diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-06 03:54:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-06 03:54:00 +0300 |
commit | 4fb8f9f0905038f3180f108ec56b2a326ceb3483 (patch) | |
tree | 94b221f6bc81e07d565d2828dac078f471854b81 /src | |
parent | df9a705c331da29cb0582539a817f68c79d4f267 (diff) | |
download | manaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.tar.gz manaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.tar.bz2 manaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.tar.xz manaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.zip |
Add particle effect miss-effect-id to items and monsters.
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 111 | ||||
-rw-r--r-- | src/being.h | 6 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/resources/beinginfo.cpp | 6 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 8 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 3 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 5 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 7 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 9 |
9 files changed, 102 insertions, 54 deletions
diff --git a/src/being.cpp b/src/being.cpp index 89134bd0b..ad867ffbc 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -635,67 +635,92 @@ void Being::takeDamage(Being *const attacker, const int amount, updateName(); } else if (mType == PLAYER && socialWindow && getName() != "") + { socialWindow->updateAvatar(getName()); + } if (effectManager) { - // Init the particle effect path based on current - // weapon or default. - int hitEffectId = 0; - if (type != SKILL) + int hitEffectId = getHitEffect(attacker, type, attackId); + if (hitEffectId >= 0) + effectManager->trigger(hitEffectId, this); + } + } + else + { + if (effectManager) + { + int hitEffectId = getHitEffect(attacker, + MISS, attackId); + if (hitEffectId >= 0) + effectManager->trigger(hitEffectId, this); + } + } +} + +int Being::getHitEffect(const Being *const attacker, + const AttackType type, const int attackId) const +{ + if (!effectManager) + return 0; + + // Init the particle effect path based on current + // weapon or default. + int hitEffectId = 0; + if (type != SKILL) + { + const ItemInfo *attackerWeapon = attacker->getEquippedWeapon(); + if (attackerWeapon && attacker->getType() == PLAYER) + { + if (type == MISS) + hitEffectId = attackerWeapon->getMissEffectId(); + else if (type != CRITICAL) + hitEffectId = attackerWeapon->getHitEffectId(); + else + hitEffectId = attackerWeapon->getCriticalHitEffectId(); + } + else if (attacker && attacker->getType() == MONSTER) + { + const BeingInfo *const info = attacker->getInfo(); + if (info) { - const ItemInfo *attackerWeapon = attacker->getEquippedWeapon(); - if (attackerWeapon && attacker->getType() == PLAYER) + const Attack *atk = info->getAttack(attackId); + if (atk) { - if (type != CRITICAL) - hitEffectId = attackerWeapon->getHitEffectId(); + if (type == MISS) + hitEffectId = atk->mMissEffectId; + else if (type != CRITICAL) + hitEffectId = atk->mHitEffectId; else - hitEffectId = attackerWeapon->getCriticalHitEffectId(); - } - else if (attacker && attacker->getType() == MONSTER) - { - const BeingInfo *const info = attacker->getInfo(); - if (info) - { - const Attack *atk = info->getAttack(attackId); - if (atk) - { - if (type != CRITICAL) - hitEffectId = atk->mHitEffectId; - else - hitEffectId = atk->mCriticalHitEffectId; - } - else - { - if (type != CRITICAL) - { - hitEffectId = paths.getIntValue("hitEffectId"); - } - else - { - hitEffectId = paths.getIntValue( - "criticalHitEffectId"); - } - } - } + hitEffectId = atk->mCriticalHitEffectId; } else { - if (type != CRITICAL) + if (type == MISS) + hitEffectId = paths.getIntValue("missEffectId"); + else if (type != CRITICAL) hitEffectId = paths.getIntValue("hitEffectId"); else hitEffectId = paths.getIntValue("criticalHitEffectId"); } } + } + else + { + if (type == MISS) + hitEffectId = paths.getIntValue("missEffectId"); + else if (type != CRITICAL) + hitEffectId = paths.getIntValue("hitEffectId"); else - { - // move skills effects to +100000 in effects list - hitEffectId = attackId + 100000; - } - if (effectManager && hitEffectId >= 0) - effectManager->trigger(hitEffectId, this); + hitEffectId = paths.getIntValue("criticalHitEffectId"); } } + else + { + // move skills effects to +100000 in effects list + hitEffectId = attackId + 100000; + } + return hitEffectId; } void Being::handleAttack(Being *const victim, const int damage, diff --git a/src/being.h b/src/being.h index 379e7a179..58d3ea21c 100644 --- a/src/being.h +++ b/src/being.h @@ -137,7 +137,8 @@ class Being : public ActorSprite, public ConfigListener MULTI = 0x08, REFLECT = 0x04, FLEE = 0x0b, - SKILL = 0xff + SKILL = 0xff, + MISS = 0xffff // pseudo value for miss attacks }; enum Reachable @@ -834,6 +835,9 @@ class Being : public ActorSprite, public ConfigListener void recalcSpritesOrder(); + int getHitEffect(const Being *const attacker, + const AttackType type, const int attackId) const; + static uint8_t genderToInt(const Gender sex); static Gender intToGender(uint8_t sex); diff --git a/src/defaults.cpp b/src/defaults.cpp index 49b683a37..a7b403298 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -323,6 +323,7 @@ DefaultsData* getPathsDefaults() AddDEF("portalEffectFile", "warparea.particle.xml"); AddDEF("effectId", -1); AddDEF("hitEffectId", 26); + AddDEF("missEffectId", -1); AddDEF("criticalHitEffectId", 28); AddDEF("minimaps", "graphics/minimaps/"); diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index eef4ba7b7..f55d1f2e3 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -32,7 +32,7 @@ BeingInfo *BeingInfo::unknown = nullptr; Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, - -1, -1, -1, std::string()); + -1, -1, -1, -1, std::string()); BeingInfo::BeingInfo() : mName(_("unnamed")), @@ -117,13 +117,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 int missEffectId, const std::string &missileParticle) { if (mAttacks[id]) delete mAttacks[id]; mAttacks[id] = new Attack(action, effectId, hitEffectId, - criticalHitEffectId, missileParticle); + criticalHitEffectId, missEffectId, missileParticle); } void BeingInfo::clear() @@ -141,5 +142,6 @@ void BeingInfo::init() empty->mEffectId = paths.getIntValue("effectId"); empty->mHitEffectId = paths.getIntValue("hitEffectId"); empty->mCriticalHitEffectId = paths.getIntValue("criticalHitEffectId"); + empty->mMissEffectId = paths.getIntValue("missEffectId"); } } diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index d08e85608..208fcd541 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -34,15 +34,17 @@ struct Attack final int mEffectId; int mHitEffectId; int mCriticalHitEffectId; + int mMissEffectId; std::string mMissileParticle; Attack(const std::string &action, const int effectId, const int hitEffectId, const int criticalHitEffectId, - const std::string &missileParticle) : + const int missEffectId, const std::string &missileParticle) : mAction(action), mEffectId(effectId), mHitEffectId(hitEffectId), mCriticalHitEffectId(criticalHitEffectId), + mMissEffectId(missEffectId), mMissileParticle(missileParticle) { } @@ -105,9 +107,9 @@ class BeingInfo final const std::string &getSound(const SoundEvent event) const; - void addAttack(const int id, std::string action, + void addAttack(const int id, std::string action, const int effectId, const int hitEffectId, const int criticalHitEffectId, - const int effectId, + const int missEffectId, const std::string &missileParticle); const Attack *getAttack(const int id) const; diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 8fd4a9fdc..559015be9 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -245,6 +245,8 @@ void ItemDB::load() const int criticalEffectId = XML::getProperty( node, "critical-hit-effect-id", paths.getIntValue("criticalHitEffectId")); + const int missEffectId = XML::getProperty(node, "miss-effect-id", + paths.getIntValue("missEffectId")); SpriteDisplay display; display.image = image; @@ -305,6 +307,7 @@ void ItemDB::load() itemInfo->setMissileParticleFile(missileParticle); itemInfo->setHitEffectId(hitEffectId); itemInfo->setCriticalHitEffectId(criticalEffectId); + itemInfo->setMissEffectId(missEffectId); itemInfo->setDrawBefore(-1, parseSpriteName(drawBefore)); itemInfo->setDrawAfter(-1, parseSpriteName(drawAfter)); itemInfo->setDrawPriority(-1, drawPriority); diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 7e106af80..c7d8ecc0e 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -81,8 +81,9 @@ ItemInfo::ItemInfo() : mMissileParticle(""), mColors(nullptr), mColorList(""), - mHitEffectId(0), - mCriticalHitEffectId(0), + mHitEffectId(-1), + mCriticalHitEffectId(-1), + mMissEffectId(-1), maxFloorOffset(32) { for (int f = 0; f < 10; f ++) diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 644b80154..ba429341d 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -194,6 +194,12 @@ class ItemInfo final int getCriticalHitEffectId() const { return mCriticalHitEffectId; } + void setMissEffectId(const int s) + { mMissEffectId = s; } + + int getMissEffectId() const + { return mMissEffectId; } + const std::string &getAttackAction() const { return mAttackAction; } @@ -306,6 +312,7 @@ class ItemInfo final std::string mColorList; int mHitEffectId; int mCriticalHitEffectId; + int mMissEffectId; int maxFloorOffset; }; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 3629357d1..22441c34e 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -192,11 +192,13 @@ void MonsterDB::load() const int id = XML::getProperty(spriteNode, "id", 0); const int effectId = XML::getProperty( spriteNode, "effect-id", paths.getIntValue("effectId")); - int hitEffectId = XML::getProperty(spriteNode, + const int hitEffectId = XML::getProperty(spriteNode, "hit-effect-id", paths.getIntValue("hitEffectId")); - int criticalHitEffectId = XML::getProperty(spriteNode, + const int criticalHitEffectId = XML::getProperty(spriteNode, "critical-hit-effect-id", paths.getIntValue("criticalHitEffectId")); + const int missEffectId = XML::getProperty(spriteNode, + "miss-effect-id", paths.getIntValue("missEffectId")); const std::string spriteAction = XML::getProperty( spriteNode, "action", "attack"); @@ -205,7 +207,8 @@ void MonsterDB::load() spriteNode, "missile-particle", ""); currentInfo->addAttack(id, spriteAction, effectId, - hitEffectId, criticalHitEffectId, missileParticle); + hitEffectId, criticalHitEffectId, missEffectId, + missileParticle); } else if (xmlNameEqual(spriteNode, "particlefx")) { |