Beispiel #1
0
bool Creature::hasCondition(ConditionType_t type, int32_t subId/* = 0*/, bool checkTime/* = true*/) const
{
	if(isSuppress(type))
		return false;

	for(ConditionList::const_iterator it = conditions.begin(); it != conditions.end(); ++it)
	{
		if((*it)->getType() != type || (subId != -1 && (*it)->getSubId() != (uint32_t)subId))
			continue;

		if(!checkTime || !(*it)->getEndTime() || (*it)->getEndTime() >= OTSYS_TIME())
			return true;
	}

	return false;
}
Beispiel #2
0
bool Creature::hasCondition(ConditionType_t type, uint32_t subId/* = 0*/) const
{
	if (isSuppress(type)) {
		return false;
	}

	int64_t timeNow = OTSYS_TIME();
	for (Condition* condition : conditions) {
		if (condition->getType() != type || condition->getSubId() != subId) {
			continue;
		}

		if (condition->getEndTime() >= timeNow) {
			return true;
		}
	}
	return false;
}
bool Creature::hasCondition(ConditionType_t type, uint32_t subId/* = 0*/) const
{
	if (type == CONDITION_EXHAUST_COMBAT && g_game.getStateTime() == 0) {
		return true;
	}

	if (isSuppress(type)) {
		return false;
	}

	for (ConditionList::const_iterator it = conditions.begin(), end = conditions.end(); it != end; ++it) {
		if ((*it)->getType() != type || (*it)->getSubId() != subId) {
			continue;
		}

		if (g_config.getBoolean(ConfigManager::OLD_CONDITION_ACCURACY)) {
			return true;
		}

		if ((*it)->getEndTime() == 0) {
			return true;
		}

		int64_t seekTime = g_game.getStateTime();

		if (seekTime == 0) {
			return true;
		}

		if ((*it)->getEndTime() >= seekTime) {
			seekTime = (*it)->getEndTime();
		}

		if (seekTime >= OTSYS_TIME()) {
			return true;
		}
	}

	return false;
}
Beispiel #4
0
void Creature::onWalk(Direction& dir)
{
	int32_t drunk = -1;
	if(!isSuppress(CONDITION_DRUNK))
	{
		Condition* condition = NULL;
		for(ConditionList::const_iterator it = conditions.begin(); it != conditions.end(); ++it)
		{
			if(!(condition = *it) || condition->getType() != CONDITION_DRUNK)
				continue;

			int32_t subId = condition->getSubId();
			if((!condition->getEndTime() || condition->getEndTime() >= OTSYS_TIME()) && subId > drunk)
				drunk = subId;
		}
	}

	if(drunk < 0)
		return;

	drunk += 25;
	int32_t r = random_range(1, 100);
	if(r > drunk)
		return;

	int32_t tmp = (drunk / 5);
	if(r <= tmp)
		dir = NORTH;
	else if(r <= (tmp * 2))
		dir = WEST;
	else if(r <= (tmp * 3))
		dir = SOUTH;
	else if(r <= (tmp * 4))
		dir = EAST;

	g_game.internalCreatureSay(this, MSG_SPEAK_MONSTER_SAY, "Hicks!", isGhost());
}