Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 69 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Tutorials

»
CoD Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
AI Scripting Basic Training: Squad Scripting Tutorial
Versions: You must be logged in to view history.
Scripting friendly AI for SP maps
 

Introduction:

So you want to make your first Single Player mission, eh? Where do you start? Well, you need a map don't you? Alright, alright, so you already have a map. What? Your squad mates and Jerries aren't moving? Why? Why dear God, why?! Ummm... Calm down, I'll hold your hand through this! AI scripting is not as hard as you may think. You just need time and patience. Unfortunately for the modding community we don't have as much support as we would like. Hell, I'd jump off a cliff just for a web dictionary of all the available keys and commands! Until recently though, we knew about as much to scripting CoD as the U.S. is aware of weapons of mass destruction in Iraq. We just didn't know, period. What I'm going to try to do is shed some light on this based on my experiences, and darn it works!

Disclaimer:

A few notes... First, don't use the quotations when entering in names and values. The compiler doesn't like it! Second, the files that I made and used can be found for download at the bottom of the page. If you really need some help please visit the CoD forums found throughout the web. I would love to answer and help everyone but the military keeps me busy and I simply don't have the time. If you do PM me, I will try hard to help though.

Your First Step:

First, you need to fire up Cod Radiant and get in grid size eight if you haven't already. You need to make a small room, like the one showed below. Texture this puppy anyway you want it, cause I couldn't care less! You then need to make a player_start entity (right-click, info->player_start). Now, press "n" to bring up the entity properties box. In the "Key" input line, enter "targetname". This is basically a reference name you would use in order to link or call it. In the "Value" line you would enter the name of the entity (anything except player_name I believe). I named mine "chainme", because we are going to chain the others to it. Oh, click the pictures below to expand them and get a clearer idea of what is going on!

So there we go! Now you have a player_start entity ready for action!

Step Two:

Ok, what we are going to do now is make some teammates to join you. You will now right-click again and select actor->whatever you want to make. As you can see I made three teammates; one BAR, one medic, and one rifleman. Bring up the properties box again and this time in the "Key" line you will enter "target". This will make the entity target whoever (don't get creative and target enemies and stuff just yet!). In the "Value" line now, enter "chainme". You will now see an arrow connecting that entity to the player_start entity. This means it is now chained, sort of. Go through the others and chain them as well. (Tip: If you then enter in the "Key" line, "script_friendname" you can enter in "Value" the name you want to show, just like in the Single Player game! For example, "Cpl. Beye")

Alright, you are off to a good start! Lets move on...

Step Three:

Ok, it's going to get a little more difficult now. Get ready... First, I hear a lot "I have some pathnodes but my guys don't follow it!" Get pathnodes out of your head when it comes to actually making your squad move. Let me explain. Pathnodes are actually used to tell the game where the entity can travel. You would use them to bound the entity to that path. The other nodes, i.e. cover_crouch or cover_prone, are your money makers. They actually tell the game to do something. Say you have a cover_crouch entity on one side of the map and a cover_left on the other and the middle of the map is one big minefield. You would put pathnodes from the first node, cover_crouch, around the perimeter of the map to the other node. This would tell the game, "Hey, I don't feel like having my ass sent home in five boxes." The best part is that the game automatically knows what they are used for so you don't need to target each one together. Get it? Got it? Good! Ok, moving on... You will first need to create a "Trigger AI" brush over your player_start entity. Press "n" and use the scrollbar to find the trigger_friendlychain. Click it twice and close the dialog. What this does is say that you and buddies are now chained, a team that reacts together, and when you spawn you will trigger it, since it is right over you. Now create another entity, right-click and then node->cover_crouch. In the "Key" enter "targetname" and for "Value" enter "auto31" (the name can be whatever is easiest. I recommend that you use a number scheme to remember). See below for a useful shortcut about linking nodes! Now make another "Key", "target" and use "auto32" as a "Value". Now for the second node (I used cover_crouch again) use "auto32" for the "targetname" and "auto33" for the "target". Once again for the last one I used "auto33" for the "targetname" and did NOT use a target. Why? This will be the end of this particular movement. The cool thing is that we now have three node entities and three actors. Each actor will assign itself to one node so they don't crowd the individual ones. Sweet, huh?! Now that the node entities are connected go back to the "AI Trigger" brush and press "n". For "Key" enter "target" and "Value" enter "auto31". When you spawn the trigger will chain you all and go to node "auto31". Now if you save this map and compile it, your squad will move up to their positions. Oh, if they are slow moving and you don't have any weapons, don't worry... We will fix that!

You are almost there!!

The BIG Step Four:

Now that you understand the previous step, the rest easy!! All I did here is make another "AI Trigger" next to the last node entity we made. I made it a "friendlychain" just like before as well. I then added another three nodes which do the same thing as the other ones. The only difference is that I made the names of them "auto41", "auto42", and "auto43". Hopefully, if you paid attention to the earlier step, you will know what to do to link these! Don't forget the "AI Trigger" brush! You need to tell him who to target too!

Now, if you got overzealous and compiled it and ran it, you will notice that they don't move past the first set of nodes. Why? Well, I'll tell ya!

Step Five:

Like I said earlier, the pathnode entity is use to define a path to be taken when ordered by the other nodes. This is why the squad doesn't move past the first set. They simply don't know what to do! As you can see below, all you need to do is define the path you want to take. I find placing one pathnode in the middle of a 8x8 square perfect for now. Now if you run it they will move to the second position once you past the trigger. Cool huh?!

Now you know the basic of getting your squad to move. Of course there is more but you should focus on mastering the basics first. In essence, all you need to do is tell the squad where to go with the nodes and they take care of the Jerries, or vice versa! Now, you will want a small little GSC file in the same place the map file is and compile it. Pretty simple, just add this to a notepad document:

// This script was made by Seeded[USAF] on December 26th, 2003.

main()
{
//Loads all the global scripts... Just use it!
maps\_load::main();

// This little bit equips you with some weaponry. You need specifiy which items to equip your character.
level.player takeallweapons();
level.player giveWeapon("m1carbine");
level.player giveWeapon("thompson");
level.player giveWeapon("colt");
level.player giveWeapon("fraggrenade");
level.player switchToWeapon("thompson");

}

Now go to "Save As" and and enther this (quotations and all): "mapname.gsc". The quotations tells notepad that you are defining the file extension something different than the default, and mapname is the name of your map.

You you can go experiment and next time I will discuss enemy AI and how to make an opponent to scrap with! Till then... Peace!

Click here for the source files.

Tips and Hints:

Now that you understand how to assign nodes and link them, use this handy trick. Select your first node, then the second one. Press Ctrl+k to have the editor automatically name and target the second node. This saves valuable time!!

Written by Seeded[USAF]

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»