From 69b5220d914fb3b874622dcbf8e0fbd4fd73d1f7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 5 Oct 2012 22:36:53 +0300 Subject: Second part adding mob particle effects for attacks. Base on commit from mana afa134640b2e2c7c0f28a54c8691545848795dd9 by Yohann Ferreira --- src/resources/beinginfo.cpp | 7 +++++-- src/resources/beinginfo.h | 6 ++++++ src/resources/monsterdb.cpp | 10 ++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src/resources') diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 992a43b5b..9ee0f3de9 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -30,7 +30,8 @@ #include "debug.h" BeingInfo *BeingInfo::unknown = nullptr; -Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, -1, std::string()); +Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, + -1, -1, -1, std::string()); BeingInfo::BeingInfo() : mName(_("unnamed")), @@ -114,12 +115,14 @@ const Attack *BeingInfo::getAttack(const int id) const } void BeingInfo::addAttack(const int id, std::string action, const int effectId, + const int hitEffectId, const int criticalHitEffectId, const std::string &missileParticle) { if (mAttacks[id]) delete mAttacks[id]; - mAttacks[id] = new Attack(action, effectId, missileParticle); + mAttacks[id] = new Attack(action, effectId, hitEffectId, + criticalHitEffectId, missileParticle); } void BeingInfo::clear() diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index ceaed6c40..306ac637d 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -32,12 +32,17 @@ struct Attack final { std::string mAction; int mEffectId; + int mHitEffectId; + int mCriticalHitEffectId; std::string mMissileParticle; Attack(const std::string &action, const int effectId, + const int hitEffectId, const int criticalHitEffectId, const std::string &missileParticle) : mAction(action), mEffectId(effectId), + mHitEffectId(hitEffectId), + mCriticalHitEffectId(criticalHitEffectId), mMissileParticle(missileParticle) { } @@ -101,6 +106,7 @@ class BeingInfo final const std::string &getSound(const SoundEvent event) const; void addAttack(const int id, std::string action, + const int hitEffectId, const int criticalHitEffectId, const int effectId, const std::string &missileParticle); diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index f6352d8ec..d6aa53809 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -192,13 +192,19 @@ void MonsterDB::load() const int id = XML::getProperty(spriteNode, "id", 0); const int effectId = XML::getProperty( spriteNode, "effect-id", -1); + int hitEffectId = XML::getProperty(spriteNode, + "hit-effect-id", paths.getIntValue("hitEffectId")); + int criticalHitEffectId = XML::getProperty(spriteNode, + "critical-hit-effect-id", + paths.getIntValue("criticalHitEffectId")); + const std::string spriteAction = XML::getProperty( spriteNode, "action", "attack"); const std::string missileParticle = XML::getProperty( spriteNode, "missile-particle", ""); - currentInfo->addAttack(id, spriteAction, - effectId, missileParticle); + currentInfo->addAttack(id, spriteAction, hitEffectId, + criticalHitEffectId, effectId, missileParticle); } else if (xmlNameEqual(spriteNode, "particlefx")) { -- cgit v1.2.3-60-g2f50