Xonotic
sv_globalforces.qc
Go to the documentation of this file.
1 #include "sv_globalforces.qh"
2 
3 AUTOCVAR(g_globalforces, float, false, "Global forces: knockback affects everyone");
4 AUTOCVAR(g_globalforces_noself, bool, true, "Global forces: ignore self damage");
5 AUTOCVAR(g_globalforces_self, float, 1, "Global forces: knockback self scale");
6 AUTOCVAR(g_globalforces_range, float, 1000, "Global forces: max range of effect");
7 REGISTER_MUTATOR(mutator_globalforces, autocvar_g_globalforces);
8 
9 MUTATOR_HOOKFUNCTION(mutator_globalforces, BuildMutatorsString) {
10  M_ARGV(0, string) = strcat(M_ARGV(0, string), ":GlobalForces");
11 }
12 
13 MUTATOR_HOOKFUNCTION(mutator_globalforces, BuildMutatorsPrettyString) {
14  M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Global forces");
15 }
16 
17 MUTATOR_HOOKFUNCTION(mutator_globalforces, PlayerDamage_SplitHealthArmor) {
18  entity frag_attacker = M_ARGV(1, entity);
19  entity frag_target = M_ARGV(2, entity);
20  if (autocvar_g_globalforces_noself && frag_target == frag_attacker) return;
21  vector damage_force = M_ARGV(3, vector) * autocvar_g_globalforces;
22  FOREACH_CLIENT(IS_PLAYER(it) && it != frag_target, {
23  if (autocvar_g_globalforces_range) {
24  if (vdist(it.origin - frag_target.origin, >, autocvar_g_globalforces_range)) {
25  continue;
26  }
27  }
28  float f = (it == frag_attacker) ? autocvar_g_globalforces_self : 1;
29  it.velocity += damage_explosion_calcpush(f * it.damageforcescale * damage_force, it.velocity, autocvar_g_balance_damagepush_speedfactor);
30  });
31 }
entity() spawn
vector damage_explosion_calcpush(vector explosion_f, vector target_v, float speedfactor)
Definition: calculations.qc:45
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
AUTOCVAR(g_globalforces, float, false, "Global forces: knockback affects everyone")
REGISTER_MUTATOR(mutator_globalforces, autocvar_g_globalforces)
#define M_ARGV(x, type)
Definition: events.qh:17
float autocvar_g_balance_damagepush_speedfactor
Definition: damage.qh:18
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
MUTATOR_HOOKFUNCTION(mutator_globalforces, BuildMutatorsString)
#define IS_PLAYER(v)
Definition: utils.qh:9