GTAGames.nl advertentie

Creating characters (GTA2)

From WikiGTA - The Complete Grand Theft Auto Walkthrough
Jump to: navigation, search

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

Code Character
0 Cop
1 Green SWAT cop
2 Red SWAT cop
3 Yellow SWAT cop
4 Soldier
5 Redneck #1
6 Redneck #2
7 SRS Scientist
8 Zaibatsu
9 Hare Krishna
10 Russian
11 Loonie
12 Elvis
13 Yakuza
14 Fire fighter
15 Car jacker
16 Medic
17 Pickpocket
18 Blue pedestrian
19 Light blue pedestrian
20 Red pedestrian
21 Pedestrian
22 Prisoner
23 Poisened pedestrian
24 Poisened pedestrian
25 Claude Speed (default player ped)
26 Naked pedestrian
27 t/m 52 Other generic pedestrians

Occupations

Occupation Code
No occupation NO_OCCUPATION
Normal pedestrian DUMMY
Pedestrian who attacks everyone PSYCHO
Pickpocket MUGGER
Bank robber BANK_ROBBER
Ped who responds to attacks CRIMINAL
Ped who attacks CRIMINAL_TYPE2 CRIMINAL_TYPE1
Ped who attacks CRIMINAL_TYPE1 CRIMINAL_TYPE2
Tank driver TANK_DRIVER
Mission ped DRONE
Refugee REFUGEES
Car thief CAR_THIEF
Driver DRIVER
Elvis chain member ELVIS
Elvis chain leader ELVIS_LEADER
Special Agent FBI
Fire fighter FIREMAN
Guard GUARD
Guard who attacks the player GUARD_AGAINST_PLAYER
Pickpocket MUGGER
Police officer POLICE
Road block tank driver ROAD_BLOCK_TANK_MAN
Special group member SPECIAL_GROUP_MEMBER
Stationary ped STAND_STILL_BLOKE
SWAT cop SWAT
Soldier ARMY
Modding tutorials of Grand Theft Auto 2
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