changes to wotk with protocol 860

This commit is contained in:
Eduardo Bart 2012-01-08 13:42:23 -02:00
parent d04596c5fd
commit fbaa7c8c43
17 changed files with 226 additions and 81 deletions

View File

@ -7,6 +7,7 @@ Module
onLoad: | onLoad: |
require 'ext/table' require 'ext/table'
require 'ext/string' require 'ext/string'
require 'ext/os'
require 'math/point' require 'math/point'
require 'math/size' require 'math/size'
require 'math/color' require 'math/color'

View File

@ -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

View File

@ -0,0 +1,2 @@
Mouse = {}

View File

@ -5,20 +5,72 @@ importStyle 'textmessage.otui'
-- private variables -- private variables
local bottomLabelWidget, centerLabelWidget local bottomLabelWidget, centerLabelWidget
local messageTypes = {
first = 12, local MessageTypes = {
{ msgtype = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ msgtype = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, eventAdvance = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ msgtype = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, eventDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, statusDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, infoDesc = { color = '#00EB00', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, statusSmall = { color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' },
{ msgtype = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, consoleOrange = { color = '#FE6500', showOnConsole = true, showOnWindow = false },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' }, consoleBlue = { color = '#9F9DFD', showOnConsole = true, showOnWindow = false },
{ msgtype = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false }, consoleRed = { color = '#F55E5E', showOnConsole = true, showOnWindow = false }
{ msgtype = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false }
} }
local hideEvent
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
]]--
}
-- private variables
local bottomLabelHideEvent
local centerLabelHideEvent
-- private functions
local function displayMessage(msgtype, msg)
if msgtype.showOnConsole then
-- TODO
end
if msgtype.showOnWindow then
local label
if msgtype.windowLocation == 'BottomLabel' then
label = bottomLabelWidget
elseif msgtype.windowLocation == 'CenterLabel' then
label = centerLabelWidget
end
label:setVisible(true)
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 -- public functions
function TextMessage.create() function TextMessage.create()
@ -26,33 +78,22 @@ function TextMessage.create()
centerLabelWidget = createWidget('UILabel', Game.gameMapPanel) centerLabelWidget = createWidget('UILabel', Game.gameMapPanel)
end 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 -- hooked events
function TextMessage.onTextMessage(msgtype, message) function TextMessage.onTextMessage(msgtypeid, msg)
local messageType = messageTypes[msgtype - messageTypes.first] TextMessage.display(msgtypeid, msg)
if messageType.showOnConsole then
-- TODO
end
if messageType.showOnWindow then
local label
if messageType.windowLocation == 'BottomLabel' then
label = bottomLabelWidget
elseif messageType.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)
end
end end

View File

@ -2,10 +2,11 @@
-- you can place any custom user code here -- you can place any custom user code here
Hotkeys.bind('F1', function() Game.talk('exura gran') end) Hotkeys.bind('F1', function() Game.talk('exura gran') end)
Hotkeys.bind('F2', function() Game.talk('exori frigo') end) Hotkeys.bind('F2', function() Game.talk('exori mort') end)
Hotkeys.bind('F3', function() Game.talk('exevo flam hur') end) Hotkeys.bind('F3', function() Game.talk('exori frigo') end)
Hotkeys.bind('F4', function() Game.talk('exevo pan') end) Hotkeys.bind('F4', function() Game.talk('exevo vis hur') end)
Hotkeys.bind('F5', function() Game.talk('exani tera') 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) Hotkeys.bind('Ctrl+R', function() runscript('otclientrc.lua') end)
if rcloaded then if rcloaded then

View File

@ -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) ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
# otclient options # 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) IF(NO_BOT_PROTECTION)
ADD_DEFINITIONS(-DFORBIDDEN_FUNCTIONS) ADD_DEFINITIONS(-DNO_BOT_PROTECTION)
MESSAGE(STATUS "Lua forbidden functions: ON") MESSAGE(STATUS "Bot protection: OFF")
ELSE(FORBIDDEN_FUNCTIONS) ELSE(NO_BOT_PROTECTION)
MESSAGE(STATUS "Lua forbidden functions: OFF") MESSAGE(STATUS "Bot protection: ON")
ENDIF(FORBIDDEN_FUNCTIONS) ENDIF(NO_BOT_PROTECTION)
SET(otclient_SOURCES ${otclient_SOURCES} SET(otclient_SOURCES ${otclient_SOURCES}
# otclient # otclient

View File

@ -333,20 +333,30 @@ namespace Otc
}; };
enum SpeakClasses { enum SpeakClasses {
SpeakSay = 0x01, //normal talk SpeakSay = 1, //normal talk
SpeakWhisper = 0x02, //whispering - #w text SpeakWhisper, //whispering - #w text
SpeakYell = 0x03, //yelling - #y text SpeakYell, //yelling - #y text
SpeakPrivatePlayerToNpc = 0x04, //Player-to-NPC speaking(NPCs channel) SpeakPrivatePlayerToNpc, //Player-to-NPC speaking(NPCs channel)
SpeakPrivateNpcToPlayer = 0x05, //NPC-to-Player speaking SpeakPrivateNpcToPlayer, //NPC-to-Player speaking
SpeakPrivate = 0x06, //Players speaking privately to players SpeakPrivate, //Players speaking privately to players
SpeakChannelYellow = 0x07, //Yellow message in chat SpeakChannelYellow, //Yellow message in chat
SpeakChannelWhite = 0x08, //White message in chat SpeakChannelWhite, //White message in chat
SpeakBroadcast = 0x09, //Broadcast a message - #b #if PROTOCOL==860
SpeakChannelRed = 0x0A, //Talk red on chat - #c SpeakReportChannel, //Reporting rule violation - Ctrl+R
SpeakPrivateRed = 0x0B, //Red private - @name@ text SpeakReportAnswer, //Answering report
SpeakChannelOrange = 0x0C, //Talk orange on text SpeakReportContinue, //Answering the answer of the report
SpeakMonsterSay = 0x0D, //Talk orange #endif
SpeakMonsterYell = 0x0E //Yell orange 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 { enum CreaturesIdRange {

View File

@ -322,7 +322,7 @@ void Game::removeVip(int playerId)
bool Game::checkBotProtection() bool Game::checkBotProtection()
{ {
#ifndef DISABLE_BOT_PROTECTION #ifndef NO_BOT_PROTECTION
if(g_lua.isInCppCallback() && !g_ui.isOnInputEvent()) { if(g_lua.isInCppCallback() && !g_ui.isOnInputEvent()) {
logError("caught a lua call to a bot protected game function, the call was canceled"); logError("caught a lua call to a bot protected game function, the call was canceled");
return false; return false;

View File

@ -78,6 +78,7 @@ public:
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; } LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
ProtocolGamePtr getProtocolGame() { return m_protocolGame; } ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
int getProtocolVersion() { return PROTOCOL; }
private: private:
LocalPlayerPtr m_localPlayer; LocalPlayerPtr m_localPlayer;

View File

@ -286,10 +286,10 @@ ThingPtr Map::getThing(const Position& pos, int stackPos)
return nullptr; return nullptr;
} }
void Map::removeThing(const Position& pos, int stackPos) void Map::removeThingByPos(const Position& pos, int stackPos)
{ {
if(TilePtr& tile = m_tiles[pos]) if(TilePtr& tile = m_tiles[pos])
tile->removeThing(stackPos); tile->removeThingByStackpos(stackPos);
} }
void Map::removeThing(const ThingPtr& thing) void Map::removeThing(const ThingPtr& thing)

View File

@ -53,7 +53,7 @@ public:
void addThing(const ThingPtr& thing, const Position& pos, int stackPos = -1); void addThing(const ThingPtr& thing, const Position& pos, int stackPos = -1);
ThingPtr getThing(const Position& pos, int stackPos); 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 removeThing(const ThingPtr& thing);
void cleanTile(const Position& pos); void cleanTile(const Position& pos);
TilePtr getTile(const Position& pos); TilePtr getTile(const Position& pos);

View File

@ -107,7 +107,7 @@ void StaticText::compose()
m_color = Color(95, 247, 247); m_color = Color(95, 247, 247);
} }
else { else {
logWarning("unknown message type: ", m_type); logWarning("unknown speak type: ", m_type);
} }
// Todo: add break lines // Todo: add break lines

View File

@ -149,7 +149,7 @@ ThingPtr Tile::getTopThing()
return m_things[m_things.size() - 1]; return m_things[m_things.size() - 1];
} }
ThingPtr Tile::removeThing(int stackPos) ThingPtr Tile::removeThingByStackpos(int stackPos)
{ {
ThingPtr oldObject; ThingPtr oldObject;
if(stackPos >= 0 && stackPos < (int)m_things.size()) { if(stackPos >= 0 && stackPos < (int)m_things.size()) {

View File

@ -41,7 +41,7 @@ public:
ThingPtr getThing(int stackPos); ThingPtr getThing(int stackPos);
int getThingStackpos(const ThingPtr& thing); int getThingStackpos(const ThingPtr& thing);
ThingPtr getTopThing(); ThingPtr getTopThing();
ThingPtr removeThing(int stackPos); ThingPtr removeThingByStackpos(int stackPos);
ThingPtr removeThing(const ThingPtr& thing); ThingPtr removeThing(const ThingPtr& thing);

View File

@ -26,6 +26,10 @@
#include <otclient/core/game.h> #include <otclient/core/game.h>
#include <otclient/core/tile.h> #include <otclient/core/tile.h>
#include <otclient/core/item.h> #include <otclient/core/item.h>
#include <otclient/core/effect.h>
#include <otclient/core/missile.h>
#include <otclient/core/statictext.h>
#include <otclient/core/animatedtext.h>
#include <otclient/core/creature.h> #include <otclient/core/creature.h>
#include <otclient/core/player.h> #include <otclient/core/player.h>
#include <otclient/core/localplayer.h> #include <otclient/core/localplayer.h>
@ -54,6 +58,27 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_sprites", "isLoaded", std::bind(&SpriteManager::isLoaded, &g_sprites)); 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.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.bindGlobalFunction("getOufitColor", Outfit::getColor);
g_lua.registerClass<ProtocolLogin, Protocol>(); g_lua.registerClass<ProtocolLogin, Protocol>();
@ -64,16 +89,36 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<ProtocolGame, Protocol>(); g_lua.registerClass<ProtocolGame, Protocol>();
g_lua.registerClass<Thing>(); g_lua.registerClass<Thing>();
g_lua.bindClassMemberFunction<Thing>("setId", &Thing::setId);
g_lua.bindClassMemberFunction<Thing>("setPos", &Thing::setPos);
g_lua.bindClassMemberFunction<Thing>("getId", &Thing::getId); g_lua.bindClassMemberFunction<Thing>("getId", &Thing::getId);
g_lua.bindClassMemberFunction<Thing>("getType", &Thing::getType); g_lua.bindClassMemberFunction<Thing>("getPos", &Thing::getPos);
g_lua.bindClassMemberFunction<Thing>("getStackPriority", &Thing::getStackPriority);
g_lua.bindClassMemberFunction<Thing>("getAnimationPhases", &Thing::getAnimationPhases);
g_lua.bindClassMemberFunction<Thing>("setXPattern", &Thing::setXPattern);
g_lua.bindClassMemberFunction<Thing>("setYPattern", &Thing::setYPattern);
g_lua.bindClassMemberFunction<Thing>("setZPattern", &Thing::setZPattern);
g_lua.bindClassMemberFunction<Thing>("asThing", &Thing::asThing);
g_lua.bindClassMemberFunction<Thing>("asItem", &Thing::asItem);
g_lua.bindClassMemberFunction<Thing>("asCreature", &Thing::asCreature);
g_lua.bindClassMemberFunction<Thing>("asEffect", &Thing::asEffect);
g_lua.bindClassMemberFunction<Thing>("asMissile", &Thing::asMissile);
g_lua.bindClassMemberFunction<Thing>("asPlayer", &Thing::asPlayer);
g_lua.bindClassMemberFunction<Thing>("asLocalPlayer", &Thing::asLocalPlayer);
g_lua.bindClassMemberFunction<Thing>("asAnimatedText", &Thing::asAnimatedText);
g_lua.bindClassMemberFunction<Thing>("asStaticText", &Thing::asStaticText);
g_lua.bindClassMemberFunction<Thing>("isGround", &Thing::isGround);
g_lua.bindClassMemberFunction<Thing>("isGroundBorder", &Thing::isGroundBorder);
g_lua.bindClassMemberFunction<Thing>("isOnBottom", &Thing::isOnBottom);
g_lua.bindClassMemberFunction<Thing>("isOnTop", &Thing::isOnTop);
g_lua.bindClassMemberFunction<Thing>("isContainer", &Thing::isContainer); g_lua.bindClassMemberFunction<Thing>("isContainer", &Thing::isContainer);
g_lua.bindClassMemberFunction<Thing>("isForceUse", &Thing::isForceUse);
g_lua.bindClassMemberFunction<Thing>("isMultiUse", &Thing::isMultiUse); g_lua.bindClassMemberFunction<Thing>("isMultiUse", &Thing::isMultiUse);
g_lua.bindClassMemberFunction<Thing>("isRotateable", &Thing::isRotateable); g_lua.bindClassMemberFunction<Thing>("isRotateable", &Thing::isRotateable);
g_lua.bindClassMemberFunction<Thing>("isNotMoveable", &Thing::isNotMoveable); g_lua.bindClassMemberFunction<Thing>("isNotMoveable", &Thing::isNotMoveable);
g_lua.bindClassMemberFunction<Thing>("isPickupable", &Thing::isPickupable); g_lua.bindClassMemberFunction<Thing>("isPickupable", &Thing::isPickupable);
g_lua.bindClassMemberFunction<Thing>("asCreature", &Thing::asCreature); g_lua.bindClassMemberFunction<Thing>("ignoreLook", &Thing::ignoreLook);
g_lua.bindClassMemberFunction<Thing>("asPlayer", &Thing::asPlayer); g_lua.bindClassMemberFunction<Thing>("isStackable", &Thing::isStackable);
g_lua.bindClassMemberFunction<Thing>("asLocalPlayer", &Thing::asLocalPlayer);
g_lua.registerClass<Creature, Thing>(); g_lua.registerClass<Creature, Thing>();
g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName); g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName);
@ -85,12 +130,40 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<Player, Creature>(); g_lua.registerClass<Player, Creature>();
g_lua.registerClass<Effect, Thing>();
g_lua.registerClass<Missile, Thing>();
g_lua.registerClass<StaticText, Thing>();
g_lua.registerClass<AnimatedText, Thing>();
g_lua.registerClass<LocalPlayer, Player>(); g_lua.registerClass<LocalPlayer, Player>();
g_lua.bindClassMemberFunction<LocalPlayer>("getAttackingCreature", &LocalPlayer::getAttackingCreature); g_lua.bindClassMemberFunction<LocalPlayer>("getAttackingCreature", &LocalPlayer::getAttackingCreature);
g_lua.bindClassMemberFunction<LocalPlayer>("getFollowingCreature", &LocalPlayer::getFollowingCreature); g_lua.bindClassMemberFunction<LocalPlayer>("getFollowingCreature", &LocalPlayer::getFollowingCreature);
g_lua.registerClass<Item, Thing>(); g_lua.registerClass<Item, Thing>();
g_lua.registerClass<Tile>(); g_lua.registerClass<Tile>();
g_lua.bindClassMemberFunction<Tile>("clean", &Tile::clean);
g_lua.bindClassMemberFunction<Tile>("addThing", &Tile::addThing);
g_lua.bindClassMemberFunction<Tile>("getThing", &Tile::getThing);
g_lua.bindClassMemberFunction<Tile>("getThingStackpos", &Tile::getThingStackpos);
g_lua.bindClassMemberFunction<Tile>("getTopThing", &Tile::getTopThing);
g_lua.bindClassMemberFunction<Tile>("removeThingByStackpos", &Tile::removeThingByStackpos);
g_lua.bindClassMemberFunction<Tile>("removeThing", &Tile::removeThing);
g_lua.bindClassMemberFunction<Tile>("getTopLookThing", &Tile::getTopLookThing);
g_lua.bindClassMemberFunction<Tile>("getTopUseThing", &Tile::getTopUseThing);
g_lua.bindClassMemberFunction<Tile>("getTopCreature", &Tile::getTopCreature);
g_lua.bindClassMemberFunction<Tile>("getPos", &Tile::getPos);
g_lua.bindClassMemberFunction<Tile>("getDrawElevation", &Tile::getDrawElevation);
g_lua.bindClassMemberFunction<Tile>("getCreatures", &Tile::getCreatures);
g_lua.bindClassMemberFunction<Tile>("getGround", &Tile::getGround);
g_lua.bindClassMemberFunction<Tile>("isWalkable", &Tile::isWalkable);
g_lua.bindClassMemberFunction<Tile>("isFullGround", &Tile::isFullGround);
g_lua.bindClassMemberFunction<Tile>("isFullyOpaque", &Tile::isFullyOpaque);
g_lua.bindClassMemberFunction<Tile>("isLookPossible", &Tile::isLookPossible);
g_lua.bindClassMemberFunction<Tile>("hasCreature", &Tile::hasCreature);
g_lua.bindClassMemberFunction<Tile>("isEmpty", &Tile::isEmpty);
g_lua.bindClassMemberFunction<Tile>("isClickable", &Tile::isClickable);
g_lua.registerClass<Map>(); g_lua.registerClass<Map>();
g_lua.registerClass<Game>(); g_lua.registerClass<Game>();
@ -114,6 +187,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("talkChannel", std::bind(&Game::talkChannel, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction<Game>("talkChannel", std::bind(&Game::talkChannel, &g_game, _1, _2, _3));
g_lua.bindClassStaticFunction<Game>("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction<Game>("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3));
g_lua.bindClassStaticFunction<Game>("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game)); g_lua.bindClassStaticFunction<Game>("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game));
g_lua.bindClassStaticFunction<Game>("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game));
g_lua.registerClass<UIItem, UIWidget>(); g_lua.registerClass<UIItem, UIWidget>();
g_lua.bindClassStaticFunction<UIItem>("create", []{ return UIItemPtr(new UIItem); } ); g_lua.bindClassStaticFunction<UIItem>("create", []{ return UIItemPtr(new UIItem); } );

View File

@ -80,6 +80,7 @@ bool luavalue_cast(int index, Position& pos)
pos.y = g_lua.popInteger(); pos.y = g_lua.popInteger();
g_lua.getField("z", index); g_lua.getField("z", index);
pos.z = g_lua.popInteger(); pos.z = g_lua.popInteger();
return true;
} }
return false; return false;
} }

View File

@ -353,8 +353,6 @@ void ProtocolGame::parseMoveWest(InputMessage& msg)
void ProtocolGame::parseUpdateTile(InputMessage& msg) void ProtocolGame::parseUpdateTile(InputMessage& msg)
{ {
logDebug("PARSE UPDATE TILE!");
Position tilePos = parsePosition(msg); Position tilePos = parsePosition(msg);
uint16 thingId = msg.getU16(true); uint16 thingId = msg.getU16(true);
if(thingId == 0xFF01) { if(thingId == 0xFF01) {
@ -390,7 +388,7 @@ void ProtocolGame::parseTileTransformThing(InputMessage& msg)
} }
else { else {
ThingPtr thing = internalGetItem(msg, thingId); ThingPtr thing = internalGetItem(msg, thingId);
g_map.removeThing(pos, stackPos); g_map.removeThingByPos(pos, stackPos);
g_map.addThing(thing, pos, stackPos); g_map.addThing(thing, pos, stackPos);
} }
} }
@ -400,7 +398,7 @@ void ProtocolGame::parseTileRemoveThing(InputMessage& msg)
Position pos = parsePosition(msg); Position pos = parsePosition(msg);
uint8 stackPos = msg.getU8(); uint8 stackPos = msg.getU8();
g_map.removeThing(pos, stackPos); g_map.removeThingByPos(pos, stackPos);
} }
void ProtocolGame::parseCreatureMove(InputMessage& msg) void ProtocolGame::parseCreatureMove(InputMessage& msg)
@ -756,10 +754,13 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
case Otc::SpeakPrivateNpcToPlayer: case Otc::SpeakPrivateNpcToPlayer:
creaturePos = parsePosition(msg); creaturePos = parsePosition(msg);
break; break;
case Otc::SpeakChannelRed:
case Otc::SpeakChannelOrange:
case Otc::SpeakChannelYellow: case Otc::SpeakChannelYellow:
case Otc::SpeakChannelWhite: case Otc::SpeakChannelWhite:
case Otc::SpeakChannelRed:
#if PROTOCOL==860
case Otc::SpeakChannelRed2:
#endif
case Otc::SpeakChannelOrange:
channelId = msg.getU16(); channelId = msg.getU16();
break; break;
case Otc::SpeakPrivate: case Otc::SpeakPrivate:
@ -767,6 +768,11 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
case Otc::SpeakBroadcast: case Otc::SpeakBroadcast:
case Otc::SpeakPrivateRed: case Otc::SpeakPrivateRed:
break; break;
#if PROTOCOL==860
case Otc::SpeakReportChannel:
msg.getU32();
break;
#endif
default: default:
logTraceError("unknown speak type ", type); logTraceError("unknown speak type ", type);
break; break;