diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-06-10 15:11:01 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-01-08 16:58:57 +0100 |
commit | 6f287f239e9d94707735b183d6c6b89eea9fef20 (patch) | |
tree | 694427dbff77f73a1a3a4f84b4f53269a4763f74 /src/game-server/monster.h | |
parent | 0f0004ff3e286270c0425642a5669661ef6cb592 (diff) | |
download | manaserv-6f287f239e9d94707735b183d6c6b89eea9fef20.tar.gz manaserv-6f287f239e9d94707735b183d6c6b89eea9fef20.tar.bz2 manaserv-6f287f239e9d94707735b183d6c6b89eea9fef20.tar.xz manaserv-6f287f239e9d94707735b183d6c6b89eea9fef20.zip |
Work on (Auto)Attack system.
During the implementation bjorn and I agreed to limit the number of attacks that
can be used in the same tick to one. This makes a lot of stuff easier and the
client cannot display two frames at the same time
Things done:
- Implemented setting of attacks when equipping/unequipping items
- Single place where the xml attack node is parsed
- Finished attack logic
- Unified the attack handling of monsters and characters
- Added a global cooldown after attack use
(not only for next use of same attack)
- Removed the temponary attributes for the monster attack values
- Priorities for all attacks
- Rewrote the attack core:
- Attacks now have this attributes:
- warmup -> time a attack needs after starting it to actually deal the damage
- cooldown -> time a attack needs after dealing damage before another attack
can be used
- reuse -> time before the same attack can be used again
- If no attack is performed at the moment the following is done:
- make a list with all ready attacks
- check for attack that has the necessarily range and highest priority
- start this attack (inform client about it)
- when warmup is finished -> trigger damage
- when cooldown is finished -> allow to use other (or the same if reusetimer
allows) attacks
TODO:
- sync client with this to allow better timed animations
Diffstat (limited to 'src/game-server/monster.h')
-rw-r--r-- | src/game-server/monster.h | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/src/game-server/monster.h b/src/game-server/monster.h index 5da975e9..600196f7 100644 --- a/src/game-server/monster.h +++ b/src/game-server/monster.h @@ -54,7 +54,7 @@ struct MonsterAttack unsigned id; int priority; float damageFactor; - int element; + Element element; DamageType type; int preDelay; int aftDelay; @@ -62,8 +62,6 @@ struct MonsterAttack std::string scriptEvent; }; -typedef std::vector< MonsterAttack *> MonsterAttacks; - /** * Class describing the characteristics of a generic monster. */ @@ -85,6 +83,8 @@ class MonsterClass mOptimalLevel(0) {} + ~MonsterClass(); + /** * Returns monster type. This is the Id of the monster class. */ @@ -188,10 +188,10 @@ class MonsterClass unsigned getAttackDistance() const { return mAttackDistance; } /** Adds an attack to the monsters repertoire. */ - void addAttack(MonsterAttack *type) { mAttacks.push_back(type); } + void addAttack(AttackInfo *info) { mAttacks.push_back(info); } /** Returns all attacks of the monster. */ - const MonsterAttacks &getAttacks() const { return mAttacks; } + std::vector<AttackInfo *> &getAttackInfos() { return mAttacks; } /** sets the script file for the monster */ void setScript(const std::string &filename) { mScript = filename; } @@ -205,18 +205,12 @@ class MonsterClass void setDamageCallback(Script *script) { script->assignCallback(mDamageCallback); } - void setEventCallback(const std::string &event, Script *script) - { script->assignCallback(mEventCallbacks[event]); } - Script::Ref getUpdateCallback() const { return mUpdateCallback; } Script::Ref getDamageCallback() const { return mDamageCallback; } - Script::Ref getEventCallback(const std::string &event) const - { return mEventCallbacks.value(event); } - private: unsigned short mId; std::string mName; @@ -234,7 +228,7 @@ class MonsterClass int mMutation; int mAttackDistance; int mOptimalLevel; - MonsterAttacks mAttacks; + std::vector<AttackInfo *> mAttacks; std::string mScript; /** @@ -247,12 +241,6 @@ class MonsterClass */ Script::Ref mDamageCallback; - /** - * Named event callbacks. Currently only used for custom attack - * callbacks. - */ - utils::NameMap<Script::Ref> mEventCallbacks; - friend class MonsterManager; friend class Monster; }; @@ -300,9 +288,9 @@ class Monster : public Being void refreshTarget(); /** - * Performs an attack, if needed. + * Performs an attack */ - void processAttack(); + virtual void processAttack(Attack &attack); /** * Loads a script file for this monster @@ -310,12 +298,6 @@ class Monster : public Being void loadScript(const std::string &scriptName); /** - * Gets the attack id the being is currently performing. - */ - virtual int getAttackId() const - { return mCurrentAttack->id; } - - /** * Kills the being. */ void died(); @@ -371,6 +353,9 @@ class Monster : public Being */ Character *mOwner; + /** Factor for damage mutation */ + unsigned mDamageMutation; + /** List of characters and their skills that attacked this monster. */ std::map<Character *, std::set <size_t> > mExpReceivers; @@ -380,9 +365,6 @@ class Monster : public Being */ std::set<Character *> mLegalExpReceivers; - /** Attack the monster is currently performing. */ - MonsterAttack *mCurrentAttack; - /** * Set positions relative to target from which the monster can attack. */ @@ -394,8 +376,6 @@ class Monster : public Being Timeout mKillStealProtectedTimeout; /** Time until dead monster is removed */ Timeout mDecayTimeout; - /** Time until monster can attack again */ - Timeout mAttackTimeout; friend struct MonsterTargetEventDispatch; }; |