Being Class Reference

#include <being.h>

Inheritance diagram for Being:

Monster Player LocalPlayer NPC

List of all members.


Detailed Description

Definition at line 71 of file being.h.


Public Types

enum  Type { UNKNOWN, PLAYER, NPC, MONSTER }
enum  Action {
  STAND, WALK, ATTACK, SIT,
  DEAD, HURT
}
 Action the being is currently performing WARNING: Has to be in sync with the same enum in the Being class of the server! More...
enum  Sprite {
  BASE_SPRITE = 0, SHOE_SPRITE, BOTTOMCLOTHES_SPRITE, TOPCLOTHES_SPRITE,
  HAIR_SPRITE, HAT_SPRITE, WEAPON_SPRITE, VECTOREND_SPRITE
}
enum  TargetCursorSize { TC_SMALL = 0, TC_MEDIUM, TC_LARGE, NUM_TC }
enum  Speech {
  NO_SPEECH = 0, TEXT_OVERHEAD, NO_NAME_IN_BUBBLE, NAME_IN_BUBBLE,
  NUM_SPEECH
}
enum  AttackType {
  HIT = 0x00, CRITICAL = 0x0a, MULTI = 0x08, REFLECT = 0x04,
  FLEE = 0x0b
}
enum  { DOWN = 1, LEFT = 2, UP = 4, RIGHT = 8 }
 Directions, to be used as bitmask values. More...

Public Member Functions

 Being (int id, int job, Map *map)
 Constructor.
virtual ~Being ()
void clearPath ()
 Removes all path nodes from this being.
void setDestination (int x, int y)
 Sets a new destination for this being to walk to.
const VectorgetDestination () const
 Returns the destination for this being.
void adjustCourse (int srcX, int srcY)
 Adjusts course to expected start point.
void adjustCourse (int srcX, int srcY, int destX, int destY)
 Adjusts course to expected start and end points.
void setSpeech (const std::string &text, int time=500)
 Puts a "speech balloon" above this being for the specified amount of time.
virtual void takeDamage (Being *attacker, int damage, AttackType type)
 Puts a damage bubble above this being.
virtual void handleAttack (Being *victim, int damage, AttackType type)
 Handles an attack of another being by this being.
const std::string & getName () const
 Returns the name of the being.
virtual void setName (const std::string &name)
 Sets the name for the being.
int getHairColor () const
 Gets the hair color for this being.
int getHairStyle () const
 Gets the hair style for this being.
virtual void setHairStyle (int style, int color)
 Sets the hair style and color for this being.
virtual void setSprite (int slot, int id, const std::string &color="")
 Sets visible equipments for this being.
virtual void setGender (Gender gender)
 Sets the gender of this being.
Gender getGender () const
virtual void setGM ()
 Triggers whether or not to show the name as a GM name.
virtual void logic ()
 Performs being logic.
void drawSpeech (int offsetX, int offsetY)
 Draws the speech text above the being.
void drawEmotion (Graphics *graphics, int offsetX, int offsetY)
 Draws the emotion picture above the being.
virtual Type getType () const
 Returns the type of the being.
void setWalkSpeed (int speed)
 Sets the walk speed (in pixels per second).
int getWalkSpeed () const
void setId (int id)
 Sets the sprite id.
int getId () const
void setMap (Map *map)
 Sets the map the being is on.
virtual void setAction (Action action, int attackType=0)
 Sets the current action.
bool isAlive () const
 Returns whether this being is still alive.
Uint8 getDirection () const
 Returns the current direction.
void setDirection (Uint8 direction)
 Sets the current direction.
SpriteDirection getSpriteDirection () const
 Returns the direction the being is facing.
virtual void draw (Graphics *graphics, int offsetX, int offsetY) const
 Draws this being to the given graphics context.
int getPixelX () const
 Returns the X coordinate in pixels.
int getPixelY () const
 Returns the Y coordinate in pixels.
void setPosition (const Vector &pos)
 Sets the position of this being.
void setPosition (float x, float y, float z=0.0f)
 Overloaded method provided for convenience.
const VectorgetPosition () const
 Returns the position of this being.
virtual int getWidth () const
 Returns the horizontal size of the current base sprite of the being.
virtual int getHeight () const
 Returns the vertical size of the current base sprite of the being.
virtual Being::TargetCursorSize getTargetCursorSize () const
 Returns the required size of a target cursor for this being.
void controlParticle (Particle *particle)
 Take control of a particle.
virtual unsigned char getWalkMask () const
 Gets the way the object is blocked by other objects.
const PathgetPath () const
 Returns the path this being is following.
void setTargetAnimation (SimpleAnimation *animation)
 Sets the target animation for this being.
void untarget ()
 Untargets the being.
void setEmote (Uint8 emotion, Uint8 emote_time)
void setStunMode (int stunMode)
 Sets the being's stun mode.
void setStatusEffect (int index, bool active)
void setStatusEffectBlock (int offset, Uint16 flags)
 A status effect block is a 16 bit mask of status effects.
virtual void triggerEffect (int effectId)
 Triggers a visual effect, such as `level up'.
virtual AnimatedSpritegetSprite (int index) const

Static Public Member Functions

static int getNumOfHairstyles ()
 Get the number of hairstyles implemented.
static int getHairColorCount ()
static int getHairStyleCount ()
static std::string getHairColor (int index)
static void load ()

Public Attributes

int mEmotion
 Currently showing emotion.
int mEmotionTime
 Time until emotion disappears.
int mSpeechTime
int mAttackSpeed
 Attack speed.
Action mAction
 Action the being is performing.
Uint16 mJob
 Job (player job, npc, monster, creature ).

Protected Member Functions

void setPath (const Path &path)
 Sets the new path for this being.
virtual void updateCoords ()
 Let the sub-classes react to a replacement.
virtual Map::BlockType getBlockType () const
 Gets the way the object blocks pathfinding for other objects.
void internalTriggerEffect (int effectId, bool sfx, bool gfx)
 Trigger visual effect, with components.
virtual void updateStunMode (int oldMode, int newMode)
 Notify self that the stun mode has been updated.
virtual void updateStatusEffect (int index, bool newStatus)
 Notify self that a status effect has flipped.
virtual void handleStatusEffect (StatusEffect *effect, int effectId)
 Handle an update to a status or stun effect.

Protected Attributes

int mId
 Unique sprite id.
Uint8 mDirection
 Facing direction.
MapmMap
 Map on which this being resides.
std::string mName
 Name of character.
SpriteIterator mSpriteIterator
bool mIsGM
bool mParticleEffects
 Whether to display particles or not.
const ItemInfomEquippedWeapon
 Engine-related infos about weapon.
Path mPath
 Number of hair styles in use.
std::string mSpeech
TextmText
int mHairStyle
int mHairColor
Gender mGender
Uint16 mStunMode
 Stun mode; zero if not stunned.
std::set< int > mStatusEffects
 set of active status effects
const gcn::Color * mNameColor
std::vector< AnimatedSprite * > mSprites
std::vector< int > mSpriteIDs
std::vector< std::string > mSpriteColors
ParticleList mStunParticleEffects
ParticleVector mStatusParticleEffects
ParticleList mChildParticleEffects

Static Protected Attributes

static std::vector< std::string > hairColors
static int mNumberOfHairColors = 1
static int mNumberOfHairstyles = 1
 Number of hair colors in use.

Private Attributes

bool mMustResetParticles
 Reset particle status effects on next redraw?
SpeechBubblemSpeechBubble
 Speech Bubble components.
int mWalkSpeed
 Walking speed (pixels/sec).
Vector mPos
Vector mDest
int mPx
int mPy
 Position in pixels.
SimpleAnimationmUsedTargetCursor
 Target cursor being used.

Member Enumeration Documentation

Enumerator:
UNKNOWN 
PLAYER 
NPC 
MONSTER 

Definition at line 74 of file being.h.

Action the being is currently performing WARNING: Has to be in sync with the same enum in the Being class of the server!

Enumerator:
STAND 
WALK 
ATTACK 
SIT 
DEAD 
HURT 

Definition at line 87 of file being.h.

Enumerator:
BASE_SPRITE 
SHOE_SPRITE 
BOTTOMCLOTHES_SPRITE 
TOPCLOTHES_SPRITE 
HAIR_SPRITE 
HAT_SPRITE 
WEAPON_SPRITE 
VECTOREND_SPRITE 

Definition at line 97 of file being.h.

Enumerator:
TC_SMALL 
TC_MEDIUM 
TC_LARGE 
NUM_TC 

Definition at line 120 of file being.h.

Enumerator:
NO_SPEECH 
TEXT_OVERHEAD 
NO_NAME_IN_BUBBLE 
NAME_IN_BUBBLE 
NUM_SPEECH 

Definition at line 128 of file being.h.

Enumerator:
HIT 
CRITICAL 
MULTI 
REFLECT 
FLEE 

Definition at line 137 of file being.h.

anonymous enum

Directions, to be used as bitmask values.

Enumerator:
DOWN 
LEFT 
UP 
RIGHT 

Definition at line 149 of file being.h.


Constructor & Destructor Documentation

Being::Being ( int  id,
int  job,
Map map 
)

Constructor.

Parameters:
id a unique being id
job partly determines the type of the being
map the map the being is on

Definition at line 74 of file being.cpp.

Being::~Being (  )  [virtual]

Definition at line 123 of file being.cpp.


Member Function Documentation

void Being::clearPath (  ) 

Removes all path nodes from this being.

Definition at line 328 of file being.cpp.

void Being::setDestination ( int  x,
int  y 
)

Sets a new destination for this being to walk to.

const Vector& Being::getDestination (  )  const [inline]

Returns the destination for this being.

Definition at line 191 of file being.h.

void Being::adjustCourse ( int  srcX,
int  srcY 
)

Adjusts course to expected start point.

void Being::adjustCourse ( int  srcX,
int  srcY,
int  destX,
int  destY 
)

Adjusts course to expected start and end points.

void Being::setSpeech ( const std::string &  text,
int  time = 500 
)

Puts a "speech balloon" above this being for the specified amount of time.

Parameters:
text The text that should appear.
time The amount of time the text should stay in milliseconds.

Definition at line 360 of file being.cpp.

void Being::takeDamage ( Being attacker,
int  damage,
AttackType  type 
) [virtual]

Puts a damage bubble above this being.

Parameters:
attacker the attacking being
damage the amount of damage recieved (0 means miss)
type the attack type

Reimplemented in Monster.

Definition at line 414 of file being.cpp.

void Being::handleAttack ( Being victim,
int  damage,
AttackType  type 
) [virtual]

Handles an attack of another being by this being.

Parameters:
victim the victim being
damage the amount of damage dealt (0 means miss)
type the attack type

Reimplemented in LocalPlayer, and Monster.

Definition at line 471 of file being.cpp.

const std::string& Being::getName (  )  const [inline]

Returns the name of the being.

Definition at line 238 of file being.h.

virtual void Being::setName ( const std::string &  name  )  [inline, virtual]

Sets the name for the being.

Parameters:
name The name that should appear.

Reimplemented in LocalPlayer, NPC, and Player.

Definition at line 246 of file being.h.

int Being::getHairColor (  )  const [inline]

Gets the hair color for this being.

Definition at line 252 of file being.h.

int Being::getHairStyle (  )  const [inline]

Gets the hair style for this being.

Definition at line 257 of file being.h.

static int Being::getNumOfHairstyles (  )  [inline, static]

Get the number of hairstyles implemented.

Definition at line 262 of file being.h.

void Being::setHairStyle ( int  style,
int  color 
) [virtual]

Sets the hair style and color for this being.

Reimplemented in Player.

Definition at line 347 of file being.cpp.

void Being::setSprite ( int  slot,
int  id,
const std::string &  color = "" 
) [virtual]

Sets visible equipments for this being.

Reimplemented in Player.

Definition at line 353 of file being.cpp.

virtual void Being::setGender ( Gender  gender  )  [inline, virtual]

Sets the gender of this being.

Reimplemented in NPC, and Player.

Definition at line 278 of file being.h.

Gender Being::getGender (  )  const [inline]

Definition at line 280 of file being.h.

virtual void Being::setGM (  )  [inline, virtual]

Triggers whether or not to show the name as a GM name.

Reimplemented in LocalPlayer.

Definition at line 292 of file being.h.

void Being::logic (  )  [virtual]

Performs being logic.

Reimplemented in LocalPlayer.

Definition at line 638 of file being.cpp.

void Being::drawSpeech ( int  offsetX,
int  offsetY 
)

Draws the speech text above the being.

Definition at line 757 of file being.cpp.

void Being::drawEmotion ( Graphics graphics,
int  offsetX,
int  offsetY 
)

Draws the emotion picture above the being.

Definition at line 744 of file being.cpp.

Being::Type Being::getType (  )  const [virtual]

Returns the type of the being.

Reimplemented in Monster, NPC, and Player.

Definition at line 810 of file being.cpp.

void Being::setWalkSpeed ( int  speed  )  [inline]

Sets the walk speed (in pixels per second).

Definition at line 317 of file being.h.

int Being::getWalkSpeed (  )  const [inline]

Definition at line 319 of file being.h.

void Being::setId ( int  id  )  [inline]

Sets the sprite id.

Definition at line 324 of file being.h.

int Being::getId (  )  const [inline]

Definition at line 326 of file being.h.

void Being::setMap ( Map map  ) 

Sets the map the being is on.

Definition at line 481 of file being.cpp.

void Being::setAction ( Action  action,
int  attackType = 0 
) [virtual]

Sets the current action.

Reimplemented in LocalPlayer, and Monster.

Definition at line 503 of file being.cpp.

bool Being::isAlive (  )  const [inline]

Returns whether this being is still alive.

Definition at line 341 of file being.h.

Uint8 Being::getDirection (  )  const [inline]

Returns the current direction.

Definition at line 346 of file being.h.

void Being::setDirection ( Uint8  direction  ) 

Sets the current direction.

Definition at line 551 of file being.cpp.

SpriteDirection Being::getSpriteDirection (  )  const

Returns the direction the being is facing.

void Being::draw ( Graphics graphics,
int  offsetX,
int  offsetY 
) const [virtual]

Draws this being to the given graphics context.

See also:
Sprite::draw(Graphics, int, int)

Definition at line 724 of file being.cpp.

int Being::getPixelX (  )  const [inline]

Returns the X coordinate in pixels.

Definition at line 380 of file being.h.

int Being::getPixelY (  )  const [inline]

Returns the Y coordinate in pixels.

See also:
Sprite::getPixelY()

Definition at line 387 of file being.h.

void Being::setPosition ( const Vector pos  ) 

Sets the position of this being.

Definition at line 138 of file being.cpp.

void Being::setPosition ( float  x,
float  y,
float  z = 0.0f 
) [inline]

Overloaded method provided for convenience.

See also:
setPosition(const Vector &pos)

Definition at line 413 of file being.h.

const Vector& Being::getPosition (  )  const [inline]

Returns the position of this being.

Definition at line 421 of file being.h.

int Being::getWidth (  )  const [virtual]

Returns the horizontal size of the current base sprite of the being.

Definition at line 893 of file being.cpp.

int Being::getHeight (  )  const [virtual]

Returns the vertical size of the current base sprite of the being.

Definition at line 901 of file being.cpp.

virtual Being::TargetCursorSize Being::getTargetCursorSize (  )  const [inline, virtual]

Returns the required size of a target cursor for this being.

Reimplemented in Monster.

Definition at line 437 of file being.h.

void Being::controlParticle ( Particle particle  ) 

Take control of a particle.

Definition at line 498 of file being.cpp.

virtual unsigned char Being::getWalkMask (  )  const [inline, virtual]

Gets the way the object is blocked by other objects.

Reimplemented in Monster, NPC, and Player.

Definition at line 448 of file being.h.

const Path& Being::getPath (  )  const [inline]

Returns the path this being is following.

An empty path is returned when this being isn't following any path currently.

Definition at line 455 of file being.h.

void Being::setTargetAnimation ( SimpleAnimation animation  ) 

Sets the target animation for this being.

Definition at line 909 of file being.cpp.

void Being::untarget (  )  [inline]

Untargets the being.

Definition at line 465 of file being.h.

void Being::setEmote ( Uint8  emotion,
Uint8  emote_time 
) [inline]

Definition at line 467 of file being.h.

void Being::setStunMode ( int  stunMode  )  [inline]

Sets the being's stun mode.

If zero, the being is `normal', otherwise it is `stunned' in some fashion.

Definition at line 477 of file being.h.

void Being::setStatusEffect ( int  index,
bool  active 
)

Definition at line 858 of file being.cpp.

void Being::setStatusEffectBlock ( int  offset,
Uint16  flags 
)

A status effect block is a 16 bit mask of status effects.

We assign each such flag a block ID of offset + bitnr.

These are NOT the same as the status effect indices.

Definition at line 815 of file being.cpp.

virtual void Being::triggerEffect ( int  effectId  )  [inline, virtual]

Triggers a visual effect, such as `level up'.

Only draws the visual effect, does not play sound effects

Parameters:
effectId ID of the effect to trigger

Definition at line 501 of file being.h.

int Being::getHairColorCount (  )  [static]

Definition at line 1010 of file being.cpp.

int Being::getHairStyleCount (  )  [static]

Definition at line 1005 of file being.cpp.

std::string Being::getHairColor ( int  index  )  [static]

Definition at line 1015 of file being.cpp.

virtual AnimatedSprite* Being::getSprite ( int  index  )  const [inline, virtual]

Definition at line 512 of file being.h.

void Being::load (  )  [static]

Definition at line 1023 of file being.cpp.

void Being::setPath ( const Path path  )  [protected]

Sets the new path for this being.

Definition at line 333 of file being.cpp.

virtual void Being::updateCoords (  )  [inline, protected, virtual]

Let the sub-classes react to a replacement.

Reimplemented in Monster, NPC, and Player.

Definition at line 526 of file being.h.

virtual Map::BlockType Being::getBlockType (  )  const [inline, protected, virtual]

Gets the way the object blocks pathfinding for other objects.

Reimplemented in Monster, NPC, and Player.

Definition at line 531 of file being.h.

void Being::internalTriggerEffect ( int  effectId,
bool  sfx,
bool  gfx 
) [protected]

Trigger visual effect, with components.

Parameters:
effectId ID of the effect to trigger
sfx Whether to trigger sound effects
gfx Whether to trigger graphical effects

Definition at line 981 of file being.cpp.

void Being::updateStunMode ( int  oldMode,
int  newMode 
) [protected, virtual]

Notify self that the stun mode has been updated.

Invoked by setStunMode if something changed.

Definition at line 847 of file being.cpp.

void Being::updateStatusEffect ( int  index,
bool  newStatus 
) [protected, virtual]

Notify self that a status effect has flipped.

The new flag is passed.

Definition at line 853 of file being.cpp.

void Being::handleStatusEffect ( StatusEffect effect,
int  effectId 
) [protected, virtual]

Handle an update to a status or stun effect.

Parameters:
The StatusEffect to effect
effectId -1 for stun, otherwise the effect index

Reimplemented in LocalPlayer.

Definition at line 825 of file being.cpp.


Member Data Documentation

Currently showing emotion.

Definition at line 156 of file being.h.

Time until emotion disappears.

Definition at line 157 of file being.h.

Definition at line 158 of file being.h.

Attack speed.

Definition at line 160 of file being.h.

Action the being is performing.

Definition at line 161 of file being.h.

Uint16 Being::mJob

Job (player job, npc, monster, creature ).

Definition at line 162 of file being.h.

int Being::mId [protected]

Unique sprite id.

Definition at line 563 of file being.h.

Uint8 Being::mDirection [protected]

Facing direction.

Definition at line 564 of file being.h.

Map* Being::mMap [protected]

Map on which this being resides.

Definition at line 568 of file being.h.

std::string Being::mName [protected]

Name of character.

Reimplemented in NPC, and Player.

Definition at line 569 of file being.h.

Definition at line 570 of file being.h.

bool Being::mIsGM [protected]

Definition at line 571 of file being.h.

bool Being::mParticleEffects [protected]

Whether to display particles or not.

Definition at line 572 of file being.h.

const ItemInfo* Being::mEquippedWeapon [protected]

Engine-related infos about weapon.

Definition at line 575 of file being.h.

std::vector< std::string > Being::hairColors [static, protected]

Definition at line 577 of file being.h.

int Being::mNumberOfHairColors = 1 [static, protected]

Definition at line 578 of file being.h.

int Being::mNumberOfHairstyles = 1 [static, protected]

Number of hair colors in use.

Definition at line 579 of file being.h.

Path Being::mPath [protected]

Number of hair styles in use.

Definition at line 581 of file being.h.

std::string Being::mSpeech [protected]

Definition at line 582 of file being.h.

Text* Being::mText [protected]

Reimplemented in Monster.

Definition at line 583 of file being.h.

int Being::mHairStyle [protected]

Definition at line 584 of file being.h.

int Being::mHairColor [protected]

Definition at line 585 of file being.h.

Gender Being::mGender [protected]

Definition at line 586 of file being.h.

Uint16 Being::mStunMode [protected]

Stun mode; zero if not stunned.

Definition at line 587 of file being.h.

std::set<int> Being::mStatusEffects [protected]

set of active status effects

Definition at line 588 of file being.h.

const gcn::Color* Being::mNameColor [protected]

Definition at line 590 of file being.h.

std::vector<AnimatedSprite*> Being::mSprites [protected]

Definition at line 592 of file being.h.

std::vector<int> Being::mSpriteIDs [protected]

Definition at line 593 of file being.h.

std::vector<std::string> Being::mSpriteColors [protected]

Definition at line 594 of file being.h.

Definition at line 595 of file being.h.

Definition at line 596 of file being.h.

Definition at line 597 of file being.h.

Reset particle status effects on next redraw?

Definition at line 609 of file being.h.

Speech Bubble components.

Definition at line 612 of file being.h.

int Being::mWalkSpeed [private]

Walking speed (pixels/sec).

Definition at line 614 of file being.h.

Vector Being::mPos [private]

Definition at line 616 of file being.h.

Vector Being::mDest [private]

Definition at line 617 of file being.h.

int Being::mPx [private]

Definition at line 618 of file being.h.

int Being::mPy [private]

Position in pixels.

Definition at line 618 of file being.h.

Target cursor being used.

Definition at line 621 of file being.h.


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:43 2009 for The Mana World by  doxygen 1.5.5