summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-06-10 15:11:01 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-01-08 16:58:57 +0100
commit6f287f239e9d94707735b183d6c6b89eea9fef20 (patch)
tree694427dbff77f73a1a3a4f84b4f53269a4763f74 /src/common
parent0f0004ff3e286270c0425642a5669661ef6cb592 (diff)
downloadmanaserv-6f287f239e9d94707735b183d6c6b89eea9fef20.tar.gz
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/common')
-rw-r--r--src/common/defines.h49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/common/defines.h b/src/common/defines.h
index dab5b03..d572df1 100644
--- a/src/common/defines.h
+++ b/src/common/defines.h
@@ -127,6 +127,28 @@ enum Element
ELEMENT_ILLEGAL
};
+static inline Element elementFromString(const std::string &name)
+{
+ static std::map<const std::string, Element> table;
+
+ if (table.empty())
+ {
+ table["neutral"] = ELEMENT_NEUTRAL;
+ table["fire"] = ELEMENT_FIRE;
+ table["water"] = ELEMENT_WATER;
+ table["earth"] = ELEMENT_EARTH;
+ table["air"] = ELEMENT_AIR;
+ table["lightning"] = ELEMENT_LIGHTNING;
+ table["metal"] = ELEMENT_METAL;
+ table["wood"] = ELEMENT_WOOD;
+ table["ice"] = ELEMENT_ICE;
+ }
+
+ std::map<const std::string, Element>::iterator val = table.find(name);
+
+ return val == table.end() ? ELEMENT_ILLEGAL : (*val).second;
+}
+
/**
* Damage type, used to know how to compute them.
*/
@@ -138,6 +160,23 @@ enum DamageType
DAMAGE_OTHER = -1
};
+static inline DamageType damageTypeFromString(const std::string &name)
+{
+ static std::map<const std::string, DamageType> table;
+
+ if (table.empty())
+ {
+ table["physical"] = DAMAGE_PHYSICAL;
+ table["magical"] = DAMAGE_MAGICAL;
+ table["direct"] = DAMAGE_DIRECT;
+ table["other"] = DAMAGE_OTHER;
+ }
+
+ std::map<const std::string, DamageType>::iterator val = table.find(name);
+
+ return val == table.end() ? DAMAGE_OTHER : (*val).second;
+}
+
/**
* A series of hardcoded attributes that must be defined.
* FIXME: Much of these serve only to indicate derivatives, and so would not be
@@ -174,15 +213,7 @@ enum
// Money and inventory size attributes.
ATTR_GP = 18,
- ATTR_INV_CAPACITY = 19,
-
- /**
- * Temporary attributes.
- * @todo Use Attacks instead.
- */
- MOB_ATTR_PHY_ATK_MIN = 20,
- MOB_ATTR_PHY_ATK_DELTA = 21,
- MOB_ATTR_MAG_ATK = 22
+ ATTR_INV_CAPACITY = 19
};
#endif // DEFINES_H