Difference between revisions of "04A7"

From GTAMods Wiki
Jump to navigation Jump to search
(page updates + code snippet)
Line 11: Line 11:
 
: [[IS_CHAR_IN_ANY_BOAT]]
 
: [[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.
+
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]]. By default the game will recognize the following list of vehicles as boats (for which the IS_BOAT model flag is set in the [[Handling.cfg#Model_Flag_Data|handling.cfg]] file):
 
*Coastguard
 
*Coastguard
 
*Dinghy
 
*Dinghy

Revision as of 20:47, 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. By default the game will recognize the following list of vehicles as boats (for which the IS_BOAT model flag is set in the handling.cfg file):

  • 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