]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'TimePath/globalforces' into 'master'
authorMario <zacjardine@y7mail.com>
Mon, 15 Aug 2016 08:16:57 +0000 (08:16 +0000)
committerMario <zacjardine@y7mail.com>
Mon, 15 Aug 2016 08:16:57 +0000 (08:16 +0000)
Global forces mutator

knockback effects everyone

See merge request !350

qcsrc/common/mutators/all.inc
qcsrc/common/mutators/mutator/globalforces/_mod.inc [new file with mode: 0644]
qcsrc/common/mutators/mutator/globalforces/_mod.qh [new file with mode: 0644]
qcsrc/common/mutators/mutator/globalforces/globalforces.qc [new file with mode: 0644]
qcsrc/common/mutators/mutator/globalforces/module.inc [new file with mode: 0644]

index e99092c660896d524f4c97e268dd8be7bead69b1..6225872332b488458e63db9d02293d886212b978 100644 (file)
@@ -16,6 +16,7 @@
 #include "mutator/damagetext/module.inc"
 #include "mutator/dodging/module.inc"
 #include "mutator/doublejump/module.inc"
+#include "mutator/globalforces/module.inc"
 #include "mutator/hook/module.inc"
 #include "mutator/instagib/module.inc"
 #include "mutator/invincibleproj/module.inc"
diff --git a/qcsrc/common/mutators/mutator/globalforces/_mod.inc b/qcsrc/common/mutators/mutator/globalforces/_mod.inc
new file mode 100644 (file)
index 0000000..006a5d5
--- /dev/null
@@ -0,0 +1,2 @@
+// generated file; do not modify
+#include <common/mutators/mutator/globalforces/globalforces.qc>
diff --git a/qcsrc/common/mutators/mutator/globalforces/_mod.qh b/qcsrc/common/mutators/mutator/globalforces/_mod.qh
new file mode 100644 (file)
index 0000000..ac5cfd2
--- /dev/null
@@ -0,0 +1,2 @@
+// generated file; do not modify
+#include <common/mutators/mutator/globalforces/globalforces.qh>
diff --git a/qcsrc/common/mutators/mutator/globalforces/globalforces.qc b/qcsrc/common/mutators/mutator/globalforces/globalforces.qc
new file mode 100644 (file)
index 0000000..49ac468
--- /dev/null
@@ -0,0 +1,33 @@
+#ifdef IMPLEMENTATION
+
+AUTOCVAR(g_globalforces, float, false, "Global forces: knockback affects everyone");
+AUTOCVAR(g_globalforces_noself, bool, true, "Global forces: ignore self damage");
+AUTOCVAR(g_globalforces_self, float, 1, "Global forces: knockback self scale");
+AUTOCVAR(g_globalforces_range, float, 1000, "Global forces: max range of effect");
+REGISTER_MUTATOR(mutator_globalforces, autocvar_g_globalforces);
+
+MUTATOR_HOOKFUNCTION(mutator_globalforces, BuildMutatorsString) {
+    M_ARGV(0, string) = strcat(M_ARGV(0, string), ":GlobalForces");
+}
+
+MUTATOR_HOOKFUNCTION(mutator_globalforces, BuildMutatorsPrettyString) {
+    M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Global forces");
+}
+
+MUTATOR_HOOKFUNCTION(mutator_globalforces, PlayerDamage_SplitHealthArmor) {
+    entity frag_attacker = M_ARGV(1, entity);
+    entity frag_target = M_ARGV(2, entity);
+    if (autocvar_g_globalforces_noself && frag_target == frag_attacker) return;
+    vector damage_force = M_ARGV(3, vector) * autocvar_g_globalforces;
+    FOREACH_CLIENT(IS_PLAYER(it) && it != frag_target, {
+        if (autocvar_g_globalforces_range) {
+            if (vdist(it.origin - frag_target.origin, >, autocvar_g_globalforces_range)) {
+                continue;
+            }
+        }
+        float f = (it == frag_attacker) ? autocvar_g_globalforces_self : 1;
+        it.velocity += damage_explosion_calcpush(f * it.damageforcescale * damage_force, it.velocity, autocvar_g_balance_damagepush_speedfactor);
+    });
+}
+
+#endif
diff --git a/qcsrc/common/mutators/mutator/globalforces/module.inc b/qcsrc/common/mutators/mutator/globalforces/module.inc
new file mode 100644 (file)
index 0000000..2a0eec8
--- /dev/null
@@ -0,0 +1,3 @@
+#ifdef SVQC
+       #include "globalforces.qc"
+#endif