Quantcast

Jump to content

» «
Photo

Tutorial Links and Mission Coding Information

  • This topic is locked This topic is locked
112 replies to this topic
Painkiller
  • Painkiller

    Player Hater

  • Members
  • Joined: 09 Jul 2004

#31

Posted 14 July 2004 - 03:28 PM

Well I still can't understand what those 4 bytes after offset to intro thread are for. Anyone know what it's for? confused.gif

Craig Kostelecky
  • Craig Kostelecky

    GTA:LC Team Leader

  • The Connection
  • Joined: 28 Jan 2004

#32

Posted 14 July 2004 - 08:31 PM

To understand the differences between the engines, you may want to look at the GTA:LC code and compare it to the GTA3 code. That way, you're looking at the same information, in a slightly different presentation.

Painkiller
  • Painkiller

    Player Hater

  • Members
  • Joined: 09 Jul 2004

#33

Posted 15 July 2004 - 02:00 AM

I noticed that the opcodes are not the same. But the SCM file layout looks the same.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#34

Posted 15 July 2004 - 09:12 AM

It is. You may have to ask CyQ. He's one of the few people that understand SCM at that level.

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#35

Posted 15 July 2004 - 01:22 PM

QUOTE
Not bad Y_Less.


Ooh, praise from the great Demarest, me is honoured.

I have a few ideas for the next one, but suggestions will be greatly appreciated (e.g. areas to look into from more experienced coders).

Prikki
  • Prikki

    Crackhead

  • Members
  • Joined: 05 Apr 2004

#36

Posted 19 July 2004 - 01:22 PM

Is it possible to delet an exsiting mission?

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#37

Posted 19 July 2004 - 02:03 PM

QUOTE (Prikki @ Jul 19 2004, 08:22)
Is it possible to delet an exsiting mission?

Yes. But remember than most any changes to the code will mean a need to restart.

PatrickW
  • PatrickW

    GTA Juggernaut

  • Inactive Staff
  • Joined: 07 Jan 2004
  • Netherlands
  • Best Script 2013 [DYOM]
    Best Script 2012 [DYOM]

#38

Posted 13 August 2004 - 11:08 PM

For all the ppl who are having trouble to find the correct constants for some of the opcodes, here's a file containing a lot of them. Then file is generated, if you disassemble your main.scm with GTAMA. But the values for MB are offcourse the same wink.gif
All credits for this info go to the great CyQ...
CODE
; Standard include file generated by VCDisAsm v1.6 (C) CyQ, 2003

; Boolean
#define False 0
#define True 1

; Zone info
#define znNight 0
#define znDay 1

; Fade
#define fdOut 0
#define fdIn 1

; Timer
#define tmCountUp 0
#define tmCountDown 1

; Pedtypes
#define ptPlayer1 0
#define ptPlayer2 1
#define ptPlayer3 2
#define ptPlayer4 3
#define ptCivMale 4
#define ptCivFemale 5
#define ptCop 6
#define ptGang1 7
#define ptGang2 8
#define ptGang3 9
#define ptGang4 10
#define ptGang5 11
#define ptGang6 12
#define ptGang7 13
#define ptGang8 14
#define ptGang9 15
#define ptEmergency 16
#define ptFireman 17
#define ptCriminal 18
#define ptSpecial 19

; Threats
#define thPlayer1 1
#define thPlayer2 2
#define thPlayer3 4
#define thPlayer4 8
#define thCivMale 16
#define thCivFemale 32
#define thCop 64
#define thGang1 128
#define thGang2 256
#define thGang3 512
#define thGang4 1024
#define thGang5 2048
#define thGang6 4096
#define thGang7 8192
#define thGang8 16384
#define thGang9 32768
#define thEmergency 65536
#define thFireman 16777216
#define thCriminal 262144
#define thSpecial 524288
#define thGun 1048576
#define thCopCar 2097152
#define thFastCar 4194304
#define thExplosion 8388608
#define thProstitute 131072
#define thDeadPeds 33554432

; Icons
#define icDot 0
#define icCentre 1
#define icArrow 2
#define icNorth 3
#define icAvery 4
#define icBiker 5
#define icCortez 6
#define icDiaz 7
#define icKent 8
#define icLawyer 9
#define icPhil 10
#define icBikers 11
#define icBoatyards 12
#define icClub 13
#define icCubans 14
#define icFilmstudio 15
#define icGun 16
#define icHaitians 17
#define icHardware 18
#define icSave 19
#define icStrip 20
#define icIcecream 21
#define icKCabs 22
#define icLoveFist 23
#define icPrintWorks 24
#define icProperty 25
#define icSunyard 26
#define icSpray 27
#define icTShirt 28
#define icTommy 29
#define icPhone 30
#define icRWildstyle 31
#define icRFlash 32
#define icRKChat 33
#define icRFever 34
#define icRVRock 35
#define icRVCPR 36
#define icREspantoso 37
#define icREmotion 38
#define icRWave 39

; Keys
#define kPedTurnLeftRight 2
#define kVehicleLookLeftRight 2
#define kVehicleTurretLeftRight 2
#define kPedLookLeftRight 3
#define kVehicleTurretUpDown 3
#define kPedAnswerPhone 4
#define kVehicleChangeRadioStation 4
#define kPedCycleWeaponLeft 5
#define kVehicleLookLeft 5
#define kPedLockTarget 6
#define kVehicleHandbrake 6
#define kPedCycleWeaponRight 7
#define kVehicleLookRight 7
#define kGoForward 8
#define kGoBackward 9
#define kGoLeft 10
#define kGoRight 11
#define kExit 12
#define kCameraChangeViewAllSituations 13
#define kPedJumping 14
#define kVehicleBrake 14
#define kVehicleEnterExit 15
#define kPedSprint 16
#define kVehicleAccelerate 16
#define kPedFireWeapon 17
#define kPedDuck 18
#define kVehicleHorn 18
#define kPedLookBehind 19
#define kToggleSubmissions 19

; Weapons
#define wpUnarmed 0
#define wpBrassKnuckle 1
#define wpScrewDriver 2
#define wpGolfClub 3
#define wpNightStick 4
#define wpKnife 5
#define wpBaseballBat 6
#define wpHammer 7
#define wpCleaver 8
#define wpMachete 9
#define wpKatana 10
#define wpChainsaw 11
#define wpGrenade 12
#define wpDetonateGrenade 13
#define wpTearGas 14
#define wpMolotov 15
#define wpRocket 16
#define wpColt45 17
#define wpPython 18
#define wpShotgun 19
#define wpSpas12Shotgun 20
#define wpStubbyShotgun 21
#define wpTec9 22
#define wpUzi 23
#define wpSilencedIngram 24
#define wpMp5 25
#define wpM4 26
#define wpRuger 27
#define wpSniperRifle 28
#define wpLaserScope 29
#define wpRocketLauncher 30
#define wpFlameThrower 31
#define wpM60 32
#define wpMinigun 33
#define wpDetonator 34
#define wpHeliCannon 35
#define wpCamera 36

; Locations
#define lOutside 0
#define lHotel 1
#define lMansion 2
#define lBank 3
#define lMall 4
#define lStripclub 5
#define lLawyers 6
#define lCafeRobina 7
#define lConcertHall 8
#define lStudio 9
#define lShootingRange 10
#define lApartmentAndBikerbar 11
#define lVCPD 12
#define lStadium1 14
#define lStadium2 15
#define lStadium3 16
#define lClub 17
#define lPrintWorks 18

; Particles
#define prSpark 0
#define prSparkSmall 1
#define prWaterSpark 2
#define prWheelDirt 3
#define prSand 4
#define prWheelWater 5
#define prBlood 6
#define prBloodSmall 7
#define prBloodSpurt 8
#define prDebris 9
#define prDebris2 10
#define prFlyers 11
#define prWater 12
#define prFlame 13
#define prFireball 14
#define prGunFlash 15
#define prGunFlashNoAnim 16
#define prGunSmoke 17
#define prGunSmoke2 18
#define prCigaretteSmoke 19
#define prSmoke 20
#define prSmokeSlowMotion 21
#define prDryIce 22
#define prTeargas 23
#define prGaragePaintSpray 24
#define prShard 25
#define prSplash 26
#define prCarFlame 27
#define prSteam 28
#define prSteam2 29
#define prSteamNY 30
#define prSteamNYSlowMotion 31
#define prGroundSteam 32
#define prEngineSteam 33
#define prRaindrop 34
#define prRaindropSmall 35
#define prRainSplash 36
#define prRainSplashBigGrow 37
#define prRainSplashUp 38
#define prWaterSpray 39
#define prWaterDrop 40
#define prBloodDrop 41
#define prExplosionMedium 42
#define prExplosionLarge 43
#define prExplosionMFast 44
#define prExplosionLFast 45
#define prCarSplash 46
#define prBoatSplash 47
#define prBoatThrustJet 48
#define prWaterHydrant 49
#define prWaterCannon 50
#define prExtinguishSteam 51
#define prPedSplash 52
#define prPedFootDust 53
#define prCarDust 54
#define prHeliDust 55
#define prHeliAttack 56
#define prEngineSmoke 57
#define prEngineSmoke2 58
#define prCarFlameSmoke 59
#define prFireballSmoke 60
#define prPaintSmoke 61
#define prTreeLeaves 62
#define prCarCollisionDust 63
#define prCarDebris 64
#define prBirdDebris 65
#define prHeliDebris 66
#define prExhaustFumes 67
#define prRubberSmoke 68
#define prBurningRubberSmoke 69
#define prBulletHitSmoke 70
#define prGunShellFirst 71
#define prGunShell 72
#define prGunShellBump1 73
#define prGunShellBump2 74
#define prRocketSmoke 75
#define prTest 76
#define prBirdFront 77
#define prShipSide 78
#define prBeastie 79
#define prRaindrop_2d 80
#define prHeatHaze 81
#define prHeatHazeInDist 82

; Misc
#define zGround -100.0
#define Infinite 101


I hope CyQ won't mind me posting this here, or else I'll have to remove it sad.gif

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#39

Posted 18 August 2004 - 07:39 PM

He shouldn't do, you did fully quote it as his work.

timmy2004
  • timmy2004

    Gangsta

  • Members
  • Joined: 05 Aug 2004

#40

Posted 30 August 2004 - 07:22 AM

Welcome to my Vice City coding tutorial for beginners!

Tutorial 1

Ok, this tutorial is strictly for beginners. Before we start I hope that you have BW’s Mission builder Version 1.3 (MUST BE VERSION 1.3!!!!!!!!!!!!!!) (u will need it to code vice city).

In this tutorial I will show u how to place cars, health, weapons, and show you how to change the starting position of the player, etc. In the next tutorial (tutorial 2) these things will be explained more and you will learn how to place money, actors and markers. And by the end of it, you will know how to make a car spawn by pressing a button and a simple bodyguard mod.

Lesson one: Weapons
Ok, in BW’s mission builder, open up the file called main.scm in the vice city data folder
Then goto search, and search for this line:

CODE

032B: $471 = create_weapon_pickup #COLT45


as u can see, there are a whole lot of:

CODE

create_weapon_pickup


things, this is where all the weapons are placed in the game. But before u create your own weapon you must understand the code:

CODE

032B: $471 = create_weapon_pickup #COLT45  15 ammo  34 at -228.4 -1318.2  9.1


-the ‘032B’ part is called the opcode (this can be ignored at the moment)
-the ‘$471’ is what rockstar games decided to name this particular weapon (every thing that u create must have a name)
-the ‘create_weapon_pickup’ is what the code is telling the game to do
-the ‘#COLT45’ is the weapon that it is creating
-the ‘15’ is the type (this can be ignored at the moment)
-the ‘ammo 34’ is how much ammo the weapon has
-the ‘at -228.4 -1318.2 9.1’ are the coordinates that you want the weapon to be created

so to create your own weapon copy that piece of code that I just showed you and paste it under it’s self so that you have two of the same codes, you will soon modify this and make your own weapon.

-Ok, first of all give your new weapon a different name, like ‘$myweapon’ instead of ‘$471’
-Then change the ‘#COLT45’ part to another weapon that you like, e.g. ‘#UZI’. Here are some names of weapons that u can choose:
#UZI
#COLT45
#M60
#M4
#GRENADE
#TEC9
#SNIPER
there are just some of the weapons, (but don’t choose any melee weapon because they use a different opcode).
-Then change the ‘ammo 34’ part to whatever u want, like ‘ammo 999’
-Then change the coordinate part of the code to a coordinate of your choice. I have chosen: ‘at 402.428 -465.688 9.918’ (outside the Washington beach police station)
-If you want to get coordinates then download a coordinate reader, like ‘Player Pos’

So I ended up with a piece of code that looks like this:

CODE

032B: $myweapon = create_weapon_pickup #UZI  15 ammo  999 at  402.428 -465.688 9.918


you can now test it by going to: ‘Copy, Compile, Run GTA Vice’
BUT YOU MUST START A NEW GAME!!!!!!!!!!!!!!

It should work!



Lesson two: Pickups (health)

I hope u still have mission builder open.
Ok, search for the line:

CODE

0213: $495 = create_pickup -86


(you should see heaps of these lines)
the one u just searched for should look like this:

CODE

0213: $495 = create_pickup -86 (HEALTH) type  15 at -113.2 -975.7  10.4


as u can see it is much similar to the weapon placing we did in lesson one.
It has an opcode, a name, the thing that tells the game what to do, the pickup that we are placing, a type (type 1 is buyable health and type 15 is free (I think)), and the coordinates. I don’t think I need to explain in further detail.

So copy that line and paste it under its self

So just like before, change the name to whatever u want
then change the coordinates to whatever u want, I have chosen 206.666 -491.721 11.351 (outside the hardware store near the police station)

so now my code should look like this:

CODE

0213: $mypickup = create_pickup -86 (BRIBE) type  15 at  206.666 -491.721 11.351


Copy compile run
Start new game!



Lesson three: Cars

Cars are a bit more tricky (some parts of this I don’t even know what they are) , but you should be able to do it if you stick to this tutorial. But if at any time you get lost, just skip to the next lesson

Search for this line:


014B: $457 = init_parked_car_generator #ADMIRAL


the whole line should look like this:

CODE

014B: $457 = init_parked_car_generator #ADMIRAL  8  8  0 alarm  50 door_lock  0  0  10000 at -401.2715 -534.6655  11.7534 angle  149.2032


and it will have this line underneath it:


014C: set_parked_car_generator $457 cars_to_generate_to 101


lets take a look at this code:

CODE

014B: $457 = init_parked_car_generator #ADMIRAL  8  8  0 alarm  50 door_lock  0  0  10000 at -401.2715 -534.6655  11.7534 angle  149.2032

014C: set_parked_car_generator $457 cars_to_generate_to  101


it is a little similar to the other things we have been doing; it has an opcode, a name, a piece of code that tells the game what to do (init_parked_car_generator), it has what car we are creating (in this case it is an admiral), the ‘8 8’ is the color, I’m not sure what the ‘0’ before the alarm is, it also says ‘alarm 50’ this means that there is 50% chance that the alarm is on and ‘door_lock 0’ this means that there is 0% chance of a locked door, I don’t know what the other ‘0’ is for, but I think the 10000 is the cars health, and obviously the ‘at -401.2715 -534.6655 11.7534 angle 149.2032’ is the coordinates and the angle (angle 0 is facing north and angle 180 is facing south, it goes all the way up to angle 360).

The line after it, is a line that tells the car to acutely appear, it has an opcode, code that tells the game what to do (set_parked_car_generator), the $457 is the name of the car that you want to appear (101 is always appear and 0 is never appearing)

So to create your own car copy those lines and paste them underneath the ones you just copied. Then you need to edit the following to your standards:

You can edit the $457 to name that you want like; $car. Then you can change ‘#ADMIRAL’ to a much better car, here are some:
#banshee
#hotring
#PCJ600
#POLICE
Then you can change the 8 8 to another color, just choose 0 0 (it means random color). Change the door lock and alarm to 0 and 0 (so that we can actually get in the car). Leave the other zero alone and leave the 10000 alone too. Change the coordinates to what ever you want and change the angle to what ever you want. I have chosen;

With the next line, just change the $457 to what ever you called the car. But leave the rest

So my code should look like this

CODE

014B: $car = init_parked_car_generator #PCJ600  0  0  0 alarm  0 door_lock  0  0  10000 at -401.2715 -534.6655  11.7534 angle  149.2032
014C: set_parked_car_generator $car cars_to_generate_to  101


copy, compile, run
and start a new game



Lesson 4: Changing the players starting position, (this is easy)

Search for this line:

CODE

0053: $PLAYER_CHAR = create_player #NULL at


This line creates the player; it should be near the top.
The coordinintas after it tell the player where to start the game. I have chosen; -369.9 -537.1 18.3 (near the hard ware store, next to the health that we placed earlier)

Compile copy run (like always)

That’s it just start a new game

This is the end of tutorial 1

For questions or comments me email me at: [email protected]
Or visit my web site at http://tubbytim.tripod.com

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#41

Posted 31 August 2004 - 12:50 AM

that is very much like mine on page 1!

timmy2004
  • timmy2004

    Gangsta

  • Members
  • Joined: 05 Aug 2004

#42

Posted 01 September 2004 - 06:01 AM

yo, Y_less you are my coding hero; you thought me coding when i first started out, because i read your tutorial. But this was definently not copied from your tutorial!

(but, i must admit after i got good at coding i was inspired to make my own tutorial for people, so because i learnt from you, our tutorials are similar. but i used mission builder 1.3)

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#43

Posted 07 September 2004 - 02:44 PM

I didn't mean it was the same tutorial, I just meant it was a similar idea, but if that is your reasoning then I fully approve, you are now in my good books, I didn't even know I had fans smile.gif . Carry on.

P.S. sorry about the off-topicness.

sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#44

Posted 17 September 2004 - 03:49 AM

Sorry I have not been around much lately I had a pretty serious car accident back in May and hurt my back pretty bad. I lost my car and still haven't gotten another one. Still trying to finish school so I spend a lot of time there.

I updated some of the links in the very first post of this thread. If you still have trouble with them let me know.

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#45

Posted 25 September 2004 - 01:49 PM Edited by Y_Less, 26 December 2004 - 12:51 PM.

Alex "Y_Less" Cole's n00b guide to coding.

Part 3: Variables.

Its been a while since I did parts 1 and 2, so I decided to do another as since that time I have progressed (IMHO) considerably. NOTE: this is designed for BWME 0.22, I do try to outline the differences between that and 1.3, but as that is not my prefered editor, the information may not be accurate.

1. Basics.

In Vice City, for the most part (all the parts I have found, but there may be an exception), integers and floating-points are handled separately, using different sets of OpCodes for definitions, checks and manipulations, although they all do the same thing, just some do it for one type, some for another. Integers are (as most people will know) whole numbers, floating-points are decimal numbers. Variables can hold either type, but must be set up using the correct OpCode set for each type, and they must not be swapped around (they can be changed, but I will cover that later).

So for example:

CODE
0004:  2420?? =  2000&  \\ integer values
0011:  2420?? *=  100!  \\ floating-point values


would not work, wheras:

CODE
0004:  2420?? =  2000&  \\ integer values
0010:  2420?? *=  100?  \\ integer values


would (should) work, giving an answer of 200000&& (I'll come to the symbols after the numbers, people using 1.3 can just ignore them.)

As you can see, you can set a variable immidiately, or you can set it to the result of something else. Most variable OpCodes only have 2 parameters, so you could not use something like:

CODE
0AA5:  2420?? =  2424?? * 5?  \\ integer values and handles


as a) it doesn't exist and, b) there is more than one parameter. If you wanted to set 2420?? to 5 times the value of 2424??, whilst still retaining the value of 2424?? you would need to use code such as:

CODE
0084:  2420?? =  2424??  \\ integer values and handles
0010:  2420?? *=  5?  \\ integer values


to some this may seem awkward and unwieldy, but it reduces the number of OpCodes and can be quite powerful once got used to.

The symbols after the numbers represent the type of number they are:

! - floating-point
? - short integer (0 - 255)
& - integer (256 - 32767)
&& - long integer (32768+)

?? means variable and a preceding $ means custom variable (in 1.3 this is used to represent all variables, integers are assumed and floating-points require at least 1 decimal point (even .0) to identify it as such).

0.22 code:

CODE
0213:  5120?? = create_pickup -205& (CAMERAPICKUP) type  2? at  18!  1148!  24!
0213:  5124?? = create_pickup -4? (BRIBE) type  15? at  474.4158! -1717.396!  57.25289!
018A:  5128?? = create_checkpoint_at  474.4158! -1717.396!  57.25289!
014B:  348?? = init_parked_car_generator #DELUXO -1? -1?  1? alarm  0? door_lock  0?  0?  10000& at -1022.6! -868.6!  12.2! angle  175!
014C: set_parked_car_generator  348?? cars_to_generate_to  0?


corresponding 1.3 code:

CODE
0213: $500 = create_pickup -205 (CAMERAPICKUP) type  2 at  18.0  1148.0  24.0
0213: $501 = create_pickup -4 (BRIBE) type  15 at  474.4158 -1717.396  57.25289
018A: $502 = create_checkpoint_at  474.4158 -1717.396  57.25289
014B: $57 = init_parked_car_generator #DELUXO -1 -1  1 alarm  0 door_lock  0  0  10000 at -1022.6 -868.6  12.2 angle  175.0
014C: set_parked_car_generator $57 cars_to_generate_to  0


2. Integers.

A list of useful integer OpCodes (the corresponding floating-point ones can be found in the next section).

CODE
0004:  268?? =  3?  \\ integer values
0084:  2892?? =  2896??  \\ integer values and handles
0010:  2904?? *=  2?  \\ integer values
0014:  3072?? /=  1000&  \\ integer values - be careful with this one, i'm not sure what happens if the result is not a whole number.
0008:  32?? +=  1?  \\ integer values
000C:  3404?? -=  1?  \\ integer values


Conditionals:

CODE
003A:    6068?? ==  5688??  \\ integer values and handles
0038:    72?? ==  3?  \\ integer values
001C:    1584?? >  4728??  \\ integer values


Their are many other OpCodes to do many other things, I suggest looking through before trying to do anything.

Integer Opcodes are also used for most of the other variables which aren't numerical, e.g. objects and properties. E.g:

CODE
0225:  5480?? = player $PLAYER_CHAR health


would save the result as an integer so you could then do:

CODE
0084:  5484?? =  5480??  \\ integer values and handles
0010:  5484?? *=  5?  \\ integer values


to end up with 5484?? being (if, say, Tommys health was 76) 380.

Also, if you used the OpCode:

CODE
0441:  8436?? = car  8432?? model

then
CODE
0084:  8440?? =  8436??  \\ integer values and handles


Whalst they are not numbers, those OpCodes would still work to set 8440?? and 8436?? to car 8432??'s model.

3. Floating-points.

Used the same as integers except they have differet OpCodes and only handle numbers, nothing else.

Corresponding OpCodes to the listed integer OpCodes:

CODE
0005:  268?? =  3.1!  \\ floating-point values
0086:  2892?? =  2896??  \\ floating-point values only
0011:  2904?? *=  100!  \\ floating-point values
0015:  3072?? /=  2!  \\ floating-point values
0009:  32?? +=  .1!  \\ floating-point values
000D:  3404?? -=  1.85!  \\ floating-point values


Conditionals:

CODE
2 variable conditional never used in VC or GTA 3
0042:    2900?? ==  100!  \\ floating-point values
0024:    3008?? >  2996??  \\ floating-point values only


4. Types of variables.

$type1 - These can be named anything as long as they have a '$' sign at the beginning.

20?? - These are the variables used in the compiled script, all the variables used in the code are compiled into this format, but can be written into it as well.

3@ - These are local variables, they are only used within 1 thread and range from 0 - 17 (apparently there is a 19, but that only works between waits, and I don't know about 18). These can be floating-point or integer, and have their own OpCodes which work for both types.

16@ and 17@ are timer variables. You set them to 0, then next time you access them they will have incremented by the number or milliseconds since your last usage. I.E. they increment by one every millisecond.

5. Usage.

Variables are used to store everything in memory. Anything you define or use must be stored in a variable so the engine can keep a track of it and so you or it can manipulate them later:

CODE
029B: $carcrane = init_object -207& (doc_crane_cab01) at -947.878! -1504.33! 22.3812!


This creates an object (in this case a crane) and stores a reference to it in the variable $carcrane (after compilation - 1008??). This information can then later be used to manipulate the crane:

CODE
00D6: if 0?
834D:   NOT unknown_rotate_object  $carcrane unknown_angle  247!  0.5!  0?
004D: jump_if_false ££Labelsumlabel


It is very difficult to define the use of variables, they are used everywhere and any code without them would be immensly basic, many things can be done without, but they really are important.

I said before that changing between the 2 types is not as straight-forward as it may seem, it can however be attained with the use of:

CODE
008C:  3076?? = float_to_integer  3088??
008D:  3092?? = integer_to_float  3076??




These simply convert between one and the other.

Practice activites:

This tutorial was mostly just information (sorry), but that means there aren't really any practice activities.

Thats it again for another part, I know this one was not as interesting as some of the others, but I did it anyway. My next one will be interesting (for me to write as well) as it is an expansion on variables into the often avoided area of arrays. Many people either despise tham or steer clear of them, but I will attempt to unravel them and make them easier to understand, and show how to use them in 0.22 - its dead easy once you know how they work.

Edit: After being commended for this (thanks very much Dup), i noticed that it still said part 2, its part 3.

Edit: Added local timers.

AdTec_224
  • AdTec_224

    Peon

  • Members
  • Joined: 22 Sep 2004
  • None

#46

Posted 07 October 2004 - 11:21 PM

timmy2004: when is the next tutorial coming out (tutorial 2) where we will learn how to place money, actors and markers.

My Website:

http://adtec224shome...o-members.co.uk

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#47

Posted 09 October 2004 - 10:48 AM

If you are that desperate to find out, tou could read another one that already covers it (e.g. mine plug, plug smile.gif ) on page 1/2.

timmy2004
  • timmy2004

    Gangsta

  • Members
  • Joined: 05 Aug 2004

#48

Posted 09 October 2004 - 11:12 AM

yeah, y_less's tutorials are good!

he tought me


hey y_less, i am in this guy's respect list!

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#49

Posted 11 October 2004 - 08:22 AM

You ARE his respect list!

Its amazing how quickly its going round, I started learning in June, taught you and now you're teching, I wonder how long it'll be before he starts teaching. smile.gif

(soz bout the off-topic-ness).

azzza
  • azzza

    Square Civilian

  • Members
  • Joined: 03 Feb 2004

#50

Posted 22 October 2004 - 01:57 AM

[request] can someone have a tutorial that explains if statements and how to use them in a poper maner(with code snippets)? this is my main draw back as i don't full understand how to use the if statements yet.

sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#51

Posted 22 October 2004 - 05:14 PM Edited by sleeper777, 29 October 2004 - 01:48 PM.

Understanding IFs ANDs and ORs with scm coding is not very hard you just have to remember that the integer passed to the if command
CODE
00D6 IF 0,1,2,3,4,5,6,7 ?

CODE
00D6 IF 21,22,23,24,25,26,27 ?

is one less than the number of conditions used following that if command

0 for 1 condition
1 for 2 conditions
2 for 3 conditions
etc...

the standard if command usage is automatically AND'ed by adding the next condition and changing the integer accordingly

CODE

:labelcodemod
0001: wait  0? ms
00D6: if  1?
0256:   player $PLAYER_CHAR defined
80E0:   NOT   player $PLAYER_CHAR driving
004D: jump_if_false ££labelcodemod
0222: set player $PLAYER_CHAR health to  200&


translates to
CODE

If
>the player character is defined
AND
>the player character is not driving
THEN
>give player 200 health
ELSE
>loops back to check again


If either condition is false the whole IF condition is false and it loops back to the beginning. Thus the need for the wait command to keep this code from running forever, or bogging your game.

Now in order to use OR conditions just add twenty to the integer used by the IF command.

CODE

:NOSboost
0001: wait  0? ms
00D6: if  22?
00DE:   player $PLAYER_CHAR driving vehicle type #PCJ600
00DE:   player $PLAYER_CHAR driving_vehicle_type #CHEETAH
00DE:   player $PLAYER_CHAR driving_vehicle_type #FAGGIO
004D: jump_if_false ££NOSboost
(code to get car speed and modify car speed goes here)


translates to
CODE

IF
>player is Driving a pcj600
OR
>player is Driving a cheetah
OR
>player is Driving a faggio
THEN
>do NOS Code
ELSE
>loop back to check again


this code executes if any one condtion of the three is met, otherwise it continues to loop.

It doesn't get any clearer than that, and it is also good to know that you can't have more than 8 conditions to any one IF that means 1 thru 7 done in the AND fashion and 21 thru 27 done in the OR fashion.... there was some dispute over the maximum number of conditions but i have pulled off eight in GTA3 but had buggy results with 8 in Vice City. Remember if your version of the mission builder gives you 'if command' errors while compiling the original .scm you should turn off if checking from the compiler menu in barton's builders.

DaEllum67
  • DaEllum67

    Liberty City Coder

  • Members
  • Joined: 02 Oct 2004

#52

Posted 03 December 2004 - 11:35 PM Edited by DaEllum67, 03 December 2004 - 11:41 PM.

Sorry, I posted this in the wrong thread. blush.gif

sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#53

Posted 10 December 2004 - 02:23 AM

I have made a few more changes to the first post updating some links and i also indexed a link list of the coding tutorials from this thread so one does not have to sift through the miscellaneous posts to get to the meat of this thread.

As knew tutorials are added i will index those also ....

Horizon Star
  • Horizon Star

    Player Hater

  • Members
  • Joined: 13 Dec 2004

#54

Posted 13 December 2004 - 11:11 PM

This is greate and all but i still dont understand! cryani.gif

Horizon Star
  • Horizon Star

    Player Hater

  • Members
  • Joined: 13 Dec 2004

#55

Posted 13 December 2004 - 11:26 PM

Alright i have to ask i know ppl are going to yell at me but is there any way to delete the original missions and star from scratch desiging your own in Vice City?

U get a cookie.gif if you can help.

sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#56

Posted 14 December 2004 - 09:20 AM

with barton's editor's there are several scripts all ready to go just open with the builder and compile....

in subdirectory of the mission builder directory ie..
CODE

'c:\(Vice Builder Directory)\Stripped scripts'

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#57

Posted 14 December 2004 - 11:15 AM

Cool, cheers sleeper.

May I just make one suggestion regarding the first post, where you compare 2 OpCodes from the different builders, it may be clearer if you use the SAME Opcode so they can see there is a difference, otherwise who knows if they're different or not.

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#58

Posted 25 December 2004 - 08:36 PM Edited by Y_Less, 26 December 2004 - 12:53 PM.

Double post I know, but I have written another part to my mission coding tutorial for newbs after a request (of sorts) from timmy2004.

Alex "Y_Less" Cole's n00b guide to coding.

Part 3b: More Floating Point Numbers.

After a comment by Timmy 2004 on my website about not understanding floating point numbers, I thought "well if he doesn't, what chance do new people stand?" So I decided to write this to help explain them.

Basically, a floating point number is not a whole one 1.2 is a floating point number, 12 isn't. In mission coding, whole and floating numbers are handled by different OpCodes to speed things up (Its a lot easier for computers to do integer operations than floating ones, so they reduce thhe number needed to be done).

You can manipulate whole numbers as floating point ones (e.g. 12 effectively becomes 12.000) and this does have its uses, but this takes longer to process and sometimes you cannot do this due to the type and usage of the integer.

For this I will be using the later MB format of 12 for an integer number and 1.2 (or 12.0) for a floating point (or whole floating point).

As stated earlier, floats use different OpCodes to whole numbers and these cannot be mixed and matched so 5 * 6 would use a different Code to 5.2 * 6.7. They cannot be used together either so 5 * 6.7 wouldn't work at all.

When a variable is stored, so is its type, and this is remembered, so adding 0.1 to 5.9 will not make it suddenly turn into an integer and only be able to use float OpCodes. This would wreak havoc with coding! (On a side note, you cannot use integer OpCodes with the answer at all, its the wrong data type.)

What do I need these for?

They are mainly used for positional data, times and other continuous data. Things like 'people killed' is discrete data, you cannot kill 6.74 people so it is stored as integer data. However you can be stood at co-ordinates 4.5 67.549 -89.6 (yes, negative numbers can be both), 76.1 8.0 1078.5 or pretty much anywhere else.

The only major things I can think of for them are co-ordinates, distances, times/ timings and rotations, though there will be more, minor ones.

So 2.5 by 2.5 is 1.0, not 1, right?

Yes.

But what happens if I divide 7 by 6, the answer isn't a whole number?

No, but if you are using them as integers, they just ignore the remainder.

Changing between them.

This is possible using OpCode's
CODE
008D: (int) integer_to_float (float)
and
CODE
008C: (float) float_to_integer (int)
, which do 'exactly what they say on the tin'

I've tried going into as exhaustive as possible detail, but if you still don't understand anything, or think i've missed something useful or fundamental, tell/ ask me and I'll add it.

Edit: Cheers Craig, added the division info. Also added to tutorial forum.

random_download
  • random_download

    :o

  • Members
  • Joined: 07 Mar 2004

#59

Posted 25 December 2004 - 10:34 PM

QUOTE
3@ - These are local variables, they are only used within 1 thread and range from 0 - 17 (apparently there is a 19, but that only works between waits, and I don't know about 18). These can be floating-point or integer, and have their own OpCodes which work for both types.

16@ and 17@ are timers, so they increase by 1 for every milisecond that passes. Didn't think that was clear in that section.

Craig Kostelecky
  • Craig Kostelecky

    GTA:LC Team Leader

  • The Connection
  • Joined: 28 Jan 2004

#60

Posted 26 December 2004 - 12:47 AM Edited by Craig Kostelecky, 26 December 2004 - 12:51 AM.

QUOTE (Y_Less @ Dec 25 2004, 14:36)
But what happens if I divide 7 by 6, the answer isn't a whole number?

I don’t know, but I suspect it'll just crash your game. Unless you know you are likely to be doing calculations like that, in which case, you would set the numbers/ variables up initialy as floating points (i.e. using 0005 rather than 0004).

When you do integer division the remainders are simply ignored. So 7 / 6 would be 1 (and 6 / 7 = 0) It shouldn't crash the engine.

And there's a few more differences between floats and integers as far as computers are concerned, but for new coders your tutorial pretty much explains it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users