]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator/mutator_touchexplode.qc
Mutators: add hooks for overkill
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / mutator_touchexplode.qc
1 #ifdef IMPLEMENTATION
2 REGISTER_MUTATOR(touchexplode, cvar("g_touchexplode"));
3
4 .float touchexplode_time;
5
6 void PlayerTouchExplode(entity p1, entity p2)
7 {SELFPARAM();
8         vector org = (p1.origin + p2.origin) * 0.5;
9         org.z += (p1.mins.z + p2.mins.z) * 0.5;
10
11         sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
12         Send_Effect(EFFECT_EXPLOSION_SMALL, org, '0 0 0', 1);
13
14         entity e = spawn();
15         setorigin(e, org);
16         RadiusDamage(e, world, autocvar_g_touchexplode_damage, autocvar_g_touchexplode_edgedamage, autocvar_g_touchexplode_radius, world, world, autocvar_g_touchexplode_force, DEATH_TOUCHEXPLODE.m_id, world);
17         remove(e);
18 }
19
20 MUTATOR_HOOKFUNCTION(touchexplode, PlayerPreThink)
21 {SELFPARAM();
22         if(time > self.touchexplode_time)
23         if(!gameover)
24         if(!self.frozen)
25         if(IS_PLAYER(self))
26         if(self.deadflag == DEAD_NO)
27         if (!IS_INDEPENDENT_PLAYER(self))
28         FOR_EACH_PLAYER(other) if(self != other)
29         {
30                 if(time > other.touchexplode_time)
31                 if(!other.frozen)
32                 if(other.deadflag == DEAD_NO)
33                 if (!IS_INDEPENDENT_PLAYER(other))
34                 if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax))
35                 {
36                         PlayerTouchExplode(self, other);
37                         self.touchexplode_time = other.touchexplode_time = time + 0.2;
38                 }
39         }
40
41         return false;
42 }
43 #endif