![]() |
#32
|
|||
|
|||
![]()
Thanks to everyone who posted about the ambulance script on this thread. I've worked on an updated version of it that is designed to work in multiuser servers (though it should work offline just as well).
- Vehicles spawn in along with you & then drive off (ie, your service vehicles just finished with getting your a/c ready, then they drive off) - When you land (full stop landing--putting chocks in will make sure) the fuel & repair trucks will come trundling up pretty soon. - Whenever you crash, even just borking up a takeoff & damaging your propeller & undercarriage, you'll soon be visited by an ambulance and a fire truck. Even if you crash out in the middle of nowhere. Only exception would be in water--they if close to the shore the emergency vehicles will do their best & drive right up to the shore. (Rescue boats will hae to come in a future version I guess. Someone to pick you up when you parachute in could be a future improvement as well.) - Vehicles mostly avoid you but if you hit them they WILL damage you. So you have to look sharp & avoid. - Vehicles travel to & from Spawn Points (ie, "Birthplace" in the .mis files) preferentially. They always travel more or less directly between the target aircraft & an area immediately around the spawn point .This gives you general control over where the vehicles appear & where they travel to/park just by moving the spawn point at your airfield in FMB. - I couldn't get the "reuse old vehicles at the same airport" code to work at all, so this simply spawns in new vehicles every time & then spawns them out after they are no longer needed. It seems to work fine so far. -You're welcome to use as is or adapt for use in your own scripts, missions, servers, etc. - It's designed to be a painless plug-in to any existing mission. It's a self-standing mission, so you just put it in your mission folder & then load it as a sub-mission during OnBattleStarted(). ZIP file with script & mission files, sample code, instructions all in one FILE: auto-generate-vehicles.cs <see separate message> The mission file is just a stub and you don't need anything in it except the headers (and maybe not even those--I haven't really experimented). It just allows your main .cs file to load the auto-vehicle-generate.cs neatly as a sub-mission. However I like to keep a minimal .mis file in place with a map, weather, etc. because then you can edit & run it easily in FMB. That is helpful for testing. Here is my sample .mis file: FILE: auto-generate-vehicles.mis Code:
[PARTS] core.100 bob.100 [MAIN] MAP Land$Online_Volcanic_Island BattleArea 6000 1700 21000 38000 1000 TIME 12 Army 1 gb Army 2 de WeatherIndex 0 CloudsHeight 1000 BreezeActivity 0 ThermalActivity 0 [GlobalWind_0] Power 0.000 0.000 0.000 BottomBound 0.00 TopBound 1500.00 GustPower 5 GustAngle 0 [splines] [CustomChiefs] [Stationary] [Buildings] [BuildingsLinks] [Airdromes] FILE: main.cs Code:
public override void OnBattleStarted() { base.OnBattleStarted(); ReadInitialSubmissions(MISSION_ID + "-auto-generate-vehicles", 0, 0); //etc . . . your code } } Code:
public void ReadInitialSubmissions(string filenameID, int timespread=60, int wait=0) { string MISSION_ID = "M001"; string USER_DOC_PATH = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // DO NOT CHANGE string CLOD_PATH = USER_DOC_PATH + @"/1C SoftClub/il-2 sturmovik cliffs of dover - MOD/"; // DO NOT CHANGE string FILE_PATH = @"missions/Multi/MyMissionFolder"; // mission install directory (CHANGE AS NEEDED - your sub-mission .mis and .cs files should be in this directory) List<string> InitSubMissions = GetFilenamesFromDirectory(CLOD_PATH + FILE_PATH, filenameID); // gets .mis files with with word filenameID in them DebugAndLog ("Debug: Loading " + InitSubMissions.Count + " missions to load. " + filenameID + " " + CLOD_PATH + FILE_PATH); foreach (string s in InitSubMissions) { //Distribute loading of initial sub-missions over the first timespread seconds //If you make each sub-mission small enough it will load without a noticeable stutter //If they are large & make a noticeable stutter, probably best to load them all very near the beginning of the mission //so that all the stutters happen at that point if ((timespread==0) && (wait==0)) { GamePlay.gpPostMissionLoad(s); DebugAndLog( s + " file Loaded"); } else { Timeout(wait + random.Next(timespread), () => { GamePlay.gpPostMissionLoad(s); }); } } } Code:
////////////////////////////////////////////////////////////////////////////////////////////////// //Listen to events of every mission public override void Init(maddox.game.ABattle battle, int missionNumber) { base.Init(battle, missionNumber); MissionNumberListener = -1; //Listen to events of every mission //This is what allows you to catch all the OnTookOff, OnAircraftDamaged, and other similar events. Vitally important to make this work! //If we load missions as sub-missions, as we often do, it is vital to have this in Init, not in "onbattlestarted" or some other place where it may never be detected or triggered if this sub-mission isn't loaded at the very start. } ////////////////////////////////////////////////////////////////////////////////////////////////// I believe that conf.ini pertains to your regular Launcher.exe process and confs.ini applies if you are running "Launcher.exe -server" as a dedicated server. Note that you will need to exit Launcher.exe, then edit and save conf.ini & confs.ini, then re-start Launcher.exe. If you don't follow this process, your conf.ini and/or confs.ini will be overwritten when Launcher.exe exits. Code:
[rts] scriptAppDomain=0 ;avoids the dreaded serialization runtime error when running server or testing missions in FMB ;per http://forum.1cpublishing.eu/showthread.php?t=34797 ![]() Again: ZIP file with script & mission files, sample code, instructions all in one Last edited by flug32; 05-22-2016 at 11:00 PM. |
|
|