summaryrefslogtreecommitdiff
path: root/src/game-server/being.hpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2007-03-11 21:38:08 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2007-03-11 21:38:08 +0000
commit99f34a8a72f63b4bd9fc2f3c370c8cbe9b9127cf (patch)
treec075dcc834e0720e6de819c7514f4fdfa7cfe554 /src/game-server/being.hpp
parent0a74cd8c92844e730cf6f56bdc3dd578c65a10d0 (diff)
downloadmanaserv-99f34a8a72f63b4bd9fc2f3c370c8cbe9b9127cf.tar.gz
manaserv-99f34a8a72f63b4bd9fc2f3c370c8cbe9b9127cf.tar.bz2
manaserv-99f34a8a72f63b4bd9fc2f3c370c8cbe9b9127cf.tar.xz
manaserv-99f34a8a72f63b4bd9fc2f3c370c8cbe9b9127cf.zip
Implemented stat handling infrastructure and basic damage calculation.
Diffstat (limited to 'src/game-server/being.hpp')
-rw-r--r--src/game-server/being.hpp119
1 files changed, 92 insertions, 27 deletions
diff --git a/src/game-server/being.hpp b/src/game-server/being.hpp
index 2eaffa16..77b7bfc8 100644
--- a/src/game-server/being.hpp
+++ b/src/game-server/being.hpp
@@ -30,12 +30,14 @@
#include "defines.h"
#include "game-server/object.hpp"
+class Being;
class MapComposite;
/**
* Element attribute for beings, actors and items.
+ * Subject to change until pauan and dabe are finished with the element system.
*/
-enum
+enum Element
{
ELEMENT_NEUTRAL = 0,
ELEMENT_FIRE,
@@ -75,38 +77,43 @@ enum
DIRECTION_RIGHT
};
-
/**
- * Computed statistics of a Being.
+ * Methods of damage calculation
*/
-enum
+enum Damagetype
{
- STAT_HEAT = 0,
- STAT_ATTACK,
- STAT_DEFENCE,
- STAT_MAGIC,
- STAT_ACCURACY,
- STAT_SPEED,
- NB_CSTAT
+ DAMAGETYPE_PHYSICAL,
+ DAMAGETYPE_MAGICAL,
+ DAMAGETYPE_HAZARD,
+ DAMAGETYPE_OTHER
};
/**
- * Structure type for the computed statistics of a Being.
+ * Structure describing severity and nature of an attack a being can suffer of
*/
-struct Statistics
+struct Damage
{
- unsigned short stats[NB_CSTAT];
+ int value;
+ int penetration;
+ Element element;
+ Damagetype type;
+ Being *source;
};
/**
- * Placeholder for a more complex damage structure
+ * Type definition for a list of hits
*/
-typedef unsigned short Damage;
+typedef std::list<unsigned int> Hits;
/**
- * Type definition for a list of hits
+ * Structure type for the stats of a Being.
*/
-typedef std::list<unsigned int> Hits;
+struct Stats
+{
+ std::vector<unsigned short> base;
+ std::vector<short> absoluteModificator;
+ std::vector< std::list<short> > percentModificators;
+};
/**
* Generic Being (living object).
@@ -115,6 +122,20 @@ typedef std::list<unsigned int> Hits;
class Being : public MovingObject
{
public:
+
+ /**
+ * Computed statistics of a Being.
+ */
+ enum Stat
+ {
+ STAT_HP_MAXIMUM,
+ STAT_PHYSICAL_ATTACK_MINIMUM,
+ STAT_PHYSICAL_ATTACK_FLUCTUATION,
+ STAT_PHYSICAL_DEFENCE,
+ // add new computed statistics on demand
+ NB_STATS_BEING
+ };
+
/**
* Moves enum for beings and actors for others players vision.
* WARNING: Has to be in sync with the same enum in the Being class
@@ -128,6 +149,7 @@ class Being : public MovingObject
DEAD,
HURT
};
+
/**
* Proxy constructor.
*/
@@ -137,27 +159,70 @@ class Being : public MovingObject
{}
/**
- * Sets a computed statistic.
+ * Sets a being statistic.
*
* @param numStat the statistic number.
* @param value the new value.
*/
- void setStat(int numStat, unsigned short value)
- { mStats.stats[numStat] = value; }
+ void setBaseStat(unsigned numStat, unsigned short value)
+ { mStats.base[numStat] = value;
+ calculateBaseStats();
+ }
+
+ /**
+ * Adds a fixed value stat modifier
+ */
+ void addAbsoluteStatModifier(unsigned numStat, short value);
+
+ /**
+ * Removes a fixed value stat modifier
+ */
+ void removeAbsoluteStatModifier(unsigned numStat, short value);
+
+ /**
+ * Adds a multiplier stat modificator in percent
+ */
+ void addPercentStatModifier(unsigned numStat, short value);
/**
- * Gets a computed statistic.
+ * Removes a previously added percent stat modifier.
+ * Does nothing and logs a warning when no modifier with the same
+ * value has been added before.
+ */
+ void removePercentStatModifier(unsigned numStat, short value);
+
+ /**
+ * Returns a being statistic without temporary modifiers
*
* @param numStat the statistic number.
* @return the statistic value.
*/
- unsigned short getStat(int numStat)
- { return mStats.stats[numStat]; }
+ unsigned short getBaseStat(unsigned stat)
+ { return mStats.base.at(stat); }
+
+ /**
+ * Returns a being statistic with added temporary modifiers
+ */
+ unsigned short getRealStat(unsigned stat);
+
+ /**
+ * Recalculates all stats of the being that are derived from others.
+ * Call whenever you change something that affects a derived stat.
+ * Called automatically when you manipulate a stat using setBaseStat()
+ */
+ virtual void calculateBaseStats()
+ { /*NOOP*/ };
+
+ /**
+ * Creates a damage structure for a normal melee attack based on the
+ * current being stats and equipment.
+ */
+ Damage getPhysicalAttackDamage();
/**
* sets the hit points
*/
- void setHitpoints(int hp)
+ void setHitpoints(unsigned hp)
{ mHitpoints = hp; }
/**
@@ -206,12 +271,12 @@ class Being : public MovingObject
int mHitpoints; /**< Hitpoints of the being */
Action mAction;
+ Stats mStats;
+
private:
Being(Being const &rhs);
Being &operator=(Being const &rhs);
- Statistics mStats; /**< stats modifiers or computed stats */
-
Hits mHitsTaken; /**< List of punches taken since last update */
};