diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index a960f693..11d9f277 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -36,7 +36,6 @@ Creature::Creature() : Thing(Otc::Creature) m_walking = false; m_walkOffsetX = 0; m_walkOffsetY = 0; - m_lastWalkAnim = 1; m_informationFont = g_fonts.getFont("tibia-12px-rounded"); } @@ -127,12 +126,11 @@ void Creature::draw(int x, int y) int walkOffset = std::max(std::abs(m_walkOffsetX), std::abs(m_walkOffsetY)); if(walkOffset % (int)std::ceil(32 / (float)attributes.animationPhases) == 0) { - if(m_lastWalkAnim+1 == attributes.animationPhases) - m_lastWalkAnim = 1; + if((m_animation+1) % attributes.animationPhases == 0) + m_animation = 1; else - m_lastWalkAnim++; + m_animation++; } - m_animation = m_lastWalkAnim; if(((m_walkOffsetX == 0 && m_walkOffsetY == 0) && m_walkOffsetX != m_walkOffsetY) || ((m_walkOffsetX == 0 || m_walkOffsetY == 0) && m_walkOffsetX == m_walkOffsetY)) { diff --git a/src/otclient/core/creature.h b/src/otclient/core/creature.h index 44557466..5565830e 100644 --- a/src/otclient/core/creature.h +++ b/src/otclient/core/creature.h @@ -93,7 +93,6 @@ private: Color m_informationColor; int m_lastTicks; - int m_lastWalkAnim; bool m_walking; float m_walkTimePerPixel; Position m_walkingFromPosition; diff --git a/src/otclient/core/item.cpp b/src/otclient/core/item.cpp index e67e3f7c..0c6d9e1c 100644 --- a/src/otclient/core/item.cpp +++ b/src/otclient/core/item.cpp @@ -38,11 +38,7 @@ void Item::draw(int x, int y) if(attributes.animationPhases > 1) { if(g_platform.getTicks() - m_lastTicks > 500) { - if(m_animation+1 == attributes.animationPhases) - m_animation = 0; - else - m_animation++; - + m_animation++; m_lastTicks = g_platform.getTicks(); } } diff --git a/src/otclient/core/thing.cpp b/src/otclient/core/thing.cpp index dcfd3fff..4024a1b8 100644 --- a/src/otclient/core/thing.cpp +++ b/src/otclient/core/thing.cpp @@ -42,26 +42,26 @@ void Thing::setPosition(const Position& position) void Thing::internalDraw(int x, int y, int layers, Otc::SpriteMask mask) { - const ThingAttributes& attributes = getAttributes(); + const ThingAttributes& type = getAttributes(); - for(int yi = 0; yi < attributes.height; yi++) { - for(int xi = 0; xi < attributes.width; xi++) { - int sprIndex = xi + - yi * attributes.width + - layers * attributes.width * attributes.height + - m_xPattern * attributes.width * attributes.height * attributes.layers + - m_yPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern + - m_zPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern + - m_animation * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern * attributes.zPattern; + for(int yi = 0; yi < type.height; yi++) { + for(int xi = 0; xi < type.width; xi++) { + int sprIndex = ((((((m_animation % type.animationPhases) + * type.zPattern + m_zPattern) + * type.yPattern + m_yPattern) + * type.xPattern + m_xPattern) + * type.layers + layers) + * type.height + yi) + * type.width + xi; - int spriteId = attributes.sprites[sprIndex]; + int spriteId = type.sprites[sprIndex]; if(!spriteId) continue; TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId, mask); - Rect drawRect((x - xi*32) - attributes.xDisplacment, - (y - yi*32) - attributes.yDisplacment, + Rect drawRect((x - xi*32) - type.xDisplacment, + (y - yi*32) - type.yDisplacment, 32, 32); g_graphics.drawTexturedRect(drawRect, spriteTex); }