Exemple #1
0
void Mob::CalculateNewFearpoint()
{
	if(RuleB(Pathing, Fear) && zone->pathing)
	{
		int Node = zone->pathing->GetRandomPathNode();
	
		VERTEX Loc = zone->pathing->GetPathNodeCoordinates(Node);

		++Loc.z;

		VERTEX CurrentPosition(GetX(), GetY(), GetZ());

		list<int> Route = zone->pathing->FindRoute(CurrentPosition, Loc);

		if(Route.size() > 0)
		{
			fear_walkto_x = Loc.x;
			fear_walkto_y = Loc.y;
			fear_walkto_z = Loc.z;
			curfp = true;

			mlog(PATHING__DEBUG, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z);
			return;
		}

		mlog(PATHING__DEBUG, "No path found to selected node. Falling through to old fear point selection.");
	}

	int loop = 0;
	float ranx, rany, ranz;
	curfp = false;
	while (loop < 100) //Max 100 tries
	{
		int ran = 250 - (loop*2);
		loop++;
		ranx = GetX()+MakeRandomInt(0, ran-1)-MakeRandomInt(0, ran-1);
		rany = GetY()+MakeRandomInt(0, ran-1)-MakeRandomInt(0, ran-1);
		ranz = FindGroundZ(ranx,rany);
		if (ranz == -999999)
			continue;
		float fdist = ranz - GetZ();
		if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(),GetY(),GetZ(),ranx,rany,ranz))
		{
			curfp = true;
			break;
		}
	}
	if (curfp)
	{
		fear_walkto_x = ranx;
		fear_walkto_y = rany;
		fear_walkto_z = ranz;
	}
	else //Break fear
	{
		BuffFadeByEffect(SE_Fear);
	}
}
Exemple #2
0
void Mob::CalculateNewFearpoint()
{
	if(RuleB(Pathing, Fear) && zone->pathing)
	{
		int Node = zone->pathing->GetRandomPathNode();

		glm::vec3 Loc = zone->pathing->GetPathNodeCoordinates(Node);

		++Loc.z;

		glm::vec3 CurrentPosition(GetX(), GetY(), GetZ());

		std::deque<int> Route = zone->pathing->FindRoute(CurrentPosition, Loc);

		if(Route.size() > 0)
		{
            m_FearWalkTarget = glm::vec3(Loc.x, Loc.y, Loc.z);
			curfp = true;

			Log.Out(Logs::Detail, Logs::None, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z);
			return;
		}

		Log.Out(Logs::Detail, Logs::None, "No path found to selected node. Falling through to old fear point selection.");
	}

	int loop = 0;
	float ranx, rany, ranz;
	curfp = false;
	while (loop < 100) //Max 100 tries
	{
		int ran = 250 - (loop*2);
		loop++;
		ranx = GetX()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
		rany = GetY()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
		ranz = FindGroundZ(ranx,rany);
		if (ranz == -999999)
			continue;
		float fdist = ranz - GetZ();
		if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(),GetY(),GetZ(),ranx,rany,ranz))
		{
			curfp = true;
			break;
		}
	}
	if (curfp)
        m_FearWalkTarget = glm::vec3(ranx, rany, ranz);
	else //Break fear
		BuffFadeByEffect(SE_Fear);
}