diff options
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/actorsprite.cpp | 80 | ||||
-rw-r--r-- | src/being/actorsprite.h | 16 |
2 files changed, 67 insertions, 29 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index 40b3ef992..df8f14fdf 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -22,6 +22,7 @@ #include "being/actorsprite.h" #include "configuration.h" +#include "settings.h" #include "statuseffect.h" #include "being/localplayer.h" @@ -214,42 +215,79 @@ void ActorSprite::setStatusEffectBlock(const int offset, } } +static void applyEffectByOption(ActorSprite *const actor, + const uint32_t option, + const OptionsMap& options) +{ + FOR_EACH (OptionsMapCIter, it, options) + { + const int opt = (*it).first; + const int id = (*it).second; + const Enable enable = (opt & option) != 0 ? Enable_true : Enable_false; + actor->setStatusEffect(id, enable); + } +} + void ActorSprite::setStatusEffectOpitons(const uint32_t option, const uint32_t opt1, const uint32_t opt2, const uint32_t opt3) { - uint32_t statusEffects = opt2; - statusEffects |= option << 16; - - setStunMode(opt1); - setStatusEffectBlock(0, - CAST_U16((statusEffects >> 16) & 0xffffU)); - setStatusEffectBlock(16, - CAST_U16(statusEffects & 0xffffU)); - setStatusEffectBlock(32, - opt3); + if (settings.legacyEffects == false) + { + applyEffectByOption(this, option, StatusEffectDB::getOptionMap()); + applyEffectByOption(this, opt1, StatusEffectDB::getOpt1Map()); + applyEffectByOption(this, opt2, StatusEffectDB::getOpt2Map()); + applyEffectByOption(this, opt3, StatusEffectDB::getOpt3Map()); + } + else + { + uint32_t statusEffects = opt2; + statusEffects |= option << 16; + setStunMode(opt1); + setStatusEffectBlock(0, + CAST_U16((statusEffects >> 16) & 0xffffU)); + setStatusEffectBlock(16, + CAST_U16(statusEffects & 0xffffU)); + setStatusEffectBlock(32, + opt3); + } } void ActorSprite::setStatusEffectOpitons(const uint32_t option, const uint32_t opt1, const uint32_t opt2) { - uint32_t statusEffects = opt2; - statusEffects |= option << 16; - - setStunMode(opt1); - setStatusEffectBlock(0, - CAST_U16((statusEffects >> 16) & 0xffffU)); - setStatusEffectBlock(16, - CAST_U16(statusEffects & 0xffffU)); + if (settings.legacyEffects == false) + { + applyEffectByOption(this, option, StatusEffectDB::getOptionMap()); + applyEffectByOption(this, opt1, StatusEffectDB::getOpt1Map()); + applyEffectByOption(this, opt2, StatusEffectDB::getOpt2Map()); + } + else + { + uint32_t statusEffects = opt2; + statusEffects |= option << 16; + setStunMode(opt1); + setStatusEffectBlock(0, + CAST_U16((statusEffects >> 16) & 0xffffU)); + setStatusEffectBlock(16, + CAST_U16(statusEffects & 0xffffU)); + } } void ActorSprite::setStatusEffectOpiton0(const uint32_t option) { - const uint32_t statusEffects = option << 16; - setStatusEffectBlock(0, - CAST_U16((statusEffects >> 16) & 0xffff)); + if (settings.legacyEffects == false) + { + applyEffectByOption(this, option, StatusEffectDB::getOptionMap()); + } + else + { + const uint32_t statusEffects = option << 16; + setStatusEffectBlock(0, + CAST_U16((statusEffects >> 16) & 0xffff)); + } } void ActorSprite::updateStunMode(const int oldMode, const int newMode) diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index 5c5f5a80d..0bc6eff00 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -131,14 +131,6 @@ class ActorSprite notfinal : public CompoundSprite, public Actor void setStatusEffectOpiton0(const uint32_t option); - /** - * A status effect block is a 16 bit mask of status effects. We assign - * each such flag a block ID of offset + bitnr. - * - * These are NOT the same as the status effect indices. - */ - void setStatusEffectBlock(const int offset, const uint16_t flags); - void setAlpha(const float alpha) override final { CompoundSprite::setAlpha(alpha); } @@ -200,6 +192,14 @@ class ActorSprite notfinal : public CompoundSprite, public Actor protected: /** + * A status effect block is a 16 bit mask of status effects. We assign + * each such flag a block ID of offset + bitnr. + * + * These are NOT the same as the status effect indices. + */ + void setStatusEffectBlock(const int offset, const uint16_t flags); + + /** * Notify self that the stun mode has been updated. Invoked by * setStunMode if something changed. */ |