Xonotic
sv_touchexplode.qc
Go to the documentation of this file.
1 #include "sv_touchexplode.qh"
2 
8 
10 
12 
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);
24  delete(e);
25 }
26 
28 {
29  entity player = M_ARGV(0, entity);
30 
31  if(time > player.touchexplode_time && !game_stopped && !IS_DEAD(player) && IS_PLAYER(player) && !STAT(FROZEN, player) && !IS_INDEPENDENT_PLAYER(player))
32  {
33  FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
34  if(time > it.touchexplode_time && !STAT(FROZEN, it) && !IS_DEAD(it) && !IS_INDEPENDENT_PLAYER(it))
35  if(boxesoverlap(player.absmin, player.absmax, it.absmin, it.absmax))
36  {
37  PlayerTouchExplode(player, it);
38  player.touchexplode_time = it.touchexplode_time = time + 0.2;
39  }
40  });
41  }
42 }
float autocvar_g_touchexplode_radius
MUTATOR_HOOKFUNCTION(touchexplode, PlayerPreThink)
REGISTER_MUTATOR(touchexplode, expr_evaluate(autocvar_g_touchexplode))
float touchexplode_time
#define IS_INDEPENDENT_PLAYER(e)
Definition: client.qh:314
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
float autocvar_g_touchexplode_damage
float autocvar_g_touchexplode_force
void PlayerPreThink(entity this)
Definition: client.qc:2402
#define DMG_NOWEP
Definition: damage.qh:126
float autocvar_g_touchexplode_edgedamage
void PlayerTouchExplode(entity p1, entity p2)
ERASEABLE float boxesoverlap(vector m1, vector m2, vector m3, vector m4)
requires that m2>m1 in all coordinates, and that m4>m3
Definition: vector.qh:73
const int CH_TRIGGER
Definition: sound.qh:12
#define NULL
Definition: post.qh:17
const float VOL_BASE
Definition: sound.qh:36
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
const float ATTEN_NORM
Definition: sound.qh:30
vector(float skel, float bonenum) _skel_get_boneabs_hidden
string autocvar_g_touchexplode
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
Definition: damage.qc:1057
setorigin(ent, v)
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]? [var[op]val | [op]var | val | var] ...
Definition: cvar.qh:48