Being Class Reference

Generic being (living actor). More...

#include <being.hpp>

Inheritance diagram for Being:

Actor Thing Character Monster NPC

List of all members.

Public Types

enum  Action {
  STAND, WALK, ATTACK, SIT,
  DEAD, HURT
}
 Moves enum for beings and actors for others players vision. More...

Public Member Functions

 Being (ThingType type)
 Proxy constructor.
virtual void update ()
 Cleans obsolete attribute modifiers.
virtual int damage (Actor *source, const Damage &damage)
 Takes a damage structure, computes the real damage based on the stats, deducts the result from the hitpoints and adds the result to the HitsTaken list.
virtual void died ()
 Changes status and calls all the "died" listeners.
virtual void perform ()
 Performs actions scheduled by the being.
const PointgetDestination () const
 Gets the destination coordinates of the being.
void setDestination (const Point &dst)
 Sets the destination coordinates of the being.
void clearDestination ()
 Sets the destination coordinates of the being to the current position.
const PointgetOldPosition () const
 Gets the old coordinates of the being.
void setDirection (int direction)
 Sets the facing direction of the being.
int getDirection () const
int getSpeed () const
 Gets beings speed.
void setSpeed (int s)
const Hits & getHitsTaken () const
 Gets the damage list.
void clearHitsTaken ()
 Clears the damage list.
void performAttack (const Damage &, const AttackZone *attackZone)
 Performs an attack.
void setAction (Action action)
 Sets the current action.
Action getAction () const
 Sets the current action.
virtual int getAttackType () const
 Gets the type of the attack the being is currently performing.
void move ()
 Moves the being toward its destination.
void setAttribute (int n, int value)
 Sets an attribute.
int getAttribute (int n) const
 Gets an attribute.
int getModifiedAttribute (int) const
 Gets an attribute after applying modifiers.
void applyModifier (int attr, int value, int duration=0, int lvl=0)
 Adds a modifier to one attribute.
void dispellModifiers (int level)
 Removes all the modifiers with a level low enough.
virtual void modifiedAttribute (int)
 Called when an attribute modifier is changed.
const std::string & getName () const
 Gets the name of the being.
void setName (const std::string &name)
 Sets the name of the being.

Static Public Member Functions

static int directionToAngle (int direction)
 Converts a direction to an angle.

Protected Attributes

Action mAction
std::vector< AttributemAttributes

Static Protected Attributes

static const int TICKS_PER_HP_REGENERATION = 100


Detailed Description

Generic being (living actor).

Keeps direction, destination and a few other relevant properties. Used for characters & monsters (all animated objects).

Definition at line 108 of file being.hpp.


Member Enumeration Documentation

Moves enum for beings and actors for others players vision.

WARNING: Has to be in sync with the same enum in the Being class of the client!

Definition at line 117 of file being.hpp.


Member Function Documentation

int Being::getSpeed (  )  const [inline]

Gets beings speed.

Todo:
Document what kind of units actor speed is in!

Definition at line 190 of file being.hpp.

void Being::applyModifier ( int  attr,
int  value,
int  duration = 0,
int  lvl = 0 
)

Adds a modifier to one attribute.

Parameters:
duration If non-zero, creates a temporary modifier that expires after duration ticks.
lvl If non-zero, indicates that a temporary modifier can be dispelled prematuraly by a spell of given level.

Definition at line 365 of file being.cpp.

References modifiedAttribute().

Referenced by ItemModifiers::applyAttributes(), ItemModifiers::cancelAttributes(), and update().

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

Gets the name of the being.

Reimplemented in Character.

Definition at line 269 of file being.hpp.

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

Sets the name of the being.

Reimplemented in Character.

Definition at line 273 of file being.hpp.

int Being::directionToAngle ( int  direction  )  [static]

Converts a direction to an angle.

Used for combat hit checks.

Definition at line 209 of file being.cpp.

Referenced by performAttack(), and Monster::update().


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

Generated on Sun Apr 26 17:30:46 2009 for TMW Server Collection by  doxygen 1.5.5