Demo mission
From NexusWiki
Contents
Heading
MISSION 1 //mission number Name "Demo Mission" //name of the mission DefLocation "NAV_CHAKRIS_IV" //the location where the mission will take place OBJECTIVES //in here we place the number of objectives that will be includid in the mission 1 2 3 END
SceneInit
RULES RULE event sceneInit :action SetSceneRadius(100000); //this is, as the name suggests it, the radious in meters of the scene. GuiSelect(0); //this is required to start a cinematic scene SetRelation(#race_player, #race_spacetech, 2); SetRelation(#race_player, #race_gorg, 2); SetRelation(#race_gorg, #race_player, 2); SetRelation(#race_spacetech, #race_player, 2); SetRelation(#race_player, #race_Human_E, 1); //the relations between the races that will appear in //the game. the "race_player" is the playable race, //and the number mean what sort of relationship they //share with other races, more info on that is //located on the modding manual sp := GetSceneObj("Mayflower"); bs := GetSceneObj("Hawkeye"); //in here we define the "Scene Objects", the ships and other //interactive obects drone := GetSceneObj("Nightingale"); gorg1 := GetSceneObj("Feral"); gorg2 := GetSceneObj("Darkclaw"); Disappear(drone); Disappear(gorg1); Disappear(gorg2); //we disappear the ships that are bound to appear via ip drive FadeScreen(1, 0, 0); //we "fade" the screen, make it black Playmusic(1); //in here we set the number of the music track (as defined in the //mod_sound.ini file, in the universe\engine\ folder GetMachine("Director"):ChangeState(IntroMovie, 0); GetMachine("Objectives"):ChangeState(monitor,0); // with these commands we "call" the machines //that would define the game, and their given // state :end END
Body
MACHINE "Director" STATE IntroMovie RULE event In :action Delay(0,1, FadeScreen(0, 2, StartMission); //we "unfade" the screen, and as defined by the command, when the fading finishes the "StartMission" event will be fired SelectDevices(1, m.bs, s.this:devtype=#weap_miss3); //we select the missile batterie Execlist(1, LoadWeapon(s.this, -100)); //we unload the weapon. Don't worry, I'll explain the execlist command later along the way. ,0); :end END Rule event StartMission :action CamMoveAndTurn(m.bs, 2000, m.drone, 4, 10); //we move the camera to see the // "drone" ship from the perspective of //the "bs" ship (more info in the manual). Title(0,0,0,"Demo Mission"); //we play a title (obviously) Delay(0,10, Guiselect(3); //we wait 10 seconds (the ammount of time that will take the //camera to stop moving) to stop the simple cinematic Dialog("demo_1",0,0); //we bring upon the 1° string of dialogs, when one of //them finishes (or is interrupted by the player) the //following will appear. Dialog("demo_2",0,0); Dialog("demo_3",0,0); ,0); :end END Rule event SecObj //this event is fired when the last dialog expires, and is called via the "ExpireEvent" //command, as you can see the demo.ini file in the \texts\dialogs\ folder :action Title(0,0,0,"objective_1_2"); //we display the second objective MissionObjective(2, #OBJECTIVE_UNCOMPLETED); //and we make it so it appears on the //"objectives" screen SetArea(1, m.sp, 5000); Timer(Arrival, 10, 0); //this event fires a localevent with a given delay, for more //info, check the "timer" command :end END Rule event AreaEntered condition e.ship=m.bs&e.area=1 //this is an other special rule, it's fired when a ship enters a //given area. E.ship, the ship and e.area the area. :action Engines:=GetFreeSel(); //we start a list with this command SelectDevices(Engines, m.bs, InSet(s.this, 52) | InSet(s.this, 53) | InSet(s.this, 54)); //in here we select all the devices that fall under the 52 and 53 "sets" (normal and secondary engines). //Check the tacticstypes.ini for more info. Execlist(Engines, EnableDevice(s.this,0)); AddItem(1, m.bs); AddItem(1, m.sp); traffic1 := StartTraffic(1, 2); //we start some "traffic", small ships that will //travel from one ship to the other. Delay(0,40, /*we wait some time for the ships to finish some travels*/ Execlist(Engines, EnableDevice(s.this,1)); //and we let our ship move again SelectDevices(1, m.bs, s.this:devtype=#weap_miss3); Execlist(1, LoadWeapon(s.this, 13)); //we load the weapon EndTraffic(traffic1); //we end the traffic MissionObjective(2, #OBJECTIVE_COMPLETED); //and we tell the player that the //objective has completed ,0); :end END Rule event Arrival :action LongRangeArrive(m.drone); //with this command we make the ship appears using it's //ip drives :end END Rule event RunAway //this is also a special event, is only fired when a ship leaves the scene using the ip //drives. condition e.ship=m.bs // we check if the player decides to leave the scene :action if(MissionObjective(2) = #OBJECTIVE_UNCOMPLETED, MissionObjective(2, #OBJECTIVE_FAILED)); if(MissionObjective(1) = #OBJECTIVE_UNCOMPLETED, MissionObjective(2, #OBJECTIVE_FAILED)); //we check wether these objectives have been completed or not, and if not, then we mark them as failed Delay(0,5, uQuitMission(0),0); :end END Rule event LongRangeArrived condition e.ship=m.drone /* this is a special rule, and it is only fired when a ship appears by means of an ip drive. In this rule the variable "e.ship" refers to the ship that appeared, so with the "condition" line we check that it matches the "drone" from our scene obj */ :action MakeFullyknown(e.ship); //with this command we detect the ship FreezeReconState(e.ship,1); //and with this other command we make sure it stays that //way. SelectDevices(1, m.drone, 1); //with this rule we efectibly select all the devices of //a given ship, "m.drone" Execlist(1, EnableDevice(s.this,0)); /* for those familiar with basic programing, the execlist command works a bit like a "for" thing, where the objects to be replaced are the items of the list placed in that rule, (in this case, the "1", all the devices of the "m.drone" ship, and then replace "s.this" with each item until it reaches the very end, like a for rule. And for the ones that don't know what a for rule is... well... look it up :P nah, kidding. What I did here was run every item from the list "1" with a "EnableDevice" rule (again, look what that means in the modding manual) */ Title(0,0,0,"objective_1_1"); //we display the first objective MissionObjective(1, #OBJECTIVE_UNCOMPLETED); //and we make it so it appears on the //"objectives" screen :end END Rule event Fataldamaged condition e.ship=m.drone //like the longrangearrived rule, this is also a special one, that will //only be fired when a ship is wrecked (not destroyed). E.ship is the wrecked ship. :action MissionObjective(1, #OBJECTIVE_COMPLETED); //with this we show that the objective //has been, of course, completed. Delay(0,10, Dialog("demo_4",0,0); LongRangeArrive(m.gorg1); LongRangeArrive(m.gorg2); //I know this is a cliche... but what //the hell. When the practice drone is done for, I //make two gorg ships appear from hyperspace. ,0); :end END Rule event LongRangeArrived condition e.ship:race=#race_gorg //with this we place a condition that the incoming ship must //belong to the gorg race to be valid for the rule :action MakeFullyknown(m.gorg1); //with this command we detect the ship FreezeReconState(m.gorg1,1); //and with this other command we make sure it stays //that way. MakeFullyknown(m.gorg2); //with this command we detect the ship FreezeReconState(m.gorg2,1); //and with this other command we make sure it stays //that way. ChangeState(Next,0); //we change the state. Note that from every machine only one //state can run at a time, so everything that was in this //state will effectibly stop working. :end END END //state IntroMovie State Next Rule event in :action if(MissionObjective(2) = #OBJECTIVE_UNCOMPLETED, MissionObjective(2, #OBJECTIVE_FAILED)); //which means that if you didn't accomplish the second objective by now, then your time is over amigo, now you have other priorities. SelectShips(1, s.this:race=#race_gorg); //we select every ship that belongs to the //gorg race Execlist(1, s.this:tMoveTo(m.bs, 2, 0)); //and using the execlist rule (the one that //was like a "for", remember?) to move them against our ship. Dialog("demo_5",0,0); :end END Rule event Flee //an other event that is called by a dialog ending. again, check the demo.ini file for //more details. :action MissionObjective(3, #OBJECTIVE_UNCOMPLETED); Title(0,0,0,"objective_1_3"); //same as before. SelectDevices(1, m.sp, s.this:devtype=#supp_longrange); //in this time we select //only the devices (or device) matching an specific criteria, that it must //belong to the devicetype #supp_longrange, the ip drive. Execlist(1, ActivateDevice(s.this,1)); //and we activate the device. Simple. :end END Rule event RunAway condition e.ship=m.bs //we check that leaving ship is our own :action if(MissionObjective(3) = #OBJECTIVE_UNCOMPLETED, MissionObjective(2, #OBJECTIVE_FAILED)); //as before, if you didn't complete the objective, then you failed it. Delay(0,10, uQuitMission(1),0); //and finally we quit to a "you've won!" screen :end END Rule event Fataldamaged condition e.ship:race=#race_gorg :action SelectShips(1, s.this:race=#race_gorg); //we select all the gorg ships and we place //inside one list, labeled as "1" (note that using a number is not mandatory) If(AllNumOf(1) = 0, ChangeState(mission_won,0)); //and we check the number of //elements of that list, and if //that is number is 0 it means that the //list is empty, thus, no more gorg ships. :end END Rule event Fataldamaged condition e.ship=m.bs //well, this means that this event will be fired only if our ship suffered //terminal damage, and thus, you've lost the mission :action Delay(0,10, uQuitMission(0),0); :end END END //state next State Mission_won rule event in :action MissionObjective(3, #OBJECTIVE_COMPLETED); Delay(0,10, uQuitMission(1),0); //and we finish the mission. :end END END //state mission_won END //Machine "Director" Machine "Objectives" State Monitor Rule event in :action //in here we set the common, starting parameters of the mission, like the initial //objectives MissionObjective(1, #OBJECTIVE_HIDDEN); MissionObjective(2, #OBJECTIVE_HIDDEN); MissionObjective(3, #OBJECTIVE_HIDDEN); SetObjectivePrimary(1,1); SetObjectivePrimary(2,0); SetObjectivePrimary(3,0); //in here we set wether an objective is or not primary :end END END //Monitor END END
Entities
ENTITIES SHIP Name "Hawkeye" Race #race_Player ShipType #styp_ep6_Siege_Battleship Position -1000 838 -8966 Orientation 0 0 0 NPC Name "Johan Mastropiero" ID 1 Face 20 Rank 3 Medals ; CrewLevel 1 Skill 1 0 Skill 2 0 Skill 3 0 XP 0 END END SHIP Name "Nightingale" Race #race_SpaceTech ShipType #styp_Frigate Position 2441.14 -8877.7 2618.99 Orientation 180 0 0 END SHIP Name "Mayflower" Race #race_Human_E ShipType #styp_Supportship Position -12843.8 -1399.87 -5833.99 Orientation 0 0 0 NPC Name "James Carson" ID 2 Face 26 Rank 2 Medals ; CrewLevel 1 Skill 1 0 Skill 2 0 Skill 3 0 XP 0 END END SHIP Name "Feral" TechCat 31 20 TechPointsScanned 0 Race #race_Gorg ShipType #styp_ep6_gorg_escortcruiser Position -5890.52 -22.7949 7108.39 Orientation -92.7069 -36.0036 47.6695 END SHIP Name "Darkclaw" TechCat 31 30 TechPointsScanned 0 Race #race_Gorg ShipType #styp_ep3_gorg_heavy_battleship Position -5892.08 769.904 6509.39 Orientation -92.7069 -36.0036 47.6695 END END
Life is short, and this article saved vlaubale time on this Earth.
Objectives
Also, read this before copying these lines into a file!
TEXT "objective_1_1" 0 "Destroy the drone" END TEXT "objective_1_2" 0 "Approach the support ship to have your missile bank filled up" END TEXT "objective_1_3" 0 "Destroy the Gorg ships" END