- Gives the weapon to the character
- 01B2: give_actor [char handle] weapon [int1] ammo [int2]
- [char handle]
- The handle of the character
- Weapon type
- Native analog
This opcode adds to the character's weapon ammo and sets the weapon as the current one for the character. If the character does not have the weapon, the weapon is given to it and replaces any weapon of the same slot. Using this opcode requires loading the weapon model through 0247 or else the weapon might not be visible which can crash the game. When the character dies, it drops the weapon as a pickup type 4 with predefined ammo count.
The following example using Sanny Builder will spawn a character holding a pistol close to the player character. The values used here are for Vice City and should be changed if used for other games.
// set constants const CHAR_MODEL = #BFORI // set your character model WEAP_MODEL = #COLT45 // set your weapon model WEAP_TYPE = 17 // set your weapon type SPAWNED_CHAR = [email protected] X_POS = [email protected] Y_POS = [email protected] Z_POS = [email protected] end // load models, required to prevent unnecessary crash! 0247: request_model CHAR_MODEL 0247: request_model WEAP_MODEL 038B: load_requested_models // spawn character with weapon 00A0: store_actor $PLAYER_ACTOR position_to X_POS Y_POS Z_POS X_POS += 4.0 009A: SPAWNED_CHAR = create_actor 4 CHAR_MODEL at X_POS Y_POS Z_POS 01B2: give_actor SPAWNED_CHAR weapon WEAP_TYPE ammo 100 // cleanup 0249: release_model CHAR_MODEL 0249: release_model WEAP_MODEL 01C2: remove_references_to_actor SPAWNED_CHAR
give, assign, actor, character, weapon