Difference between revisions of "0392"

From GTAMods Wiki
Jump to navigation Jump to search
(rewrite instead)
Line 1: Line 1:
{{I|Create a more detailed example}}
+
{{Icon|trilogy}}
{{OpCode
+
<hr />
| ini        = 0392=2, %1d%  %2d%
+
'''Description'''
| description = Toggles an objects movability
+
: Sets the object's ability to be dynamic
| p1          = Existing object handle
+
'''Syntax'''
| p2          = Boolean value (0/1)
+
: 0392: object [''object handle''] toggle_in_moving_list [''int'']
| game        = [[GTA 3]], [[Vice City]], [[San Andreas]]
+
'''Parameter'''
}}
+
: [''object handle'']
This opcode makes an object movable or unmovable.
+
:: The handle of the object
 +
: [''int'']
 +
:: Boolean (0 = disable, 1 = enable)
 +
'''Native analog'''
 +
: [[SET_OBJECT_DYNAMIC]]
  
== Sanny Builder example ==
+
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.
  
<source lang="scm">0392: make_object $OBJECT moveable 1</source>
+
== 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.
 +
<source lang="scm">
 +
// set constants
 +
const
 +
OBJECT_MODEL = #PIZZABOX  // for VC, use different object for other games
 +
POS_X = 0@
 +
POS_Y = 1@
 +
POS_Z = 2@
 +
OBJ_HANDLE = 3@
 +
HEIGHT = 4@
 +
end
  
==Keywords==
+
00A0: store_actor $PLAYER_ACTOR position_to POS_X POS_Y POS_Z
object, movable, toggle
+
POS_Z += 20.0
 +
0107: OBJ_HANDLE = create_object OBJECT_MODEL at POS_X POS_Y POS_Z
 +
0382: set_object OBJ_HANDLE collision_detection 1
 +
while true
 +
    wait 10
 +
    01BB: store_object OBJ_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 OBJ_HANDLE at POS_X POS_Y POS_Z
 +
    end
 +
    if
 +
        00E1:  key_pressed 0 13
 +
    then
 +
        0392: object OBJ_HANDLE toggle_in_moving_list 1  // if key is held, box will fall
 +
    else
 +
        0392: object OBJ_HANDLE toggle_in_moving_list 0  // if key is not held, box will not fall
 +
    end
 +
end
 +
</source>
  
==See also==
+
== Keywords ==
*[[Move an object]]
+
set, toggle, object, movable, move
  
{{N|SA|VC}}
+
== See also ==
[[Category:GTA_3]]
+
* [[Move an object]]
 +
 
 +
[[Category:OpCodes]]

Revision as of 06:47, 6 December 2011

GTA III Vice City San Andreas


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]
Boolean (0 = disable, 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.

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.

// set constants
const
OBJECT_MODEL = #PIZZABOX  // for VC, use different object for other games
POS_X = 0@
POS_Y = 1@
POS_Z = 2@
OBJ_HANDLE = 3@
HEIGHT = 4@
end

00A0: store_actor $PLAYER_ACTOR position_to POS_X POS_Y POS_Z
POS_Z += 20.0
0107: OBJ_HANDLE = create_object OBJECT_MODEL at POS_X POS_Y POS_Z 
0382: set_object OBJ_HANDLE collision_detection 1
while true
    wait 10
    01BB: store_object OBJ_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 OBJ_HANDLE at POS_X POS_Y POS_Z
    end
    if
        00E1:   key_pressed 0 13
    then
        0392: object OBJ_HANDLE toggle_in_moving_list 1  // if key is held, box will fall
    else
        0392: object OBJ_HANDLE toggle_in_moving_list 0  // if key is not held, box will not fall
    end
end

Keywords

set, toggle, object, movable, move

See also