diff --git a/data/images/game/npcicons/icon_chat.png b/data/images/game/npcicons/icon_chat.png new file mode 100644 index 00000000..b0da15e0 Binary files /dev/null and b/data/images/game/npcicons/icon_chat.png differ diff --git a/data/images/game/npcicons/icon_quest.png b/data/images/game/npcicons/icon_quest.png new file mode 100644 index 00000000..dcc88607 Binary files /dev/null and b/data/images/game/npcicons/icon_quest.png differ diff --git a/data/images/game/npcicons/icon_trade.png b/data/images/game/npcicons/icon_trade.png new file mode 100644 index 00000000..87db9f0c Binary files /dev/null and b/data/images/game/npcicons/icon_trade.png differ diff --git a/data/images/game/npcicons/icon_tradequest.png b/data/images/game/npcicons/icon_tradequest.png new file mode 100644 index 00000000..7f90a6cc Binary files /dev/null and b/data/images/game/npcicons/icon_tradequest.png differ diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index 9a107312..9c45a65b 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -56,7 +56,7 @@ function init() end function bindKeys() - gameRootPanel:setAutoRepeatDelay(80) + gameRootPanel:setAutoRepeatDelay(200) bindWalkKey('Up', North) bindWalkKey('Right', East) diff --git a/modules/gamelib/const.lua b/modules/gamelib/const.lua index f4d4b8b7..06b4f5d7 100644 --- a/modules/gamelib/const.lua +++ b/modules/gamelib/const.lua @@ -186,7 +186,7 @@ CIPSOFT_RSA = "1321277432058722840622950990822933849527763264961655079678763618" "88792221429527047321331896351555606801473202394175817" -- set to the latest Tibia.pic signature to make otclient compatible with official tibia -PIC_SIGNATURE = 0x52131b61 +PIC_SIGNATURE = 0x52de78da OsTypes = { Linux = 1, diff --git a/modules/gamelib/creature.lua b/modules/gamelib/creature.lua index 22603871..5a734008 100644 --- a/modules/gamelib/creature.lua +++ b/modules/gamelib/creature.lua @@ -27,6 +27,12 @@ EmblemGreen = 1 EmblemRed = 2 EmblemBlue = 3 +NpcIconNone = 0 +NpcIconChat = 1 +NpcIconTrade = 2 +NpcIconQuest = 3 +NpcIconTradeQuest = 4 + -- @} function getSkullImagePath(skullId) @@ -91,6 +97,20 @@ function getEmblemImagePath(emblemId) return path end +function getIconImagePath(iconId) + local path + if iconId == NpcIconChat then + path = '/images/game/npcicons/icon_chat' + elseif iconId == NpcIconTrade then + path = '/images/game/npcicons/icon_trade' + elseif iconId == NpcIconQuest then + path = '/images/game/npcicons/icon_quest' + elseif iconId == NpcIconTradeQuest then + path = '/images/game/npcicons/icon_tradequest' + end + return path +end + function Creature:onSkullChange(skullId) local imagePath = getSkullImagePath(skullId) if imagePath then @@ -111,3 +131,10 @@ function Creature:onEmblemChange(emblemId) self:setEmblemTexture(imagePath) end end + +function Creature:onIconChange(iconId) + local imagePath = getIconImagePath(iconId) + if imagePath then + self:setIconTexture(imagePath) + end +end \ No newline at end of file diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index 719753e1..ca8ca5b4 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -54,7 +54,7 @@ function g_game.getSupportedClients() 940, 944, 953, 954, 960, 961, 963, 970, 980, 981, 982, 983, 984, 985, 986, 1001, 1002, 1010, 1020, 1021, - 1022, 1031, 1034, 1035 + 1022, 1031, 1034, 1035, 1036 } end diff --git a/src/client/const.h b/src/client/const.h index 59ff9e7d..c8c3289d 100644 --- a/src/client/const.h +++ b/src/client/const.h @@ -247,6 +247,14 @@ namespace Otc EmblemOther }; + enum CreatureIcons { + NpcIconNone = 0, + NpcIconChat, + NpcIconTrade, + NpcIconQuest, + NpcIconTradeQuest + }; + enum PlayerStates { IconNone = 0, IconPoison = 1, @@ -377,6 +385,8 @@ namespace Otc GameWritableDate = 51, GameAdditionalVipInfo = 52, GameBaseSkillU16 = 53, + GameCreatureIcons = 54, + GameHideNpcNames = 55, LastGameFeature = 101 }; diff --git a/src/client/creature.cpp b/src/client/creature.cpp index 3bfc45b4..48e0b6ff 100644 --- a/src/client/creature.cpp +++ b/src/client/creature.cpp @@ -53,6 +53,7 @@ Creature::Creature() : Thing() m_skull = Otc::SkullNone; m_shield = Otc::ShieldNone; m_emblem = Otc::EmblemNone; + m_icon = Otc::NpcIconNone; m_lastStepDirection = Otc::InvalidDirection; m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded")); m_nameCache.setAlign(Fw::AlignTopCenter); @@ -258,7 +259,7 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray) fillColor = Color(0x66, 0xcc, 0xff); - if(drawFlags & Otc::DrawBars) { + if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames))) { g_painter->setColor(Color::black); g_painter->drawFilledRect(backgroundRect); @@ -287,6 +288,11 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize()); g_painter->drawTexturedRect(emblemRect, m_emblemTexture); } + if(m_icon != Otc::NpcIconNone && m_iconTexture) { + g_painter->setColor(Color::white); + Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize()); + g_painter->drawTexturedRect(iconRect, m_iconTexture); + } } void Creature::turn(Otc::Direction direction) @@ -708,6 +714,12 @@ void Creature::setEmblem(uint8 emblem) callLuaField("onEmblemChange", m_emblem); } +void Creature::setIcon(uint8 icon) +{ + m_icon = icon; + callLuaField("onIconChange", m_icon); +} + void Creature::setSkullTexture(const std::string& filename) { m_skullTexture = g_textures.getTexture(filename); @@ -733,6 +745,12 @@ void Creature::setEmblemTexture(const std::string& filename) m_emblemTexture = g_textures.getTexture(filename); } +void Creature::setIconTexture(const std::string& filename) +{ + m_iconTexture = g_textures.getTexture(filename); +} + + void Creature::setSpeedFormula(double speedA, double speedB, double speedC) { m_speedFormula[Otc::SpeedFormulaA] = speedA; diff --git a/src/client/creature.h b/src/client/creature.h index ff2c5258..eb14c267 100644 --- a/src/client/creature.h +++ b/src/client/creature.h @@ -61,9 +61,11 @@ public: void setSkull(uint8 skull); void setShield(uint8 shield); void setEmblem(uint8 emblem); + void setIcon(uint8 icon); void setSkullTexture(const std::string& filename); void setShieldTexture(const std::string& filename, bool blink); void setEmblemTexture(const std::string& filename); + void setIconTexture(const std::string& filename); void setPassable(bool passable) { m_passable = passable; } void setSpeedFormula(double speedA, double speedB, double speedC); @@ -83,6 +85,7 @@ public: uint8 getSkull() { return m_skull; } uint8 getShield() { return m_shield; } uint8 getEmblem() { return m_emblem; } + uint8 getIcon() { return m_icon; } bool isPassable() { return m_passable; } Point getDrawOffset(); int getStepDuration(bool ignoreDiagonal = false, Otc::Direction dir = Otc::InvalidDirection); @@ -146,9 +149,11 @@ protected: uint8 m_skull; uint8 m_shield; uint8 m_emblem; + uint8 m_icon; TexturePtr m_skullTexture; TexturePtr m_shieldTexture; TexturePtr m_emblemTexture; + TexturePtr m_iconTexture; stdext::boolean m_showShieldTexture; stdext::boolean m_shieldBlink; stdext::boolean m_passable; diff --git a/src/client/game.cpp b/src/client/game.cpp index 8a926d7e..dd07e6fa 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1459,7 +1459,7 @@ void Game::setProtocolVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change protocol version while online"); - if(version != 0 && (version < 760 || version > 1035)) + if(version != 0 && (version < 760 || version > 1036)) stdext::throw_exception(stdext::format("Protocol version %d not supported", version)); m_features.reset(); @@ -1563,9 +1563,15 @@ void Game::setProtocolVersion(int version) } if (version >= 1035) { - enableFeature(Otc::GameDoubleSkills); - enableFeature(Otc::GameBaseSkillU16); + enableFeature(Otc::GameDoubleSkills); + enableFeature(Otc::GameBaseSkillU16); } + + if(version >= 1036) { + enableFeature(Otc::GameCreatureIcons); + enableFeature(Otc::GameHideNpcNames); + } + m_protocolVersion = version; Proto::buildMessageModesMap(version); @@ -1581,7 +1587,7 @@ void Game::setClientVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change client version while online"); - if(version != 0 && (version < 760 || version > 1035)) + if(version != 0 && (version < 760 || version > 1036)) stdext::throw_exception(stdext::format("Client version %d not supported", version)); m_clientVersion = version; diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index 933084d6..0420aa7f 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -297,9 +297,11 @@ void LocalPlayer::onAppear() { Creature::onAppear(); + /* Does not seem to be needed anymore // on teleports lock the walk if(!m_oldPosition.isInRange(m_position,1,1)) lockWalk(); + */ } void LocalPlayer::onPositionChange(const Position& newPos, const Position& oldPos) diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 8e9f1be8..093c651e 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -436,6 +436,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("getSkull", &Creature::getSkull); g_lua.bindClassMemberFunction("getShield", &Creature::getShield); g_lua.bindClassMemberFunction("getEmblem", &Creature::getEmblem); + g_lua.bindClassMemberFunction("getIcon", &Creature::getIcon); g_lua.bindClassMemberFunction("setOutfit", &Creature::setOutfit); g_lua.bindClassMemberFunction("getOutfit", &Creature::getOutfit); g_lua.bindClassMemberFunction("setOutfitColor", &Creature::setOutfitColor); @@ -448,6 +449,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("setSkullTexture", &Creature::setSkullTexture); g_lua.bindClassMemberFunction("setShieldTexture", &Creature::setShieldTexture); g_lua.bindClassMemberFunction("setEmblemTexture", &Creature::setEmblemTexture); + g_lua.bindClassMemberFunction("setIconTexture", &Creature::setIconTexture); g_lua.bindClassMemberFunction("showStaticSquare", &Creature::showStaticSquare); g_lua.bindClassMemberFunction("hideStaticSquare", &Creature::hideStaticSquare); g_lua.bindClassMemberFunction("isWalking", &Creature::isWalking); diff --git a/src/client/protocolcodes.cpp b/src/client/protocolcodes.cpp index 5fea82dd..6cc9a95e 100644 --- a/src/client/protocolcodes.cpp +++ b/src/client/protocolcodes.cpp @@ -28,8 +28,15 @@ std::map messageModesMap; void buildMessageModesMap(int version) { messageModesMap.clear(); - if(version >= 900) { - for(int i=Otc::MessageNone;i<=Otc::MessageBeyondLast;++i) + if(version >= 1036) { + for(int i = Otc::MessageNone; i <= Otc::MessageBeyondLast; ++i) { + if(i >= Otc::MessageNpcTo) + messageModesMap[i] = i + 1; + else + messageModesMap[i] = i; + } + } else if(version >= 900) { + for(int i = Otc::MessageNone; i <= Otc::MessageBeyondLast; ++i) messageModesMap[i] = i; } else if(version >= 861) { messageModesMap[Otc::MessageNone] = 0; diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 1ef15751..08ba09e1 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -1879,7 +1879,6 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type) CreaturePtr creature; bool known = (type != Proto::UnknownCreature); - if(type == Proto::OutdatedCreature || type == Proto::UnknownCreature) { if(known) { uint id = msg->getU32(); @@ -1944,6 +1943,7 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type) // emblem is sent only when the creature is not known int emblem = -1; + int icon = -1; bool unpass = true; uint8 mark; @@ -1952,6 +1952,13 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type) if(g_game.getFeature(Otc::GameThingMarks)) { msg->getU8(); // creature type for summons + } + + if(g_game.getFeature(Otc::GameCreatureIcons)) { + icon = msg->getU8(); + } + + if(g_game.getFeature(Otc::GameThingMarks)) { mark = msg->getU8(); // mark msg->getU16(); // helpers @@ -1977,6 +1984,8 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type) creature->setLight(light); if(emblem != -1) creature->setEmblem(emblem); + if(icon != -1) + creature->setIcon(icon); if(creature == m_localPlayer && !m_localPlayer->isKnown()) m_localPlayer->setKnown(true);