summaryrefslogtreecommitdiff
path: root/src/game-server/being.h
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-03-30 09:29:08 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-04-02 13:19:11 +0200
commit585a33e221a7ee392791f4fd5a5ec9214b8fe868 (patch)
tree3aa60a57ff7cdd8f57761d620352fd2ad4d0dd6f /src/game-server/being.h
parent4dfc82415691fe298f21bb2f81fed5c168ee14e5 (diff)
downloadmanaserv-585a33e221a7ee392791f4fd5a5ec9214b8fe868.tar.gz
manaserv-585a33e221a7ee392791f4fd5a5ec9214b8fe868.tar.bz2
manaserv-585a33e221a7ee392791f4fd5a5ec9214b8fe868.tar.xz
manaserv-585a33e221a7ee392791f4fd5a5ec9214b8fe868.zip
Moved fighting code into a component
All damage dealing is now handeled via CombatComponent. Monsters use a derived MonsterCombatComponent since they can have a damage mutation and have a seperate script callback. The wirering with Being is still not optional since most of the stuff does not exist as components. Things done: - Seperated the fighting code from Being and only let Characters and Monsters add the Component (less overhead for npcs) - Added a getter for Attribute values to prevent searching it all the time in non Being members - Fixed the type if the damage mutation to double (no idea why it was int) I did not want to copy it over incorrectly - Removed the addAttack/removeAttack overrides in Character and made the knuckleAttack being added based on newly added signals Future TODOS: - Remove depedency on Being as soon all needed dependencies are available as components of Entity - Move the monster script callback into the general combatcomponent and make it usuable for characters too
Diffstat (limited to 'src/game-server/being.h')
-rw-r--r--src/game-server/being.h86
1 files changed, 7 insertions, 79 deletions
diff --git a/src/game-server/being.h b/src/game-server/being.h
index 1d1f4204..ce45d59c 100644
--- a/src/game-server/being.h
+++ b/src/game-server/being.h
@@ -47,11 +47,6 @@ struct Status
typedef std::map< int, Status > StatusEffects;
/**
- * Type definition for a list of hits
- */
-typedef std::vector<unsigned> Hits;
-
-/**
* Generic being (living actor). Keeps direction, destination and a few other
* relevant properties. Used for characters & monsters (all animated objects).
*/
@@ -68,13 +63,6 @@ class Being : public Actor
*/
virtual void update();
- /**
- * 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 int damage(Actor *source, const Damage &damage);
-
/** Restores all hit points of the being */
void heal();
@@ -87,21 +75,6 @@ class Being : public Actor
virtual void died();
/**
- * Process all available attacks
- */
- void processAttacks();
-
- /**
- * Adds an attack to the available attacks
- */
- void addAttack(AttackInfo *attack);
-
- /**
- * Removes an attack from the available attacks
- */
- void removeAttack(AttackInfo *attackInfo);
-
- /**
* Gets the destination coordinates of the being.
*/
const Point &getDestination() const
@@ -133,25 +106,6 @@ class Being : public Actor
BeingDirection getDirection() const
{ return mDirection; }
-
- /**
- * Gets the damage list.
- */
- const Hits &getHitsTaken() const
- { return mHitsTaken; }
-
- /**
- * Clears the damage list.
- */
- void clearHitsTaken()
- { mHitsTaken.clear(); }
-
- /**
- * Performs an attack.
- * Return Value: damage inflicted or -1 when illegal target
- */
- int performAttack(Being *target, const Damage &dmg);
-
/**
* Sets the current action.
*/
@@ -164,15 +118,6 @@ class Being : public Actor
{ return mAction; }
/**
- * Gets the attack id the being is currently performing.
- * For being, this is defaulted to the first one (1).
- */
- virtual int getAttackId() const
- { return mCurrentAttack ?
- mCurrentAttack->getAttackInfo()->getDamage().id : 0;
- }
-
- /**
* Moves the being toward its destination.
*/
void move();
@@ -195,9 +140,14 @@ class Being : public Actor
void setAttribute(unsigned id, double value);
/**
- * Gets an attribute.
+ * Gets an attribute or 0 if not existing.
+ */
+ const Attribute *getAttribute(unsigned id) const;
+
+ /**
+ * Gets an attribute base.
*/
- double getAttribute(unsigned id) const;
+ double getAttributeBase(unsigned id) const;
/**
* Gets an attribute after applying modifiers.
@@ -285,18 +235,6 @@ class Being : public Actor
*/
static int directionToAngle(int direction);
- /**
- * Get Target
- */
- Being *getTarget() const
- { return mTarget; }
-
- /**
- * Set Target
- */
- void setTarget(Being *target)
- { mTarget = target; }
-
static void setUpdateDerivedAttributesCallback(Script *script)
{ script->assignCallback(mRecalculateDerivedAttributesCallback); }
@@ -318,11 +256,6 @@ class Being : public Actor
protected:
/**
- * Performs an attack
- */
- virtual void processAttack(Attack &attack);
-
- /**
* Update the being direction when moving so avoid directions desyncs
* with other clients.
*/
@@ -333,14 +266,10 @@ class Being : public Actor
BeingAction mAction;
AttributeMap mAttributes;
- Attacks mAttacks;
StatusEffects mStatus;
- Being *mTarget;
Point mOld; /**< Old coordinates. */
Point mDst; /**< Target coordinates. */
BeingGender mGender; /**< Gender of the being. */
- Attack *mCurrentAttack; /**< Last used attack. */
-
private:
Being(const Being &rhs);
@@ -355,7 +284,6 @@ class Being : public Actor
BeingDirection mDirection; /**< Facing direction. */
std::string mName;
- Hits mHitsTaken; /**< List of punches taken since last update. */
/** Time until hp is regenerated again */
Timeout mHealthRegenerationTimeout;