forked from engineerOfLies/Game-Mod-Q4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTower.cpp
157 lines (106 loc) · 3.05 KB
/
Tower.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "game/Game_local.h"
#include "Tower.h"
CLASS_DECLARATION(idAI, rvTower)
END_CLASS
bool rvTower::healthRegenEnabled = FALSE;
bool rvTower::poisonIvy = FALSE;
int rvTower::regenTime = 3000;
int rvTower::poisonscale = 1;
int rvTower::maxHealth = 1000;
int rvTower::lvl = 1;
void rvTower::Spawn(void) {
health = spawnArgs.GetInt("health", "100");
fl.takedamage = true;
fl.solidForTeam = true;
BecomeSolid();
physicsObj.GetClipModel()->Link();
healthRegenNextTime = 0;
healthRegen = 15;
ActivatePhysics(this);
}
void rvTower::InitSpawnArgsVariables(void)
{
}
void rvTower::Think(void) {
idAI::Think();
//==================Tower Ability============================
if (health > 0 && health < maxHealth && healthRegenEnabled) {
if (gameLocal.GetTime() >= healthRegenNextTime) {
health += healthRegen;
healthRegenNextTime = gameLocal.GetTime() + regenTime;
}
}
}
void rvTower::Save(idSaveGame* savefile) const {
savefile->WriteInt(health);
}
void rvTower::Restore(idRestoreGame* savefile) {
savefile->ReadInt( health );
}
void rvTower::Damage(idEntity* inflictor, idEntity* attacker, const idVec3& dir, const char* damageDefName, const float damageScale, const int location)
{
idVec3 kick;
int damage;
idVec3 damage_from;
float attackerPushScale;
if (!fl.takedamage ) {
return;
}
if (attacker->IsType(idActor::GetClassType()) && static_cast<idActor*>(attacker)->team == team) {
return;
}
//EFFECTS; Could be added later (?) criipi
/*
if (damageDef->dict.GetBool("burn")) {
StartSound("snd_burn", SND_CHANNEL_BODY3, 0, false, NULL);
}
else if (damageDef->dict.GetBool("no_air")) {
if (!armorSave && health > 0) {
StartSound("snd_airGasp", SND_CHANNEL_ITEM, 0, false, NULL);
}
}
*/
const idDict* damageDef = gameLocal.FindEntityDefDict(damageDefName, false);
if (!damageDef) {
gameLocal.Error("Unknown damageDef '%s'", damageDefName);
}
damage = damageDef->GetInt("damage");
// do the damage
if (damage > 0) {
if (damage < 1) {
damage = 1;
}
health -= damage;
GAMELOG_ADD(va("Tower%d_damage_taken", entityNumber), damage);
GAMELOG_ADD(va("Tower%d_damage_%s", entityNumber, damageDefName), damage);
if (health <= 0) {
if (health < -999) {
health = -999;
}
lastDmgTime = gameLocal.time;
Killed(inflictor, attacker, damage, dir, location);
}
else {
// force a blink
blink_time = 0;
// let the anim script know we took damage
Pain(inflictor, attacker, damage, dir, location);
if (!g_testDeath.GetBool()) {
lastDmgTime = gameLocal.time;
}
}
}
//==================Tower Ability============================
if(poisonIvy)
{
attacker->Damage(inflictor, attacker, dir, damageDefName, poisonscale, location);
}
lastDamageDir = dir;
lastDamageDir.Normalize();
lastDamageLocation = location;
// gameLocal.Printf("damage:%i \n",damage);
//healthRegenEnabled ? gameLocal.Printf("true\n") : gameLocal.Printf("flase\n");
//gameLocal.Printf("Damage taken; Current Life %i\n", health);
}