1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
// -------------------------------------------------------------------------
// AAI
//
// A skirmish AI for the Spring engine.
// Copyright Alexander Seizinger
//
// Released under GPL license: see LICENSE.html for more information.
// -------------------------------------------------------------------------
#pragma once
#include "aidef.h"
#include "AAIBrain.h"
#include "AAIExecute.h"
#include "AAISector.h"
#include "AAIBuildTable.h"
#include "AAIGroup.h"
#include "AAIBuildTask.h"
#include "AAIUnitTable.h"
#include "AAIMap.h"
#include "AAIAirForceManager.h"
#include "AAIAttackManager.h"
#include "AAIConstructor.h"
#include <math.h>
using namespace std;
class AAIExecute;
class Profiler;
class AAI : public IGlobalAI
{
public:
AAI();
virtual ~AAI();
void InitAI(IGlobalAICallback* callback, int team);
void UnitCreated(int unit, int builder); //called when a new unit is created on ai team
void UnitFinished(int unit); //called when an unit has finished building
void UnitIdle(int unit); //called when a unit go idle and is not assigned to any group
void UnitDestroyed(int unit, int attacker); //called when a unit is destroyed
void UnitDamaged(int damaged,int attacker,float damage,float3 dir); //called when one of your units are damaged
void UnitMoveFailed(int unit);
void EnemyEnterLOS(int enemy);
void EnemyLeaveLOS(int enemy);
void EnemyEnterRadar(int enemy); //called when an enemy enters radar coverage (not called if enemy go directly from not known -> los)
void EnemyLeaveRadar(int enemy); //called when an enemy leaves radar coverage (not called if enemy go directly from inlos -> now known)
void RecvChatMessage(const char* msg,int player) {} //called when someone writes a chat msg
void RecvLuaMessage(const char* inData, const char** outData) {}
void EnemyDamaged(int damaged,int attacker,float damage,float3 dir); //called when an enemy inside los or radar is damaged
void EnemyDestroyed(int enemy, int attacker);
int HandleEvent(int msg, const void *data);
// called every frame
void Update();
Profiler* GetProfiler();
// callbacks
IAICallback* cb;
IGlobalAICallback* aicb;
// side 1= arm, 2 = core, 0 = neutral
int side;
// if there is more than one instance of AAI, make sure to allocate/free memory only once
int aai_instance;
// list of buildtasks
list<AAIBuildTask*> build_tasks;
AAIBrain *brain; // makes decisions
AAIExecute *execute; // executes all kinds of tasks
AAIUnitTable *ut; // unit table
AAIBuildTable *bt; // buildtable for the different units
AAIMap *map; // keeps track of all constructed buildings and searches new constr. sites
AAIAirForceManager *af; // coordinates the airforce
AAIAttackManager *am; // coordinates combat forces
vector<list<AAIGroup*> > group_list; // unit groups
bool initialized;
FILE *file;
private:
Profiler* profiler;
};
|