-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattacker.cpp
More file actions
47 lines (42 loc) · 879 Bytes
/
Copy pathattacker.cpp
File metadata and controls
47 lines (42 loc) · 879 Bytes
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
#include "attacker.h"
bool Attacker::commitMove(Pawn* p)
{
std::string sound_effect = "shooting_sound.wav";
float r = std::rand() % 100;
int d = damage;
if (getTeamName() != p->getTeamName()) {
if (get_p_id() == 1)//Buff Guy
{
if (p->get_hp() * 2 <= p->get_init_hp() && r < get_probability())
{
d = -p->get_hp();
}
}
else if (get_p_id() == 2)//Gladiator
{
if (r <= get_probability())
{
d = special_damage;
}
}
else if (get_p_id() == 3)//Archer
{
if (r <= get_probability())
{
d = -std::rand() % 5;
if (d == 0) { sound_effect = "miss.wav"; }
}
}
else if (get_p_id() == 4)//Tank
{
set_probability(1 / (13 - get_hp()) * 100);
if (r < get_probability())
{
d = special_damage;
}
}
p->alterHP(d);
graphics::playSound(std::string(ASSET_PATH) + sound_effect, 0.5, false);
return true;
}
}