Difference between revisions of "01B2"
Jump to navigation
Jump to search
Thehambone (talk | contribs) m (→Example: 01C2 requires an actor handle, not a character model id.) |
m |
||
Line 1: | Line 1: | ||
− | {{Icon| | + | {{OpCode |
− | + | | games = {{Icon|t}} | |
− | + | | command = GIVE_WEAPON_TO_CHAR | |
− | + | | description = Gives a weapon to the character | |
− | + | | syntax1 = 01B2: give_actor [''char handle''] weapon [''int1''] ammo [''int2''] | |
− | + | | p1t = [''char handle''] | |
− | + | | p1d = The handle of the character | |
− | + | | p2t = [''int1''] | |
− | + | | p2d = [[Weapon#Lists of Weapons|Weapon number]] | |
− | + | | p3t = [''int2''] | |
− | + | | p3d = Ammo | |
− | + | | native = [[GIVE_WEAPON_TO_CHAR]] | |
− | + | }} | |
− | |||
− | |||
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 group. 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 [[0213#Weapons|pickup type 4 with predefined ammo count]]. | 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 group. 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 [[0213#Weapons|pickup type 4 with predefined ammo count]]. | ||
Line 60: | Line 58: | ||
== See also == | == See also == | ||
− | * [[017B]], sets the character's weapon ammo | + | * {{Icon|3}} {{Icon|SA}} [[017B]], sets the character's weapon ammo |
− | * [[01B1]], gives a weapon to the player | + | * {{Icon|3}} {{Icon|VC}} [[01B1]], gives a weapon to the player |
− | |||
− | |||
− |
Revision as of 08:00, 16 June 2016
- Description
- Gives a weapon to the character
- Syntax
- 01B2: give_actor [char handle] weapon [int1] ammo [int2]
- Parameter
- [char handle]
- The handle of the character
- [int1]
- Weapon number
- [int2]
- Ammo
- Native analog
- GIVE_WEAPON_TO_CHAR
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 group. 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.
Example
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
WEAP_MODEL = #COLT45
WEAP_NUMBER = 17 // each game is different! see weapons page for the proper number to use!
SPAWNED_CHAR = 0@
X_POS = 1@
Y_POS = 2@
Z_POS = 3@
end
// load models, required to prevent unnecessary crash!
0247: request_model CHAR_MODEL
0247: request_model WEAP_MODEL
// check if models are loaded
repeat
wait 0
if and
0248: model CHAR_MODEL available
0248: model WEAP_MODEL available
then
break
end
until false
// 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_NUMBER ammo 100
// cleanup
0249: release_model CHAR_MODEL
0249: release_model WEAP_MODEL
01C2: remove_references_to_actor SPAWNED_CHAR
Keywords
give, assign, actor, character, weapon