if(Creature* movingCreature = thing->getCreature())
{
uint32_t delay = g_config.getNumber(ConfigManager::PUSH_CREATURE_DELAY);
if(Position::areInRange<1,1,0>(movingCreature->getPosition(), player->getPosition()) && delay > 0
&& !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
{
SchedulerTask* task = createSchedulerTask(delay, boost::bind(&Game::playerMoveCreature, this,
player->getID(), movingCreature->getID(), movingCreature->getPosition(), toCylinder->getPosition()));
player->setNextActionTask(task);
}
else
playerMoveCreature(playerId, movingCreature->getID(), movingCreature->getPosition(), toCylinder->getPosition());
}
else if(thing->getItem())
playerMoveItem(playerId, fromPos, spriteId, fromStackpos, toPos, count);
return true;
}
bool Game::playerMoveCreature(uint32_t playerId, uint32_t movingCreatureId,
const Position& movingCreaturePos, const Position& toPos)
{
Player* player = getPlayerByID(playerId);
if(!player || player->isRemoved() || player->hasFlag(PlayerFlag_CannotMoveCreatures))
return false;
if(!player->canDoAction())
{
uint32_t delay = player->getNextActionTime();
SchedulerTask* task = createSchedulerTask(delay, boost::bind(&Game::playerMoveCreature,
this, playerId, movingCreatureId, movingCreaturePos, toPos));
player->setNextActionTask(task);
return false;
}
Creature* movingCreature = getCreatureByID(movingCreatureId);
if(!movingCreature || movingCreature->isRemoved() || movingCreature->getNoMove())
return false;
player->setNextActionTask(NULL);
if(!Position::areInRange<1,1,0>(movingCreaturePos, player->getPosition()) && !player->hasCustomFlag(PlayerCustomFlag_CanMoveFromFar))
{
//need to walk to the creature first before moving it
std::list<Direction> listDir;
if(getPathToEx(player, movingCreaturePos, listDir, 0, 1, true, true))
{
Dispatcher::getInstance().addTask(createTask(boost::bind(&Game::playerAutoWalk,
this, player->getID(), listDir)));
SchedulerTask* task = createSchedulerTask(player->getStepDuration(),
boost::bind(&Game::playerMoveCreature, this, playerId, movingCreatureId, movingCreaturePos, toPos));
player->setNextWalkActionTask(task);
return true;
}
player->sendCancelMessage(RET_THEREISNOWAY);
return false;
}