]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/g_damage.qc
allow "uid2name" on bots ;)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_damage.qc
1 .float dmg;
2 .float dmg_edge;
3 .float dmg_force;
4 .float dmg_radius;
5
6 float Damage_DamageInfo_SendEntity(entity to, float sf)
7 {
8         WriteByte(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO);
9         WriteShort(MSG_ENTITY, self.projectiledeathtype);
10         WriteCoord(MSG_ENTITY, floor(self.origin_x));
11         WriteCoord(MSG_ENTITY, floor(self.origin_y));
12         WriteCoord(MSG_ENTITY, floor(self.origin_z));
13         WriteByte(MSG_ENTITY, bound(1, self.dmg, 255));
14         WriteByte(MSG_ENTITY, bound(0, self.dmg_radius, 255));
15         WriteByte(MSG_ENTITY, bound(1, self.dmg_edge, 255));
16         WriteShort(MSG_ENTITY, self.oldorigin_x);
17         return TRUE;
18 }
19
20 void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad, vector force, float deathtype, entity dmgowner)
21 {
22         // TODO maybe call this from non-edgedamage too?
23         // TODO maybe make the client do the particle effects for the weapons and the impact sounds using this info?
24
25         entity e;
26
27         if(!sound_allowed(MSG_BROADCAST, dmgowner))
28                 deathtype |= 0x8000;
29
30         e = spawn();
31         setorigin(e, org);
32         e.projectiledeathtype = deathtype;
33         e.dmg = coredamage;
34         e.dmg_edge = edgedamage;
35         e.dmg_radius = rad;
36         e.dmg_force = vlen(force);
37         e.velocity = force;
38
39         e.oldorigin_x = compressShortVector(e.velocity);
40
41         Net_LinkEntity(e, FALSE, 0.2, Damage_DamageInfo_SendEntity);
42 }
43
44 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
45
46 float checkrules_firstblood;
47
48 float yoda;
49 float damage_goodhits;
50 float damage_gooddamage;
51 float headshot;
52 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
53
54 .float dmg_team;
55 .float teamkill_complain;
56 .float teamkill_soundtime;
57 .entity teamkill_soundsource;
58 .entity pusher;
59 .float taunt_soundtime;
60
61
62 float IsDifferentTeam(entity a, entity b)
63 {
64         if(teams_matter)
65         {
66                 if(a.team == b.team)
67                         return 0;
68         }
69         else
70         {
71                 if(a == b)
72                         return 0;
73         }
74         return 1;
75 }
76
77 float IsFlying(entity a)
78 {
79         if(a.flags & FL_ONGROUND)
80                 return 0;
81         if(a.waterlevel >= WATERLEVEL_SWIMMING)
82                 return 0;
83         traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
84         if(trace_fraction < 1)
85                 return 0;
86         return 1;
87 }
88
89 vector GetHeadshotMins(entity targ)
90 {
91         return '-0.5 0 0' * PL_HEAD_x + '0 -0.5 0' * PL_HEAD_y + '0 0 1' * (targ.maxs_z - PL_HEAD_z);
92 }
93 vector GetHeadshotMaxs(entity targ)
94 {
95         return '0.5 0 0' * PL_HEAD_x + '0 0.5 0' * PL_HEAD_y + '0 0 1' * targ.maxs_z;
96 }
97
98 void UpdateFrags(entity player, float f)
99 {
100         PlayerTeamScore_AddScore(player, f);
101 }
102
103 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
104 void W_SwitchWeapon_Force(entity e, float w);
105 void GiveFrags (entity attacker, entity targ, float f, float deathtype)
106 {
107         float w;
108
109         // TODO route through PlayerScores instead
110         if(gameover) return;
111
112         if(f < 0)
113         {
114                 if(targ == attacker)
115                 {
116                         // suicide
117                         PlayerScore_Add(attacker, SP_SUICIDES, 1);
118                 }
119                 else
120                 {
121                         // teamkill
122                         PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
123                 }
124         }
125         else
126         {
127                 // regular frag
128                 PlayerScore_Add(attacker, SP_KILLS, 1);
129         }
130
131         PlayerScore_Add(targ, SP_DEATHS, 1);
132
133         if(g_arena || g_ca)
134                 if(autocvar_g_arena_roundbased)
135                         return;
136
137         if(targ != attacker) // not for suicides
138         if(g_weaponarena_random)
139         {
140                 // after a frag, exchange the current weapon (or the culprit, if detectable) by a new random weapon
141                 float culprit;
142                 culprit = DEATH_WEAPONOF(deathtype);
143                 if(!culprit || !(attacker.weapons & W_WeaponBit(culprit)))
144                         culprit = attacker.weapon;
145
146                 if(g_weaponarena_random_with_laser && culprit == WEPBIT_LASER)
147                 {
148                         // no exchange
149                 }
150                 else
151                 {
152                         if(inWarmupStage)
153                                 w = warmup_start_weapons;
154                         else
155                                 w = start_weapons;
156
157                         // all others (including the culprit): remove
158                         w &~= attacker.weapons;
159
160                         // among the remaining ones, choose one by random
161                         w = randombits(w, 1, FALSE);
162                         if(w)
163                         {
164                                 attacker.weapons |= w;
165                                 attacker.weapons &~= W_WeaponBit(culprit);
166                         }
167                 }
168
169                 // after a frag, choose another random weapon set
170                 if not(attacker.weapons & W_WeaponBit(attacker.weapon))
171                         W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker));
172         }
173
174         // FIXME fix the mess this is (we have REAL points now!)
175         entity oldself;
176         oldself = self;
177         self = attacker;
178         frag_attacker = attacker;
179         frag_target = targ;
180         frag_score = f;
181         if(MUTATOR_CALLHOOK(GiveFragsForKill))
182         {
183                 f = frag_score;
184                 self = oldself;
185         }
186         else
187         {
188                 self = oldself;
189                 if(g_runematch)
190                 {
191                         f = RunematchHandleFrags(attacker, targ, f);
192                 }
193                 else if(g_lms)
194                 {
195                         // remove a life
196                         float tl;
197                         tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
198                         if(tl < lms_lowest_lives)
199                                 lms_lowest_lives = tl;
200                         if(tl <= 0)
201                         {
202                                 if(!lms_next_place)
203                                         lms_next_place = player_count;
204                                 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
205                                 --lms_next_place;
206                         }
207                         f = 0;
208                 }
209                 else if(g_ctf)
210                 {
211                         if(g_ctf_ignore_frags)
212                                 f = 0;
213                 }
214         }
215
216         attacker.totalfrags += f;
217
218         if(f)
219                 UpdateFrags(attacker, f);
220 }
221
222 string AppendItemcodes(string s, entity player)
223 {
224         float w;
225         w = player.weapon;
226         //if(w == 0)
227         //      w = player.switchweapon;
228         if(w == 0)
229                 w = player.cnt; // previous weapon!
230         s = strcat(s, ftos(w));
231         if(time < player.strength_finished)
232                 s = strcat(s, "S");
233         if(time < player.invincible_finished)
234                 s = strcat(s, "I");
235         if(player.flagcarried != world)
236                 s = strcat(s, "F");
237         if(player.BUTTON_CHAT)
238                 s = strcat(s, "T");
239         if(player.kh_next)
240                 s = strcat(s, "K");
241         if(player.runes)
242                 s = strcat(s, "|", ftos(player.runes));
243         return s;
244 }
245
246 void LogDeath(string mode, float deathtype, entity killer, entity killed)
247 {
248         string s;
249         if(!autocvar_sv_eventlog)
250                 return;
251         s = strcat(":kill:", mode);
252         s = strcat(s, ":", ftos(killer.playerid));
253         s = strcat(s, ":", ftos(killed.playerid));
254         s = strcat(s, ":type=", ftos(deathtype));
255         s = strcat(s, ":items=");
256         s = AppendItemcodes(s, killer);
257         if(killed != killer)
258         {
259                 s = strcat(s, ":victimitems=");
260                 s = AppendItemcodes(s, killed);
261         }
262         GameLogEcho(s);
263 }
264
265 void Send_KillNotification (string s1, string s2, string s3, float msg, float type)
266 {
267         WriteByte(MSG_ALL, SVC_TEMPENTITY);
268         WriteByte(MSG_ALL, TE_CSQC_NOTIFY);
269         WriteByte(MSG_ALL, CSQC_KILLNOTIFY);
270         WriteString(MSG_ALL, s1);
271         WriteString(MSG_ALL, s2);
272         WriteString(MSG_ALL, s3);
273         WriteShort(MSG_ALL, msg);
274         WriteByte(MSG_ALL, type);
275 }
276
277 // Function is used to send a generic centerprint whose content CSQC gets to decide (gentle version or not in the below cases)
278 void Send_CSQC_Centerprint(entity e, string s1, string s2, float msg, float type)
279 {
280         if (clienttype(e) == CLIENTTYPE_REAL)
281         {
282                 msg_entity = e;
283                 WRITESPECTATABLE_MSG_ONE({
284                         WriteByte(MSG_ONE, SVC_TEMPENTITY);
285                         WriteByte(MSG_ONE, TE_CSQC_NOTIFY);
286                         WriteByte(MSG_ONE, CSQC_CENTERPRINT);
287                         WriteString(MSG_ONE, s1);
288                         WriteString(MSG_ONE, s2);
289                         WriteShort(MSG_ONE, msg);
290                         WriteByte(MSG_ONE, type);
291                 });
292         }
293 }
294
295 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
296 {
297         string  s, a, msg;
298         float w, type;
299
300         if (targ.classname == "player" || targ.classname == "corpse")
301         {
302                 if (targ.classname == "corpse")
303                         s = "A corpse";
304                 else
305                         s = targ.netname;
306
307                 a = attacker.netname;
308
309                 if (targ == attacker) // suicides
310                 {
311                         if (deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
312                                 msg = ColoredTeamName(targ.team); // TODO: check if needed?
313             if(!g_cts) // no "killed your own dumb self" message in CTS
314                 Send_CSQC_Centerprint(targ, msg, "", deathtype, MSG_SUICIDE);
315
316                         if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
317                         {
318                                 LogDeath("suicide", deathtype, targ, targ);
319                                 GiveFrags(attacker, targ, -1, deathtype);
320                         }
321
322                         if (targ.killcount > 2)
323                                 msg = ftos(targ.killcount);
324                         if(teams_matter && deathtype == DEATH_MIRRORDAMAGE)
325                         {
326                                 if(attacker.team == COLOR_TEAM1)
327                                         deathtype = KILL_TEAM_RED;
328                                 else
329                                         deathtype = KILL_TEAM_BLUE;
330                         }
331
332                         Send_KillNotification(s, msg, ftos(w), deathtype, MSG_SUICIDE);
333                 }
334                 else if (attacker.classname == "player" || attacker.classname == "gib")
335                 {
336                         if(teams_matter && attacker.team == targ.team)
337                         {
338                                 if(attacker.team == COLOR_TEAM1)
339                                         type = KILL_TEAM_RED;
340                                 else
341                                         type = KILL_TEAM_BLUE;
342
343                                 GiveFrags(attacker, targ, -1, deathtype);
344
345                                 Send_CSQC_Centerprint(attacker, s, "", type, MSG_KILL);
346
347                                 if (targ.killcount > 2) {
348                                         msg = ftos(targ.killcount);
349                                 }
350
351                                 if (attacker.killcount > 2) {
352                                         msg = ftos(attacker.killcount);
353                                         type = KILL_TEAM_SPREE;
354                                 }
355                                 Send_KillNotification(a, s, msg, type, MSG_KILL);
356
357                                 attacker.killcount = 0;
358
359                                 LogDeath("tk", deathtype, attacker, targ);
360                         }
361                         else
362                         {
363                                 if (!checkrules_firstblood)
364                                 {
365                                         checkrules_firstblood = TRUE;
366                                         Send_KillNotification(a, "", "", KILL_FIRST_BLOOD, MSG_KILL);
367                                         // TODO: make these print a newline if they dont
368                                         Send_CSQC_Centerprint(attacker, "", "", KILL_FIRST_BLOOD, MSG_KILL);
369                                         Send_CSQC_Centerprint(targ, "", "", KILL_FIRST_VICTIM, MSG_KILL);
370                                 }
371
372                                 if((autocvar_sv_fragmessage_information_typefrag) && (targ.BUTTON_CHAT)) {
373                                         Send_CSQC_Centerprint(attacker, s, GetAdvancedDeathReports(targ), KILL_TYPEFRAG, MSG_KILL);
374                                         Send_CSQC_Centerprint(targ, a, GetAdvancedDeathReports(attacker), KILL_TYPEFRAGGED, MSG_KILL);
375                                 } else {
376                                         Send_CSQC_Centerprint(attacker, s, GetAdvancedDeathReports(targ), KILL_FRAG, MSG_KILL);
377                                         Send_CSQC_Centerprint(targ, a, GetAdvancedDeathReports(attacker), KILL_FRAGGED, MSG_KILL);
378                                 }
379
380                                 attacker.taunt_soundtime = time + 1;
381
382                                 // TODO: fix this?
383                                 if (deathtype == DEATH_CUSTOM)
384                                         msg = deathmessage;
385                                 else
386                                         msg = inflictor.message2;
387
388                                 if(strstrofs(msg, "%", 0) < 0)
389                                         msg = strcat("%s ", msg, " by %s");
390
391                                 Send_KillNotification(a, s, msg, deathtype, MSG_KILL);
392
393                                 if(g_ctf && targ.flagcarried)
394                                 {
395                                         UpdateFrags(attacker, ctf_score_value("score_kill"));
396                                         PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
397                                         GiveFrags(attacker, targ, 0, deathtype); // for logging
398                                 }
399                                 else
400                                         GiveFrags(attacker, targ, 1, deathtype);
401
402                                 if (targ.killcount > 2) {
403                                         Send_KillNotification(s, ftos(targ.killcount), a, KILL_END_SPREE, MSG_SPREE);
404                                 }
405
406                                 attacker.killcount = attacker.killcount + 1;
407
408                                 if (attacker.killcount > 2) {
409                                         Send_KillNotification(a, ftos(attacker.killcount), "", KILL_SPREE, MSG_SPREE);
410                                 }
411                                 else if (attacker.killcount == 3)
412                                 {
413                                         Send_KillNotification(a, "", "", KILL_SPREE_3, MSG_SPREE);
414                                         AnnounceTo(attacker, "03kills");
415                                 }
416                                 else if (attacker.killcount == 5)
417                                 {
418                                         Send_KillNotification(a, "", "", KILL_SPREE_5, MSG_SPREE);
419                                         AnnounceTo(attacker, "05kills");
420                                 }
421                                 else if (attacker.killcount == 10)
422                                 {
423                                         Send_KillNotification(a, "", "", KILL_SPREE_10, MSG_SPREE);
424                                         AnnounceTo(attacker, "10kills");
425                                 }
426                                 else if (attacker.killcount == 15)
427                                 {
428                                         Send_KillNotification(a, "", "", KILL_SPREE_15, MSG_SPREE);
429                                         AnnounceTo(attacker, "15kills");
430                                 }
431                                 else if (attacker.killcount == 20)
432                                 {
433                                         Send_KillNotification(a, "", "", KILL_SPREE_20, MSG_SPREE);
434                                         AnnounceTo(attacker, "20kills");
435                                 }
436                                 else if (attacker.killcount == 25)
437                                 {
438                                         Send_KillNotification(a, "", "", KILL_SPREE_25, MSG_SPREE);
439                                         AnnounceTo(attacker, "25kills");
440                                 }
441                                 else if (attacker.killcount == 30)
442                                 {
443                                         Send_KillNotification(a, "", "", KILL_SPREE_30, MSG_SPREE);
444                                         AnnounceTo(attacker, "30kills");
445                                 }
446                                 LogDeath("frag", deathtype, attacker, targ);
447                         }
448                 }
449                 else
450                 {
451                         Send_CSQC_Centerprint(targ, "", "", deathtype, MSG_KILL_ACTION);
452                         if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
453                                 msg = inflictor.message;
454                         else if (deathtype == DEATH_CUSTOM)
455                                 msg = deathmessage;
456                         if(strstrofs(msg, "%", 0) < 0)
457                                 msg = strcat("%s ", msg);
458
459                         GiveFrags(targ, targ, -1, deathtype);
460                         if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
461                                 AnnounceTo(targ, "botlike");
462                         }
463                         Send_KillNotification(s, msg, "", deathtype, MSG_KILL_ACTION);
464
465                         if (targ.killcount > 2)
466                                 Send_KillNotification(s, ftos(targ.killcount), "", 0, MSG_KILL_ACTION_SPREE);
467
468                         LogDeath("accident", deathtype, targ, targ);
469                 }
470
471                 targ.death_origin = targ.origin;
472                 if(targ != attacker)
473                         targ.killer_origin = attacker.origin;
474
475                 // FIXME: this should go in PutClientInServer
476                 if (targ.killcount)
477                         targ.killcount = 0;
478         }
479 }
480
481 // these are updated by each Damage call for use in button triggering and such
482 entity damage_targ;
483 entity damage_inflictor;
484 entity damage_attacker;
485 .float prevhitsound;
486
487 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
488 {
489         float mirrordamage;
490         float mirrorforce;
491         float teamdamage0;
492         entity attacker_save;
493         mirrordamage = 0;
494         mirrorforce = 0;
495
496         if (gameover || targ.killcount == -666)
497                 return;
498
499         local entity oldself;
500         oldself = self;
501         self = targ;
502         damage_targ = targ;
503         damage_inflictor = inflictor;
504         damage_attacker = attacker;
505                 attacker_save = attacker;
506
507         if(targ.classname == "player")
508                 if(targ.hook)
509                         if(targ.hook.aiment)
510                                 if(targ.hook.aiment == attacker)
511                                         RemoveGrapplingHook(targ); // STOP THAT, you parasite!
512
513         // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
514         if(DEATH_ISWEAPON(deathtype, WEP_HOOK) || DEATH_ISWEAPON(deathtype, WEP_TUBA))
515         {
516                 if(targ.classname == "player")
517                         if not(IsDifferentTeam(targ, attacker))
518                         {
519                                 self = oldself;
520                                 return;
521                         }
522         }
523
524         if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE || deathtype == DEATH_QUIET)
525         {
526                 // These are ALWAYS lethal
527                 // No damage modification here
528                 // Instead, prepare the victim for his death...
529                 targ.armorvalue = 0;
530                 targ.spawnshieldtime = 0;
531                 targ.health = 0.9; // this is < 1
532                 targ.flags -= targ.flags & FL_GODMODE;
533                 damage = 100000;
534         }
535         else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
536         {
537                 // no processing
538         }
539         else
540         {
541                 if (targ.classname == "player")
542                 if (attacker.classname == "player")
543                 if (!targ.isbot)
544                 if (attacker.isbot)
545                         damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
546
547                 // nullify damage if teamplay is on
548                 if(deathtype != DEATH_TELEFRAG)
549                 if(attacker.classname == "player")
550                 {
551                         if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
552                         {
553                                 damage = 0;
554                                 force = '0 0 0';
555                         }
556                         else if(teams_matter && attacker.team == targ.team)
557                         {
558                                 if(autocvar_teamplay_mode == 1)
559                                         damage = 0;
560                                 else if(attacker != targ)
561                                 {
562                                         if(autocvar_teamplay_mode == 3)
563                                                 damage = 0;
564                                         else if(autocvar_teamplay_mode == 4)
565                                         {
566                                                 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
567                                                 {
568                                                         teamdamage0 = max(attacker.dmg_team, autocvar_g_teamdamage_threshold);
569                                                         attacker.dmg_team = attacker.dmg_team + damage;
570                                                         if(attacker.dmg_team > teamdamage0 && !g_ca)
571                                                                 mirrordamage = autocvar_g_mirrordamage * (attacker.dmg_team - teamdamage0);
572                                                         mirrorforce = autocvar_g_mirrordamage * vlen(force);
573                                                         if(g_minstagib)
574                                                         {
575                                                                 if(autocvar_g_friendlyfire == 0)
576                                                                         damage = 0;
577                                                         }
578                                                         else if(g_ca)
579                                                                 damage = 0;
580                                                         else
581                                                                 damage = autocvar_g_friendlyfire * damage;
582                                                         // mirrordamage will be used LATER
583
584                                                         if(autocvar_g_mirrordamage_virtual)
585                                                         {
586                                                                 vector v;
587                                                                 v = healtharmor_applydamage(attacker.armorvalue, autocvar_g_balance_armor_blockpercent, mirrordamage);
588                                                                 attacker.dmg_take += v_x;
589                                                                 attacker.dmg_save += v_y;
590                                                                 attacker.dmg_inflictor = inflictor;
591                                                                 mirrordamage = 0;
592                                                                 mirrorforce = 0;
593                                                         }
594
595                                                         if(autocvar_g_friendlyfire_virtual)
596                                                         {
597                                                                 vector v;
598                                                                 v = healtharmor_applydamage(targ.armorvalue, autocvar_g_balance_armor_blockpercent, damage);
599                                                                 targ.dmg_take += v_x;
600                                                                 targ.dmg_save += v_y;
601                                                                 targ.dmg_inflictor = inflictor;
602                                                                 damage = 0;
603                                 if(!autocvar_g_friendlyfire_virtual_force)
604                                     force = '0 0 0';
605                                                         }
606                                                 }
607                                                 else
608                                                         damage = 0;
609                                         }
610                                 }
611                         }
612                 }
613
614                 if(targ.classname == "player")
615                 if(attacker.classname == "player")
616                 if(attacker != targ)
617                 {
618                         targ.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
619                         attacker.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
620                 }
621
622                 if(targ.classname == "player")
623                 if (g_minstagib)
624                 {
625                         if ((deathtype == DEATH_FALL)  ||
626                                 (deathtype == DEATH_DROWN) ||
627                                 (deathtype == DEATH_SLIME) ||
628                                 (deathtype == DEATH_LAVA)  ||
629                                 (!DEATH_ISWEAPON(deathtype, WEP_LASER) && damage > 0 && damage < 100))
630                         {
631                                 self = oldself;
632                                 return;
633                         }
634                         if(damage > 0)
635                             damage = 10000;
636                         if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
637                         {
638                                 targ.armorvalue -= 1;
639                                 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
640                                 damage = 0;
641                                 targ.hitsound += 1;
642                                 attacker.hitsound += 1; // TODO change this to a future specific hitsound for armor hit
643                         }
644                         if (DEATH_ISWEAPON(deathtype, WEP_LASER))
645                         {
646                                 damage = 0;
647                                 mirrordamage = 0;
648                                 if (targ != attacker)
649                                 {
650                                         if ((targ.health >= 1) && (targ.classname == "player"))
651                                                 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
652                                         force = '0 0 0';
653                                         // keep mirrorforce
654                                         attacker = targ;
655                                 }
656                         }
657                 }
658
659                 if not(DEATH_ISSPECIAL(deathtype))
660                 {
661                         damage *= g_weapondamagefactor;
662                         mirrordamage *= g_weapondamagefactor;
663                         force = force * g_weaponforcefactor;
664                         mirrorforce *= g_weaponforcefactor;
665                 }
666                 
667                 // should this be changed at all? If so, in what way?
668                 frag_attacker = attacker;
669                 frag_target = targ;
670                 frag_damage = damage;
671                 frag_force = force;
672         frag_deathtype = deathtype;
673                 MUTATOR_CALLHOOK(PlayerDamage_Calculate);
674                 damage = frag_damage;
675                 force = frag_force;
676                 
677                 // apply strength multiplier
678                 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
679                 {
680                         if(targ == attacker)
681                         {
682                                 damage = damage * autocvar_g_balance_powerup_strength_selfdamage;
683                                 force = force * autocvar_g_balance_powerup_strength_selfforce;
684                         }
685                         else
686                         {
687                                 damage = damage * autocvar_g_balance_powerup_strength_damage;
688                                 force = force * autocvar_g_balance_powerup_strength_force;
689                         }
690                 }
691
692                 // apply invincibility multiplier
693                 if (targ.items & IT_INVINCIBLE && !g_minstagib)
694                         damage = damage * autocvar_g_balance_powerup_invincible_takedamage;
695
696                 if (targ == attacker)
697                 {
698                         if(g_ca || (g_cts && !autocvar_g_cts_selfdamage))
699                                 damage = 0;
700                         else
701                                 damage = damage * autocvar_g_balance_selfdamagepercent; // Partial damage if the attacker hits himself
702                 }
703
704                 // CTF: reduce damage/force
705                 if(g_ctf)
706                 if(targ == attacker)
707                 if(targ.flagcarried)
708                 {
709                         damage = damage * autocvar_g_ctf_flagcarrier_selfdamage;
710                         force = force * autocvar_g_ctf_flagcarrier_selfforce;
711                 }
712
713                 if(g_runematch)
714                 {
715                         // apply strength rune
716                         if (attacker.runes & RUNE_STRENGTH)
717                         {
718                                 if(attacker.runes & CURSE_WEAK) // have both curse & rune
719                                 {
720                                         damage = damage * autocvar_g_balance_rune_strength_combo_damage;
721                                         force = force * autocvar_g_balance_rune_strength_combo_force;
722                                 }
723                                 else
724                                 {
725                                         damage = damage * autocvar_g_balance_rune_strength_damage;
726                                         force = force * autocvar_g_balance_rune_strength_force;
727                                 }
728                         }
729                         else if (attacker.runes & CURSE_WEAK)
730                         {
731                                 damage = damage * autocvar_g_balance_curse_weak_damage;
732                                 force = force * autocvar_g_balance_curse_weak_force;
733                         }
734
735                         // apply defense rune
736                         if (targ.runes & RUNE_DEFENSE)
737                         {
738                                 if (targ.runes & CURSE_VULNER) // have both curse & rune
739                                         damage = damage * autocvar_g_balance_rune_defense_combo_takedamage;
740                                 else
741                                         damage = damage * autocvar_g_balance_rune_defense_takedamage;
742                         }
743                         else if (targ.runes & CURSE_VULNER)
744                                 damage = damage * autocvar_g_balance_curse_vulner_takedamage;
745                 }
746
747                 // count the damage
748                 if(attacker)
749                 if(!targ.deadflag)
750                 if(targ.takedamage == DAMAGE_AIM)
751                 if(targ != attacker)
752                 {
753                         if(targ.classname == "player")
754                         {
755                                 // HEAD SHOT:
756                                 // find height of hit on player axis
757                                 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
758                                 vector headmins, headmaxs, org;
759                                 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
760                                 headmins = org + GetHeadshotMins(targ);
761                                 headmaxs = org + GetHeadshotMaxs(targ);
762                                 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
763                                 {
764                                         deathtype |= HITTYPE_HEADSHOT;
765                                 }
766                         }
767                         else if(targ.classname == "turret_head")
768                         {
769                                 deathtype |= HITTYPE_HEADSHOT;
770                         }
771                         if(deathtype & HITTYPE_HEADSHOT)
772                                 damage *= 1 + damage_headshotbonus;
773
774                         if(targ.classname == "player")
775                         {
776                                 if(IsDifferentTeam(targ, attacker))
777                                 {
778                                         if(damage > 0)
779                                         {
780                                                 if(attacker.weapon != WEP_LASER
781                                                 && (attacker.weapon != WEP_ELECTRO || !autocvar_g_balance_electro_lightning)
782                                                 && attacker.prevhitsound + autocvar_sv_hitsound_antispam_time < time)
783                                                 {
784                                                         if(targ.BUTTON_CHAT)
785                                                                 attacker.typehitsound += 1;
786                                                         else
787                                                                 attacker.hitsound += 1;
788                                                         attacker.prevhitsound = time;
789                                                 }
790
791                                                 damage_goodhits += 1;
792                                                 damage_gooddamage += damage;
793
794                                                 if not(DEATH_ISSPECIAL(deathtype))
795                                                 {
796                                                         if(!g_minstagib)
797                                                         if(IsFlying(targ))
798                                                                 yoda = 1;
799
800                                                         if(g_minstagib)
801                                                         if(targ.items & IT_STRENGTH)
802                                                                 yoda = 1;
803
804                                                         if(deathtype & HITTYPE_HEADSHOT)
805                                                                 headshot = 1;
806                                                 }
807                                                 if(g_ca)
808                                                         PlayerScore_Add(attacker, SP_SCORE, damage * autocvar_g_ca_damage2score_multiplier);
809                                         }
810                                 }
811                                 else
812                                 {
813                                         if(deathtype != DEATH_FIRE
814                                         && attacker.prevhitsound + autocvar_sv_hitsound_antispam_time < time)
815                                         {
816                                                 attacker.typehitsound += 1;
817                                                 attacker.prevhitsound = time;
818                                         }
819                                         if(mirrordamage > 0)
820                                                 if(time > attacker.teamkill_complain)
821                                                 {
822                                                         attacker.teamkill_complain = time + 5;
823                                                         attacker.teamkill_soundtime = time + 0.4;
824                                                         attacker.teamkill_soundsource = targ;
825                                                 }
826                                 }
827                         }
828                 }
829         }
830
831         // apply push
832         if (self.damageforcescale)
833         if (vlen(force))
834         if (self.classname != "player" || time >= self.spawnshieldtime || g_midair)
835         {
836                 self.velocity = self.velocity + self.damageforcescale * force;
837                 self.flags &~= FL_ONGROUND;
838                 UpdateCSQCProjectile(self);
839         }
840         // apply damage
841         if (damage != 0 || (self.damageforcescale && vlen(force)))
842         if (self.event_damage)
843                 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
844         self = oldself;
845
846         if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
847         {
848                 if(g_runematch)
849                 {
850                         if (attacker.runes & RUNE_VAMPIRE)
851                         {
852                         // apply vampire rune
853                                 if (attacker.runes & CURSE_EMPATHY) // have the curse too
854                                 {
855                                         //attacker.health = attacker.health + damage * autocvar_g_balance_rune_vampire_combo_absorb;
856                                         attacker.health = bound(
857                                                 autocvar_g_balance_curse_empathy_minhealth, // LA: was 3, now 40
858                                                 attacker.health + damage * autocvar_g_balance_rune_vampire_combo_absorb,
859                                                 autocvar_g_balance_rune_vampire_maxhealth);     // LA: was 1000, now 500
860                                 }
861                                 else
862                                 {
863                                         //attacker.health = attacker.health + damage * autocvar_g_balance_rune_vampire_absorb;
864                                         attacker.health = bound(
865                                                 attacker.health,        // LA: was 3, but changed so that you can't lose health
866                                                                                         // empathy won't let you gain health in the same way...
867                                                 attacker.health + damage * autocvar_g_balance_rune_vampire_absorb,
868                                                 autocvar_g_balance_rune_vampire_maxhealth);     // LA: was 1000, now 500
869                                         }
870                         }
871                         // apply empathy curse
872                         else if (attacker.runes & CURSE_EMPATHY)
873                         {
874                                 attacker.health = bound(
875                                         autocvar_g_balance_curse_empathy_minhealth, // LA: was 3, now 20
876                                         attacker.health + damage * autocvar_g_balance_curse_empathy_takedamage,
877                                         attacker.health);
878                         }
879                 }
880         }
881
882         // apply mirror damage if any
883         if(mirrordamage > 0 || mirrorforce > 0)
884         {
885                 attacker = attacker_save;
886                 if(g_minstagib)
887                 if(mirrordamage > 0)
888                 {
889                         // just lose extra LIVES, don't kill the player for mirror damage
890                         if(attacker.armorvalue > 0)
891                         {
892                                 attacker.armorvalue = attacker.armorvalue - 1;
893                                 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
894                                 attacker.hitsound += 1;
895                         }
896                         mirrordamage = 0;
897                 }
898
899                 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
900                 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
901         }
902 }
903
904 float RadiusDamage_running;
905 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
906 // Returns total damage applies to creatures
907 {
908         entity  targ;
909         float   finaldmg;
910         float   power;
911         vector  blastorigin;
912         vector  force;
913         vector  diff;
914         vector  center;
915         vector  nearest;
916         float   total_damage_to_creatures;
917         entity  next;
918         float   tfloordmg;
919         float   tfloorforce;
920
921         float stat_damagedone;
922
923         if(RadiusDamage_running)
924         {
925                 backtrace("RadiusDamage called recursively! Expect stuff to go HORRIBLY wrong.");
926                 return 0;
927         }
928
929         RadiusDamage_running = 1;
930
931         tfloordmg = autocvar_g_throughfloor_damage;
932         tfloorforce = autocvar_g_throughfloor_force;
933
934         blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
935         total_damage_to_creatures = 0;
936
937         if(deathtype != (WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once
938         if(DEATH_WEAPONOF(deathtype) != WEP_TUBA) // do not send tuba damage (bandwidth hog)
939         {
940                 force = inflictor.velocity;
941                 if(vlen(force) == 0)
942                         force = '0 0 -1';
943                 else
944                         force = normalize(force);
945                 if(forceintensity >= 0)
946                         Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, attacker);
947                 else
948                         Damage_DamageInfo(blastorigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, attacker);
949         }
950
951         stat_damagedone = 0;
952
953         targ = WarpZone_FindRadius (blastorigin, rad, FALSE);
954         while (targ)
955         {
956                 next = targ.chain;
957                 if (targ != inflictor)
958                         if (ignore != targ) if(targ.takedamage)
959                         {
960                                 // LordHavoc: measure distance to nearest point on target (not origin)
961                                 // (this guarentees 100% damage on a touch impact)
962                                 nearest = targ.WarpZone_findradius_nearest;
963                                 diff = targ.WarpZone_findradius_dist;
964                                 // round up a little on the damage to ensure full damage on impacts
965                                 // and turn the distance into a fraction of the radius
966                                 power = 1 - ((vlen (diff) - 2) / rad);
967                                 //bprint(" ");
968                                 //bprint(ftos(power));
969                                 //if (targ == attacker)
970                                 //      print(ftos(power), "\n");
971                                 if (power > 0)
972                                 {
973                                         if (power > 1)
974                                                 power = 1;
975                                         finaldmg = coredamage * power + edgedamage * (1 - power);
976                                         if (finaldmg > 0)
977                                         {
978                                                 local float a;
979                                                 local float c;
980                                                 local float hits;
981                                                 local float total;
982                                                 local float hitratio;
983                                                 local vector hitloc;
984                                                 local vector myblastorigin;
985                                                 myblastorigin = WarpZone_TransformOrigin(targ, blastorigin);
986                                                 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
987                                                 // if it's a player, use the view origin as reference
988                                                 if (targ.classname == "player")
989                                                         center = targ.origin + targ.view_ofs;
990                                                 force = normalize(center - myblastorigin);
991                                                 force = force * (finaldmg / coredamage) * forceintensity;
992                                                 // test line of sight to multiple positions on box,
993                                                 // and do damage if any of them hit
994                                                 hits = 0;
995                                                 if (targ.classname == "player")
996                                                         total = ceil(bound(1, finaldmg, 50));
997                                                 else
998                                                         total = ceil(bound(1, finaldmg/10, 5));
999                                                 hitloc = nearest;
1000                                                 c = 0;
1001                                                 while (c < total)
1002                                                 {
1003                                                         //traceline(targ.WarpZone_findradius_findorigin, nearest, MOVE_NOMONSTERS, inflictor);
1004                                                         WarpZone_TraceLine(blastorigin, WarpZone_UnTransformOrigin(targ, nearest), MOVE_NOMONSTERS, inflictor);
1005                                                         if (trace_fraction == 1 || trace_ent == targ)
1006                                                         {
1007                                                                 hits = hits + 1;
1008                                                                 if (hits > 1)
1009                                                                         hitloc = hitloc + nearest;
1010                                                                 else
1011                                                                         hitloc = nearest;
1012                                                         }
1013                                                         nearest_x = targ.origin_x + targ.mins_x + random() * targ.size_x;
1014                                                         nearest_y = targ.origin_y + targ.mins_y + random() * targ.size_y;
1015                                                         nearest_z = targ.origin_z + targ.mins_z + random() * targ.size_z;
1016                                                         c = c + 1;
1017                                                 }
1018                                                 nearest = hitloc * (1 / max(1, hits));
1019                                                 hitratio = (hits / total);
1020                                                 a = bound(0, tfloordmg + (1-tfloordmg) * hitratio, 1);
1021                                                 finaldmg = finaldmg * a;
1022                                                 a = bound(0, tfloorforce + (1-tfloorforce) * hitratio, 1);
1023                                                 force = force * a;
1024
1025                                                 // laser force adjustments :P
1026                                                 if(DEATH_WEAPONOF(deathtype) == WEP_LASER)
1027                                                 {
1028                             if (targ == attacker)
1029                             {
1030                                 vector vel;
1031
1032                                 float force_zscale;
1033                                 float force_velocitybiasramp;
1034                                 float force_velocitybias;
1035
1036                                 force_velocitybiasramp = autocvar_sv_maxspeed;
1037                                 if(deathtype & HITTYPE_SECONDARY)
1038                                 {
1039                                     force_zscale = autocvar_g_balance_laser_secondary_force_zscale;
1040                                     force_velocitybias = autocvar_g_balance_laser_secondary_force_velocitybias;
1041                                 }
1042                                 else
1043                                 {
1044                                     force_zscale = autocvar_g_balance_laser_primary_force_zscale;
1045                                     force_velocitybias = autocvar_g_balance_laser_primary_force_velocitybias;
1046                                 }
1047
1048                                 vel = targ.velocity;
1049                                 vel_z = 0;
1050                                 vel = normalize(vel) * bound(0, vlen(vel) / force_velocitybiasramp, 1) * force_velocitybias;
1051                                 force =
1052                                     vlen(force)
1053                                     *
1054                                     normalize(normalize(force) + vel);
1055
1056                                 force_z *= force_zscale;
1057                             }
1058                             else
1059                             {
1060                                 if(deathtype & HITTYPE_SECONDARY)
1061                                 {
1062                                     force *= autocvar_g_balance_laser_secondary_force_other_scale;
1063                                 }
1064                                 else
1065                                 {
1066                                     force *= autocvar_g_balance_laser_primary_force_other_scale;
1067                                 }
1068                             }
1069                                                 }
1070
1071                                                 //if (targ == attacker)
1072                                                 //{
1073                                                 //      print("hits ", ftos(hits), " / ", ftos(total));
1074                                                 //      print(" finaldmg ", ftos(finaldmg), " force ", vtos(force));
1075                                                 //      print(" (", ftos(a), ")\n");
1076                                                 //}
1077                                                 if(hits || tfloordmg || tfloorforce)
1078                                                 {
1079                                                         if(targ.iscreature)
1080                                                         {
1081                                                                 total_damage_to_creatures += finaldmg;
1082
1083                                                                 if(accuracy_isgooddamage(attacker, targ))
1084                                                                         stat_damagedone += finaldmg;
1085                                                         }
1086
1087                                                         if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
1088                                                                 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
1089                                                         else
1090                                                                 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
1091                                                 }
1092                                         }
1093                                 }
1094                         }
1095                 targ = next;
1096         }
1097
1098         RadiusDamage_running = 0;
1099
1100         if(!DEATH_ISSPECIAL(deathtype))
1101                 accuracy_add(attacker, DEATH_WEAPONOFWEAPONDEATH(deathtype), 0, min(coredamage, stat_damagedone));
1102
1103         return total_damage_to_creatures;
1104 }
1105
1106 .float fire_damagepersec;
1107 .float fire_endtime;
1108 .float fire_deathtype;
1109 .entity fire_owner;
1110 .float fire_hitsound;
1111 .entity fire_burner;
1112
1113 void fireburner_think();
1114
1115 float Fire_IsBurning(entity e)
1116 {
1117         return (time < e.fire_endtime);
1118 }
1119
1120 float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
1121 {
1122         float dps;
1123         float maxtime, mintime, maxdamage, mindamage, maxdps, mindps, totaldamage, totaltime;
1124
1125         if(e.classname == "player")
1126         {
1127                 if(e.deadflag)
1128                         return -1;
1129         }
1130         else
1131         {
1132                 if(!e.fire_burner)
1133                 {
1134                         // print("adding a fire burner to ", e.classname, "\n");
1135                         e.fire_burner = spawn();
1136                         e.fire_burner.classname = "fireburner";
1137                         e.fire_burner.think = fireburner_think;
1138                         e.fire_burner.nextthink = time;
1139                         e.fire_burner.owner = e;
1140                 }
1141         }
1142
1143         t = max(t, 0.1);
1144         dps = d / t;
1145         if(Fire_IsBurning(e))
1146         {
1147                 mintime = e.fire_endtime - time;
1148                 maxtime = max(mintime, t);
1149
1150                 mindps = e.fire_damagepersec;
1151                 maxdps = max(mindps, dps);
1152
1153                 if(maxtime > mintime || maxdps > mindps)
1154                 {
1155                         mindamage = mindps * mintime;
1156                         maxdamage = mindamage + d;
1157
1158                         // interval [mintime, maxtime] * [mindps, maxdps]
1159                         // intersected with
1160                         // [mindamage, maxdamage]
1161                         // maximum of this!
1162
1163                         if(maxdamage >= maxtime * maxdps)
1164                         {
1165                                 totaltime = maxtime;
1166                                 totaldamage = maxtime * maxdps;
1167
1168                                 // this branch increases totaldamage if either t > mintime, or dps > mindps
1169                         }
1170                         else
1171                         {
1172                                 // maxdamage is inside the interval!
1173                                 // first, try to use mindps; only if this fails, increase dps as needed
1174                                 totaltime = min(maxdamage / mindps, maxtime); // maxdamage / mindps >= mindamage / mindps = mintime
1175                                 totaldamage = maxdamage;
1176                                 // can totaldamage / totaltime be >= maxdps?
1177                                 // max(mindps, maxdamage / maxtime) >= maxdps?
1178                                 // we know maxdamage < maxtime * maxdps
1179                                 // so it cannot be
1180
1181                                 // this branch ALWAYS increases totaldamage, but requires maxdamage < maxtime * maxdps
1182                         }
1183
1184                         // total conditions for increasing:
1185                         //     maxtime > mintime OR maxdps > mindps OR maxtime * maxdps > maxdamage
1186                         // however:
1187                         //     if maxtime = mintime, maxdps = mindps
1188                         // then:
1189                         //     maxdamage = mindamage + d
1190                         //     mindamage = mindps * mintime = maxdps * maxtime < maxdamage!
1191                         // so the last condition is not needed
1192
1193                         e.fire_damagepersec = totaldamage / totaltime;
1194                         e.fire_endtime = time + totaltime;
1195                         if(totaldamage > 1.2 * mindamage)
1196                         {
1197                                 e.fire_deathtype = dt;
1198                                 if(e.fire_owner != o)
1199                                 {
1200                                         e.fire_owner = o;
1201                                         e.fire_hitsound = FALSE;
1202                                 }
1203                         }
1204                         if(accuracy_isgooddamage(o, e))
1205                                 accuracy_add(o, DEATH_WEAPONOFWEAPONDEATH(dt), 0, max(0, totaldamage - mindamage));
1206                         return max(0, totaldamage - mindamage); // can never be negative, but to make sure
1207                 }
1208                 else
1209                         return 0;
1210         }
1211         else
1212         {
1213                 e.fire_damagepersec = dps;
1214                 e.fire_endtime = time + t;
1215                 e.fire_deathtype = dt;
1216                 e.fire_owner = o;
1217                 e.fire_hitsound = FALSE;
1218                 if(accuracy_isgooddamage(o, e))
1219                         accuracy_add(o, DEATH_WEAPONOFWEAPONDEATH(dt), 0, d);
1220                 return d;
1221         }
1222 }
1223
1224 void Fire_ApplyDamage(entity e)
1225 {
1226         float t, d, hi, ty;
1227         entity o;
1228
1229         if not(Fire_IsBurning(e))
1230                 return;
1231
1232         for(t = 0, o = e.owner; o.owner && t < 16; o = o.owner, ++t);
1233         if(clienttype(o) == CLIENTTYPE_NOTACLIENT)
1234                 o = e.fire_owner;
1235
1236         // water and slime stop fire
1237         if(e.waterlevel)
1238         if(e.watertype != CONTENT_LAVA)
1239                 e.fire_endtime = 0;
1240
1241         // ice stops fire
1242         if(e.freezetag_frozen)
1243                 e.fire_endtime = 0;
1244
1245         t = min(frametime, e.fire_endtime - time);
1246         d = e.fire_damagepersec * t;
1247
1248         hi = e.fire_owner.hitsound;
1249         ty = e.fire_owner.typehitsound;
1250         Damage(e, e, e.fire_owner, d, e.fire_deathtype, e.origin, '0 0 0');
1251         if(e.fire_hitsound && e.fire_owner)
1252         {
1253                 e.fire_owner.hitsound = hi;
1254                 e.fire_owner.typehitsound = ty;
1255         }
1256         e.fire_hitsound = TRUE;
1257
1258         if not(IS_INDEPENDENT_PLAYER(e))
1259         FOR_EACH_PLAYER(other) if(e != other)
1260         {
1261                 if(other.classname == "player")
1262                 if(other.deadflag == DEAD_NO)
1263                 if not(IS_INDEPENDENT_PLAYER(other))
1264                 if(boxesoverlap(e.absmin, e.absmax, other.absmin, other.absmax))
1265                 {
1266                         t = autocvar_g_balance_firetransfer_time * (e.fire_endtime - time);
1267                         d = autocvar_g_balance_firetransfer_damage * e.fire_damagepersec * t;
1268                         Fire_AddDamage(other, o, d, t, DEATH_FIRE);
1269                 }
1270         }
1271 }
1272
1273 void Fire_ApplyEffect(entity e)
1274 {
1275         if(Fire_IsBurning(e))
1276                 e.effects |= EF_FLAME;
1277         else
1278                 e.effects &~= EF_FLAME;
1279 }
1280
1281 void fireburner_think()
1282 {
1283         // for players, this is done in the regular loop
1284         if(wasfreed(self.owner))
1285         {
1286                 remove(self);
1287                 return;
1288         }
1289         Fire_ApplyEffect(self.owner);
1290         if(!Fire_IsBurning(self.owner))
1291         {
1292                 self.owner.fire_burner = world;
1293                 remove(self);
1294                 return;
1295         }
1296         Fire_ApplyDamage(self.owner);
1297         self.nextthink = time;
1298 }