From 585a33e221a7ee392791f4fd5a5ec9214b8fe868 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sat, 30 Mar 2013 09:29:08 +0100 Subject: 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 --- src/game-server/being.h | 86 ++++--------------------------------------------- 1 file changed, 7 insertions(+), 79 deletions(-) (limited to 'src/game-server/being.h') 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 @@ -46,11 +46,6 @@ struct Status typedef std::map< int, Status > StatusEffects; -/** - * Type definition for a list of hits - */ -typedef std::vector 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(); @@ -86,21 +74,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. */ @@ -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. */ @@ -163,15 +117,6 @@ class Being : public Actor BeingAction getAction() const { 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. */ @@ -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); } @@ -317,11 +255,6 @@ class Being : public Actor { return mEmoteId; } 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; -- cgit v1.2.3-60-g2f50