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