コード例 #1
0
ファイル: creature.cpp プロジェクト: Azuen/RealOTX-7.72
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());
}