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