-
Notifications
You must be signed in to change notification settings - Fork 0
/
zcannon.cpp
executable file
·75 lines (63 loc) · 1.36 KB
/
zcannon.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
#include "zcannon.h"
ZSDL_Surface ZCannon::init_place[3];
ZCannon::ZCannon(ZTime *ztime_, ZSettings *zsettings_) : ZObject(ztime_, zsettings_)
{
object_type = CANNON_OBJECT;
selectable = true;
can_be_sniped = true;
ejectable = true;
width = 2;
height = 2;
width_pix = 32;
height_pix = 32;
}
void ZCannon::Init()
{
int i;
char filename_c[500];
//load colors
for(i=0;i<3;i++)
{
sprintf(filename_c, "assets/units/cannons/init-place_n%02d.png", i);
init_place[i].LoadBaseImage(filename_c);// = IMG_Load_Error(filename_c);
}
}
void ZCannon::SetAttackObject(ZObject *obj)
{
attack_object = obj;
if(attack_object)
{
int tx, ty;
int new_dir;
attack_object->GetCenterCords(tx, ty);
new_dir = DirectionFromLoc(tx - loc.x, ty - loc.y);
if(new_dir != -1) direction = new_dir;
}
}
bool ZCannon::CanBeSniped()
{
return can_be_sniped && driver_info.size() && ejectable;
}
bool ZCannon::CanEjectDrivers()
{
//return true;
return ejectable;
}
void ZCannon::SetInitialDrivers()
{
if(owner != NULL_TEAM)
{
driver_type = GRUNT;
//AddDriver(GRUNT_MAX_HEALTH);
AddDriver(zsettings->GetUnitSettings(ROBOT_OBJECT, GRUNT).health * MAX_UNIT_HEALTH);
}
else
{
driver_type = GRUNT;
ClearDrivers();
}
}
void ZCannon::SetEjectableCannon(bool ejectable_)
{
ejectable = ejectable_;
}