forked from itslunaranyo/copper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw_rockets.qc
159 lines (128 loc) · 3.31 KB
/
w_rockets.qc
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
150
151
152
153
154
155
156
157
158
159
/*
===============
ROCKETS
===============
*/
void(vector org, float rad) T_GibDownedZombies =
{
if (rad < 72) return; // not a big enough blast
entity head;
head = findradiusplus(org + '0 0 16', rad, type, "zombie");
// look a little too high since we'll assume zombies are lower than their
// actual origin, which is 24u off the ground
while(head)
{
if ( head.customflags & CFL_KNOCKEDDOWN && // on ground
head.solid == SOLID_NOT && // can't be hurt otherwise
CanDamage(head, org) && // in sight
rad - vlen(head.origin - org) > 0.5 * head.health // close enough to hurt
)
{
T_Damage (head, self, self, head.health + 10);
}
head = head.chain;
}
}
// =======================================================
void() T_MissileExplode =
{
local float damg;
damg = 100 + random()*20;
if (other.health)
{
if (other.classname == "monster_shambler")
damg = damg * 0.5;
if (other.type == "zombie")
damg = max(damg, other.health + 25); // so ogre rockets kill zombies despite being too weak
T_Damage (other, self, self.trueowner, damg );
}
// don't do radius damage to other, because all damage will be done in the impact
T_RadiusDamage (self, self.trueowner, 120, other);
}
void() T_MissileTouch =
{
if (other == self.owner) return; // don't explode on owner
if (CheckProjectilePassthru()) return;
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
T_MissileExplode();
self.origin = self.origin - 8*normalize(self.velocity);
BecomeExplosion ();
}
/*
================
W_FireRocket
player rocket launch inherited from generic launch_rocket
================
*/
void() W_FireRocket =
{
local entity missile;
local vector loc;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
makevectors (self.v_angle);
loc = self.origin + v_forward * 8 + '0 0 16';
missile = launch_rocket( loc, v_forward * 1000 );
self.attack_finished = time + 0.8;
}
//=============================================================================
/*
===============
GERNADES
===============
*/
void() GrenadeExplode =
{
T_RadiusDamage (self, self.trueowner, 120, world);
//T_GibDownedZombies (self, 120);
BecomeExplosion ();
}
void() GrenadeTouch =
{
if (other == self.owner ) return; // don't explode on owner
if (CheckProjectilePassthru()) return;
if (other.takedamage == DAMAGE_AIM)
{
self.velocity = '0 0 0';
T_MissileExplode();
BecomeExplosion();
return;
}
sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
if (self.velocity == '0 0 0')
self.avelocity = '0 0 0';
}
/*
================
W_FireGrenade
================
*/
void() W_FireGrenade =
{
entity g;
float base;
vector gvel;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
// set grenade speed
makevectors (self.v_angle);
base = 200;
if (self.v_angle_x)
gvel = v_forward * base * 3 + v_up * base + crandom() * v_right * 10 + crandom() * v_up * 10;
else
{
gvel = aim(self, AUTOAIM_DIST);
gvel = gvel * base * 3;
gvel_z = base;
}
g = launch_grenade(self.origin, gvel);
self.attack_finished = time + 0.6;
g.touch = GrenadeTouch;
g.th_die = GrenadeExplode;
}