]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator_touchexplode.qc
Merge branch 'master' into TimePath/deathtypes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_touchexplode.qc
1
2 #include "mutator.qh"
3
4 .float touchexplode_time;
5
6 void PlayerTouchExplode(entity p1, entity p2)
7 {SELFPARAM();
8         vector org;
9         org = (p1.origin + p2.origin) * 0.5;
10         org.z += (p1.mins.z + p2.mins.z) * 0.5;
11
12         sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
13         Send_Effect(EFFECT_EXPLOSION_SMALL, org, '0 0 0', 1);
14
15         entity e;
16         e = spawn();
17         setorigin(e, org);
18         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);
19         remove(e);
20 }
21
22 MUTATOR_HOOKFUNCTION(touchexplode_PlayerThink)
23 {SELFPARAM();
24         if(time > self.touchexplode_time)
25         if(!gameover)
26         if(!self.frozen)
27         if(IS_PLAYER(self))
28         if(self.deadflag == DEAD_NO)
29         if (!IS_INDEPENDENT_PLAYER(self))
30         FOR_EACH_PLAYER(other) if(self != other)
31         {
32                 if(time > other.touchexplode_time)
33                 if(!other.frozen)
34                 if(other.deadflag == DEAD_NO)
35                 if (!IS_INDEPENDENT_PLAYER(other))
36                 if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax))
37                 {
38                         PlayerTouchExplode(self, other);
39                         self.touchexplode_time = other.touchexplode_time = time + 0.2;
40                 }
41         }
42
43         return false;
44 }
45
46 MUTATOR_DEFINITION(mutator_touchexplode)
47 {
48         MUTATOR_HOOK(PlayerPreThink, touchexplode_PlayerThink, CBC_ORDER_ANY);
49
50         return false;
51 }