Difference between revisions of "CObject"

From Project X Wiki
Jump to: navigation, search
m (test)
 
(Method documentation)
 
(3 intermediate revisions by the same user not shown)
Line 25: Line 25:
 
<div style="border:1px solid #C8C8C8;width:80%;">
 
<div style="border:1px solid #C8C8C8;width:80%;">
 
<p style="font-size:12px;margin-left:10px">'''''[constructor]''''' <b>[[#CObject|CObject]]</b> ( [[CObject]] *''parent'' )<br />
 
<p style="font-size:12px;margin-left:10px">'''''[constructor]''''' <b>[[#CObject|CObject]]</b> ( [[CObject]] *''parent'' )<br />
void <b>[[#AddBitmap|AddBitmap]]</b> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''unk'', [[CBitmap]] *''bitmap'', int ''scrX'', int ''scrY'', int ''sx'', int ''sy'', int ''flags'' )<br />
+
void <b>[[#AddBitmap|AddBitmap]]</b> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''unk'', [[CBitmap]] *''bitmap'', int ''sx'', int ''sy'', int ''flags'' )<br />
 
void <b>[[#AddCustomRender|AddCustomRender]]</b> ( fixed ''z'', string ''name'' )<br />
 
void <b>[[#AddCustomRender|AddCustomRender]]</b> ( fixed ''z'', string ''name'' )<br />
void <b>[[#AddInterfaceBitmap|AddInterfaceBitmap]]</b> ( int ''unk'', fixed ''x'', fixed ''y'', [[CBitmap]] *''bitmap'', int ''srcX'', int ''srcY'', int ''sx'', int ''sy'', int ''flags'' )<br />
+
void <b>[[#AddInterfaceBitmap|AddInterfaceBitmap]]</b> ( int ''unk'', fixed ''x'', fixed ''y'', [[CBitmap]] *''bitmap'', int ''sx'', int ''sy'', int ''flags'' )<br />
 
void <b>[[#AddSprite|AddSprite]]</b> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''unk'', int ''sprite'', fixed ''frame'' )<br />
 
void <b>[[#AddSprite|AddSprite]]</b> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''unk'', int ''sprite'', fixed ''frame'' )<br />
 
void <b>[[#AddSpriteEx|AddSpriteEx]]</b> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''sprite'', fixed ''frame'', float ''rot'', float ''scale'' )<br />
 
void <b>[[#AddSpriteEx|AddSpriteEx]]</b> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''sprite'', fixed ''frame'', float ''rot'', float ''scale'' )<br />
 
void <b>[[#AddSpriteQ|AddSpriteQ]]</b> ( fixed ''z'', [[CQuad]] *''q'', int ''sprite'', fixed ''frame'', int ''flags'' )<br />
 
void <b>[[#AddSpriteQ|AddSpriteQ]]</b> ( fixed ''z'', [[CQuad]] *''q'', int ''sprite'', fixed ''frame'', int ''flags'' )<br />
void <b>[[#DoExplosion|DoExplosion]]</b> ( int ''unk'', fixed ''x'', fixed ''y'', int ''push'', int ''damage'', int ''unkB'', int ''team'' )<br />
+
void <b>[[#DoExplosion|DoExplosion]]</b> ( fixed ''x'', fixed ''y'', int ''push'', int ''damage'', int ''unkB'', int ''team'' )<br />
 
void <b>[[#Free|Free]]</b> ( bool ''freeMem'' )<br />
 
void <b>[[#Free|Free]]</b> ( bool ''freeMem'' )<br />
 
void <b>[[#Message|Message]]</b> ( [[CObject]] *''sender'', [[EMType]] ''type'', int ''mSize'', [[CMessageData]] *''mData'' )<br />
 
void <b>[[#Message|Message]]</b> ( [[CObject]] *''sender'', [[EMType]] ''type'', int ''mSize'', [[CMessageData]] *''mData'' )<br />
Line 77: Line 77:
 
Default constructor, takes a pointer to the object's parent as an argument. Most objects should be parented to '''Store->GetObject(25, 0)''', which is supposedly the world object.<br />
 
Default constructor, takes a pointer to the object's parent as an argument. Most objects should be parented to '''Store->GetObject(25, 0)''', which is supposedly the world object.<br />
  
<br /><div id="AddBitmap" style="font-size:16px;font-weight:bold;border:1px solid #C8C8C8;padding:3px;">void <font color=#006000>AddBitmap</font> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''unk'', [[CBitmap]] *''bitmap'', int ''scrX'', int ''scrY'', int ''sx'', int ''sy'', int ''flags'' )</div>
+
<br /><div id="AddBitmap" style="font-size:16px;font-weight:bold;border:1px solid #C8C8C8;padding:3px;">void <font color=#006000>AddBitmap</font> ( fixed ''z'', fixed ''x'', fixed ''y'', int ''unk'', [[CBitmap]] *''bitmap'', int ''sx'', int ''sy'', int ''flags'' )</div>
 
'''<font color="#FF0000">This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!</font>'''<br />
 
'''<font color="#FF0000">This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!</font>'''<br />
 
Draws a bitmap on the screen.<br />
 
Draws a bitmap on the screen.<br />
Line 84: Line 84:
 
* '''z''' is the depth at which the bitmap should be drawn.<br />
 
* '''z''' is the depth at which the bitmap should be drawn.<br />
 
* '''unk''' is an unknown parameter, its value is usually set to 0.<br />
 
* '''unk''' is an unknown parameter, its value is usually set to 0.<br />
* '''bitmap''' is a pointer to the [[CBitmap]] object which should be rendered.<br />
 
* '''scrX''', '''scrY''', '''sX''' and '''sY''' determine which part of the bitmap should be rendered. scrX and scrY are the coordinates of the top left corner of the rectangle which will be used to "clip" the bitmap, and sX and sY are respectively the width and height of that clipping rectangle.<br />
 
 
* '''flags''' should be usually set to 0.<br />
 
* '''flags''' should be usually set to 0.<br />
  
Line 95: Line 93:
 
* '''name''' is a string containing the name of the global function which should be called.<br />
 
* '''name''' is a string containing the name of the global function which should be called.<br />
  
<br /><div id="AddInterfaceBitmap" style="font-size:16px;font-weight:bold;border:1px solid #C8C8C8;padding:3px;">void <font color=#006000>AddInterfaceBitmap</font> ( int ''unk'', fixed ''x'', fixed ''y'', [[CBitmap]] *''bitmap'', int ''srcX'', int ''srcY'', int ''sx'', int ''sy'', int ''flags'' )</div>
+
<br /><div id="AddInterfaceBitmap" style="font-size:16px;font-weight:bold;border:1px solid #C8C8C8;padding:3px;">void <font color=#006000>AddInterfaceBitmap</font> ( int ''unk'', fixed ''x'', fixed ''y'', [[CBitmap]] *''bitmap'', int ''sx'', int ''sy'', int ''flags'' )</div>
 
'''<font color="#FF0000">This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!</font>'''<br />
 
'''<font color="#FF0000">This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!</font>'''<br />
 
<br />
 
<br />
Line 103: Line 101:
 
* '''unk''' is an unknown parameter, its value is usually set to 0.<br />
 
* '''unk''' is an unknown parameter, its value is usually set to 0.<br />
 
* '''bitmap''' is a pointer to the [[CBitmap]] object which should be rendered.<br />
 
* '''bitmap''' is a pointer to the [[CBitmap]] object which should be rendered.<br />
* '''scrX''', '''scrY''', '''sX''' and '''sY''' determine which part of the bitmap should be rendered. scrX and scrY are the coordinates of the top left corner of the rectangle which will be used to "clip" the bitmap, and sX and sY are respectively the width and height of that clipping rectangle.<br />
 
 
* '''flags''' should be usually set to 0.<br />
 
* '''flags''' should be usually set to 0.<br />
  
Line 139: Line 136:
 
See [[CQuad]] for more information.<br />
 
See [[CQuad]] for more information.<br />
  
<br /><div id="DoExplosion" style="font-size:16px;font-weight:bold;border:1px solid #C8C8C8;padding:3px;">void <font color=#006000>DoExplosion</font> ( int ''unk'', fixed ''x'', fixed ''y'', int ''push'', int ''damage'', int ''unkB'', int ''team'' )</div>
+
<br /><div id="DoExplosion" style="font-size:16px;font-weight:bold;border:1px solid #C8C8C8;padding:3px;">void <font color=#006000>DoExplosion</font> ( fixed ''x'', fixed ''y'', int ''push'', int ''damage'', int ''unkB'', int ''team'' )</div>
 
Creates an explosion at a given position.<br />
 
Creates an explosion at a given position.<br />
 
<br />
 
<br />

Latest revision as of 15:56, 15 January 2012


Experimental page


Icon wa 16x16.png Worms Armageddon class

Base class for every object, contains basic methods for receiving messages as well as graphical and sound methods.

Inherited by CGObject CTurnGame

Fields

Childs : CObjList
ClType : EObjectClass
GS : CGameState *
HaveHashTable : bool
Parent : CObject *
Store : CHashStore *
StoreIndex : int
StoreType : int

Methods

[constructor] CObject ( CObject *parent )
void AddBitmap ( fixed z, fixed x, fixed y, int unk, CBitmap *bitmap, int sx, int sy, int flags )
void AddCustomRender ( fixed z, string name )
void AddInterfaceBitmap ( int unk, fixed x, fixed y, CBitmap *bitmap, int sx, int sy, int flags )
void AddSprite ( fixed z, fixed x, fixed y, int unk, int sprite, fixed frame )
void AddSpriteEx ( fixed z, fixed x, fixed y, int sprite, fixed frame, float rot, float scale )
void AddSpriteQ ( fixed z, CQuad *q, int sprite, fixed frame, int flags )
void DoExplosion ( fixed x, fixed y, int push, int damage, int unkB, int team )
void Free ( bool freeMem )
void Message ( CObject *sender, EMType type, int mSize, CMessageData *mData )
void PlaySound ( int index, int unk, fixed unkB, fixed unkC, fixed pan )
void SetActiveLevel ( )
void SetActiveLevel ( int mult )


Detailed description

This class is the base of every spawnable object and provides the user with simple methods for handling messages and rendering sprites.

Field documentation


Childs : CObjList

A list which contains every object parented to this object.


ClType : EObjectClass

An integer identifier which tells what kind of class this object belongs to.
See EObjectClass for more information.


GS : CGameState*

A pointer to the global CGameState object.


HaveHashTable : bool

True if the object contains a storage hash table. If this is false, accessing Store will most likely crash the game.


Parent : CObject*

The parent of this object, or NullObj if this object has no parent.


Store : CHashStore*

Storage hash table. There are not many uses found for this other than Store->GetObject(25, 0), which returns a pointer to the world.


StoreIndex : int

Unknown.


StoreType : int

Unknown.


Method documentation


[constructor] CObject ( CObject *parent )

Default constructor, takes a pointer to the object's parent as an argument. Most objects should be parented to Store->GetObject(25, 0), which is supposedly the world object.


void AddBitmap ( fixed z, fixed x, fixed y, int unk, CBitmap *bitmap, int sx, int sy, int flags )

This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!
Draws a bitmap on the screen.

  • x and y are the coordinates at which the bitmap should be rendered. Note that the bitmap's top left corner will be positioned there, and not the center.
  • z is the depth at which the bitmap should be drawn.
  • unk is an unknown parameter, its value is usually set to 0.
  • flags should be usually set to 0.

void AddCustomRender ( fixed z, string name )

This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!
Calls a custom drawing function for fast rendering.

  • z is the depth at which the rendering should be done.
  • name is a string containing the name of the global function which should be called.

void AddInterfaceBitmap ( int unk, fixed x, fixed y, CBitmap *bitmap, int sx, int sy, int flags )

This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!

Draws a bitmap on the interface. Bitmaps drawn using this method will be rendered relative to the screen instead of the level, and will render in front of everything else.

  • x and y are the coordinates at which the bitmap should be rendered. Note that the bitmap's top left corner will be positioned there, and not the center.
  • unk is an unknown parameter, its value is usually set to 0.
  • bitmap is a pointer to the CBitmap object which should be rendered.
  • flags should be usually set to 0.

void AddSprite ( fixed z, fixed x, fixed y, int unk, int sprite, fixed frame )

This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!
Renders a centered sprite in world coordinates.

  • x and y are the coordinates at which the sprite should be rendered. Note that the sprite will be centered on those coordinates.
  • z is the depth at which the sprite should be drawn. Sprites with a lower Z value will render in front of sprites with a higher Z value. Rendering two sprites at the same place with the same depth will result in Z fighting. The standard depth for rendering objects such as projectiles is 5.
  • unk is an unknown parameter, it is usually set to 0.
  • sprite is the identifier of the sprite to render. Adding 262144 to it will result in the sprite being mirrored horizontally.
  • frame defines which frame of a sprite should be rendered when using animated sprites. The value of this argument should be a value between 0 and 1, where 0 is the first frame and 1 is the last frame of the animation.

void AddSpriteEx ( fixed z, fixed x, fixed y, int sprite, fixed frame, float rot, float scale )

This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!
Renders a centered sprite in world coordinates, with rotation and scaling.

  • x and y are the coordinates at which the sprite should be rendered.
  • z is the depth at which the sprite should be drawn.
  • sprite is the identifier of the sprite to render. Adding 262144 to it will result in the sprite being mirrored horizontally.
  • frame defines which frame of a sprite should be rendered when using animated sprites. The value of this argument should be a value between 0 and 1, where 0 is the first frame and 1 is the last frame of the animation.
  • rot defines how much the sprite should be rotated, in radians.
  • scale defines how much the sprite should be scaled. 1 renders the sprite at normal size, 2 renders the sprite at double size.

void AddSpriteQ ( fixed z, CQuad *q, int sprite, fixed frame, int flags )

This function should be only called in the Message function when a message of type M_DRAWQUEUE is being processed!
Renders a sprite using a quad, allows for advanced deformations, transparency and colouring.

  • q is a pointer to the quad object which should be used for rendering the sprite.
  • z is the depth at which the sprite should be drawn.
  • sprite is the identifier of the sprite to render. Adding 262144 to it will result in the sprite being mirrored horizontally.
  • frame defines which frame of a sprite should be rendered when using animated sprites. The value of this argument should be a value between 0 and 1, where 0 is the first frame and 1 is the last frame of the animation.
  • flags should be usually set to 0. When set to 64, the sprite will be rendered in additive blending mode, useful for glowing effects.


See CQuad for more information.


void DoExplosion ( fixed x, fixed y, int push, int damage, int unkB, int team )

Creates an explosion at a given position.

  • unk and unkB are unknown arguments, and are usually set respectively to 1 and 0.
  • x and y are the coordinates at which the explosion should be created.
  • push is the force of the explosion, how far objects and worms will fly when exposed to it. 100 is approximatively the explosion force of a Bazooka.
  • damage is the amount of damage done by the explosion. The size of the hole created in the landscape is automatically calculated from this value.

void Free ( bool freeMem )

Removes the object. This should be called with an argument of true if the object was allocated on the heap (created with the new operator), and false otherwise.


void Message ( CObject *sender, EMType type, int mSize, CMessageData *mData )

This function is the core of scripted objects, it is called every time an event occurs in the game.

  • sender is a pointer to the object which sent this message.
  • type is a number defining the type of the event which occured.
  • mSize is the total size of the message, it should be always equal to 1032.
  • mData contains the information sent along with the message.


Scripted objects should override this function to define custom behaviour. It is also possible to send a message to an object by calling this function on it with the correct arguments.

See Message, EMType and CMessageData for more information.


void PlaySound ( int index, int unk, fixed unkB, fixed unkC, fixed pan )

Plays a sound.

  • index is the index of the sound to play.
  • unk, unkB and unkC are unknown arguments, they are usually set respectively to 0, 1 and 1.
  • pan is the balance of the sound. 0 will play the sound on both speakers, -1 will play the sound only on the left speaker, 1 will play the sound only on the right speaker. Use this to give an illusion of position when playing a sound which should originate from a moving object.

void SetActiveLevel ( )

Unknown.


void SetActiveLevel ( int mult )

Unknown.