Game.useOnCreature lua api

This commit is contained in:
Eduardo Bart
2012-01-17 20:28:55 -02:00
parent 0b08552bbc
commit cc5b36b1cb
7 changed files with 18 additions and 4 deletions

View File

@@ -274,6 +274,14 @@ void Game::useHotkey(int itemId, const ThingPtr& toThing)
m_protocolGame->sendUseItemEx(Position(0xFFFF, 0, 0), itemId, 0, toThing->getPos(), toThing->getId(), getThingStackpos(toThing));
}
void Game::useOnCreature(const ThingPtr& thing, const CreaturePtr& creature)
{
if(!m_online || !thing || !checkBotProtection())
return;
m_protocolGame->sendUseOnCreature(thing->getPos(), thing->getId(), getThingStackpos(thing), creature->getId());
}
void Game::attack(const CreaturePtr& creature)
{
if(!m_online || !creature || !checkBotProtection())

View File

@@ -65,6 +65,7 @@ public:
void use(const ThingPtr& thing);
void useWith(const ThingPtr& fromThing, const ThingPtr& toThing);
void useHotkey(int itemId, const ThingPtr& toThing);
void useOnCreature(const ThingPtr& thing, const CreaturePtr& creature);
// attack/follow related
void attack(const CreaturePtr& creature);

View File

@@ -198,6 +198,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("use", std::bind(&Game::use, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("useWith", std::bind(&Game::useWith, &g_game, _1, _2));
g_lua.bindClassStaticFunction<Game>("useHotkey", std::bind(&Game::useHotkey, &g_game, _1, _2));
g_lua.bindClassStaticFunction<Game>("useOnCreature", std::bind(&Game::useOnCreature, &g_game, _1, _2));
g_lua.bindClassStaticFunction<Game>("walk", std::bind(&Game::walk, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("forceWalk", std::bind(&Game::forceWalk, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("attack", std::bind(&Game::attack, &g_game, _1));

View File

@@ -66,7 +66,7 @@ public:
void sendRejectTrade();
void sendUseItem(const Position& position, int itemId, int stackpos, int index);
void sendUseItemEx(const Position& fromPos, int fromThingId, int fromStackpos, const Position& toPos, int toThingId, int toStackpos);
void sendUseItemCreature(const Position& pos, int thingId, int stackpos, uint creatureId);
void sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId);
void sendRotateItem(const Position& pos, int thingId, int stackpos);
void sendCloseContainer(int containerId);
void sendUpContainer(int containerId);

View File

@@ -275,7 +275,7 @@ void ProtocolGame::sendUseItemEx(const Position& fromPos, int fromThingId, int f
send(oMsg);
}
void ProtocolGame::sendUseItemCreature(const Position& pos, int thingId, int stackpos, uint creatureId)
void ProtocolGame::sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId)
{
OutputMessage oMsg;
oMsg.addU8(Proto::ClientUseOnCreature);