Difference between revisions of "0415"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with "{{Icon|3}} '''IS_CAR_DOOR_CLOSED''' <hr /> '''Description''' : Checks if the car component of the car is closed '''Syntax''' : 0415:   car [''car handle''] door [''int'']...")
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Icon|3}} '''IS_CAR_DOOR_CLOSED'''
+
{{OpCode
<hr />
+
| games      = {{Icon|3}}
'''Description'''
+
| command    = IS_CAR_DOOR_CLOSED
: Checks if the car component of the car is closed
+
| description = Checks if the car component of the car is closed
'''Syntax'''
+
| syntax1    = 0415: &nbsp; car [''car handle''] door [''int''] closed
: 0415: &nbsp; car [''car handle''] door [''int''] closed
+
| p1t        = [''car handle'']
'''Parameter'''
+
| p1d        = The handle of the vehicle
: [''car handle'']
+
| p2t        = [''int'']
:: The handle of the vehicle
+
| p2d        = Car part ([[#Car parts|see below]])
: [''int'']
+
}}
:: Component ID (see below)
 
  
This opcode returns true if the car component of the car is closed. 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 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 [[Main.scm|original script]] of GTA III.
{| class="wikitable"
+
 
! ID || [[SCM language III/VC definitions#DOOR|Enum]] || Notes
+
== Car parts ==
 +
{|class="wikitable center-col-1"
 +
!Part ||[[SCM language III/VC definitions#DOOR|Enum]] ||Notes
 
|-
 
|-
| 0 || BONNET || bonnet, hood
+
|0 ||BONNET ||bonnet, hood
 
|-
 
|-
| 1 || BOOT || boot, trunk, tailgate
+
|1 ||BOOT ||boot, trunk, tailgate
 
|-
 
|-
| 2 || FRONT_LEFT_DOOR || front left door
+
|2 ||FRONT_LEFT_DOOR ||front left door
 
|-
 
|-
| 3 || FRONT_RIGHT_DOOR || front right door
+
|3 ||FRONT_RIGHT_DOOR ||front right door
 
|-
 
|-
| 4 || REAR_LEFT_DOOR || rear left door
+
|4 ||REAR_LEFT_DOOR ||rear left door
 
|-
 
|-
| 5 || REAR_RIGHT_DOOR || rear right 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:
 +
{{Pre|class=sb-code|1=
 +
<span class="nl">:opcode_0415</span>
 +
<span class="c1">// 0@ - input param (car handle)</span>
 +
<span class="c1">// 1@ - input param (part)</span>
 +
05E7: <span class="nv">0@</span> = car <span class="nv">0@</span> struct
 +
05E0: <span class="nv">2@</span> = read_memory <span class="nv">0@</span> size <span class="m">4</span> virtual_protect <span class="m">0</span>  <span class="c1">// read virtual table</span>
 +
<span class="nv">2@</span> += <span class="m">0x6C</span>  <span class="c1">// offset in table</span>
 +
05E0: <span class="nv">3@</span> = read_memory <span class="nv">2@</span> size <span class="m">4</span> virtual_protect <span class="m">0</span>
 +
05E4: call_function_method <span class="nv">3@</span> <span class="nv">0@</span> num_params <span class="m">1</span> pop <span class="m">0</span> part <span class="nv">1@</span> <span class="nv">4@</span>  <span class="c1">// CAutomobile::IsDoorMissing</span>
 +
05F9: <span class="nv">4@</span> = <span class="nv">4@</span> <span class="k">AND</span> <span class="m">1</span>  <span class="c1">// retrieve only 1 byte</span>
 +
05E0: <span class="nv">2@</span> = read_memory <span class="nv">0@</span> size <span class="m">4</span> virtual_protect <span class="m">0</span>  <span class="c1">// read virtual table</span>
 +
<span class="nv">2@</span> += <span class="m">0x68</span>  <span class="c1">// offset in table</span>
 +
05E0: <span class="nv">3@</span> = read_memory <span class="nv">2@</span> size <span class="m">4</span> virtual_protect <span class="m">0</span>
 +
05E4: call_function_method <span class="nv">3@</span> <span class="nv">0@</span> num_params <span class="m">1</span> pop <span class="m">0</span> part <span class="nv">1@</span> <span class="nv">5@</span>  <span class="c1">// CAutomobile::IsDoorClosed</span>
 +
05F9: <span class="nv">5@</span> = <span class="nv">5@</span> <span class="k">AND</span> <span class="m">1</span>  <span class="c1">// retrieve only 1 byte</span>
 +
<span class="k">if</span> <span class="k">and</span>
 +
    <span class="nv">4@</span> == <span class="m">0</span>
 +
    <span class="nv">5@</span> == <span class="m">1</span>
 +
<span class="k">then</span>
 +
<span class="k">end</span>
 +
05F6: ret <span class="m">0</span>
 +
}}
 +
 +
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=
 +
<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, closed
+
check, car, vehicle, door, component, part, closed
 
 
[[Category:OpCodes]]
 

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