]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator_touchexplode.qc
Mapinfo: decentralise mapinfo parsing
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_touchexplode.qc
1 #include "mutator.qh"
2
3 REGISTER_MUTATOR(touchexplode, cvar("g_touchexplode"));
4
5 .float touchexplode_time;
6
7 void PlayerTouchExplode(entity p1, entity p2)
8 {SELFPARAM();
9         vector 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 = spawn();
16         setorigin(e, org);
17         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);
18         remove(e);
19 }
20
21 MUTATOR_HOOKFUNCTION(touchexplode, PlayerPreThink)
22 {SELFPARAM();
23         if(time > self.touchexplode_time)
24         if(!gameover)
25         if(!self.frozen)
26         if(IS_PLAYER(self))
27         if(self.deadflag == DEAD_NO)
28         if (!IS_INDEPENDENT_PLAYER(self))
29         FOR_EACH_PLAYER(other) if(self != other)
30         {
31                 if(time > other.touchexplode_time)
32                 if(!other.frozen)
33                 if(other.deadflag == DEAD_NO)
34                 if (!IS_INDEPENDENT_PLAYER(other))
35                 if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax))
36                 {
37                         PlayerTouchExplode(self, other);
38                         self.touchexplode_time = other.touchexplode_time = time + 0.2;
39                 }
40         }
41
42         return false;
43 }