]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/touchexplode/sv_touchexplode.qc
Merge branch 'master' into terencehill/hud_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / touchexplode / sv_touchexplode.qc
1 #include "sv_touchexplode.qh"
2
3 float autocvar_g_touchexplode_radius;
4 float autocvar_g_touchexplode_damage;
5 float autocvar_g_touchexplode_edgedamage;
6 float autocvar_g_touchexplode_force;
7
8 REGISTER_MUTATOR(touchexplode, cvar("g_touchexplode"));
9
10 .float touchexplode_time;
11
12 void PlayerTouchExplode(entity p1, entity p2)
13 {
14         vector org = (p1.origin + p2.origin) * 0.5;
15         org.z += (p1.mins.z + p2.mins.z) * 0.5;
16
17         sound(p1, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
18         Send_Effect(EFFECT_EXPLOSION_SMALL, org, '0 0 0', 1);
19
20         entity e = spawn();
21         setorigin(e, org);
22         RadiusDamage(e, NULL, autocvar_g_touchexplode_damage, autocvar_g_touchexplode_edgedamage, autocvar_g_touchexplode_radius, NULL, NULL, autocvar_g_touchexplode_force, DEATH_TOUCHEXPLODE.m_id, NULL);
23         delete(e);
24 }
25
26 MUTATOR_HOOKFUNCTION(touchexplode, PlayerPreThink)
27 {
28         entity player = M_ARGV(0, entity);
29
30         if(time > player.touchexplode_time)
31         if(!gameover)
32         if(!STAT(FROZEN, player))
33         if(IS_PLAYER(player))
34         if(!IS_DEAD(player))
35         if(!IS_INDEPENDENT_PLAYER(player))
36                 FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
37                         if(time > it.touchexplode_time)
38                         if(!STAT(FROZEN, it))
39                         if(!IS_DEAD(it))
40                         if (!IS_INDEPENDENT_PLAYER(it))
41                         if(boxesoverlap(player.absmin, player.absmax, it.absmin, it.absmax))
42                         {
43                                 PlayerTouchExplode(player, it);
44                                 player.touchexplode_time = it.touchexplode_time = time + 0.2;
45                         }
46                 ));
47 }