|
 |
|
|
|
|
|
GTA Modification Forums
Tutorial Links and Mission Coding Information some links if you want to learn coding
 |
|
 |
| |
sleeper777  |
|
Mission Coder | Help Guru | Tech Ninja

Group: Members
Joined: Mar 28, 2003


|
"Topic is somewhat outdated so here's a link for the latest info on the best tools and tutorials to use" You will need either one of Barton's Mission Builders(GTA3, VC, SA) , the gtama + the ide + disasm, or Sanny Builder in order to decompile the main.scm file and see it in script format. Script format is viewed as follows: | CODE |
;MB Format 02AC: set_car 0@ immunities 1 1 1 1 1
| or |
;gtaMA Format set_car_immunities $my_currcar, 1, 1, 1, 0, 1
| or |
;Sanny Builder Format 02AC: set_car 0@ immunities BP 1 FP 1 EP 1 DP 1 SP 1
|
As you can See here that the formats are only slightly different and understanding of basic programming logic should be your main concern. You should be able to read and understand thoroughly the readme of the tools you use and the documentation collected here and many other places hosted by the members here. And by all means when you really want to know how to approach a thread idea refer to the original code. Decompile your main.scm and save this text file somewhere all by itself open it and search whenever you want to find how a particular thread was accomplished. never modify this backup of the oriiginal code it will help you tremendously to have a backup of the un-modded source code for missions. Basic understanding of IF THEN ELSE, FOR, WHILE, DO UNTIL, Incrementing, and Decrementing, basic algebra and geometry are helpful, and of course the ability to logic out problems, all are base requirements before getting into Main.SCM Modding a.k.a Mission Scripting, or Mission Coding. If you really want to understand the flow of the game logic you should read as much information as you can find on Programming Logic. Yes, While some things like new pickups, parked cars, and some basic stat modifications are easily accomplished with one or two opcodes, the majority of the the best tools a mission scripter can build require some knowledge of basic programmer's skills. Basically if you can understand one scripting language or programming language, then your chances of survival as a Mission Scripter are greatly Improved. | CODE | For (X = 0;While X < Number_of_Repeated_Questions_by_Noobs; X++) { Write "Read, Read, Read ......" } Write "The Readme";
If (WannabeCoder == Understands.This) Then Message = "You may have Hope"; Else Message = "You must travel another Path"; End;
Write Message;
|
Tutorials List from this thread. JasonB, PatrickW, Y_less 1, Y_less 2, Y_less 3, Y_less 4, Craig Kostelecky, timmy2004, IF(s) ,AND(s), & OR(s), From Other Areas of the Forums Tutorial on spookie's SCM/D3D hook for Vice City and for those of you who need a primer on san andreas coding specifically, Yeti has written a nice tutorial on the basics. (More Links and updates soon !) YeTi's SA Coding Tutorial Part One, YeTi's SA Coding Tutorial Part Two , DarkPact SA - Demarest, Be sure to read back here for updates and check the other pinned topics in the mission coding forum. In Barton's editor it begins with the opcode number followed usually by some descriptive text about what the opcode does, this is also true of most of the script in Sanny Builder with some minor differences in the format of some code. The other text or numbers you see is usually parameters for the opcode, these are identified by the parameter data type symbols: Edit: these do not apply to the current version 1.4 of Vice Builder except the $, @, "quotes", : , #, ££ global variable identifier $, Float parameter identifier used for world coordinates ! (-2048 to 2047.9375 x -2048 to 2047.9375 in GTA 3) ( Little Integer parameter identifier ?(-128 to 127) Memory Location identifier ?? (avoid these like the plague when modding an already built scm) 0-65535 in increments of 4 Big Integer parameter identifier &(-32768 to 32767) or $ in the more recent versions of VC SA and Sanny Really Big Integer parameter identifier && (theoretically any size - or +) Local variable identifier @ string variable "quotes" model identifier # thread label marker : thread prefix Marker ££ or @ in Sanny builder In gtaMa/VCME it usually just a description of the opcode's function, followed by comma seperated parameters or variables. The symbols used are: the uniquely named global variable identifier $ the label marker @ the local variable identifier ! the string variable "quotes" the model identifier % More Information Any one interested in coding should read all of the Above information. Search these forums for all the descriptions, parameters, and examples they can find. Only after you have read all this information and tried to develop some code will you be bale to understand some of the short answers that you will get from those of us who have spent the time to learn it and have answered the basic questions hundreds of times. The development of Mods is time better spent than answering questions that have already been answered. For Questions about most versions of Syntax for Sanny Builder: SA.OpSearch+SCM DojoOp-Search+ TopicUsing the following link will answer more questions than any posting will give you be sure to set the date feature of the search to the "Any Date" setting and also be sure to set the 'Search Where' to 'Mission Coding' Only this will tighten your Search and give you results pertaining to mission coding only. This post has been edited by spaceeinstein on Friday, Apr 10 2009, 10:05
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
JasonB  |
|
GTA-SA/GTA-VC/GTA3 Modder Extraordinaire

Group: Members
Joined: Aug 24, 2002

|
You might also want to give this a read, its a little old but hey what the hell. I may update it soon though GTA3\Vice City Modding Tutorial #1: Author: JasonB Topics: 1) Intro 2) Basics 3) Your first addition 4) New Thread 5) Conclusion 1: Intro OK, to start off in mission coding for either GTA3 or Vice City you DO NOT need to know anything about programming. Maybe a little logic and maths skills but that’s about it. This tutorial assumes that you have a copy of Bartons mission builder, either for GTA3 or VC. Some of the stuff in here may apply to other builders but I use Bartons, so I will not write tutorials for other builders. 2: Basics OK heres your first lesson in coding. Open up the MAIN.SCM in Bartons builder, make a backup of main.scm as well. Look at all the code, theres a lot but most of it you wont ever touch, so don’t worry. Opcodes: Look at the lines, they all have four number-letter combos before them, that’s an opcode, depending on what opcode it is determines what it will do. There are a lot of opcodes, most of them are useful. Variables & Data Types: There are several different data types. A brief explanation follows: | CODE | ? – Short Integer: Can values up to 255 eg 1@ = 5? & - Long Integer: Can hold values up to 65535 (I think) eg $TEST = 500& ! – Float (Real value) eg 8?? = 0.25! $ - Global variable eg $TEST = 500& @ - Local Variable eg 1@ = 25? ?? – Global Number variable eg 8?? = 0.25!
|
Threads: A thread is a section of code that runs independently of the main program. For example a speedometer has to always be running even if you are in a mission. 3: Time for your first addition Your first addition to the game should always be simple, don’t try to make an uber-leet mad ass never before done mod on your first attempt, that will get you nowhere. Instead the first thing you will add is a new pickup. (Note: the following code and examples was written with Vice City code as a basis, the same principles apply to GTA3 but the code is different, also this code may be out of date, I might be getting references from an older version, but still, the same principles apply) Search in the code for opcodes that match these numbers 0213. In Vice city the first matches you should get are bribes, so we are going to make a new bribe in a new location. Copy and paste one of the lines. | CODE | 0213: 440?? = create_pickup -4? (BRIBE) type 15? at 393.9! -60.2! 11.5!
|
0213 is the opcode. The 440?? Is its identifier. -4? Is the model of the pickup. And the last three numbers are the XYZ coordinates. Lets change it too: | CODE | 0213: $BRIBE1 = create_pickup -4? (BRIBE) type 15? at 229.69! -1263.40! 20.11!
|
Save it and compile it, put the updated Main.SCM in your DATA folder and run the game. GO to the ocean view hotel and there should be a bribe in your room. Did it work, if so good, now your next lesson: New parked cars: Look for OpCodes 014B and 014C, copy a 014B and 014C line. | CODE | 014B: 7972?? = init_parked_car_generator #MAVERICK -1? -1? 0? alarm 0? door_lock 0? 0? 10000& at -853.6609! 1353.785! 68.6104! angle 0! 014C: set_parked_car_generator 7972?? cars_to_generate_to 101?
|
That’s something like what it should look like. Now lets change it a bit, first the 014B line: | CODE | 014B: $KENCAR = init_parked_car_generator #ROMERO -1? -1? 0? alarm 50? door_lock 0? 0? 10000& at 112.018! -804.531! 10.4193! angle 30!
|
OK, once again, theres the opcode and the indentifier, I cant remember which value is which but the other values are, cars colour 1, cars colour 2, Belongs TO Player (no starts for stealing), alarm (value out of 100, 0 means no car alarm, 100 means always), Door Lock (same rules apply to door lock as they did to alarm), car value and the XYZ co-ords and the angle. Now for the 014C opcode: | CODE | 014C: set_parked_car_generator $KENCAR cars_to_generate_to 101?
|
Basicallay it tells the game to always spawn a hearse near Kens place. Compile and place in data directory, and there you go. 4: New Thread OK now you are going to make a new thread that does something. In this case makes it rain until you complete the Phnom Penh mission (The Hurricane). | CODE | :LabelSunny 0001: wait 500& ms 00D6: if 0? 0038: $PASSED_COK2_PHNOM_PENH_86 == 1? 004D: jump if false ££LabelRainy 01B6: weather 0? 0002: jump ££LabelSunny
:LabelRainy 0001: wait 500& ms 01B6: weather 2? 0002: jump ££LabelSunny
|
ok :LabelSunny and LabelRainy are parts of this thread. The wait command makes it so Vice or GTA3 doesn’t freeze and eat up your system resources, since this doesn’t need to be checked very often, it only checks it twice every second. The if 0? Command is an if statement, the 0? Is how many things have to be right to make it continue or jump, if you add 20 to it becomes an OR statement. The $PASSED_COK2_PHNOM_PENH_86 == 1? Line only checks to see whether you have passed a mission or not. The jump_if_false says, if you haven’t passed it, jump to the rainy section. Weather 0? Is a state of the game sweather, 0? Means its fine. The jump statement means it jumps to the start of the thread to check again. The same principles apply to LabelRainy. Just so you know you put this all before the Mission 0 part of the code. SO to find Mission zero look for Mission 0- and put this code ABOVE it. Now to make the game check for the code you require a create thread command. Go to the top of the code and look for 004F opcodes, there should be quite a few of the, copy and paste one of them and then change the jumble of numbers and letters at the end to be Sunny, so it should say 004F: create thread ££LabelSunny. Compile and run the game, It should be raining, if so good, if not, try again. 5: Conclusion You have now made a mini-mod for either GTA3 or VC. Congratulations . Just so you know there is a high chance that I will write more tutorials, so more learning . But don’t wait, expand on the code and make more cars, pickups and threads, make VC or GTA3 how you want it, and remember, have fun.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
Y_Less  |
Posted: Thursday, Jun 17 2004, 12:10
|
629

Group: Members
Joined: Mar 14, 2004



|
Alex "Y_Less" Cole's n00b guide to coding.I know a coding n00b writing a tutorial on coding may seem a bit odd at first, but there is method in my madness. I am just starting coding, as I know alot of other people are or would like to, so I am putting things here as I find them out, in n00b terms, from the point of a n00b, so that hopefully other n00bs will be able to follow it. Its all well and good going "how do I do this?" and the experienced people go "using OpCodes bla bla bla with some variable doing this", nut I don't know about you, but I would much rather know how to figure all this stuff out myself, as, I am sure, everyone else (including experienced coders - whose time would be freed up by not having to tell 5 different people how to do an OR cos they can't find the command) would. If anyone with more experience would like to contribute, please fell free to, but remember that we don't know what OpCode 04AE or 02A7, for example, do off by heart and would need to be explained. I am hoping that eventually, as I get more experienced, and other people do, I will be able to make this into a full blown tutorial on coding for beginners, easy to understand for them, and others. Anyway, enough about all that, on to Part 1: Placing Items. There are a couple of items I am going to cover in this, pickups, vehicles, weapons, marker points and other models, this is probably the best place to start as without these, you can't do anything else. 1. Pickups.The easiest way to find out how to do things is to search the code for existing examples of it. When you first power up the editor, you see a long list of object definitions, one of which looks like this: | CODE | | DEFINE OBJECT BODYARMOUR \\ Object number -18 |
We know what the object is called, so it we want to place one, just go to search and search for BODYARMOUR. Whats the first result that somes up, besides the object definiton we just looked at? this line: | CODE | | 0107: 3572?? = create_object -18? (BODYARMOUR) at -66.629! -1488! 12.113! |
Unfortunately, we are looking for the body armour pickup, that is just an object, so keep searching until you find this line: | CODE | | 0213: 5272?? = create_pickup -18? (BODYARMOUR) type 15? at -314.7! -551.2! 10.3! |
0213 is the create_pickup OpCode, used for item pickups (except weapons except mele weapons). If you look below the line you are on, you will se the line: | CODE | | 0213: 5276?? = create_pickup #CHNSAW type 15? at -310.7! -551.2! 10.3! |
- the 0213 OpCode And then a bit further down, the line: | CODE | | 032B: 5280?? = create_weapon_pickup #PYTHON 15? ammo 24? at -306.7! -551.2! 10.3! |
- not the 0213 OpCode - it has ammo values as well. Back to our armour pickup, you can see after the OpCode a variable, this is what stores the armour, if we want to add our own, we need to change this to an unused variable, you can either find out what the lowest unused variable number is, or you can use a string variable, e.g: | CODE | | 0213: $my1starmour = create_pickup -18? (BODYARMOUR) type 15? at -314.7! -551.2! 10.3! |
Now to where to put it, fire up Code Creator and VC and walk to where you want it, I'm going to put it at: 108.0565! -839.6693! 10.46322! - by the front door of Ken's next door neighbours, so change the co-ordinates at the end to those, and you get: | CODE | | 0213: $my1starmour = create_pickup -18? (BODYARMOUR) type 15? at 108.0565! -839.6693! 10.46322! |
Now you can't put this line into the code where you got it from because that was in the middle of a thread, so continue searching through the code until you find a long list of pickups next to each other (at around line 28430) and insert in in there. Now save, compile and run. 2. VehiclesWe will use the tequniques used in the previous part to find how to make vehicles, if you are still on the part with the armour, scroll up a little bit and you will find the code for the vehicles. I am going to place a packer (the car transporter) outside the Malibu to jump over it, find the line for the packer in the Vice Port and copy it: | CODE | 014B: 7516?? = init_parked_car_generator #PACKER -1? -1? 0? alarm 0? door_lock 0? 0? 10000& at -946.3! -1379.5! 11.5! angle 69! 014C: set_parked_car_generator 7516?? cars_to_generate_to 101? |
The co-ordinates I got were: 470.9084! -121.0596! 10.36153! and the rotation is 0 as I am looking North (rotation is done in degrees anti-clockwise from North). There is also another variable in these 2 lines, so replace them both with a new one (they are the same, so leave them the same). | CODE | 014B: $my1stcar = init_parked_car_generator #PACKER -1? -1? 0? alarm 0? door_lock 0? 0? 10000& at 470.9084! -121.0596! 10.36153! angle 0! 014C: set_parked_car_generator $my1stcar cars_to_generate_to 101? |
We want it unlocked and unalarmed, so leave those as 0, and we want it to appear, so leave the cars_to_generate_to as 101? Save, compile and run again. Remember that you need to start a new game after every little tiny mod. 3. WeaponsWe have already covered the OpCode for weapons, most weapons are directly under the cars, so go down to them and copy the line for an M4 | CODE | | 032B: 8096?? = create_weapon_pickup #M4 15? ammo 60? at -1221! -641.6! 11.7! |
Then decide where you want it and and how much ammo you want to give it and put them in (?'s are interger values and !'s are floating point values). Finally, change the variable at the beginning again (you always need to do this), save, compile and test. | CODE | | 032B: $my1stgun = create_weapon_pickup #M4 15? ammo 100? at 5.266161! -939.0254! 16.116! |
4. Marker pointsI don't know what the code for this is, but thankfully, the people who find these things out give them sensible names, so, as we want to create a marker, search for create_marker, and what do we get? - a bit of marker code! The second one I came accross I know is a small round pink one as it is the marker from the 'The Party' mission outside Rafael's, so copy this and edit it. | CODE | | 02A8: 236?? = create_marker 28? at 396?? 400?? 404?? |
Note on this one, unlike the others, the co-ordinates are stored as variables instead, these will have been defined earlier in the mission as the actual co-ordinates and just used here. | CODE | | 02A8: $my1stblob = create_marker 28? at 556.2355! -3.073752! 14.3036! |
I have made mine by the front door of the WK Chariot, insert this code somewhere sensible, e.g. with all the other pickups in Mission 0, this will mean it is there from the start. And now, of course, test. If you have been following, you will have discovered that testing is very important, as that is infact the wrong OpCode! That just creates a marker on the radar that looks like a T-shirt (the Rafael marker). After a bit more searching through the code, I found these markers to test: | CODE | 02A7: 892?? = create_icon_marker_and_sphere 1668?? at 1824?? 1828?? 1832?? 018A: 76?? = create_checkpoint_at 8452?? 8456?? 8460?? |
But when I tested it, I found the first was the Lawyer radar marker and the second was just the pink marker on the radar that shows whether something is below, level with or above you. So after alot more searching, I found this: | CODE | | 0189: 264?? = unknown_create_checkpoint_at 240.4! -1280.2! 10! |
In the end I just searched for instances where I know it existed, i.e. the hotel marker at the very beginning an searched for those. But this does show you how easy it is to get it wrong and how important testing is (I did consider re-writing this part, but I decided to leave my blunder in just to show you how to sort things like this). So after editing it, and removing the t-shirt marker (I kept in the height marker for show), I ended up with code that looked like this: | CODE | 018A: $my1stblob = create_checkpoint_at 556.2355! -3.073752! 14.3036! 0189: $my2ndblob = unknown_create_checkpoint_at 556.2355! -3.073752! 14.3036!
|
Which, after testing, does work. 5. Other modelsFrom what I have read, alot of people consider this quite advanced as it allows you to do map manipulation, which is supposedly hard, but I think its quite fundamental. The first thing you need to do for this is define the model, if you have Moo Mapper, this is probably the easiest way to find a model. For this, I am going to put a security box outside 1102 Washington Street - not exciting, but it can be expanded on. First, you need to find add the model. At the top, where we first got the body armour info, to the bottom of the list, add this line: | CODE | | DEFINE OBJECT bar_gatebox01 \\ Object number -204 |
And increase the number of models at the top by one. This has now defined the model in the code. Now you need to find the code to put the model into the world, simply scrolling down a few lines reveals these lines: | CODE | 029B: $ARENA_DOOR_1 = init_object -1? (DTN_STADDOORA) at -1109.615! 1330.097! 20.372! 01C7: spawn_object $ARENA_DOOR_1 |
Using these co-ordinates: 103.192! -812.6703! 10.46329! We can modify the code to add our model. Note - the model number in the above example is above -128, so it can be a short integer variable, as ours is -204 - much less that -128 we need to use the & variable type. | CODE | 029B: $my1stobject = init_object -204& (bar_gatebox01) at 103.192! -812.6703! 10.46329! 01C7: spawn_object $my1stobject |
This will spawn a random box outside 1102 Washington Street - it is above the ground and flies off when you touch it, but it is a start and this can easilly be rectified later. Practice activites:1. Put a police bribe in the room at the top of the lighthouse. 2. Add a marker to the radar to show you where it is. 3. Spawn a motorbike inside the grocery store down the road from El Swanko Casa, and turn its alarm on. 4. Find the OpCode for the large, racing checkpoint circles and put one on the bridge to Starfish Island. 5. Find the weapon number for the camera as used in Marthas Mugshot and give the player it. I hope this is a useful introduction to coding, if so I will continue and try to write more as I find more, please add any comments you like below (except flames for the maker mess up - I think I deserve to not get flamed for owning up to it). note: Edited for new hosting. This post has been edited by Y_Less on Friday, Jul 9 2004, 08:13
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Pages:
(6) [1] 2 3 ... Last »
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|