summaryrefslogtreecommitdiff
path: root/src/game-server/monstermanager.cpp
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/game-server/monstermanager.cpp
parent0f0004ff3e286270c0425642a5669661ef6cb592 (diff)
downloadmanaserv-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/monstermanager.cpp')
-rw-r--r--src/game-server/monstermanager.cpp78
1 files changed, 8 insertions, 70 deletions
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp
index 2e772a38..0e98f94e 100644
--- a/src/game-server/monstermanager.cpp
+++ b/src/game-server/monstermanager.cpp
@@ -32,28 +32,6 @@
#define DEFAULT_MONSTER_SIZE 16
#define DEFAULT_MONSTER_SPEED 4.0f
-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;
-}
-
void MonsterManager::reload()
{
deinitialize();
@@ -150,12 +128,6 @@ void MonsterManager::initialize()
monster->setAttribute(ATTR_MAX_HP, hp);
monster->setAttribute(ATTR_HP, hp);
- monster->setAttribute(MOB_ATTR_PHY_ATK_MIN,
- XML::getProperty(subnode, "attack-min", -1));
- monster->setAttribute(MOB_ATTR_PHY_ATK_DELTA,
- XML::getProperty(subnode, "attack-delta", -1));
- monster->setAttribute(MOB_ATTR_MAG_ATK,
- XML::getProperty(subnode, "attack-magic", -1));
monster->setAttribute(ATTR_DODGE,
XML::getProperty(subnode, "evade", -1));
monster->setAttribute(ATTR_MAGIC_DODGE,
@@ -249,62 +221,28 @@ void MonsterManager::initialize()
}
else if (xmlStrEqual(subnode->name, BAD_CAST "attack"))
{
- MonsterAttack *att = new MonsterAttack;
- att->id = XML::getProperty(subnode, "id", 0);
- att->priority = XML::getProperty(subnode, "priority", 1);
- att->damageFactor = XML::getFloatProperty(subnode,
- "damage-factor", 1.0f);
- att->preDelay = XML::getProperty(subnode, "pre-delay", 1);
- att->aftDelay = XML::getProperty(subnode, "aft-delay", 0);
- att->range = XML::getProperty(subnode, "range", 0);
- att->scriptEvent = XML::getProperty(subnode, "script-event",
- std::string());
- std::string sElement = XML::getProperty(subnode,
- "element", "neutral");
- att->element = elementFromString(sElement);
- std::string sType = XML::getProperty(subnode,
- "type", "physical");
-
+ AttackInfo *att = AttackInfo::readAttackNode(subnode);
bool validMonsterAttack = true;
- if (sType == "physical")
- {
- att->type = DAMAGE_PHYSICAL;
- }
- else if (sType == "magical" || sType == "magic")
- {
- att->type = DAMAGE_MAGICAL;
- }
- else if (sType == "other")
- {
- att->type = DAMAGE_OTHER;
- }
- else
- {
- LOG_WARN("Monster manager " << mMonsterReferenceFile
- << ": unknown damage type '" << sType << "'.");
- validMonsterAttack = false;
- }
- if (att->id < 1)
+ if (att->getDamage().id < 1)
{
LOG_WARN(mMonsterReferenceFile
<< ": Attack without ID for monster Id:"
<< id << " (" << name << ") - attack ignored");
validMonsterAttack = false;
}
- else if (att->element == ELEMENT_ILLEGAL)
+ else if (att->getDamage().element == ELEMENT_ILLEGAL)
{
LOG_WARN(mMonsterReferenceFile
- << ": Attack with unknown element \""
- << sElement << "\" for monster Id:" << id
- << " (" << name << ") - attack ignored");
+ << ": Attack with unknown element for monster Id:"
+ << id << " (" << name << ") - attack ignored");
validMonsterAttack = false;
}
- else if (att->type == -1)
+ else if (att->getDamage().type == DAMAGE_OTHER)
{
LOG_WARN(mMonsterReferenceFile
- << ": Attack with unknown type \"" << sType << "\""
- << " for monster Id:" << id
+ << ": Attack with unknown damage type "
+ << "for monster Id:" << id
<< " (" << name << ")");
validMonsterAttack = false;
}