WikiGTA Tutorials

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
CarThief
Hitman
Hitman
Posts: 108
Joined: 19 May 2012, 18:12
GH nick: CarThief
Location: Holland, AKA The Netherlands

WikiGTA Tutorials

Post by CarThief »

Just putting this here for two reasons. Firstly i noticed no clear references to this website which has extensive tutorials for GTA2, though i can be mistaken i guess. And secondly i posted this for manual translations of the few pages that werent officially translated yet into English of the Wiki.
English GTA2 Modding page: http://en.wikigta.org/index.php/Modding_(GTA2) <-
Dutch page: http://nl.wikigta.org/wiki/Modding_(GTA2) <-
Edit: Fixed the links, i guess.

The only thing not properly translated on there are phones, save points and missions. I'll just post them in this order.
I merely translated them, didnt touch or test any of the code, aside from putting small notes on stuff where it comes in handy, so i cant guarantee if its functional. Didnt include the save point one, as i believe Project Cerbera already covers that.

Phones(PHONE's)
Phones are mainly used to start missions. There are four different phones; the blue Information Phone and the three Mission Phones in the colors green, yellow and red.

Information Phone (Informatietelefoon)
The blue phone is ussually used to display gang information (what gang it is about, and what their rival gang is). This happens by simply calling a brief command when the player walks over the phone en thus is easy to set up with a simple Thread Trigger.

Code: Select all

OBJ_DATA phonename = ( X.x , Y.y , Z.z ) rotation PHONE

FORWARD subroutinenaam:

THREAD_TRIGGER threadname = THREAD_WAIT_FOR_ANSWER_PHONE ( player , phonename , subroutinename: )

subroutinename:

DISPLAY_BRIEF ( tekstID )

RETURN
Mission Phone
The Mission Phones are ussually used to start missions. For this the mission will be started as an external script. It is important that the mission is in a different file, in a map with the exact same name as your main script (Doesnt have to be in the Data folder -CT). The mission will be started with a PHONE_TEMPLATE:

OBJ_DATA telefoonnaam = ( X.x , Y.y , Z.z ) rotatie PHONE

Code: Select all

FORWARD subroutinename:

THREAD_TRIGGER threadname = THREAD_WAIT_FOR_ANSWER_PHONE ( player , phonename , subroutinename: )

subroutinename:
DO_EASY_PHONE_TEMPLATE ( mission_already_done_text , mission_filename , flag_passed , flag_failed , on_gang1_mission , on_gang3_mission , on_gang2_mission , gangname , respect_required )
RETURN
PHONE - Which Phone type you want it to be: GREEN_PHONE, YELLOW_PHONE, RED_PHONE or PHONE.
mission_already_done_text - The brief to be displayed if you already did this mission.
mission_filename - The name of the external script file. (Dont forget to add .mis -CT)
flag_passed - Declared counter keeping track if this mission is passed yet.
flag_failed - Declared counter tracking if the mission failed yet.
on_gang1_mission , on_gang3_mission , on_gang2_mission - The counters that keep track if a player does a mission for a gang. The order changes per gang:
Gang1: on_gang1_mission
on_gang2_mission
on_gang3_mission
Gang2: on_gang2_mission
on_gang3_mission
on_gang1_mission
Gang3: on_gang3_mission
on_gang1_mission
on_gang2_mission

Gangname - The name of the gang, which was submitted as a Gang Zone.
respect_required - How much Respect is required to do the mission, from 0 to 5.

Notes
* Phones have a different angle then most object. When placed in angle 90 it will face down instead of left.
* Mission Phones have to be in a gang zone to function. (Otherwise the game crashes -CT)
* Every gang can only have two mission phones of each color. Blue Information Phones dont seem to have any limits; there can be atleast a 100 of these in a level.
* Once a gang has minimally 0, 3 or 5 respect for the player, an arrow will automatically point an arrow to the green, yellow or red phones respectively, regardless of if there is a mission tied to this phone or or if the respect requirement is the same as the required amount given in the PHONE_TEMPLATE.
* Above example is intended for a phone that only gives one mission, such as the green phones in GTA2. The yellow and red phones instead give more missions. For this a larger PHONE_TEMPLATE is needed.
* PHONE_TEMPLATE's dont function on their own but are part of a larger system. See the singleplayer script for this.

Scripting Missions (Missie scripten (GTA2))
Missions are in seperate files (multiscripts) in a map with the same name as your main script. Missions also get the name of the main script but with something added after it. This addition exists of the first character of the gang (that does have to be different), a character that tells if it is a green, yellow or red mission and a number that tells what mission it is. If we use the same naming method as the original scripts, then the example map has the following files:

tst.gmp - For the level itself
tst.mis - For the main script.
tst - For the map the missions are in.
tst_te1 - For the first green mission of Testgang.
tst_vm3 - For the third yellow mission of the Examplegang.
tst_ph2 - For the second mission of the Dummygang
Instead of LEVELSTART and LEVELEND a multiscript uses MISSIONSTART and MISSIONEND. The function remains the same, even if the missions of GTA2 are entirely in subroutines. Because of this almost all the code is before LEVELSTART.

When you want to compile a mission script through the compiler you can just select the main script. The compiler will automatically look for the external scripts, if they are mentioned in the main script and the mission scripts will be saved in a map at the same location as the main script.

Example
The script below contains an complete, simple mission. Multiple times a counter will be used from the main script. These counters keep track of stuff like how many missions have been passed and failed, or if the player is busy doing a mission and if so: for what gang he is doing it. This is part of a extensive system that allows the mission structure of GTA2 to function. Additional counters that are created in the mission, have to have a unique name that is not present in the main script.

This example is about the first green mission of the Zaibatsu Corporation ("zaibgang"). By accepting this mission an Eddy and a Panto will be created. To pass the mission you have to enter the Eddy. Get into the Panto, get arrested or killed and you will fail the mission.

Code: Select all

COUNTER main_zaibgang_green_1 = 1
COUNTER zaibgang_green_1_in_eddy = 0
COUNTER zaibgang_green_1_in_panto = 0

CAR_DATA zaibgang_green_1_eddy
CAR_DATA zaibgang_green_1_panto

FORWARD clean_up_zaibgang_green_1:

zaibgang_green_1:

SET flag_failed_zaibgang_green_1 = 0 //Needed if the player failed the mission before.
SET flag_on_mission = 1 //The player is now on a mission and cant start another. (Or save the game -CT)
SET flag_on_zaibgang_mission = 1 //The player is busy with a Zaibatsu Mission.

zaibgang_green_1_eddy = CREATE_CAR ( 130.5 , 114.5 , 2.0 ) 5 270 EDSEL END //Eddy is being created
zaibgang_green_1_panto = CREATE_CAR ( 130.5 , 116.5 , 2.0 ) 7 270 FIAT END //Panto is being created.

DISPLAY_MESSAGE ( 3847 ) // Mission Title
DISPLAY_BRIEF_NOW ( 3800 ) // The mission is explained.

WHILE_EXEC ( main_zaibgang_green_1 = 1 ) //The following commands are valid as long as you're not in either car.

	IF ( IS_CHARACTER_IN_CAR  (  player1  ,  zaibgang_green_1_eddy  ) ) //When the player gets in the Eddy...
		SET zaibgang_green_1_in_eddy = 1
		SET main_zaibgang_green_1 = 0
	ENDIF

	IF ( IS_CHARACTER_IN_CAR  (  player1  ,  zaibgang_green_1_panto  ) ) //When the player gets in the Panto...
		SET zaibgang_green_1_in_panto = 1
		SET main_zaibgang_green_1 = 0
	ENDIF

	IF ( zaibgang_green_1_in_eddy = 1 )
		CLEAR_ALL_BRIEFS ( ) //Remove all text and briefs.
		DISPLAY_BRIEF ( 7022 ) // "Well done! You passed!"
		SET flag_passed_zaibgang_green_1 = 1 //You completed this mission.
		DISPLAY_MESSAGE ( 3100 ) // "JOB COMPLETE!"
		ADD_SCORE ( player1 , 3000 )//You get the reward.
		ADD_MULTIPLIER ( player1 , 1 ) //You get a Multiplier.
		CHANGE_GANG_CHAR_RESPECT_AND_UPDATE ( zaibgang , player1 , 1 ) //You get more respect.
		CLEAR_WANTED_LEVEL ( player1 ) //Your wanted level is set to 0 again.
		SET_PHONE_DEAD ( zaibgang_green_phone_1 ) //The phone will be disabled.
		DISABLE_THREAD_TRIGGER ( thr_zaibgang_green_1 ) //The mission thread trigger will be disabled.
		RETURN 
	ENDIF

	IF ( zaibgang_green_1_in_panto = 1 )
		CLEAR_ALL_BRIEFS ( )
		DISPLAY_BRIEF ( 3683 ) // "You blew it, baby! The job's over for you."
		CHANGE_GANG_CHAR_RESPECT_AND_UPDATE ( zaibgang , player1 , -1 ) 
		SET flag_failed_zaibgang_green_1 = 1 //You failed this mission.
//		SET flag_failed_zaibgang_green_phone_1a = 1 //You failed this mission and are now allowed to repeat it.
		DISPLAY_MESSAGE ( 3730 ) // "JOB FAILED!"
		RETURN 
	ENDIF	 
ENDWHILE
RETURN

//---------------------------------------------------------------------------------------------

clean_up_zaibgang_green_1: 

IF ( flag_passed_zaibgang_green_1 = 1 )
	++ flag_all_missions_passed //The player passed the mission succesfully.
	++ flag_zaibgang_missions_passed //The player passed a Zaibatsu mission.
	IF ( flag_zaibgang_missions_passed = 7 ) // If the player completes all the (7) Zaibatsu jobs...
		DISPLAY_MESSAGE ( 3674 ) // "ALL ZAIBATSU JOBS DONE!"
		DISPLAY_BRIEF ( 3675 ) //"Congratulations, Gecko! You have succeeded in completing ALL the Zaibatsu jobs!"
	ENDIF
ENDIF

IF ( flag_failed_zaibgang_green_1 = 1 )
	++ flag_all_missions_failed //The player failed a mission.
	++ flag_zaibgang_missions_failed //The player failed a zaibatsu mission.
ENDIF

IF ( CHECK_DEATHARREST_EXECUTED ( ) ) //If the player gets arrested or killed during the mission...
	++ flag_all_missions_failed //The player failed a mission.
	++ flag_zaibgang_missions_failed //The player failed a zaibatsu mission.
	CHANGE_GANG_CHAR_RESPECT_AND_UPDATE ( zaibgang , player1 , -1 )
ENDIF

MISSION_HAS_FINISHED (  ) 
    
SET flag_on_mission = 0 //Player is no longer busy on a mission.
SET flag_on_zaibgang_mission = 0 //Player is no longer busy on a Zaibatsu mission.
 
RETURN

MISSIONSTART

GOSUB zaibgang_green_1:
GOSUB clean_up_zaibgang_green_1:

MISSIONEND
Singleplayer Script (Singleplayerscript (GTA2))
Only has a dutch page.
A complete singleplayer script of GTA2 contains, aside the required code of the basic script, a large system of Counters, subroutines and PHONE_TEMPLATES to make the multiscripts work correctly. Below script contains a complete system for the missions of a singleplayer level. The script supports two gangs, who each give seven missions according to the standard method of GTA2. Two of the missions (the first green missions of both gangs) are enabled. Aside from that is space for a save point, information phones, five kill frenzies, fifty GTA2 badges and a "final mission" if all gang missions have been completed and a end goal if the player has the required amount of money to leave the map. The script is based on bil.mis.

Very large script example, see the page for it instead.
Last edited by CarThief on 16 Jun 2012, 09:04, edited 1 time in total.
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: WikiGTA Tutorials

Post by BenMillard »

Yep, it's a great resource. Also worth seeing the graphical GTA2 vehicle list and the GTA2 Wikia.

Have you been involved in an accident that wasn't your fault? Was it caused by limitations with auto-linking on a phpBB forum? Here are BBcodeTips4U we have a decade of experience handling cases just like yours. And, as a special introductory offer, your first solution is free!

Code: Select all

[size=150][url=http://nl.wikigta.org/wiki/Singleplayerscript_(GTA2)]Singleplayer Script for GTA2[/url][/size]
CarThief
Hitman
Hitman
Posts: 108
Joined: 19 May 2012, 18:12
GH nick: CarThief
Location: Holland, AKA The Netherlands

Re: WikiGTA Tutorials

Post by CarThief »

Ah, tried that with ' and " marks and so on but i guess it didnt need any this time. It just keeps changing! But now its fixed i suppose.
Hm, that car list does have the advantadge of displaying the car crusher rewards, i certainly could use that to fix up the crusher reward system in my project.
Post Reply