Difference between revisions of "04A7"

From GTAMods Wiki
Jump to navigation Jump to search
m
(page updates + code snippet)
Line 1: Line 1:
{{OpCode
+
{{Icon|SA}} '''IS_CHAR_IN_ANY_BOAT'''
| ini        = 04A7=1,  %1d%
+
<hr />
| description = Checks if an actor is in a boat
+
'''Description'''
| p1          = Actor handle
+
: Checks if the character is in a boat
| game        = [[San Andreas]]
+
'''Syntax'''
| native      = [[IS_CHAR_IN_ANY_BOAT]]
+
: 04A7: &nbsp; actor [''char handle''] driving_boat
}}
+
'''Parameter'''
This opcode checks if an actor is in a boat, either as a driver or a passenger. It supersedes [[Vice City]]'s opcode [[04A8]].
+
: [''char handle'']
 +
:: The handle of the character
 +
'''Native analog'''
 +
: [[IS_CHAR_IN_ANY_BOAT]]
  
==List of Boats==
+
This conditional opcode returns true if the character is in a boat, either as a driver or a passenger. It supersedes [[Vice City]]'s opcode [[04A8]]. The game will recognize the following list of vehicles as boats.
The game will recognize the following list of vehicles as boats.
 
 
*Coastguard
 
*Coastguard
 
*Dinghy
 
*Dinghy
Line 21: Line 23:
 
*Tropic
 
*Tropic
  
==Keywords==
+
== For GTA III and Vice City ==
actor, character, driving, boat
+
This opcode does not exist in GTA III and Vice City but it is possible to check the type of vehicle a character is in. The following example, using Sanny Builder with [[CLEO]] for GTA III and 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 for Vice City:
 +
<syntaxhighlight lang="scm">
 +
:opcode_04A7
 +
// 0@ - input param (char handle)
 +
if
 +
    00DF:  actor 0@ driving
 +
then
 +
    03C0: 0@ = actor 0@ car
 +
    05E7: 0@ = car 0@ struct
 +
    05E4: call_function_method 0x5BAA80 struct 0@ num_params 0 pop 1 store_to 0@  // get vehicle type
 +
    if
 +
        0@ == 4  // is type boat
 +
    then
 +
    end
 +
end
 +
05F6: ret 0
 +
</syntaxhighlight>
 +
 
 +
or for GTA III:
 +
<syntaxhighlight lang="scm">
 +
:opcode_04A7
 +
// 0@ - input param (char handle)
 +
if
 +
    00DF:  actor 0@ driving
 +
then
 +
    03C0: 0@ = actor 0@ car
 +
    05E7: 0@ = car 0@ struct
 +
    0@ += 0x284  // vehicle type offset
 +
    05E0: 0@ = read_memory 0@ size 1 virtual_protect 0  // get value
 +
    if
 +
        0@ == 1  // is type boat
 +
    then
 +
    end
 +
end
 +
05F6: ret 0
 +
</syntaxhighlight>
 +
 
 +
Use this line as a substitute for opcode 04A7. This can be placed anywhere within the external script as a conditional statement:
 +
<syntaxhighlight lang="scm">
 +
// ...
 +
if
 +
    05F5: call_scm_func @opcode_04A7 inputs 1 char_handle [char handle]
 +
then
 +
    // [RETURNED TRUE]
 +
else
 +
    // [RETURNED FALSE]
 +
end
 +
// ...
 +
</syntaxhighlight>
 +
 
 +
== Keywords ==
 +
actor, character, driving, any, boat
 +
 
 +
[[Category:OpCodes]]
 +
[[Category:Code Snippets]]

Revision as of 06:14, 29 July 2015

San Andreas IS_CHAR_IN_ANY_BOAT


Description

Checks if the character is in a boat

Syntax

04A7:   actor [char handle] driving_boat

Parameter

[char handle]
The handle of the character

Native analog

IS_CHAR_IN_ANY_BOAT

This conditional opcode returns true if the character is in a boat, either as a driver or a passenger. It supersedes Vice City's opcode 04A8. The game will recognize the following list of vehicles as boats.

  • Coastguard
  • Dinghy
  • Jetmax
  • Launch
  • Marquis
  • Predator
  • Speeder
  • Squalo
  • Reefer
  • Tropic

For GTA III and Vice City

This opcode does not exist in GTA III and Vice City but it is possible to check the type of vehicle a character is in. The following example, using Sanny Builder with CLEO for GTA III and 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 for Vice City:

:opcode_04A7
// 0@ - input param (char handle)
if
    00DF:   actor 0@ driving
then
    03C0: 0@ = actor 0@ car
    05E7: 0@ = car 0@ struct
    05E4: call_function_method 0x5BAA80 struct 0@ num_params 0 pop 1 store_to 0@  // get vehicle type
    if
        0@ == 4  // is type boat
    then
    end
end
05F6: ret 0

or for GTA III:

:opcode_04A7
// 0@ - input param (char handle)
if
    00DF:   actor 0@ driving
then
    03C0: 0@ = actor 0@ car
    05E7: 0@ = car 0@ struct
    0@ += 0x284  // vehicle type offset
    05E0: 0@ = read_memory 0@ size 1 virtual_protect 0  // get value
    if
        0@ == 1  // is type boat
    then
    end
end
05F6: ret 0

Use this line as a substitute for opcode 04A7. This can be placed anywhere within the external script as a conditional statement:

// ...
if
    05F5: call_scm_func @opcode_04A7 inputs 1 char_handle [char handle]
then
    // [RETURNED TRUE]
else
    // [RETURNED FALSE]
end
// ...

Keywords

actor, character, driving, any, boat