Quadropheniac90 Posted June 9, 2006 Share Posted June 9, 2006 (edited) I made a piece of code to make a car $PLCAR be able to drop bombs and when the button with which the bombs are dropped is pressed when a bomb is made, it explodes. Also, when you get into a car that is not $PLCAR, the new car cannot drop bombs or explode bombs which have been dropped by another car. I still have to make a sphere somewhere or something to remove references to the old $PLCAR and make the car in the sphere $PLCAR, but for now I made the first car the player enters at the start of the game $PLCAR for easy testing. Here's the code (I don't care if anybody rips it, it's probably not good enough anyways): :CARWEAPS 0001: wait 0 ms 0247: request_model #SATCHEL038B: load_requested_models:CHECKCHAIN0001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 00449: actor $PLAYER_ACTOR in_a_car004D: jump_if_false ££CHECKCHAIN03C0: $PLCAR = actor $PLAYER_ACTOR car 00D6: if 08119: NOT car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD:CARCHECKKEY0001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 08119: NOT car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD00D6: if 00448: actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££CARCHECKKEY00D6: if 000E1: key_pressed 0 17004D: jump_if_false ££CARCHECKKEY0002: jump ££KEYREL:KEYREL 0001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 08119: NOT car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD00D6: if 00448: actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££CARCHECKKEY00D6: if 080E1: NOT key_pressed 0 17004D: jump_if_false ££KEYREL0002: jump ££GOGO1 :GOGO10001: wait 0 ms 00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF 00D6: if 08119: NOT car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD00D6: if 00248: model #SATCHEL available004D: jump_if_false ££GOGO100D6: if 083CA: NOT object @6 exists004D: jump_if_false ££EXPLODE00D6: if 00448: actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££GOGO10050: gosub ££DROPBOMB0002: jump ££CARWEAPS:DROPBOMB0407: create_coordinate @1 @2 @3 from_car $PLCAR offset 0.0 -3.0 -.50174: @4 = car $PLCAR z_angle0009: @4 += 90.0;; floating-point values02CE: @5 = ground_z @1 @2 @3 0107: @6 = create_object #SATCHEL at @1 @2 @30249: release_model #SATCHEL 0177: set_object @6 z_angle_to @40051: return :EXPLODE00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF 020C: create_explosion_with_radius 10 at @1 @2 @3064B: @7 = create_particle "EXPLOSION_SMALL" at @1 @2 @3 1064C: make_particle @7 visible0108: destroy_object @60002: jump ££CARCHECKKEY :CRWCKPDD01C3: remove_references_to_car $PLCAR (This is for ease of coding as well, I can make a new car $PLCAR when my previous one broke down. Normally, I'd end the thread off course.) 0002: jump ££CARWEAPS :PLDEF00D6: if 083CA: NOT object @6 exists004D: jump_if_false ££PLDEF_B0002: jump ££CARWEAPS :PLDEF_B020C: create_explosion_with_radius 10 at @1 @2 @3064B: @7 = create_particle "EXPLOSION_SMALL" at @1 @2 @3 1064C: make_particle @7 visible0108: destroy_object @60002: jump ££CARWEAPS I'm not very good at it, and I'd appreciate any help shortening it, or even someone telling me if it has to be shortened. Is it good as it is? Or can it be more compact? Thanks for any help. EDIT: Because there's no way I can let people save their bombdrop addition, I will do the following whenever the player is in a garage: I check if the car is in one of the saving garages, if so, I display text, and I check if the player still in, always checking if the car's wrecked or the player is defined, and the moment the player is out, the script ends. (Restarts, because of the create_thread. It does restart after it ends, doesn't it?) Then, the whole thing can be done again, etc. I also add that only normal cars and bikes can drop bombs, no bicycles, planes, heli's, and boats. Though boats could be fun. Edited June 9, 2006 by teun.steenbekkers Link to comment Share on other sites More sharing options...
random_download Posted June 9, 2006 Share Posted June 9, 2006 Couple of places you could make it slightly more compact without altering what the code actually does: 0002: jump ££KEYREL:KEYREL 0002: jump ££GOGO1:GOGO1 In those two places the jumps aren't needed as the code goes straight to the next label anyway. :EXPLODE00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF There you don't need the player_defined check, as there was already one since the last wait. :CARWEAPS0001: wait 0 ms The wait is not needed there, as the code will always go on to a wait just below it. If you change what your code does, you could make it more compact. The check to see if the model is loaded could have the player_defined and in_car checks removed, as it doesn't matter if these change whilst the model is loading. You could also remove the same checks when checking to see if the key has been released. Alternativly, if you wanted to keep these checks you could use a gosub to them as you do the same ones 4 times in different places I think. Hope this helps Link to comment Share on other sites More sharing options...
Quadropheniac90 Posted June 10, 2006 Author Share Posted June 10, 2006 Yeah, thanks! One question though: How should I make that 'gosub' for the checks? Those checks all have a 'jump_if_false' of course, but I thought a 'gosub' always had to return. Now I think it'd just jump to another thread and stuff up, or something. Or am I way off here? Thanks for the help. Link to comment Share on other sites More sharing options...
random_download Posted June 10, 2006 Share Posted June 10, 2006 Ahhh, you're right lol. You wouldn't be able to gosub but you could do: :CARCHECKKEY0001: wait 0 [email protected] = ££CARCHECKKEY_20002: jump ££GosubTypeThing:CARCHECKKEY_200D6: if 00448: actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££CARCHECKKEY00D6: if 000E1: key_pressed 0 17004D: jump_if_false ££CARCHECKKEY0002: jump ££KEYREL...:GosubTypeThing00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 08119: NOT car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD0002: jump @0 Which would probably make your code more compact, however it would mean that the game had to process extra commands. Sacrifice efficiency for space, or vica versa. Link to comment Share on other sites More sharing options...
Quadropheniac90 Posted June 10, 2006 Author Share Posted June 10, 2006 I'll stay with this one then. Now to add me a trigger. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now