04C9

From GTAMods Wiki
Revision as of 08:00, 4 December 2016 by Spaceeinstein (talk | contribs)
Jump to navigation Jump to search

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 CRunningScript 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
    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
    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
    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 CRunningScript for thiscall
    push    ebx                               ; push compare flag
    call    CRunningScript::UpdateCompareFlag ; call CRunningScript::UpdateCompareFlag
    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