예제 #1
0
void InvestigateSpotTask::Init( idAI *owner, Subsystem &subsystem ) {
	// Just init the base class
	Task::Init( owner, subsystem );
	// Get a shortcut reference
	Memory &memory = owner->GetMemory();
	// Stop previous moves
	//owner->StopMove(MOVE_STATUS_DONE);
	if( memory.currentSearchSpot != idVec3( idMath::INFINITY, idMath::INFINITY, idMath::INFINITY ) ) {
		// Set the goal position
		SetNewGoal( memory.currentSearchSpot );
	} else {
		// Invalid hiding spot, terminate task
		DM_LOG( LC_AI, LT_DEBUG )LOGSTRING( "memory.currentSearchSpot not set to something valid, terminating task.\r" );
		subsystem.FinishTask();
	}
	//_exitTime = 0; // grayman #3507
}
예제 #2
0
void UnitGroup::Update ()
{
	if (state == ugroup_Building || units.empty ())
		return;

	int2 sector, dif;
	float2 pmin, pmax;
	if (!CalcPositioning (pmin,pmax,mid,sector))
		return;

	if (current.x < 0)
		current = globals->map->GetGameInfoCoords (float3 (mid.x,0.0f,mid.y));

	// change current?
	if (sector.x >= 0) {
		dif.x=sector.x-current.x; dif.y=sector.y-current.y;
		if (dif.x*dif.x+dif.y*dif.y > 2)
			current = sector;
	}

	GameInfo *b = globals->map->GetGameInfo (goal);

	// calc spreading
	float difx=pmax.x-pmin.x, dify=pmax.y-pmin.y;
	float spread = sqrtf (difx*difx+dify*dify);

	GameInfo *cur = 0;
	cur = globals->map->GetGameInfo (current);

	switch (state)
	{
	case ugroup_Grouping:
		if (spread < group->groupdist)
			SetMoving ();
		break;

	case ugroup_Pruning: {
		// is current target still in sector?
		if (find (cur->enemies.begin(),cur->enemies.end(), curTarget) == cur->enemies.end ())
		{
			// no, so find a new target
			if (cur->enemies.empty ()) // move on
			{
				SetNewGoal();
				SetMoving ();
			}
			else if (lastCmdFrame < globals->cb->GetCurrentFrame () - 30)
				SetPruning ();
		}
		break;}

	case ugroup_Moving:
		if (!cur->enemies.empty ())
			SetPruning ();
		else
		{
			if (goal.x < 0 || IsGoalReached (mid,spread))
				SetNewGoal ();

			if (spread > group->maxspread)
				SetGrouping ();
		}
		break;

	case ugroup_WaitingForGoal:
		SetNewGoal ();
		break;
	}
}
void InvestigateSpotTask::Init(idAI* owner, Subsystem& subsystem)
{
	// Just init the base class
	Task::Init(owner, subsystem);

	// Get a shortcut reference
	Memory& memory = owner->GetMemory();

	// Stop previous moves
	//owner->StopMove(MOVE_STATUS_DONE);

	if (memory.currentSearchSpot != idVec3(idMath::INFINITY, idMath::INFINITY, idMath::INFINITY))
	{
		// Set the goal position
		SetNewGoal(memory.currentSearchSpot);
		memory.hidingSpotInvestigationInProgress = true; // grayman #3857
		memory.stopHidingSpotInvestigation = false;
	}
	else
	{
		// Invalid hiding spot, terminate task
		subsystem.FinishTask();
	}

	// grayman #3857 - Only the first searcher in a search is allowed to investigate
	// the spot closely. Am I it?

	if (_investigateClosely)
	{
		Search* search = gameLocal.m_searchManager->GetSearch(owner->m_searchID);
		if (search)
		{
			if (search->_searcherCount > 0)
			{
				Assignment *assignment = &search->_assignments[0]; // first AI assigned to the search
				if (assignment->_searcher != owner)
				{
					_investigateClosely = false;
				}
			}
		}
	}

	if (owner->HasSeenEvidence())
	{
		// Draw weapon, if we haven't already
		if (!owner->GetAttackFlag(COMBAT_MELEE) && !owner->GetAttackFlag(COMBAT_RANGED))
		{
			if ( ( owner->GetNumRangedWeapons() > 0 ) && !owner->spawnArgs.GetBool("unarmed_ranged","0") )
			{
				owner->DrawWeapon(COMBAT_RANGED);
			}
			else if ( ( owner->GetNumMeleeWeapons() > 0 ) && !owner->spawnArgs.GetBool("unarmed_melee","0") )
			{
				owner->DrawWeapon(COMBAT_MELEE);
			}
		}
	}

	//_exitTime = 0; // grayman #3507
}