Call of Duty 5: SP - Objectives
From Mods Repository Wiki
World at War SP Objective can be achieved in a variety of ways but the easiest is to add the objective to the list, set it as the current objective and then have a condition that waits until it's complete.
Example below shows a "clearing a building" type Objective
/* Lets sort out our utilities first */ #include maps\_music; #include maps\_utility; #include maps\_anim; #include common_scripts\utility; #using_animtree ("generic_human"); main() { maps\_load::main(); // maps\yourmapname_anim::main(); // maps\yourmapname_fx::main(); // precache any models used in your objectives here // precacheModel("weapon_explosives"); // FLAGS - set any flags you might want to use // flag_init("example_flag"); // best way to spawn 4 players, just get 4 script structs in your map with targetname initial_spawn_points structs = getstructarray( "initial_spawn_points", "targetname" ); flag_wait( "all_players_connected" ); players = get_players(); for( i = 0; i < players.size; i++ ) { players[i] setorigin( structs[i].origin ); players[i] setplayerangles( structs[i].angles ); } // the players are in the level, now we can thread to our first objective thread 1st_objective(); } 1st_objective() { // Lets add an objective for the players, this is our first, so 1, it's the current objective and // YOURMAPNAME_OPENDOOR will call on a string reference in raw\english\localizedstrings\yourlevelname.str // the last part, marker.origin is where our objective marker will be displayed in reference to the compass // simply place an entity like a script_origin at the objectives location, give it a targetname and call it before our objective line marker = getent("yourobjectivemarker", "targetname"); objective_add( 1, "current", &"YOURMAPNAME_OPENDOOR", marker.origin ); // get_closest( level.players[0], marker.origin ) ); objective_current(1); //current objective // Now we need to have a condition for our objective, let's say the player needs to open a door, we'd simply get the trigger // on the door and wait for the player to use it trig = getent("doortrig", "targetname"); trig waittill ("trigger"); objective_state(1, "done"); thread next_objective(); thread officer(); } next_objective() { // so once objective 1 is done we can set the next one - this will be clearing enemies // First of all lets spawn the enemies, we can rely on a trigger for now, otherwise spawn the enemies in the script. But either way // Always wait for the enemies to spawn before using any funcs on them // example of using coords as the marker objective_add( 2, "current", &"YOURMAPNAME_KILLGUYS", (264, -497, -36) ); objective_current(2); //current objective // our trigger obj2trig = getent("objective_2", "targetname"); obj2trig waittill ("trigger"); wait(1); enemy_spawners = getentarray("your_enemies", "targetname"); wait(1); // If your enemies have a count on them, so they spawn multiple times, deplete the count in script first or make sure there's // a killspawner trigger before the player can get in sight of/kill the last enemy so that no more enemy respawn after the // objective is complete - this will wait for the enemy + their officer to be killed waittill_dead(your_enemies); flag_wait("example_flag"); objective_state(2, "done"); thread 3rd_objective(); } officer() { // example flag usage with objective 2 officer = getent("officer", "targetname"); officer Dospawn(); waittil_dead(officer); flag_set(example_flag); }
By Techno2SL
Sources