GTAGames.nl advertentie

Scripting Kill Frenzies (GTA2)

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

Main Page > GTA2 > Modding Tutorial > Kill Frenzies


Kill Frenzies are basicly small missions triggered by entering a car or an area with a Kill Frenzy icon. Luckily, Kill Frenzies have their own template code, so we don't have to script all conditions.

Generic Kill Frenzy commands

Let's start with scripting some things you can recycle for every Kill Frenzy, meaning you have to script them only once. These things are the TIMER, which keeps track of the time the player has left, the ONSCREEN_COUNTER, which shows the remaing time onscreen and a SAVED_COUNTER, which keeps track of the passed frenzies. You'll also need to declare the total number of Kill Frenzies and two COUNTERs to keep track of the number of failed and passed Kill Frenzies. These COUNTERs have to be declared as FLAGs with two additional commands. The code to do this all should look something like this:

TIMER_DATA kf_timer_name
ONSCREEN_COUNTER kf_onscreen_counter_name 
SAVED_COUNTER kf_saved_counter_name
DECLARE_TOTAL_SECRETS ( 2 ) //This is the number of kill frenzies. We're making two of them in this tutorial
SAVED_COUNTER kill_frenzies_passed = 0 
SAVED_COUNTER kill_frenzies_failed = 0 
DECLARE_SECRETS_PASSED_FLAG ( kill_frenzies_passed )
DECLARE_SECRETS_FAILED_FLAG ( kill_frenzies_failed )

Adding a Kill Frenzy

First, we need to tell the script we're adding a Kill Frenzy. Kill Frenzies are called "BONUSes" in the script. Add the following command to your script:

BONUS kf_name
kf_name An unique name. You're going to need this name later.

Objects

Next, we need a pick-up or car to start the Kill Frenzy. You can script these with the normal OBJ_DATA and CAR_DATA commands:

OBJ_DATA kf_icon_name = ( X.x , Y.y , Z.z ) rotation KILL_FRENZY
CAR_DATA kf_car_name = ( X.x , Y.y , Z.z ) color rotation vehicle

Use the GIVE_WEAPON command to add a weapon to the car if you want to.

GIVE_WEAPON ( kf_car_name , car_weapon )

Subroutine

Beneath these codes, add the subroutine of the Kill Frenzy:

FORWARD kf_subroutine_name:
//This is where the THREAD_TRIGGER and KF_TEMPLATEs will be
RETURN

THREAD_TRIGGER

Inside this subroutine, we create a THREAD_TRIGGER to start the Kill Frenzy when the player walks on the pick-up or gets in the car.

THREAD_TRIGGER kf_thread_trigger_name = THREAD_WAIT_FOR_CHAR_IN_AREA ( player , X.x , Y.y , Z.z , width , height , kf_subroutine_name: )
THREAD_TRIGGER kf_thread_trigger_name = THREAD_WAIT_FOR_CHAR_IN_CAR ( player , kf_car_name , kf_subroutine_name: )
kf_thread_trigger_name An unique name for this THREAD_TRIGGER.
player The name of the player ped.
X.x , Y.y , Z.z The coordinates of the center of the kill frenzy icon.
width , height The height and width of the trigger area. Use 0.2 , 0.2 for an area with the size of the icon.
kf_car_name The name of the car you've created for the kill frenzy.
kf_subroutine_name: The name of the subroutine you created earlier. Don't forget the : at the end.

START_BASIC_KF_TEMPLATE

With the THREAD_TRIGGER in place, we can finally add the actual kill frenzy inside the subroutine. This is done with three commands: two KF_TEMPLATEs and a BONUS_CHECK. The first KF_TEMPLATE looks like this:

START_BASIC_KF_TEMPLATE ( kf_thread_trigger_name , text_ID , kf_pick_up_name/kf_car_name , player , weapon_type )
kf_thread_trigger_name The name of the THREAD_TRIGGER you've created earlier.
text_ID The ID of the text explaining the objective of the kill frenzy. These texts can be found and changed with a GXT Editor.
kf_pick_up_name/kf_car_name The name of the icon or car to start the kill frenzy
player The name of the player ped
weapon_type The weapon to use with this kill frenzy. Set this to NO_WEAPON if the player shouldn't get a weapon.

START_BONUS_CHECK

To declare the target, time and some other variables, you may choose from six START_BONUS_CHECKs:

kf_name = START_BONUS_CHECK ( zone , time , target_number , reward , CHAR/CAR , exclusive_mode , damage_type , car_model , gang_name )
kf_name = START_BONUS_CHECK ( zone , time , target_number , reward , CHAR/CAR , exclusive_mode , damage_type , car_model , gang_name , target_remap )
kf_name = START_BONUS_CHECK ( zone , time , target_number , reward , CHAR/CAR , exclusive_mode , damage_type , car_model , char_occupation )
kf_name = START_BONUS_CHECK ( zone , time , target_number , reward , CHAR/CAR , exclusive_mode , damage_type , car_model , char_occupation , target_remap  )
kf_name = START_BONUS_CHECK ( zone , time , target_number , reward , CHAR/CAR , exclusive_mode , damage_type , car_model , target_car_model )
kf_name = START_BONUS_CHECK ( zone , time , target_number , reward , CHAR/CAR , exclusive_mode , damage_type , car_model , target_car_model , target_remap )
kf_name The name of the kill frenzy you used in BONUS
zone The zone the player should stay in during the kill frenzy. Set to "NONE" if the player isn't limited to a single zone.
time The time the player has to fulfil the kill frenzy. 30 is one second, 1800 is one minute.
target_number The ammount of peds or cars the player has to kill or destroy to pass the kill frenzy.
reward An extra reward the player receives after passing the kill frenzy. This doesn't seem to be used in GTA2 and is always set to '0'.
CHAR/CAR Whether the player should kill pedestrians (CHAR) or destroy vehicles (CAR)
exclusive_mode Whether the player should be able to commit other score types or not: either EXCLUSIVE or NOT_EXCLUSIVE
damage_type How the player should kill or destroy the targets. See the damage types listed below.
car_model In which car model the player should be during the kill frenzy. Set to NONE if the player isn't required to stay in a certain car model.
gang_name The gang name you used in the SET_GANG_INFO command.
char_occupation Which occupation the target pedestrians should have. See the character occupations below.
target_car_model Which car model the player should destroy. Set to NONE if the model isn't important.
target_remap The remap or color the target has to have.

DO_BASIC_KF_TEMPLATE

Lastly, you need to add the DO_BASIC_KF_TEMPLATE command to configure the remaining settings. For some unknown reason, several settings are set in both START_BONUS_CHECK and DO_BASIC_KF_TEMPLATE.

DO_BASIC_KF_TEMPLATE ( kf_name , kf_timer_name , time , kf_onscreen_counter_name , kf_saved_counter_name, target_number , text_ID , player , reward_type , reward_ammount )
kf_name The name of the kill frenzy you used in BONUS
kf_timer_name The name of the TIMER you've created before
kf_onscreen_counter_name The name of the ONSCREEN_COUNTER you've created before
kf_onscreen_counter_name The name of the SAVED_COUNTER you've created before
target_number The ammount of peds or cars the player has to kill or destroy to pass the kill frenzy.
text_ID The ID of the text explaining the objective of the kill frenzy. These texts can be found and changed with a GXT Editor.
player The name of the player ped
reward_type What sort of reward the player should get upon passing the kill frenzy. Choose from NOTHING, SCORE (money), LIVES and MULT (multiplier)
reward_ammount How high the reward must be.

Code lists

Weapons and damage types

Weapon Weapon code Damage type code
No weapon NO_WEAPON BY_PUNCH
Pistol PISTOL BY_GUN
Dual pistol DUAL_PISTOL BY_GUN
S-Uzi machine gun MACHINE_GUN BY_GUN
Silenced S-Uzi machine gun SILENCED_MACHINE_GUN BY_GUN
Shotgun SHOTGUN BY_SHOTGUN
Rocket launcher ROCKET_LAUNCHER BY_ROCKET_LAUNCHER
Flame thrower FLAME_THROWER BY_FLAMETHROWER
Electrogun ELECTRO_GUN BY_ELECTRO_WEAPON
Electro baton ELECTRO_BATON
Molotov cocktails MOLOTOV BY_MOLOTOV
Grenades GRENADE BY_GRENADE
Vehicle machine guns CAR_MACHINE_GUN BY_GUN
Vehicle mine CAR_MINE BY_CAR_MINE
Vehicle oil slicks CAR_OIL
Vehicle bomb CAR_BOMB BY_CAR_BOMB
Vehicle flame thrower CAR_FLAMETHROWER BY_FLAMETHROWER
Vehicle water canon WATER_CANNON BY_WATER_CANNON
Vehicle rocket launcher TANK_GUN BY_ROCKET_LAUNCHER
Armed Land Roamer machine gun JEEP_GUN BY_GUN
Explosions BY_EXPLOSION
Drowning BY_DROWNING
Fire BY_FIRE
Punching BY_PUNCH
Any weapon BY_ANY_WEAPON
Any gun BY_GUN
Any foot weapon BY_ANY_FOOT_WEAPON

Character occupations

Occupation Code
No occupation NO_OCCUPATION
Cops ANY_LAW_ENFORCEMENT
Medics ANY_EMERGENCY_SERVICE_MAN
Gang members ANY_GANG_MEMBER
Elvis ANY_ELVIS

Examples

Below is an example script with two fully functional Kill Frenzies. In the first kill frenzy, you have to destroy ten vehicles in 30 seconds with a rocket launcher, and in the second you have to kill 30 pedestrians in one minute using the vehicle flame thrower mounted on a Fire Truck.

ONSCREEN_COUNTER onscreen_counter_kill_frenzy 
SAVED_COUNTER saved_counter_kill_frenzy
TIMER_DATA timer_kill_frenzy
 
DECLARE_TOTAL_SECRETS ( 2 ) 
SAVED_COUNTER kill_frenzies_passed = 0 
SAVED_COUNTER kill_frenzies_failed = 0 
DECLARE_SECRETS_PASSED_FLAG ( kill_frenzies_passed ) 
DECLARE_SECRETS_FAILED_FLAG ( kill_frenzies_failed ) 
 
OBJ_DATA icon_kill_frenzy_1 = ( 102.0 , 92.0 , 2.0 ) 0 KILL_FRENZY
CAR_DATA kf_firetruck = ( 114.5 , 92.5 , 2.0 ) 1 270 FIRETRUK
GIVE_WEAPON ( kf_firetruck , CAR_FLAMETHROWER )
 
BONUS kill_frenzy_1
BONUS kill_frenzy_2 
 
FORWARD do_kill_frenzy_1:
FORWARD do_kill_frenzy_2: 
 
THREAD_TRIGGER thr_kill_frenzy_1 = THREAD_WAIT_FOR_CHAR_IN_AREA ( grnplayer , 102.0 , 92.0 , 2.0 , 0.2 , 0.2 , do_kill_frenzy_1: )
THREAD_TRIGGER thr_kill_frenzy_2 = THREAD_WAIT_FOR_CHAR_IN_CAR ( grnplayer , kf_firetruck , do_kill_frenzy_2: )


//destroy 10 vehicles in 30 seconds with a rocket launcher

do_kill_frenzy_1: 
START_BASIC_KF_TEMPLATE ( thr_kill_frenzy_1 , 1804 , icon_kill_frenzy_1 , grnplayer , ROCKET_LAUNCHER ) 
kill_frenzy_1 = START_BONUS_CHECK ( no_zone , 900 , 10 , 0 , CAR , not_exclusive , BY_ROCKET_LAUNCHER , NONE , NONE )
DO_BASIC_KF_TEMPLATE ( kill_frenzy_1 , timer_kill_frenzy , 30 , onscreen_counter_kill_frenzy , saved_counter_kill_frenzy , 10 , 1804 , grnplayer , SCORE , 50000 ) 
RETURN


//kill 30 peds in 60 seconds with the fire truck with flame thrower

do_kill_frenzy_2: 
START_BASIC_KF_TEMPLATE ( thr_kill_frenzy_2 , 1804 , kf_firetruck , grnplayer , CAR_FLAMETHROWER ) 
kill_frenzy_2 = START_BONUS_CHECK ( no_zone , 1800 , 30 , 0 , CHAR , not_exclusive , BY_FLAMETHROWER , NONE , NO_OCCUPATION )
DO_BASIC_KF_TEMPLATE ( kill_frenzy_2 , timer_kill_frenzy , 60 , onscreen_counter_kill_frenzy , saved_counter_kill_frenzy , 30 , 1804 , grnplayer , SCORE , 50000 ) 
RETURN
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