]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/touchexplode/sv_touchexplode.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / touchexplode / sv_touchexplode.qc
1 #include "sv_touchexplode.qh"
2
3 string autocvar_g_touchexplode;
4 float autocvar_g_touchexplode_radius;
5 float autocvar_g_touchexplode_damage;
6 float autocvar_g_touchexplode_edgedamage;
7 float autocvar_g_touchexplode_force;
8
9 REGISTER_MUTATOR(touchexplode, expr_evaluate(autocvar_g_touchexplode));
10
11 .float touchexplode_time;
12
13 void PlayerTouchExplode(entity p1, entity p2)
14 {
15         vector org = (p1.origin + p2.origin) * 0.5;
16         org.z += (p1.mins.z + p2.mins.z) * 0.5;
17
18         sound(p1, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
19         Send_Effect(EFFECT_EXPLOSION_SMALL, org, '0 0 0', 1);
20
21         entity e = spawn();
22         setorigin(e, org);
23         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);
24         delete(e);
25 }
26
27 MUTATOR_HOOKFUNCTION(touchexplode, PlayerPreThink)
28 {
29         entity player = M_ARGV(0, entity);
30
31         if (time > player.touchexplode_time) {
32                 if (!game_stopped) {
33                         if (!STAT(FROZEN, player)) {
34                                 if (IS_PLAYER(player)) {
35                                         if (!IS_DEAD(player)) {
36                                                 if (!IS_INDEPENDENT_PLAYER(player)) {
37                                                         FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
38                                                                 if (time > it.touchexplode_time) {
39                                                                         if (!STAT(FROZEN, it)) {
40                                                                                 if (!IS_DEAD(it)) {
41                                                                                         if (!IS_INDEPENDENT_PLAYER(it)) {
42                                                                                                 if (boxesoverlap(player.absmin, player.absmax, it.absmin, it.absmax)) {
43                                                                                                         PlayerTouchExplode(player, it);
44                                                                                                         player.touchexplode_time = it.touchexplode_time = time + 0.2;
45                                                                                                 }
46                                                                                         }
47                                                                                 }
48                                                                         }
49                                                                 }
50                                                         });
51                                                 }
52                                         }
53                                 }
54                         }
55                 }
56         }
57 }