Difference between revisions of "04C4"

From GTAMods Wiki
Jump to navigation Jump to search
(adding more info)
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Icon|VC}} {{Icon|SA}}
+
{{OpCode
<hr />
+
| games      = {{Icon|VC}} {{Icon|SA}}
'''Description'''
+
| command    = GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS
: Stores a point offset from the character's position
+
| description = Stores a point offset from the character's position
'''Syntax'''
+
| syntax1    = 04C4: create_coordinate [''var1''] [''var2''] [''var3''] from_actor [''char handle''] offset [''flt1''] [''flt2''] [''flt3'']
: 04C4: create_coordinate [''var1''] [''var2''] [''var3''] from_actor [''char handle''] offset [''float1''] [''float2''] [''float3'']
+
| p1t        = [''char handle'']
'''Parameter'''
+
| p1d        = The handle of the character
: [''var1'']
+
| p2t        = [''flt1'']
:: Variable to store the offset x-coordinate
+
| p2d        = Distance to offset from the character's right side
: [''var2'']
+
| p3t        = [''flt2'']
:: Variable to store the offset y-coordinate
+
| p3d        = Distance to offset from the character's front side
: [''var3'']
+
| p4t        = [''flt3'']
:: Variable to store the offset z-coordinate
+
| p4d        = Distance to offset from the character's top side
: [''char handle'']
+
| p5t        = [''var1'']
:: The handle of the character
+
| p5d        = Variable to store the offset x-coordinate
: [''float1'']
+
| p6t        = [''var2'']
:: Distance to offset from the character's right side
+
| p6d        = Variable to store the offset y-coordinate
: [''float1'']
+
| p7t        = [''var3'']
:: Distance to offset from the character's front side
+
| p7d        = Variable to store the offset z-coordinate
: [''float1'']
+
| native      = [[GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS]]
:: 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 [[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.
+
This opcode stores a point offset from the character's position. The coordinates it stores are 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 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.
+
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 [[00E1|button 4]] (ACTION key on foot).
  
<source lang="scm">
+
{{Pre|class=sb-code|1=
// set constants
+
<span class="c1">// set constants</span>
const
+
<span class="k">const</span>
X_POS = 0@
+
X_POS = <span class="nv">0@</span>
Y_POS = 1@
+
Y_POS = <span class="nv">1@</span>
Z_POS = 2@
+
Z_POS = <span class="nv">2@</span>
PICKUP_1 = 3@
+
PICKUP_1 = <span class="nv">3@</span>
PICKUP_2 = 4@
+
PICKUP_2 = <span class="nv">4@</span>
end
+
<span class="k">end</span>
  
// spawn pickups  
+
<span class="c1">// spawn pickups </span>
while true
+
<span class="k">while</span> <span class="k">true</span>
     wait 50
+
     <span class="k">wait</span> <span class="m">50</span>
     if  
+
     <span class="k">if</span>
         00E1:  key_pressed 0 4  // action key
+
         [[00E1]]:  key_pressed <span class="m">0</span> <span class="m">4</span> <span class="c1">// action key</span>
     then
+
     <span class="k">then</span>
         // spawn adrenaline
+
         <span class="c1">// spawn adrenaline</span>
         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
+
         04C4: create_coordinate X_POS Y_POS Z_POS from_actor <span class="nv">$PLAYER_ACTOR</span> offset <span class="m">0.0</span> <span class="m">3.0</span> <span class="m">0.0</span> <span class="c1">// 3 units to the front of the player</span>
 
         0215: destroy_pickup PICKUP_1
 
         0215: destroy_pickup PICKUP_1
         0213: PICKUP_1 = create_pickup #ADRENALINE type 3 at X_POS Y_POS Z_POS
+
         [[0213]]: PICKUP_1 = create_pickup <span class="nt">#ADRENALINE</span> type <span class="m">3</span> at X_POS Y_POS Z_POS
         // spawn bribe
+
         <span class="c1">// spawn bribe</span>
         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
+
         04C4: create_coordinate X_POS Y_POS Z_POS from_actor <span class="nv">$PLAYER_ACTOR</span> offset <span class="m">3.0</span> <span class="m">0.0</span> <span class="m">0.0</span> <span class="c1">// 3 units to the right of the player</span>
 
         0215: destroy_pickup PICKUP_2
 
         0215: destroy_pickup PICKUP_2
         0213: PICKUP_2 = create_pickup #BRIBE type 3 at X_POS Y_POS Z_POS
+
         [[0213]]: PICKUP_2 = create_pickup <span class="nt">#BRIBE</span> type <span class="m">3</span> at X_POS Y_POS Z_POS
     end
+
     <span class="k">end</span>
end
+
<span class="k">end</span>
</source>
+
}}
 
 
== 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: <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">
 
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
 
</source>
 
  
 
== Keywords ==
 
== Keywords ==
 
store, coordinates, get, point, actor, character, offset
 
store, coordinates, get, point, actor, character, offset
  
[[Category:OpCodes]][[Category:Code Snippets]]
+
== See also ==
 +
* {{Icon|VC}} {{Icon|SA}} [[0400]], for objects
 +
* {{Icon|VC}} {{Icon|SA}} [[0407]], for vehicles
 +
 
 +
[[Category:Code Snippets]]

Latest revision as of 15:45, 22 December 2016

Vice City San Andreas GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS


Description
Stores a point offset from the character's position
Syntax
04C4: create_coordinate [var1] [var2] [var3] from_actor [char handle] offset [flt1] [flt2] [flt3]
Parameter
[char handle]
The handle of the character
[flt1]
Distance to offset from the character's right side
[flt2]
Distance to offset from the character's front side
[flt3]
Distance to offset from the character's top side
[var1]
Variable to store the offset x-coordinate
[var2]
Variable to store the offset y-coordinate
[var3]
Variable to store the offset z-coordinate
Native analog
GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS

This opcode stores a point offset from the character's position. The coordinates it stores are 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 button 4 (ACTION key on foot).

// 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

Keywords

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

See also