[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

🆑
fix: Fixed the "Random" deathmatch modifier. Also turned the "Heightened
Hearing" option into a modifier as well.
/🆑
This commit is contained in:
Ghom
2024-03-29 13:55:04 +01:00
committed by GitHub
parent 5e68c24715
commit cf28cbee11
3 changed files with 21 additions and 41 deletions
+2 -15
View File
@@ -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
+19 -14
View File
@@ -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)
@@ -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) => {
<br />
Current players: <b>{Object.keys(data.players).length}</b>
</Box>
<Button.Checkbox
checked={data.global_chat}
disabled={!(data.host || data.admin)}
content="Heightened Hearing"
tooltip="Players can hear ghosts and hear through walls."
onClick={() =>
act('host', {
func: 'global_chat',
})
}
/>
<Divider />
<Box textAlign="center">{data.active_mods}</Box>
{(!!data.admin || !!data.host) && (