diff --git a/modules/game/creature.lua b/modules/game/creature.lua new file mode 100644 index 00000000..4b0ea9b6 --- /dev/null +++ b/modules/game/creature.lua @@ -0,0 +1,75 @@ +SkullNone = 0 +SkullYellow = 1 +SkullGreen = 2 +SkullWhite = 3 +SkullRed = 4 +SkullBlack = 5 +SkullOrange = 6 + +ShieldNone = 0 +ShieldWhiteYellow = 1 +ShieldWhiteBlue = 2 +ShieldBlue = 3 +ShieldYellow = 4 +ShieldBlueSharedExp = 5 +ShieldYellowSharedExp = 6 +ShieldBlueNoSharedExpBlink = 7 +ShieldYellowNoSharedExpBlink = 8 +ShieldBlueNoSharedExp = 9 +ShieldYellowNoSharedExp = 10 + +EmblemNone = 0 +EmblemGreen = 1 +EmblemRed = 2 +EmblemBlue = 3 + +function Creature:onSkullChange(skullId) + if skullId == SkullYellow then + self:setSkullTexture(resolvepath('images/skull_yellow.png')) + elseif skullId == SkullGreen then + self:setSkullTexture(resolvepath('images/skull_green.png')) + elseif skullId == SkullWhite then + self:setSkullTexture(resolvepath('images/skull_white.png')) + elseif skullId == SkullRed then + self:setSkullTexture(resolvepath('images/skull_red.png')) + elseif skullId == SkullBlack then + self:setSkullTexture(resolvepath('images/skull_black.png')) + elseif skullId == SkullOrange then + self:setSkullTexture(resolvepath('images/skull_orange.png')) + end +end + +function Creature:onShieldChange(shieldId) + if shieldId == ShieldWhiteYellow then + self:setShieldTexture(resolvepath('images/shield_yellow_white.png')) + elseif shieldId == ShieldWhiteBlue then + self:setShieldTexture(resolvepath('images/shield_blue_white.png')) + elseif shieldId == ShieldBlue then + self:setShieldTexture(resolvepath('images/shield_blue.png')) + elseif shieldId == ShieldYellow then + self:setShieldTexture(resolvepath('images/shield_yellow.png')) + elseif shieldId == ShieldBlueSharedExp then + self:setShieldTexture(resolvepath('images/shield_blue_shared.png')) + elseif shieldId == ShieldYellowSharedExp then + self:setSkullTexture(resolvepath('images/shield_yellow_shared.png')) + elseif shieldId == ShieldBlueNoSharedExpBlink then + self:setSkullTexture(resolvepath('images/shield_blue_not_shared.png')) + elseif shieldId == ShieldYellowNoSharedExpBlink then + self:setSkullTexture(resolvepath('images/shield_yellow_not_shared.png')) + elseif shieldId == ShieldBlueNoSharedExp then + self:setSkullTexture(resolvepath('images/shield_blue_not_shared.png')) + elseif shieldId == ShieldYellowNoSharedExp then + self:setSkullTexture(resolvepath('images/shield_yellow_not_shared.png')) + end +end + +function Creature:onEmblemChange(emblemId) + if emblemId == EmblemGreen then + self:setEmblemTexture(resolvepath('images/emblem_green.png')) + elseif emblemId == EmblemRed then + self:setEmblemTexture(resolvepath('images/emblem_red.png')) + elseif emblemId == EmblemBlue then + self:setEmblemTexture(resolvepath('images/emblem_blue.png')) + end +end + diff --git a/modules/game/game.otmod b/modules/game/game.otmod index 0d8184c3..51f916ed 100644 --- a/modules/game/game.otmod +++ b/modules/game/game.otmod @@ -16,3 +16,4 @@ Module onLoad: | require 'game' require 'thing' + require 'creature' diff --git a/modules/game/images/emblem_blue.png b/modules/game/images/emblem_blue.png new file mode 100644 index 00000000..a018e3da Binary files /dev/null and b/modules/game/images/emblem_blue.png differ diff --git a/modules/game/images/emblem_green.png b/modules/game/images/emblem_green.png new file mode 100644 index 00000000..e5ead379 Binary files /dev/null and b/modules/game/images/emblem_green.png differ diff --git a/modules/game/images/emblem_red.png b/modules/game/images/emblem_red.png new file mode 100644 index 00000000..94d712ae Binary files /dev/null and b/modules/game/images/emblem_red.png differ diff --git a/modules/game/images/shield_blue.png b/modules/game/images/shield_blue.png new file mode 100644 index 00000000..2d057972 Binary files /dev/null and b/modules/game/images/shield_blue.png differ diff --git a/modules/game/images/shield_blue_not_shared.png b/modules/game/images/shield_blue_not_shared.png new file mode 100644 index 00000000..6bd6a782 Binary files /dev/null and b/modules/game/images/shield_blue_not_shared.png differ diff --git a/modules/game/images/shield_blue_shared.png b/modules/game/images/shield_blue_shared.png new file mode 100644 index 00000000..4cdc2b7b Binary files /dev/null and b/modules/game/images/shield_blue_shared.png differ diff --git a/modules/game/images/shield_blue_white.png b/modules/game/images/shield_blue_white.png new file mode 100644 index 00000000..f1aa8fe0 Binary files /dev/null and b/modules/game/images/shield_blue_white.png differ diff --git a/modules/game/images/shield_yellow.png b/modules/game/images/shield_yellow.png new file mode 100644 index 00000000..eaee81c1 Binary files /dev/null and b/modules/game/images/shield_yellow.png differ diff --git a/modules/game/images/shield_yellow_not_shared.png b/modules/game/images/shield_yellow_not_shared.png new file mode 100644 index 00000000..85b0b305 Binary files /dev/null and b/modules/game/images/shield_yellow_not_shared.png differ diff --git a/modules/game/images/shield_yellow_shared.png b/modules/game/images/shield_yellow_shared.png new file mode 100644 index 00000000..196c4fd2 Binary files /dev/null and b/modules/game/images/shield_yellow_shared.png differ diff --git a/modules/game/images/shield_yellow_white.png b/modules/game/images/shield_yellow_white.png new file mode 100644 index 00000000..7dc9899a Binary files /dev/null and b/modules/game/images/shield_yellow_white.png differ diff --git a/modules/game/images/skull_black.png b/modules/game/images/skull_black.png new file mode 100644 index 00000000..8d3ddc0e Binary files /dev/null and b/modules/game/images/skull_black.png differ diff --git a/modules/game/images/skull_green.png b/modules/game/images/skull_green.png new file mode 100644 index 00000000..382461f1 Binary files /dev/null and b/modules/game/images/skull_green.png differ diff --git a/modules/game/images/skull_orange.png b/modules/game/images/skull_orange.png new file mode 100644 index 00000000..0c906c1f Binary files /dev/null and b/modules/game/images/skull_orange.png differ diff --git a/modules/game/images/skull_red.png b/modules/game/images/skull_red.png new file mode 100644 index 00000000..67245fa6 Binary files /dev/null and b/modules/game/images/skull_red.png differ diff --git a/modules/game/images/skull_white.png b/modules/game/images/skull_white.png new file mode 100644 index 00000000..e2c3d551 Binary files /dev/null and b/modules/game/images/skull_white.png differ diff --git a/modules/game/images/skull_yellow.png b/modules/game/images/skull_yellow.png new file mode 100644 index 00000000..2994f8ef Binary files /dev/null and b/modules/game/images/skull_yellow.png differ diff --git a/src/otclient/const.h b/src/otclient/const.h index 5f5b6dd2..95b99423 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -368,6 +368,37 @@ namespace Otc StandWhileFighting = 0, ChaseOpponent = 1 }; + + enum PlayerSkulls { + SkullNone = 0, + SkullYellow = 1, + SkullGreen = 2, + SkullWhite = 3, + SkullRed = 4, + SkullBlack = 5, + SkullOrange = 6 + }; + + enum PlayerShields { + ShieldNone = 0, + ShieldWhiteYellow = 1, + ShieldWhiteBlue = 2, + ShieldBlue = 3, + ShieldYellow = 4, + ShieldBlueSharedExp = 5, + ShieldYellowSharedExp = 6, + ShieldBlueNoSharedExpBlink = 7, + ShieldYellowNoSharedExpBlink = 8, + ShieldBlueNoSharedExp = 9, + ShieldYellowNoSharedExp = 10 + }; + + enum PlayerEmblems { + EmblemNone = 0, + EmblemGreen = 1, + EmblemRed = 2, + EmblemBlue = 3 + }; } #endif diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index 65c794f6..95f9abb3 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -34,6 +34,7 @@ #include #include +#include #include "spritemanager.h" Creature::Creature() : Thing() @@ -158,6 +159,19 @@ void Creature::drawInformation(int x, int y, bool useGray, const Rect& visibleRe if(m_informationFont) m_informationFont->renderText(m_name, textRect, Fw::AlignTopCenter, fillColor); + + if(m_skull != Otc::SkullNone && m_skullTexture) { + g_painter.setColor(Fw::white); + g_painter.drawTexturedRect(Rect(x + 12, y + 5, m_skullTexture->getSize()), m_skullTexture); + } + if(m_shield != Otc::ShieldNone && m_shieldTexture) { + g_painter.setColor(Fw::white); + g_painter.drawTexturedRect(Rect(x, y + 5, m_shieldTexture->getSize()), m_shieldTexture); + } + if(m_emblem != Otc::EmblemNone && m_emblemTexture) { + g_painter.setColor(Fw::white); + g_painter.drawTexturedRect(Rect(x + 12, y + 16, m_emblemTexture->getSize()), m_emblemTexture); + } } void Creature::walk(const Position& position, bool inverse) @@ -325,6 +339,40 @@ void Creature::setOutfit(const Outfit& outfit) m_outfit.resetClothes(); } +void Creature::setSkull(uint8 skull) +{ + m_skull = skull; + g_lua.callGlobalField("Creature","onSkullChange", asCreature(), m_skull); +} + +void Creature::setShield(uint8 shield) +{ + m_shield = shield; + g_lua.callGlobalField("Creature","onShieldChange", asCreature(), m_shield); +} + +void Creature::setEmblem(uint8 emblem) +{ + m_emblem = emblem; + + g_lua.callGlobalField("Creature","onEmblemChange", asCreature(), m_emblem); +} + +void Creature::setSkullTexture(const std::string& filename) +{ + m_skullTexture = g_textures.getTexture(filename); +} + +void Creature::setShieldTexture(const std::string& filename) +{ + m_shieldTexture = g_textures.getTexture(filename); +} + +void Creature::setEmblemTexture(const std::string& filename) +{ + m_emblemTexture = g_textures.getTexture(filename); +} + void Creature::addVolatileSquare(uint8 color) { m_showVolatileSquare = true; diff --git a/src/otclient/core/creature.h b/src/otclient/core/creature.h index 18dfa80a..9b219d88 100644 --- a/src/otclient/core/creature.h +++ b/src/otclient/core/creature.h @@ -46,9 +46,12 @@ public: void setOutfit(const Outfit& outfit); void setLight(const Light& light) { m_light = light; } void setSpeed(uint16 speed) { m_speed = speed; } - void setSkull(uint8 skull) { m_skull = skull; } - void setShield(uint8 shield) { m_shield = shield; } - void setEmblem(uint8 emblem) { m_emblem = emblem; } + void setSkull(uint8 skull); + void setShield(uint8 shield); + void setEmblem(uint8 emblem); + void setSkullTexture(const std::string& filename); + void setShieldTexture(const std::string& filename); + void setEmblemTexture(const std::string& filename); void setPassable(bool passable) { m_passable = passable; } void addVolatileSquare(uint8 color); @@ -88,9 +91,8 @@ protected: Outfit m_outfit; Light m_light; uint16 m_speed; - uint8 m_skull; - uint8 m_shield; - uint8 m_emblem; + uint8 m_skull, m_shield, m_emblem; + TexturePtr m_skullTexture, m_shieldTexture, m_emblemTexture; bool m_passable; Color m_volatileSquareColor, m_staticSquareColor; bool m_showVolatileSquare, m_showStaticSquare; diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index 96ba5b4b..fac119e1 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -80,6 +80,9 @@ void OTClient::registerLuaFunctions() g_lua.bindClassMemberFunction("getName", &Creature::getName); g_lua.bindClassMemberFunction("setOutfit", &Creature::setOutfit); g_lua.bindClassMemberFunction("getOutfit", &Creature::getOutfit); + g_lua.bindClassMemberFunction("setSkullTexture", &Creature::setSkullTexture); + g_lua.bindClassMemberFunction("setShieldTexture", &Creature::setShieldTexture); + g_lua.bindClassMemberFunction("setEmblemTexture", &Creature::setEmblemTexture); g_lua.registerClass(); g_lua.registerClass();