Call of Duty 5: SP - Objectives

From COD Modding & Mapping Wiki
Jump to: navigation, search
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");



	// 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();


   // 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();



  // 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");


	enemy_spawners = getentarray("your_enemies", "targetname");


	// 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



    objective_state(2, "done");
    thread 3rd_objective();



	// example flag usage with objective 2

	officer = getent("officer", "targetname");
	officer Dospawn();



By Techno2SL