-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathw_axe.qc
137 lines (116 loc) · 3.06 KB
/
w_axe.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
/*
===============
THE AXE
===============
*/
// SOUNDS
void() W_AxeWhiffSound =
{
sound (self, CHAN_OTHER, "weapons/ax1.wav", 1, ATTN_NORM);
}
void() W_AxeHitSound =
{
if (random() < 0.5)
sound (self, CHAN_WEAPON, "weapons/axhit1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_WEAPON, "weapons/axhit2.wav", 1, ATTN_NORM);
}
void(float foff) W_AxeCycle =
{
// lip and touch_time are overloaded on the player for animation event timing
// lip = 10fps player anim clock (axe animates at 20 so player has to think on 20s)
// touch_time = timer for the actual weapon attack trace event
self.weaponframe = min(57, self.weaponframe + foff);
// entire axe swing anim is scheduled to be done by now
if (self.attack_finished <= time)
{
// stop the player anim cycle and restore normal thinking
W_SetIdleWeaponFrame();
player_run();
return;
}
if (self.touch_time && self.touch_time <= time)
{
self.touch_time = 0;
W_FireAxe();
}
// time for a regular animation think
else if (self.lip <= time)
{
self.think1(); // advance the player anim on the standard 10fps clock
self.lip = time + 0.1;
}
self.nextthink = time + 0.05;
}
void() W_AxeThink = { self.think = W_AxeThink; W_AxeCycle(1); }
void() W_AxeThinkReverse = { self.think = W_AxeThinkReverse; W_AxeCycle(-1); }
void() W_AxeSwing =
{
W_AxeWhiffSound();
self.weaponframe = 10 * (floor(4.99 * random()));
self.touch_time = time + 0.1;
self.attack_finished = time + 0.49;
self.think1 = player_axe;
W_AxeThink();
}
/*
================
W_FireAxe
================
*/
void() W_FireAxe =
{
vector source, org;
if (self.health <= 0)
return;
makevectors (self.v_angle);
source = self.origin + self.view_ofs;//'0 0 16';
traceline2(source, source + v_forward * (64), self, 0);
if (trace_ent == self)
return; // some notrace shit happened
if (trace_fraction == 1.0)
return;
self.show_hostile = time + 1; // wake monsters up
org = trace_endpos - v_forward*4;
if (trace_ent.takedamage)
{
trace_ent.customflags = trace_ent.customflags | CFL_AXEHITME;
SpawnBlood (org, '0 0 0', 20);
T_Damage (trace_ent, self, self, 24, DMGTYPE_MELEE);
if (trace_ent.flags & FL_MONSTER)
{
if (trace_ent.type == "zombie")
zombie_knockdown(trace_ent);
W_AxeHitSound();
}
else
{
sound (self, CHAN_WEAPON, "zombie/z_hit.wav", 1, ATTN_IDLE);
}
// do knockback with a quad
if (has_quad(self))
{
if ((trace_ent.movetype == MOVETYPE_STEP || trace_ent.movetype == MOVETYPE_WALK) &&
// don't swat bosses or other non-standard-sized enemies around
trace_ent.maxs_x <= 32 && trace_ent.health > 0 && trace_ent.type != "boss")
{
local vector toss;
toss = v_forward;
toss_z = 0;
toss = normalize(toss) * 400;
toss_z = 100;
//bprint(vtos(toss));
//bprint("\n");
//toss *= - vlen(head.maxs - head.mins)
trace_ent.origin_z = trace_ent.origin_z + 1;
trace_ent.velocity = toss;
trace_ent.flags = not(trace_ent.flags, FL_ONGROUND);
}
}
}
else
{ // hit wall
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
gunshot(org);
}
}