Mission Coding for Dummies - Give weapons to actor

A Tutorial for Grand Theft Auto: San Andreas

Hello world. We are one of the oldest mod sites on the Interwebs. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation by sending Arman Ossi Loko points.
  • Post: Give Arman Ossi Loko your thoughts on this Tutorial.
  • Vote: Help Arman Ossi Loko win the Monthly Awards.
  • Rate: Give this Tutorial a rating out of 10.
  • Flag: Alert moderators and warn members of a problem with this Tutorial.
  • Watch: Get notified when this Tutorial is updated.
Mascot

Interested?

Sign up

Already a Bananite? Login

Give weapons to actors **Introduction** In the second part of this tutorial, we will extend the code of part 1. We will give the actor a weapon, and will set some other properties. The player itself gets a weapon too. To make it more fun, the player and the actor needs to kill each other. If you kill the actor, you will get music, a mission passed text and 25000 dollar. We will start with giving the actor a weapon. Before giving a weapon to an actor (the player is also an actor!), we first have to load the weapon-model. Just like we did in part 1 for the actors. It is exactly the same as loading the model for a "normal"-actor. This was the code for loading an "normal" actor: CODE > // Load models 0247: load_model #BFYST 038B: load_requested_models :MODEL_LOAD wait 0 ms if 8248: not model #BFYST available else_jump @MODEL_SPAWN jump @MODEL_LOAD :MODEL_SPAWN We will extend this part of the code by loading the right models of 3 weapons: the desert-eagle, the rocket-launcher and the M4. In the help-files of SannyBuilder we look up the model names and the numbers of the three weapons: Help > SCM Documentation > GTA SA > Weapon Numbers. There we find the following data: desert-eagle 24 #DESERT_EAGLE rocket-launcher 35 #ROCKETLA M4 31 #M4 We extend the code above with the model names of the weapons: CODE > // Load models 0247: load_model #BFYST 0247: load_model #rocketla 0247: load_model #desert_eagle 0247: load_model #m4 038B: load_requested_models :MODEL_LOAD wait 0 ms if or 8248: not model #BFYST available 8248: not model #rocketla available 8248: not model #desert_eagle available 8248: not model #m4 available else_jump @MODEL_SPAWN jump @MODEL_LOAD :MODEL_SPAWN Now the code will stay in the loop as long as any of the model isn't loaded yet. You have to make "if" a "if or", because their is more then one condition. "if or" means that one of the conditions has to be true, "if and" means that all of the conditions have to be true. So in this case, the code waits until all 4 models are loaded. Now we are going to give the weapons. We will start with giving the player a rocket-launcher and a desert-eagle: CODE > 01B2: give_actor $PLAYER_ACTOR weapon 35 ammo 10 // Load the weapon model before using this 01B2: give_actor $PLAYER_ACTOR weapon 24 ammo 30000 // Load the weapon model before using this 01B9: set_actor $PLAYER_ACTOR armed_weapon_to 24 Here you will need the numbers of the weapons which we found in the help-files. We will give the player a rocketlauncher (number 35) with 10 rockets and a desert-eagle (number 24) with 30,000 bullets. The player has two weapons, but can only use one at the same time. To define which is in his hand, you have to use the "01B9" opcode. In this case the player has the desert-eagle in his hands. Now we will give an actor a weapon: CODE > 01B2: give_actor 10@ weapon 31 ammo 30000 // Load the weapon model before using this 01B9: set_actor 10@ armed_weapon_to 31 So the actor gets a M4 (number 31) with 30,000 bullets. It will also be in his hands. Both actors (Player and other) have weapons. Now we will give the actor an assignment: kill the player. We will also set some other properties of the actor. CODE > 05E2: AS_actor 10@ kill_actor $PLAYER_ACTOR The actor (10@) has to kill the player. CODE > actor.WeaponAccuracy(10@)= 90 The weapon accuracy of the actor is 90, so the actor will shoot more accurate then when you don't use this opcode. CODE > actor.Health(10@) = 2000 The actor has a lot of health, so it is more difficult to kill him. CODE > 0350: toggle_actor 10@ maintain_position_when_attacked 1 The actor maintain his position when it's attacked. Otherwise it is possible that he runs away. Now we have to code the end of the fight. We have to check if the actor is dead: CODE > repeat wait 0 ms until actor.Dead(10@) Finally we have to set a sound, a text and a reward: CODE > 0394: play_music 1 01E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1 // MISSION PASSED!~n~~w~$~1~ Player.Money($PLAYER_CHAR) += 25000 The first line is for the sound, the second is for the text. This will display after the actor is dead. We will give a reward of $250000. Then we have to unload the models, just like we learned in previous tutorials: CODE > 0249: release_model #BFYST 0249: release_model #rocketla 0249: release_model #desert_eagle 0249: release_model #m4 [All together (with a stripped file)](http://pastebin.com/f2aa10cf8 "")

Posts

None found

Share

Shareable Image:
Share banner
HTML embed code:
BB embed code:
Markdown embed code:

More embeddable images

Bookmark and Share

Credits

Original Authors
Dutchy3010

Submitter

Arman Ossi Loko avatar
Arman Ossi Loko avatar Lurkin'
Admin Joined 10y
71,925 points Ranked 56th
63 medals 9 legendary 16 rare
  • GTAV First Adopter Medal icon
  • Submitted 15 Tools Medal icon
  • Submitted 30 Tutorials Medal icon
  • 1st place - 2015 Uberstyles Contest Medal icon
  • Achieved Admin clearance Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2015 Medal icon

Arman Ossi Loko avatar
Arman Ossi Loko
KOPASSUS Incorporated Flag
KOPASSUS Incorporated

Redistributor
Are you the owner? Request Ownership
Sign up to access this!
Sign up to access this!
Sign up to access this!
Sign up to access this!

Category

Details

Difficulty Level
Beginner Difficulty

Attributes

Stats

Posts
0
Views
2,551
Date Added
5y
Date Modified
4y
bcp.crwdcntrl.net tracking pixel