$treeview $search $mathjax
Stratagus
2.2.6
$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 <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "unit.h"
#include "unittype.h"
#include "upgrade.h"
#include "map.h"
#include "pathfinder.h"
#include "ai_local.h"
#include "actions.h"
#include "player.h"
#include "depend.h"
Classes | |
struct | cnode |
ai_resource.cpp - AI resource manager. | |
#define | COLLECT_RESOURCES_INTERVAL 4 |
static int | AiMakeUnit (CUnitType &type, int near_x, int near_y) |
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 int | AiBuildBuilding (const CUnitType &type, CUnitType &building, int near_x, int near_y) |
static bool | AiRequestedTypeAllowed (const CPlayer &player, const CUnitType &type) |
static int | cnode_cmp (const void *const t0, const void *const t1) |
int | AiGetBuildRequestsCount (PlayerAi *pai, int counter[UnitTypeMax]) |
CUnit * | FindDepositNearLoc (CPlayer &p, const Vec2i &pos, int range, int resource) |
void | AiNewDepotRequest (CUnit &worker) |
static bool | AiRequestSupply () |
static int | AiTrainUnit (const CUnitType &type, CUnitType &what) |
static int | AiResearchUpgrade (const CUnitType &type, CUpgrade *what) |
void | AiAddResearchRequest (CUpgrade *upgrade) |
Add research request to resource manager. | |
static int | AiUpgradeTo (const CUnitType &type, CUnitType &what) |
void | AiAddUpgradeToRequest (CUnitType &type) |
Add upgrade-to request to resource manager. | |
static void | AiCheckingWork () |
static int | AiAssignHarvester (CUnit &unit, int resource) |
static int | CmpWorkers (const void *w0, const void *w1) |
static void | AiCollectResources () |
static int | AiRepairBuilding (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 AiBuildBuilding | ( | const CUnitType & | type, | |
CUnitType & | building, | |||
int | near_x, | |||
int | near_y | |||
) | [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 | ( | PlayerAi * | pai, | |
int | counter[UnitTypeMax] | |||
) |
static int AiMakeUnit | ( | CUnitType & | typeToMake, | |
int | near_x, | |||
int | near_y | |||
) | [static] |
Check if we can make a unit-type.
type | Unit-type that must be made. |
void AiNewDepotRequest | ( | CUnit & | worker | ) |
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 int CmpWorkers | ( | const void * | w0, | |
const void * | w1 | |||
) | [static] |
static int cnode_cmp | ( | const void *const | t0, | |
const void *const | t1 | |||
) | [static] |