mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Separates the 'count and assess everything' stuff to it's own datum, called the metric datum, which I plan to add on to in the future to make counting and metrics easier. Makes decision process a bit more weight-based, will probably continue tweaking later. Makes the admin debug UI have links to change settings easily. Adds replacement for grid check event, which works similar to the old one, but is now based on a physical machine in the game world, that Engineering can hack to make the event end faster, if so desired. Note that the machine is not mapped in, and won't be mapped in until the event system is ready for launch. Adds grid_check variables to SMESes and APCs to make them stop doing work without draining the battery. Grid checks in the new system are caused by a "power spike" which originates from the engine and will cause bad things, should no grid checker machine be connected to the power-net. These power spikes occur when the GM decides that a grid check is a good event to have. The grid checker can be built and deconstructed using the standard machine construction methods.
72 lines
2.3 KiB
Plaintext
72 lines
2.3 KiB
Plaintext
|
|
// This proc tries to find the department of an arbitrary mob.
|
|
/datum/metric/proc/guess_department(var/mob/M)
|
|
var/list/found_roles = list()
|
|
. = ROLE_UNKNOWN
|
|
|
|
// Records are usually the most reliable way to get what job someone is.
|
|
var/datum/data/record/R = find_general_record("name", M.real_name)
|
|
if(R) // We found someone with a record.
|
|
var/recorded_rank = R.fields["real_rank"]
|
|
found_roles = role_name_to_department(recorded_rank)
|
|
. = found_roles[1]
|
|
if(. != ROLE_UNKNOWN) // We found the correct department, so we can stop now.
|
|
return
|
|
|
|
// They have a custom title, aren't crew, or someone deleted their record, so we need a fallback method.
|
|
// Let's check the mind.
|
|
if(M.mind)
|
|
found_roles = role_name_to_department(M.mind.assigned_role)
|
|
. = found_roles[1]
|
|
if(. != ROLE_UNKNOWN)
|
|
return
|
|
|
|
// At this point, they don't have a mind, or for some reason assigned_role didn't work.
|
|
found_roles = role_name_to_department(M.job)
|
|
. = found_roles[1]
|
|
if(. != ROLE_UNKNOWN)
|
|
return
|
|
|
|
return ROLE_UNKNOWN // Welp.
|
|
|
|
// Feed this proc the name of a job, and it will try to figure out what department they are apart of.
|
|
// Note that this returns a list, as some jobs are in more than one department, like Command. The 'primary' department is the first
|
|
// in the list, e.g. a HoS has Security as first, Command as second in the returned list.
|
|
/datum/metric/proc/role_name_to_department(var/role_name)
|
|
var/list/result = list()
|
|
|
|
if(role_name in security_positions)
|
|
result += ROLE_SECURITY
|
|
|
|
if(role_name in engineering_positions)
|
|
result += ROLE_ENGINEERING
|
|
|
|
if(role_name in medical_positions)
|
|
result += ROLE_MEDICAL
|
|
|
|
if(role_name in science_positions)
|
|
result += ROLE_RESEARCH
|
|
|
|
if(role_name in cargo_positions)
|
|
result += ROLE_CARGO
|
|
|
|
if(role_name in civilian_positions)
|
|
result += ROLE_CIVILIAN
|
|
|
|
if(role_name in nonhuman_positions)
|
|
result += ROLE_SYNTHETIC
|
|
|
|
if(role_name in command_positions) // We do Command last, since we consider command to only be a primary department for hop/admin.
|
|
result += ROLE_COMMAND
|
|
|
|
if(!result.len) // No department was found.
|
|
result += ROLE_UNKNOWN
|
|
return result
|
|
|
|
/datum/metric/proc/count_people_in_department(var/department)
|
|
if(!department)
|
|
return
|
|
for(var/mob/M in player_list)
|
|
if(guess_department(M) != department) // Ignore people outside the department we're counting.
|
|
continue
|
|
. += 1 |