Characters (also called chars, bots, pedestrians or peds, although the last two tend to refer to the generic pedestrians roaming the streets) are very important when creating missions or similar code structures. They can be given various AI's and objectives.
Creating characters
Chars created in the script with the CHAR_DATA command.
CHAR_DATA name //declare name = CREATE_CHAR ( X.x , Y.y , Z.z ) remap rotation occupation END //set CHAR_DATA name = ( X.x , Y.y , Z.z ) remap rotation occupation //declare & set
name | Unique name of the char |
---|---|
( X.x , Y.y , Z.z ) | The coordinates |
remap | The outfit you want the char to have. Each remap has it's own number, see the list below. |
rotation | The direction the car should face. |
occupation | Which AI the char should have, see the list below. Each AI has it's own set of responses to situations in combination with its objective. For example, a FBI AI with the objective to kill you will pull you out of your car and chase you to fire at close range, while a DUMMY with the same objective will fire at you car from a distance. |
Example
If you want a dummy pedestrian who looks like Elvis at 126.5 , 112.5 , 2.0, the code looks like this:
CHAR_DATA ped = ( 126.5 , 112.5 , 2.0 ) 12 180 DUMMY
Adding objectives
Just creating a character isn't really exciting; most of the times you will end up with a character wandering around aimlessly. Let's give him an objective to make things interesting.
SET_CHAR_OBJECTIVE ( name , objective ) SET_CHAR_OBJECTIVE ( name , objective , second_item ) SET_CHAR_OBJECTIVE ( name , objective , X.x , Y.y , Z.z ) SET_CHAR_OBJECTIVE ( name , objective , X.x , Y.y , Z.z , rotation , distance )
name | Name of the char | ||
---|---|---|---|
objective | The objective the char should have. This can be any of the following: | NO_OBJ | Make the char wander around doing nothing. |
WAIT_ON_FOOT | Make the char wait on his current location until something happens | ||
FLEE_ON_FOOT_TILL_SAFE | Make the char flee untill he thinks he is safe. | ||
GUARD_SPOT | Make the char guard his current location | ||
GUARD_AREA | Make the char guard his current are | ||
WAIT_IN_CAR | Make the char wait inside his current car without driving of. | ||
second_item | The next objectives require a second character, object, etc. to be declared: | KILL_CHAR_ON_FOOT | Make the char attack another char until he's dead. If the target char is out of reach he will chase him on foot. |
KILL_CHAR_ANY_MEANS | Make the char attack another char until he's dead. If the target char is out of reach he will spawn a car and teleport close to the target. The char is only able to locate far away targets when the target is on a road. | ||
FLEE_CHAR_ON_FOOT_TILL_SAFE | Make the char flee from another character on foot until he thinks he's safe. After this, he'll start walking around normally. | ||
FLEE_CHAR_ON_FOOT_ALWAYS | Make the char flee from another character on foot forever. | ||
GOTO_CHAR_ON_FOOT | Make the char chase another char until he reaches him. After this, he';; start walking around normally. | ||
LEAVE_CAR | Make a char leave his car. | ||
ENTER_CAR_AS_PASSENGER | Make a char entering a car through the passenger door. | ||
ENTER_CAR_AS_DRIVER | Make a char entering a car through the drivers door. | ||
FOLLOW_CAR_IN_CAR | Make a char follow another car. Make sure the char is inside a car when using this command! | ||
FIRE_AT_OBJECT_FROM_VEHICLE | Make a char fire at a object from a tank. Make sure the char is inside a tank when using this command! | ||
DESTROY_OBJECT | Make a char attacking an object. | ||
DESTROY_CAR | Make a char attacking a car. | ||
X.x , Y.y , Z.z | The next objectives require coordinates to be declared: | GOTO_AREA_ON_FOOT | Make a char go to the coordinates on foot |
GOTO_AREA_IN_CAR | Make a char go to the coordinates on foot | ||
rotation , distance | This objective needs a rotation (0-359) and a distance in blocks (0.0): | FOLLOW_CAR_ON_FOOT_WITH_OFFSET | Make a char follow a car on foot. The rotation tells the char where to chase the car (270 is from the left, for example) and the distance tells the car how close he should stay to the car. |
Example
Lets create an army soldier who wants to kill the player at all costs.
CHAR_DATA soldier = ( 126.5 , 112.5 , 2.0 ) 4 0 ARMY SET_CHAR_OBJECTIVE ( soldier , KILL_CHAR_ANY_MEANS , player )
If you try this, you'll encounter a soldier who attacks you with his bare hands. That's no good, so we have to give him a weapon. Also, he'll be chasing you in a brown Benson, which doesn't suit his him very well either. Lets give him a Armed Land Roamer and while where at it, why not telling him to use the jeep gun.
GIVE_WEAPON ( soldier , MACHINE_GUN ) SET_FAVOURITE_MODEL ( soldier , GUNJEEP ) SET_CHAR_TO_USE_CAR_WEAPON ( soldier , ON )
Remaps
|
Occupations
|
Mapping | Map Editor · Buildings · Roads · Water & animations · Slopes · Flat tiles · Collision info · Level edge · Zones · Putting a level ingame | |
---|---|---|
Scripting | Declarering: | Main script · Script Compiler · Code lists · Commands · Vehicles · Objects · Sounds · Characters |
Programming: | IF · WHILE · COUNTERs · Subroutines · THREAD TRIGGERs · Kill Frenzies | |
Both | Manual · Lighting · Car shops · Cranes & crushers · Gangs · Subway · Multiplayer levels | |
File types | .gci · .gmp · .gxt · .mis · .mmp · .scr · .seq · .tmp · .sty | |
Other | Texting · Physics · Creating vehicles · Terminology · Installing levels |