diff --git a/modules/core_lib/core_lib.otmod b/modules/core_lib/core_lib.otmod index e6912f20..96b319c2 100644 --- a/modules/core_lib/core_lib.otmod +++ b/modules/core_lib/core_lib.otmod @@ -7,6 +7,7 @@ Module onLoad: | require 'ext/table' require 'ext/string' + require 'ext/os' require 'math/point' require 'math/size' require 'math/color' diff --git a/modules/core_lib/ext/os.lua b/modules/core_lib/ext/os.lua new file mode 100644 index 00000000..f7041281 --- /dev/null +++ b/modules/core_lib/ext/os.lua @@ -0,0 +1,6 @@ +function os.execute(command) + local f = assert(io.popen(command, 'r')) + local data = assert(f:read('*a')) + f:close() + print(data) +end diff --git a/modules/core_lib/mouse.lua b/modules/core_lib/mouse.lua new file mode 100644 index 00000000..602f9472 --- /dev/null +++ b/modules/core_lib/mouse.lua @@ -0,0 +1,2 @@ +Mouse = {} + diff --git a/modules/game_textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua index 26d786e6..707c5745 100644 --- a/modules/game_textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -5,54 +5,95 @@ importStyle 'textmessage.otui' -- private variables local bottomLabelWidget, centerLabelWidget -local messageTypes = { - first = 12, - { msgtype = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, - { msgtype = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, - { msgtype = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, - { msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, - { msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, - { msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, - { msgtype = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, - { msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' }, - { msgtype = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false }, - { msgtype = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false } + +local MessageTypes = { + warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, + eventAdvance = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, + eventDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, + statusDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, + infoDesc = { color = '#00EB00', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, + statusSmall = { color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' }, + consoleOrange = { color = '#FE6500', showOnConsole = true, showOnWindow = false }, + consoleBlue = { color = '#9F9DFD', showOnConsole = true, showOnWindow = false }, + consoleRed = { color = '#F55E5E', showOnConsole = true, showOnWindow = false } } -local hideEvent --- public functions -function TextMessage.create() - bottomLabelWidget = createWidget('UILabel', Game.gameMapPanel) - centerLabelWidget = createWidget('UILabel', Game.gameMapPanel) -end +local MessageTypesMap = { + [12] = MessageTypes.consoleOrange, + [13] = MessageTypes.consoleOrange, + [14] = MessageTypes.warning, + [15] = MessageTypes.eventAdvance, + [15] = MessageTypes.eventDefault, + [16] = MessageTypes.statusDefault, + [17] = MessageTypes.infoDesc, + [18] = MessageTypes.statusSmall, + [19] = MessageTypes.consoleBlue, + [20] = MessageTypes.consoleRed, +--[[ + [18] = MessageTypes.consoleRed, + [19] = MessageTypes.consoleOrange, + [20] = MessageTypes.consoleOrange, + [21] = MessageTypes.warning, + [22] = MessageTypes.eventAdvance, + [23] = MessageTypes.eventDefault, + [24] = MessageTypes.statusDefault, + [25] = MessageTypes.infoDesc, + [26] = MessageTypes.statusSmall, + [27] = MessageTypes.consoleBlue +]]-- +} --- hooked events -function TextMessage.onTextMessage(msgtype, message) - local messageType = messageTypes[msgtype - messageTypes.first] +-- private variables +local bottomLabelHideEvent +local centerLabelHideEvent - if messageType.showOnConsole then +-- private functions +local function displayMessage(msgtype, msg) + if msgtype.showOnConsole then -- TODO end - if messageType.showOnWindow then + if msgtype.showOnWindow then local label - if messageType.windowLocation == 'BottomLabel' then + if msgtype.windowLocation == 'BottomLabel' then label = bottomLabelWidget - elseif messageType.windowLocation == 'CenterLabel' then + elseif msgtype.windowLocation == 'CenterLabel' then label = centerLabelWidget end label:setVisible(true) - label:setText(message) - label:setStyle(messageType.windowLocation) - label:setForegroundColor(messageType.color) - - time = #message * 75 - removeEvent(hideEvent) - hideEvent = scheduleEvent(function() - label:setVisible(false) - end, time) + label:setText(msg) + label:setStyle(msgtype.windowLocation) + label:setForegroundColor(msgtype.color) + + time = #msg * 75 + removeEvent(label.hideEvent) + label.hideEvent = scheduleEvent(function() label:setVisible(false) end, time) + end +end + +-- public functions +function TextMessage.create() + bottomLabelWidget = createWidget('UILabel', Game.gameMapPanel) + centerLabelWidget = createWidget('UILabel', Game.gameMapPanel) +end + +function TextMessage.displayWarning(msg) + TextMessage.display(MessageTypes.warning, msg) +end + +function TextMessage.display(msgtypeid, msg) + local msgtype = MessageTypesMap[msgtypeid] + if msgtype == nil then + error('unknown text msg type ' .. msgtypeid) + return end + displayMessage(msgtype, msg) +end + +-- hooked events +function TextMessage.onTextMessage(msgtypeid, msg) + TextMessage.display(msgtypeid, msg) end diff --git a/modules/otclientrc.lua b/modules/otclientrc.lua index 44b7eff8..26756756 100644 --- a/modules/otclientrc.lua +++ b/modules/otclientrc.lua @@ -2,10 +2,11 @@ -- you can place any custom user code here Hotkeys.bind('F1', function() Game.talk('exura gran') end) -Hotkeys.bind('F2', function() Game.talk('exori frigo') end) -Hotkeys.bind('F3', function() Game.talk('exevo flam hur') end) -Hotkeys.bind('F4', function() Game.talk('exevo pan') end) -Hotkeys.bind('F5', function() Game.talk('exani tera') end) +Hotkeys.bind('F2', function() Game.talk('exori mort') end) +Hotkeys.bind('F3', function() Game.talk('exori frigo') end) +Hotkeys.bind('F4', function() Game.talk('exevo vis hur') end) +Hotkeys.bind('F5', function() Game.talk('utani gran hur') end) +Hotkeys.bind('F6', function() Game.talk('exani tera') end) Hotkeys.bind('Ctrl+R', function() runscript('otclientrc.lua') end) if rcloaded then diff --git a/src/otclient/CMakeLists.txt b/src/otclient/CMakeLists.txt index 84aa7bb6..99e3b1cd 100644 --- a/src/otclient/CMakeLists.txt +++ b/src/otclient/CMakeLists.txt @@ -4,14 +4,16 @@ IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) # otclient options -OPTION(FORBIDDEN_FUNCTIONS "Enable forbidden lua functions" ON) +OPTION(NO_BOT_PROTECTION "Disables bot protection" OFF) +SET(PROTOCOL 862 CACHE "Protocol version" STRING) +ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL}) -IF(FORBIDDEN_FUNCTIONS) - ADD_DEFINITIONS(-DFORBIDDEN_FUNCTIONS) - MESSAGE(STATUS "Lua forbidden functions: ON") -ELSE(FORBIDDEN_FUNCTIONS) - MESSAGE(STATUS "Lua forbidden functions: OFF") -ENDIF(FORBIDDEN_FUNCTIONS) +IF(NO_BOT_PROTECTION) + ADD_DEFINITIONS(-DNO_BOT_PROTECTION) + MESSAGE(STATUS "Bot protection: OFF") +ELSE(NO_BOT_PROTECTION) + MESSAGE(STATUS "Bot protection: ON") +ENDIF(NO_BOT_PROTECTION) SET(otclient_SOURCES ${otclient_SOURCES} # otclient diff --git a/src/otclient/const.h b/src/otclient/const.h index 95b99423..ddfa587f 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -333,20 +333,30 @@ namespace Otc }; enum SpeakClasses { - SpeakSay = 0x01, //normal talk - SpeakWhisper = 0x02, //whispering - #w text - SpeakYell = 0x03, //yelling - #y text - SpeakPrivatePlayerToNpc = 0x04, //Player-to-NPC speaking(NPCs channel) - SpeakPrivateNpcToPlayer = 0x05, //NPC-to-Player speaking - SpeakPrivate = 0x06, //Players speaking privately to players - SpeakChannelYellow = 0x07, //Yellow message in chat - SpeakChannelWhite = 0x08, //White message in chat - SpeakBroadcast = 0x09, //Broadcast a message - #b - SpeakChannelRed = 0x0A, //Talk red on chat - #c - SpeakPrivateRed = 0x0B, //Red private - @name@ text - SpeakChannelOrange = 0x0C, //Talk orange on text - SpeakMonsterSay = 0x0D, //Talk orange - SpeakMonsterYell = 0x0E //Yell orange + SpeakSay = 1, //normal talk + SpeakWhisper, //whispering - #w text + SpeakYell, //yelling - #y text + SpeakPrivatePlayerToNpc, //Player-to-NPC speaking(NPCs channel) + SpeakPrivateNpcToPlayer, //NPC-to-Player speaking + SpeakPrivate, //Players speaking privately to players + SpeakChannelYellow, //Yellow message in chat + SpeakChannelWhite, //White message in chat +#if PROTOCOL==860 + SpeakReportChannel, //Reporting rule violation - Ctrl+R + SpeakReportAnswer, //Answering report + SpeakReportContinue, //Answering the answer of the report +#endif + SpeakBroadcast, //Broadcast a message - #b + SpeakChannelRed, //Talk red on chat - #c + SpeakPrivateRed, //Red private - @name@ text + SpeakChannelOrange, //Talk orange on text +#if PROTOCOL==860 + SpeakUnk1, + SpeakChannelRed2, //Talk red anonymously on chat - #d + SpeakUnk2, +#endif + SpeakMonsterSay, //Talk orange + SpeakMonsterYell //Yell orange }; enum CreaturesIdRange { diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 794c603f..50c744fa 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -322,7 +322,7 @@ void Game::removeVip(int playerId) bool Game::checkBotProtection() { -#ifndef DISABLE_BOT_PROTECTION +#ifndef NO_BOT_PROTECTION if(g_lua.isInCppCallback() && !g_ui.isOnInputEvent()) { logError("caught a lua call to a bot protected game function, the call was canceled"); return false; diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 1753d097..0fa32552 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -78,6 +78,7 @@ public: LocalPlayerPtr getLocalPlayer() { return m_localPlayer; } ProtocolGamePtr getProtocolGame() { return m_protocolGame; } + int getProtocolVersion() { return PROTOCOL; } private: LocalPlayerPtr m_localPlayer; diff --git a/src/otclient/core/map.cpp b/src/otclient/core/map.cpp index 6b66afab..b3260b25 100644 --- a/src/otclient/core/map.cpp +++ b/src/otclient/core/map.cpp @@ -286,10 +286,10 @@ ThingPtr Map::getThing(const Position& pos, int stackPos) return nullptr; } -void Map::removeThing(const Position& pos, int stackPos) +void Map::removeThingByPos(const Position& pos, int stackPos) { if(TilePtr& tile = m_tiles[pos]) - tile->removeThing(stackPos); + tile->removeThingByStackpos(stackPos); } void Map::removeThing(const ThingPtr& thing) diff --git a/src/otclient/core/map.h b/src/otclient/core/map.h index a2a38977..da9774b0 100644 --- a/src/otclient/core/map.h +++ b/src/otclient/core/map.h @@ -53,7 +53,7 @@ public: void addThing(const ThingPtr& thing, const Position& pos, int stackPos = -1); ThingPtr getThing(const Position& pos, int stackPos); - void removeThing(const Position& pos, int stackPos); + void removeThingByPos(const Position& pos, int stackPos); void removeThing(const ThingPtr& thing); void cleanTile(const Position& pos); TilePtr getTile(const Position& pos); diff --git a/src/otclient/core/statictext.cpp b/src/otclient/core/statictext.cpp index 1fe940fe..14a4b12c 100644 --- a/src/otclient/core/statictext.cpp +++ b/src/otclient/core/statictext.cpp @@ -107,7 +107,7 @@ void StaticText::compose() m_color = Color(95, 247, 247); } else { - logWarning("unknown message type: ", m_type); + logWarning("unknown speak type: ", m_type); } // Todo: add break lines diff --git a/src/otclient/core/tile.cpp b/src/otclient/core/tile.cpp index aa9586e8..a5ec02dc 100644 --- a/src/otclient/core/tile.cpp +++ b/src/otclient/core/tile.cpp @@ -149,7 +149,7 @@ ThingPtr Tile::getTopThing() return m_things[m_things.size() - 1]; } -ThingPtr Tile::removeThing(int stackPos) +ThingPtr Tile::removeThingByStackpos(int stackPos) { ThingPtr oldObject; if(stackPos >= 0 && stackPos < (int)m_things.size()) { diff --git a/src/otclient/core/tile.h b/src/otclient/core/tile.h index 51aa1123..817907c6 100644 --- a/src/otclient/core/tile.h +++ b/src/otclient/core/tile.h @@ -41,7 +41,7 @@ public: ThingPtr getThing(int stackPos); int getThingStackpos(const ThingPtr& thing); ThingPtr getTopThing(); - ThingPtr removeThing(int stackPos); + ThingPtr removeThingByStackpos(int stackPos); ThingPtr removeThing(const ThingPtr& thing); diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index f3554b6b..abd13dc0 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -26,6 +26,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -54,6 +58,27 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("g_sprites", "isLoaded", std::bind(&SpriteManager::isLoaded, &g_sprites)); g_lua.bindClassStaticFunction("g_sprites", "getSignature", std::bind(&SpriteManager::getSignature, &g_sprites)); + g_lua.registerStaticClass("g_map"); + g_lua.bindClassStaticFunction("g_map", "getFirstVisibleFloor", std::bind(&Map::getFirstVisibleFloor, &g_map)); + g_lua.bindClassStaticFunction("g_map", "isLookPossible", std::bind(&Map::isLookPossible, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "isCovered", std::bind(&Map::isCovered, &g_map, _1, _2)); + g_lua.bindClassStaticFunction("g_map", "isCompletlyCovered", std::bind(&Map::isCompletlyCovered, &g_map, _1, _2)); + g_lua.bindClassStaticFunction("g_map", "addThing", std::bind(&Map::addThing, &g_map, _1, _2, _3)); + g_lua.bindClassStaticFunction("g_map", "getThing", std::bind(&Map::getThing, &g_map, _1, _2)); + g_lua.bindClassStaticFunction("g_map", "removeThingByPos", std::bind(&Map::removeThingByPos, &g_map, _1, _2)); + g_lua.bindClassStaticFunction("g_map", "removeThing", std::bind(&Map::removeThing, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "cleanTile", std::bind(&Map::cleanTile, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "getTile", std::bind(&Map::getTile, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "setCentralPosition", std::bind(&Map::setCentralPosition, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "getCentralPosition", std::bind(&Map::getCentralPosition, &g_map)); + g_lua.bindClassStaticFunction("g_map", "addCreature", std::bind(&Map::addCreature, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "getCreatureById", std::bind(&Map::getCreatureById, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "removeCreatureById", std::bind(&Map::removeCreatureById, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "setVisibleSize", std::bind(&Map::setVisibleSize, &g_map, _1)); + g_lua.bindClassStaticFunction("g_map", "getVibibleSize", std::bind(&Map::getVibibleSize, &g_map)); + g_lua.bindClassStaticFunction("g_map", "getCentralOffset", std::bind(&Map::getCentralOffset, &g_map)); + g_lua.bindClassStaticFunction("g_map", "positionTo2D", std::bind(&Map::positionTo2D, &g_map, _1)); + g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor); g_lua.registerClass(); @@ -64,16 +89,36 @@ void OTClient::registerLuaFunctions() g_lua.registerClass(); g_lua.registerClass(); + g_lua.bindClassMemberFunction("setId", &Thing::setId); + g_lua.bindClassMemberFunction("setPos", &Thing::setPos); g_lua.bindClassMemberFunction("getId", &Thing::getId); - g_lua.bindClassMemberFunction("getType", &Thing::getType); + g_lua.bindClassMemberFunction("getPos", &Thing::getPos); + g_lua.bindClassMemberFunction("getStackPriority", &Thing::getStackPriority); + g_lua.bindClassMemberFunction("getAnimationPhases", &Thing::getAnimationPhases); + g_lua.bindClassMemberFunction("setXPattern", &Thing::setXPattern); + g_lua.bindClassMemberFunction("setYPattern", &Thing::setYPattern); + g_lua.bindClassMemberFunction("setZPattern", &Thing::setZPattern); + g_lua.bindClassMemberFunction("asThing", &Thing::asThing); + g_lua.bindClassMemberFunction("asItem", &Thing::asItem); + g_lua.bindClassMemberFunction("asCreature", &Thing::asCreature); + g_lua.bindClassMemberFunction("asEffect", &Thing::asEffect); + g_lua.bindClassMemberFunction("asMissile", &Thing::asMissile); + g_lua.bindClassMemberFunction("asPlayer", &Thing::asPlayer); + g_lua.bindClassMemberFunction("asLocalPlayer", &Thing::asLocalPlayer); + g_lua.bindClassMemberFunction("asAnimatedText", &Thing::asAnimatedText); + g_lua.bindClassMemberFunction("asStaticText", &Thing::asStaticText); + g_lua.bindClassMemberFunction("isGround", &Thing::isGround); + g_lua.bindClassMemberFunction("isGroundBorder", &Thing::isGroundBorder); + g_lua.bindClassMemberFunction("isOnBottom", &Thing::isOnBottom); + g_lua.bindClassMemberFunction("isOnTop", &Thing::isOnTop); g_lua.bindClassMemberFunction("isContainer", &Thing::isContainer); + g_lua.bindClassMemberFunction("isForceUse", &Thing::isForceUse); g_lua.bindClassMemberFunction("isMultiUse", &Thing::isMultiUse); g_lua.bindClassMemberFunction("isRotateable", &Thing::isRotateable); g_lua.bindClassMemberFunction("isNotMoveable", &Thing::isNotMoveable); g_lua.bindClassMemberFunction("isPickupable", &Thing::isPickupable); - g_lua.bindClassMemberFunction("asCreature", &Thing::asCreature); - g_lua.bindClassMemberFunction("asPlayer", &Thing::asPlayer); - g_lua.bindClassMemberFunction("asLocalPlayer", &Thing::asLocalPlayer); + g_lua.bindClassMemberFunction("ignoreLook", &Thing::ignoreLook); + g_lua.bindClassMemberFunction("isStackable", &Thing::isStackable); g_lua.registerClass(); g_lua.bindClassMemberFunction("getName", &Creature::getName); @@ -85,12 +130,40 @@ void OTClient::registerLuaFunctions() g_lua.registerClass(); + g_lua.registerClass(); + g_lua.registerClass(); + g_lua.registerClass(); + g_lua.registerClass(); + g_lua.registerClass(); g_lua.bindClassMemberFunction("getAttackingCreature", &LocalPlayer::getAttackingCreature); g_lua.bindClassMemberFunction("getFollowingCreature", &LocalPlayer::getFollowingCreature); g_lua.registerClass(); + g_lua.registerClass(); + g_lua.bindClassMemberFunction("clean", &Tile::clean); + g_lua.bindClassMemberFunction("addThing", &Tile::addThing); + g_lua.bindClassMemberFunction("getThing", &Tile::getThing); + g_lua.bindClassMemberFunction("getThingStackpos", &Tile::getThingStackpos); + g_lua.bindClassMemberFunction("getTopThing", &Tile::getTopThing); + g_lua.bindClassMemberFunction("removeThingByStackpos", &Tile::removeThingByStackpos); + g_lua.bindClassMemberFunction("removeThing", &Tile::removeThing); + g_lua.bindClassMemberFunction("getTopLookThing", &Tile::getTopLookThing); + g_lua.bindClassMemberFunction("getTopUseThing", &Tile::getTopUseThing); + g_lua.bindClassMemberFunction("getTopCreature", &Tile::getTopCreature); + g_lua.bindClassMemberFunction("getPos", &Tile::getPos); + g_lua.bindClassMemberFunction("getDrawElevation", &Tile::getDrawElevation); + g_lua.bindClassMemberFunction("getCreatures", &Tile::getCreatures); + g_lua.bindClassMemberFunction("getGround", &Tile::getGround); + g_lua.bindClassMemberFunction("isWalkable", &Tile::isWalkable); + g_lua.bindClassMemberFunction("isFullGround", &Tile::isFullGround); + g_lua.bindClassMemberFunction("isFullyOpaque", &Tile::isFullyOpaque); + g_lua.bindClassMemberFunction("isLookPossible", &Tile::isLookPossible); + g_lua.bindClassMemberFunction("hasCreature", &Tile::hasCreature); + g_lua.bindClassMemberFunction("isEmpty", &Tile::isEmpty); + g_lua.bindClassMemberFunction("isClickable", &Tile::isClickable); + g_lua.registerClass(); g_lua.registerClass(); @@ -114,6 +187,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("talkChannel", std::bind(&Game::talkChannel, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game)); + g_lua.bindClassStaticFunction("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game)); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIItemPtr(new UIItem); } ); diff --git a/src/otclient/luascript/luavaluecasts.cpp b/src/otclient/luascript/luavaluecasts.cpp index 256d1a17..a82d49d9 100644 --- a/src/otclient/luascript/luavaluecasts.cpp +++ b/src/otclient/luascript/luavaluecasts.cpp @@ -80,6 +80,7 @@ bool luavalue_cast(int index, Position& pos) pos.y = g_lua.popInteger(); g_lua.getField("z", index); pos.z = g_lua.popInteger(); + return true; } return false; } diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index 6ee87420..6a1f3c8f 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -353,8 +353,6 @@ void ProtocolGame::parseMoveWest(InputMessage& msg) void ProtocolGame::parseUpdateTile(InputMessage& msg) { - logDebug("PARSE UPDATE TILE!"); - Position tilePos = parsePosition(msg); uint16 thingId = msg.getU16(true); if(thingId == 0xFF01) { @@ -390,7 +388,7 @@ void ProtocolGame::parseTileTransformThing(InputMessage& msg) } else { ThingPtr thing = internalGetItem(msg, thingId); - g_map.removeThing(pos, stackPos); + g_map.removeThingByPos(pos, stackPos); g_map.addThing(thing, pos, stackPos); } } @@ -400,7 +398,7 @@ void ProtocolGame::parseTileRemoveThing(InputMessage& msg) Position pos = parsePosition(msg); uint8 stackPos = msg.getU8(); - g_map.removeThing(pos, stackPos); + g_map.removeThingByPos(pos, stackPos); } void ProtocolGame::parseCreatureMove(InputMessage& msg) @@ -756,10 +754,13 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg) case Otc::SpeakPrivateNpcToPlayer: creaturePos = parsePosition(msg); break; - case Otc::SpeakChannelRed: - case Otc::SpeakChannelOrange: case Otc::SpeakChannelYellow: case Otc::SpeakChannelWhite: + case Otc::SpeakChannelRed: +#if PROTOCOL==860 + case Otc::SpeakChannelRed2: +#endif + case Otc::SpeakChannelOrange: channelId = msg.getU16(); break; case Otc::SpeakPrivate: @@ -767,6 +768,11 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg) case Otc::SpeakBroadcast: case Otc::SpeakPrivateRed: break; +#if PROTOCOL==860 + case Otc::SpeakReportChannel: + msg.getU32(); + break; +#endif default: logTraceError("unknown speak type ", type); break;