forked from ike3/mangosbot-bots
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFleeManager.h
65 lines (50 loc) · 1.45 KB
/
FleeManager.h
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
#pragma once
#include "WorldPosition.h"
using namespace std;
class Player;
namespace ai
{
class Engine;
class FleePoint {
public:
FleePoint(PlayerbotAI* ai, float x, float y, float z) : ai(ai), sumDistance(0.0f), minDistance(0.0f) {
this->x = x;
this->y = y;
this->z = z;
}
public:
float x;
float y;
float z;
float sumDistance;
float minDistance;
private:
PlayerbotAI* ai;
};
class FleeManager
{
public:
FleeManager(Player* bot, float maxAllowedDistance, float followAngle, bool forceMaxDistance = false, WorldPosition startPosition = WorldPosition()) {
this->bot = bot;
this->maxAllowedDistance = maxAllowedDistance;
this->followAngle = followAngle;
this->forceMaxDistance = forceMaxDistance;
this->startPosition = startPosition ? startPosition : WorldPosition(bot);
}
public:
bool CalculateDestination(float* rx, float* ry, float* rz);
bool isUseful();
private:
void calculatePossibleDestinations(list<FleePoint*> &points);
void calculateDistanceToCreatures(FleePoint *point);
void cleanup(list<FleePoint*> &points);
FleePoint* selectOptimalDestination(list<FleePoint*> &points);
bool isBetterThan(FleePoint* point, FleePoint* other);
private:
Player* bot;
float maxAllowedDistance;
float followAngle;
bool forceMaxDistance;
WorldPosition startPosition;
};
};