-
Notifications
You must be signed in to change notification settings - Fork 1
/
Healer.cpp
114 lines (107 loc) · 3.21 KB
/
Healer.cpp
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "Healer.h"
// to avoid any ambuguity in the equations of the healers it is assumed that healers cannot heal one another
// other wise the game will be biased towards the enemies
Healer::Healer(int id, int arrtime, int d) :Enemy(id, arrtime, d)
{
// possible to add a K memeber function in the future not sure
dir = 1;
}
Healer::Healer(int id, int type, int arr, int health, int power, int rld, int spd) : Enemy(id, type, arr, health, power, rld, spd)
{
// possible to add a K memeber function in the future not sure
dir = 1;
}
void Healer::Move(Battle* hot_battle)// the move function is diffenet when it comes to the healers they can go backwards aswell
{
int s = speed;
if (Health < (original_health / 2))
s = s / 2;
if (dir)
{
int currDistance = Distance - s;
if (currDistance < 2)
{
SetDistance(s - Distance + 4); // current +4 same
dir = 0; // change direction when a U turn happens
}
else
SetDistance(currDistance);
if (currDistance == 2)
dir = 0;
}
else
{
int currDistance = Distance + s;
if (currDistance > 60)
{
SetDistance(120 - s - Distance); //120 - current same
dir = 1;// change the diretion when a U turn happens
}
else
SetDistance(currDistance);
if (currDistance == 60)
dir = 1;
}
}
void Healer::Act(Battle* hot_battle)
{
int reload_current = this->get_reloadcounter();// get the reload time counter of the fihter
if (reload_current > 0 && status == ACTV) // Decrement reload counter only
{
reload_counter--;
return;
}
else if (reload_current == 0 && status == ACTV)
{
Enemy* temp;
temp = hot_battle->GetCurrentEnemy();
int diffDistance = temp->GetDistance() - Distance;
double ratio = 1;
if (Health < (original_health / 2))
ratio = 0.5;
// Increase Enemy's health by function
if (dir)
{
if (diffDistance == -2) // If Enemy is far then healing will be less effective
{
double healedHealth = temp->gethealth() + (power / (temp->gethealth() * 2)) * ratio;
if (healedHealth >= temp->getOriginalHealth())
temp->sethealth(temp->getOriginalHealth());
else
temp->sethealth(healedHealth);
}
else if (diffDistance == -1 || diffDistance == 0)
{
double healedHealth = temp->gethealth() + (power / (temp->gethealth())) * ratio;
if (healedHealth >= temp->getOriginalHealth())
temp->sethealth(temp->getOriginalHealth());
else
temp->sethealth(healedHealth);
}
}
else
{
if (diffDistance == 2) // If Enemy is far then healing will be less effective
{
double healedHealth = temp->gethealth() + (power / (temp->gethealth() * 2)) * ratio;
if (healedHealth >= temp->getOriginalHealth())
temp->sethealth(temp->getOriginalHealth());
else
temp->sethealth(healedHealth);
}
else if (diffDistance == 1 || diffDistance == 0)
{
double healedHealth = temp->gethealth() + (power / (temp->gethealth())) * ratio;
if (healedHealth >= temp->getOriginalHealth())
temp->sethealth(temp->getOriginalHealth());
else
temp->sethealth(healedHealth);
}
}
reload_counter = reload_time; // Reset reload counter
}
}
int Healer::GETPERIORITY()
{
return 0;
}