____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "unittype.h"
#include "unit.h"
#include "ai_local.h"
#include "actions.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
Go to the source code of this file.
Functions | |
| void | AiResetUnitTypeEquiv (void) |
| Finds all equivalents units to a given one. | |
| void | AiNewUnitTypeEquiv (CUnitType *a, CUnitType *b) |
| Remove any equivalence between unittypes. | |
| int | AiFindUnitTypeEquiv (const CUnitType *unittype, int *result) |
| Finds all available equivalents units to a given one, in the prefered order. | |
| int | AiFindAvailableUnitTypeEquiv (const CUnitType *unittype, int *usableTypes) |
| static void | AiCleanForce (int force) |
| void | AiCleanForces (void) |
| < Cleanup units in force | |
| static int | AiCheckBelongsToForce (int force, const CUnitType *type) |
| void | AiAssignToForce (CUnit *unit) |
| Assign a free units to a force. | |
| void | AiAssignFreeUnitsToForce (void) |
| Attack with force at position. | |
| void | AiAttackWithForceAt (int force, int x, int y) |
| Attack with force. | |
| void | AiAttackWithForce (int force) |
| Periodic called force manager handler. | |
| static void | AiForceAttacks (AiForce *force) |
| void | AiForceManager (void) |
Variables | |
| int | UnitTypeEquivs [UnitTypeMax+1] |
| equivalence between unittypes | |
Definition in file ai_force.cpp.
| void AiAssignFreeUnitsToForce | ( | void | ) |
Attack with force at position.
Assign free units to force.
Definition at line 334 of file ai_force.cpp.
References AI_MAX_ATTACKING_FORCES, AiAssignToForce(), AiCleanForces(), AiPlayer, PlayerAi::Force, int(), PlayerAi::Player, CPlayer::TotalNumUnits, UnitMax, AiForce::Units, and CPlayer::Units.
Referenced by AiForceManager(), and CclAiForce().
| void AiAssignToForce | ( | CUnit * | unit | ) |
Assign a free units to a force.
Ai assign unit to force.
| unit | Unit to assign to force. |
Definition at line 310 of file ai_force.cpp.
References AI_MAX_FORCES, AiCheckBelongsToForce(), AiPlayer, AiForce::Attacking, AiForce::Defending, PlayerAi::Force, CUnit::RefsIncrease(), CUnit::Type, and AiForce::Units.
Referenced by AiAssignFreeUnitsToForce(), and AiTrainingComplete().
| void AiAttackWithForce | ( | int | force | ) |
Periodic called force manager handler.
Attack opponent with force.
| force | Force number to attack with. |
Definition at line 403 of file ai_force.cpp.
References AI_MAX_ATTACKING_FORCES, AI_MAX_FORCES, AiCleanForce(), AiPlanAttack(), AiPlayer, AiForce::Attacking, AttackUnitsInDistance(), CUnitType::CanAttack, CommandAttack(), CommandMove(), DebugPrint, FlushCommands, PlayerAi::Force, int(), MaxMapWidth, AiForce::Reset(), AiForce::State, CUnit::Type, AiForce::Units, CUnit::Wait, CUnit::X, CUnit::Y, and y.
Referenced by CclAiAttackWithForce().
| void AiAttackWithForceAt | ( | int | force, | |
| int | x, | |||
| int | y | |||
| ) |
Attack with force.
Attack at position with force.
| force | Force number to attack with. | |
| x | X tile map position to be attacked. | |
| y | Y tile map position to be attacked. |
Definition at line 376 of file ai_force.cpp.
References AiCleanForce(), AiPlayer, AiForce::Attacking, CUnitType::CanAttack, CommandAttack(), CommandMove(), FlushCommands, PlayerAi::Force, int(), CUnit::Type, AiForce::Units, and CUnit::Wait.
Referenced by AiHelpMe().
| static int AiCheckBelongsToForce | ( | int | force, | |
| const CUnitType * | type | |||
| ) | [static] |
Check if the units belongs to the force.
| force | Force to be checked. | |
| type | Type to check. |
Definition at line 267 of file ai_force.cpp.
References AiPlayer, AiForce::Completed, PlayerAi::Force, int(), CUnitType::Slot, AiUnitType::Type, CUnit::Type, AiForce::Units, UnitTypeEquivs, UnitTypeMax, AiForce::UnitTypes, and AiUnitType::Want.
Referenced by AiAssignToForce().
| static void AiCleanForce | ( | int | force | ) | [static] |
Ai clean units in a force.
| force | Force number. |
Definition at line 178 of file ai_force.cpp.
References AiPlayer, AiForce::Attacking, AiForce::Completed, CUnit::Destroyed, PlayerAi::Force, int(), CUnit::Orders, CUnit::RefsDecrease(), CUnitType::Slot, AiUnitType::Type, CUnit::Type, UnitActionDie, AiForce::Units, UnitTypeEquivs, UnitTypeMax, AiForce::UnitTypes, and AiUnitType::Want.
Referenced by AiAttackWithForce(), AiAttackWithForceAt(), AiCleanForces(), and AiForceManager().
| void AiCleanForces | ( | void | ) |
< Cleanup units in force
Cleanup units in forces.
Definition at line 249 of file ai_force.cpp.
References AI_MAX_ATTACKING_FORCES, and AiCleanForce().
Referenced by AiAssignFreeUnitsToForce(), AiTrainingComplete(), and CclAiWaitForce().
| int AiFindAvailableUnitTypeEquiv | ( | const CUnitType * | unittype, | |
| int * | usableTypes | |||
| ) |
Find All unittypes equivalent to a given one, and which are available UnitType are returned in the prefered order ( ie palladin >> knight... )
| unittype | The unittype to find equivalence for | |
| usableTypes | int array which will hold the result. (Size UnitTypeMax+1) |
Definition at line 137 of file ai_force.cpp.
References AiFindUnitTypeEquiv(), AiPlayer, CPlayer::Index, PlayerAi::Player, and UnitTypes.
Referenced by AiMakeUnit().
| int AiFindUnitTypeEquiv | ( | const CUnitType * | unittype, | |
| int * | result | |||
| ) |
Finds all available equivalents units to a given one, in the prefered order.
Find All unittypes equivalent to a given one
| unittype | the unittype to find equivalence for | |
| result | int array which will hold the result. (Size UnitTypeMax+1) |
Definition at line 108 of file ai_force.cpp.
References CUnitType::Slot, UnitTypeEquivs, and UnitTypeMax.
Referenced by AiFindAvailableUnitTypeEquiv(), AiReduceMadeInBuilt(), and AiRemoveFromBuilt().
| static void AiForceAttacks | ( | AiForce * | force | ) | [static] |
Force on attack ride. We attack until there is no unit or enemy left.
| force | Force pointer. |
Definition at line 479 of file ai_force.cpp.
References AiForce::Attacking, AttackUnitsInDistance(), CUnitType::CanAttack, CommandAttack(), CommandMove(), DebugPrint, FlushCommands, int(), CUnit::IsIdle(), MaxMapWidth, NoUnitP, CUnit::Orders, CUnit::Type, AiForce::Units, CUnit::X, CUnit::Y, and y.
Referenced by AiForceManager().
| void AiForceManager | ( | void | ) |
Entry point of force manager, perodic called.
Definition at line 565 of file ai_force.cpp.
References AI_MAX_ATTACKING_FORCES, AiAssignFreeUnitsToForce(), AiCleanForce(), AiForceAttacks(), AiPlayer, AiForce::Attacking, AttackUnitsInReactRange(), CUnitType::CanAttack, DebugPrint, AiForce::Defending, PlayerAi::Force, int(), CUnit::Type, and AiForce::Units.
Referenced by AiEachSecond().
Remove any equivalence between unittypes.
Make two unittypes equivalents from the AI's point of vue
| a | the first unittype | |
| b | the second unittype |
Definition at line 75 of file ai_force.cpp.
References CUnitType::Slot, UnitTypeEquivs, and UnitTypeMax.
Referenced by CclDefineAiHelper().
| void AiResetUnitTypeEquiv | ( | void | ) |
Finds all equivalents units to a given one.
Remove any equivalence between unittypes
Definition at line 62 of file ai_force.cpp.
References UnitTypeEquivs, and UnitTypeMax.
Referenced by FreeAi(), and InitAiModule().
| int UnitTypeEquivs[UnitTypeMax+1] |
equivalence between unittypes
Definition at line 52 of file ai_force.cpp.
Referenced by AiCheckBelongsToForce(), AiCleanForce(), AiFindUnitTypeEquiv(), AiNewUnitTypeEquiv(), AiResetUnitTypeEquiv(), and CclAiForce().
1.5.6