Difference between revisions of "04C9"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with "{{Icon|VC}} '''IS_PLAYER_IN_FLYING_VEHICLE''' <hr /> '''Description''' : Checks if the player is in a flying vehicle '''Syntax''' : 04C9:   player [''player handle''] in_...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Icon|VC}} '''IS_PLAYER_IN_FLYING_VEHICLE'''
+
{{OpCode
<hr />
+
| games      = {{Icon|VC}}
'''Description'''
+
| command    = IS_PLAYER_IN_FLYING_VEHICLE
: Checks if the player is in a flying vehicle
+
| description = Checks if the player is in a flying vehicle
'''Syntax'''
+
| syntax1    = 04C9: &nbsp; player [''player handle''] in_flying_vehicle
: 04C9: &nbsp; player [''player handle''] in_flying_vehicle
+
| p1t        = [''player handle'']
'''Parameter'''
+
| p1d        = The [[0053|handle of the player]]
: [''player handle'']
+
}}
:: The [[0053|handle of the player]]
 
  
This conditional opcode returns true if the player is in a flying vehicle, either as a driver or a passenger. It behaves the same way as using both opcodes [[04AA]] and [[04AC]] together. This opcode is [[List of unsupported opcodes|unsupported]] in [[San Andreas]] and is superseded by opcode [[04C8]]. By default the game will recognize the following list of vehicles as flying vehicles (for which the IS_HELI or IS_PLANE flag is set in the [[Handling.cfg#Flag_Data_2|handling.cfg]] file):
+
This conditional opcode returns true if the player is in a flying vehicle, either as a driver or a passenger. It behaves the same way as using both opcodes [[04AA]] and [[04AC]] together. By default the game will recognize the following list of vehicles as flying vehicles (for which the IS_HELI or IS_PLANE flag is set in the [[Handling.cfg#Flag_Data_2|handling.cfg]] file):
 
* Hunter
 
* Hunter
 
* Maverick
 
* Maverick
Line 21: Line 20:
 
* VCN Maverick
 
* VCN Maverick
 
Legacy documentation describes this as applying to just planes.
 
Legacy documentation describes this as applying to just planes.
 +
 +
== Disassembled code ==
 +
This is disassembled code for this opcode from PC v1.0 US.
 +
<syntaxhighlight lang="nasm">
 +
loc_630F46:
 +
    lea    eax, [ebp+10h]                    ; get address of script's current instruction pointer
 +
    mov    ecx, ebp                          ; get address of script for thiscall
 +
    push    1                                ; push 1 for one parameter to collect
 +
    push    eax                              ; push address of script's current instruction pointer
 +
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
 +
    mov    edi, ds:ScriptParams[0]          ; get value of first parameter, the player handle
 +
    xor    bl, bl                            ; set compare flag to false
 +
    imul    edi, 170h
 +
    add    edi, offset CWorld::Players
 +
    mov    eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
 +
    cmp    byte ptr [eax+3ACh], 0            ; offset player ped address by 0x3AC and check whether or not the player ped is in a vehicle
 +
    jz      short loc_630F9A
 +
    mov    ecx, [eax+3A8h]                  ; offset player ped address by 0x3A8 to get address of last entered vehicle for thiscall
 +
    test    ecx, ecx                          ; check whether or not the last entered vehicle address is null
 +
    jz      short loc_630F9A
 +
    call    CVehicle::GetVehicleAppearance    ; call CVehicle::GetVehicleAppearance(void)
 +
    cmp    eax, 5                            ; check whether or not the vehicle is plane
 +
    jz      short loc_630F98
 +
    mov    eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
 +
    mov    ecx, [eax+3A8h]                  ; offset player ped address by 0x3A8 to get address of last entered vehicle for thiscall
 +
    call    CVehicle::GetVehicleAppearance    ; call CVehicle::GetVehicleAppearance(void)
 +
    cmp    eax, 3                            ; check whether or not the vehicle is heli
 +
    jnz    short loc_630F9A
 +
loc_630F98:
 +
    mov    bl, 1                            ; set compare flag to true
 +
loc_630F9A:
 +
    mov    ecx, ebp                          ; get address of script for thiscall
 +
    push    ebx                              ; push compare flag
 +
    call    CRunningScript::UpdateCompareFlag ; call CRunningScript::UpdateCompareFlag(uchar)
 +
    xor    al, al                            ; return 0
 +
</syntaxhighlight>
  
 
== Keywords ==
 
== Keywords ==
 
player, driving, any, plane, heli, helicopter, flying, vehicle
 
player, driving, any, plane, heli, helicopter, flying, vehicle
  
[[Category:OpCodes]]
+
== See also ==
 +
* {{Icon|SA}} [[04C8]], checks if the character is in a flying vehicle

Latest revision as of 17:43, 24 May 2017

Vice City IS_PLAYER_IN_FLYING_VEHICLE


Description
Checks if the player is in a flying vehicle
Syntax
04C9:   player [player handle] in_flying_vehicle
Parameter
[player handle]
The handle of the player

This conditional opcode returns true if the player is in a flying vehicle, either as a driver or a passenger. It behaves the same way as using both opcodes 04AA and 04AC together. By default the game will recognize the following list of vehicles as flying vehicles (for which the IS_HELI or IS_PLANE flag is set in the handling.cfg file):

  • Hunter
  • Maverick
  • Police Maverick
  • RC Baron
  • RC Goblin
  • RC Raider
  • Sea Sparrow
  • Skimmer
  • Sparrow
  • VCN Maverick

Legacy documentation describes this as applying to just planes.

Disassembled code

This is disassembled code for this opcode from PC v1.0 US.

loc_630F46:
    lea     eax, [ebp+10h]                    ; get address of script's current instruction pointer
    mov     ecx, ebp                          ; get address of script for thiscall
    push    1                                 ; push 1 for one parameter to collect
    push    eax                               ; push address of script's current instruction pointer
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
    mov     edi, ds:ScriptParams[0]           ; get value of first parameter, the player handle
    xor     bl, bl                            ; set compare flag to false
    imul    edi, 170h
    add     edi, offset CWorld::Players
    mov     eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
    cmp     byte ptr [eax+3ACh], 0            ; offset player ped address by 0x3AC and check whether or not the player ped is in a vehicle
    jz      short loc_630F9A
    mov     ecx, [eax+3A8h]                   ; offset player ped address by 0x3A8 to get address of last entered vehicle for thiscall
    test    ecx, ecx                          ; check whether or not the last entered vehicle address is null
    jz      short loc_630F9A
    call    CVehicle::GetVehicleAppearance    ; call CVehicle::GetVehicleAppearance(void)
    cmp     eax, 5                            ; check whether or not the vehicle is plane
    jz      short loc_630F98
    mov     eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
    mov     ecx, [eax+3A8h]                   ; offset player ped address by 0x3A8 to get address of last entered vehicle for thiscall
    call    CVehicle::GetVehicleAppearance    ; call CVehicle::GetVehicleAppearance(void)
    cmp     eax, 3                            ; check whether or not the vehicle is heli
    jnz     short loc_630F9A
loc_630F98:
    mov     bl, 1                             ; set compare flag to true
loc_630F9A:
    mov     ecx, ebp                          ; get address of script for thiscall
    push    ebx                               ; push compare flag
    call    CRunningScript::UpdateCompareFlag ; call CRunningScript::UpdateCompareFlag(uchar)
    xor     al, al                            ; return 0

Keywords

player, driving, any, plane, heli, helicopter, flying, vehicle

See also

  • San Andreas 04C8, checks if the character is in a flying vehicle