Difference between revisions of "0491"
Jump to navigation
Jump to search
(Created page with "{{Icon|SA}} '''HAS_CHAR_GOT_WEAPON''' <hr /> '''Description''' : Checks if the character has the specified weapon '''Syntax''' : 0491: actor [''char handle''] has_weapo...") |
(highlight) |
||
Line 1: | Line 1: | ||
− | {{Icon|SA}} | + | {{OpCode |
− | + | | games = {{Icon|SA}} | |
− | + | | command = HAS_CHAR_GOT_WEAPON | |
− | + | | description = Checks if the character has the specified weapon | |
− | + | | syntax1 = 0491: actor [''char handle''] has_weapon [''int''] | |
− | + | | p1t = [''char handle''] | |
− | + | | p1d = The handle of the character | |
− | + | | p2t = [''int''] | |
− | + | | p2d = [[Weapon#San Andreas|Weapon number]] | |
− | + | }} | |
− | |||
− | This conditional opcode returns true if the character has the specified weapon | + | This conditional opcode returns true if the character has the specified weapon. |
== For Vice City == | == 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 | + | 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: |
− | < | + | {{Pre|class=sb-code|1= |
− | :opcode_0491 | + | <span class="nl">:opcode_0491</span> |
− | // 0@ - input param (char handle) | + | <span class="c1">// 0@ - input param (char handle)</span> |
− | // 1@ - input param (weapon number) | + | <span class="c1">// 1@ - input param (weapon number)</span> |
− | 05E6: 0@ = actor 0@ struct | + | 05E6: <span class="nv">0@</span> = actor <span class="nv">0@</span> struct |
− | 0@ += 0x408 // weapons offset | + | <span class="nv">0@</span> += <span class="m">0x408</span> <span class="c1">// weapons offset</span> |
− | 2@ = 0 // index | + | <span class="nv">2@</span> = <span class="m">0</span> <span class="c1">// index</span> |
− | while 2@ < 10 | + | <span class="k">while</span> <span class="nv">2@</span> < <span class="m">10</span> |
− | 05E0: 3@ = read_memory 0@ size 4 virtual_protect 0 // read weapon number | + | 05E0: <span class="nv">3@</span> = read_memory <span class="nv">0@</span> size <span class="m">4</span> virtual_protect <span class="m">0</span> <span class="c1">// read weapon number</span> |
− | if | + | <span class="k">if</span> |
− | 003B: 3@ == 1@ // weapon number matches | + | 003B: <span class="nv">3@</span> == <span class="nv">1@</span> <span class="c1">// weapon number matches</span> |
− | then | + | <span class="k">then</span> |
− | 05F6: ret 0 | + | 05F6: ret <span class="m">0</span> |
− | end | + | <span class="k">end</span> |
− | 0@ += 0x18 // iterate weapon struct | + | <span class="nv">0@</span> += <span class="m">0x18</span> <span class="c1">// iterate weapon struct</span> |
− | 2@ += 1 // iterate index | + | <span class="nv">2@</span> += <span class="m">1</span> <span class="c1">// iterate index</span> |
− | end | + | <span class="k">end</span> |
− | 05F6: ret 0 | + | 05F6: ret <span class="m">0</span> |
− | </ | + | }} |
Use this line as a substitute for opcode 0491. This can be placed anywhere within the external script as a conditional statement: | Use this line as a substitute for opcode 0491. This can be placed anywhere within the external script as a conditional statement: | ||
− | < | + | {{Pre|class=sb-code|1= |
− | // ... | + | <span class="c1">// ...</span> |
− | if | + | <span class="k">if</span> |
− | 05F5: call_scm_func @opcode_0491 inputs 2 char_handle [char handle] weapon [int] | + | 05F5: call_scm_func <span class="nl">@opcode_0491</span> inputs <span class="m">2</span> char_handle [char handle] weapon [int] |
− | then | + | <span class="k">then</span> |
− | // [RETURNED TRUE] | + | <span class="c1">// [RETURNED TRUE]</span> |
− | else | + | <span class="k">else</span> |
− | // [RETURNED FALSE] | + | <span class="c1">// [RETURNED FALSE]</span> |
− | end | + | <span class="k">end</span> |
− | // ... | + | <span class="c1">// ...</span> |
− | </ | + | }} |
+ | |||
+ | Be careful if you want to modify the example because the loop does not have a [[0001|wait]] in order to minimize any delays. Alternatively, the loop can be unrolled to result in the same behavior. | ||
== Keywords == | == Keywords == | ||
has, actor, character, got, weapon | has, actor, character, got, weapon | ||
− | + | == See also == | |
− | [[ | + | * {{Icon|VC}} [[0490]], checks if the player has the specified weapon |
Revision as of 12:43, 21 December 2016
- 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 number
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 number) 05E6: 0@ = actor 0@ struct 0@ += 0x408 // weapons offset 2@ = 0 // index while 2@ < 10 05E0: 3@ = read_memory 0@ size 4 virtual_protect 0 // read weapon number if 003B: 3@ == 1@ // weapon number matches then 05F6: ret 0 end 0@ += 0x18 // iterate weapon struct 2@ += 1 // iterate 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