summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-05 23:39:39 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-06 00:33:02 +0300
commitd8fca9f196ad59be5b211325ac2d70e29379e825 (patch)
treebb65fde6f734283be151b5d21c771f425d84ef3e /src
parent69b5220d914fb3b874622dcbf8e0fbd4fd73d1f7 (diff)
downloadmanaverse-d8fca9f196ad59be5b211325ac2d70e29379e825.tar.gz
manaverse-d8fca9f196ad59be5b211325ac2d70e29379e825.tar.bz2
manaverse-d8fca9f196ad59be5b211325ac2d70e29379e825.tar.xz
manaverse-d8fca9f196ad59be5b211325ac2d70e29379e825.zip
Fix default particle effects in attacks.
Was broken in previous commits. Also add default value for "effectId" in paths.xml (by default -1)
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp29
-rw-r--r--src/being.h2
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/game.cpp1
-rw-r--r--src/resources/beinginfo.cpp11
-rw-r--r--src/resources/beinginfo.h2
-rw-r--r--src/resources/monsterdb.cpp2
7 files changed, 39 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 48c6cbe8b..89134bd0b 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -657,12 +657,26 @@ void Being::takeDamage(Being *const attacker, const int amount,
const BeingInfo *const info = attacker->getInfo();
if (info)
{
- const Attack *attack = info->getAttack(attackId);
-
- if (type != CRITICAL)
- hitEffectId = attack->mHitEffectId;
+ const Attack *atk = info->getAttack(attackId);
+ if (atk)
+ {
+ if (type != CRITICAL)
+ hitEffectId = atk->mHitEffectId;
+ else
+ hitEffectId = atk->mCriticalHitEffectId;
+ }
else
- hitEffectId = attack->mCriticalHitEffectId;
+ {
+ if (type != CRITICAL)
+ {
+ hitEffectId = paths.getIntValue("hitEffectId");
+ }
+ else
+ {
+ hitEffectId = paths.getIntValue(
+ "criticalHitEffectId");
+ }
+ }
}
}
else
@@ -678,7 +692,8 @@ void Being::takeDamage(Being *const attacker, const int amount,
// move skills effects to +100000 in effects list
hitEffectId = attackId + 100000;
}
- effectManager->trigger(hitEffectId, this);
+ if (effectManager && hitEffectId >= 0)
+ effectManager->trigger(hitEffectId, this);
}
}
}
@@ -1053,7 +1068,7 @@ void Being::setAction(const Action &action, const int attackId)
default:
break;
}
- if (effectManager)
+ if (effectManager && effectId >= 0)
effectManager->trigger(effectId, this, rotation);
}
}
diff --git a/src/being.h b/src/being.h
index a3535afc2..379e7a179 100644
--- a/src/being.h
+++ b/src/being.h
@@ -258,7 +258,7 @@ class Being : public ActorSprite, public ConfigListener
* @param id skill id
*/
void takeDamage(Being *const attacker, const int damage,
- const AttackType type, const int attackId = 0);
+ const AttackType type, const int attackId = 1);
/**
* Handles an attack of another being by this being.
diff --git a/src/defaults.cpp b/src/defaults.cpp
index fd6feeee9..49b683a37 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -321,6 +321,7 @@ DefaultsData* getPathsDefaults()
AddDEF("particles", "graphics/particles/");
AddDEF("levelUpEffectFile", "levelup.particle.xml");
AddDEF("portalEffectFile", "warparea.particle.xml");
+ AddDEF("effectId", -1);
AddDEF("hitEffectId", 26);
AddDEF("criticalHitEffectId", 28);
diff --git a/src/game.cpp b/src/game.cpp
index 2ebda2032..c86af69a9 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -173,6 +173,7 @@ static void initEngines()
particleEngine = new Particle(nullptr);
particleEngine->setupEngine();
+ BeingInfo::init();
DepricatedEvent::trigger(CHANNEL_GAME,
DepricatedEvent(EVENT_ENGINESINITALIZED));
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 9ee0f3de9..eef4ba7b7 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -22,6 +22,7 @@
#include "resources/beinginfo.h"
+#include "configuration.h"
#include "logger.h"
#include "utils/dtor.h"
@@ -132,3 +133,13 @@ void BeingInfo::clear()
delete empty;
empty = nullptr;
}
+
+void BeingInfo::init()
+{
+ if (empty)
+ {
+ empty->mEffectId = paths.getIntValue("effectId");
+ empty->mHitEffectId = paths.getIntValue("hitEffectId");
+ empty->mCriticalHitEffectId = paths.getIntValue("criticalHitEffectId");
+ }
+}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 306ac637d..d08e85608 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -169,6 +169,8 @@ class BeingInfo final
void setDeadSortOffsetY(const int n)
{ mDeadSortOffsetY = n; }
+ static void init();
+
static void clear();
private:
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index d6aa53809..2bbd51d5a 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -191,7 +191,7 @@ void MonsterDB::load()
{
const int id = XML::getProperty(spriteNode, "id", 0);
const int effectId = XML::getProperty(
- spriteNode, "effect-id", -1);
+ spriteNode, "effect-id", paths.getIntValue("effectId"));
int hitEffectId = XML::getProperty(spriteNode,
"hit-effect-id", paths.getIntValue("hitEffectId"));
int criticalHitEffectId = XML::getProperty(spriteNode,