Difference between revisions of "0415"

From GTAMods Wiki
Jump to navigation Jump to search
(code snippet)
m
 
Line 54: Line 54:
 
}}
 
}}
  
Use this line as a substitute for opcode 0415. This can be placed anywhere within the external script:
+
Use this line as a substitute for opcode 0415. This can be placed anywhere within the external script as a conditional statement:
 
{{Pre|class=sb-code|1=
 
{{Pre|class=sb-code|1=
05F5: call_scm_func <span class="nl">@opcode_0415</span> inputs <span class="m">2</span> car_handle [car handle] car_part [int]
+
<span class="c1">// ...</span>
 +
<span class="k">if</span>
 +
    05F5: call_scm_func <span class="nl">@opcode_0415</span> inputs <span class="m">2</span> car_handle [car handle] car_part [int]
 +
<span class="k">then</span>
 +
    <span class="c1">// [RETURNED TRUE]</span>
 +
<span class="k">else</span>
 +
    <span class="c1">// [RETURNED FALSE]</span>
 +
<span class="k">end</span>
 +
<span class="c1">// ...</span>
 
}}
 
}}
  
 
== Keywords ==
 
== Keywords ==
 
check, car, vehicle, door, component, part, closed
 
check, car, vehicle, door, component, part, closed

Latest revision as of 12:34, 11 December 2016

GTA III IS_CAR_DOOR_CLOSED


Description
Checks if the car component of the car is closed
Syntax
0415:   car [car handle] door [int] closed
Parameter
[car handle]
The handle of the vehicle
[int]
Car part (see below)

This conditional opcode returns true if the car component of the car is closed; the component does not need to be a door. If the component is damaged and cannot be closed shut, the opcode can still return true if the component rotates into the closing position. This opcode was never called in the original script of GTA III.

Car parts

Part Enum Notes
0 BONNET bonnet, hood
1 BOOT boot, trunk, tailgate
2 FRONT_LEFT_DOOR front left door
3 FRONT_RIGHT_DOOR front right door
4 REAR_LEFT_DOOR rear left door
5 REAR_RIGHT_DOOR rear right door

For Vice City

This opcode does not exist in Vice City but it possible to get the state of the vehicle's car parts. 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_0415
// 0@ - input param (car handle)
// 1@ - input param (part)
05E7: 0@ = car 0@ struct
05E0: 2@ = read_memory 0@ size 4 virtual_protect 0  // read virtual table
2@ += 0x6C  // offset in table
05E0: 3@ = read_memory 2@ size 4 virtual_protect 0
05E4: call_function_method 3@ 0@ num_params 1 pop 0 part 1@ 4@  // CAutomobile::IsDoorMissing
05F9: 4@ = 4@ AND 1  // retrieve only 1 byte
05E0: 2@ = read_memory 0@ size 4 virtual_protect 0  // read virtual table
2@ += 0x68  // offset in table
05E0: 3@ = read_memory 2@ size 4 virtual_protect 0
05E4: call_function_method 3@ 0@ num_params 1 pop 0 part 1@ 5@  // CAutomobile::IsDoorClosed
05F9: 5@ = 5@ AND 1  // retrieve only 1 byte
if and
    4@ == 0
    5@ == 1
then
end
05F6: ret 0

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

// ...
if
    05F5: call_scm_func @opcode_0415 inputs 2 car_handle [car handle] car_part [int]
then
    // [RETURNED TRUE]
else
    // [RETURNED FALSE]
end
// ...

Keywords

check, car, vehicle, door, component, part, closed