-
Notifications
You must be signed in to change notification settings - Fork 0
/
Heal.cpp
37 lines (33 loc) · 1.05 KB
/
Heal.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
#include "Mobile.hpp"
#include "Alien.hpp"
#include "Heal.hpp"
#define DEBUG_HEAL
#ifdef DEBUG_HEAL
# include <iostream>
#endif
Heal::Heal(std::string name, Mobile *character, Mobile *target, double healTime, double healRadius) :
Void(name),
character(character),
target(target),
healTime(healTime),
healRadius(healRadius),
accum(0)
{}
void Heal::run(unsigned int ticks, unsigned int delta_ticks) {
Alien *a;
if (!(character)->active) {
if((this->accum +=delta_ticks) >= healTime) {
character->active = true;
this->accum = 0;
}
}
else {
if ((target->pos - character->pos).length() < healRadius) {
if ((a = dynamic_cast<Alien *>(target)) != NULL) {
a->hp += 20;
if (a->hp > 100) a->hp = 100;
character->active = false;
}
}
}
}