1
2/*
3==============================================================================
4
5PLAYER
6
7==============================================================================
8*/
9
10$cd id1/models/player_4
11$origin 0 -6 24
12$base base
13$skin skin
14
15//
16// running
17//
18$frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6
19
20$frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6
21
22//
23// standing
24//
25$frame stand1 stand2 stand3 stand4 stand5
26
27$frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6
28$frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12
29
30
31//
32// pain
33//
34$frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6
35
36$frame pain1 pain2 pain3 pain4 pain5 pain6
37
38
39//
40// death
41//
42
43$frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6
44$frame axdeth7 axdeth8 axdeth9
45
46$frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8
47$frame deatha9 deatha10 deatha11
48
49$frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
50$frame deathb9
51
52$frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
53$frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15
54
55$frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7
56$frame deathd8 deathd9
57
58$frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7
59$frame deathe8 deathe9
60
61//
62// attacks
63//
64$frame nailatt1 nailatt2
65
66$frame light1 light2
67
68$frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6
69
70$frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6
71
72$frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6
73
74$frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
75
76$frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
77
78$frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6
79
80
81/*
82==============================================================================
83PLAYER
84==============================================================================
85*/
86
87.float playermovestate, playermovebegin;
88
89void() player_move = [$stand1, player_move]
90{
91	local float m, n, t;
92
93	m = (self.velocity_x || self.velocity_y) + (self.weapon == IT_WEAPON1) * 2;
94	if (m != self.playermovestate)
95		self.playermovebegin = time;
96	self.playermovestate = m;
97
98	if (m == 0) {n =  5;self.frame = $stand1;  } // gun stand
99	else if (m == 1) {n =  6;self.frame = $rockrun1;} // gun run
100	else if (m == 2) {n = 12;self.frame = $axstnd1; } // axe stand
101	else             {n =  6;self.frame = $axrun1;  } // axe run
102
103	t = (time - self.playermovebegin) * 10;
104	t = t - (floor(t / n) * n);
105	self.frame = floor(self.frame + t);
106};
107
108void() player_movestart =
109{
110	self.playermovebegin = time;
111	self.playermovestate = -1;
112	player_move();
113};
114
115void() W_FireAxe;
116void()	player_axe1		=	[$axatt1	, player_axe2		] {};
117void()	player_axe2		=	[$axatt2	, player_axe3		] {};
118void()	player_axe3		=	[$axatt3	, player_axe4		] {W_FireAxe();};
119void()	player_axe4		=	[$axatt4	, player_movestart	] {};
120
121void()	player_axeb1	=	[$axattb1	, player_axeb2		] {};
122void()	player_axeb2	=	[$axattb2	, player_axeb3		] {};
123void()	player_axeb3	=	[$axattb3	, player_axeb4		] {W_FireAxe();};
124void()	player_axeb4	=	[$axattb4	, player_movestart	] {};
125
126void()	player_axec1	=	[$axattc1	, player_axec2		] {};
127void()	player_axec2	=	[$axattc2	, player_axec3		] {};
128void()	player_axec3	=	[$axattc3	, player_axec4		] {W_FireAxe();};
129void()	player_axec4	=	[$axattc4	, player_movestart	] {};
130
131void()	player_axed1	=	[$axattd1	, player_axed2		] {};
132void()	player_axed2	=	[$axattd2	, player_axed3		] {};
133void()	player_axed3	=	[$axattd3	, player_axed4		] {W_FireAxe();};
134void()	player_axed4	=	[$axattd4	, player_movestart	] {};
135
136void()	player_shot1	=	[$shotatt1	, player_shot2		] {};
137void()	player_shot2	=	[$shotatt2	, player_shot3		] {};
138void()	player_shot3	=	[$shotatt3	, player_shot4		] {};
139void()	player_shot4	=	[$shotatt4	, player_shot5		] {};
140void()	player_shot5	=	[$shotatt5	, player_shot6		] {};
141void()	player_shot6	=	[$shotatt6	, player_movestart	] {};
142
143void()	player_nail1	=	[$nailatt1	, player_movestart	] {self.frame = $nailatt1 + ((self.weaponframe - 1) & 1);};
144
145void()	player_rocket1	=	[$rockatt1	, player_rocket2	] {};
146void()	player_rocket2	=	[$rockatt2	, player_rocket3	] {};
147void()	player_rocket3	=	[$rockatt3	, player_rocket4	] {};
148void()	player_rocket4	=	[$rockatt4	, player_rocket5	] {};
149void()	player_rocket5	=	[$rockatt5	, player_rocket6	] {};
150void()	player_rocket6	=	[$rockatt6	, player_movestart	] {};
151
152void()	player_light1	=	[$light1	, player_movestart	] {self.frame = $light1 + ((self.weaponframe - 1) & 1);};
153
154//============================================================================
155
156void(float damgtype) PainSound =
157{
158	local float rs;
159
160	if (self.health < 1)
161		return;
162
163	// water pain sounds
164	if (self.watertype == CONTENT_WATER && self.waterlevel == 3)
165	{
166		self.bubble_count = self.bubble_count + 1;
167		if (random() > 0.5)
168			sound (self, CHAN_VOICE, "player/drown1.wav", 1, ATTN_NORM);
169		else
170			sound (self, CHAN_VOICE, "player/drown2.wav", 1, ATTN_NORM);
171		return;
172	}
173
174	// slime pain sounds
175	if (self.watertype == CONTENT_SLIME)
176	{
177		if (random() > 0.5)
178			sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
179		else
180			sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
181		return;
182	}
183
184	if (self.watertype == CONTENT_LAVA)
185	{
186		if (random() > 0.5)
187			sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
188		else
189			sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
190		return;
191	}
192
193	if (self.pain_finished > time)
194		return;
195	self.pain_finished = time + 0.3;
196
197	// don't make multiple pain sounds right after each other
198
199	// ax pain sound
200	if (damgtype & DTF_AXHIT)
201	{
202		sound (self, CHAN_VOICE, "player/axhit1.wav", 1, ATTN_NORM);
203		return;
204	}
205
206
207	rs = random() * 6;
208
209	if (rs < 1)
210		sound (self, CHAN_VOICE, "player/pain1.wav", 1, ATTN_NORM);
211	else if (rs < 2)
212		sound (self, CHAN_VOICE, "player/pain2.wav", 1, ATTN_NORM);
213	else if (rs < 3)
214		sound (self, CHAN_VOICE, "player/pain3.wav", 1, ATTN_NORM);
215	else if (rs < 4)
216		sound (self, CHAN_VOICE, "player/pain4.wav", 1, ATTN_NORM);
217	else if (rs < 5)
218		sound (self, CHAN_VOICE, "player/pain5.wav", 1, ATTN_NORM);
219	else
220		sound (self, CHAN_VOICE, "player/pain6.wav", 1, ATTN_NORM);
221
222	return;
223};
224
225void()	player_pain1	= [$pain1	, player_pain2		] {};
226void()	player_pain2	= [$pain2	, player_pain3		] {};
227void()	player_pain3	= [$pain3	, player_pain4		] {};
228void()	player_pain4	= [$pain4	, player_pain5		] {};
229void()	player_pain5	= [$pain5	, player_pain6		] {};
230void()	player_pain6	= [$pain6	, player_movestart	] {};
231
232void()	player_axpain1	= [$axpain1	, player_axpain2	] {};
233void()	player_axpain2	= [$axpain2	, player_axpain3	] {};
234void()	player_axpain3	= [$axpain3	, player_axpain4	] {};
235void()	player_axpain4	= [$axpain4	, player_axpain5	] {};
236void()	player_axpain5	= [$axpain5	, player_axpain6	] {};
237void()	player_axpain6	= [$axpain6	, player_movestart	] {};
238
239void(entity attacker, float damage, float damgtype, string dethtype) player_pain =
240{
241	if (damage < 5) // ignore
242		return;
243
244	if (self.deadflag)
245		return; // dead
246
247	PainSound(damgtype);
248
249	if (self.think != player_move)
250		return;
251
252	if (self.invisible_finished > time)
253		return;		// eyes don't have pain frames
254
255	if (self.weapon == IT_WEAPON1)
256		player_axpain1 ();
257	else
258		player_pain1 ();
259};
260
261void() player_diea1;
262void() player_dieb1;
263void() player_diec1;
264void() player_died1;
265void() player_diee1;
266void() player_die_ax1;
267
268void() DeathSound =
269{
270	local float rs, p;
271
272	// water death sounds
273	p = pointcontents(self.origin + '0 0 22');
274	if (p == CONTENT_SLIME || p == CONTENT_WATER)
275	{
276		self.bubble_count = self.bubble_count + 20;
277		sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE);
278		return;
279	}
280
281	rs = random() * 5;
282	if (rs < 1)
283		sound (self, CHAN_VOICE, "player/death1.wav", 1, ATTN_NONE);
284	else if (rs < 2)
285		sound (self, CHAN_VOICE, "player/death2.wav", 1, ATTN_NONE);
286	else if (rs < 3)
287		sound (self, CHAN_VOICE, "player/death3.wav", 1, ATTN_NONE);
288	else if (rs < 4)
289		sound (self, CHAN_VOICE, "player/death4.wav", 1, ATTN_NONE);
290	else
291		sound (self, CHAN_VOICE, "player/death5.wav", 1, ATTN_NONE);
292	return;
293};
294
295
296void() PlayerDead =
297{
298	self.nextthink = -1;
299// allow respawn after a certain time
300	self.deadflag = DEAD_DEAD;
301};
302
303void() GibPlayer =
304{
305	PlayerGibs("progs/h_player.mdl", 6, "", 0, "", 0);
306
307	self.deadflag = DEAD_DEAD;
308
309	if (self.deathtype == "TELEFRAG" || self.deathtype == "TRIEDTOTELEFRAG")
310	{
311		sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
312		return;
313	}
314
315	if (random() < 0.5)
316		sound (self, CHAN_VOICE, "player/gib.wav", 1, ATTN_NONE);
317	else
318		sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NONE);
319};
320
321void() PlayerDie =
322{
323	local float i;
324
325	if (self.deadflag)
326	{
327		bprint("warning: PlayerDie called twice\n");
328		return;
329	}
330
331	if (deathmatch || coop)
332		DropBackpack();
333
334	self.items = self.items - (self.items & IT_INVISIBILITY);
335	self.invisible_finished = 0;	// don't die as eyes
336	self.invincible_finished = 0;
337	self.super_damage_finished = 0;
338	self.radsuit_finished = 0;
339
340	self.weaponmodel="";
341	self.view_ofs = '0 0 -8';
342	self.deadflag = DEAD_DYING;
343	self.solid = SOLID_CORPSE;
344	self.flags = self.flags - (self.flags & FL_ONGROUND);
345	self.movetype = MOVETYPE_TOSS;
346	if (self.velocity_z < 10)
347		self.velocity_z = self.velocity_z + random()*300;
348
349	DeathSound();
350
351	self.angles_x = 0;
352	self.angles_z = 0;
353	self.avelocity = '0 0 0';
354	setmodel(self, "progs/player.mdl");
355
356	if (self.weapon == IT_WEAPON1)
357		BecomeCorpse(self, player_die_ax1);
358	else
359	{
360		i = random() * 5;
361
362		if (i < 1) BecomeCorpse(self, player_diea1);
363		else if (i < 2) BecomeCorpse(self, player_dieb1);
364		else if (i < 3) BecomeCorpse(self, player_diec1);
365		else if (i < 4) BecomeCorpse(self, player_died1);
366		else            BecomeCorpse(self, player_diee1);
367	}
368};
369
370void() player_suicideframe = [$deatha11, player_suicideframe] {body_nonsolid('-16 -16 -24', '16 16 0');PlayerDead();};
371
372void() set_suicide_frame =
373{
374	// used by kill and disconnect commands
375	if (self.deadflag >= DEAD_DEAD)
376		return; // already dead
377	self.items = self.items - (self.items & IT_INVISIBILITY);
378	self.invisible_finished = 0;	// don't die as eyes
379	self.invincible_finished = 0;
380	self.super_damage_finished = 0;
381	self.radsuit_finished = 0;
382	setmodel(self, "progs/player.mdl");
383	self.frame = $deatha11;
384	self.deadflag = DEAD_DEAD;
385	self.nextthink = -1;
386	BecomeCorpse(self, player_suicideframe);
387};
388
389void()	player_diea1	=	[	$deatha1,	player_diea2	] {body_solid('-16 -16 -24', '16 16 24');};
390void()	player_diea2	=	[	$deatha2,	player_diea3	] {body_solid('-16 -16 -24', '16 16 24');};
391void()	player_diea3	=	[	$deatha3,	player_diea4	] {body_solid('-16 -16 -24', '16 16 24');};
392void()	player_diea4	=	[	$deatha4,	player_diea5	] {body_solid('-16 -16 -24', '16 16 24');};
393void()	player_diea5	=	[	$deatha5,	player_diea6	] {body_solid('-16 -16 -24', '16 16 24');};
394void()	player_diea6	=	[	$deatha6,	player_diea7	] {body_solid('-16 -16 -24', '16 16 21');};
395void()	player_diea7	=	[	$deatha7,	player_diea8	] {body_solid('-16 -16 -24', '16 16 12');};
396void()	player_diea8	=	[	$deatha8,	player_diea9	] {body_nonsolid('-16 -16 -24', '16 16 1');};
397void()	player_diea9	=	[	$deatha9,	player_diea10	] {body_nonsolid('-16 -16 -24', '16 16 0');};
398void()	player_diea10	=	[	$deatha10,	player_diea11	] {body_nonsolid('-16 -16 -24', '16 16 0');};
399void()	player_diea11	=	[	$deatha11,	player_diea11	] {body_nonsolid('-16 -16 -24', '16 16 0');PlayerDead();};
400
401void()	player_dieb1	=	[	$deathb1,	player_dieb2	] {body_solid('-16 -16 -24', '16 16 24');};
402void()	player_dieb2	=	[	$deathb2,	player_dieb3	] {body_solid('-16 -16 -24', '16 16 24');};
403void()	player_dieb3	=	[	$deathb3,	player_dieb4	] {body_solid('-16 -16 -24', '16 16 24');};
404void()	player_dieb4	=	[	$deathb4,	player_dieb5	] {body_solid('-16 -16 -24', '16 16 21');};
405void()	player_dieb5	=	[	$deathb5,	player_dieb6	] {body_solid('-16 -16 -24', '16 16 12');};
406void()	player_dieb6	=	[	$deathb6,	player_dieb7	] {body_solid('-16 -16 -24', '16 16 7');};
407void()	player_dieb7	=	[	$deathb7,	player_dieb8	] {body_solid('-16 -16 -24', '16 16 5');};
408void()	player_dieb8	=	[	$deathb8,	player_dieb9	] {body_nonsolid('-16 -16 -24', '16 16 0');};
409void()	player_dieb9	=	[	$deathb9,	player_dieb9	] {body_nonsolid('-16 -16 -24', '16 16 0');PlayerDead();};
410
411void()	player_diec1	=	[	$deathc1,	player_diec2	] {body_solid('-16 -16 -24', '16 16 24');};
412void()	player_diec2	=	[	$deathc2,	player_diec3	] {body_solid('-16 -16 -24', '16 16 24');};
413void()	player_diec3	=	[	$deathc3,	player_diec4	] {body_solid('-16 -16 -24', '16 16 24');};
414void()	player_diec4	=	[	$deathc4,	player_diec5	] {body_solid('-16 -16 -24', '16 16 23');};
415void()	player_diec5	=	[	$deathc5,	player_diec6	] {body_solid('-16 -16 -24', '16 16 12');};
416void()	player_diec6	=	[	$deathc6,	player_diec7	] {body_nonsolid('-16 -16 -24', '16 16 2');};
417void()	player_diec7	=	[	$deathc7,	player_diec8	] {body_nonsolid('-16 -16 -24', '16 16 0');};
418void()	player_diec8	=	[	$deathc8,	player_diec9	] {body_nonsolid('-16 -16 -24', '16 16 0');};
419void()	player_diec9	=	[	$deathc9,	player_diec10	] {body_nonsolid('-16 -16 -24', '16 16 0');};
420void()	player_diec10	=	[	$deathc10,	player_diec11	] {body_nonsolid('-16 -16 -24', '16 16 0');};
421void()	player_diec11	=	[	$deathc11,	player_diec12	] {body_nonsolid('-16 -16 -24', '16 16 0');};
422void()	player_diec12	=	[	$deathc12,	player_diec13	] {body_nonsolid('-16 -16 -24', '16 16 0');};
423void()	player_diec13	=	[	$deathc13,	player_diec14	] {body_nonsolid('-16 -16 -24', '16 16 0');};
424void()	player_diec14	=	[	$deathc14,	player_diec15	] {body_nonsolid('-16 -16 -24', '16 16 0');};
425void()	player_diec15	=	[	$deathc15,	player_diec15	] {body_nonsolid('-16 -16 -24', '16 16 0');PlayerDead();};
426
427void()	player_died1	=	[	$deathd1,	player_died2	] {body_solid('-16 -16 -24', '16 16 24');};
428void()	player_died2	=	[	$deathd2,	player_died3	] {body_solid('-16 -16 -24', '16 16 24');};
429void()	player_died3	=	[	$deathd3,	player_died4	] {body_solid('-16 -16 -24', '16 16 22');};
430void()	player_died4	=	[	$deathd4,	player_died5	] {body_solid('-16 -16 -24', '16 16 18');};
431void()	player_died5	=	[	$deathd5,	player_died6	] {body_solid('-16 -16 -24', '16 16 13');};
432void()	player_died6	=	[	$deathd6,	player_died7	] {body_nonsolid('-16 -16 -24', '16 16 3');};
433void()	player_died7	=	[	$deathd7,	player_died8	] {body_nonsolid('-16 -16 -24', '16 16 0');};
434void()	player_died8	=	[	$deathd8,	player_died9	] {body_nonsolid('-16 -16 -24', '16 16 0');};
435void()	player_died9	=	[	$deathd9,	player_died9	] {body_nonsolid('-16 -16 -24', '16 16 0');PlayerDead();};
436
437void()	player_diee1	=	[	$deathe1,	player_diee2	] {body_solid('-16 -16 -24', '16 16 24');};
438void()	player_diee2	=	[	$deathe2,	player_diee3	] {body_solid('-16 -16 -24', '16 16 22');};
439void()	player_diee3	=	[	$deathe3,	player_diee4	] {body_solid('-16 -16 -24', '16 16 13');};
440void()	player_diee4	=	[	$deathe4,	player_diee5	] {body_solid('-16 -16 -24', '16 16 7');};
441void()	player_diee5	=	[	$deathe5,	player_diee6	] {body_nonsolid('-16 -16 -24', '16 16 3');};
442void()	player_diee6	=	[	$deathe6,	player_diee7	] {body_nonsolid('-16 -16 -24', '16 16 0');};
443void()	player_diee7	=	[	$deathe7,	player_diee8	] {body_nonsolid('-16 -16 -24', '16 16 0');};
444void()	player_diee8	=	[	$deathe8,	player_diee9	] {body_nonsolid('-16 -16 -24', '16 16 0');};
445void()	player_diee9	=	[	$deathe9,	player_diee9	] {body_nonsolid('-16 -16 -24', '16 16 0');PlayerDead();};
446
447void()	player_die_ax1	=	[	$axdeth1,	player_die_ax2	] {body_solid('-16 -16 -24', '16 16 24');};
448void()	player_die_ax2	=	[	$axdeth2,	player_die_ax3	] {body_solid('-16 -16 -24', '16 16 24');};
449void()	player_die_ax3	=	[	$axdeth3,	player_die_ax4	] {body_solid('-16 -16 -24', '16 16 21');};
450void()	player_die_ax4	=	[	$axdeth4,	player_die_ax5	] {body_solid('-16 -16 -24', '16 16 15');};
451void()	player_die_ax5	=	[	$axdeth5,	player_die_ax6	] {body_solid('-16 -16 -24', '16 16 3');};
452void()	player_die_ax6	=	[	$axdeth6,	player_die_ax7	] {body_nonsolid('-16 -16 -24', '16 16 0');};
453void()	player_die_ax7	=	[	$axdeth7,	player_die_ax8	] {body_nonsolid('-16 -16 -24', '16 16 0');};
454void()	player_die_ax8	=	[	$axdeth8,	player_die_ax9	] {body_nonsolid('-16 -16 -24', '16 16 0');};
455void()	player_die_ax9	=	[	$axdeth9,	player_die_ax9	] {body_nonsolid('-16 -16 -24', '16 16 0');PlayerDead();};
456
457/*QUAKED dead_player (1 0 0) (-16 -16 -24) (16 16 0)
458*/
459void() dead_player =
460{
461	local float r;
462	r = random() * 5;
463	if (r < 1) deadmonstersetup("progs/player.mdl", "progs/h_player.mdl", player_diea11, 6, 5, HEALTHBODY);
464	else if (r < 2) deadmonstersetup("progs/player.mdl", "progs/h_player.mdl", player_dieb9 , 6, 5, HEALTHBODY);
465	else if (r < 3) deadmonstersetup("progs/player.mdl", "progs/h_player.mdl", player_diec15, 6, 5, HEALTHBODY);
466	else if (r < 4) deadmonstersetup("progs/player.mdl", "progs/h_player.mdl", player_died9 , 6, 5, HEALTHBODY);
467	else            deadmonstersetup("progs/player.mdl", "progs/h_player.mdl", player_diee9 , 6, 5, HEALTHBODY);
468};
469
470/*QUAKED dead_player_axe (1 0 0) (-16 -16 -24) (16 16 0)
471*/
472void() dead_player_axe =
473{
474	deadmonstersetup("progs/player.mdl", "progs/h_player.mdl", player_die_ax9, 6, 5, HEALTHBODY);
475};
476
477