$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include "stratagus.h"
#include "ai_local.h"
#include "action/action_build.h"
#include "action/action_repair.h"
#include "action/action_resource.h"
#include "commands.h"
#include "depend.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
#include "unit.h"
#include "unit_find.h"
#include "unittype.h"
#include "upgrade.h"
Classes | |
class | IsAEnemyUnitOf |
class | IsAEnemyUnitWhichCanCounterAttackOf |
struct | cnode |
ai_resource.cpp - AI resource manager. | |
#define | COLLECT_RESOURCES_INTERVAL 4 |
static int | AiMakeUnit (CUnitType &type, const Vec2i &nearPos) |
static int | AiCheckCosts (const int *costs) |
static int | AiCheckSupply (const PlayerAi &pai, const CUnitType &type) |
static int | AiCheckUnitTypeCosts (const CUnitType &type) |
int | AiEnemyUnitsInDistance (const CPlayer &player, const CUnitType *type, const Vec2i &pos, unsigned range) |
int | AiEnemyUnitsInDistance (const CUnit &unit, unsigned range) |
static bool | IsAlreadyWorking (const CUnit &unit) |
static int | AiBuildBuilding (const CUnitType &type, CUnitType &building, const Vec2i &nearPos) |
static bool | AiRequestedTypeAllowed (const CPlayer &player, const CUnitType &type) |
static bool | cnode_cmp (const cnode &lhs, const cnode &rhs) |
int | AiGetBuildRequestsCount (const PlayerAi &pai, int(&counter)[UnitTypeMax]) |
CUnit * | FindDepositNearLoc (CPlayer &p, const Vec2i &pos, int range, int resource) |
void | AiNewDepotRequest (CUnit &worker) |
static bool | AiRequestSupply () |
static bool | AiTrainUnit (const CUnitType &type, CUnitType &what) |
static bool | AiResearchUpgrade (const CUnitType &type, CUpgrade &what) |
void | AiAddResearchRequest (CUpgrade *upgrade) |
Add research request to resource manager. | |
static bool | AiUpgradeTo (const CUnitType &type, CUnitType &what) |
void | AiAddUpgradeToRequest (CUnitType &type) |
Add upgrade-to request to resource manager. | |
static void | AiCheckingWork () |
static int | AiAssignHarvesterFromTerrain (CUnit &unit, int resource) |
static int | AiAssignHarvesterFromUnit (CUnit &unit, int resource) |
static int | AiAssignHarvester (CUnit &unit, int resource) |
static bool | CmpWorkers (const CUnit *lhs, const CUnit *rhs) |
static void | AiCollectResources () |
static bool | IsReadyToRepair (const CUnit &unit) |
static bool | AiRepairBuilding (const CPlayer &player, const CUnitType &type, CUnit &building) |
static int | AiRepairUnit (CUnit &unit) |
static void | AiCheckRepair () |
void | AiAddUnitTypeRequest (CUnitType &type, int count) |
Current AI player. | |
void | AiExplore (const Vec2i &pos, int mask) |
void | AiResourceManager () |
Periodic called resource manager handler. |
#define COLLECT_RESOURCES_INTERVAL 4 |
void AiAddResearchRequest | ( | CUpgrade * | upgrade | ) |
Add research request to resource manager.
Check if the research can be done.
upgrade | Upgrade to research |
void AiAddUnitTypeRequest | ( | CUnitType & | type, | |
int | count | |||
) |
Current AI player.
Add unit-type request to resource manager.
type | Unit type requested. | |
count | How many units. |
void AiAddUpgradeToRequest | ( | CUnitType & | type | ) |
Add upgrade-to request to resource manager.
Check if the upgrade-to can be done.
type | FIXME: docu |
static int AiAssignHarvester | ( | CUnit & | unit, | |
int | resource | |||
) | [static] |
Assign worker to gather a certain resource.
unit | pointer to the unit. | |
resource | resource identification. |
static int AiAssignHarvesterFromTerrain | ( | CUnit & | unit, | |
int | resource | |||
) | [static] |
Assign worker to gather a certain resource from terrain.
unit | pointer to the unit. | |
resource | resource identification. |
static int AiAssignHarvesterFromUnit | ( | CUnit & | unit, | |
int | resource | |||
) | [static] |
Assign worker to gather a certain resource from Unit.
unit | pointer to the unit. | |
resource | resource identification. |
static int AiBuildBuilding | ( | const CUnitType & | type, | |
CUnitType & | building, | |||
const Vec2i & | nearPos | |||
) | [static] |
Check if we can build the building.
type | Unit that can build the building. | |
building | Building to be build. |
static int AiCheckCosts | ( | const int * | costs | ) | [static] |
Check if the costs are available for the AI.
Take reserve and already used resources into account.
costs | Costs for something. |
static void AiCheckingWork | ( | ) | [static] |
Check what must be built / trained.
static void AiCheckRepair | ( | ) | [static] |
Check if there's a unit that should be repaired.
Check if the AI player needs food.
It counts buildings in progress and units in training queues.
pai | AI player. | |
type | Unit-type that should be build. |
static int AiCheckUnitTypeCosts | ( | const CUnitType & | type | ) | [static] |
Check if the costs for an unit-type are available for the AI.
Take reserve and already used resources into account.
type | Unit-type to check the costs for. |
static void AiCollectResources | ( | ) | [static] |
Assign workers to collect resources.
If we have a shortage of a resource, let many workers collecting this. If no shortage, split workers to all resources.
int AiEnemyUnitsInDistance | ( | const CUnit & | unit, | |
unsigned | range | |||
) |
Enemy units in distance.
unit | Find in distance for this unit. | |
range | Distance range to look. |
int AiEnemyUnitsInDistance | ( | const CPlayer & | player, | |
const CUnitType * | type, | |||
const Vec2i & | pos, | |||
unsigned | range | |||
) |
Enemy units in distance.
player | Find enemies of this player | |
type | Optional unit type to check if enemy can target this | |
pos | location | |
range | Distance range to look. |
void AiExplore | ( | const Vec2i & | pos, | |
int | mask | |||
) |
Mark that a zone is requiring exploration.
pos | Pos of the zone | |
mask | Mask to explore ( land/sea/air ) |
int AiGetBuildRequestsCount | ( | const PlayerAi & | pai, | |
int(&) | counter[UnitTypeMax] | |||
) |
Check if we can make a unit-type.
type | Unit-type that must be made. |
void AiNewDepotRequest | ( | CUnit & | worker | ) |
static bool AiRepairBuilding | ( | const CPlayer & | player, | |
const CUnitType & | type, | |||
CUnit & | building | |||
) | [static] |
Check if we can repair the building.
type | Unit that can repair the building. | |
building | Building to be repaired. |
static int AiRepairUnit | ( | CUnit & | unit | ) | [static] |
Check if we can repair this unit.
unit | Unit that must be repaired. |
static bool AiRequestSupply | ( | ) | [static] |
Build new units to reduce the food shortage.
Check if we can research the upgrade.
type | Unit that can research the upgrade. | |
what | What should be researched. |
void AiResourceManager | ( | ) |
Periodic called resource manager handler.
Entry point of resource manager, periodically called.
Check if we can train the unit.
type | Unit that can train the unit. | |
what | What to be trained. |
Check if we can upgrade to unit-type.
type | Unit that can upgrade to unit-type | |
what | To what should be upgraded. |
static bool IsAlreadyWorking | ( | const CUnit & | unit | ) | [static] |
static bool IsReadyToRepair | ( | const CUnit & | unit | ) | [static] |