Tutorial Links and Mission Coding Information
Posted 14 July 2004 - 03:28 PM
Posted 14 July 2004 - 08:31 PM
Posted 15 July 2004 - 02:00 AM
Posted 15 July 2004 - 09:12 AM
Posted 15 July 2004 - 01:22 PM
|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).
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.
Posted 13 August 2004 - 11:08 PM
All credits for this info go to the great CyQ...
| ; Standard include file generated by VCDisAsm v1.6 (C) CyQ, 2003|
#define False 0
#define True 1
; Zone info
#define znNight 0
#define znDay 1
#define fdOut 0
#define fdIn 1
#define tmCountUp 0
#define tmCountDown 1
#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
#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
#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
#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
#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
#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
#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
#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
Posted 30 August 2004 - 07:22 AM
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:
032B: $471 = create_weapon_pickup #COLT45
as u can see, there are a whole lot of:
things, this is where all the weapons are placed in the game. But before u create your own weapon you must understand the 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:
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:
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:
0213: $495 = create_pickup -86
(you should see heaps of these lines)
the one u just searched for should look like this:
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:
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:
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:
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:
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
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:
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
Posted 01 September 2004 - 06:01 AM
(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)
Posted 07 September 2004 - 02:44 PM
P.S. sorry about the off-topicness.
Posted 17 September 2004 - 03:49 AM
I updated some of the links in the very first post of this thread. If you still have trouble with them let me know.
Posted 25 September 2004 - 01:49 PM Edited by Y_Less, 26 December 2004 - 12:51 PM.
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.
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:
| 0004: 2420?? = 2000& \\ integer values|
0011: 2420?? *= 100! \\ floating-point values
would not work, wheras:
| 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:
|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:
| 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).
| 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:
| 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
A list of useful integer OpCodes (the corresponding floating-point ones can be found in the next section).
| 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
| 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:
|0225: 5480?? = player $PLAYER_CHAR health|
would save the result as an integer so you could then do:
| 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:
|0441: 8436?? = car 8432?? model|
|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.
Used the same as integers except they have differet OpCodes and only handle numbers, nothing else.
Corresponding OpCodes to the listed integer OpCodes:
| 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
| 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.
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:
|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:
| 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:
| 008C: 3076?? = float_to_integer 3088??|
008D: 3092?? = integer_to_float 3076??
These simply convert between one and the other.
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.
Posted 09 October 2004 - 10:48 AM
Posted 09 October 2004 - 11:12 AM
he tought me
hey y_less, i am in this guy's respect list!
Posted 11 October 2004 - 08:22 AM
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.
(soz bout the off-topic-ness).
Posted 22 October 2004 - 01:57 AM
Posted 22 October 2004 - 05:14 PM Edited by sleeper777, 29 October 2004 - 01:48 PM.
|00D6 IF 0,1,2,3,4,5,6,7 ?|
|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
the standard if command usage is automatically AND'ed by adding the next condition and changing the integer accordingly
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&
>the player character is defined
>the player character is not driving
>give player 200 health
>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.
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)
>player is Driving a pcj600
>player is Driving a cheetah
>player is Driving a faggio
>do NOS Code
>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.
Posted 03 December 2004 - 11:35 PM Edited by DaEllum67, 03 December 2004 - 11:41 PM.
Posted 10 December 2004 - 02:23 AM
As knew tutorials are added i will index those also ....
Posted 13 December 2004 - 11:26 PM
U get a if you can help.
Posted 14 December 2004 - 09:20 AM
in subdirectory of the mission builder directory ie..
'c:\(Vice Builder Directory)\Stripped scripts'
Posted 14 December 2004 - 11:15 AM
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.
Posted 25 December 2004 - 08:36 PM Edited by Y_Less, 26 December 2004 - 12:53 PM.
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?
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
|008D: (int) integer_to_float (float)|
|008C: (float) float_to_integer (int)|
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.
Posted 25 December 2004 - 10:34 PM
|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.
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.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users