Difference between revisions of "04C4"

From GTAMods Wiki
Jump to navigation Jump to search
(Example)
(adding more info)
Line 23: Line 23:
 
: [[GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS]]
 
: [[GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS]]
  
This opcode stores a point offset from the character's position. The coordinates it store is dependent on the [[angle|direction]] the character is facing.
+
This opcode stores a point offset from the character's position. The coordinates it store is dependent on the [[angle|direction]] the character is facing. Unlike opcode [[00A0]], if the character is in a vehicle, this opcode will center on the character's position instead on the vehicle's position. The coordinates the opcode return will lag behind the character's actual position and is especially noticeable if the character is moving really fast.
  
 
== Example ==
 
== Example ==
The following exmaple, using Sanny Builder, will spawn an Adrenaline pickup in front of the player character and a Bribe pickup to the right of the player character after pressing the ACTION key.
+
The following example, using Sanny Builder, will spawn an Adrenaline pickup in front of the player character and a Bribe pickup to the right of the player character after pressing the ACTION key.
  
 
<source lang="scm">
 
<source lang="scm">
Line 57: Line 57:
  
 
== For GTA III ==
 
== For GTA III ==
This opcode does not exist in GTA III. The following code, in which GTA III can use, will work similarly to this: <source lang="scm">04C4: create_coordinate X_POS Y_POS Z_POS from_actor $PLAYER_ACTOR offset 0.0 3.0 0.0</source>
+
This opcode does not exist in GTA III. The following example, in which GTA III can use, will work similarly to this: <source lang="scm">04C4: create_coordinate X_POS Y_POS Z_POS from_actor $PLAYER_ACTOR offset 0.0 3.0 0.0</source>
  
 
<source lang="scm">
 
<source lang="scm">

Revision as of 02:10, 24 August 2011

Vice City San Andreas


Description

Stores a point offset from the character's position

Syntax

04C4: create_coordinate [var1] [var2] [var3] from_actor [char handle] offset [float1] [float2] [float3]

Parameter

[var1]
Variable to store the offset x-coordinate
[var2]
Variable to store the offset y-coordinate
[var3]
Variable to store the offset z-coordinate
[char handle]
The handle of the character
[float1]
Distance to offset from the character's right side
[float1]
Distance to offset from the character's front side
[float1]
Distance to offset from the character's top side

Native analog

GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS

This opcode stores a point offset from the character's position. The coordinates it store is dependent on the direction the character is facing. Unlike opcode 00A0, if the character is in a vehicle, this opcode will center on the character's position instead on the vehicle's position. The coordinates the opcode return will lag behind the character's actual position and is especially noticeable if the character is moving really fast.

Example

The following example, using Sanny Builder, will spawn an Adrenaline pickup in front of the player character and a Bribe pickup to the right of the player character after pressing the ACTION key.

// set constants
const
X_POS = 0@
Y_POS = 1@
Z_POS = 2@
PICKUP_1 = 3@
PICKUP_2 = 4@
end

// spawn pickups 
while true
    wait 50
    if 
        00E1:   key_pressed 0 4  // action key
    then
        // spawn adrenaline
        04C4: create_coordinate X_POS Y_POS Z_POS from_actor $PLAYER_ACTOR offset 0.0 3.0 0.0  // 3 units to the front of the player
        0215: destroy_pickup PICKUP_1
        0213: PICKUP_1 = create_pickup #ADRENALINE type 3 at X_POS Y_POS Z_POS
        // spawn bribe
        04C4: create_coordinate X_POS Y_POS Z_POS from_actor $PLAYER_ACTOR offset 3.0 0.0 0.0  // 3 units to the right of the player
        0215: destroy_pickup PICKUP_2
        0213: PICKUP_2 = create_pickup #BRIBE type 3 at X_POS Y_POS Z_POS
    end
end

For GTA III

This opcode does not exist in GTA III. The following example, in which GTA III can use, will work similarly to this:

04C4: create_coordinate X_POS Y_POS Z_POS from_actor $PLAYER_ACTOR offset 0.0 3.0 0.0
const
X_POS = 0@
Y_POS = 1@
Z_POS = 2@
ANGLE = 3@
SINE_ANGLE = 4@
COSINE_ANGLE = 5@
end

var
X_POS : float
Y_POS : float
SINE_ANGLE : float
COSINE_ANGLE : float
end

00A0: store_actor $PLAYER_ACTOR position_to X_POS Y_POS Z_POS
0172: ANGLE = actor $PLAYER_ACTOR z_angle
02F6: SINE_ANGLE = sine ANGLE
02F7: COSINE_ANGLE = cosine ANGLE
SINE_ANGLE *= -3.0
COSINE_ANGLE *= 3.0
X_POS += SINE_ANGLE
Y_POS += COSINE_ANGLE

Keywords

store, coordinates, get, point, actor, character, offset