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