Skip to content

Commit

Permalink
[MIRROR] [NO GBP] Fixes the "Random" deathmatch modifier and turns "H…
Browse files Browse the repository at this point in the history
…eightened Hearing" into a modifier as well. (#1702)

* [NO GBP] Fixes the "Random" deathmatch modifier and turns "Heightened Hearing" into a modifier as well.

* Update deathmatch_lobby.dm

---------

Co-authored-by: Ghom <[email protected]>
Co-authored-by: Mal <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Mar 29, 2024
1 parent bb03c1c commit 1149f01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 41 deletions.
17 changes: 2 additions & 15 deletions code/modules/deathmatch/deathmatch_lobby.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
// NOVA EDIT ADDITION START - Synth brains don't drop here - let them delete with the mob
var/obj/item/organ/internal/brain/synth/synth_brain = new_player.get_organ_slot(ORGAN_SLOT_BRAIN)
if(istype(synth_brain))
Expand Down Expand Up @@ -351,7 +346,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)
Expand Down Expand Up @@ -488,9 +482,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
Expand All @@ -501,18 +492,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
Expand Down
33 changes: 19 additions & 14 deletions code/modules/deathmatch/deathmatch_modifier.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand All @@ -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)
12 changes: 0 additions & 12 deletions tgui/packages/tgui/interfaces/DeathmatchLobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type Data = {
self: string;
host: BooleanLike;
admin: BooleanLike;
global_chat: BooleanLike;
playing: BooleanLike;
loadouts: string[];
maps: string[];
Expand Down Expand Up @@ -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) && (
Expand Down

0 comments on commit 1149f01

Please sign in to comment.