bool Game::steerCreature(Creature* creature, const Position& position, uint16_t maxNodes/* = 1000*/)
{
FindPathParams fpp;
fpp.maxClosedNodes = maxNodes;
fpp.fullPathSearch = true;
fpp.maxSearchDist = -1;
fpp.minTargetDist = 0;
fpp.maxTargetDist = 1;
std::list<Direction> dirList;
if(!getPathToEx(creature, position, dirList, fpp))
return false;
creature->startAutoWalk(dirList);
return true;
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local position = {x= toPosition.x, y = toPosition.y+4,z=toPosition.z}
if not doSteerCreature(cid,position) then
return doPlayerSendCancel(cid,getCreatureName(monsters).." can't go there.")
end
return true
end
I think it shoulddo a auto walk ye.
Code:bool Game::steerCreature(Creature* creature, const Position& position, uint16_t maxNodes/* = 1000*/) { FindPathParams fpp; fpp.maxClosedNodes = maxNodes; fpp.fullPathSearch = true; fpp.maxSearchDist = -1; fpp.minTargetDist = 0; fpp.maxTargetDist = 1; std::list<Direction> dirList; if(!getPathToEx(creature, position, dirList, fpp)) return false; creature->startAutoWalk(dirList); return true; }
Example(I think not tested)
LUA:function onUse(cid, item, fromPosition, itemEx, toPosition) local position = {x= toPosition.x, y = toPosition.y+4,z=toPosition.z} if not doSteerCreature(cid,position) then return doPlayerSendCancel(cid,getCreatureName(monsters).." can't go there.") end return true end