Skip to content

Commit

Permalink
Merge pull request #3437 from Superlagg/dynamic-butt-mobile
Browse files Browse the repository at this point in the history
Jams Dynamic 2021 where it doesnt belong
  • Loading branch information
Tk420634 authored Oct 16, 2023
2 parents f76019a + 15e781c commit 52605de
Show file tree
Hide file tree
Showing 77 changed files with 2,844 additions and 2,727 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#define COMSIG_GLOB_RADIATION_SHOW "!debug_show_rads" //Makes turfs that are radioactive green and show a number


#define COMSIG_GLOB_PRE_RANDOM_EVENT "!pre_random_event"
/// Do not allow this random event to continue.
#define CANCEL_PRE_RANDOM_EVENT (1<<0)

// signals from globally accessible objects
/// from SSsun when the sun changes position : (azimuth)
#define COMSIG_SUN_MOVED "sun_moved"
Expand Down
28 changes: 14 additions & 14 deletions code/__DEFINES/dynamic.dm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#define CURRENT_LIVING_PLAYERS 1
#define CURRENT_LIVING_ANTAGS 2
#define CURRENT_DEAD_PLAYERS 3
#define CURRENT_OBSERVERS 4
/// This is the only ruleset that should be picked this round, used by admins and should not be on rulesets in code.
#define ONLY_RULESET (1 << 0)

#define NO_ASSASSIN (1<<0)
#define WAROPS_ALWAYS_ALLOWED (1<<1)
#define USE_PREF_WEIGHTS (1<<2)
#define FORCE_IF_WON (1<<3)
#define USE_PREV_ROUND_WEIGHTS (1<<4)
/// Only one ruleset with this flag will be picked.
#define HIGH_IMPACT_RULESET (1 << 1)

#define ONLY_RULESET (1<<0)
#define HIGHLANDER_RULESET (1<<1)
#define TRAITOR_RULESET (1<<2)
#define MINOR_RULESET (1<<3)
/// This ruleset can only be picked once. Anything that does not have a scaling_cost MUST have this.
#define LONE_RULESET (1 << 2)

#define RULESET_STOP_PROCESSING 1
/// No round event was hijacked this cycle
#define HIJACKED_NOTHING "HIJACKED_NOTHING"

/// This cycle, a round event was hijacked when the last midround event was too recent.
#define HIJACKED_TOO_RECENT "HIJACKED_TOO_RECENT"

/// This cycle, a round event was hijacked when the next midround event is too soon.
#define HIJACKED_TOO_SOON "HIJACKED_TOO_SOON"
9 changes: 9 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -637,3 +637,12 @@
#define PHUD_SHIRT "GENITAL_HUD_SHIRT"
#define PHUD_PANTS "GENITAL_HUD_PANTS"
#define PHUD_SOCKS "GENITAL_HUD_SOCKS"
//Gremlins
#define NPC_TAMPER_ACT_FORGET 1 //Don't try to tamper with this again
#define NPC_TAMPER_ACT_NOMSG 2 //Don't produce a visible message

//Game mode list indexes
#define CURRENT_LIVING_PLAYERS "living_players_list"
#define CURRENT_LIVING_ANTAGS "living_antags_list"
#define CURRENT_DEAD_PLAYERS "dead_players_list"
#define CURRENT_OBSERVERS "current_observers_list"
6 changes: 6 additions & 0 deletions code/__DEFINES/role_preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define ROLE_MALF "malf AI"
#define ROLE_REV "revolutionary"
#define ROLE_REV_HEAD "Head Revolutionary"
#define ROLE_REV_SUCCESSFUL "Victorious Revolutionary"
#define ROLE_ALIEN "xenomorph"
#define ROLE_PAI "pAI"
#define ROLE_CULTIST "cultist"
Expand All @@ -39,6 +40,11 @@
//#define ROLE_MONSTERHUNTER "monster hunter" Disabled for now
#define ROLE_GHOSTCAFE "ghostcafe"
#define ROLE_MINOR_ANTAG "minorantag"
#define ROLE_RESPAWN "respawnsystem"
/// Not an actual antag. Lets players force all antags off.
#define ROLE_NO_ANTAGONISM "NO_ANTAGS"
//Define for disabling individual antagonists for dynamic
#define HAS_ANTAG_PREF(C,ROLE) (!(ROLE_NO_ANTAGONISM in C.prefs.be_special) && (ROLE in C.prefs.be_special))
//Missing assignment means it's not a gamemode specific role, IT'S NOT A BUG OR ERROR.
//The gamemode specific ones are just so the gamemodes can query whether a player is old enough
//(in game days played) to play that role
Expand Down
16 changes: 16 additions & 0 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,22 @@
if (total <= 0)
return item

/proc/pickweightAllowZero(list/L) //The original pickweight proc will sometimes pick entries with zero weight. I'm not sure if changing the original will break anything, so I left it be.
var/total = 0
var/item
for (item in L)
if (!L[item])
L[item] = 0
total += L[item]

total = rand(0, total)
for (item in L)
total -=L [item]
if (total <= 0 && L[item])
return item

return null

//Picks a number of elements from a list based on weight.
//This is highly optimised and good for things like grabbing 200 items from a list of 40,000
//Much more efficient than many pickweight calls
Expand Down
2 changes: 2 additions & 0 deletions code/__HELPERS/config.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/proc/get_policy(keyword)
return global.config.policy[keyword]
3 changes: 3 additions & 0 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,6 @@ GLOBAL_LIST_EMPTY(species_list)
sleep(1)
if(set_original_dir)
AM.setDir(originaldir)
/// Gets the client of the mob, allowing for mocking of the client.
/// You only need to use this if you know you're going to be mocking clients somewhere else.
#define GET_CLIENT(mob) (##mob.client || ##mob.mock_client)
19 changes: 6 additions & 13 deletions code/__HELPERS/roundend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
var/list/publisher = list("Oasis Publishing","Brotherhood News","Mojave Publishing","FEV News")
//tell the nice people on discord what went on before the salt cannon happens.
// send2chat sending the new round ping off
send2chat(" <@&922230570791108628> ", CONFIG_GET(string/discord_channel_serverstatus))
//send2chat(" <@&922230570791108628> ", CONFIG_GET(string/discord_channel_serverstatus))
world.TgsTargetedChatBroadcast("The current round has ended. Please standby for your [pick(publisher)] report!", FALSE)
//lonestar edit. i'm adding a timer here because i'm tired of the messages being sent out of order
addtimer(CALLBACK(src, .proc/send_roundinfo), 3 SECONDS)
Expand Down Expand Up @@ -301,6 +301,7 @@
/datum/controller/subsystem/ticker/proc/survivor_report(popcount)
var/list/parts = list()
var/station_evacuated = EMERGENCY_ESCAPED_OR_ENDGAMED
var/datum/game_mode/dynamic/mode = SSticker.mode

if(GLOB.round_id)
var/statspage = CONFIG_GET(string/roundstatsurl)
Expand Down Expand Up @@ -334,21 +335,13 @@
else
parts += "[FOURSPACES]<i>Nobody died this shift!</i>"
if(istype(SSticker.mode, /datum/game_mode/dynamic))
var/datum/game_mode/dynamic/mode = SSticker.mode
mode.update_playercounts()
parts += "[FOURSPACES]Final threat level: [mode.threat_level]"
parts += "[FOURSPACES]Final threat: [mode.threat]"
parts += "[FOURSPACES]Average threat: [mode.threat_average]"
parts += "[FOURSPACES]Initial threat level: [mode.threat_level]"
parts += "[FOURSPACES]Initial roundstart threat: [mode.initial_round_start_budget]"
parts += "[FOURSPACES]Roundstart budget after antags: [mode.round_start_budget]"
parts += "[FOURSPACES]Midround budget at round end: [mode.mid_round_budget]"
parts += "[FOURSPACES]Executed rules:"
for(var/datum/dynamic_ruleset/rule in mode.executed_rules)
parts += "[FOURSPACES][FOURSPACES][rule.ruletype] - <b>[rule.name]</b>: -[rule.cost + rule.scaled_times * rule.scaling_cost] threat"
parts += "[FOURSPACES]Other threat changes:"
for(var/str in mode.threat_log)
parts += "[FOURSPACES][FOURSPACES][str]"
for(var/entry in mode.threat_tallies)
parts += "[FOURSPACES][FOURSPACES][entry] added [mode.threat_tallies[entry]]"
SSblackbox.record_feedback("tally","dynamic_threat",mode.threat_level,"Final threat level")
SSblackbox.record_feedback("tally","dynamic_threat",mode.threat,"Final Threat")
return parts.Join("<br>")

/client/proc/roundend_report_file()
Expand Down
4 changes: 2 additions & 2 deletions code/_globalvars/game_modes.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GLOBAL_VAR_INIT(master_mode, "traitor") //"extended"
GLOBAL_VAR_INIT(secret_force_mode, "secret") // if this is anything but "secret", the secret rotation will forceably choose this mode
GLOBAL_VAR_INIT(master_mode, "dynamic") //"extended"
GLOBAL_VAR_INIT(secret_force_mode, "dynamic") // if this is anything but "secret", the secret rotation will forceably choose this mode
GLOBAL_VAR(common_report) //Contains common part of roundend report
GLOBAL_VAR(survivor_report) //Contains shared survivor report for roundend report (part of personal report)

Expand Down
9 changes: 9 additions & 0 deletions code/_globalvars/lists/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ GLOBAL_LIST_EMPTY(mob_config_movespeed_type_lookup)

GLOBAL_LIST_EMPTY(latejoiners) //CIT CHANGE - All latejoining people, for traitor-target purposes.

/// All alive antags with clients.
GLOBAL_LIST_EMPTY(current_living_antags)

/// All observers with clients that joined as observers.
GLOBAL_LIST_EMPTY(current_observers_list)

//Dynamic Port
GLOBAL_LIST_EMPTY(new_player_list) //all /mob/dead/new_player, in theory all should have clients and those that don't are in the process of spawning and get deleted when done.

/proc/update_config_movespeed_type_lookup(update_mobs = TRUE)
// NOTE: This is entirely based on the fact that byond typesof/subtypesof gets longer/deeper paths before shallower ones.
// If that ever breaks this entire proc breaks.
Expand Down
48 changes: 6 additions & 42 deletions code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
var/list/mode_false_report_weight

var/motd
// var/policy
var/policy

var/static/regex/ic_filter_regex

Expand All @@ -41,7 +41,6 @@
CRASH("/datum/controller/configuration/Load() called more than once!")
InitEntries()
LoadModes()
storyteller_cache = typecacheof(/datum/dynamic_storyteller, TRUE)
if(fexists("[directory]/config.txt") && LoadEntries("config.txt") <= 1)
var/list/legacy_configs = list("game_options.txt", "dbconfig.txt", "comms.txt")
for(var/I in legacy_configs)
Expand All @@ -52,7 +51,7 @@
break
loadmaplist(CONFIG_MAPS_FILE)
LoadMOTD()
// LoadPolicy()
LoadPolicy()
LoadChatFilter()

if (Master)
Expand Down Expand Up @@ -266,7 +265,7 @@
if(M.votable)
votable_modes += M.config_tag
qdel(M)
votable_modes += "secret"
votable_modes += "dynamic"

/datum/controller/configuration/proc/LoadMOTD()
motd = file2text("[directory]/motd.txt")
Expand All @@ -292,7 +291,7 @@ Example config:
}
*/
/*

/datum/controller/configuration/proc/LoadPolicy()
policy = list()
var/rawpolicy = file2text("[directory]/policy.json")
Expand All @@ -303,7 +302,7 @@ Example config:
DelayedMessageAdmins("JSON parsing failure for policy.json")
else
policy = parsed
*/

/datum/controller/configuration/proc/loadmaplist(filename)
log_config("Loading config file [filename]...")
filename = "[directory]/[filename]"
Expand Down Expand Up @@ -388,42 +387,7 @@ Example config:
var/ct = initial(M.config_tag)
if(ct && ct == mode_name)
return new T
return new /datum/game_mode/extended()

/// For dynamic.
/datum/controller/configuration/proc/pick_storyteller(storyteller_name)
for(var/T in storyteller_cache)
var/datum/dynamic_storyteller/S = T
var/name = initial(S.name)
if(name && name == storyteller_name)
return T
return /datum/dynamic_storyteller/classic

/// Same with this
/datum/controller/configuration/proc/get_runnable_storytellers()
var/list/datum/dynamic_storyteller/runnable_storytellers = new
var/list/probabilities = Get(/datum/config_entry/keyed_list/storyteller_weight)
var/list/repeated_mode_adjust = Get(/datum/config_entry/number_list/repeated_mode_adjust)
var/list/min_player_counts = Get(/datum/config_entry/keyed_list/storyteller_min_players)
for(var/T in storyteller_cache)
var/datum/dynamic_storyteller/S = T
var/config_tag = initial(S.config_tag)
var/probability = (config_tag in probabilities) ? probabilities[config_tag] : initial(S.weight)
var/min_players = (config_tag in min_player_counts) ? min_player_counts[config_tag] : initial(S.min_players)
if(probability <= 0)
continue
if(length(GLOB.player_list) < min_players)
continue
if(SSpersistence.saved_storytellers.len == repeated_mode_adjust.len)
var/name = initial(S.name)
var/recent_round = min(SSpersistence.saved_storytellers.Find(name),3)
var/adjustment = 0
while(recent_round)
adjustment += repeated_mode_adjust[recent_round]
recent_round = SSpersistence.saved_modes.Find(name,recent_round+1,0)
probability *= ((100-adjustment)/100)
runnable_storytellers[S] = probability
return runnable_storytellers
return new /datum/game_mode/dynamic

/datum/controller/configuration/proc/get_runnable_modes()
var/list/datum/game_mode/runnable_modes = new
Expand Down
5 changes: 1 addition & 4 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,4 @@
/datum/config_entry/flag/atmos_equalize_enabled
default = FALSE

// for tgs to ping certain channels. if the channel is tagged with server_status in tgs, it will send a message to that
// via send2chat("Hello world.", CONFIG_GET(string/discord_channel_serverstatus))
/datum/config_entry/string/discord_channel_serverstatus
config_entry_value = "server_status"
/datum/config_entry/flag/dynamic_config_enabled
2 changes: 2 additions & 0 deletions code/controllers/subsystem/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ SUBSYSTEM_DEF(job)
var/datum/job/new_overflow = GetJob(new_overflow_role)
var/cap = CONFIG_GET(number/overflow_cap)

new_overflow.allow_bureaucratic_error = FALSE
new_overflow.spawn_positions = cap
new_overflow.total_positions = cap

if(new_overflow_role != overflow_role)
var/datum/job/old_overflow = GetJob(overflow_role)
old_overflow.allow_bureaucratic_error = initial(old_overflow.allow_bureaucratic_error)
old_overflow.spawn_positions = initial(old_overflow.spawn_positions)
old_overflow.total_positions = initial(old_overflow.total_positions)
overflow_role = new_overflow_role
Expand Down
10 changes: 5 additions & 5 deletions code/controllers/subsystem/persistence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ SUBSYSTEM_DEF(persistence)
saved_storytellers.len = 3
saved_storytellers[3] = saved_storytellers[2]
saved_storytellers[2] = saved_storytellers[1]
saved_storytellers[1] = mode.storyteller.name
average_dynamic_threat = (mode.threat_average + average_dynamic_threat) / 2
//saved_storytellers[1] = mode.storyteller.name
//average_dynamic_threat = (mode.threat_average + average_dynamic_threat) / 2
var/json_file = file("data/RecentStorytellers.json")
var/list/file_data = list()
file_data["data"] = saved_storytellers + average_dynamic_threat
Expand All @@ -510,9 +510,9 @@ SUBSYSTEM_DEF(persistence)
saved_dynamic_rules[3] = saved_dynamic_rules[2]
saved_dynamic_rules[2] = saved_dynamic_rules[1]
saved_dynamic_rules[1] = list()
for(var/r in mode.executed_rules)
var/datum/dynamic_ruleset/rule = r
saved_dynamic_rules[1] += rule.config_tag
// for(var/r in mode.executed_rules)
// var/datum/dynamic_ruleset/rule = r
// saved_dynamic_rules[1] += rule.config_tag
var/json_file = file("data/RecentRulesets.json")
var/list/file_data = list()
file_data["data"] = saved_dynamic_rules
Expand Down
Loading

0 comments on commit 52605de

Please sign in to comment.