From e6d7fca349c28eaf98d643325dc99dd9d3a53568 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 5 Oct 2012 21:33:44 +0300 Subject: first part for adding mobs particle effects. Based on mana commit b35aef2d924f03d85eb44a2465be5a745444eafd by Yohann Ferreira --- src/resources/beinginfo.cpp | 11 +++++------ src/resources/beinginfo.h | 22 +++++++++++----------- src/resources/monsterdb.cpp | 12 ++++++------ 3 files changed, 22 insertions(+), 23 deletions(-) (limited to 'src/resources') diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 5ffdb887d..992a43b5b 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -30,7 +30,7 @@ #include "debug.h" BeingInfo *BeingInfo::unknown = nullptr; -Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, "", ""); +Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, -1, std::string()); BeingInfo::BeingInfo() : mName(_("unnamed")), @@ -106,21 +106,20 @@ const std::string &BeingInfo::getSound(const SoundEvent event) const i->second->at(rand() % i->second->size()); } -const Attack *BeingInfo::getAttack(const int type) const +const Attack *BeingInfo::getAttack(const int id) const { - const Attacks::const_iterator i = mAttacks.find(type); + const Attacks::const_iterator i = mAttacks.find(id); return (i == mAttacks.end()) ? empty : (*i).second; } -void BeingInfo::addAttack(const int id, std::string action, - const std::string &particleEffect, +void BeingInfo::addAttack(const int id, std::string action, const int effectId, const std::string &missileParticle) { if (mAttacks[id]) delete mAttacks[id]; - mAttacks[id] = new Attack(action, particleEffect, missileParticle); + mAttacks[id] = new Attack(action, effectId, missileParticle); } void BeingInfo::clear() diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index ccd9ccf21..ceaed6c40 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -30,15 +30,15 @@ struct Attack final { - std::string action; - std::string particleEffect; - std::string missileParticle; - - Attack(std::string action0, std::string particleEffect0, - std::string missileParticle0) : - action(action0), - particleEffect(particleEffect0), - missileParticle(missileParticle0) + std::string mAction; + int mEffectId; + std::string mMissileParticle; + + Attack(const std::string &action, const int effectId, + const std::string &missileParticle) : + mAction(action), + mEffectId(effectId), + mMissileParticle(missileParticle) { } }; @@ -101,10 +101,10 @@ class BeingInfo final const std::string &getSound(const SoundEvent event) const; void addAttack(const int id, std::string action, - const std::string &particleEffect, + const int effectId, const std::string &missileParticle); - const Attack *getAttack(const int type) const; + const Attack *getAttack(const int id) const; void setWalkMask(const unsigned char mask) { mWalkMask = mask; } diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index a7976b97d..f6352d8ec 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -190,15 +190,15 @@ void MonsterDB::load() else if (xmlNameEqual(spriteNode, "attack")) { const int id = XML::getProperty(spriteNode, "id", 0); - const std::string particleEffect = XML::getProperty( - spriteNode, "particle-effect", ""); - const std::string spriteAction = XML::getProperty(spriteNode, - "action", - "attack"); + const 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); + effectId, missileParticle); } else if (xmlNameEqual(spriteNode, "particlefx")) { -- cgit v1.2.3-60-g2f50