Difference between revisions of "0392"

From GTAMods Wiki
Jump to navigation Jump to search
(highlight)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Icon|trilogy}}
+
{{OpCode
<hr />
+
| games      = {{Icon|t}}
'''Description'''
+
| command    = SET_OBJECT_DYNAMIC
: Sets the object's ability to be dynamic
+
| description = Sets the object's ability to be dynamic
'''Syntax'''
+
| syntax1    = 0392: object [''object handle''] toggle_in_moving_list [''int'']
: 0392: object [''object handle''] toggle_in_moving_list [''int'']
+
| p1t        = [''object handle'']
'''Parameter'''
+
| p1d        = The handle of the object
: [''object handle'']
+
| p2t        = [''int'']
:: The handle of the object
+
| p2d        = 0 = not dynamic, {{hint|1|or any value other than 0}} = dynamic
: [''int'']
+
| native      = [[SET_OBJECT_DYNAMIC]]
:: Integer (0 = disable, any other {{hint|value|recommended value 1}} = enable)
+
}}
'''Native analog'''
 
: [[SET_OBJECT_DYNAMIC]]
 
  
This opcode sets the object's ability to be dynamic in the environment. This opcode only affects dynamic objects and has no effect on static ones. By default, when dynamic objects are created using either opcode [[0107]] or [[029B]], gravity will not affect the object and will float in the air unless acted upon by the environment. Enabling dynamics through this opcode will allow gravity to affect the object and allow it to drop onto the ground. Disabling dynamics can stop gravity and all environmental effects from affecting the object.
+
This opcode sets the object's ability to be dynamic in the environment. This opcode only affects dynamic objects and has no effect on static ones. By default, when dynamic objects are created using either opcode [[0107]] or [[029B]], gravity will not affect the object and will float in the air unless acted upon by the environment. Enabling dynamics through this opcode will allow gravity to affect the object and allow it to drop onto the ground. Disabling dynamics will stop gravity and all environmental effects from affecting the object at that moment; the object can still be affected by the environment and will not be static.
  
 
== Example ==
 
== Example ==
The following example, using Sanny Builder, will spawn a dynamic object above the player (a pizza box for Vice City in this example). The object will only be affected by gravity and the environment if the CAMERA key is being held. Otherwise, gravity and the environment is forced to have no effect on the object and the box will be stuck floating in the air. If the object is about to hit the ground, it is warped back up to resume the fall.
+
The following example spawns a dynamic object above the player (a pizza box for Vice City in this example). The object will only be affected by gravity and the environment when holding [[00E1|button 13]] (CAMERA key). Otherwise, gravity and the environment is forced to have no effect on the object and the box will be stuck floating in the air. If the object is about to hit the ground, it is warped back up to resume the fall.
<source lang="scm">
+
{{Pre|class=sb-code|1=
// set constants
+
<span class="c1">// set constants</span>
const
+
<span class="k">const</span>
OBJECT_MODEL = #PIZZABOX // for VC, use different object for other games
+
OBJECT_MODEL = <span class="nt">#PIZZABOX</span>
POS_X = 0@
+
OBJECT_HANDLE = <span class="nv">0@</span>
POS_Y = 1@
+
OBJECT_MARKER = <span class="nv">1@</span>
POS_Z = 2@
+
POS_X = <span class="nv">2@</span>
OBJ_HANDLE = 3@
+
POS_Y = <span class="nv">3@</span>
HEIGHT = 4@
+
POS_Z = <span class="nv">4@</span>
end
+
HEIGHT = <span class="nv">5@</span>
 +
<span class="k">end</span>
  
00A0: store_actor $PLAYER_ACTOR position_to POS_X POS_Y POS_Z
+
<span class="c1">// spawn object</span>
POS_Z += 20.0
+
[[00A0]]: store_actor <span class="nv">$PLAYER_ACTOR</span> position_to POS_X POS_Y POS_Z
0107: OBJ_HANDLE = create_object OBJECT_MODEL at POS_X POS_Y POS_Z  
+
POS_Z += <span class="m">20.0</span>
0382: set_object OBJ_HANDLE collision_detection 1
+
[[0107]]: OBJECT_HANDLE = create_object OBJECT_MODEL at POS_X POS_Y POS_Z
while 03CA:  object OBJ_HANDLE exists
+
[[0188]]: OBJECT_MARKER = create_marker_above_object OBJECT_HANDLE
     wait 10
+
0382: set_object OBJECT_HANDLE collision_detection <span class="m">1</span>
     01BB: store_object OBJ_HANDLE position_to POS_X POS_Y POS_Z
+
 
     02CE: HEIGHT = ground_z POS_X POS_Y POS_Z
+
<span class="k">while</span> <span class="k">if</span> 03CA:  object OBJECT_HANDLE exists
     0063: POS_Z -= HEIGHT
+
     <span class="k">wait</span> <span class="m">10</span>
     if
+
     [[01BB]]: store_object OBJECT_HANDLE position_to POS_X POS_Y POS_Z
         POS_Z < 5.0
+
     [[02CE]]: HEIGHT = ground_z POS_X POS_Y POS_Z
     then
+
     [[0063]]: POS_Z -= HEIGHT
         POS_Z += 50.0
+
     <span class="k">if</span>
         01BC: put_object OBJ_HANDLE at POS_X POS_Y POS_Z
+
         POS_Z < <span class="m">5.0</span>
     end
+
     <span class="k">then</span>
     if
+
         POS_Z += <span class="m">50.0</span>
         00E1:  key_pressed 0 13
+
         [[01BC]]: put_object OBJECT_HANDLE at POS_X POS_Y POS_Z
     then
+
     <span class="k">end</span>
         0392: object OBJ_HANDLE toggle_in_moving_list 1  // if key is held, box will fall
+
     <span class="k">if</span>
     else
+
         [[00E1]]:  key_pressed <span class="m">0</span> <span class="m">13</span>  <span class="c1">// camera key</span>
         0392: object OBJ_HANDLE toggle_in_moving_list 0  // if key is not held, box will not fall
+
     <span class="k">then</span>
     end
+
         0392: object OBJECT_HANDLE toggle_in_moving_list <span class="m">1</span> <span class="c1">// if key is held, box will fall</span>
end
+
     <span class="k">else</span>
</source>
+
         0392: object OBJECT_HANDLE toggle_in_moving_list <span class="m">0</span> <span class="c1">// if key is not held, box will not fall</span>
 +
     <span class="k">end</span>
 +
<span class="k">end</span>
 +
}}
  
 
== Keywords ==
 
== Keywords ==
set, toggle, object, movable, move
+
set, toggle, object, movable, move, dynamic
 
 
== See also ==
 
* [[Move an object]]
 
 
 
[[Category:OpCodes]]
 

Latest revision as of 05:36, 1 February 2017

GTA III Vice City San Andreas SET_OBJECT_DYNAMIC


Description
Sets the object's ability to be dynamic
Syntax
0392: object [object handle] toggle_in_moving_list [int]
Parameter
[object handle]
The handle of the object
[int]
0 = not dynamic, 1 = dynamic
Native analog
SET_OBJECT_DYNAMIC

This opcode sets the object's ability to be dynamic in the environment. This opcode only affects dynamic objects and has no effect on static ones. By default, when dynamic objects are created using either opcode 0107 or 029B, gravity will not affect the object and will float in the air unless acted upon by the environment. Enabling dynamics through this opcode will allow gravity to affect the object and allow it to drop onto the ground. Disabling dynamics will stop gravity and all environmental effects from affecting the object at that moment; the object can still be affected by the environment and will not be static.

Example

The following example spawns a dynamic object above the player (a pizza box for Vice City in this example). The object will only be affected by gravity and the environment when holding button 13 (CAMERA key). Otherwise, gravity and the environment is forced to have no effect on the object and the box will be stuck floating in the air. If the object is about to hit the ground, it is warped back up to resume the fall.

// set constants
const
OBJECT_MODEL = #PIZZABOX
OBJECT_HANDLE = 0@
OBJECT_MARKER = 1@
POS_X = 2@
POS_Y = 3@
POS_Z = 4@
HEIGHT = 5@
end

// spawn object
00A0: store_actor $PLAYER_ACTOR position_to POS_X POS_Y POS_Z
POS_Z += 20.0
0107: OBJECT_HANDLE = create_object OBJECT_MODEL at POS_X POS_Y POS_Z
0188: OBJECT_MARKER = create_marker_above_object OBJECT_HANDLE
0382: set_object OBJECT_HANDLE collision_detection 1

while if 03CA:   object OBJECT_HANDLE exists
    wait 10
    01BB: store_object OBJECT_HANDLE position_to POS_X POS_Y POS_Z
    02CE: HEIGHT = ground_z POS_X POS_Y POS_Z
    0063: POS_Z -= HEIGHT
    if
        POS_Z < 5.0
    then
        POS_Z += 50.0
        01BC: put_object OBJECT_HANDLE at POS_X POS_Y POS_Z
    end
    if
        00E1:   key_pressed 0 13  // camera key
    then
        0392: object OBJECT_HANDLE toggle_in_moving_list 1  // if key is held, box will fall
    else
        0392: object OBJECT_HANDLE toggle_in_moving_list 0  // if key is not held, box will not fall
    end
end

Keywords

set, toggle, object, movable, move, dynamic