Call of Duty 4: SP - Basic AI Paths

From COD Modding & Mapping Wiki
Share/Save/Bookmark
Jump to: navigation, search

By Ryokukitsune

Preface

Alrighty, so you want to start poking around in Radiant for COD 4 huh? Well so do I and as a point I like to keep notes which usually means sifting threw a lot of tutorials and figuring out how things work and clearing up a lot of things which may trip of my fellow newb so lets get started.

First things you need to know to use this tutorial,

How to use Radiant How to Build, populate and export a playable map

We need to figure out how to move our AIs.


Creating AI Paths

For this tutorial you need a simple room and an objective, for the sake of this tutorial it will simply be to have an AI move a crossed the room and take cover. Simple enough rite? Well if you’re an absolute beginner this can be extremely annoying since its not as straight forward as you think it would be though the learning curve isn’t too great and once you do it then its easy to replicate.

So aside from the room we need two more things: a player, that’s you, and an actor which is our AI. First anywhere in the room create an “info_playerstart” node and make sure its not penetrating the ground then create an actor by selecting actor>ally>marine>AR>m4grunt. Any actor will do though if you select the wrong one it might end up shooting at you during the course of the test. (don’t select axis if you don’t want to be fired on)

NOTE: depending on which actor you chose you need to make sure to add in his weapon into the zone file or you will get an error an example would be

xmodel,weapon_mp5 (the world model to see it) xmodel,viewmodel_mp5 (the view model if he dies so you can pick it up)

If you don’t add them first the map won’t load, second you will get a crashing error if you try to pick it up.

Now in order for the AI to go a crossed the room you need to place a cover node somewhere by going to node>cover>crouch.

Now for the AI to actually go places you need to trigger it, meaning that if you don’t do anything the game doesn’t do anything basically everything will be stuck in a loop until a set condition is met its a series of triggers till you achieve the end of the sequences IE beat the map.

SO we need to create a trigger. Create a large brush and place it in front of the info_playerstart node make sure it covers the width of the room (so you can’t go around it) and right click and turn it into a trigger_multiple [trigger>multiple] now select your cover node and your trigger_multiple node and hit shift+G to bring up the “Script Group Name” editor.

This is the window which assigns color groups to nodes and triggers which drive the AIs, creating a sequence of these all over the map not only moves your AIs but creates a series of events leading you to your conclusion, IE game over mission accomplished congradulations, you get a cookie… ahem…

Select the red box and click the add button then down where it says

name
script_color_allies

press OK. Congratulations you’ve made a color group. Though to get the AI to move. You need two more things.

First you need to add a piece of script to your AI.

Type exactly the fallowing two lines for key/value:

script_forceColor
r

now if you look at your trigger/cover nodes you’ll see that you have a key/value that reads

script_color_allies
r0

this means that once triggered this is the first position your AI moves to and performs the action which in our case is to take cover.

NOTE: The “script_color_allies” value of “r0” is the number in the sequence of triggers each AI[group] has if you want the AI to move again place another trigger and cover nodes with the same key/value and change “r0” to “r1” and so on and so on.

Well this is where I got hung up in the tutorial on the subject since there was absolutely no mention of anything else beyond this other than more scripting which was over my head.

If you load your map up now you have a retarded AI because things aren’t quite set up rite. You will have a world and an AI but he isn’t doing what you’ve set him up to do. He knows where to go its just he isn’t smart enough to get there on his own. Tisk tisk, stupid AIs…

Well the final piece of this puzzle is Pathnodes. A pathnode is basically an independent node which is placed in the map to guide AIs around between other nodes nodes. It’s like a landmark.

If you consider the biology of an ant colony they all move towards an objective though no one ant is smart enough to get there to do its job. Between points A and B are scent markers to guide them to their destination to do their job. Since pathnodes are something you cant see in game the concept is very similar however the process is much different.

Back in Radiant you need to create a path node [node>pathnode] in front of your AI about 5-10 units. Then copy it [Spacebar] a few dozen times every few units or so and be sure to spread them out.

Thankfully an AI is smart enough not to just move from pathnode to pathnode but unless you have enough to populate an area between cover he will just kind of stop at the lat one he knew how to get to.

If you want to specify a path for him to take create a narrow line of path nodes between him and the cover node though I recommend using at least 2 columns to get the job done or he might get lost and confused and turn around a few times. (this happened to me as I experimented with placement a bit)

Now short of lights and light volumes the map is ready to save and load. Congratulations you’re on your way to being a pro!


Map GSC

IMPORTANT EDIT:

well apparently i forgot something that is essential to the process, hey I'm human, if you don't have a valid GSC file in your raw/maps directory you can't trigger anything. you basically don't exist in the game past being a target and a camera.

you cant activate triggers or spawners and you will have no weapons unless they are picked up.

the most basic valid gsc file consists of the fallowing 3 lines:

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


Sources: Modsonline.com