]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add Spawn Unique mutator to prevent spawning at the same spawn point twice in a row
authorMario <mario.mario@y7mail.com>
Mon, 21 Oct 2024 20:04:57 +0000 (20:04 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Mon, 21 Oct 2024 20:04:57 +0000 (20:04 +0000)
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 7bf69658dd6479f79b1e5d3b9a2616a75c2fb9f6..61e19ccb2bf60d8760d8b55d489136e65a4464c8 100644 (file)
@@ -551,3 +551,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 in a row"
index 924e442f3b137c5c5d3aa9bca9be89925abf2e9b..d07e3eae5910399cb1bc920bea39ae3321dbaa8d 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 ad45ec8c947990976530dda01cd6ae5be0f0f210..be1ed7f13c7a94b911c246d65116bff217f716b2 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..7bb6d97
--- /dev/null
@@ -0,0 +1,4 @@
+// genmod.sh autogenerated 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..c19bd6a
--- /dev/null
@@ -0,0 +1,4 @@
+// genmod.sh autogenerated 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;