void Creature::addEventWalk(bool firstStep) { cancelNextWalk = false; if (getStepSpeed() <= 0) { return; } if (eventWalk != 0) { return; } int64_t ticks = getEventStepTicks(firstStep); if (ticks <= 0) { return; } // Take first step right away, but still queue the next if (ticks == 1) { g_game.checkCreatureWalk(getID()); } eventWalk = g_scheduler.addEvent(createSchedulerTask( std::max<int64_t>(SCHEDULER_MINTICKS, ticks), boost::bind(&Game::checkCreatureWalk, &g_game, getID()))); }
int32_t Creature::getStepDuration() const { if(removed) return 0; uint32_t stepSpeed = getStepSpeed(); if(!stepSpeed) return 0; const Tile* tile = getTile(); if(!tile || !tile->ground) return 0; return ((1000 * Item::items[tile->ground->getID()].speed) / stepSpeed) * lastStepCost; }
void Creature::addEventWalk(bool firstStep/* = false*/) { cancelNextWalk = false; if(getStepSpeed() < 1 || eventWalk) return; int64_t ticks = getEventStepTicks(firstStep); if(ticks < 1) return; if(ticks == 1) g_game.checkCreatureWalk(getID()); eventWalk = Scheduler::getInstance().addEvent(createSchedulerTask(std::max((int64_t)SCHEDULER_MINTICKS, ticks), boost::bind(&Game::checkCreatureWalk, &g_game, id))); }
int32_t Creature::getStepDuration() const { if (isRemoved()) { return 0; } uint32_t calculatedStepSpeed; uint32_t groundSpeed; int32_t stepSpeed = getStepSpeed(); if (stepSpeed > -Creature::speedB) { calculatedStepSpeed = floor((Creature::speedA * log((stepSpeed / 2) + Creature::speedB) + Creature::speedC) + 0.5); if (calculatedStepSpeed <= 0) { calculatedStepSpeed = 1; } } else { calculatedStepSpeed = 1; } const Tile* tile = getTile(); if (tile && tile->ground) { uint32_t groundId = tile->ground->getID(); groundSpeed = Item::items[groundId].speed; if (groundSpeed == 0) { groundSpeed = 150; } } else { groundSpeed = 150; } double duration = std::floor(1000 * groundSpeed / calculatedStepSpeed); int32_t stepDuration = std::ceil(duration / 50) * 50; const Monster* monster = getMonster(); if (monster && monster->isTargetNearby() && !monster->isFleeing() && !monster->getMaster()) { stepDuration <<= 1; } return stepDuration; }
int32_t Creature::getStepDuration() const { if(isRemoved()){ return 0; } int32_t duration = 0; const Tile* tile = getParentTile(); if(tile && tile->ground){ uint32_t groundId = tile->ground->getID(); uint16_t groundSpeed = Item::items[groundId].speed; uint32_t stepSpeed = getStepSpeed(); if(stepSpeed != 0){ duration = (1000 * groundSpeed) / stepSpeed; } } return duration * lastStepCost; }