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