Ejemplo n.º 1
0
void Squad::Set_Goal 
(
  Goal_ptr new_strategic_goal
)

{
	
	if (new_strategic_goal is NULL) return;

	
	if (my_strategic_goal isnt NULL)
	{
		

		
		if (my_strategic_goal->attacking_squad is this)		{
			






			Detach_Goal();
		} 
		BOOL GOAL_DETACHED_WITHOUT_NOTIFYING_SQUAD = FALSE;
		Assert(GOAL_DETACHED_WITHOUT_NOTIFYING_SQUAD);
	} 

	
	my_strategic_goal = new_strategic_goal;
    my_goal_id = my_strategic_goal->GetID(); 
    already_committed = TRUE; 

	
    my_strategic_goal->my_squad_id = squad_ID; 
	new_strategic_goal->attacking_squad = this;

    
    *(my_strategic_goal->m_current_attacking_strength) = m_squad_strength; 

	#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_DETAILS)
	{
		AILOG(( wstr,  "Squad::Set_Goal: Attaching squad %d to goal %d.\n", 
				squad_ID, new_strategic_goal->goal_ID));

		
		new_strategic_goal->Display_Goal_Type(ai);
		new_strategic_goal->Display_Goal_Details(ai);

		AILOG(( wstr,  "\n"));
	}
	#endif
	#endif DBGAILOG
}
Ejemplo n.º 2
0
BOOL GoalSally::FollowPathToTask(AiMain *ai, ArmyAgent *first_army, 
    ArmyAgent *second_army, const SUB_TASK_TYPE sub_task, 
    MapPointData &dest_pos)
{ 
	Assert(first_army->the_squad);

	if (first_army->the_squad && sub_task == SUB_TASK_GOAL)
		
		first_army->the_squad->GroupWithArmy(ai, first_army);

	
	
	ForeignAgent *target = GetTarget(ai);
	MapPointData XYpos;
	MapPointData pos;
	first_army->GetPos(ai,pos);
	ai->m_player->Norm2XY(pos, XYpos); 
	double threat = ai->m_planner->the_strategic_map->Get_Threat(XYpos);
	if (target->GetAttackStrength() < threat)
		{
			#ifdef DBGAILOG
			
			if (ai->AI_VERBOSITY >= LOG_MEDIUM)
			AILOG(( wstr,  "\nFollowPathToTask: Chicken out, target does not account entire threat.\n"));
			#endif DBGAILOG
			return FALSE;
		}

	return ArmyGoal::FollowPathToTask(ai, first_army, second_army, sub_task, dest_pos);
}
Ejemplo n.º 3
0
void Squad::Detach_Goal()

{
	
	Goal *tmp_goal;
	if (my_strategic_goal isnt NULL)
	{
		
		
#ifdef DBGAILOG

#ifdef LOG_SQUADS
		if (ai->AI_VERBOSITY >= LOG_DETAILS)
		{
			AILOG((wstr, "Detaching goal #%d ", my_strategic_goal->goal_ID));
			my_strategic_goal->Display_Goal_Type(ai);
			AILOG((wstr, "\n"));
		}
#endif
#endif DBGAILOG

		

		
		tmp_goal = my_strategic_goal;
		my_strategic_goal = NULL;
        tmp_goal->Detach_Squad();

		


		
		tmp_goal->CleanUp();
	}

	
	my_strategic_goal = NULL;
    my_goal_id = SAVE_NO_GOAL; 



	last_goal_type = GOAL_TYPE_MAX;

	
	already_committed = FALSE;

}
Ejemplo n.º 4
0
void GoalSally::Display_Goal_Type(AiMain *ai)
{
#ifdef DBGAILOG
	
	if (ai->AI_VERBOSITY >= LOG_MEDIUM)
		AILOG(( wstr,  "GOAL_TYPE_SALLY"));
#endif DBGAILOG
}
void Goal_Attack_Region::Display_Goal_Type(AiMain *ai)
{
#ifdef DBGAILOG

	if (ai->AI_VERBOSITY >= LOG_MEDIUM)
		AILOG(( wstr,  "GOAL_TYPE_ATTACK_REGION"));
#endif DBGAILOG
}
Ejemplo n.º 6
0
void GoalTransport::Display_Goal_Type(AiMain *ai)
{
#ifdef DBGAILOG
	
	if (ai->AI_VERBOSITY >= LOG_MEDIUM)
		AILOG(( wstr,  "GOAL_TYPE_TRANSPORT"));
#endif DBGAILOG
}
Ejemplo n.º 7
0
void GoalBombard::Display_Goal_Type(AiMain *ai)
{
#ifdef DBGAILOG

	if (ai->AI_VERBOSITY >= LOG_MEDIUM)
		AILOG(( wstr,  "GOAL_TYPE_BOMBARD"));
#endif DBGAILOG
}
void Goal_Attack_Region::Display_Goal_Details(AiMain *ai)
{
#ifdef DBGAILOG

	if (ai->AI_VERBOSITY >= LOG_DETAILS)
		AILOG((wstr, " Target: (%d, %d, %d)", m_pos->x, m_pos->y, m_pos->z));
#endif DBGAILOG
}
Ejemplo n.º 9
0
void GoalSettle::Display_Goal_Type(AiMain *ai)
{
    Assert(m_XYpos);
#ifdef DBGAILOG

	if (ai->AI_VERBOSITY >= LOG_MEDIUM)
		AILOG(( wstr,  "GOAL_TYPE_SETTLE"));
#endif DBGAILOG
}
Ejemplo n.º 10
0
void GoalMapTarget::Display_Goal_Details(AiMain *ai)
{
#ifdef DBGAILOG
	GetPos(*m_pos);

	if (ai->AI_VERBOSITY >= LOG_DETAILS)
		AILOG((wstr, " Target: (%d, %d, %d)", m_pos->x, m_pos->y, m_pos->z));
#endif DBGAILOG
}
Ejemplo n.º 11
0
void Squad::Remove_Agent
(
	Agent * remove_me
)
{
	
	Assert(remove_me->the_squad);
	if (!remove_me->the_squad)
		return;

	#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY > LOG_DETAILS)
	{
		AILOG(( wstr,  "Squad::Remove_Agent:\n\tArmyCount() = %d (before).\n", 
				m_squad_strength.GetArmyCount()))
		AILOG(( wstr,  "\tGetUnitCount() = %d (before).\n", 
				m_squad_strength.GetUnitCount()))
		AILOG(( wstr,  "\tremoveme->GetSquadStrength()->GetArmyCount() = %d\n", 
				remove_me->GetSquadStrength()->GetArmyCount()))
		AILOG(( wstr,  "\tremoveme->GetSquadStrength()->GetUnitCount() = %d.\n", 
				remove_me->GetSquadStrength()->GetUnitCount()))

	}
	#endif
	#endif DBGAILOG

    
    m_squad_strength.Subtract(remove_me->GetSquadStrength()); 

	#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY > LOG_DETAILS)
	{
		AILOG(( wstr,  "\tArmyCount() = %d (after).\n", 
				m_squad_strength.GetArmyCount()))
		AILOG(( wstr,  "\tGetUnitCount() = %d (after).\n", 
				m_squad_strength.GetUnitCount()))
	}
	#endif
	#endif DBGAILOG

	
	remove_me->the_squad = NULL;

	
    if (my_strategic_goal) { 
         *(my_strategic_goal->m_current_attacking_strength) = m_squad_strength;
    }

	
	my_agents.Remove_Cell( remove_me->squads_list_cell_ptr );
	remove_me->squads_list_cell_ptr = NULL;

	
	m_moveType = 0x0;

}
Ejemplo n.º 12
0
void GoalBombard::Display_Goal_Details(AiMain *ai)
{
	#ifdef DBGAILOG

	if (ai->AI_VERBOSITY >= LOG_DETAILS)
	{
		if (m_target_type == AGENT_TYPE_CITY)
		{
			AILOG((wstr, " City: (%d, %d, %d)", m_pos->x, m_pos->y, m_pos->z))
		}
		else
		{
			AILOG((wstr, " Army: (%d, %d, %d)", m_pos->x, m_pos->y, m_pos->z))
		}
	}
	#endif DBGAILOG
}
Ejemplo n.º 13
0
void Squad::Add_Agent
(
	AiMain *ai, 
	Agent * add_me
)

{
	#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY > LOG_DETAILS)
	{
		AILOG(( wstr,  "Squad::Add_Agent:\n\tArmyCount() = %d (before).\n", 
				m_squad_strength.GetArmyCount()))
		AILOG(( wstr,  "\tGetUnitCount() = %d (before).\n", 
				m_squad_strength.GetUnitCount()))
		AILOG(( wstr,  "\taddme->GetSquadStrength().GetArmyCount() = %d\n", 
				add_me->GetSquadStrength()->GetArmyCount()))
		AILOG(( wstr,  "\taddme->GetSquadStrength().GetUnitCount() = %d.\n", 
				add_me->GetSquadStrength()->GetUnitCount()))
	}
	#endif
	#endif DBGAILOG

	

    
	add_me->squads_list_cell_ptr = my_agents.Add_Data((data_ptr) add_me);
	add_me->the_squad = this;

    
    m_squad_strength.Add(add_me->GetSquadStrength()); 

	#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY > LOG_DETAILS)
	{
		AILOG(( wstr,  "\tArmyCount() = %d (after).\n", 
				m_squad_strength.GetArmyCount()))
		AILOG(( wstr,  "\tGetUnitCount() = %d (after).\n", 
				m_squad_strength.GetUnitCount()))
	}
	#endif
	#endif DBGAILOG



	
    BOOL will_be_transported = FALSE; 
    MapPointData target_pos, agent_pos; 
    double move_point_cost; 
    double build_time; 
    ArmyAgent *the_army=NULL; 
    CityAgent *the_city=NULL; 
    sint32 dist; 
    if (my_strategic_goal) { 
         *(my_strategic_goal->m_current_attacking_strength) = m_squad_strength;
    

         
         
        ((ArmyGoal*)my_strategic_goal)->GetPos(target_pos); 

         if (add_me->GetType() == AGENT_TYPE_CITY) { 
             the_city = (CityAgent*) add_me; 
             the_city->GetPos(agent_pos); 
             dist = sint32(ai->m_map->WrappedDistance(agent_pos, target_pos)); 
    
         } else { 
             the_army = (ArmyAgent*) add_me; 

             if (the_army->BidDistance(ai, will_be_transported, target_pos, move_point_cost, 
                 dist, build_time) < 0.0) { 
                 dist = 100; 
             }
         }

         if (my_strategic_goal->m_farthest_agent_to_target_dist < dist) { 
             my_strategic_goal->m_farthest_agent_to_target_dist = (sint16) dist; 
         }
    }

	
	m_moveType = 0x0;

	
	Reclassify_Squad(ai, add_me);
}
Ejemplo n.º 14
0
void GoalMapTarget::Display_Goal_Type(AiMain *ai)
{
	BOOL ASSERT_MAP_TARGET_INVALID = 0;
	char position[20];

	if (ai->AI_VERBOSITY >= LOG_MEDIUM)
		{
			switch (GetType())
				{
					case GOAL_TYPE_TRANSPORT:
						AILOG(( wstr,  "GOAL_TYPE_TRANSPORT"));
						break;
					case GOAL_TYPE_WANDER:
						AILOG(( wstr,  "GOAL_TYPE_WANDER"));
						break;
					case GOAL_TYPE_CHOKEPOINT:
						AILOG(( wstr,  "GOAL_TYPE_CHOKE_POINT"));
						break;


					case GOAL_TYPE_PILLAGE:
						AILOG(( wstr,  "GOAL_TYPE_PILLAGE"));
						break;
					case GOAL_TYPE_PIRATE:
						AILOG(( wstr,  "GOAL_TYPE_PIRATE"));
						break;
					case GOAL_TYPE_COUNTER_STEALTH:
						AILOG(( wstr,  "GOAL_TYPE_COUNTER_STEALTH"));
						break;
					case GOAL_TYPE_BONUS_FOOD:
						AILOG(( wstr,  "GOAL_TYPE_BONUS_FOOD"));
						break;
					case GOAL_TYPE_GOODY_HUT:
						AILOG(( wstr,  "GOAL_TYPE_GOODY_HUT"));
						break;
					case GOAL_TYPE_PROBE_WORMHOLE:
						AILOG(( wstr,  "GOAL_TYPE_PROBE_WORMHOLE"));
						break;
					default:
						AILOG(( wstr,  "INVALID??"));
						Assert(ASSERT_MAP_TARGET_INVALID);
						break;
				}
				GetPos(*m_pos);
				sprintf(position,"(%d,%d,%d)",m_pos->x,m_pos->y,m_pos->z);
				AILOG(( wstr,  position));
		}

}
Ejemplo n.º 15
0
Goal_Result Squad::Rally_Troops
(
	AiMain* ai,
	MapPointData target,				
										
	ArmyGoal *the_goal,					
    BOOL &any_group_needed_to_rally		
)
{
	
	int current_agent = 0;				
	int last_agent;						
	int agent_count;					
	int actually_rally;					
	
	MapPointData rally_point;			
	
	

#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_PAINFUL_DETAILS)
		AILOG((wstr, "Squad::Rally_Troops: Entering\n"));
	#endif
#endif DBGAILOG

	
	
	

	
	agent_count = my_agents.count;

	
	if (agent_count <= 1) return GOAL_INAPPROPRIATE;

	
	any_group_needed_to_rally = false;

	
	
	current_agent = agent_count - 1;
    Goal_Result result;

	
#ifdef _DEBUG
    sint32 finite_loop=0; 
#endif
	while (current_agent >= 0)
	{
Assert(++finite_loop < 100000); 
		
		last_agent = current_agent;

		
		
		
		
		actually_rally = Choose_Rally_Point(ai, target, 
											rally_point, current_agent);

		
		any_group_needed_to_rally |= actually_rally;

		
		if (actually_rally)
		{
			
			
			result = Send_Troops_To_Rally(ai, last_agent, current_agent, rally_point,
								 the_goal);

            if (GOAL_IN_PROGRESS != result) { 
                return result; 
            } 
		} 

	} 

#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_PAINFUL_DETAILS)
		AILOG((wstr, "Squad::Rally_Troops: Exiting\n"));
	#endif
#endif DBGAILOG
	
	
	return GOAL_IN_PROGRESS;
}
Ejemplo n.º 16
0
Goal_Result Squad::Send_Troops_To_Rally
(
	AiMain *ai,							
	int last_agent,						
	int first_agent,					
	MapPointData &rally_pos,			
	ArmyGoal *the_goal					
)
{
	
	sint32 army_idx;					
	double utility;						
    Agent *agent=NULL;					
	ArmyAgent * the_army;				
	AGENT_STATE army_state;				
	MapPointData agent_pos;				
	
    
    BOOL revealed_unexplored = FALSE; 
    BOOL did_move = FALSE; 
    BOOL redo_explore = FALSE; 
    BOOL use_marked=FALSE;
    BOOL revealed_forign_units = FALSE; 
	sint32 first_one_there = -1;		
										
	BOOL is_unknown_id;					
	Goal_Result result = GOAL_COMPLETE; 
	

#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_PAINFUL_DETAILS)
		AILOG((wstr, "Squad::Send_Troops_To_Rally: Entering\n"));
	#endif
#endif DBGAILOG
	
	
	

	
	utility = the_goal->Compute_Raw_Priority(ai);

	
	army_idx = last_agent;

	
	
#ifdef _DEBUG
    sint32 finite_loop=0; 
#endif

    
    

	
	while (army_idx > first_agent)
	{
Assert(++finite_loop < 100000); 
		
		agent = (Agent *) my_agents.Return_Data_By_Number( army_idx );

		
		switch(agent->GetType())
		{
		
		case AGENT_TYPE_CITY:
			
			break;

		
		case AGENT_TYPE_ARMY:
			
			the_army = (ArmyAgent *) agent;

			
			
			
			the_army->GetPos(ai, agent_pos);

			
			army_state = the_army->GetState();

			
			if (not (
					(rally_pos.x is agent_pos.x) and
					(rally_pos.y is agent_pos.y) and
					(rally_pos.z is agent_pos.z) 
					))
			{
				
				the_goal->GotoTaskSolution(ai, 
					army_idx, the_army, 
					0, NULL, 
					rally_pos, SUB_TASK_RALLYING);
				
				
				if (ai->m_i_am_dead || the_goal->Get_Totally_Complete(ai)) 
				{ 
					
					return GOAL_COMPLETE; 
				} 



























			} 
			
			
			
			
			the_army->GetPos(ai, agent_pos);

			
			if ((
				(rally_pos.x is agent_pos.x) and
				(rally_pos.y is agent_pos.y) and
				(rally_pos.z is agent_pos.z) 
				))
			{
				
				if (first_one_there isnt -1)
				{
					
					Remove_Agent(the_army);

					
					
					
					ai->m_player->ArmyGroup(
						agent->GetID().GetVal(), 
						first_one_there, 
						&is_unknown_id
						);

					
					Assert(is_unknown_id == FALSE);

				} 
				
				else
				{
					first_one_there = agent->GetID().GetVal();
				} 

			} 
			else
				result = GOAL_IN_PROGRESS; 

			break;

		
		default:
			Assert(FALSE);
			break;
		} 

		
		army_idx--;

	} 

#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_PAINFUL_DETAILS)
		AILOG((wstr, "Squad::Send_Troops_To_Rally: Exiting\n"));
	#endif
#endif DBGAILOG

    return result;
	
}
Ejemplo n.º 17
0
int Squad::Choose_Rally_Point
(
	AiMain *ai,							
	MapPointData target,				
										
	MapPointData &rally_pos,			
	int &current_agent					
)
{
	
    Agent *agent=NULL;					
	ArmyAgent * the_army;				
	CityAgent * the_city;				
	MapPointData agent_pos;				
	MapPointData closest_pos;			
	double distance;					
	double best_distance;				
	int need_to_rally = false;			
	int units_in_segment = 0;			
	int agents_in_segment = 0;			
	int units_in_agent;					
	int found_one_distance = false;		
	int num_got_there = 0;				
	int rally_successful = false;		
	

#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_PAINFUL_DETAILS)
		AILOG((wstr, "Squad::Choose_Rally_Point: Entering\n"));
	#endif
#endif DBGAILOG
	
	
	if (my_agents.count <= 0)
	{
#ifdef DBGAILOG
		if (ai->AI_VERBOSITY >= LOG_HEADERS)
			AILOG((wstr, "Squad WARNING: Rally point set for EMPTY SQUAD!\n"));
#endif DBGAILOG
		return false;
	} 

	
	

    MapPointData *size = ai->m_map->GetSize(); 

	
	
	best_distance = 2*(size->y + 2*size->x);
	
	
	do
	{
		
		agent = (Agent *) my_agents.Return_Data_By_Number( current_agent );

		
		current_agent--;

		
		switch(agent->GetType())
		{
		
		case AGENT_TYPE_CITY:
			
			the_city = (CityAgent *) agent;

			
			
			
			the_city->GetPos(agent_pos);

			
			units_in_agent = 1;
			break;

		
		case AGENT_TYPE_ARMY:
			
			the_army = (ArmyAgent *) agent;

			
			
			
			the_army->GetPos(ai, agent_pos);

			
			units_in_agent = the_army->GetNUnits();

			break;

		
		default:
			Assert(false);
			break;
		} 

		
		
		if (units_in_segment + units_in_agent > k_MAX_ARMY_SIZE)
		{



			
			continue;

		} 

		
		
		distance = ai->m_map->WrappedDistance(agent_pos, target);

		
		if (distance < best_distance)
		{
			
			if (found_one_distance)
				need_to_rally = true;

			
			best_distance = distance;

			
			closest_pos.x = agent_pos.x;
			closest_pos.y = agent_pos.y;
			closest_pos.z = agent_pos.z;

			
			found_one_distance = true;

		} 

		
		units_in_segment += units_in_agent;

		
		agents_in_segment++;

		
		if (not (
				(closest_pos.x is agent_pos.x) and
				(closest_pos.y is agent_pos.y) 
				
				))
		{
			
			need_to_rally = true;

		} 
		
		else
		{
			
			num_got_there += units_in_agent;

		} 

	} while ((units_in_segment < k_MAX_ARMY_SIZE) and (current_agent >= 0));

	
	rally_pos = closest_pos;
















	
	if (agents_in_segment > 1)
		need_to_rally = true;

#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_PAINFUL_DETAILS)
		AILOG((wstr, "Squad::Choose_Rally_Point: Exiting\n"));
	#endif
#endif DBGAILOG
	
	
	return need_to_rally;
}
Ejemplo n.º 18
0
BOOL Squad::Recruit_Best_Strength
(
	AiMain *ai,							
	Goal *the_goal,						
	Squad *donor_squad,					
	bool looking_for_transports			
)
{
    sint32 max_donor_idx, donor_idx, donor_num; 
    double max_str_score, str_score; 
    Agent *donor_agent=NULL; 
	bool anybody_found_ever = false;
	Agent *best_donor_agent=NULL;		
										

    Assert(donor_squad); 

	
	
    if (((!donor_squad->auxiliary_candidate) and (looking_for_transports)) ||
       (donor_squad->already_committed) ||
       (donor_squad->my_agents.count < 1) ) { 
         return FALSE;
    }


	
	
	
    Assert(this != donor_squad); 

	
	if (this == donor_squad)
		return FALSE;
	


	#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_DETAILS)
	{
		AILOG(( wstr,  "Squad::Recruit_Best_Strength: Recruiting from squad %d into squad %d.\n", 
				donor_squad->squad_ID, squad_ID));
	}
	#endif
	#endif DBGAILOG

    
	int excess;
    do { 
        max_str_score = 0.0; 
        max_donor_idx = -1;
		best_donor_agent=NULL;
        donor_num = donor_squad->my_agents.count; 
		str_score = -1.0;

        
        for (donor_idx=0; donor_idx < donor_num; donor_idx++) 
		{ 

            donor_agent = (Agent*)donor_squad->my_agents.Return_Data_By_Number(donor_idx);

            
            the_goal->EstimateRecruitmentStrength(ai, donor_agent, str_score); 

			
			if (str_score > 0)
			{
				
				if (max_str_score < str_score) { 
					max_str_score = str_score; 
					max_donor_idx = donor_idx; 
					best_donor_agent=donor_agent;
				} 

			} 

        } 

        if (-1 == max_donor_idx) { 
			#ifdef DBGAILOG
			#ifdef LOG_SQUADS
			if (ai->AI_VERBOSITY >= LOG_DETAILS)
			{
				if (!anybody_found_ever)
					{
						
						AILOG(( wstr,  "    No Matching Donor Agents Found...\n "));
					}
			}
			#endif
			#endif DBGAILOG

        } else {

			
			anybody_found_ever = true;

			
			donor_squad->Remove_Agent(best_donor_agent);	

			
			donor_squad->Recompute_Squad_Class(ai); 

			Add_Agent(ai, best_donor_agent); 

			#ifdef DBGAILOG
			#ifdef LOG_SQUADS
			if (ai->AI_VERBOSITY >= LOG_DETAILS)
			{
				
				AILOG(( wstr,  "    RECRUIT: "));
				best_donor_agent->Log_Type(ai);
				AILOG(( wstr,  "\n"));
			}
			#endif
			#endif DBGAILOG

        }

    } 
	
	while (!the_goal->Is_Satisfied(&excess) && 
		   max_donor_idx != -1);  

	
	
	if (anybody_found_ever)
	{
		
		ignore_goals.Append_Whole_List(&(donor_squad->ignore_goals));

	} 

	BOOL is_enough = the_goal->Is_Satisfied(&excess);

	#ifdef DBGAILOG
	#ifdef LOG_SQUADS
	if (ai->AI_VERBOSITY >= LOG_DETAILS && anybody_found_ever)
	{
		
		char str[100];
		AILOG(( wstr,  "                 Needed       Current\n"));
		sprintf(str, "    Army Count   %5d        %5d\n", 
			the_goal->m_current_needed_strength->GetArmyCount(),
			the_goal->m_current_attacking_strength->GetArmyCount());	
		AILOG(( wstr,  str));
		
		sprintf(str, "    Unit Count   %5d        %5d\n", 
			the_goal->m_current_needed_strength->GetUnitCount(),
			the_goal->m_current_attacking_strength->GetUnitCount());	
		AILOG(( wstr,  str));
		
		sprintf(str, "    Attack       %6.0f     %6.0f\n", 
			the_goal->m_current_needed_strength->GetAttack(),
			the_goal->m_current_attacking_strength->GetAttack());	
		AILOG(( wstr,  str));
		
		sprintf(str, "    Defense      %6.0f     %6.0f\n", 
			the_goal->m_current_needed_strength->GetDefense(),
			the_goal->m_current_attacking_strength->GetDefense());	
		AILOG(( wstr,  str));

		sprintf(str, "    Eff. Ranged  %6d     %6d\n", 
			the_goal->m_current_needed_strength->EffectiveRangedStrength(),
			the_goal->m_current_attacking_strength->EffectiveRangedStrength());	
		AILOG(( wstr,  str));
		
		sprintf(str, "    Transport    %5d        %5d\n\n", 
			the_goal->m_current_needed_strength->GetTransport(),
			the_goal->m_current_attacking_strength->GetTransport());	
		AILOG(( wstr,  str));

		if (ai->AI_VERBOSITY > LOG_DETAILS)
		{
			
			AILOG((wstr, "the_team->GetUsableTransport() = %d\n", the_team->GetUsableTransport()));

			
			AILOG((wstr, "the_team->GetUsableDefense() = %d\n", the_team->GetUsableDefense()));

			
			AILOG((wstr, "the_team->GetUsableAttack() = %d\n", the_team->GetUsableAttack()));
		}
		if (is_enough)
		{
			AILOG(( wstr,  "    Squad strength is enough...\n\n"));
		}
		else 
		{
			AILOG(( wstr,  "    Squad strength still not enough...\n"));
		}

	}
	#endif
	#endif DBGAILOG

    return is_enough;
}
Ejemplo n.º 19
0
void Squad::Display_Squad_Type(AiMain *ai)
{
#ifdef DBGAILOG
	switch (squad_type)
		{
		case DEFAULT_SQUAD:
			AILOG((wstr, "DEFAULT_SQUAD"));
			break;
		case CITY_SQUAD:
			AILOG((wstr, "CITY_SQUAD"));
			break;
		case EXPLORE_SQUAD:
			AILOG((wstr, "EXPLORE_SQUAD"));
			break;
		case MILITARY_SQUAD:
			AILOG((wstr, "MILITARY_SQUAD"));
			break;
		case DEFENSE_SQUAD:
			AILOG((wstr, "DEFENSE_SQUAD"));
			break;
		case PROTECT_SQUAD:
			AILOG((wstr, "PROTECT_SQUAD"));
			break;
		case SEIGE_SQUAD:
			AILOG((wstr, "SEIGE_SQUAD"));
			break;
		case BOMBARD_SQUAD:
			AILOG((wstr, "BOMBARD_SQUAD"));
			break;
		case SLAVER_SQUAD:
			AILOG((wstr, "SLAVER_SQUAD"));
			break;
		case GOD_SQUAD:
			AILOG((wstr, "GOD_SQUAD_SQUAD"));
			break;
		case ESPIONAGE_SQUAD:
			AILOG((wstr, "EXPIONAGE_SQUAD"));
			break;
		case DEFUSE_MINES_SQUAD:
			AILOG((wstr, "DEFUSE_MINES_SQUAD"));
			break;
		case BONUS_FOOD_SQUAD:
			AILOG((wstr, "BONUS_FOOD_SQUAD"));
			break;
		case ENVIRONMENTALIST_SQUAD:
			AILOG((wstr, "ENVIRONMENTALIST_SQUAD"));
			break;
		case MEDIA_SQUAD:
			AILOG((wstr, "MEDIA_SQUAD"));
			break;
		case DIPLOMATIC_SQUAD:
			AILOG((wstr, "DIPLOMATIC_SQUAD"));
			break;
		case BUSINESS_SQUAD:
			AILOG((wstr, "BUSINESS_SQUAD"));
			break;
		case LAW_SQUAD:
			AILOG((wstr, "LAW_SQUAD"));
			break;
		case ABOLITIONIST_SQUAD:
			AILOG((wstr, "ABOLITIONIST_SQUAD"));
			break;
		case SETTLER_SQUAD:
			AILOG((wstr, "SETTLER_SQUAD"));
			break;
		case DESTROY_CITY_SQUAD:
			AILOG((wstr, "DESTROY_CITY_SQUAD"));
			break;
		case TRANSPORT_HACK_SQUAD:
			AILOG((wstr, "TRANSPORT_HACK_SQUAD"));
			break;
		case WORMHOLE_PROBE_SQUAD:
			AILOG((wstr, "WORMHOLE_PROBE_SQUAD"));
			break;
		case MAX_SQUAD_CLASSES:
			AILOG((wstr, "MAX_SQUAD_CLASSES"));
			break;
		default:
			AILOG((wstr, "unknown"));
			break;
		}
	AILOG((wstr, "\n"));
#endif DBGAILOG

}
Ejemplo n.º 20
0
void Squad::Display_Composition(AiMain *ai)
{
	
	int i;
    Agent *agent=NULL;				




	

#ifdef LOG_SQUADS
	
	if (my_agents.count <= 0)
	{
#ifdef DBGAILOG
		if (ai->AI_VERBOSITY >= LOG_DETAILS)
			AILOG((wstr, "    EMPTY SQUAD!\n"));
#endif DBGAILOG
		return;
	} 

	
	for (i = 0; i < my_agents.count; i++)
	{
		
		agent = (Agent *) my_agents.Return_Data_By_Number( i );
		#ifdef DBGAILOG
		if (ai->AI_VERBOSITY >= LOG_DETAILS)
		{
			
			MapPointData pos;
			MapPointData xy_pos;
			sint32 row, column;
			if (agent->GetType() == AGENT_TYPE_CITY)
			{
				CityAgent *city = (CityAgent *)agent;
				city->GetPos(pos);
				city->GetXYPos(ai,xy_pos);
			}
			else
			{
				ArmyAgent *army = (ArmyAgent *)agent;
				army->GetPos(ai, pos);
				army->GetXYPos(ai,xy_pos);
			}
			ai->m_planner->the_strategic_map->XY_to_MapgridRC(xy_pos.x, xy_pos.y, 
				row, column, 
				ai->m_planner->the_strategic_map->threat_map_resolution);

			AILOG((wstr, "    #%d  @ %x (%d,%d) [%d, %d]", 
				i, 
				(int) agent,
				pos.x,
				pos.y,
				row,
				column));
		}
		#endif DBGAILOG
		
		
		agent->Log_Type(ai);
		
	} 
#endif
}