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
|
#ifndef KAIK_ATTACKHANDLER_HDR
#define KAIK_ATTACKHANDLER_HDR
#include <list>
#include <utility>
#include <vector>
class CAttackGroup;
struct AIClasses;
class CAttackHandler {
public:
CR_DECLARE(CAttackHandler)
CAttackHandler(AIClasses* ai);
~CAttackHandler(void);
void AddUnit(int unitID);
void Update(int);
void UnitDestroyed(int unitID);
// K-means functions are placed here for now
std::vector<float3> KMeansIteration(std::vector<float3> means, std::vector<float3> unitPositions, int newK);
float DistanceToBase(float3 pos);
float3 GetClosestBaseSpot(float3 pos);
bool PlaceIdleUnit(int unit);
// for use for builders
bool IsSafeBuildSpot(float3 mypos);
float3 FindSafeSpot(float3 myPos, float minSafety, float maxSafety);
float3 FindSafeArea(float3 pos);
float3 FindVerySafeArea(float3 pos);
float3 FindUnsafeArea(float3 pos);
void AirAttack(int);
void AirPatrol(int);
void UpdateKMeans(void);
void UpdateAir(int);
void UpdateSea(int);
// nuke-related functions
void UpdateNukeSilos(int);
int PickNukeSiloTarget(std::vector<std::pair<int, float> >&);
void GetNukeSiloTargets(std::vector<std::pair<int, float> >&);
void AssignTargets(int);
void AssignTarget(CAttackGroup* group);
bool UnitGroundAttackFilter(int unit);
bool UnitBuildingFilter(const UnitDef* ud);
bool UnitReadyFilter(int unit);
void CombineGroups(void);
private:
AIClasses* ai;
std::list<int> attackUnits;
std::list< std::pair<int, float3> > stuckUnits;
// TODO: should be sets
std::list<int> unarmedAirUnits;
std::list<int> armedAirUnits;
bool airIsAttacking;
bool airPatrolOrdersGiven;
int airTarget;
int newGroupID;
std::list<CAttackGroup> attackGroups;
// std::list<CAttackGroup> defenseGroups;
std::vector<float3> kMeansBase;
std::vector<float3> kMeansEnemyBase;
int kMeansK;
int kMeansEnemyK;
};
#endif
|