]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/cl_player.qc
more alpha again
[divverent/nexuiz.git] / data / qcsrc / server / cl_player.qc
1
2 // changes by LordHavoc on 03/29/04 and 03/30/04 at Vermeulen's request
3 // merged player_run and player_stand to player_anim
4 // added death animations to player_anim
5 // can now spawn thrown weapons from anywhere, not just from players
6 // thrown weapons now fade out after 20 seconds
7 // created PlayerGib function
8 // PlayerDie no longer uses hitloc or damage
9 // PlayerDie now supports dying animations as well as gibbing
10 // cleaned up PlayerDie a lot
11 // added CopyBody
12
13 .entity pusher;
14 .float pushltime;
15
16 void CopyBody(float keepvelocity)
17 {
18         local entity oldself;
19         if (self.effects & EF_NODRAW)
20                 return;
21         oldself = self;
22         self = spawn();
23         self.enemy = oldself;
24         self.lip = oldself.lip;
25         self.colormap = oldself.colormap;
26         self.iscreature = oldself.iscreature;
27         self.angles = oldself.angles;
28         self.avelocity = oldself.avelocity;
29         self.classname = "body";
30         self.damageforcescale = oldself.damageforcescale;
31         self.effects = oldself.effects;
32         self.event_damage = oldself.event_damage;
33         self.animstate_startframe = oldself.animstate_startframe;
34         self.animstate_numframes = oldself.animstate_numframes;
35         self.animstate_framerate = oldself.animstate_framerate;
36         self.animstate_starttime = oldself.animstate_starttime;
37         self.animstate_endtime = oldself.animstate_endtime;
38         self.animstate_override = oldself.animstate_override;
39         self.animstate_looping = oldself.animstate_looping;
40         self.frame = oldself.frame;
41         self.dead_frame = oldself.dead_frame;
42         self.pain_finished = oldself.pain_finished;
43         self.health = oldself.health;
44         self.armorvalue = oldself.armorvalue;
45         self.armortype = oldself.armortype;
46         self.model = oldself.model;
47         self.modelindex = oldself.modelindex;
48         self.modelindex_lod0 = oldself.modelindex_lod0;
49         self.modelindex_lod0_from_nexuiz = oldself.modelindex_lod0_from_nexuiz;
50         self.modelindex_lod1 = oldself.modelindex_lod1;
51         self.modelindex_lod2 = oldself.modelindex_lod2;
52         self.skinindex = oldself.skinindex;
53         self.species = oldself.species;
54         self.movetype = oldself.movetype;
55         self.nextthink = oldself.nextthink;
56         self.solid = oldself.solid;
57         self.takedamage = oldself.takedamage;
58         self.think = oldself.think;
59         self.customizeentityforclient = oldself.customizeentityforclient;
60         self.uncustomizeentityforclient = oldself.uncustomizeentityforclient;
61         self.uncustomizeentityforclient_set = oldself.uncustomizeentityforclient_set;
62         if (keepvelocity == 1)
63                 self.velocity = oldself.velocity;
64         self.oldvelocity = self.velocity;
65         self.fade_time = oldself.fade_time;
66         self.fade_rate = oldself.fade_rate;
67         //self.weapon = oldself.weapon;
68         setorigin(self, oldself.origin);
69         setsize(self, oldself.mins, oldself.maxs);
70         self.prevorigin = oldself.origin;
71         self.reset = SUB_Remove;
72
73         Drag_MoveDrag(oldself, self);
74
75         self = oldself;
76 }
77
78 float player_getspecies()
79 {
80         local float glob, i, j, fh, len, s, sk;
81         local string fn, l;
82
83         s = -1;
84
85         glob = search_begin("models/player/*.txt", TRUE, TRUE);
86         if(glob < 0)
87                 return s;
88         for(j = 0; j <= 1; ++j)
89         {
90                 for(i = 0; i < search_getsize(glob); ++i)
91                 {
92                         fn = search_getfilename(glob, i);
93                         fh = fopen(fn, FILE_READ);
94                         if(fh < 0)
95                                 continue;
96                         fgets(fh); fgets(fh);
97                         sk = stof(fgets(fh));
98                         if(sk == (j ? 0 : self.skinindex)) // 2nd pass skips the skin test
99                         if(fgets(fh) == self.model)
100                         {
101                                 l = fgets(fh);
102                                 len = tokenize_console(l);
103                                 if (len != 2)
104                                         goto nospecies;
105                                 if (argv(0) != "species")
106                                         goto nospecies;
107                                 switch(argv(1))
108                                 {
109                                         case "human":       s = SPECIES_HUMAN;       break;
110                                         case "alien":       s = SPECIES_ALIEN;       break;
111                                         case "robot_shiny": s = SPECIES_ROBOT_SHINY; break;
112                                         case "robot_rusty": s = SPECIES_ROBOT_RUSTY; break;
113                                         case "robot_solid": s = SPECIES_ROBOT_SOLID; break;
114                                         case "animal":      s = SPECIES_ANIMAL;      break;
115                                         case "reserved":    s = SPECIES_RESERVED;    break;
116                                 }
117                         }
118 :nospecies
119                         fclose(fh);
120                 }
121                 if (s >= 0)
122                         break;
123         }
124         search_end(glob);
125
126         if (s < 0)
127                 s = SPECIES_HUMAN;
128
129         return s;
130 }
131
132 void player_setupanimsformodel()
133 {
134         local string animfilename;
135         local float animfile;
136         // defaults for legacy .zym models without animinfo files
137         self.anim_die1 = '0 1 0.5'; // 2 seconds
138         self.anim_die2 = '1 1 0.5'; // 2 seconds
139         self.anim_draw = '2 1 3'; // TODO: analyze models and set framerate
140         self.anim_duck = '3 1 100'; // this anim seems bogus in most models, so make it play VERY briefly!
141         self.anim_duckwalk = '4 1 1';
142         self.anim_duckjump = '5 1 100'; // zym anims keep playing until changed, so this only has to start the anim, landing will end it
143         self.anim_duckidle = '6 1 1';
144         self.anim_idle = '7 1 1';
145         self.anim_jump = '8 1 100'; // zym anims keep playing until changed, so this only has to start the anim, landing will end it
146         self.anim_pain1 = '9 1 2'; // 0.5 seconds
147         self.anim_pain2 = '10 1 2'; // 0.5 seconds
148         self.anim_shoot = '11 1 5'; // TODO: analyze models and set framerate
149         self.anim_taunt = '12 1 0.33'; // FIXME?  there is no code using this anim
150         self.anim_run = '13 1 1';
151         self.anim_runbackwards = '14 1 1';
152         self.anim_strafeleft = '15 1 1';
153         self.anim_straferight = '16 1 1';
154         self.anim_dead1 = '17 1 1';
155         self.anim_dead2 = '18 1 1';
156         self.anim_forwardright = '19 1 1';
157         self.anim_forwardleft = '20 1 1';
158         self.anim_backright = '21 1 1';
159         self.anim_backleft  = '22 1 1';
160         animparseerror = FALSE;
161         animfilename = strcat(self.model, ".animinfo");
162         animfile = fopen(animfilename, FILE_READ);
163         if (animfile >= 0)
164         {
165                 self.anim_die1         = animparseline(animfile);
166                 self.anim_die2         = animparseline(animfile);
167                 self.anim_draw         = animparseline(animfile);
168                 self.anim_duck         = animparseline(animfile);
169                 self.anim_duckwalk     = animparseline(animfile);
170                 self.anim_duckjump     = animparseline(animfile);
171                 self.anim_duckidle     = animparseline(animfile);
172                 self.anim_idle         = animparseline(animfile);
173                 self.anim_jump         = animparseline(animfile);
174                 self.anim_pain1        = animparseline(animfile);
175                 self.anim_pain2        = animparseline(animfile);
176                 self.anim_shoot        = animparseline(animfile);
177                 self.anim_taunt        = animparseline(animfile);
178                 self.anim_run          = animparseline(animfile);
179                 self.anim_runbackwards = animparseline(animfile);
180                 self.anim_strafeleft   = animparseline(animfile);
181                 self.anim_straferight  = animparseline(animfile);
182                 self.anim_forwardright = animparseline(animfile);
183                 self.anim_forwardleft  = animparseline(animfile);
184                 self.anim_backright    = animparseline(animfile);
185                 self.anim_backleft     = animparseline(animfile);
186                 fclose(animfile);
187
188                 // derived anims
189                 self.anim_dead1 = '0 1 1' + '1 0 0' * (self.anim_die1_x + self.anim_die1_y - 1);
190                 self.anim_dead2 = '0 1 1' + '1 0 0' * (self.anim_die2_x + self.anim_die2_y - 1);
191
192                 if (animparseerror)
193                         print("Parse error in ", animfilename, ", some player animations are broken\n");
194         }
195         else
196                 dprint("File ", animfilename, " not found, assuming legacy .zym model animation timings\n");
197         // reset animstate now
198         setanim(self, self.anim_idle, TRUE, FALSE, TRUE);
199 };
200
201 void player_anim (void)
202 {
203         updateanim(self);
204         if (self.weaponentity)
205                 updateanim(self.weaponentity);
206
207         if (self.deadflag != DEAD_NO)
208         {
209                 if (time > self.animstate_endtime)
210                 {
211                         if (self.maxs_z > 5)
212                         {
213                                 self.maxs_z = 5;
214                                 setsize(self, self.mins, self.maxs);
215                         }
216                         self.frame = self.dead_frame;
217                 }
218                 return;
219         }
220
221         if (!self.animstate_override)
222         {
223                 if (!(self.flags & FL_ONGROUND))
224                 {
225                         if (self.crouch)
226                                 setanim(self, self.anim_duckjump, FALSE, TRUE, self.restart_jump);
227                         else
228                                 setanim(self, self.anim_jump, FALSE, TRUE, self.restart_jump);
229                         self.restart_jump = FALSE;
230                 }
231                 else if (self.crouch)
232                 {
233                         if (self.movement_x * self.movement_x + self.movement_y * self.movement_y > 20)
234                                 setanim(self, self.anim_duckwalk, TRUE, FALSE, FALSE);
235                         else
236                                 setanim(self, self.anim_duckidle, TRUE, FALSE, FALSE);
237                 }
238                 else if ((self.movement_x * self.movement_x + self.movement_y * self.movement_y) > 20)
239                 {
240                         if (self.movement_x > 0 && self.movement_y == 0)
241                                 setanim(self, self.anim_run, TRUE, FALSE, FALSE);
242                         else if (self.movement_x < 0 && self.movement_y == 0)
243                                 setanim(self, self.anim_runbackwards, TRUE, FALSE, FALSE);
244                         else if (self.movement_x == 0 && self.movement_y > 0)
245                                 setanim(self, self.anim_straferight, TRUE, FALSE, FALSE);
246                         else if (self.movement_x == 0 && self.movement_y < 0)
247                                 setanim(self, self.anim_strafeleft, TRUE, FALSE, FALSE);
248                         else if (self.movement_x > 0 && self.movement_y > 0)
249                                 setanim(self, self.anim_forwardright, TRUE, FALSE, FALSE);
250                         else if (self.movement_x > 0 && self.movement_y < 0)
251                                 setanim(self, self.anim_forwardleft, TRUE, FALSE, FALSE);
252                         else if (self.movement_x < 0 && self.movement_y > 0)
253                                 setanim(self, self.anim_backright, TRUE, FALSE, FALSE);
254                         else if (self.movement_x < 0 && self.movement_y < 0)
255                                 setanim(self, self.anim_backleft, TRUE, FALSE, FALSE);
256                         else
257                                 setanim(self, self.anim_run, TRUE, FALSE, FALSE);
258                 }
259                 else
260                         setanim(self, self.anim_idle, TRUE, FALSE, FALSE);
261         }
262
263         if (self.weaponentity)
264         if (!self.weaponentity.animstate_override)
265                 setanim(self.weaponentity, self.weaponentity.anim_idle, TRUE, FALSE, FALSE);
266 }
267
268 void SpawnThrownWeapon (vector org, float w)
269 {
270         if(g_minstagib)
271         if(self.ammo_cells <= 0)
272                 return;
273
274         if(g_pinata)
275         {
276                 float j;
277                 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
278                 {
279                         if(self.weapons & W_WeaponBit(j))
280                                 if(W_IsWeaponThrowable(j))
281                                         W_ThrowNewWeapon(self, j, FALSE, self.origin, randomvec() * 175 + '0 0 325');
282                 }
283         }
284         else
285                 W_ThrowWeapon(randomvec() * 125 + '0 0 200', org - self.origin, FALSE);
286 }
287
288 void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
289 {
290         local float take, save;
291         vector v;
292         Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
293
294         // damage resistance (ignore most of the damage from a bullet or similar)
295         damage = max(damage - 5, 1);
296
297         v = healtharmor_applydamage(self.armorvalue, cvar("g_balance_armor_blockpercent"), damage);
298         take = v_x;
299         save = v_y;
300
301         if(sound_allowed(MSG_BROADCAST, attacker))
302         {
303                 if (save > 10)
304                         sound (self, CHAN_PROJECTILE, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
305                 else if (take > 30)
306                         sound (self, CHAN_PROJECTILE, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
307                 else if (take > 10)
308                         sound (self, CHAN_PROJECTILE, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM);
309         }
310
311         if (take > 50)
312                 Violence_GibSplash_At(hitloc, force * -0.1, 3, 1, self, attacker);
313         if (take > 100)
314                 Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, self, attacker);
315
316         if (!(self.flags & FL_GODMODE))
317         {
318                 self.armorvalue = self.armorvalue - save;
319                 self.health = self.health - take;
320                 // pause regeneration for 5 seconds
321                 self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_health_regen"));
322         }
323         self.dmg_save = self.dmg_save + save;//max(save - 10, 0);
324         self.dmg_take = self.dmg_take + take;//max(take - 10, 0);
325         self.dmg_inflictor = inflictor;
326
327         if (self.health <= -75 && self.modelindex != 0)
328         {
329                 // don't use any animations as a gib
330                 self.frame = 0;
331                 self.dead_frame = 0;
332                 // view just above the floor
333                 self.view_ofs = '0 0 4';
334
335                 Violence_GibSplash(self, 1, 1, attacker);
336                 self.modelindex = 0; // restore later
337                 self.solid = SOLID_NOT; // restore later
338         }
339 }
340
341 void ClientKill_Now_TeamChange();
342
343 void PlayerDamage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
344 {
345         local float take, save, waves, sdelay;
346         vector v;
347
348         if(!DEATH_ISSPECIAL(deathtype))
349         {
350                 damage *= sqrt(bound(1.0, self.cvar_cl_handicap, 100.0));
351                 if(self != attacker)
352                         damage /= sqrt(bound(1.0, attacker.cvar_cl_handicap, 100.0));
353         }
354
355         if(DEATH_ISWEAPON(deathtype, WEP_TUBA))
356         {
357                 // tuba causes blood to come out of the ears
358                 vector ear1, ear2;
359                 vector d;
360                 float f;
361                 ear1 = self.origin;
362                 ear1_z += 0.125 * self.view_ofs_z + 0.875 * self.maxs_z; // 7/8
363                 ear2 = ear1;
364                 makevectors(self.angles);
365                 ear1 += v_right * -10;
366                 ear2 += v_right * +10;
367                 d = inflictor.origin - self.origin;
368                 f = (d * v_right) / vlen(d); // this is cos of angle of d and v_right!
369                 force = v_right * vlen(force);
370                 Violence_GibSplash_At(ear1, force * -1, 2, bound(0, damage, 25) / 2 * (0.5 - 0.5 * f), self, attacker);
371                 Violence_GibSplash_At(ear2, force,      2, bound(0, damage, 25) / 2 * (0.5 + 0.5 * f), self, attacker);
372                 if(f > 0)
373                 {
374                         hitloc = ear1;
375                         force = force * -1;
376                 }
377                 else
378                 {
379                         hitloc = ear2;
380                         // force is already good
381                 }
382         }
383         else
384                 Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
385
386         if(g_arena)
387         if(numspawned < 2)
388                 return;
389
390         if (!g_minstagib)
391         {
392                 v = healtharmor_applydamage(self.armorvalue, cvar("g_balance_armor_blockpercent"), damage);
393                 take = v_x;
394                 save = v_y;
395         }
396         else
397         {
398                 save = 0;
399                 take = damage;
400         }
401
402         if(sound_allowed(MSG_BROADCAST, attacker))
403         {
404                 if (save > 10)
405                         sound (self, CHAN_PROJECTILE, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
406                 else if (take > 30)
407                         sound (self, CHAN_PROJECTILE, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
408                 else if (take > 10)
409                         sound (self, CHAN_PROJECTILE, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM); // FIXME possibly remove them?
410         }
411
412         if (take > 50)
413                 Violence_GibSplash_At(hitloc, force * -0.1, 3, 1, self, attacker);
414         if (take > 100)
415                 Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, self, attacker);
416
417         if (time > self.spawnshieldtime)
418         {
419                 if (!(self.flags & FL_GODMODE))
420                 {
421                         self.armorvalue = self.armorvalue - save;
422                         self.health = self.health - take;
423                         // pause regeneration for 5 seconds
424                         self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_health_regen"));
425
426                         if (time > self.pain_finished)          //Don't switch pain sequences like crazy
427                         {
428                                 self.pain_finished = time + 0.5;        //Supajoe
429
430                                 if(sv_gentle < 1) {
431                                         if(self.classname != "body") // pain anim is BORKED on our ZYMs, FIXME remove this once we have good models
432                                         {
433                                                 if (random() > 0.5)
434                                                         setanim(self, self.anim_pain1, FALSE, TRUE, TRUE);
435                                                 else
436                                                         setanim(self, self.anim_pain2, FALSE, TRUE, TRUE);
437                                         }
438
439                                         if(sound_allowed(MSG_BROADCAST, attacker))
440                                         if(!DEATH_ISWEAPON(deathtype, WEP_LASER) || attacker != self || self.health < 2 * cvar("g_balance_laser_primary_damage") * cvar("g_balance_selfdamagepercent") + 1)
441                                         // exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two
442                                         {
443                                                 if(self.health > 75) // TODO make a "gentle" version?
444                                                         PlayerSound(playersound_pain100, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
445                                                 else if(self.health > 50)
446                                                         PlayerSound(playersound_pain75, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
447                                                 else if(self.health > 25)
448                                                         PlayerSound(playersound_pain50, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
449                                                 else if(self.health > 1)
450                                                         PlayerSound(playersound_pain25, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
451                                         }
452                                 }
453
454                                 // throw off bot aim temporarily
455                                 local float shake;
456                                 shake = damage * 5 / (bound(0,skill,100) + 1);
457                                 self.v_angle_x = self.v_angle_x + (random() * 2 - 1) * shake;
458                                 self.v_angle_y = self.v_angle_y + (random() * 2 - 1) * shake;
459                         }
460                 }
461                 else
462                         self.max_armorvalue += (save + take);
463         }
464         self.dmg_save = self.dmg_save + save;//max(save - 10, 0);
465         self.dmg_take = self.dmg_take + take;//max(take - 10, 0);
466         self.dmg_inflictor = inflictor;
467
468         if(attacker == self)
469         {
470                 // don't reset pushltime for self damage as it may be an attempt to
471                 // escape a lava pit or similar
472                 //self.pushltime = 0;
473         }
474         else if(attacker.classname == "player" || attacker.classname == "gib")
475         {
476                 self.pusher = attacker;
477                 self.pushltime = time + cvar("g_maxpushtime");
478         }
479         else if(time < self.pushltime)
480         {
481                 attacker = self.pusher;
482                 self.pushltime = max(self.pushltime, time + 0.6);
483         }
484         else
485                 self.pushltime = 0;
486
487         if (self.health < 1)
488         {
489                 float defer_ClientKill_Now_TeamChange;
490                 defer_ClientKill_Now_TeamChange = FALSE;
491
492                 if(sv_gentle < 1) // TODO make a "gentle" version?
493                 if(sound_allowed(MSG_BROADCAST, attacker))
494                 {
495                         if(deathtype == DEATH_DROWN)
496                                 PlayerSound(playersound_drown, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
497                         else
498                                 PlayerSound(playersound_death, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
499                 }
500
501                 // get rid of kill indicator
502                 if(self.killindicator)
503                 {
504                         remove(self.killindicator);
505                         self.killindicator = world;
506                         if(self.killindicator_teamchange)
507                                 defer_ClientKill_Now_TeamChange = TRUE;
508
509                         if(self.classname == "body")
510                         if(deathtype == DEATH_KILL)
511                         {
512                                 // for the lemmings fans, a small harmless explosion
513                                 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
514                         }
515                 }
516
517                 // become fully visible
518                 self.alpha = 1;
519                 // clear selected player display
520                 ClearSelectedPlayer();
521                 // throw a weapon
522                 SpawnThrownWeapon (self.origin + (self.mins + self.maxs) * 0.5, self.switchweapon);
523                 // print an obituary message
524                 Obituary (attacker, inflictor, self, deathtype);
525                 race_PreDie();
526                 DropAllRunes(self);
527                 if(self == attacker)
528                         kh_Key_DropAll(self, TRUE);
529                 else if(attacker.classname == "player" || attacker.classname == "gib")
530                         kh_Key_DropAll(self, FALSE);
531                 else
532                         kh_Key_DropAll(self, TRUE);
533                 if(self.flagcarried)
534                 {
535                         if(attacker.classname != "player" && attacker.classname != "gib")
536                                 DropFlag(self.flagcarried, self, attacker); // penalty for flag loss by suicide
537                         else if(attacker.team == self.team)
538                                 DropFlag(self.flagcarried, attacker, attacker); // penalty for flag loss by suicide/teamkill
539                         else
540                                 DropFlag(self.flagcarried, world, attacker);
541                 }
542                 if(self.ballcarried)
543                         DropBall(self.ballcarried, self.origin, self.velocity);
544                 Portal_ClearAllLater(self);
545                 // clear waypoints
546                 WaypointSprite_PlayerDead();
547                 // make the corpse upright (not tilted)
548                 self.angles_x = 0;
549                 self.angles_z = 0;
550                 // don't spin
551                 self.avelocity = '0 0 0';
552                 // view from the floor
553                 self.view_ofs = '0 0 -8';
554                 // toss the corpse
555                 self.movetype = MOVETYPE_TOSS;
556                 // shootable corpse
557                 self.solid = SOLID_CORPSE;
558                 // don't stick to the floor
559                 self.flags &~= FL_ONGROUND;
560                 // dying animation
561                 self.deadflag = DEAD_DYING;
562                 // when to allow respawn
563                 sdelay = 0;
564                 waves = 0;
565                 if(cvar("g_respawn_mapsettings"))
566                 {
567                         sdelay = cvar("g_respawn_mapsettings_delay");
568                         waves = cvar("g_respawn_mapsettings_waves");
569                 }
570                 if(!sdelay)
571                         sdelay = cvar(strcat("g_", GetGametype(), "_respawn_delay"));
572                 if(!sdelay)
573                         sdelay = cvar("g_respawn_delay");
574                 if(!waves)
575                         waves = cvar(strcat("g_", GetGametype(), "_respawn_waves"));
576                 if(!waves)
577                         waves = cvar("g_respawn_waves");
578                 if(waves)
579                         self.death_time = ceil((time + sdelay) / waves) * waves;
580                 else
581                         self.death_time = time + sdelay;
582                 if((sdelay + waves >= 5.0) && (self.death_time - time > 1.75))
583                         self.respawn_countdown = 10; // first number to count down from is 10
584                 else
585                         self.respawn_countdown = -1; // do not count down
586                 if (random() < 0.5)
587                 {
588                         setanim(self, self.anim_die1, FALSE, TRUE, TRUE);
589                         self.dead_frame = self.anim_dead1_x;
590                 }
591                 else
592                 {
593                         setanim(self, self.anim_die2, FALSE, TRUE, TRUE);
594                         self.dead_frame = self.anim_dead2_x;
595                 }
596                 // set damage function to corpse damage
597                 self.event_damage = PlayerCorpseDamage;
598                 // call the corpse damage function just in case it wants to gib
599                 self.event_damage(inflictor, attacker, 0, deathtype, hitloc, force);
600                 // set up to fade out later
601                 SUB_SetFade (self, time + 12 + random () * 4, 1);
602
603                 // remove laserdot
604                 if(self.weaponentity)
605                         if(self.weaponentity.lasertarget)
606                                 remove(self.weaponentity.lasertarget);
607
608                 if(clienttype(self) == CLIENTTYPE_REAL)
609                 {
610                         self.fixangle = TRUE;
611                         //msg_entity = self;
612                         //WriteByte (MSG_ONE, SVC_SETANGLE);
613                         //WriteAngle (MSG_ONE, self.v_angle_x);
614                         //WriteAngle (MSG_ONE, self.v_angle_y);
615                         //WriteAngle (MSG_ONE, 80);
616                 }
617
618                 if(g_arena)
619                         Spawnqueue_Unmark(self);
620
621                 if(defer_ClientKill_Now_TeamChange)
622                         ClientKill_Now_TeamChange();
623
624                 if(sv_gentle > 0) {
625                         // remove corpse
626                         PlayerCorpseDamage (inflictor, attacker, 100.0, deathtype, hitloc, force);
627                 }
628         }
629 }
630
631 float UpdateSelectedPlayer_countvalue(float v)
632 {
633         return max(0, (v - 1.0) / 0.5);
634 }
635
636 // returns: -2 if no hit, otherwise cos of the angle
637 // uses the global v_angle
638 float UpdateSelectedPlayer_canSee(entity p, float mincosangle, float maxdist)
639 {
640         vector so, d;
641         float c;
642
643         if(p == self)
644                 return -2;
645
646         if(p.deadflag)
647                 return -2;
648
649         so = self.origin + self.view_ofs;
650         d = p.origin - so;
651
652         // misaimed?
653         if(dist_point_line(d, '0 0 0', v_forward) > maxdist)
654                 return -2;
655
656         // now find the cos of the angle...
657         c = normalize(d) * v_forward;
658
659         if(c <= mincosangle)
660                 return -2;
661
662         // not visible in any way? forget it
663         if(!checkpvs(so, p))
664                 return -2;
665
666         traceline(so, p.origin, MOVE_NOMONSTERS, self);
667         if(trace_fraction < 1)
668                 return -2;
669
670         return c;
671 }
672
673 void ClearSelectedPlayer()
674 {
675         if(self.selected_player)
676         {
677                 centerprint_expire(self, CENTERPRIO_POINT);
678                 self.selected_player = world;
679                 self.selected_player_display_needs_update = FALSE;
680         }
681 }
682
683 void UpdateSelectedPlayer()
684 {
685         entity selected;
686         float selected_score;
687         selected = world;
688         selected_score = 0.95; // 18 degrees
689
690         if(!cvar("sv_allow_shownames"))
691                 return;
692
693         if(clienttype(self) != CLIENTTYPE_REAL)
694                 return;
695
696         if(self.cvar_cl_shownames == 0)
697                 return;
698
699         if(self.cvar_cl_shownames == 1 && !teams_matter)
700                 return;
701
702         makevectors(self.v_angle); // sets v_forward
703
704         // 1. cursor trace is always right
705         if(self.cursor_trace_ent && self.cursor_trace_ent.classname == "player" && !self.cursor_trace_ent.deadflag)
706         {
707                 selected = self.cursor_trace_ent;
708         }
709         else
710         {
711                 // 2. if we don't have a cursor trace, find the player which is least
712                 //    mis-aimed at
713                 entity p;
714                 FOR_EACH_PLAYER(p)
715                 {
716                         float c;
717                         c = UpdateSelectedPlayer_canSee(p, selected_score, 100); // 100 = 2.5 meters
718                         if(c >= -1)
719                         {
720                                 selected = p;
721                                 selected_score = c;
722                         }
723                 }
724         }
725
726         if(selected)
727         {
728                 self.selected_player_display_timeout = time + self.cvar_scr_centertime;
729         }
730         else
731         {
732                 if(time < self.selected_player_display_timeout)
733                         if(UpdateSelectedPlayer_canSee(self.selected_player, 0.7, 200) >= -1) // 5 meters, 45 degrees
734                                 selected = self.selected_player;
735         }
736
737         if(selected)
738         {
739                 if(selected == self.selected_player)
740                 {
741                         float save;
742                         save = UpdateSelectedPlayer_countvalue(self.selected_player_count);
743                         self.selected_player_count = self.selected_player_count + frametime;
744                         if(save != UpdateSelectedPlayer_countvalue(self.selected_player_count))
745                         {
746                                 string namestr, healthstr;
747                                 namestr = playername(selected);
748                                 if(teams_matter)
749                                 {
750                                         healthstr = ftos(floor(selected.health));
751                                         if(self.team == selected.team)
752                                         {
753                                                 namestr = strcat(namestr, " (", healthstr, "%)");
754                                                 self.selected_player_display_needs_update = TRUE;
755                                         }
756                                 }
757                                 centerprint_atprio(self, CENTERPRIO_POINT, namestr);
758                         }
759                 }
760                 else
761                 {
762                         ClearSelectedPlayer();
763                         self.selected_player = selected;
764                         self.selected_player_time = time;
765                         self.selected_player_count = 0;
766                         self.selected_player_display_needs_update = FALSE;
767                 }
768         }
769         else
770         {
771                 ClearSelectedPlayer();
772         }
773
774         if(self.selected_player)
775                 self.last_selected_player = self.selected_player;
776 }
777
778 .float muted; // to be used by prvm_edictset server playernumber muted 1
779 void Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol)
780 {
781         string msgstr, colorstr, cmsgstr, namestr, fullmsgstr, sourcemsgstr, fullcmsgstr, sourcecmsgstr, privatemsgprefix;
782         float flood, privatemsgprefixlen;
783         entity head;
784
785         if(Ban_MaybeEnforceBan(source))
786                 return;
787
788         if(!teamsay && !privatesay)
789                 if(substring(msgin, 0, 1) == " ")
790                         msgin = substring(msgin, 1, strlen(msgin) - 1); // work around DP say bug (say_team does not have this!)
791
792         msgin = formatmessage(msgin);
793
794         if(msgin == "")
795                 return;
796
797         if(source.classname != "player")
798                 colorstr = "^0"; // black for spectators
799         else if(teams_matter)
800                 colorstr = Team_ColorCode(source.team);
801         else
802                 teamsay = FALSE;
803
804         if(intermission_running)
805                 teamsay = FALSE;
806
807         msgin = trigger_magicear_processmessage_forallears(source, teamsay, privatesay, msgin);
808         if(msgin == "")
809                 return;
810
811         /*
812          * using bprint solves this... me stupid
813         // how can we prevent the message from appearing in a listen server?
814         // for now, just give "say" back and only handle say_team
815         if(!teamsay)
816         {
817                 clientcommand(self, strcat("say ", msgin));
818                 return;
819         }
820         */
821
822         if(cvar("g_chat_teamcolors"))
823                 namestr = playername(source);
824         else
825                 namestr = source.netname;
826
827         if(privatesay)
828         {
829                 msgstr = strcat("\{1}\{13}* ^3", namestr, "^3 tells you: ^7");
830                 privatemsgprefixlen = strlen(msgstr);
831                 msgstr = strcat(msgstr, msgin);
832                 cmsgstr = strcat(colorstr, "^3", namestr, "^3 tells you:\n^7", msgin);
833                 if(cvar("g_chat_teamcolors"))
834                         privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", playername(privatesay), ": ^7");
835                 else
836                         privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", privatesay.netname, ": ^7");
837         }
838         else if(teamsay)
839         {
840                 msgstr = strcat("\{1}\{13}", colorstr, "(^3", namestr, colorstr, ") ^7", msgin);
841                 cmsgstr = strcat(colorstr, "(^3", namestr, colorstr, ")\n^7", msgin);
842         }
843         else
844         {
845                 msgstr = strcat("\{1}", namestr, "^7: ", msgin);
846                 cmsgstr = "";
847         }
848
849         msgstr = strcat(strreplace("\n", " ", msgstr), "\n"); // newlines only are good for centerprint
850         fullmsgstr = msgstr;
851         fullcmsgstr = cmsgstr;
852
853         // FLOOD CONTROL
854         flood = 0;
855         if(floodcontrol)
856         {
857                 float flood_spl;
858                 float flood_burst;
859                 float flood_lmax;
860                 var .float flood_field;
861                 float lines;
862                 if(privatesay)
863                 {
864                         flood_spl = cvar("g_chat_flood_spl_tell");
865                         flood_burst = cvar("g_chat_flood_burst_tell");
866                         flood_lmax = cvar("g_chat_flood_lmax_tell");
867                         flood_field = floodcontrol_chattell;
868                 }
869                 else if(teamsay)
870                 {
871                         flood_spl = cvar("g_chat_flood_spl_team");
872                         flood_burst = cvar("g_chat_flood_burst_team");
873                         flood_lmax = cvar("g_chat_flood_lmax_team");
874                         flood_field = floodcontrol_chatteam;
875                 }
876                 else
877                 {
878                         flood_spl = cvar("g_chat_flood_spl");
879                         flood_burst = cvar("g_chat_flood_burst");
880                         flood_lmax = cvar("g_chat_flood_lmax");
881                         flood_field = floodcontrol_chat;
882                 }
883                 flood_burst = max(0, flood_burst - 1);
884                 // to match explanation in default.cfg, a value of 3 must allow three-line bursts and not four!
885
886                 // do flood control for the default line size
887                 getWrappedLine_remaining = msgstr;
888                 msgstr = "";
889                 lines = 0;
890                 while(getWrappedLine_remaining && (!flood_lmax || lines <= flood_lmax))
891                 {
892                         msgstr = strcat(msgstr, " ", getWrappedLine(82.4289758859709, strlennocol)); // perl averagewidth.pl < gfx/vera-sans.width
893                         ++lines;
894                 }
895                 msgstr = substring(msgstr, 1, strlen(msgstr) - 1);
896
897                 if(getWrappedLine_remaining != "")
898                 {
899                         msgstr = strcat(msgstr, "\n");
900                         flood = 2;
901                 }
902
903                 if(time >= source.flood_field)
904                 {
905                         source.flood_field = max(time - flood_burst * flood_spl, source.flood_field) + lines * flood_spl;
906                 }
907                 else
908                 {
909                         flood = 1;
910                         msgstr = fullmsgstr;
911                 }
912         }
913
914         if (timeoutStatus == 2) //when game is paused, no flood protection
915                 source.flood_field = flood = 0;
916
917         if(flood == 2)
918         {
919                 if(cvar("g_chat_flood_notify_flooder"))
920                 {
921                         sourcemsgstr = strcat(msgstr, "\n^3FLOOD CONTROL: ^7message too long, trimmed\n");
922                         sourcecmsgstr = "";
923                 }
924                 else
925                 {
926                         sourcemsgstr = fullmsgstr;
927                         sourcecmsgstr = fullcmsgstr;
928                 }
929                 cmsgstr = "";
930         }
931         else
932         {
933                 sourcemsgstr = msgstr;
934                 sourcecmsgstr = cmsgstr;
935         }
936
937         if(!privatesay)
938         if(source.classname != "player")
939         {
940                 if(teamsay || (cvar("g_chat_nospectators") == 1) || (cvar("g_chat_nospectators") == 2 && !inWarmupStage))
941                         teamsay = -1; // spectators
942         }
943
944         if(flood)
945                 print("NOTE: ", playername(source), "^7 is flooding.\n");
946
947         // build sourcemsgstr by cutting off a prefix and replacing it by the other one
948         if(privatesay)
949                 sourcemsgstr = strcat(privatemsgprefix, substring(sourcemsgstr, privatemsgprefixlen, -1));
950
951         if(source.muted)
952         {
953                 // always fake the message
954                 sprint(source, sourcemsgstr);
955                 if(cmsgstr != "" && !privatesay)
956                         centerprint(source, sourcecmsgstr);
957         }
958         else if(flood == 1)
959         {
960                 if(cvar("g_chat_flood_notify_flooder"))
961                         sprint(source, strcat("^3FLOOD CONTROL: ^7wait ^1", ftos(source.flood_field - time), "^3 seconds\n"));
962                 else
963                 {
964                         sprint(source, sourcemsgstr);
965                         if(cmsgstr != "" && !privatesay)
966                                 centerprint(source, sourcecmsgstr);
967                 }
968         }
969         else if(privatesay)
970         {
971                 sprint(source, sourcemsgstr);
972                 sprint(privatesay, msgstr);
973                 if(cmsgstr != "")
974                         centerprint(privatesay, cmsgstr);
975         }
976         else if(teamsay > 0)
977         {
978                 sprint(source, sourcemsgstr);
979                 if(sourcecmsgstr != "")
980                         centerprint(source, sourcecmsgstr);
981                 FOR_EACH_REALPLAYER(head) if(head.team == source.team)
982                         if(head != source)
983                         {
984                                 sprint(head, msgstr);
985                                 if(cmsgstr != "")
986                                         centerprint(head, cmsgstr);
987                         }
988         }
989         else if(teamsay < 0)
990         {
991                 sprint(source, sourcemsgstr);
992                 FOR_EACH_REALCLIENT(head) if(head.classname != "player")
993                         if(head != source)
994                                 sprint(head, msgstr);
995         }
996         else if(sourcemsgstr != msgstr)
997         {
998                 sprint(source, sourcemsgstr);
999                 FOR_EACH_REALCLIENT(head)
1000                         if(head != source)
1001                                 sprint(head, msgstr);
1002         }
1003         else
1004                 bprint(msgstr);
1005 }
1006
1007 float GetVoiceMessageVoiceType(string type)
1008 {
1009         if(type == "taunt")
1010                 return VOICETYPE_TAUNT;
1011         if(type == "teamshoot")
1012                 return VOICETYPE_LASTATTACKER;
1013         return VOICETYPE_TEAMRADIO;
1014 }
1015
1016 string allvoicesamples;
1017 float GetPlayerSoundSampleField_notFound;
1018 float GetPlayerSoundSampleField_fixed;
1019 .string GetVoiceMessageSampleField(string type)
1020 {
1021         GetPlayerSoundSampleField_notFound = 0;
1022         GetPlayerSoundSampleField_fixed = 0;
1023         switch(type)
1024         {
1025 #define _VOICEMSG(m) case #m: return playersound_##m;
1026                 ALLVOICEMSGS
1027 #undef _VOICEMSG
1028         }
1029         GetPlayerSoundSampleField_notFound = 1;
1030         return playersound_taunt;
1031 }
1032
1033 .string GetPlayerSoundSampleField(string type)
1034 {
1035         GetPlayerSoundSampleField_notFound = 0;
1036         GetPlayerSoundSampleField_fixed = 0;
1037         switch(type)
1038         {
1039 #define _VOICEMSG(m) case #m: return playersound_##m;
1040                 ALLPLAYERSOUNDS
1041 #undef _VOICEMSG
1042         }
1043         GetPlayerSoundSampleField_notFound = 1;
1044         return playersound_taunt;
1045 }
1046
1047 void PrecacheGlobalSound(string samplestring)
1048 {
1049         float n, i;
1050         tokenize_console(samplestring);
1051         n = stof(argv(1));
1052         if(n > 0)
1053         {
1054                 for(i = 1; i <= n; ++i)
1055                         precache_sound(strcat(argv(0), ftos(i), ".wav"));
1056         }
1057         else
1058         {
1059                 precache_sound(strcat(argv(0), ".wav"));
1060         }
1061 }
1062
1063 void PrecachePlayerSounds(string f)
1064 {
1065         float fh;
1066         string s;
1067         fh = fopen(f, FILE_READ);
1068         if(fh < 0)
1069                 return;
1070         while((s = fgets(fh)))
1071         {
1072                 if(tokenize_console(s) != 3)
1073                 {
1074                         dprint("Invalid sound info line: ", s, "\n");
1075                         continue;
1076                 }
1077                 PrecacheGlobalSound(strcat(argv(1), " ", argv(2)));
1078         }
1079         fclose(fh);
1080
1081         if not(allvoicesamples)
1082         {
1083 #define _VOICEMSG(m) allvoicesamples = strcat(allvoicesamples, " ", #m);
1084                 ALLVOICEMSGS
1085 #undef _VOICEMSG
1086                 allvoicesamples = strzone(substring(allvoicesamples, 1, strlen(allvoicesamples) - 1));
1087         }
1088 }
1089
1090 void ClearPlayerSounds()
1091 {
1092 #define _VOICEMSG(m) if(self.playersound_##m) { strunzone(self.playersound_##m); self.playersound_##m = string_null; }
1093         ALLPLAYERSOUNDS
1094         ALLVOICEMSGS
1095 #undef _VOICEMSG
1096 }
1097
1098 void LoadPlayerSounds(string f, float first)
1099 {
1100         float fh;
1101         string s;
1102         var .string field;
1103         fh = fopen(f, FILE_READ);
1104         if(fh < 0)
1105                 return;
1106         while((s = fgets(fh)))
1107         {
1108                 if(tokenize_console(s) != 3)
1109                         continue;
1110                 field = GetPlayerSoundSampleField(argv(0));
1111                 if(GetPlayerSoundSampleField_notFound)
1112                         field = GetVoiceMessageSampleField(argv(0));
1113                 if(GetPlayerSoundSampleField_notFound)
1114                         continue;
1115                 if(GetPlayerSoundSampleField_fixed)
1116                         if not(first)
1117                                 continue;
1118                 if(self.field)
1119                         strunzone(self.field);
1120                 self.field = strzone(strcat(argv(1), " ", argv(2)));
1121         }
1122         fclose(fh);
1123 }
1124
1125 .float modelindex_for_playersound;
1126 void UpdatePlayerSounds()
1127 {
1128         if(self.modelindex == self.modelindex_for_playersound)
1129                 return;
1130         self.modelindex_for_playersound = self.modelindex;
1131         ClearPlayerSounds();
1132         LoadPlayerSounds("sound/player/default.sounds", 1);
1133         LoadPlayerSounds(strcat(self.model, ".sounds"), 0);
1134 }
1135
1136 void GlobalSound(string sample, float chan, float voicetype)
1137 {
1138         float n;
1139         float tauntrand;
1140
1141         if(sample == "")
1142                 return;
1143
1144         tokenize_console(sample);
1145         n = stof(argv(1));
1146         if(n > 0)
1147                 sample = strcat(argv(0), ftos(floor(random() * n + 1)), ".wav"); // randomization
1148         else
1149                 sample = strcat(argv(0), ".wav"); // randomization
1150
1151         switch(voicetype)
1152         {
1153                 case VOICETYPE_LASTATTACKER_ONLY:
1154                         if(self.pusher)
1155                                 if(self.pusher.team == self.team)
1156                                 {
1157                                         msg_entity = self.pusher;
1158                                         if(clienttype(msg_entity) == CLIENTTYPE_REAL)
1159                                         {
1160                                                 if(msg_entity.cvar_cl_voice_directional == 1)
1161                                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_MIN);
1162                                                 else
1163                                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);
1164                                         }
1165                                 }
1166                         break;
1167                 case VOICETYPE_LASTATTACKER:
1168                         if(self.pusher)
1169                                 if(self.pusher.team == self.team)
1170                                 {
1171                                         msg_entity = self.pusher;
1172                                         if(clienttype(msg_entity) == CLIENTTYPE_REAL)
1173                                         {
1174                                                 if(msg_entity.cvar_cl_voice_directional == 1)
1175                                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_MIN);
1176                                                 else
1177                                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);
1178                                         }
1179                                         msg_entity = self;
1180                                         if(clienttype(msg_entity) == CLIENTTYPE_REAL)
1181                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTN_NONE);
1182                                 }
1183                         break;
1184                 case VOICETYPE_TEAMRADIO:
1185                         FOR_EACH_REALCLIENT(msg_entity)
1186                                 if(!teams_matter || msg_entity.team == self.team)
1187                                 {
1188                                         if(msg_entity.cvar_cl_voice_directional == 1)
1189                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_MIN);
1190                                         else
1191                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);
1192                                 }
1193                         break;
1194                 case VOICETYPE_AUTOTAUNT:
1195                         if(!sv_autotaunt)
1196                                 break;
1197                         if(!sv_taunt)
1198                                 break;
1199                         if(sv_gentle)
1200                                 break;
1201                         tauntrand = random();
1202                         FOR_EACH_REALCLIENT(msg_entity)
1203                                 if (tauntrand < msg_entity.cvar_cl_autotaunt)
1204                                 {
1205                                         if (msg_entity.cvar_cl_voice_directional >= 1)
1206                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX));
1207                                         else
1208                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);
1209                                 }
1210                         break;
1211                 case VOICETYPE_TAUNT:
1212                         if(self.classname == "player")
1213                                 if(self.deadflag == DEAD_NO)
1214                                         setanim(self, self.anim_taunt, FALSE, TRUE, TRUE);
1215                         if(!sv_taunt)
1216                                 break;
1217                         if(sv_gentle)
1218                                 break;
1219                         FOR_EACH_REALCLIENT(msg_entity)
1220                         {
1221                                 if (msg_entity.cvar_cl_voice_directional >= 1)
1222                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX));
1223                                 else
1224                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);
1225                         }
1226                 case VOICETYPE_PLAYERSOUND:
1227                         sound(self, chan, sample, VOL_BASE, ATTN_NORM);
1228                         break;
1229                 default:
1230                         backtrace("Invalid voice type!");
1231                         break;
1232         }
1233 }
1234
1235 void PlayerSound(.string samplefield, float chan, float voicetype)
1236 {
1237         string sample;
1238         sample = self.samplefield;
1239         GlobalSound(sample, chan, voicetype);
1240 }
1241
1242 void VoiceMessage(string type, string msg)
1243 {
1244         var .string sample;
1245         var float voicetype, ownteam;
1246         sample = GetVoiceMessageSampleField(type);
1247
1248         if(GetPlayerSoundSampleField_notFound)
1249         {
1250                 sprint(self, strcat("Invalid voice. Use one of: ", allvoicesamples, "\n"));
1251                 return;
1252         }
1253
1254         voicetype = GetVoiceMessageVoiceType(type);
1255         ownteam = (voicetype == VOICETYPE_TEAMRADIO);
1256
1257         float flood;
1258         float flood_spv;
1259         var .float flood_field;
1260
1261         flood = 0;
1262         if(ownteam)
1263         {
1264                 flood_spv = cvar("g_voice_flood_spv_team");
1265                 flood_field = floodcontrol_voiceteam;
1266         }
1267         else
1268         {
1269                 flood_spv = cvar("g_voice_flood_spv");
1270                 flood_field = floodcontrol_voice;
1271         }
1272
1273         if(time >= self.flood_field)
1274                 self.flood_field = max(time, self.flood_field) + flood_spv;
1275         else
1276                 flood = 1;
1277
1278         if (timeoutStatus == 2) //when game is paused, no flood protection
1279                 self.flood_field = flood = 0;
1280
1281         if (msg != "")
1282                 Say(self, ownteam, world, msg, 0);
1283
1284         if (!flood)
1285                 PlayerSound(sample, CHAN_VOICE, voicetype);
1286 }