From 1ec3b65a3af0d0bbc68fb1763b019f348d68decb Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 3 Jul 2016 00:50:08 +0200 Subject: [PATCH] 10.94, 10.95 support --- modules/game_skills/skills.lua | 26 +++++++++++++++++---- modules/game_skills/skills.otui | 39 ++++++++++++++++++++++++++++++++ modules/gamelib/const.lua | 19 ++++++++++++++++ modules/gamelib/game.lua | 2 +- src/client/const.h | 30 +++++++++++++++--------- src/client/game.cpp | 7 ++++-- src/client/luafunctions.cpp | 10 +++++++- src/client/protocolcodes.cpp | 4 ++++ src/client/protocolgameparse.cpp | 12 ++++++++-- src/client/thing.h | 4 ++++ src/client/thingtype.h | 8 +++++++ src/client/tile.cpp | 5 +++- 12 files changed, 143 insertions(+), 23 deletions(-) diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index 29c6de1f..0fe7fee5 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -78,6 +78,11 @@ function resetSkillColor(id) widget:setColor('#bbbbbb') end +function toggleSkill(id, state) + local skill = skillsWindow:recursiveGetChildById(id) + skill:setVisible(state) +end + function setSkillBase(id, value, baseValue) if baseValue <= 0 or value < 0 then return @@ -118,10 +123,12 @@ end function setSkillPercent(id, percent, tooltip) local skill = skillsWindow:recursiveGetChildById(id) local widget = skill:getChildById('percent') - widget:setPercent(math.floor(percent)) + if widget then + widget:setPercent(math.floor(percent)) - if tooltip then - widget:setTooltip(tooltip) + if tooltip then + widget:setTooltip(tooltip) + end end end @@ -204,16 +211,25 @@ function refresh() onRegenerationChange(player, player:getRegenerationTime()) onSpeedChange(player, player:getSpeed()) - for i=0,6 do + local hasAdditionalSkills = g_game.getFeature(GameAdditionalSkills) + for i = Skill.Fist, Skill.ManaLeechAmount do onSkillChange(player, i, player:getSkillLevel(i), player:getSkillLevelPercent(i)) onBaseSkillChange(player, i, player:getSkillBaseLevel(i)) + + if i > Skill.Fishing then + toggleSkill('skillId'..i, hasAdditionalSkills) + end end update() local contentsPanel = skillsWindow:getChildById('contentsPanel') skillsWindow:setContentMinimumHeight(44) - skillsWindow:setContentMaximumHeight(390) + if hasAdditionalSkills then + skillsWindow:setContentMaximumHeight(480) + else + skillsWindow:setContentMaximumHeight(390) + end end function offline() diff --git a/modules/game_skills/skills.otui b/modules/game_skills/skills.otui index 30fb3f2d..7a13f2c7 100644 --- a/modules/game_skills/skills.otui +++ b/modules/game_skills/skills.otui @@ -5,6 +5,9 @@ SkillButton < UIButton margin-bottom: 2 &onClick: onSkillButtonClick +SmallSkillButton < SkillButton + height: 14 + SkillNameLabel < GameLabel font: verdana-11px-monochrome anchors.left: parent.left @@ -170,3 +173,39 @@ MiniWindow !text: tr('Fishing') SkillValueLabel SkillPercentPanel + + SmallSkillButton + id: skillId7 + SkillNameLabel + !text: tr('Critical Hit Chance') + SkillValueLabel + + SmallSkillButton + id: skillId8 + SkillNameLabel + !text: tr('Critical Hit Damage') + SkillValueLabel + + SmallSkillButton + id: skillId9 + SkillNameLabel + !text: tr('Life Leech Chance') + SkillValueLabel + + SmallSkillButton + id: skillId10 + SkillNameLabel + !text: tr('Life Leech Amount') + SkillValueLabel + + SmallSkillButton + id: skillId11 + SkillNameLabel + !text: tr('Life Leech Chance') + SkillValueLabel + + SmallSkillButton + id: skillId12 + SkillNameLabel + !text: tr('Life Leech Amount') + SkillValueLabel diff --git a/modules/gamelib/const.lua b/modules/gamelib/const.lua index 33003a38..b8d42196 100644 --- a/modules/gamelib/const.lua +++ b/modules/gamelib/const.lua @@ -45,6 +45,22 @@ Directions = { NorthWest = 7 } +Skill = { + Fist = 0, + Club = 1, + Sword = 2, + Axe = 3, + Distance = 4, + Shielding = 5, + Fishing = 6, + CriticalChance = 7, + CriticalDamage = 8, + LifeLeechChance = 9, + LifeLeechAmount = 10, + ManaLeechChance = 11, + ManaLeechAmount = 12 +} + North = Directions.North East = Directions.East South = Directions.South @@ -134,6 +150,9 @@ GameDeathType = 70 GameIdleAnimations = 71 GameKeepUnawareTiles = 72 GameIngameStore = 73 +GameIngameStoreHighlights = 74 +GameIngameStoreServiceType = 75 +GameAdditionalSkills = 76 TextColors = { red = '#f55e5e', --'#c83200' diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index 09d0cee9..c2489996 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -75,7 +75,7 @@ function g_game.getSupportedClients() 1063, 1064, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1080, 1081, 1082, 1090, 1091, 1092, - 1093 + 1093, 1094, 1095 } end diff --git a/src/client/const.h b/src/client/const.h index adcc67ba..fa4a0958 100644 --- a/src/client/const.h +++ b/src/client/const.h @@ -148,6 +148,12 @@ namespace Otc Distance, Shielding, Fishing, + CriticalChance, + CriticalDamage, + LifeLeechChance, + LifeLeechAmount, + ManaLeechChance, + ManaLeechAmount, LastSkill }; @@ -318,19 +324,20 @@ namespace Otc MessageTutorialHint = 38, MessageThankyou = 39, MessageMarket = 40, - MessageBeyondLast = 41, + MessageMana = 41, + MessageBeyondLast = 42, // deprecated - MessageMonsterYell = 42, - MessageMonsterSay = 43, - MessageRed = 44, - MessageBlue = 45, - MessageRVRChannel = 46, - MessageRVRAnswer = 47, - MessageRVRContinue = 48, - MessageGameHighlight = 49, - MessageNpcFromStartBlock = 50, - LastMessage = 51, + MessageMonsterYell = 43, + MessageMonsterSay = 44, + MessageRed = 45, + MessageBlue = 46, + MessageRVRChannel = 47, + MessageRVRAnswer = 48, + MessageRVRContinue = 49, + MessageGameHighlight = 50, + MessageNpcFromStartBlock = 51, + LastMessage = 52, MessageInvalid = 255 }; @@ -408,6 +415,7 @@ namespace Otc GameIngameStore = 73, GameIngameStoreHighlights = 74, GameIngameStoreServiceType = 75, + GameAdditionalSkills = 76, LastGameFeature = 101 }; diff --git a/src/client/game.cpp b/src/client/game.cpp index 2f8755f2..03705f70 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1492,7 +1492,7 @@ void Game::setProtocolVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change protocol version while online"); - if(version != 0 && (version < 740 || version > 1093)) + if(version != 0 && (version < 740 || version > 1095)) stdext::throw_exception(stdext::format("Protocol version %d not supported", version)); m_protocolVersion = version; @@ -1510,7 +1510,7 @@ void Game::setClientVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change client version while online"); - if(version != 0 && (version < 740 || version > 1093)) + if(version != 0 && (version < 740 || version > 1095)) stdext::throw_exception(stdext::format("Client version %d not supported", version)); m_features.reset(); @@ -1674,6 +1674,9 @@ void Game::setClientVersion(int version) enableFeature(Otc::GameIngameStoreHighlights); } + if(version >= 1094) { + enableFeature(Otc::GameAdditionalSkills); + } m_clientVersion = version; diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 9ab60e18..32a41a7c 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -387,9 +387,13 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("isTranslucent", &Thing::isTranslucent); g_lua.bindClassMemberFunction("isFullGround", &Thing::isFullGround); g_lua.bindClassMemberFunction("isMarketable", &Thing::isMarketable); + g_lua.bindClassMemberFunction("getMarketData", &Thing::getMarketData); + g_lua.bindClassMemberFunction("isUsable", &Thing::isUsable); + g_lua.bindClassMemberFunction("isWrapable", &Thing::isWrapable); + g_lua.bindClassMemberFunction("isUnwrapable", &Thing::isUnwrapable); + g_lua.bindClassMemberFunction("isTopEffect", &Thing::isTopEffect); g_lua.bindClassMemberFunction("isLyingCorpse", &Thing::isLyingCorpse); g_lua.bindClassMemberFunction("getParentContainer", &Thing::getParentContainer); - g_lua.bindClassMemberFunction("getMarketData", &Thing::getMarketData); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return HousePtr(new House); }); @@ -541,6 +545,10 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("isCloth", &ThingType::isCloth); g_lua.bindClassMemberFunction("isMarketable", &ThingType::isMarketable); g_lua.bindClassMemberFunction("getMarketData", &ThingType::getMarketData); + g_lua.bindClassMemberFunction("isUsable", &ThingType::isUsable); + g_lua.bindClassMemberFunction("isWrapable", &ThingType::isWrapable); + g_lua.bindClassMemberFunction("isUnwrapable", &ThingType::isUnwrapable); + g_lua.bindClassMemberFunction("isTopEffect", &ThingType::isTopEffect); g_lua.bindClassMemberFunction("getSprites", &ThingType::getSprites); g_lua.bindClassMemberFunction("hasAttribute", &ThingType::hasAttr); g_lua.bindClassMemberFunction("exportImage", &ThingType::exportImage); diff --git a/src/client/protocolcodes.cpp b/src/client/protocolcodes.cpp index 6e80b4e2..f053ab6c 100644 --- a/src/client/protocolcodes.cpp +++ b/src/client/protocolcodes.cpp @@ -29,6 +29,10 @@ std::map messageModesMap; void buildMessageModesMap(int version) { messageModesMap.clear(); + if(version >= 1094) { + messageModesMap[Otc::MessageMana] = 43; + } + if(version >= 1055) { // might be 1054 messageModesMap[Otc::MessageNone] = 0; messageModesMap[Otc::MessageSay] = 1; diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 6f1cade0..04e39ae9 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -1376,7 +1376,11 @@ void ProtocolGame::parsePlayerStats(const InputMessagePtr& msg) void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg) { - for(int skill = 0; skill < Otc::LastSkill; skill++) { + int lastSkill = Otc::Fishing + 1; + if(g_game.getFeature(Otc::GameAdditionalSkills)) + lastSkill = Otc::LastSkill; + + for(int skill = 0; skill < lastSkill; skill++) { int level; if(g_game.getFeature(Otc::GameDoubleSkills)) @@ -1393,7 +1397,10 @@ void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg) else baseLevel = level; - int levelPercent = msg->getU8(); + int levelPercent = 0; + // Critical, Life Leech and Mana Leech have no level percent + if(skill <= Otc::Fishing) + levelPercent = msg->getU8(); m_localPlayer->setSkill((Otc::Skill)skill, level, levelPercent); m_localPlayer->setBaseSkill((Otc::Skill)skill, baseLevel); @@ -1635,6 +1642,7 @@ void ProtocolGame::parseTextMessage(const InputMessagePtr& msg) break; } case Otc::MessageHeal: + case Otc::MessageMana: case Otc::MessageExp: case Otc::MessageHealOthers: case Otc::MessageExpOthers: { diff --git a/src/client/thing.h b/src/client/thing.h index 122e987c..5810deab 100644 --- a/src/client/thing.h +++ b/src/client/thing.h @@ -117,6 +117,10 @@ public: bool isIgnoreLook() { return rawGetThingType()->isIgnoreLook(); } bool isCloth() { return rawGetThingType()->isCloth(); } bool isMarketable() { return rawGetThingType()->isMarketable(); } + bool isUsable() { return rawGetThingType()->isUsable(); } + bool isWrapable() { return rawGetThingType()->isWrapable(); } + bool isUnwrapable() { return rawGetThingType()->isUnwrapable(); } + bool isTopEffect() { return rawGetThingType()->isTopEffect(); } MarketData getMarketData() { return rawGetThingType()->getMarketData(); } virtual void onPositionChange(const Position& newPos, const Position& oldPos) { } diff --git a/src/client/thingtype.h b/src/client/thingtype.h index f3404483..1f4f72f4 100644 --- a/src/client/thingtype.h +++ b/src/client/thingtype.h @@ -84,6 +84,9 @@ enum ThingAttr : uint8 { ThingAttrCloth = 32, ThingAttrMarket = 33, ThingAttrUsable = 34, + ThingAttrWrapable = 35, + ThingAttrUnwrapable = 36, + ThingAttrTopEffect = 37, // additional ThingAttrOpacity = 100, @@ -193,6 +196,11 @@ public: bool isIgnoreLook() { return m_attribs.has(ThingAttrLook); } bool isCloth() { return m_attribs.has(ThingAttrCloth); } bool isMarketable() { return m_attribs.has(ThingAttrMarket); } + bool isUsable() { return m_attribs.has(ThingAttrUsable); } + bool isWrapable() { return m_attribs.has(ThingAttrWrapable); } + bool isUnwrapable() { return m_attribs.has(ThingAttrUnwrapable); } + bool isTopEffect() { return m_attribs.has(ThingAttrTopEffect); } + std::vector getSprites() { return m_spritesIndex; } // additional diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 0ba698eb..570f4672 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -195,7 +195,10 @@ void Tile::addThing(const ThingPtr& thing, int stackPos) return; if(thing->isEffect()) { - m_effects.push_back(thing->static_self_cast()); + if(thing->isTopEffect()) + m_effects.insert(m_effects.begin(), thing->static_self_cast()); + else + m_effects.push_back(thing->static_self_cast()); } else { // priority 854 // 0 - ground, --> -->