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