30 #ifndef __AI_LOCAL_H__
31 #define __AI_LOCAL_H__
110 #define AI_WAIT_ON_RALLY_POINT 60
132 InternalRemoveUnit(&unit);
169 void CountTypes(
unsigned int *counter,
const size_t len);
174 static void InternalRemoveUnit(
CUnit *unit);
194 #define AI_MAX_FORCES 50
195 #define AI_MAX_FORCE_INTERNAL (AI_MAX_FORCES / 2)
207 inline size_t Size()
const {
return forces.size(); }
214 for (
unsigned int i = 0; i < forces.size(); ++i) {
215 if (force == &forces[i]) {
224 if (script[index] == -1) {
227 return script[index];
237 std::vector<AiForce> forces;
335 std::vector<std::vector<CUnitType *> >
Train;
340 std::vector<std::vector<CUnitType *> >
Build;
345 std::vector<std::vector<CUnitType *> >
Upgrade;
355 std::vector<std::vector<CUnitType *> >
Repair;
365 std::vector<std::vector<CUnitType *> >
Equiv;
377 std::vector<std::vector<CUnitType *> >
Depots;
384 extern std::vector<CAiType *>
AiTypes;
455 const Vec2i &pos,
unsigned range);
465 #endif // !__AI_LOCAL_H__
Vec2i GoalPos
Attack state.
Definition: ai_local.h:188
unsigned int Made
requested number
Definition: ai_local.h:256
bool NeedSupply
Mask for needed resources.
Definition: ai_local.h:307
bool Attacking
Flag saying force is defending.
Definition: ai_local.h:179
#define AI_WAIT_ON_RALLY_POINT
Definition: ai_local.h:110
void AiRemoveDeadUnitInForces()
Cleanup units in force.
Definition: ai_force.cpp:626
So default is attacking.
Definition: ai_local.h:97
AiForceAttackingState
Definition: ai_local.h:101
Definition: ai_local.h:103
void Update()
Definition: ai_force.cpp:1056
std::string Script
AI type of this player AI.
Definition: ai_local.h:296
int Mask
pos on map
Definition: ai_local.h:272
Definition: ai_local.h:246
resource 6
Definition: upgrade_structs.h:70
unsigned int getScriptForce(unsigned int index)
Definition: ai_local.h:222
AiForceAttackingState State
Original force number.
Definition: ai_local.h:187
Force should attack.
Definition: ai_local.h:98
std::string Script
class of this ai
Definition: ai_local.h:65
void Insert(CUnit &unit)
Definition: ai_force.cpp:284
AiForce & operator[](unsigned int index)
Definition: ai_local.h:210
T y
Definition: vec2i.h:43
CAiType()
Definition: ai_local.h:60
int WaitOnRallyPoint
Return after attack tile map position.
Definition: ai_local.h:190
void ReturnToHome()
Definition: ai_force.cpp:468
void AiAttackWithForce(unsigned int force)
Attack with force.
Definition: ai_force.cpp:687
int AiGetBuildRequestsCount(const PlayerAi &pai, int(&counter)[UnitTypeMax])
Definition: ai_resource.cpp:339
bool Defending
Flag saying force is complete build.
Definition: ai_local.h:178
bool AiFindBuildingPlace(const CUnit &worker, const CUnitType &type, const Vec2i &nearPos, Vec2i *resultPos)
Find nice building place.
Definition: ai_building.cpp:433
std::string Class
for this race
Definition: ai_local.h:64
int GetForce(const CUnit &unit)
Definition: ai_force.cpp:514
The big unit structure.
Definition: unit.h:119
std::vector< std::vector< CUnitType * > > UnitLimit
Definition: ai_local.h:360
Definition: ai_local.h:104
size_t size() const
Definition: unit_cache.h:59
int Collect[MaxCosts]
Needed resources.
Definition: ai_local.h:305
std::vector< std::vector< CUnitType * > > Research
Definition: ai_local.h:350
std::vector< std::vector< CUnitType * > > Refinery
Definition: ai_local.h:371
Definition: ai_local.h:117
Definition: ai_local.h:107
Vec2i HomePos
Attack point tile map position.
Definition: ai_local.h:189
void AiCheckMagic()
Check for magic.
Definition: ai_magic.cpp:51
void AiForceManager()
Periodic called force manager handler.
Definition: ai_force.cpp:1129
void AiAddUpgradeToRequest(CUnitType &type)
Add upgrade-to request to resource manager.
Definition: ai_resource.cpp:806
void Remove(CUnit &unit)
Definition: ai_local.h:129
int UnitTypeEquivs[UnitTypeMax+1]
AI helper variables.
Definition: ai_force.cpp:125
void AiAssignFreeUnitsToForce(int force=-1)
Assign a free units to a force.
Definition: ai_force.cpp:644
std::vector< AiBuildQueue > UnitTypeBuilt
Upgrades requested and priority list.
Definition: ai_local.h:317
PlayerAi()
Definition: ai_local.h:281
void AiAttackWithForces(int *forces)
Attack with forces in array.
Definition: ai_force.cpp:732
const AiForce & operator[](unsigned int index) const
Definition: ai_local.h:209
bool AiAssignToForce(CUnit &unit)
Assign a new unit to a force.
Definition: ai_force.cpp:636
void RemoveDeadUnit()
Definition: ai_force.cpp:300
CUnit * AiGetSuitableDepot(const CUnit &worker, const CUnit &oldDepot, CUnit **resUnit)
Definition: ai_resource.cpp:463
AiForceManager()
Definition: ai_force.cpp:485
CUnitCache Units
Count and types of unit-type.
Definition: ai_local.h:183
bool ScriptDebug
Flag need food.
Definition: ai_local.h:308
int Used[MaxCosts]
Resources to keep in reserve.
Definition: ai_local.h:303
Definition: unittype.h:467
Definition: ai_local.h:328
void CheckUnits(int *counter)
Definition: ai_force.cpp:575
std::vector< CUnitType * > UpgradeToRequests
unit-types to build/train request,priority list
Definition: ai_local.h:315
int getIndex(AiForce *force) const
Definition: ai_local.h:212
AiUnitType()
Definition: ai_local.h:86
CPlayer * Player
Definition: ai_local.h:293
std::vector< CUpgrade * > ResearchRequests
Upgrade to unit-type requested and priority list.
Definition: ai_local.h:316
void Attack(const Vec2i &pos)
Definition: ai_force.cpp:368
std::vector< std::vector< CUnitType * > > Repair
Definition: ai_local.h:355
void AiResourceManager()
Periodic called resource manager handler.
Definition: ai_resource.cpp:1456
AiForce()
Definition: ai_local.h:121
void RemoveDeadUnit()
Definition: ai_force.cpp:533
unsigned long SleepCycles
Script executed.
Definition: ai_local.h:297
int AiFindUnitTypeEquiv(const CUnitType &type, int *result)
Finds all equivalents units to a given one.
Definition: ai_force.cpp:174
Definition: ai_local.h:106
unsigned int Want
Definition: ai_local.h:255
AiForceRole
Definition: ai_local.h:95
AiBuildQueue()
Definition: ai_local.h:249
CAiType * AiType
Engine player structure.
Definition: ai_local.h:294
int NeededMask
Collect % of resources.
Definition: ai_local.h:306
Definition: ai_local.h:83
std::vector< std::vector< CUnitType * > > Upgrade
Definition: ai_local.h:345
Vec2i pos
Definition: ai_local.h:271
CUnitType * Type
number of this unit-type wanted
Definition: ai_local.h:89
std::vector< AiUnitType > UnitTypes
Role of the force.
Definition: ai_local.h:182
Definition: ai_local.h:71
Definition: ai_local.h:102
Vec2i Pos
wait until this cycle
Definition: ai_local.h:259
unsigned int FindFreeForce(AiForceRole role=AiForceRoleDefault, int begin=0)
Definition: ai_force.cpp:491
void for_each(const _T functor)
Apply a function to every element of a cache.
Definition: unit_cache.h:102
std::string Race
Name of this ai.
Definition: ai_local.h:63
bool Completed
Definition: ai_local.h:177
unsigned long Wait
unit-type
Definition: ai_local.h:258
unsigned long LastCanNotMoveGameCycle
When did the last explore occur?
Definition: ai_local.h:313
AiForceManager Force
Cycles to sleep.
Definition: ai_local.h:299
unsigned int Count
Definition: ai_local.h:76
Definition: ai_local.h:278
std::vector< CAiType * > AiTypes
Ai sleeps # cycles.
Definition: ai.cpp:164
Definition: unit_cache.h:50
AiRequestType()
Definition: ai_local.h:74
AiForceRole Role
Flag saying force is attacking.
Definition: ai_local.h:180
size_t Size() const
Definition: ai_local.h:156
void AiNewUnitTypeEquiv(const CUnitType &a, const CUnitType &b)
Make two unittypes be considered equals.
Definition: ai_force.cpp:147
T x
Definition: vec2i.h:42
Diplomacy states for CommandDiplomacy.
Definition: player.h:79
void AiExplore(const Vec2i &pos, int exploreMask)
Ask the ai to explore around pos.
Definition: ai_resource.cpp:1441
int FormerForce
Units in the force.
Definition: ai_local.h:186
unsigned long LastExplorationGameCycle
Requests for exploration.
Definition: ai_local.h:312
void AiSendExplorers()
Definition: ai_plan.cpp:503
std::vector< AiExplorationRequest > FirstExplorationRequest
Build new depots if nessesary.
Definition: ai_local.h:311
CUnitType * Type
built number
Definition: ai_local.h:257
void clear()
Definition: unit_cache.h:61
int LastRepairBuilding
What the resource manager should build.
Definition: ai_local.h:318
bool BuildDepots
Flag script debuging on/off.
Definition: ai_local.h:309
PlayerAi * AiPlayer
equivalence between unittypes
Definition: ai.cpp:167
Definition: ai_local.h:105
int AiEnemyUnitsInDistance(const CPlayer &player, const CUnitType *type, const Vec2i &pos, unsigned range)
Enemy units in distance.
Definition: ai_resource.cpp:209
bool Assign(CUnit &unit, int force=-1)
Definition: ai_force.cpp:545
std::string Name
Definition: ai_local.h:62
int Needed[MaxCosts]
Used resources.
Definition: ai_local.h:304
int Reserve[MaxCosts]
Forces controlled by AI.
Definition: ai_local.h:302
Definition: upgrade_structs.h:154
std::vector< std::vector< CUnitType * > > Equiv
Definition: ai_local.h:365
Definition: ai_local.h:265
std::vector< AiRequestType > UnitTypeRequests
Last can not move cycle.
Definition: ai_local.h:314
size_t Size() const
Definition: ai_local.h:207
std::vector< std::vector< CUnitType * > > Train
Definition: ai_local.h:335
CUnitType * Type
elements in table
Definition: ai_local.h:77
int AiFindAvailableUnitTypeEquiv(const CUnitType &type, int *result)
Finds all available equivalents units to a given one, in the preferred order.
Definition: ai_force.cpp:207
#define AI_MAX_FORCES
Definition: ai_local.h:194
void AiAttackWithForceAt(unsigned int force, int x, int y)
Attack with force at position.
Definition: ai_force.cpp:665
Definition: ai_local.h:202
Definition: ai_local.h:96
bool NewRallyPoint(const Vec2i &startPos, Vec2i *resultPos)
Definition: ai_force.cpp:347
AiExplorationRequest(const Vec2i &pos, int mask)
Definition: ai_local.h:268
void AiResetUnitTypeEquiv()
Remove any equivalence between unittypes.
Definition: ai_force.cpp:134
int AiFindWall(AiForce *force)
Find a wall to attack.
Definition: ai_plan.cpp:184
void AiNewDepotRequest(CUnit &worker)
Definition: ai_resource.cpp:354
bool IsAttacking() const
Definition: ai_local.h:158
int PlanAttack()
Definition: ai_plan.cpp:343
std::vector< std::vector< CUnitType * > > Depots
Definition: ai_local.h:377
AiHelper AiHelpers
List of all AI types.
Definition: ai.cpp:165
#define UnitTypeMax
Definition: stratagus.h:158
std::vector< std::vector< CUnitType * > > Build
Definition: ai_local.h:340
Definition: ai_local.h:57
unsigned int Want
Definition: ai_local.h:88
void AiAddResearchRequest(CUpgrade *upgrade)
Add research request to resource manager.
Definition: ai_resource.cpp:737
void Reset(bool types=false)
Definition: ai_local.h:139
void AiAddUnitTypeRequest(CUnitType &type, int count)
Current AI player.
Definition: ai_resource.cpp:1425
CUnit * Remove(const unsigned int index)
Definition: unit_cache.h:140