]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/cl_player.qc
#include this
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
1 #if defined(CSQC)
2 #elif defined(MENUQC)
3 #elif defined(SVQC)
4         #include "../dpdefs/progsdefs.qc"
5     #include "../dpdefs/dpextensions.qc"
6     #include "sys-post.qh"
7     #include "../common/constants.qh"
8     #include "../common/teams.qh"
9     #include "../common/util.qh"
10     #include "../common/animdecide.qh"
11     #include "../common/weapons/weapons.qh"
12     #include "weapons/accuracy.qh"
13     #include "t_items.qh"
14     #include "autocvars.qh"
15     #include "constants.qh"
16     #include "defs.qh"
17     #include "../common/deathtypes.qh"
18     #include "mutators/mutators_include.qh"
19     #include "../common/mapinfo.qh"
20     #include "command/common.qh"
21     #include "../csqcmodellib/sv_model.qh"
22     #include "cheats.qh"
23     #include "../common/playerstats.qh"
24     #include "portals.qh"
25 #endif
26
27 .entity pusher;
28 .float pushltime;
29 .float istypefrag;
30
31 .float CopyBody_nextthink;
32 .void(void) CopyBody_think;
33 void CopyBody_Think(void)
34 {
35         if(self.CopyBody_nextthink && time > self.CopyBody_nextthink)
36         {
37                 self.CopyBody_think();
38                 if(wasfreed(self))
39                         return;
40                 self.CopyBody_nextthink = self.nextthink;
41                 self.CopyBody_think = self.think;
42                 self.think = CopyBody_Think;
43         }
44         CSQCMODEL_AUTOUPDATE();
45         self.nextthink = time;
46 }
47 void CopyBody(float keepvelocity)
48 {
49         entity oldself;
50         if (self.effects & EF_NODRAW)
51                 return;
52         oldself = self;
53         self = spawn();
54         self.enemy = oldself;
55         self.lip = oldself.lip;
56         self.colormap = oldself.colormap;
57         self.iscreature = oldself.iscreature;
58         self.teleportable = oldself.teleportable;
59         self.damagedbycontents = oldself.damagedbycontents;
60         self.angles = oldself.angles;
61         self.v_angle = oldself.v_angle;
62         self.avelocity = oldself.avelocity;
63         self.classname = "body";
64         self.damageforcescale = oldself.damageforcescale;
65         self.effects = oldself.effects;
66         self.glowmod = oldself.glowmod;
67         self.event_damage = oldself.event_damage;
68         self.anim_state = oldself.anim_state;
69         self.anim_time = oldself.anim_time;
70         self.anim_lower_action = oldself.anim_lower_action;
71         self.anim_lower_time = oldself.anim_lower_time;
72         self.anim_upper_action = oldself.anim_upper_action;
73         self.anim_upper_time = oldself.anim_upper_time;
74         self.anim_implicit_state = oldself.anim_implicit_state;
75         self.anim_implicit_time = oldself.anim_implicit_time;
76         self.anim_lower_implicit_action = oldself.anim_lower_implicit_action;
77         self.anim_lower_implicit_time = oldself.anim_lower_implicit_time;
78         self.anim_upper_implicit_action = oldself.anim_upper_implicit_action;
79         self.anim_upper_implicit_time = oldself.anim_upper_implicit_time;
80         self.dphitcontentsmask = oldself.dphitcontentsmask;
81         self.death_time = oldself.death_time;
82         self.pain_finished = oldself.pain_finished;
83         self.health = oldself.health;
84         self.armorvalue = oldself.armorvalue;
85         self.armortype = oldself.armortype;
86         self.model = oldself.model;
87         self.modelindex = oldself.modelindex;
88         self.skin = oldself.skin;
89         self.species = oldself.species;
90         self.movetype = oldself.movetype;
91         self.solid = oldself.solid;
92         self.ballistics_density = oldself.ballistics_density;
93         self.takedamage = oldself.takedamage;
94         self.customizeentityforclient = oldself.customizeentityforclient;
95         self.uncustomizeentityforclient = oldself.uncustomizeentityforclient;
96         self.uncustomizeentityforclient_set = oldself.uncustomizeentityforclient_set;
97         if (keepvelocity == 1)
98                 self.velocity = oldself.velocity;
99         self.oldvelocity = self.velocity;
100         self.alpha = oldself.alpha;
101         self.fade_time = oldself.fade_time;
102         self.fade_rate = oldself.fade_rate;
103         //self.weapon = oldself.weapon;
104         setorigin(self, oldself.origin);
105         setsize(self, oldself.mins, oldself.maxs);
106         self.prevorigin = oldself.origin;
107         self.reset = SUB_Remove;
108
109         Drag_MoveDrag(oldself, self);
110
111         if(self.colormap <= maxclients && self.colormap > 0)
112                 self.colormap = 1024 + oldself.clientcolors;
113
114         CSQCMODEL_AUTOINIT();
115         self.CopyBody_nextthink = oldself.nextthink;
116         self.CopyBody_think = oldself.think;
117         self.nextthink = time;
118         self.think = CopyBody_Think;
119         // "bake" the current animation frame for clones (they don't get clientside animation)
120         animdecide_load_if_needed(self);
121         animdecide_setframes(self, false, frame, frame1time, frame2, frame2time);
122
123         self = oldself;
124 }
125
126 float player_getspecies()
127 {
128         float s;
129         get_model_parameters(self.model, self.skin);
130         s = get_model_parameters_species;
131         get_model_parameters(string_null, 0);
132         if(s < 0)
133                 return SPECIES_HUMAN;
134         return s;
135 }
136
137 void player_setupanimsformodel()
138 {
139         // load animation info
140         animdecide_load_if_needed(self);
141         animdecide_setstate(self, 0, false);
142 }
143
144 void player_anim (void)
145 {
146         float deadbits = (self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
147         if(self.deadflag) {
148                 if (!deadbits) {
149                         // Decide on which death animation to use.
150                         if(random() < 0.5)
151                                 deadbits = ANIMSTATE_DEAD1;
152                         else
153                                 deadbits = ANIMSTATE_DEAD2;
154                 }
155         } else {
156                 // Clear a previous death animation.
157                 deadbits = 0;
158         }
159         float animbits = deadbits;
160         if(self.frozen)
161                 animbits |= ANIMSTATE_FROZEN;
162         if(self.crouch)
163                 animbits |= ANIMSTATE_DUCK;
164         animdecide_setstate(self, animbits, false);
165         animdecide_setimplicitstate(self, (self.flags & FL_ONGROUND));
166
167         if (self.weaponentity)
168         {
169                 updateanim(self.weaponentity);
170                 if (!self.weaponentity.animstate_override)
171                         setanim(self.weaponentity, self.weaponentity.anim_idle, true, false, false);
172         }
173 }
174
175 void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
176 {
177         float take, save;
178         vector v;
179         Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
180
181         // damage resistance (ignore most of the damage from a bullet or similar)
182         damage = max(damage - 5, 1);
183
184         v = healtharmor_applydamage(self.armorvalue, autocvar_g_balance_armor_blockpercent, deathtype, damage);
185         take = v.x;
186         save = v.y;
187
188         if(sound_allowed(MSG_BROADCAST, attacker))
189         {
190                 if (save > 10)
191                         sound (self, CH_SHOTS, "misc/armorimpact.wav", VOL_BASE, ATTEN_NORM);
192                 else if (take > 30)
193                         sound (self, CH_SHOTS, "misc/bodyimpact2.wav", VOL_BASE, ATTEN_NORM);
194                 else if (take > 10)
195                         sound (self, CH_SHOTS, "misc/bodyimpact1.wav", VOL_BASE, ATTEN_NORM);
196         }
197
198         if (take > 50)
199                 Violence_GibSplash_At(hitloc, force * -0.1, 3, 1, self, attacker);
200         if (take > 100)
201                 Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, self, attacker);
202
203         self.armorvalue = self.armorvalue - save;
204         self.health = self.health - take;
205         // pause regeneration for 5 seconds
206         self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_health_regen);
207
208         self.dmg_save = self.dmg_save + save;//max(save - 10, 0);
209         self.dmg_take = self.dmg_take + take;//max(take - 10, 0);
210         self.dmg_inflictor = inflictor;
211
212         if (self.health <= -autocvar_sv_gibhealth && self.alpha >= 0)
213         {
214                 // don't use any animations as a gib
215                 self.frame = 0;
216                 // view just above the floor
217                 self.view_ofs = '0 0 4';
218
219                 Violence_GibSplash(self, 1, 1, attacker);
220                 self.alpha = -1;
221                 self.solid = SOLID_NOT; // restore later
222                 self.takedamage = DAMAGE_NO; // restore later
223                 self.damagedbycontents = false;
224         }
225 }
226
227 // g_<gametype>_str:
228 // If 0, default is used.
229 // If <0, 0 is used.
230 // Otherwise, g_str (default value) is used.
231 // For consistency, negative values there are mapped to zero too.
232 #define GAMETYPE_DEFAULTED_SETTING(str) \
233         ((gametype_setting_tmp = cvar(strcat("g_", GetGametype(), "_" #str))), \
234          (gametype_setting_tmp < 0) ? 0 : \
235          (gametype_setting_tmp == 0) ? max(0, autocvar_g_##str) : \
236          gametype_setting_tmp)
237
238
239 void calculate_player_respawn_time()
240 {
241         if(g_ca)
242                 return;
243
244         float gametype_setting_tmp;
245         float sdelay_max = GAMETYPE_DEFAULTED_SETTING(respawn_delay_max);
246         float sdelay_small = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small);
247         float sdelay_large = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large);
248         float sdelay_small_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small_count);
249         float sdelay_large_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large_count);
250         float waves = GAMETYPE_DEFAULTED_SETTING(respawn_waves);
251
252         float pcount = 1;  // Include myself whether or not team is already set right and I'm a "player".
253         entity pl;
254         if (teamplay)
255         {
256                 FOR_EACH_PLAYER(pl)
257                         if (pl != self)
258                                 if (pl.team == self.team)
259                                         ++pcount;
260                 if (sdelay_small_count == 0)
261                         sdelay_small_count = 1;
262                 if (sdelay_large_count == 0)
263                         sdelay_large_count = 1;
264         }
265         else
266         {
267                 FOR_EACH_PLAYER(pl)
268                         if (pl != self)
269                                 ++pcount;
270                 if (sdelay_small_count == 0)
271                 {
272                         if (g_cts)
273                         {
274                                 // Players play independently. No point in requiring enemies.
275                                 sdelay_small_count = 1;
276                         }
277                         else
278                         {
279                                 // Players play AGAINST each other. Enemies required.
280                                 sdelay_small_count = 2;
281                         }
282                 }
283                 if (sdelay_large_count == 0)
284                 {
285                         if (g_cts)
286                         {
287                                 // Players play independently. No point in requiring enemies.
288                                 sdelay_large_count = 1;
289                         }
290                         else
291                         {
292                                 // Players play AGAINST each other. Enemies required.
293                                 sdelay_large_count = 2;
294                         }
295                 }
296         }
297
298         float sdelay;
299
300         if (pcount <= sdelay_small_count)
301                 sdelay = sdelay_small;
302         else if (pcount >= sdelay_large_count)
303                 sdelay = sdelay_large;
304         else  // NOTE: this case implies sdelay_large_count > sdelay_small_count.
305                 sdelay = sdelay_small + (sdelay_large - sdelay_small) * (pcount - sdelay_small_count) / (sdelay_large_count - sdelay_small_count);
306
307         if(waves)
308                 self.respawn_time = ceil((time + sdelay) / waves) * waves;
309         else
310                 self.respawn_time = time + sdelay;
311
312         if(sdelay < sdelay_max)
313                 self.respawn_time_max = time + sdelay_max;
314         else
315                 self.respawn_time_max = self.respawn_time;
316
317         if((sdelay + waves >= 5.0) && (self.respawn_time - time > 1.75))
318                 self.respawn_countdown = 10; // first number to count down from is 10
319         else
320                 self.respawn_countdown = -1; // do not count down
321
322         if(autocvar_g_forced_respawn)
323                 self.respawn_flags = self.respawn_flags | RESPAWN_FORCE;
324 }
325
326 void ClientKill_Now_TeamChange();
327
328 void PlayerDamage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
329 {
330         float take, save, dh, da, j;
331         vector v;
332         float valid_damage_for_weaponstats;
333         float excess;
334
335         dh = max(self.health, 0);
336         da = max(self.armorvalue, 0);
337
338         if(!DEATH_ISSPECIAL(deathtype))
339         {
340                 damage *= sqrt(bound(1.0, self.cvar_cl_handicap, 100.0));
341                 if(self != attacker)
342                         damage /= sqrt(bound(1.0, attacker.cvar_cl_handicap, 100.0));
343         }
344
345         if(DEATH_ISWEAPON(deathtype, WEP_TUBA))
346         {
347                 // tuba causes blood to come out of the ears
348                 vector ear1, ear2;
349                 vector d;
350                 float f;
351                 ear1 = self.origin;
352                 ear1_z += 0.125 * self.view_ofs.z + 0.875 * self.maxs.z; // 7/8
353                 ear2 = ear1;
354                 makevectors(self.angles);
355                 ear1 += v_right * -10;
356                 ear2 += v_right * +10;
357                 d = inflictor.origin - self.origin;
358                 if (d)
359                         f = (d * v_right) / vlen(d); // this is cos of angle of d and v_right!
360                 else
361                         f = 0;  // Assum ecenter.
362                 force = v_right * vlen(force);
363                 Violence_GibSplash_At(ear1, force * -1, 2, bound(0, damage, 25) / 2 * (0.5 - 0.5 * f), self, attacker);
364                 Violence_GibSplash_At(ear2, force,      2, bound(0, damage, 25) / 2 * (0.5 + 0.5 * f), self, attacker);
365                 if(f > 0)
366                 {
367                         hitloc = ear1;
368                         force = force * -1;
369                 }
370                 else
371                 {
372                         hitloc = ear2;
373                         // force is already good
374                 }
375         }
376         else
377                 Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
378
379
380         v = healtharmor_applydamage(self.armorvalue, autocvar_g_balance_armor_blockpercent, deathtype, damage);
381         take = v.x;
382         save = v.y;
383
384         if(attacker == self)
385         {
386                 // don't reset pushltime for self damage as it may be an attempt to
387                 // escape a lava pit or similar
388                 //self.pushltime = 0;
389                 self.istypefrag = 0;
390         }
391         else if(IS_PLAYER(attacker))
392         {
393                 self.pusher = attacker;
394                 self.pushltime = time + autocvar_g_maxpushtime;
395                 self.istypefrag = self.BUTTON_CHAT;
396         }
397         else if(time < self.pushltime)
398         {
399                 attacker = self.pusher;
400                 self.pushltime = max(self.pushltime, time + 0.6);
401         }
402         else
403         {
404                 self.pushltime = 0;
405                 self.istypefrag = 0;
406         }
407
408         frag_inflictor = inflictor;
409         frag_attacker = attacker;
410         frag_target = self;
411         frag_damage = damage;
412         damage_take = take;
413         damage_save = save;
414         damage_force = force;
415         MUTATOR_CALLHOOK(PlayerDamage_SplitHealthArmor);
416         take = bound(0, damage_take, self.health);
417         save = bound(0, damage_save, self.armorvalue);
418         excess = max(0, damage - take - save);
419
420         if(sound_allowed(MSG_BROADCAST, attacker))
421         {
422                 if (save > 10)
423                         sound (self, CH_SHOTS, "misc/armorimpact.wav", VOL_BASE, ATTEN_NORM);
424                 else if (take > 30)
425                         sound (self, CH_SHOTS, "misc/bodyimpact2.wav", VOL_BASE, ATTEN_NORM);
426                 else if (take > 10)
427                         sound (self, CH_SHOTS, "misc/bodyimpact1.wav", VOL_BASE, ATTEN_NORM); // FIXME possibly remove them?
428         }
429
430         if (take > 50)
431                 Violence_GibSplash_At(hitloc, force * -0.1, 3, 1, self, attacker);
432         if (take > 100)
433                 Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, self, attacker);
434
435         if (time >= self.spawnshieldtime)
436         {
437                 if (!(self.flags & FL_GODMODE))
438                 {
439                         self.armorvalue = self.armorvalue - save;
440                         self.health = self.health - take;
441                         // pause regeneration for 5 seconds
442                         if(take)
443                                 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_health_regen);
444
445                         if (time > self.pain_finished)          //Don't switch pain sequences like crazy
446                         {
447                                 self.pain_finished = time + 0.5;        //Supajoe
448
449                                 if(autocvar_sv_gentle < 1) {
450                                         if(self.classname != "body") // pain anim is BORKED on our ZYMs, FIXME remove this once we have good models
451                                         {
452                                                 if (!self.animstate_override)
453                                                 {
454                                                         if (random() > 0.5)
455                                                                 animdecide_setaction(self, ANIMACTION_PAIN1, true);
456                                                         else
457                                                                 animdecide_setaction(self, ANIMACTION_PAIN2, true);
458                                                 }
459                                         }
460
461                                         if(sound_allowed(MSG_BROADCAST, attacker))
462                                         if((self.health < 2 * WEP_CVAR_PRI(blaster, damage) * autocvar_g_balance_selfdamagepercent + 1) || !((get_weaponinfo(DEATH_WEAPONOF(deathtype))).spawnflags & WEP_FLAG_CANCLIMB) || attacker != self) // WEAPONTODO: create separate limit for pain notification with laser
463                                         if(self.health > 1)
464                                         // exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two
465                                         {
466                                                 if(deathtype == DEATH_FALL)
467                                                         PlayerSound(playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
468                                                 else if(self.health > 75) // TODO make a "gentle" version?
469                                                         PlayerSound(playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
470                                                 else if(self.health > 50)
471                                                         PlayerSound(playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
472                                                 else if(self.health > 25)
473                                                         PlayerSound(playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
474                                                 else
475                                                         PlayerSound(playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
476                                         }
477                                 }
478                         }
479
480                         // throw off bot aim temporarily
481                         float shake;
482                         if(IS_BOT_CLIENT(self) && self.health >= 1)
483                         {
484                                 shake = damage * 5 / (bound(0,skill,100) + 1);
485                                 self.v_angle_x = self.v_angle.x + (random() * 2 - 1) * shake;
486                                 self.v_angle_y = self.v_angle.y + (random() * 2 - 1) * shake;
487                                 self.v_angle_x = bound(-90, self.v_angle.x, 90);
488                         }
489                 }
490                 else
491                         self.max_armorvalue += (save + take);
492         }
493         self.dmg_save = self.dmg_save + save;//max(save - 10, 0);
494         self.dmg_take = self.dmg_take + take;//max(take - 10, 0);
495         self.dmg_inflictor = inflictor;
496
497         float abot, vbot, awep;
498         abot = (IS_BOT_CLIENT(attacker));
499         vbot = (IS_BOT_CLIENT(self));
500
501         valid_damage_for_weaponstats = 0;
502         awep = 0;
503
504         if(vbot || IS_REAL_CLIENT(self))
505         if(abot || IS_REAL_CLIENT(attacker))
506         if(attacker && self != attacker)
507         if(DIFF_TEAM(self, attacker))
508         {
509                 if(DEATH_ISSPECIAL(deathtype))
510                         awep = attacker.weapon;
511                 else
512                         awep = DEATH_WEAPONOF(deathtype);
513                 valid_damage_for_weaponstats = 1;
514         }
515
516         if(valid_damage_for_weaponstats)
517         {
518                 dh = dh - max(self.health, 0);
519                 da = da - max(self.armorvalue, 0);
520                 WeaponStats_LogDamage(awep, abot, self.weapon, vbot, dh + da);
521         }
522
523         if (self.health < 1)
524         {
525                 float defer_ClientKill_Now_TeamChange;
526                 defer_ClientKill_Now_TeamChange = false;
527
528                 if(self.alivetime)
529                 {
530                         PS_GR_P_ADDVAL(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
531                         self.alivetime = 0;
532                 }
533
534                 if(valid_damage_for_weaponstats)
535                         WeaponStats_LogKill(awep, abot, self.weapon, vbot);
536
537                 if(autocvar_sv_gentle < 1) // TODO make a "gentle" version?
538                 if(sound_allowed(MSG_BROADCAST, attacker))
539                 {
540                         if(deathtype == DEATH_DROWN)
541                                 PlayerSound(playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
542                         else
543                                 PlayerSound(playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
544                 }
545
546                 // get rid of kill indicator
547                 if(self.killindicator)
548                 {
549                         remove(self.killindicator);
550                         self.killindicator = world;
551                         if(self.killindicator_teamchange)
552                                 defer_ClientKill_Now_TeamChange = true;
553
554                         if(self.classname == "body")
555                         if(deathtype == DEATH_KILL)
556                         {
557                                 // for the lemmings fans, a small harmless explosion
558                                 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
559                         }
560                 }
561
562                 // print an obituary message
563                 if(self.classname != "body")
564                         Obituary (attacker, inflictor, self, deathtype);
565
566         // increment frag counter for used weapon type
567         float w;
568         w = DEATH_WEAPONOF(deathtype);
569         if(WEP_VALID(w))
570         if(accuracy_isgooddamage(attacker, self))
571         attacker.accuracy.(accuracy_frags[w-1]) += 1;
572
573                 frag_attacker = attacker;
574                 frag_inflictor = inflictor;
575                 frag_target = self;
576                 frag_deathtype = deathtype;
577                 MUTATOR_CALLHOOK(PlayerDies);
578
579                 WEP_ACTION(self.weapon, WR_PLAYERDEATH);
580
581                 RemoveGrapplingHook(self);
582
583                 Portal_ClearAllLater(self);
584
585                 self.fixangle = true;
586
587                 if(defer_ClientKill_Now_TeamChange)
588                         ClientKill_Now_TeamChange(); // can turn player into spectator
589
590                 // player could have been miraculously resuscitated ;)
591                 // e.g. players in freezetag get frozen, they don't really die
592                 if(self.health >= 1 || !(IS_PLAYER(self) || self.classname == "body"))
593                         return;
594
595                 // when we get here, player actually dies
596
597                 Unfreeze(self); // remove any icy remains
598                 self.health = 0; // Unfreeze resets health, so we need to set it back
599
600                 // clear waypoints
601                 WaypointSprite_PlayerDead();
602                 // throw a weapon
603                 SpawnThrownWeapon (self.origin + (self.mins + self.maxs) * 0.5, self.switchweapon);
604
605                 // become fully visible
606                 self.alpha = default_player_alpha;
607                 // make the corpse upright (not tilted)
608                 self.angles_x = 0;
609                 self.angles_z = 0;
610                 // don't spin
611                 self.avelocity = '0 0 0';
612                 // view from the floor
613                 self.view_ofs = '0 0 -8';
614                 // toss the corpse
615                 self.movetype = MOVETYPE_TOSS;
616                 // shootable corpse
617                 self.solid = SOLID_CORPSE;
618                 self.ballistics_density = autocvar_g_ballistics_density_corpse;
619                 // don't stick to the floor
620                 self.flags &= ~FL_ONGROUND;
621                 // dying animation
622                 self.deadflag = DEAD_DYING;
623
624                 // when to allow respawn
625                 calculate_player_respawn_time();
626
627                 self.death_time = time;
628                 if (random() < 0.5)
629                         animdecide_setstate(self, self.anim_state | ANIMSTATE_DEAD1, true);
630                 else
631                         animdecide_setstate(self, self.anim_state | ANIMSTATE_DEAD2, true);
632                 if (self.maxs.z > 5)
633                 {
634                         self.maxs_z = 5;
635                         setsize(self, self.mins, self.maxs);
636                 }
637                 // set damage function to corpse damage
638                 self.event_damage = PlayerCorpseDamage;
639                 // call the corpse damage function just in case it wants to gib
640                 self.event_damage(inflictor, attacker, excess, deathtype, hitloc, force);
641
642                 // set up to fade out later
643                 SUB_SetFade (self, time + 6 + random (), 1);
644                 // reset body think wrapper broken by SUB_SetFade
645                 if(self.classname == "body" && self.think != CopyBody_Think) {
646                         self.CopyBody_think = self.think;
647                         self.CopyBody_nextthink = self.nextthink;
648                         self.think = CopyBody_Think;
649                         self.nextthink = time;
650                 }
651
652                 if(autocvar_sv_gentle > 0 || autocvar_ekg || self.classname == "body") {
653                         // remove corpse
654                         // clones don't run any animation code any more, so we must gib them when they die :(
655                         PlayerCorpseDamage (inflictor, attacker, autocvar_sv_gibhealth+1.0, deathtype, hitloc, force);
656                 }
657
658                 // reset fields the weapons may use just in case
659                 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
660                 {
661                         WEP_ACTION(j, WR_RESETPLAYER);
662                         ATTACK_FINISHED_FOR(self, j) = 0;
663                 }
664         }
665 }
666
667 .float muted; // to be used by prvm_edictset server playernumber muted 1
668 float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol)
669 // message "": do not say, just test flood control
670 // return value:
671 //   1 = accept
672 //   0 = reject
673 //  -1 = fake accept
674 {
675         string msgstr, colorstr, cmsgstr, namestr, fullmsgstr, sourcemsgstr, fullcmsgstr, sourcecmsgstr, colorprefix;
676         float flood;
677         var .float flood_field;
678         entity head;
679         float ret;
680         string privatemsgprefix = string_null; float privatemsgprefixlen = 0;
681
682         if(!teamsay && !privatesay)
683                 if(substring(msgin, 0, 1) == " ")
684                         msgin = substring(msgin, 1, strlen(msgin) - 1); // work around DP say bug (say_team does not have this!)
685
686         msgin = formatmessage(msgin);
687
688         if (!IS_PLAYER(source))
689                 colorstr = "^0"; // black for spectators
690         else if(teamplay)
691                 colorstr = Team_ColorCode(source.team);
692         else
693         {
694                 colorstr = "";
695                 teamsay = false;
696         }
697
698         if(intermission_running)
699                 teamsay = false;
700
701         if(msgin != "")
702                 msgin = trigger_magicear_processmessage_forallears(source, teamsay, privatesay, msgin);
703
704         /*
705          * using bprint solves this... me stupid
706         // how can we prevent the message from appearing in a listen server?
707         // for now, just give "say" back and only handle say_team
708         if(!teamsay)
709         {
710                 clientcommand(self, strcat("say ", msgin));
711                 return;
712         }
713         */
714
715         if(autocvar_g_chat_teamcolors)
716                 namestr = playername(source);
717         else
718                 namestr = source.netname;
719
720         if(strdecolorize(namestr) == namestr)
721                 colorprefix = "^3";
722         else
723                 colorprefix = "^7";
724
725         if(msgin != "")
726         {
727                 if(privatesay)
728                 {
729                         msgstr = strcat("\{1}\{13}* ", colorprefix, namestr, "^3 tells you: ^7");
730                         privatemsgprefixlen = strlen(msgstr);
731                         msgstr = strcat(msgstr, msgin);
732                         cmsgstr = strcat(colorstr, colorprefix, namestr, "^3 tells you:\n^7", msgin);
733                         if(autocvar_g_chat_teamcolors)
734                                 privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", playername(privatesay), ": ^7");
735                         else
736                                 privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", privatesay.netname, ": ^7");
737                 }
738                 else if(teamsay)
739                 {
740                         msgstr = strcat("\{1}\{13}", colorstr, "(", colorprefix, namestr, colorstr, ") ^7", msgin);
741                         cmsgstr = strcat(colorstr, "(", colorprefix, namestr, colorstr, ")\n^7", msgin);
742                 }
743                 else
744                 {
745                         msgstr = strcat("\{1}", colorprefix, namestr, "^7: ", msgin);
746                         cmsgstr = "";
747                 }
748                 msgstr = strcat(strreplace("\n", " ", msgstr), "\n"); // newlines only are good for centerprint
749         }
750         else
751         {
752                 msgstr = cmsgstr = "";
753         }
754
755         fullmsgstr = msgstr;
756         fullcmsgstr = cmsgstr;
757
758         // FLOOD CONTROL
759         flood = 0;
760         flood_field = floodcontrol_chat;
761         if(floodcontrol)
762         {
763                 float flood_spl;
764                 float flood_burst;
765                 float flood_lmax;
766                 float lines;
767                 if(privatesay)
768                 {
769                         flood_spl = autocvar_g_chat_flood_spl_tell;
770                         flood_burst = autocvar_g_chat_flood_burst_tell;
771                         flood_lmax = autocvar_g_chat_flood_lmax_tell;
772                         flood_field = floodcontrol_chattell;
773                 }
774                 else if(teamsay)
775                 {
776                         flood_spl = autocvar_g_chat_flood_spl_team;
777                         flood_burst = autocvar_g_chat_flood_burst_team;
778                         flood_lmax = autocvar_g_chat_flood_lmax_team;
779                         flood_field = floodcontrol_chatteam;
780                 }
781                 else
782                 {
783                         flood_spl = autocvar_g_chat_flood_spl;
784                         flood_burst = autocvar_g_chat_flood_burst;
785                         flood_lmax = autocvar_g_chat_flood_lmax;
786                         flood_field = floodcontrol_chat;
787                 }
788                 flood_burst = max(0, flood_burst - 1);
789                 // to match explanation in default.cfg, a value of 3 must allow three-line bursts and not four!
790
791                 // do flood control for the default line size
792                 if(msgstr != "")
793                 {
794                         getWrappedLine_remaining = msgstr;
795                         msgstr = "";
796                         lines = 0;
797                         while(getWrappedLine_remaining && (!flood_lmax || lines <= flood_lmax))
798                         {
799                                 msgstr = strcat(msgstr, " ", getWrappedLineLen(82.4289758859709, strlennocol)); // perl averagewidth.pl < gfx/vera-sans.width
800                                 ++lines;
801                         }
802                         msgstr = substring(msgstr, 1, strlen(msgstr) - 1);
803
804                         if(getWrappedLine_remaining != "")
805                         {
806                                 msgstr = strcat(msgstr, "\n");
807                                 flood = 2;
808                         }
809
810                         if(time >= source.flood_field)
811                         {
812                                 source.flood_field = max(time - flood_burst * flood_spl, source.flood_field) + lines * flood_spl;
813                         }
814                         else
815                         {
816                                 flood = 1;
817                                 msgstr = fullmsgstr;
818                         }
819                 }
820                 else
821                 {
822                         if(time >= source.flood_field)
823                                 source.flood_field = max(time - flood_burst * flood_spl, source.flood_field) + flood_spl;
824                         else
825                                 flood = 1;
826                 }
827
828                 if (timeout_status == TIMEOUT_ACTIVE) // when game is paused, no flood protection
829                         source.flood_field = flood = 0;
830         }
831
832         if(flood == 2) // cannot happen for empty msgstr
833         {
834                 if(autocvar_g_chat_flood_notify_flooder)
835                 {
836                         sourcemsgstr = strcat(msgstr, "\n^3FLOOD CONTROL: ^7message too long, trimmed\n");
837                         sourcecmsgstr = "";
838                 }
839                 else
840                 {
841                         sourcemsgstr = fullmsgstr;
842                         sourcecmsgstr = fullcmsgstr;
843                 }
844                 cmsgstr = "";
845         }
846         else
847         {
848                 sourcemsgstr = msgstr;
849                 sourcecmsgstr = cmsgstr;
850         }
851
852         if(!privatesay)
853         if (!IS_PLAYER(source))
854         {
855                 if (!intermission_running)
856                         if(teamsay || (autocvar_g_chat_nospectators == 1) || (autocvar_g_chat_nospectators == 2 && !(warmup_stage || gameover)))
857                                 teamsay = -1; // spectators
858         }
859
860         if(flood)
861                 print("NOTE: ", playername(source), "^7 is flooding.\n");
862
863         // build sourcemsgstr by cutting off a prefix and replacing it by the other one
864         if(privatesay)
865                 sourcemsgstr = strcat(privatemsgprefix, substring(sourcemsgstr, privatemsgprefixlen, -1));
866
867         if(source.muted)
868         {
869                 // always fake the message
870                 ret = -1;
871         }
872         else if(flood == 1)
873         {
874                 if(autocvar_g_chat_flood_notify_flooder)
875                 {
876                         sprint(source, strcat("^3FLOOD CONTROL: ^7wait ^1", ftos(source.flood_field - time), "^3 seconds\n"));
877                         ret = 0;
878                 }
879                 else
880                         ret = -1;
881         }
882         else
883         {
884                 ret = 1;
885         }
886
887         if(sourcemsgstr != "" && ret != 0)
888         {
889                 if(ret < 0) // faked message, because the player is muted
890                 {
891                         sprint(source, sourcemsgstr);
892                         if(sourcecmsgstr != "" && !privatesay)
893                                 centerprint(source, sourcecmsgstr);
894                 }
895                 else if(privatesay) // private message, between 2 people only
896                 {
897                         sprint(source, sourcemsgstr);
898                         sprint(privatesay, msgstr);
899                         if (!autocvar_g_chat_tellprivacy) { dedicated_print(msgstr); } // send to server console too if "tellprivacy" is disabled
900                         if(cmsgstr != "")
901                                 centerprint(privatesay, cmsgstr);
902                 }
903                 else if(teamsay > 0) // team message, only sent to team mates
904                 {
905                         sprint(source, sourcemsgstr);
906                         dedicated_print(msgstr); // send to server console too
907                         if(sourcecmsgstr != "")
908                                 centerprint(source, sourcecmsgstr);
909                         FOR_EACH_REALPLAYER(head) if(head.team == source.team)
910                                 if(head != source)
911                                 {
912                                         sprint(head, msgstr);
913                                         if(cmsgstr != "")
914                                                 centerprint(head, cmsgstr);
915                                 }
916                 }
917                 else if(teamsay < 0) // spectator message, only sent to spectators
918                 {
919                         sprint(source, sourcemsgstr);
920                         dedicated_print(msgstr); // send to server console too
921                         FOR_EACH_REALCLIENT(head) if (!IS_PLAYER(head))
922                                 if(head != source)
923                                         sprint(head, msgstr);
924                 }
925                 else if(sourcemsgstr != msgstr) // trimmed/server fixed message, sent to all players
926                 {
927                         sprint(source, sourcemsgstr);
928                         dedicated_print(msgstr); // send to server console too
929                         FOR_EACH_REALCLIENT(head)
930                                 if(head != source)
931                                         sprint(head, msgstr);
932                 }
933                 else
934                         bprint(msgstr); // entirely normal message, sent to all players -- bprint sends to server console too.
935         }
936
937         return ret;
938 }
939
940 float GetVoiceMessageVoiceType(string type)
941 {
942         if(type == "taunt")
943                 return VOICETYPE_TAUNT;
944         if(type == "teamshoot")
945                 return VOICETYPE_LASTATTACKER;
946         return VOICETYPE_TEAMRADIO;
947 }
948
949 string allvoicesamples;
950 .string GetVoiceMessageSampleField(string type)
951 {
952         GetPlayerSoundSampleField_notFound = 0;
953         switch(type)
954         {
955 #define _VOICEMSG(m) case #m: return playersound_##m;
956                 ALLVOICEMSGS
957 #undef _VOICEMSG
958         }
959         GetPlayerSoundSampleField_notFound = 1;
960         return playersound_taunt;
961 }
962
963 .string GetPlayerSoundSampleField(string type)
964 {
965         GetPlayerSoundSampleField_notFound = 0;
966         switch(type)
967         {
968 #define _VOICEMSG(m) case #m: return playersound_##m;
969                 ALLPLAYERSOUNDS
970 #undef _VOICEMSG
971         }
972         GetPlayerSoundSampleField_notFound = 1;
973         return playersound_taunt;
974 }
975
976 void PrecacheGlobalSound(string samplestring)
977 {
978         float n, i;
979         tokenize_console(samplestring);
980         n = stof(argv(1));
981         if(n > 0)
982         {
983                 for(i = 1; i <= n; ++i)
984                         precache_sound(strcat(argv(0), ftos(i), ".wav"));
985         }
986         else
987         {
988                 precache_sound(strcat(argv(0), ".wav"));
989         }
990 }
991
992 void PrecachePlayerSounds(string f)
993 {
994         float fh;
995         string s;
996         fh = fopen(f, FILE_READ);
997         if(fh < 0)
998                 return;
999         while((s = fgets(fh)))
1000         {
1001                 if(tokenize_console(s) != 3)
1002                 {
1003                         dprint("Invalid sound info line: ", s, "\n");
1004                         continue;
1005                 }
1006                 PrecacheGlobalSound(strcat(argv(1), " ", argv(2)));
1007         }
1008         fclose(fh);
1009
1010         if (!allvoicesamples)
1011         {
1012 #define _VOICEMSG(m) allvoicesamples = strcat(allvoicesamples, " ", #m);
1013                 ALLVOICEMSGS
1014 #undef _VOICEMSG
1015                 allvoicesamples = strzone(substring(allvoicesamples, 1, strlen(allvoicesamples) - 1));
1016         }
1017 }
1018
1019 void ClearPlayerSounds()
1020 {
1021 #define _VOICEMSG(m) if(self.playersound_##m) { strunzone(self.playersound_##m); self.playersound_##m = string_null; }
1022         ALLPLAYERSOUNDS
1023         ALLVOICEMSGS
1024 #undef _VOICEMSG
1025 }
1026
1027 float LoadPlayerSounds(string f, float first)
1028 {
1029         float fh;
1030         string s;
1031         var .string field;
1032         fh = fopen(f, FILE_READ);
1033         if(fh < 0)
1034         {
1035                 dprint("Player sound file not found: ", f, "\n");
1036                 return 0;
1037         }
1038         while((s = fgets(fh)))
1039         {
1040                 if(tokenize_console(s) != 3)
1041                         continue;
1042                 field = GetPlayerSoundSampleField(argv(0));
1043                 if(GetPlayerSoundSampleField_notFound)
1044                         field = GetVoiceMessageSampleField(argv(0));
1045                 if(GetPlayerSoundSampleField_notFound)
1046                         continue;
1047                 if(self.field)
1048                         strunzone(self.field);
1049                 self.field = strzone(strcat(argv(1), " ", argv(2)));
1050         }
1051         fclose(fh);
1052         return 1;
1053 }
1054
1055 .float modelindex_for_playersound;
1056 .float skin_for_playersound;
1057 void UpdatePlayerSounds()
1058 {
1059         if(self.modelindex == self.modelindex_for_playersound)
1060         if(self.skin == self.skin_for_playersound)
1061                 return;
1062         self.modelindex_for_playersound = self.modelindex;
1063         self.skin_for_playersound = self.skin;
1064         ClearPlayerSounds();
1065         LoadPlayerSounds("sound/player/default.sounds", 1);
1066         if(!autocvar_g_debug_defaultsounds)
1067                 if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skin, "sounds"), 0))
1068                         LoadPlayerSounds(get_model_datafilename(self.model, 0, "sounds"), 0);
1069 }
1070
1071 void FakeGlobalSound(string sample, float chan, float voicetype)
1072 {
1073         float n;
1074         float tauntrand;
1075
1076         if(sample == "")
1077                 return;
1078
1079         tokenize_console(sample);
1080         n = stof(argv(1));
1081         if(n > 0)
1082                 sample = strcat(argv(0), ftos(floor(random() * n + 1)), ".wav"); // randomization
1083         else
1084                 sample = strcat(argv(0), ".wav"); // randomization
1085
1086         switch(voicetype)
1087         {
1088                 case VOICETYPE_LASTATTACKER_ONLY:
1089                         break;
1090                 case VOICETYPE_LASTATTACKER:
1091                         if(self.pusher)
1092                         {
1093                                 msg_entity = self;
1094                                 if(IS_REAL_CLIENT(msg_entity))
1095                                         soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTEN_NONE);
1096                         }
1097                         break;
1098                 case VOICETYPE_TEAMRADIO:
1099                         msg_entity = self;
1100                         if(msg_entity.cvar_cl_voice_directional == 1)
1101                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN);
1102                         else
1103                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1104                         break;
1105                 case VOICETYPE_AUTOTAUNT:
1106                         if(!sv_autotaunt)
1107                                 break;
1108                         if(!sv_taunt)
1109                                 break;
1110                         if(autocvar_sv_gentle)
1111                                 break;
1112                         tauntrand = random();
1113                         msg_entity = self;
1114                         if (tauntrand < msg_entity.cvar_cl_autotaunt)
1115                         {
1116                                 if (msg_entity.cvar_cl_voice_directional >= 1)
1117                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX));
1118                                 else
1119                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1120                         }
1121                         break;
1122                 case VOICETYPE_TAUNT:
1123                         if(IS_PLAYER(self))
1124                                 if(self.deadflag == DEAD_NO)
1125                                         animdecide_setaction(self, ANIMACTION_TAUNT, true);
1126                         if(!sv_taunt)
1127                                 break;
1128                         if(autocvar_sv_gentle)
1129                                 break;
1130                         msg_entity = self;
1131                         if (msg_entity.cvar_cl_voice_directional >= 1)
1132                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX));
1133                         else
1134                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1135                         break;
1136                 case VOICETYPE_PLAYERSOUND:
1137                         msg_entity = self;
1138                         soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTEN_NORM);
1139                         break;
1140                 default:
1141                         backtrace("Invalid voice type!");
1142                         break;
1143         }
1144 }
1145
1146 void GlobalSound(string sample, float chan, float voicetype)
1147 {
1148         float n;
1149         float tauntrand;
1150
1151         if(sample == "")
1152                 return;
1153
1154         tokenize_console(sample);
1155         n = stof(argv(1));
1156         if(n > 0)
1157                 sample = strcat(argv(0), ftos(floor(random() * n + 1)), ".wav"); // randomization
1158         else
1159                 sample = strcat(argv(0), ".wav"); // randomization
1160
1161         switch(voicetype)
1162         {
1163                 case VOICETYPE_LASTATTACKER_ONLY:
1164                         if(self.pusher)
1165                         {
1166                                 msg_entity = self.pusher;
1167                                 if(IS_REAL_CLIENT(msg_entity))
1168                                 {
1169                                         if(msg_entity.cvar_cl_voice_directional == 1)
1170                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN);
1171                                         else
1172                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1173                                 }
1174                         }
1175                         break;
1176                 case VOICETYPE_LASTATTACKER:
1177                         if(self.pusher)
1178                         {
1179                                 msg_entity = self.pusher;
1180                                 if(IS_REAL_CLIENT(msg_entity))
1181                                 {
1182                                         if(msg_entity.cvar_cl_voice_directional == 1)
1183                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN);
1184                                         else
1185                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1186                                 }
1187                                 msg_entity = self;
1188                                 if(IS_REAL_CLIENT(msg_entity))
1189                                         soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTEN_NONE);
1190                         }
1191                         break;
1192                 case VOICETYPE_TEAMRADIO:
1193                         FOR_EACH_REALCLIENT(msg_entity)
1194                                 if(!teamplay || msg_entity.team == self.team)
1195                                 {
1196                                         if(msg_entity.cvar_cl_voice_directional == 1)
1197                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN);
1198                                         else
1199                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1200                                 }
1201                         break;
1202                 case VOICETYPE_AUTOTAUNT:
1203                         if(!sv_autotaunt)
1204                                 break;
1205                         if(!sv_taunt)
1206                                 break;
1207                         if(autocvar_sv_gentle)
1208                                 break;
1209                         tauntrand = random();
1210                         FOR_EACH_REALCLIENT(msg_entity)
1211                                 if (tauntrand < msg_entity.cvar_cl_autotaunt)
1212                                 {
1213                                         if (msg_entity.cvar_cl_voice_directional >= 1)
1214                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX));
1215                                         else
1216                                                 soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1217                                 }
1218                         break;
1219                 case VOICETYPE_TAUNT:
1220                         if(IS_PLAYER(self))
1221                                 if(self.deadflag == DEAD_NO)
1222                                         animdecide_setaction(self, ANIMACTION_TAUNT, true);
1223                         if(!sv_taunt)
1224                                 break;
1225                         if(autocvar_sv_gentle)
1226                                 break;
1227                         FOR_EACH_REALCLIENT(msg_entity)
1228                         {
1229                                 if (msg_entity.cvar_cl_voice_directional >= 1)
1230                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX));
1231                                 else
1232                                         soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE);
1233                         }
1234                         break;
1235                 case VOICETYPE_PLAYERSOUND:
1236                         sound(self, chan, sample, VOL_BASE, ATTEN_NORM);
1237                         break;
1238                 default:
1239                         backtrace("Invalid voice type!");
1240                         break;
1241         }
1242 }
1243
1244 void PlayerSound(.string samplefield, float chan, float voicetype)
1245 {
1246         GlobalSound(self.samplefield, chan, voicetype);
1247 }
1248
1249 void VoiceMessage(string type, string msg)
1250 {
1251         var .string sample;
1252         float voicetype, ownteam;
1253         float flood;
1254         sample = GetVoiceMessageSampleField(type);
1255
1256         if(GetPlayerSoundSampleField_notFound)
1257         {
1258                 sprint(self, strcat("Invalid voice. Use one of: ", allvoicesamples, "\n"));
1259                 return;
1260         }
1261
1262         voicetype = GetVoiceMessageVoiceType(type);
1263         ownteam = (voicetype == VOICETYPE_TEAMRADIO);
1264
1265         flood = Say(self, ownteam, world, msg, 1);
1266
1267         if(IS_SPEC(self) || IS_OBSERVER(self) || flood < 0)
1268                 FakeGlobalSound(self.sample, CH_VOICE, voicetype);
1269         else if (flood > 0)
1270                 GlobalSound(self.sample, CH_VOICE, voicetype);
1271 }
1272
1273 void MoveToTeam(entity client, float team_colour, float type)
1274 {
1275         float lockteams_backup;
1276
1277         lockteams_backup = lockteams;  // backup any team lock
1278
1279         lockteams = 0;  // disable locked teams
1280
1281         TeamchangeFrags(client);  // move the players frags
1282         SetPlayerColors(client, team_colour - 1);  // set the players colour
1283         Damage(client, client, client, 100000, DEATH_AUTOTEAMCHANGE, client.origin, '0 0 0');  // kill the player
1284
1285         lockteams = lockteams_backup;  // restore the team lock
1286
1287         LogTeamchange(client.playerid, client.team, type);
1288 }