Storm of War Teamspeak

C# Script tutorial: Knocking out airfields

Tutorials, help, questions or code snippets

Re: C# Script tutorial: Knocking out airfields

Postby TWC_Fatal_Error » Fri Jul 07, 2017 5:39 pm

Red am i grasping this right?

Code: Select all
    public Dictionary<string, bool> AllBombableTargets = new Dictionary<string, bool>();

   //Dictionary to hold all targets names and true false// not just airfields
   //The first thing we need to do is tell the game which our airfield targets are. We do this via this
   //function, which simply adds the airfields and all of our bombable targets to the dictionary above.
       public void SetAllBombableTargets()

                                    AllBombableTargets.Add("Abbev",true);// this is the name for the airbase or bombable target area???
                                    AllBombableTargets.Add("Liges",true); //You'd just repeat this line for each airfield you wanted //to add as a target.   
                                    AllBombableTargets.Add("Arras",true);// this would be an area not an airfield but would have been included in the list made earlier corect?
                                    AllBombableTargets.Add("AbbevFuel",true);   //same here not airfield
                                    AllBombableTargets.Add("BapumeRail",true);//same here not airfield
                                    AllBombableTargets.Add("ArrasFuel",true);//same here not airfield
                                    AllBombableTargets.Add("Liges",true);// back to an airfield
   //We need to fire this function from somewhere though, so we do this using the OnBattleStarted event which gets fired strangely enough when the Battle starts!.

    public override void OnBattleStarted()

//Now we need something which will actually do the work. This function removes all spawnpoints,
//reloads the non destroyable file and then loads in the target files as required. You will need
// to put your mission folder name in the path below.
//(Probably should add that as a Global variable actually!)

    public void LoadAirfieldSpawns ()

        foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces())

            bp.destroy();//Removes all spawnpoints
        GamePlay.gpPostMissionLoad("missions/YOUR MISSION FOLDER HERE/nondestroyable.mis");// wrote a mission with //things i didn't want destroyed

       foreach (string ap in AllBombableTargets.Keys) {// this is a reference to the list created
        if(AllBombableTargets[ap]) {
            //Airfield still active so load mission
            GamePlay.gpPostMissionLoad("missions/YOUR MISSION FOLDER HERE/"+ap+".mis");// loads the mission for  field with spawns active and functions normal ????

//Lastly you need to set the boolean to false when the trigger fires (ie you've destroyed the target)
// and load the airfields again. We do this as follows.

    public override void OnTrigger(int missionNumber, string shortName, bool active)
        base.OnTrigger(missionNumber, shortName, active);// here the actual name of the trigger is called
        if ("Abbev".Equals(shortName) && active)
            GamePlay.gpGetTrigger(shortName).Enable = false;
            LoadAirfieldSpawns ();// this could be left out for targets such as fuel   yes????
            GamePlay.gpLogServer(null, "Abbeville Destroyed!", new object[] { });
            LoadTargeDestroyedMission (MISSION_ID + "-" + "tar_Abbev_destroyed");// loads mission with smoking holes in the //ground and destroyed equipment
        if ("Barly_Heavy".Equals(shortName) && active)//name of trigger and checking to make sure is set to true?
            GamePlay.gpGetTrigger(shortName).Enable = false;
            AirfieldTargets["Barly_Heavy"]=false;//set trigger to false
            LoadAirfieldSpawns ();// but not the one in Barly since it reads as false
             GamePlay.gpLogServer(null, "Barly Destroyed!", new object[] { });// notify destruction of base all players in server log
             LoadTargeDestroyedMission (MISSION_ID + "-" + "tar_Barly_destroyed");// loads the mission with destruction of airfield and no spawns
        if ("AbbevFuel".Equals(shortName) && active)// looks for next trigger next trigger repeat for all targets in BombableTargets
            GamePlay.gpGetTrigger(shortName).Enable = false;
           // LoadAirfieldSpawns ();// just remmed out this line since the target is not a spawn point
            GamePlay.gpLogServer(null, "Abbeville Fuel Destroyed.", new object[] { });
    //// And more like above for all targets Blue and then a similar call out for RED/////////
//    I've used the same naming convention through out for the target1 etc. In truth as
//long as the entry in the dictionary and the mis file name are the same, it doesn't matter
// what the trigger name is, but for sake of consistency I would advocate making it so. Obviously
// you could add your own confirmation message to the trigger to say that the target is destroyed,
// the base is removed etc, but I'm trying to give you easy to use functions rather than script the
// mission for you.

//Next up, removing spawns based on bomb weight.
i7,16 gigs,780, ed tracker,3 ssds,
3 screens: 60 main 24 instruments 8 comms
Warthog ,2 mfd's and thrustmaster rudders
800 watts sound {will vibrate the dishes of the mantle in the living room 20 feet away}
understanding and supporting wife!!
Posts: 30
Joined: Thu Oct 30, 2014 12:30 pm


Return to Full Mission Building & C# Scripting

Who is online

Users browsing this forum: No registered users and 1 guest