diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-05-26 23:41:01 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-05-26 23:42:10 +0200 |
commit | b35aef2d924f03d85eb44a2465be5a745444eafd (patch) | |
tree | 5de5dc327397f9e970ce1bdfacf850a16da02241 /src/resources | |
parent | b02081c00450d274c23b7198620ee7748756bd72 (diff) | |
download | mana-client-b35aef2d924f03d85eb44a2465be5a745444eafd.tar.gz mana-client-b35aef2d924f03d85eb44a2465be5a745444eafd.tar.bz2 mana-client-b35aef2d924f03d85eb44a2465be5a745444eafd.tar.xz mana-client-b35aef2d924f03d85eb44a2465be5a745444eafd.zip |
Added effects support in monsters attacks.
This is provided through the use of the 'effect-id' property
of the <attack> tag.
Note that the 'particle-effect' support has been removed
as it was redundant, but can be kept for backward compatibility.
Now, on both Manaserv and tA, only the attack id 1 is supported,
i.e:
<monster>
...
<attack id="1" effect-id="11" action="attack" />
</monster>
More to come with re-enabling of the attack type support.
I had to fix a crash in the Being::takeDamage() function
when there were no attacker (in Manaserv), and add rotation
support to the effectManager to achieve this.
Reviwed-by: Jaxad0127.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/beinginfo.cpp | 13 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 23 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 11 |
3 files changed, 22 insertions, 25 deletions
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index e8824391..22651f6f 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -88,20 +88,19 @@ const std::string &BeingInfo::getSound(SoundEvent event) const i->second->at(rand() % i->second->size()); } -const Attack *BeingInfo::getAttack(int type) const +const Attack *BeingInfo::getAttack(int id) const { - static Attack *empty = new Attack(SpriteAction::ATTACK, "", ""); + static Attack *empty = new Attack(SpriteAction::ATTACK, -1, std::string()); - Attacks::const_iterator i = mAttacks.find(type); + Attacks::const_iterator i = mAttacks.find(id); return (i == mAttacks.end()) ? empty : (*i).second; } -void BeingInfo::addAttack(int id, std::string action, - const std::string &particleEffect, - const std::string &missileParticle) +void BeingInfo::addAttack(int id, std::string action, int effectId, + const std::string &missileParticleFilename) { if (mAttacks[id]) delete mAttacks[id]; - mAttacks[id] = new Attack(action, particleEffect, missileParticle); + mAttacks[id] = new Attack(action, effectId, missileParticleFilename); } diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 52390976..b4529b2f 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -32,16 +32,16 @@ #include <vector> struct Attack { - std::string action; - std::string particleEffect; - std::string missileParticle; + std::string mAction; + int mEffectId; + std::string mMissileParticleFilename; - Attack(std::string action, std::string particleEffect, - std::string missileParticle) + Attack(std::string action, int effectId, + std::string missileParticleFilename) { - this->action = action; - this->particleEffect = particleEffect; - this->missileParticle = missileParticle; + mAction = action; + mEffectId = effectId; + mMissileParticleFilename = missileParticleFilename; } }; @@ -95,11 +95,10 @@ class BeingInfo const std::string &getSound(SoundEvent event) const; - void addAttack(int id, std::string action, - const std::string &particleEffect, - const std::string &missileParticle); + void addAttack(int id, std::string action, int effectId, + const std::string &missileParticleFilename); - const Attack *getAttack(int type) const; + const Attack *getAttack(int id) const; void setWalkMask(unsigned char mask) { mWalkMask = mask; } diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 6bc64a89..ca9b8e83 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -124,15 +124,14 @@ void MonsterDB::load() else if (xmlStrEqual(spriteNode->name, BAD_CAST "attack")) { const int id = XML::getProperty(spriteNode, "id", 0); - const std::string particleEffect = XML::getProperty( - spriteNode, "particle-effect", ""); + int effectId = XML::getProperty(spriteNode, "effect-id", -1); const std::string spriteAction = XML::getProperty(spriteNode, "action", "attack"); - const std::string missileParticle = XML::getProperty( - spriteNode, "missile-particle", ""); - currentInfo->addAttack(id, spriteAction, - particleEffect, missileParticle); + const std::string missileParticleFilename = + XML::getProperty(spriteNode, "missile-particle", ""); + currentInfo->addAttack(id, spriteAction, effectId, + missileParticleFilename); } else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) { |