Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into xeno_endgame_revive
Browse files Browse the repository at this point in the history
# Conflicts:
#	code/modules/mob/living/carbon/xenomorph/castes/Queen.dm
  • Loading branch information
Drulikar committed Jul 21, 2024
2 parents e04d971 + 10f073a commit f69b5c5
Show file tree
Hide file tree
Showing 96 changed files with 1,026 additions and 1,134 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
#define CANROOT (1<<6)
#define GODMODE (1<<12)
#define FAKEDEATH (1<<13) //Replaces stuff like changeling.changeling_fakedeath
#define DISFIGURED (1<<14) //I'll probably move this elsewhere if I ever get wround to writing a bitflag mob-damage system
//#define DISFIGURED (1<<14) //unused
#define XENO_HOST (1<<15) //Tracks whether we're gonna be a baby alien's mummy.
#define IMMOBILE_ACTION (1<<16) // If you are performing an action that prevents you from being pushed by your own people.
#define PERMANENTLY_DEAD (1<<17)
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
#define SS_INIT_NIGHTMARE 21.5
#define SS_INIT_TIMETRACK 21.1
#define SS_INIT_HUMANS 21
#define SS_INIT_WHO 20
#define SS_INIT_POWER 19
#define SS_INIT_INFLUXMCSTATS 12
#define SS_INIT_INFLUXSTATS 11
Expand Down
18 changes: 12 additions & 6 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,23 @@
* You should only pass integers in.
*/
/proc/pick_weight(list/list_to_pick)
if(length(list_to_pick) == 0)
return null

var/total = 0
var/item
for(item in list_to_pick)
for(var/item in list_to_pick)
if(!list_to_pick[item])
list_to_pick[item] = 0
total += list_to_pick[item]

total = rand(0, total)
for(item in list_to_pick)
total -= list_to_pick[item]
if(total <= 0 && list_to_pick[item])
total = rand(1, total)
for(var/item in list_to_pick)
var/item_weight = list_to_pick[item]
if(item_weight == 0)
continue

total -= item_weight
if(total <= 0)
return item

return null
Expand Down
16 changes: 0 additions & 16 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,6 @@
result = first ^ second
return result

//Pretends to pick an element based on its weight but really just seems to pick a random element.
/proc/pickweight(list/L)
var/total = 0
var/item
for (item in L)
if (!L[item])
L[item] = 1
total += L[item]

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

/// Pick a random element from the list and remove it from the list.
/proc/pick_n_take(list/L)
RETURN_TYPE(L[_].type)
Expand Down
1 change: 0 additions & 1 deletion code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ DEFINE_BITFIELD(status_flags, list(
"PASSEMOTES" = PASSEMOTES,
"GODMODE" = GODMODE,
"FAKEDEATH" = FAKEDEATH,
"DISFIGURED" = DISFIGURED,
"XENO_HOST" = XENO_HOST,
"IMMOBILE_ACTION" = IMMOBILE_ACTION,
"PERMANENTLY_DEAD" = PERMANENTLY_DEAD,
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SUBSYSTEM_DEF(sound)
if(!run_hearers) // Initialize for handling next template
run_hearers = run_queue[run_template] // get base hearers
if(run_template.range) // ranging
run_hearers |= SSquadtree.players_in_range(SQUARE(run_template.x, run_template.y, run_template.range), run_template.z)
run_hearers |= SSquadtree.players_in_range(SQUARE(run_template.x, run_template.y, run_template.range * 2), run_template.z)
if(MC_TICK_CHECK)
return
while(length(run_hearers)) // Output sound to hearers
Expand Down
312 changes: 312 additions & 0 deletions code/controllers/subsystem/who.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
SUBSYSTEM_DEF(who)
name = "Who"
flags = SS_BACKGROUND
runlevels = RUNLEVELS_DEFAULT|RUNLEVEL_LOBBY
init_order = SS_INIT_WHO
wait = 5 SECONDS

var/datum/player_list/who = new
var/datum/player_list/staff/staff_who = new

/datum/controller/subsystem/who/Initialize()
who.update_data()
staff_who.update_data()
return SS_INIT_SUCCESS

/datum/controller/subsystem/who/fire(resumed = TRUE)
who.update_data()
staff_who.update_data()

//datum
/datum/player_list
var/tgui_name = "Who"
var/tgui_interface_name = "Who"
var/list/mobs_ckey = list()
var/list/list_data = list()

/datum/player_list/proc/update_data()
var/list/new_list_data = list()
var/list/new_mobs_ckey = list()
var/list/additional_data = list(
"lobby" = 0,
"admin_observers" = 0,
"observers" = 0,
"yautja" = 0,
"infected_preds" = 0,
"humans" = 0,
"infected_humans" = 0,
"uscm" = 0,
"uscm_marines" = 0,
)
new_list_data["additional_info"] = list()
var/list/counted_factions = list()
for(var/client/client as anything in sortTim(GLOB.clients, GLOBAL_PROC_REF(cmp_ckey_asc)))
CHECK_TICK
new_list_data["all_clients"]++
var/list/client_payload = list()
client_payload["ckey"] = "[client.key]"
client_payload["text"] = "[client.key]"
client_payload["ckey_color"] = "white"
var/mob/client_mob = client.mob
new_mobs_ckey[client.key] = client_mob
if(client_mob)
if(istype(client_mob, /mob/new_player))
client_payload["text"] += " - in Lobby"
additional_data["lobby"]++

else if(isobserver(client_mob))
client_payload["text"] += " - Playing as [client_mob.real_name]"
if(CLIENT_IS_STAFF(client))
additional_data["admin_observers"]++
else
additional_data["observers"]++

var/mob/dead/observer/observer = client_mob
if(observer.started_as_observer)
client_payload["color"] += "#ce89cd"
client_payload["text"] += " - Spectating"
else
client_payload["color"] += "#A000D0"
client_payload["text"] += " - DEAD"

else
client_payload["text"] += " - Playing as [client_mob.real_name]"

switch(client_mob.stat)
if(UNCONSCIOUS)
client_payload["color"] += "#B0B0B0"
client_payload["text"] += " - Unconscious"
if(DEAD)
client_payload["color"] += "#A000D0"
client_payload["text"] += " - DEAD"

if(client_mob.stat != DEAD)
if(isxeno(client_mob))
client_payload["color"] += "#ec3535"
client_payload["text"] += " - Xenomorph"

else if(ishuman(client_mob))
if(client_mob.faction == FACTION_ZOMBIE)
counted_factions[FACTION_ZOMBIE]++
client_payload["color"] += "#2DACB1"
client_payload["text"] += " - Zombie"
else if(client_mob.faction == FACTION_YAUTJA)
client_payload["color"] += "#7ABA19"
client_payload["text"] += " - Yautja"
additional_data["yautja"]++
if(client_mob.status_flags & XENO_HOST)
additional_data["infected_preds"]++
else
additional_data["humans"]++
if(client_mob.status_flags & XENO_HOST)
additional_data["infected_humans"]++
if(client_mob.faction == FACTION_MARINE)
additional_data["uscm"]++
if(client_mob.job in (GLOB.ROLES_MARINES))
additional_data["uscm_marines"]++
else
counted_factions[client_mob.faction]++

new_list_data["total_players"] += list(client_payload)

new_list_data["additional_info"] += list(list(
"content" = "In Lobby: [additional_data["lobby"]]",
"color" = "#777",
"text" = "Player in lobby",
))

new_list_data["additional_info"] += list(list(
"content" = "Spectating Players: [additional_data["observers"]]",
"color" = "#777",
"text" = "Spectating players",
))

new_list_data["additional_info"] += list(list(
"content" = "Spectating Admins: [additional_data["admin_observers"]]",
"color" = "#777",
"text" = "Spectating administrators",
))

new_list_data["additional_info"] += list(list(
"content" = "Humans: [additional_data["humans"]]",
"color" = "#2C7EFF",
"text" = "Players playing as Human",
))

new_list_data["additional_info"] += list(list(
"content" = "Infected Humans: [additional_data["infected_humans"]]",
"color" = "#ec3535",
"text" = "Players playing as Infected Human",
))

new_list_data["additional_info"] += list(list(
"content" = "[MAIN_SHIP_NAME] Personnel: [additional_data["uscm"]]",
"color" = "#5442bd",
"text" = "Players playing as [MAIN_SHIP_NAME] Personnel",
))

new_list_data["additional_info"] += list(list(
"content" = "Marines: [additional_data["uscm_marines"]]",
"color" = "#5442bd",
"text" = "Players playing as Marines",
))

new_list_data["additional_info"] += list(list(
"content" = "Yautjas: [additional_data["yautja"]]",
"color" = "#7ABA19",
"text" = "Players playing as Yautja",
))

new_list_data["additional_info"] += list(list(
"content" = "Infected Predators: [additional_data["infected_preds"]]",
"color" = "#7ABA19",
"text" = "Players playing as Infected Yautja",
))

for(var/i in 1 to length(counted_factions))
if(counted_factions[counted_factions[i]])
new_list_data["factions"] += list(list(
"content" = "[counted_factions[i]]: [counted_factions[counted_factions[i]]]",
"color" = "#2C7EFF",
"text" = "Other",
))
if(counted_factions[FACTION_NEUTRAL])
new_list_data["factions"] += list(list(
"content" = "[FACTION_NEUTRAL] Humans: [counted_factions[FACTION_NEUTRAL]]",
"color" = "#688944",
"text" = "Neutrals",
))

for(var/faction_to_get in ALL_XENO_HIVES)
var/datum/hive_status/hive = GLOB.hive_datum[faction_to_get]
if(hive && length(hive.totalXenos))
new_list_data["xenomorphs"] += list(list(
"content" = "[hive.name]: [length(hive.totalXenos)]",
"color" = hive.color ? hive.color : "#8200FF",
"text" = "Queen: [hive.living_xeno_queen ? "Alive" : "Dead"]",
))

list_data = new_list_data
mobs_ckey = new_mobs_ckey

/datum/player_list/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, tgui_name, tgui_interface_name)
ui.open()
ui.set_autoupdate(TRUE)

/datum/player_list/ui_data(mob/user)
. = list_data

/datum/player_list/ui_static_data(mob/user)
. = list()

.["admin"] = CLIENT_IS_STAFF(user.client)

/datum/player_list/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return

switch(action)
if("get_player_panel")
if(mobs_ckey[params["ckey"]])
GLOB.admin_datums[usr.client.ckey].show_player_panel(mobs_ckey[params["ckey"]])

/datum/player_list/ui_status(mob/user, datum/ui_state/state)
return UI_INTERACTIVE


/datum/player_list/staff
tgui_name = "StaffWho"
tgui_interface_name = "Staff Who"

var/list/category_colors = list(
"Management" = "purple",
"Maintainers" = "blue",
"Administrators" = "red",
"Moderators" = "orange",
"Mentors" = "green"
)

/datum/player_list/staff/update_data()
var/list/new_list_data = list()
mobs_ckey = list()

var/list/listings
var/list/mappings
if(CONFIG_GET(flag/show_manager))
LAZYSET(mappings, "Management", R_PERMISSIONS)
if(CONFIG_GET(flag/show_devs))
LAZYSET(mappings, "Maintainers", R_PROFILER)
LAZYSET(mappings, "Administrators", R_ADMIN)
if(CONFIG_GET(flag/show_mods))
LAZYSET(mappings, "Moderators", R_MOD && R_BAN)
if(CONFIG_GET(flag/show_mentors))
LAZYSET(mappings, "Mentors", R_MENTOR)

for(var/category in mappings)
LAZYSET(listings, category, list())

for(var/client/client as anything in GLOB.admins)
if(client.admin_holder?.fakekey && !CLIENT_IS_STAFF(client))
continue

for(var/category in mappings)
if(CLIENT_HAS_RIGHTS(client, mappings[category]))
LAZYADD(listings[category], client)
break

for(var/category in listings)
var/list/admins = list()
for(var/client/entry as anything in listings[category])
var/list/admin = list()
var/rank = entry.admin_holder.rank
if(entry.admin_holder.extra_titles?.len)
for(var/srank in entry.admin_holder.extra_titles)
rank += " & [srank]"

admin["content"] = "[entry.key] ([rank])"
admin["text"] = ""

if(entry.admin_holder?.fakekey)
admin["text"] += " (HIDDEN)"

if(istype(entry.mob, /mob/dead/observer))
admin["color"] = "#808080"
admin["text"] += " Spectating"

else if(istype(entry.mob, /mob/new_player))
admin["color"] = "#688944"
admin["text"] += " in Lobby"
else
admin["color"] = "#688944"
admin["text"] += " Playing"

if(entry.is_afk())
admin["color"] = "#A040D0"
admin["text"] += " (AFK)"

admins += list(admin)

new_list_data["administrators"] += list(list(
"category" = category,
"category_color" = category_colors[category],
"category_administrators" = length(listings[category]),
"admins" = admins,
))

list_data = new_list_data

/mob/verb/who()
set category = "OOC"
set name = "Who"

SSwho.who.tgui_interact(src)

/mob/verb/staffwho()
set category = "Admin"
set name = "StaffWho"

SSwho.staff_who.tgui_interact(src)
Loading

0 comments on commit f69b5c5

Please sign in to comment.