Call of Duty 4: SP - Objective Basics

From COD Modding & Mapping Wiki
Share/Save/Bookmark
Jump to: navigation, search
Nutshell.png
This guide will tell you how to create objectives in COD4 easily as well as infinite health for your teammates.
  • First create your world in radiant. Then create a trigger brush anywhere you like. This is where you would have to go to complete the objective. Make sure the trigger brush is trigger_multiple.
  • Then fill in this:
Key: targetname
value: obj1
  • If you want more objectives, create more triggers. Replace the value with obj2, obj3 and so on.
  • To make an actor an objective, create the actor and give him the key of targetname and value of obj#.
  • After you're done, finish your map and save!
  • Complie your map!

Now is the time for scripting. It's fairly simple. Copy and paste this in your gsc file.

main()
{
	maps\_load::main();

	level.player takeallweapons();
	level.player giveWeapon ("m16_basic"); //use whatever gun you want
	level.player giveWeapon ("g36c"); //same
	level.player switchToWeapon ("g36c"); //pick the gun you want to hold
	level.player giveWeapon ("fraggrenade");
	level.player giveWeapon ("flash_grenade");
	thread obj1(); //call your objectives
}

obj1()
{
	obj1 = getent("obj1", "targetname"); //the game finds the trigger
	objective_add(1, "active", &"mapname_OBJ1",getent("obj1","targetname").origin); //add obj.
	objective_current(1); //current objective

	obj1 waittill("trigger"); //wait till the trigger is triggered
	objective_state(1, "done");
	obj1 delete(); //deletes it

	wait 2; //fill in however long you like (in seconds)
	thread obj2(); //thread next objectives.
}

obj2()
{
	obj2 = getent("obj2", "targetname");
	objective_add(2, "active", &"mapname_OBJ2",getent("obj2","targetname").origin);
	objective_current(2);

	obj2 waittill("trigger");
	objective_state(2, "done");
	obj2 delete();

	wait 2;
	thread obj3();
}

obj3()
{
	obj3 = getent("obj3", "targetname");
	objective_add(3, "active", &"mapname_OBJ3",getent("obj3","targetname").origin);
	objective_current(3);

	obj3 waittill("trigger");
	objective_state(3, "done");
	obj3 delete();

	wait 2;
	iprintlnbold (&"mapname_OBJ_COMPLETED"); //tells player obj finished
	missionSuccess ("fun",false); //the mission ends
}

The script above is for trigger objectives. For actors replace

obj# waittill("trigger");

with

obj# waittill("death");
  • You can add more objectives if you like. Just repeat.
  • You're done the gsc file but scripting is not done yet!
  • create a mapname.str in your main/localizedstrings folder.
  • Copy this:
VERSION             "1"
CONFIG              "F:\projects\mk\bin\StringEd\StringEd.cfg"
FILENOTES           ""

REFERENCE           OBJ1
LANG_ENGLISH        "Get to the centre of the road. Clear out the road block." //change to whatever you want for your objective.

REFERENCE           OBJ2
LANG_ENGLISH        "Get to your teammates!" //same

REFERENCE           OBJ3
LANG_ENGLISH        "Get on the truck." //same

REFERENCE           OBJ_COMPLETED
LANG_ENGLISH        "All Objective Completed!"  //same

REFERENCE           OBJECTIVES
LANG_ENGLISH        "Press ^3[{+scores}]^7 to check your Objectives" //reminder

ENDMARKER

You can add more references for more objectives. Just add OBJ4, OBJ5, etc.


That's it you're done!


Time for infinite health. This is very simple.

  • In radiant, create some actors or just one. Give them a targetname of ally or whatever. You're done in radiant!

Script time!

I can't call the script from another gsc file because I don't know how to get it to work. Just copy and paste into your main gsc file.

thread ally_nodamage(); //whatever value you like for thread

ally_nodamage() //whatever you called above
{
	allyteam = getentarray ("ally", "targetname"); //what you named
	for(i=0; i<allyteam.size; i++)
		allyteam[i] thread maps\_utility::magic_bullet_shield(); //infinite health
}

You're done! The infinite health works great for heroes or any regular actors, but not you, the player, unfortunately. Also thanx to this post and everyone who helped me on this topic.


Combine both tutorials together you get this. My map as an example.

main()
{
	level.weaponClipModels = [];
	level.weaponClipModels[0] = "weapon_m16_clip";
	level.weaponClipModels[1] = "weapon_ak47_clip";
	level.weaponClipModels[2] = "weapon_g36_clip";
	level.weaponClipModels[3] = "weapon_mp5_clip";

	maps\_load::main();

	level.player takeallweapons();
	level.player giveWeapon ("m16_basic");
	level.player giveWeapon ("g36c");
	level.player switchToWeapon ("g36c");
	level.player giveWeapon ("fraggrenade");
	level.player giveWeapon ("flash_grenade");
	thread ally_nodamage();   //  executes ally_nodamage() function
	thread obj1();
}

ally_nodamage()
{
	allyteam = getentarray ("ally", "targetname");

	for(i=0; i<allyteam.size; i++)
		allyteam[i] thread maps\_utility::magic_bullet_shield();
}

obj1()
{
	obj1 = getent("obj1", "targetname");
	objective_add(1, "active", &"streetclearing2_OBJ1",getent("obj1","targetname").origin);
	objective_current(1);

	obj1 waittill("trigger");
	objective_state(1, "done");
	obj1 delete();

	wait 2;
	thread obj2();
}

obj2()
{
	obj2 = getent("obj2", "targetname");
	objective_add(2, "active", &"streetclearing2_OBJ2",getent("obj2","targetname").origin);
	objective_current(2);

	obj2 waittill("trigger");
	objective_state(2, "done");
	obj2 delete();

	wait 2;
	thread obj3();
}

obj3()
{
	obj3 = getent("obj3", "targetname");
	objective_add(3, "active", &"streetclearing2_OBJ3",getent("obj3","targetname").origin);
	objective_current(3);

	obj3 waittill("trigger");
	objective_state(3, "done");
	obj3 delete();

	wait 2;
	iprintlnbold (&"streetclearing2_OBJ_COMPLETED"); //Let player know he is done
	missionSuccess ("dawnville",false);
}

Thanx for reading, hope you make great Single Player maps!

Source files.


P.S. This Tutorial can be used for all COD games.

By sam_fisher3000


Related Links:

Sources: Modsonline.com

--CoDEmanX 02:43, 29 July 2009 (UTC)