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