]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/touchexplode/touchexplode.qc
Merge branch 'master' into terencehill/infomessages_panel_update
[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 {
13         vector org = (p1.origin + p2.origin) * 0.5;
14         org.z += (p1.mins.z + p2.mins.z) * 0.5;
15
16         sound(p1, 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, NULL, autocvar_g_touchexplode_damage, autocvar_g_touchexplode_edgedamage, autocvar_g_touchexplode_radius, NULL, NULL, autocvar_g_touchexplode_force, DEATH_TOUCHEXPLODE.m_id, NULL);
22         remove(e);
23 }
24
25 MUTATOR_HOOKFUNCTION(touchexplode, PlayerPreThink)
26 {
27         entity player = M_ARGV(0, entity);
28
29         if(time > player.touchexplode_time)
30         if(!gameover)
31         if(!STAT(FROZEN, player))
32         if(IS_PLAYER(player))
33         if(!IS_DEAD(player))
34         if(!IS_INDEPENDENT_PLAYER(player))
35                 FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
36                         if(time > it.touchexplode_time)
37                         if(!STAT(FROZEN, it))
38                         if(!IS_DEAD(it))
39                         if (!IS_INDEPENDENT_PLAYER(it))
40                         if(boxesoverlap(player.absmin, player.absmax, it.absmin, it.absmax))
41                         {
42                                 PlayerTouchExplode(player, it);
43                                 player.touchexplode_time = it.touchexplode_time = time + 0.2;
44                         }
45                 ));
46 }
47 #endif