Mission Coding for Dummies - Actors

A Tutorial for Grand Theft Auto: San Andreas

Yo, buddy. 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

Stop Lurking!

Sign up

Already a Bananite? Login

Actors There are 2 types of actors: 'normal' actors and 'special' actors. The normal actors are easier to make, because they have to be loaded just like normal models (like weapons). The special actors are a bit more difficult, but I will explain it later. We will begin with a "stripped" code, that is a code which is clean. The only thing you can do, is walk/drive around. It is perfect for a new mod. An actor is a character in the game, like Sweet, but also random pedestrians. First we are going to spawn a normal actor. You have to do it in three steps: - Load actor models (and check if it is loaded) - Spawn actors - Unload models Load actor models (and check if it is loaded): CODE > // Load models 0247: load_model #BFYST 038B: load_requested_models I think this part of the code speaks for itself, but I will explain it shortly. When you typ //, it is a comment, like it was told in previous tutorials. This is only a note for the coder. In the line "load_model", you have to say which model you want to use. If you are looking for a specific ped, you can find the name by using the ped editor. I chose for BFYST, but there are also other possibilities. You have to write the third line because then the previous models will actually be loaded. Then you have to check if the model is loaded: CODE > :MODEL_LOAD wait 0 ms if 8248: not model #BFYST available else_jump @MODEL_SPAWN jump @MODEL_LOAD :MODEL_SPAWN You have to make a new label, because you are creating a loop. Then you know where you can jump to. It doesn't matter which name you give to the label, I called it "MODEL_LOAD". I advise you to give it a clear name, because it is easier to find it when you have a big mod. When you followed the previous tutorials, you know what the jump-if-false (or else_jump) structure is. This is a example of its usage. If the model " BFYST" isn't available, then jump to MODEL_LOAD. If it is available, jump to :MODEL_SPAWN. The following code is the same: CODE > :MODEL_LOAD wait 0 ms if 0248: model 15@ available else_jump @MODEL_LOAD Spawn Actor CODE > :MODEL_SPAWN 10@ = Actor.Create(CIVFEMALE, #BFYST, 0.0, 0.0, 0.0) Actor.Angle(10@) = 318.9705 The 10@ is a local variable, it doesn't matter which number you are using. It has to be under the 32, because that is the maximum within a thread (when you are using an "official" mission structure, it can be more then 33). Then we are going to assign the variable a value, in this case an actor. So we give the actor, in this case, the name "10@". Actor.Create is the command, I think it speaks for itself. After that, you will see 5 parameters. First the type of the ped, CIVFEMALE. Then the model name and after that there are 3 coords: x, y and z. Like I already told in previous tutorials, there is a built-in coords tool in SannyBuilder, you can use that to determine coordinates like these. The Actor Angle is the direction of the ped. 0.0 is to the west. So if you want him to stand to the east, you have to give it an angle of 180.0. You can also use the coords tool for this. Model unload Finally you have to unload the model: CODE > 0249: release_model #BFYST Caution! Release_model doesn't mean that he actor will disappear! Just like loading the actor doesn't mean that you spawn the actor. You have to use another opcode to delete the actor (e.g. 009B: destroy_actor 18@) So the complete code for an actor spawn is: CODE > > // Load models 0247: load_model #BFYST 038B: load_requested_models :MODEL_LOAD 00D6: if 8248: not model #BFYST available 004D: jump_if_false @MODEL_SPAWN 0001: wait 0 ms 0002: jump @MODEL_LOAD :MODEL_SPAWN 10@ = Actor.Create(CIVFEMALE, #BFYST, 0.0, 0.0, 0.0) //Here you do what you want to do with the actor. 0249: release_model #BFYST With the Ped Editor you can find your ped-model, you will also get a view of the ped (how he looks ingame). You will see the name of the ped and the group/type. So for making an actor spawn, you need SannyBuilder (to edit the file), coords tool (in SannyBuilder) and Ped Editor to look up the names of the actor-models. Special Actors Special Actors are a bit more difficult. You have 10 "slots" for special actors models. You can compare this to the 8 slots in which you can save you savegame: you can only have 8 at one time, and if you want another savegame, you have to delete one first. To see a list of all special actors, you can look in the helpfile: Help > Contents > SCM Documentation > GTA SA > Special Actors. When you understand the normal actors, you can also understand special actors. It looks a similar, but with slightly different code. Again, you have to load the model, check if the model is available, spawn the actor and unload the model. Loading the model We take Catalina for example. You will see, when you look to the SCM Documentation, that she has the name 'CAT'. First we are going to load the model: CODE > // Load models 023C: load_special_actor 'CAT' as 1 // models 290-299 038B: load_requested_models So in this code, you load special actor Catalina (CAT), at slot 1. Next to this one, you can load upto 9 others. Check if it is loaded: CODE > :MODEL_LOAD if 823D: not special_actor 1 loaded else_jump @MODEL_SPAWN wait 0 ms jump @MODEL_LOAD :MODEL_SPAWN This is almost the same as the "normal" actor. Only the second line is a different, the structure is the same: when the model of the special actor isn't loaded, jump to the label MODEL_LOAD. If it is loaded, jump to MODEL_SPAWN. The 1 is in this case the number of the slot, in which you loaded it. Spawning the actor CODE > :MODEL_SPAWN 009A: 10@ = create_actor_pedtype CIVFEMALE model #SPECIAL01 at 0.0 0.0 0.0 0173: set_actor #SPECIAL01 Z_angle_to 0.0 It is exactly the same as for 'normal' actors, except that the models are named #SPECIALxx. XX depends on which slot you used. In this case, it is 01, because it was slot 1. If it was slot 2, you have to use: #SPECIAL02. CIVFEMALE is the pedtype, the angle is just like normal actors. Unload the actor Finally you have to unload it: CODE > 0296: unload_special_actor 1 So we unload the model of the special actor, which is in slot 1. The whole code to spawn a special actor: CODE > // Load models 023C: load_special_actor 'CAT' as 1 // models 290-299 038B: load_requested_models > :MODEL_LOAD 00D6: if or 823D: not special_actor 1 loaded 004D: jump_if_false @MODEL_SPAWN 0001: wait 0 ms 0002: jump @MODEL_LOAD :MODEL_SPAWN 009A: 10@ = create_actor_pedtype CIVMALE model #SPECIAL01 at 0.0 0.0 0.0 0173: set_actor 10@ Z_angle_to 0.0 //Here you do what you want to do with the actor. 0296: unload_special_actor 1 When you include a normal actor to a stripped file! You can let the actor do many things, like get in a car, or shoot at someone. But first you have to spawn them, then you can add other things. That is why it is essential to know this. I hope you learned something from this tutorial, and if you have any questions, just let me know!

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
1,760
Date Added
5y
Date Modified
4y
bcp.crwdcntrl.net tracking pixel