bool Creature::addCondition(Condition* condition, bool force/* = false*/) { if (condition == NULL) { return false; } if (!force && condition->getType() == CONDITION_HASTE && hasCondition(CONDITION_PARALYZE)) { int64_t walkDelay = getWalkDelay(); if (walkDelay > 0) { g_scheduler.addEvent(createSchedulerTask(walkDelay, boost::bind(&Game::forceAddCondition, &g_game, getID(), condition))); return false; } } Condition* prevCond = getCondition(condition->getType(), condition->getId(), condition->getSubId()); if (prevCond) { prevCond->addCondition(this, condition); delete condition; return true; } if (condition->startCondition(this)) { conditions.push_back(condition); onAddCondition(condition->getType()); return true; } delete condition; return false; }
void Creature::removeCondition(ConditionType_t type, ConditionId_t id, bool force/* = false*/) { ConditionList::iterator it = conditions.begin(); while (it != conditions.end()) { Condition* condition = *it; if (condition->getType() != type || condition->getId() != id) { ++it; continue; } if (!force && condition->getType() == CONDITION_PARALYZE) { int64_t walkDelay = getWalkDelay(); if (walkDelay > 0) { g_scheduler.addEvent(createSchedulerTask(walkDelay, boost::bind(&Game::forceRemoveCondition, &g_game, getID(), type))); return; } } it = conditions.erase(it); condition->endCondition(this, CONDITIONEND_ABORT); delete condition; onEndCondition(type); } }
void Creature::removeCondition(ConditionType_t type, bool force/* = false*/) { auto it = conditions.begin(), end = conditions.end(); while (it != end) { Condition* condition = *it; if (condition->getType() != type) { ++it; continue; } if (!force && type == CONDITION_PARALYZE) { int64_t walkDelay = getWalkDelay(); if (walkDelay > 0) { g_scheduler.addEvent(createSchedulerTask(walkDelay, std::bind(&Game::forceRemoveCondition, &g_game, getID(), type))); return; } } it = conditions.erase(it); condition->endCondition(this); delete condition; onEndCondition(type); } }
void Creature::onWalk() { if (getWalkDelay() <= 0) { Direction dir; uint32_t flags = FLAG_IGNOREFIELDDAMAGE; if (getNextStep(dir, flags)) { ReturnValue ret = g_game.internalMoveCreature(this, dir, flags); if (ret != RETURNVALUE_NOERROR) { if (Player* player = getPlayer()) { player->sendCancelMessage(ret); player->sendCancelWalk(); } forceUpdateFollowPath = true; } } else { if (listWalkDir.empty()) { onWalkComplete(); } stopEventWalk(); } } if (cancelNextWalk) { listWalkDir.clear(); onWalkAborted(); cancelNextWalk = false; } if (eventWalk != 0) { eventWalk = 0; addEventWalk(); } }
void Creature::onWalk() { if(getWalkDelay() <= 0) { Direction dir; uint32_t flags = FLAG_IGNOREFIELDDAMAGE; if(!getNextStep(dir, flags)) { if(listWalkDir.empty()) onWalkComplete(); stopEventWalk(); } else if(g_game.internalMoveCreature(this, dir, flags) != RET_NOERROR) forceUpdateFollowPath = true; } if(cancelNextWalk) { cancelNextWalk = false; listWalkDir.clear(); onWalkAborted(); } if(eventWalk) { eventWalk = 0; addEventWalk(); } }
int64_t Creature::getEventStepTicks() const { int64_t ret = getWalkDelay(); if(ret > 0) return ret; return getStepDuration(); }
int64_t Creature::getEventStepTicks(bool onlyDelay/* = false*/) const { int64_t ret = getWalkDelay(); if(ret > 0) return ret; if(!onlyDelay) return getStepDuration(); return 1; }
int64_t Creature::getEventStepTicks(bool onlyDelay) const { int64_t ret = getWalkDelay(); if (ret <= 0) { int64_t stepDuration = getStepDuration(); if (onlyDelay && stepDuration > 0) { ret = 1; } else { ret = stepDuration * lastStepCost; } } return ret; }
void Creature::onWalk() { if(getWalkDelay() <= 0) { Direction dir; uint32_t flags = FLAG_IGNOREFIELDDAMAGE; if(getNextStep(dir, flags) && g_game.internalMoveCreature(this, dir, flags) != RET_NOERROR) forceUpdateFollowPath = true; } if(listWalkDir.empty()) onWalkComplete(); if(eventWalk) { eventWalk = 0; addEventWalk(); } }
void Creature::removeCondition(Condition* condition, bool force/* = false*/) { ConditionList::iterator it = std::find(conditions.begin(), conditions.end(), condition); if (it == conditions.end()) { return; } if (!force && condition->getType() == CONDITION_PARALYZE) { int64_t walkDelay = getWalkDelay(); if (walkDelay > 0) { g_scheduler.addEvent(createSchedulerTask(walkDelay, boost::bind(&Game::forceRemoveCondition, &g_game, getID(), condition->getType()))); return; } } conditions.erase(it); condition->endCondition(this, CONDITIONEND_ABORT); onEndCondition(condition->getType()); delete condition; }