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