From cf28cbee1100e9b294bc0dcd4e7377b3182e4459 Mon Sep 17 00:00:00 2001
From: Ghom <42542238+Ghommie@users.noreply.github.com>
Date: Fri, 29 Mar 2024 13:55:04 +0100
Subject: [PATCH] [NO GBP] Fixes the "Random" deathmatch modifier and turns
"Heightened Hearing" into a modifier as well. (#82223)
## About The Pull Request
See the title.
## Why It's Good For The Game
This will fix #82149
## Changelog
:cl:
fix: Fixed the "Random" deathmatch modifier. Also turned the "Heightened
Hearing" option into a modifier as well.
/:cl:
---
code/modules/deathmatch/deathmatch_lobby.dm | 17 ++--------
.../modules/deathmatch/deathmatch_modifier.dm | 33 +++++++++++--------
.../tgui/interfaces/DeathmatchLobby.tsx | 12 -------
3 files changed, 21 insertions(+), 41 deletions(-)
diff --git a/code/modules/deathmatch/deathmatch_lobby.dm b/code/modules/deathmatch/deathmatch_lobby.dm
index 9088f1cd072..5dfdba213ca 100644
--- a/code/modules/deathmatch/deathmatch_lobby.dm
+++ b/code/modules/deathmatch/deathmatch_lobby.dm
@@ -9,8 +9,6 @@
var/datum/lazy_template/deathmatch/map
/// Our turf reservation AKA where the arena is
var/datum/turf_reservation/location
- /// Whether players hear deadchat and people through walls
- var/global_chat = FALSE
/// Whether the lobby is currently playing
var/playing = DEATHMATCH_NOT_PLAYING
/// Number of total ready players
@@ -148,9 +146,6 @@
// register death handling.
RegisterSignals(new_player, list(COMSIG_LIVING_DEATH, COMSIG_MOB_GHOSTIZED, COMSIG_QDELETING), PROC_REF(player_died))
- if (global_chat)
- ADD_TRAIT(new_player, TRAIT_SIXTHSENSE, INNATE_TRAIT)
- ADD_TRAIT(new_player, TRAIT_XRAY_HEARING, INNATE_TRAIT)
/datum/deathmatch_lobby/proc/game_took_too_long()
if (!location || QDELING(src))
@@ -346,7 +341,6 @@
.["self"] = user.ckey
.["host"] = is_host
.["admin"] = is_admin
- .["global_chat"] = global_chat
.["playing"] = playing
.["loadouts"] = list("Randomize")
for (var/datum/outfit/deathmatch_loadout/loadout as anything in loadouts)
@@ -483,9 +477,6 @@
return FALSE
change_map(params["map"])
return TRUE
- if ("global_chat")
- global_chat = !global_chat
- return TRUE
if("open_mod_menu")
mod_menu_open = TRUE
return TRUE
@@ -496,18 +487,14 @@
var/datum/deathmatch_modifier/modpath = text2path(params["modpath"])
if(!ispath(modpath))
return TRUE
- var/global_mod = params["global_mod"]
- if(global_mod)
- if(usr.ckey != host && !check_rights(R_ADMIN))
- return TRUE
- else if(!(usr.ckey in players))
+ if(usr.ckey != host && !check_rights(R_ADMIN))
return TRUE
var/datum/deathmatch_modifier/chosen_modifier = GLOB.deathmatch_game.modifiers[modpath]
if(modpath in modifiers)
chosen_modifier.unselect(src)
modifiers -= modpath
return TRUE
- else if(chosen_modifier.selectable(src))
+ if(chosen_modifier.selectable(src))
chosen_modifier.on_select(src)
modifiers += modpath
return TRUE
diff --git a/code/modules/deathmatch/deathmatch_modifier.dm b/code/modules/deathmatch/deathmatch_modifier.dm
index c0d5807063f..5037b3c3ae3 100644
--- a/code/modules/deathmatch/deathmatch_modifier.dm
+++ b/code/modules/deathmatch/deathmatch_modifier.dm
@@ -478,6 +478,7 @@
/datum/deathmatch_modifier/random
name = "Random Modifiers"
description = "Picks 3 to 5 random modifiers as the game is about to start"
+ random_exempted = TRUE
/datum/deathmatch_modifier/random/on_select(datum/deathmatch_lobby/lobby)
///remove any other global modifier if chosen. It'll pick random ones when the time comes.
@@ -486,36 +487,32 @@
if(modifier.random_exempted)
continue
modifier.unselect(lobby)
- lobby -= modpath
+ lobby.modifiers -= modpath
/datum/deathmatch_modifier/random/on_start_game(datum/deathmatch_lobby/lobby)
lobby.modifiers -= type //remove it before attempting to select other modifiers, or they'll fail.
var/static/list/static_pool
- if(!static_pool)
+ if(isnull(static_pool))
static_pool = subtypesof(/datum/deathmatch_modifier)
for(var/datum/deathmatch_modifier/modpath as anything in static_pool)
if(initial(modpath.random_exempted))
static_pool -= modpath
var/list/modifiers_pool = static_pool.Copy()
+ for(var/modpath in modifiers_pool)
+ var/datum/deathmatch_modifier/modifier = GLOB.deathmatch_game.modifiers[modpath]
+ if(!modifier.selectable(lobby))
+ modifiers_pool -= modpath
///Pick global modifiers at random.
for(var/iteration in rand(3, 5))
- var/mod_len = length(modifiers_pool)
- if(!mod_len)
- break
- var/datum/deathmatch_modifier/modifier
- if(mod_len > 1)
- modifier = GLOB.deathmatch_game.modifiers[pick_n_take(modifiers_pool)]
- else //pick() throws errors if the list has only one element iirc.
- modifier = GLOB.deathmatch_game.modifiers[modifiers_pool[1]]
- modifiers_pool = null
- if(!modifier.selectable(lobby))
- continue
+ var/datum/deathmatch_modifier/modifier = GLOB.deathmatch_game.modifiers[pick_n_take(modifiers_pool)]
modifier.on_select(lobby)
modifier.on_start_game(lobby)
- lobby += modifier
+ lobby += modifier.type
modifiers_pool -= modifier.blacklisted_modifiers
+ if(!length(modifiers_pool))
+ return
/datum/deathmatch_modifier/any_loadout
name = "Any Loadout Allowed"
@@ -539,3 +536,11 @@
lobby.modifiers -= type
else
lobby.loadouts = GLOB.deathmatch_game.loadouts
+
+/datum/deathmatch_modifier/hear_global_chat
+ name = "Heightened Hearing"
+ description = "This lets you hear people through wall, as well as deadchat"
+ random_exempted = TRUE
+
+/datum/deathmatch_modifier/hear_global_chat/apply(mob/living/carbon/player, datum/deathmatch_lobby/lobby)
+ player.add_traits(list(TRAIT_SIXTHSENSE, TRAIT_XRAY_HEARING), DEATHMATCH_TRAIT)
diff --git a/tgui/packages/tgui/interfaces/DeathmatchLobby.tsx b/tgui/packages/tgui/interfaces/DeathmatchLobby.tsx
index a910f48a9fe..3a3cc19cd05 100644
--- a/tgui/packages/tgui/interfaces/DeathmatchLobby.tsx
+++ b/tgui/packages/tgui/interfaces/DeathmatchLobby.tsx
@@ -36,7 +36,6 @@ type Data = {
self: string;
host: BooleanLike;
admin: BooleanLike;
- global_chat: BooleanLike;
playing: BooleanLike;
loadouts: string[];
maps: string[];
@@ -174,17 +173,6 @@ export const DeathmatchLobby = (props) => {
Current players: {Object.keys(data.players).length}
-
- act('host', {
- func: 'global_chat',
- })
- }
- />
{data.active_mods}
{(!!data.admin || !!data.host) && (