CGObject

From Project X Wiki
Jump to: navigation, search


Experimental page


Icon wa 16x16.png Worms Armageddon class

Base class which supports physics and collisions. Most gameplay objects are derived from this.

Inherits CObject
Inherited by CArrow CCrate CFire CGas CMine CMissile COilDrum CWorm

Fields

ColGroup : int
ColMask : CColMask *
CouldSkipTurn : int
DumpingA : fixed
DumpingB : fixed
DumpingC : fixed
GravityFactor : fixed
InMidAir : int
IsMaterial : bool
Layer : int
MaskIndex : int
ObjState : EObjState
PosX : fixed
PosY : fixed
RopeAX : int
RopeAY : int
RopeAttached : int
RopeData : int [ ]
RopeFragments : int
RopeLength : int
RopeSpeedFactor : int
SinkSpeedFactor : fixed
Sinking : int
SkimFactor : int
Snd : CGSounder
SpX : fixed
SpY : fixed
SpeedDivider : fixed
SpeedDividerB : fixed
Stopped : int
WindFactor : fixed

Methods

[constructor] CGObject ( CObject *parent, int layer, int maskIndex )
void Collide ( CGObject *obj, int type )
void OnSink ( )
void PlayLocalSound ( int sIndex, int unk, fixed unkB, fixed unkC, CGSounder *sounder )
void Reflect ( CGObject *obj, int type )
void SetState ( EObjState state )


Detailed description

This class is the base for most moving objects and provides properties and functions for handling movement and collisions.

Field documentation


ColGroup : int

The collision flags this object should use for filtering collisions. This is a misnamed field, the actual collision group is Layer.
Each bit corresponds to a collision group, a bit set to 1 will enable collisions with the collision group attributed to this bit. For instance, setting bit 17 to 1 (by performing a bitwise OR with 0x00020000) will enable collisions with oil drums.

See Collision flags for more information.


ColMask : CColMask*

The collision mask used by this object.


CouldSkipTurn : int

Unknown.


DumpingA : fixed

Affect the object's bounciness from walls.
CWorm->DumpingA = 0.6
CMine->DumpingA = 0.6
COilDrum->DumpingA = 0.0
CCrate has same values as COilDrum.


DumpingB : fixed

Affect the object's bounciness from floors and ceilings.
CWorm->DumpingB = 0.0
CMine->DumpingB = 0.6
COilDrum->DumpingB = 0.5


DumpingC : fixed

Affect the object's friction.
If it set to 0.0 the object will not roll\slide after colliding with floor-ceiling.
CWorm->DumpingC = 1.0
CMine->DumpingC = 1.0
COilDrum->DumpingC = 1.0


GravityFactor : fixed

How much this object is influenced by gravity.


InMidAir : int

Equal to 1 when the object is not resting on the ground, 0 otherwise.


IsMaterial : bool

True if collisions are enabled on this object, false otherwise. Setting this to false will effectively prevent this object from colliding with anything. Also SpX and SpY changes do nothing and object dont affected by gravity.


Layer : int

The collision group this object belongs to. This allows certain objects to collide with this object.
Do not confuse this with ColGroup, this should be an integer between 0 and 31. For instance, an object with a Layer equal to 17 will be considered as an oil drum by other objects, collision-wise.

See Collision flags for more information.


MaskIndex : int

The index of the collision mask this object should use. This is obsolete if the object uses a custom collision mask. (see ColMask)

The following values have been tested:

  • 2 = Mine
  • 9 = Oil drum

ObjState : EObjState

The current state of this object.
This should not be set directly, use SetState instead.

See EObjState for more information.


PosX : fixed

The horizontal position of this object.


PosY : fixed

The vertical position of this object.


RopeAX : int

The X coordinate of where the rope is attached, divide it by 65536, then round up or convert to int to get the number of pixels. Since 3.6.30.0, WA doesn't allow the rope to be attached to the air. If you'd like to make the scripts such as "ropetest" properly work on the latest PX, you will need to emulate an older version.


RopeAY : int

The Y coordinate of where the rope is attached, divide it by 65536, then round up or convert to int to get the number of pixels. Since 3.6.30.0, WA doesn't allow the rope to be attached to the air. If you'd like to make the scripts such as "ropetest" properly work on the latest PX, you will need to emulate an older version.


RopeAttached : int

Tells whether the rope is attached or not. If yes, the value will be "1". If not, the value will be "0".


RopeData : int[ ]

Unused.


RopeFragments : int

Number of rope fragments in the current rope or bungee. One rope fragment is 8 pixels in length. If you enlarge or shorten the rope/bungee, the number of fragments will change respectively. The max number of rope fragments in W:A is currently 58.


RopeLength : int

The current length of the rope. Takes relatively big values, divide them by 65536 to get the number of pixels.


RopeSpeedFactor : int

Unused.


SinkSpeedFactor : fixed

The speed at which this object sinks when under water.


Sinking : int

Equal to 1 when the object is sinking, 0 otherwise.


SkimFactor : int

Unknown.


Snd : CGSounder

This should be passed as the 5th argument to PlayLocalSound. Does not seem to have any other use.


SpX : fixed

The current horizontal speed of this object.


SpY : fixed

The current vertical speed of this object.
For CWorm: if speed is more than 7, the worm loses control.


SpeedDivider : fixed

The speed of this object is divided by this value every frame. Usually set to 1 for most objects.
Setting this to a very high value such as 1000 will effectively freeze the object in place.


SpeedDividerB : fixed

Unknown.


Stopped : int

Unknown. Supposedly equal to 1 when the object has stopped moving, 0 otherwise.


WindFactor : fixed

How much this object is influenced by wind.

Method documentation


[constructor] CGObject ( CObject *parent, int layer, int maskIndex )
  • layer is the collision group this object should be attributed to. See Layer.
  • maskIndex is the index of the collision mask which should be given to this object. See ColMask


See CObject for more information.


void Collide ( CGObject *obj, int type )

This is called whenever the object collides with another object.

  • obj is the object this object collided with.
  • type is the which side of this object collided with "obj". The possible values: 1, 2, 3, 4:

---1---
4-----2
---3---

Override this in your custom class to define custom behaviour on collisions.
CGObject has empty collide function (it doesnt do anything).


void OnSink ( )

This is called whenever the object falls into the water and sinks.

Override this in your custom class to define custom behaviour when your object sinks.


void PlayLocalSound ( int sIndex, int unk, fixed unkB, fixed unkC, CGSounder *sounder )

Plays a sound centered around this object's position.

  • index is the index of the sound to play.
  • unk, unkB and unkC are unknown arguments, they are usually set respectively to 5, 1 and 1.
  • sounder should be always Snd.

void Reflect ( CGObject *obj, int type )

That method called by the game every time object reflecting another object.
Obj is the object this object reflected.
Type is the side of this object, which reflected obj.
Types:
1 - bottom.
2 - left.
3 - top.
4 - right.

Main difference between Collide and Reflect is easy to understand in this example:
If grenade is falling onto the barrel, Collide will be called in CMissile, and Reflect will be called in COilDrum (and there will be no Collide for COilDrum, if its not moving).
CGObject has empty reflect function (it doesnt do anything).


void SetState ( EObjState state )

Changes the state of an object. Can be also overriden to define custom behaviour whenever the state of an object changes.

See EObjState for more information.