diff --git a/src/client/creature.cpp b/src/client/creature.cpp index efb5a06d8e..1d7d49f368 100644 --- a/src/client/creature.cpp +++ b/src/client/creature.cpp @@ -1005,6 +1005,8 @@ ThingType* Creature::getMountThingType() const { uint16_t Creature::getCurrentAnimationPhase(const bool mount) { + if (!canAnimate()) return 0; + const auto thingType = mount ? getMountThingType() : getThingType(); if (const auto idleAnimator = thingType->getIdleAnimator()) { diff --git a/src/client/effect.cpp b/src/client/effect.cpp index 517f7474bc..f018c6edac 100644 --- a/src/client/effect.cpp +++ b/src/client/effect.cpp @@ -36,22 +36,24 @@ void Effect::draw(const Point& dest, const bool drawThings, const LightViewPtr& if (m_animationTimer.ticksElapsed() < m_timeToStartDrawing) return; - int animationPhase; - if (g_game.getFeature(Otc::GameEnhancedAnimations)) { - const auto* animator = getThingType()->getIdleAnimator(); - if (!animator) - return; - - // This requires a separate getPhaseAt method as using getPhase would make all magic effects use the same phase regardless of their appearance time - animationPhase = animator->getPhaseAt(m_animationTimer); - } else { - // hack to fix some animation phases duration, currently there is no better solution - int ticks = g_gameConfig.getEffectTicksPerFrame(); - if (m_clientId == 33) { - ticks <<= 2; + int animationPhase = 0; + if (canAnimate()) { + if (g_game.getFeature(Otc::GameEnhancedAnimations)) { + const auto* animator = getThingType()->getIdleAnimator(); + if (!animator) + return; + + // This requires a separate getPhaseAt method as using getPhase would make all magic effects use the same phase regardless of their appearance time + animationPhase = animator->getPhaseAt(m_animationTimer); + } else { + // hack to fix some animation phases duration, currently there is no better solution + int ticks = g_gameConfig.getEffectTicksPerFrame(); + if (m_clientId == 33) { + ticks <<= 2; + } + + animationPhase = std::min(static_cast(m_animationTimer.ticksElapsed() / ticks), getAnimationPhases() - 1); } - - animationPhase = std::min(static_cast(m_animationTimer.ticksElapsed() / ticks), getAnimationPhases() - 1); } const int offsetX = m_position.x - g_map.getCentralPosition().x; diff --git a/src/client/item.cpp b/src/client/item.cpp index e5136ec6bd..97248f4864 100644 --- a/src/client/item.cpp +++ b/src/client/item.cpp @@ -246,7 +246,7 @@ void Item::updatePatterns() int Item::calculateAnimationPhase() { - if (!hasAnimationPhases()) return 0; + if (!hasAnimationPhases() || !canAnimate()) return 0; if (getIdleAnimator()) return getIdleAnimator()->getPhase(); diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index fed4e057e9..bdb716b893 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -454,6 +454,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("setShader", &Thing::setShader); g_lua.bindClassMemberFunction("setPosition", &Thing::setPosition); g_lua.bindClassMemberFunction("setMarked", &Thing::lua_setMarked); + g_lua.bindClassMemberFunction("setAnimate", &Thing::setAnimate); g_lua.bindClassMemberFunction("isMarked", &Thing::isMarked); g_lua.bindClassMemberFunction("getId", &Thing::getId); g_lua.bindClassMemberFunction("getTile", &Thing::getTile); @@ -498,6 +499,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("setHighlight", &Thing::lua_setHighlight); g_lua.bindClassMemberFunction("isHighlighted", &Thing::isHighlighted); g_lua.bindClassMemberFunction("getExactSize", &Thing::getExactSize); + g_lua.bindClassMemberFunction("canAnimate", &Thing::canAnimate); #ifdef FRAMEWORK_EDITOR g_lua.registerClass(); diff --git a/src/client/thing.h b/src/client/thing.h index cd97da2237..ef75125a16 100644 --- a/src/client/thing.h +++ b/src/client/thing.h @@ -208,6 +208,9 @@ class Thing : public AttachableObject uint8_t getPatternY()const { return m_numPatternY; } uint8_t getPatternZ()const { return m_numPatternZ; } + bool canAnimate() { return m_animate; } + void setAnimate(bool aniamte) { m_animate = aniamte; } + protected: virtual ThingType* getThingType() const = 0; @@ -242,6 +245,7 @@ class Thing : public AttachableObject void lua_setHighlight(const std::string_view color) { setHighlight(Color(color)); } bool m_canDraw{ true }; + bool m_animate{ true }; friend class Client; friend class Tile;