Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_globalforces.qc
Go to the documentation of this file.
1#include "sv_globalforces.qh"
2
3AUTOCVAR(g_globalforces, float, false, "enable global forces, so that knockback affects everyone");
4AUTOCVAR(g_globalforces_noself, bool, true, "ignore self damage");
5AUTOCVAR(g_globalforces_self, float, 1, "global forces knockback self scale");
6AUTOCVAR(g_globalforces_range, float, 1000, "global forces max range of effect");
7REGISTER_MUTATOR(mutator_globalforces, autocvar_g_globalforces);
8
9MUTATOR_HOOKFUNCTION(mutator_globalforces, BuildMutatorsString) {
10 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":GlobalForces");
11}
12
13MUTATOR_HOOKFUNCTION(mutator_globalforces, BuildMutatorsPrettyString) {
14 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Global forces");
15}
16
17MUTATOR_HOOKFUNCTION(mutator_globalforces, PlayerDamage_SplitHealthArmor) {
18 entity frag_attacker = M_ARGV(1, entity);
20 if (autocvar_g_globalforces_noself && frag_target == frag_attacker) return;
21 vector damage_force = M_ARGV(3, vector) * autocvar_g_globalforces;
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}
#define REGISTER_MUTATOR(...)
Definition base.qh:295
#define MUTATOR_HOOKFUNCTION(...)
Definition base.qh:335
vector damage_explosion_calcpush(vector explosion_f, vector target_v, float speedfactor)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
#define IS_PLAYER(s)
Definition player.qh:243
#define AUTOCVAR(...)
Definition cvar.qh:161
float autocvar_g_balance_damagepush_speedfactor
Definition damage.qh:18
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
vector
Definition self.qh:92
entity frag_target
Definition sv_ctf.qc:2321
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8