Converts jobs and admin equipment to use outfits (#5827)

Converts the jobs and admin equipment to use outfit datums.
This commit is contained in:
Werner
2019-02-19 23:58:05 +02:00
committed by Erki
parent 1bc27306a0
commit b823b4eb05
38 changed files with 1802 additions and 1447 deletions
+7
View File
@@ -85,3 +85,10 @@
* Parameters: var/obj/structure/closet/crate/sold, var/area/shuttle
*/
/hook/sell_crate
/**
* Captain spawned.
* Called whenever a captain is spawned.
* Parameters: var/mob/living/carbon/human
*/
/hook/captain_spawned
+29 -74
View File
@@ -14,6 +14,8 @@
// Vars.
var/list/occupations = list()
var/list/name_occupations = list() //Dict of all jobs, keys are titles
var/list/type_occupations = list() //Dict of all jobs, keys are titles
var/list/unassigned = list()
var/list/job_debug = list()
@@ -43,7 +45,11 @@
var/datum/job/job = new J()
if(!job || job.faction != faction)
continue
if(!job.faction in faction)
continue
occupations += job
name_occupations[job.title] = job
type_occupations[J] = job
if (config && config.use_age_restriction_for_jobs)
job.fetch_age_restriction()
@@ -53,13 +59,16 @@
if (!rank)
return null
for (var/thing in occupations)
var/datum/job/J = thing
if (!J)
continue
return name_occupations[rank]
if (J.title == rank)
return J
/datum/controller/subsystem/jobs/proc/GetJobType(jobtype)
if(!jobtype)
return null
return type_occupations[jobtype]
/datum/controller/subsystem/jobs/proc/GetRandomJob()
return pick(occupations)
/datum/controller/subsystem/jobs/proc/ShouldCreateRecords(var/rank)
if(!rank) return 0
@@ -315,22 +324,20 @@
var/datum/job/job = GetJob(rank)
var/list/spawn_in_storage = list()
H.job = rank
if(job)
var/list/custom_equip_slots = list() //If more than one item takes the same slot, all after the first one spawn in storage.
var/list/custom_equip_leftovers = list()
//Equip job items.
if(!megavend) //Equip custom gear loadout.
Debug("ER/([H]): Equipping custom loadout.")
job.equip_backpack(H)
job.pre_equip(H)
job.setup_account(H)
EquipCustom(H, job, H.client.prefs, custom_equip_leftovers, spawn_in_storage, custom_equip_slots)
// This goes after custom loadout it doesn't prevent custom loadout stuff from being equipped.
job.equip_survival(H)
job.equip(H)
job.apply_fingerprints(H)
// Randomize nutrition and hydration. Defines are in __defines/mobs.dm
@@ -343,9 +350,7 @@
if (!megavend)
spawn_in_storage += EquipCustomDeferred(H, H.client.prefs, custom_equip_leftovers, custom_equip_slots)
else
H << "Your job is [rank] and the game just can't handle it! Please report this bug to an administrator."
H.job = rank
to_chat(H,"Your job is [rank] and the game just can't handle it! Please report this bug to an administrator.")
if(!joined_late || job.latejoin_at_spawnpoints)
var/obj/S = get_roundstart_spawnpoint(rank)
@@ -384,9 +389,6 @@
if("AI")
Debug("ER/([H]): Job is AI, returning early.")
return H
if("Captain")
var/sound/announce_sound = (SSticker.current_state <= GAME_STATE_SETTING_UP)? null : sound('sound/misc/boatswain.ogg', volume=20)
captain_announcement.Announce("All hands, Captain [H.real_name] on deck!", new_sound=announce_sound)
//Deferred item spawning.
if(!megavend && LAZYLEN(spawn_in_storage))
@@ -408,11 +410,6 @@
if(job.supervisors)
H << "<b>As the [alt_title ? alt_title : rank] you answer directly to [job.supervisors]. Special circumstances may change this.</b>"
if(job.idtype)
spawnId(H, rank, alt_title)
H.equip_to_slot_or_del(new /obj/item/device/radio/headset(H), slot_l_ear)
H << "<b>To speak on your department's radio channel use :h. For the use of other channels, examine your headset.</b>"
if(job.req_admin_notify)
H << "<b>You are playing a job that is important for Game Progression. If you have to disconnect, please notify the admins via adminhelp.</b>"
@@ -512,11 +509,13 @@
var/datum/job/job = GetJob(rank)
H.job = rank
if(spawning_at != "Arrivals Shuttle" || job.latejoin_at_spawnpoints)
return EquipRank(H, rank, 1)
var/list/spawn_in_storage = list()
H <<"<span class='notice'>You have ten minutes to reach the station before you will be forced there.</span>"
to_chat(H,"<span class='notice'>You have ten minutes to reach the station before you will be forced there.</span>")
if(job)
//Equip custom gear loadout.
@@ -525,19 +524,16 @@
EquipCustom(H, job, H.client.prefs, custom_equip_leftovers, spawn_in_storage, custom_equip_slots)
Debug("EP/([H]): EC Complated, running pre_equip and late_equip.")
//Equip job items.
job.pre_equip(H) // Spawn in the backpack
job.late_equip(H)
job.equip_backpack(H)
job.equip_survival(H)
job.setup_account(H)
spawn_in_storage += EquipCustomDeferred(H, H.client.prefs, custom_equip_leftovers, custom_equip_slots)
job.apply_fingerprints(H)
else
H << "Your job is [rank] and the game just can't handle it! Please report this bug to an administrator."
H.job = rank
to_chat(H,"Your job is [rank] and the game just can't handle it! Please report this bug to an administrator.")
if(LAZYLEN(spawn_in_storage))
EquipItemsStorage(H, H.client.prefs, spawn_in_storage)
@@ -574,47 +570,6 @@
return H
/datum/controller/subsystem/jobs/proc/spawnId(mob/living/carbon/human/H, rank, title)
if (!H)
return FALSE
Debug("SI/([H]): Entry; rank=[rank],title=[title].")
var/obj/item/weapon/card/id/C = null
var/datum/job/job = GetJob(rank)
if(job)
if(job.title == "Cyborg")
Debug("SI/([H]): Abort; job is cyborg.")
return
else
C = new job.idtype(H)
C.access = job.get_access(title)
else
C = new /obj/item/weapon/card/id(H)
if(C)
C.rank = rank
C.assignment = title ? title : rank
addtimer(CALLBACK(H, /mob/.proc/set_id_info, C), 1 SECOND) // Delay a moment to allow an icon update to happen.
//put the player's account number onto the ID
if(H.mind && H.mind.initial_account)
C.associated_account_number = H.mind.initial_account.account_number
H.equip_to_slot_or_del(C, slot_wear_id)
H.equip_to_slot_or_del(new /obj/item/device/pda(H), slot_belt)
if(locate(/obj/item/device/pda,H))
var/obj/item/device/pda/pda = locate(/obj/item/device/pda,H)
pda.owner = H.real_name
pda.ownjob = C.assignment
pda.ownrank = C.rank
pda.name = "PDA-[H.real_name] ([pda.ownjob])"
Debug("SI/([H]): Completed.")
return TRUE
/datum/controller/subsystem/jobs/proc/LoadJobs(jobsfile)
if (!config.load_jobs_from_txt)
return FALSE
@@ -792,14 +747,14 @@
// This is a miserable way to fix the loadout overwrite bug, but the alternative requires
// adding an arg to a bunch of different procs. Will look into it after this merge. ~ Z
var/metadata = prefs.gear[G.display_name]
var/obj/item/CI = G.spawn_item(H,metadata)
var/obj/item/CI = G.spawn_item(null,metadata)
if (G.slot == slot_wear_mask || G.slot == slot_wear_suit || G.slot == slot_head)
if (leftovers)
leftovers += thing
Debug("EC/([H]): [thing] failed mask/suit/head check; leftovers=[!!leftovers]")
else if (H.equip_to_slot_or_del(CI, G.slot))
CI.autodrobe_no_remove = TRUE
H << "<span class='notice'>Equipping you with \a [thing]!</span>"
to_chat(H, "<span class='notice'>Equipping you with [thing]!</span>")
custom_equip_slots += G.slot
Debug("EC/([H]): Equipped [CI] successfully.")
else if (leftovers)
@@ -827,7 +782,7 @@
var/metadata = prefs.gear[G.display_name]
var/obj/item/CI = G.spawn_item(H, metadata)
if (H.equip_to_slot_or_del(CI, G.slot))
to_chat(H, "<span class='notice'>Equipping you with \a [thing]!</span>")
to_chat(H, "<span class='notice'>Equipping you with [thing]!</span>")
used_slots += G.slot
CI.autodrobe_no_remove = TRUE
Debug("ECD/([H]): Equipped [thing] successfully.")