0491
Revision as of 19:43, 7 July 2017 by Spaceeinstein (talk | contribs)
- Description
- Checks if the character has the specified weapon
- Syntax
- 0491: actor [char handle] has_weapon [int]
- Parameter
- [char handle]
- The handle of the character
- [int]
- Weapon type
This conditional opcode returns true if the character has the specified weapon.
For Vice City
This opcode does not exist in Vice City but it is possible to check if the character has the specified weapon. The following example, using Sanny Builder with CLEO for Vice City in an external script (not the main one) and tested on US v1.0, should work similarly to this opcode. Place this at the end of the file:
:opcode_0491 // 0@ - input param (char handle) // 1@ - input param (weapon type) 05E6: 0@ = actor 0@ struct 0@ += 0x408 // weapon structs base offset 2@ = 0 // index while 2@ < 10 05E0: 3@ = read_memory 0@ size 4 virtual_protect 0 // read weapon type if 003B: 3@ == 1@ // weapon type matches then 05F6: ret 0 end 0@ += 0x18 // increment weapon struct 2@ += 1 // increment index end 05F6: ret 0
Use this line as a substitute for opcode 0491. This can be placed anywhere within the external script as a conditional statement:
// ... if 05F5: call_scm_func @opcode_0491 inputs 2 char_handle [char handle] weapon [int] then // [RETURNED TRUE] else // [RETURNED FALSE] end // ...
Be careful if you want to modify the example because the loop does not have a wait in order to minimize any delays. Alternatively, the loop can be unrolled to result in the same behavior.
Keywords
has, actor, character, got, weapon
See also
- 0490, checks if the player has the specified weapon