]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a mutator to prevent players spawning at the same spawn point twice
authorMario <mario.mario@y7mail.com>
Tue, 13 Aug 2024 05:56:22 +0000 (15:56 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 13 Aug 2024 05:56:22 +0000 (15:56 +1000)
mutators.cfg
qcsrc/common/mutators/mutator/_mod.inc
qcsrc/common/mutators/mutator/_mod.qh
qcsrc/common/mutators/mutator/spawn_unique/_mod.inc [new file with mode: 0644]
qcsrc/common/mutators/mutator/spawn_unique/_mod.qh [new file with mode: 0644]
qcsrc/common/mutators/mutator/spawn_unique/sv_spawn_unique.qc [new file with mode: 0644]
qcsrc/common/mutators/mutator/spawn_unique/sv_spawn_unique.qh [new file with mode: 0644]

index 0851dc4f7cbc81fd6095c12824af650e4ca8c834..b33dfba3038a05c337c721b7cd86f3bec5679e0e 100644 (file)
@@ -550,3 +550,8 @@ set g_pinata_offhand 0 "if enabled, the second weapon will drop as well while du
 // =========
 set g_cloaked 0 "display all players mostly invisible"
 set g_balance_cloaked_alpha 0.25 "opacity of cloaked players"
+
+// ==============
+//  spawn unique
+// ==============
+set g_spawn_unique 0 "players cannot spawn at the same point twice"
index c463c429f0c0eec1c0c1ffa89487a79158a9ae1a..0efbc406a04673612cca707a0de84a6aea879f3d 100644 (file)
@@ -34,6 +34,7 @@
 #include <common/mutators/mutator/running_guns/_mod.inc>
 #include <common/mutators/mutator/sandbox/_mod.inc>
 #include <common/mutators/mutator/spawn_near_teammate/_mod.inc>
+#include <common/mutators/mutator/spawn_unique/_mod.inc>
 #include <common/mutators/mutator/stale_move_negation/_mod.inc>
 #include <common/mutators/mutator/status_effects/_mod.inc>
 #include <common/mutators/mutator/superspec/_mod.inc>
index 3b4eba7cb65a6a4fa93d97e515d6bb19a7f7b347..edeaca545298fecd3d541c4063dfff51230e603f 100644 (file)
@@ -34,6 +34,7 @@
 #include <common/mutators/mutator/running_guns/_mod.qh>
 #include <common/mutators/mutator/sandbox/_mod.qh>
 #include <common/mutators/mutator/spawn_near_teammate/_mod.qh>
+#include <common/mutators/mutator/spawn_unique/_mod.qh>
 #include <common/mutators/mutator/stale_move_negation/_mod.qh>
 #include <common/mutators/mutator/status_effects/_mod.qh>
 #include <common/mutators/mutator/superspec/_mod.qh>
diff --git a/qcsrc/common/mutators/mutator/spawn_unique/_mod.inc b/qcsrc/common/mutators/mutator/spawn_unique/_mod.inc
new file mode 100644 (file)
index 0000000..e9e7b39
--- /dev/null
@@ -0,0 +1,4 @@
+// generated file; do not modify
+#ifdef SVQC
+    #include <common/mutators/mutator/spawn_unique/sv_spawn_unique.qc>
+#endif
diff --git a/qcsrc/common/mutators/mutator/spawn_unique/_mod.qh b/qcsrc/common/mutators/mutator/spawn_unique/_mod.qh
new file mode 100644 (file)
index 0000000..252c8ac
--- /dev/null
@@ -0,0 +1,4 @@
+// generated file; do not modify
+#ifdef SVQC
+    #include <common/mutators/mutator/spawn_unique/sv_spawn_unique.qh>
+#endif
diff --git a/qcsrc/common/mutators/mutator/spawn_unique/sv_spawn_unique.qc b/qcsrc/common/mutators/mutator/spawn_unique/sv_spawn_unique.qc
new file mode 100644 (file)
index 0000000..2d32c51
--- /dev/null
@@ -0,0 +1,23 @@
+#include "sv_spawn_unique.qh"
+
+REGISTER_MUTATOR(spawn_unique, expr_evaluate(autocvar_g_spawn_unique));
+
+MUTATOR_HOOKFUNCTION(spawn_unique, Spawn_Score)
+{
+       entity player = M_ARGV(0, entity);
+       entity spawn_spot = M_ARGV(1, entity);
+       vector spawn_score = M_ARGV(2, vector);
+
+       if(spawn_spot == player.su_last_point)
+               spawn_score.x = 0.1; // extremely low priority but still selectable
+
+       M_ARGV(2, vector) = spawn_score;
+}
+
+MUTATOR_HOOKFUNCTION(spawn_unique, PlayerSpawn)
+{
+       entity player = M_ARGV(0, entity);
+       entity spawn_spot = M_ARGV(1, entity);
+
+       player.su_last_point = spawn_spot;
+}
diff --git a/qcsrc/common/mutators/mutator/spawn_unique/sv_spawn_unique.qh b/qcsrc/common/mutators/mutator/spawn_unique/sv_spawn_unique.qh
new file mode 100644 (file)
index 0000000..fd4d5ee
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+string autocvar_g_spawn_unique;
+
+.entity su_last_point;