Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes for Loadout Items #4849

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__DEFINES/dcs/signals/atom/signals_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
/// from /obj/item/weapon/gun/proc/load_into_chamber() : ()
#define COMSIG_GUN_INTERRUPT_FIRE "gun_interrupt_fire"

//Additional procs on items that will be triggered right after the human finishes spawns in
//from /datum/authority/branch/role/proc/equip_role()
#define COMSIG_POST_SPAWN_UPDATE "post_spawn_update"
4 changes: 1 addition & 3 deletions code/game/jobs/role_authority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
new_human.sec_hud_set_ID()
new_human.hud_set_squad()

for(var/obj/current_item in new_human.get_contents())
SEND_SIGNAL(current_item, COMSIG_POST_SPAWN_UPDATE, new_human)

SEND_SIGNAL(new_human, COMSIG_POST_SPAWN_UPDATE)
SSround_recording.recorder.track_player(new_human)

//Find which squad has the least population. If all 4 squads are equal it should just use a random one
Expand Down
29 changes: 19 additions & 10 deletions code/game/objects/items/props/helmetgarb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -527,29 +527,38 @@
icon = 'icons/obj/items/items.dmi'
icon_state = "photo"
///The human who spawns with the photo
var/mob/living/carbon/human/owner
var/datum/weakref/owner
///The belonging human name
var/owner_name
///The belonging human faction
var/owner_faction
///Text written on the back
var/scribble

/obj/item/prop/helmetgarb/family_photo/Initialize(mapload, ...)
/obj/item/prop/helmetgarb/family_photo/pickup(mob/user, silent)
. = ..()
if(!mapload)
RegisterSignal(src, COMSIG_POST_SPAWN_UPDATE, PROC_REF(set_owner))
if(!owner)
RegisterSignal(user, COMSIG_POST_SPAWN_UPDATE, PROC_REF(set_owner))


///Sets the owner of the family photo to the human it spawns with, needs var/source for signals
/obj/item/prop/helmetgarb/family_photo/proc/set_owner(source = src, mob/living/carbon/human/user)
UnregisterSignal(src, COMSIG_POST_SPAWN_UPDATE)
owner = user
/obj/item/prop/helmetgarb/family_photo/proc/set_owner(datum/source)
SIGNAL_HANDLER
UnregisterSignal(source, COMSIG_POST_SPAWN_UPDATE)
var/mob/living/carbon/human/user = source
owner = WEAKREF(user)
owner_name = user.name
owner_faction = user.faction

/obj/item/prop/helmetgarb/family_photo/get_examine_text(mob/user)
. = ..()
if(scribble)
. += "\"[scribble]\" is written on the back of the photo."
if(user == owner)
if(user.weak_reference == owner)
. += "A photo of you and your family."
return
if(user.faction == owner?.faction)
. += "A photo of [owner] and their family."
if(user.faction == owner_faction)
. += "A photo of [owner_name] and their family."
return
. += "A photo of a family you do not know."

Expand Down
19 changes: 11 additions & 8 deletions code/game/objects/items/tools/misc_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,24 @@
matter = list("metal" = 20, "gold" = 10)
var/static/list/colour_list = list("red", "blue", "green", "yellow", "purple", "pink", "brown", "black", "orange") // Can add more colors as required
var/current_colour_index = 1
var/owner = "hard to read text"
var/owner_name

/obj/item/tool/pen/fountain/Initialize(mapload, ...)
/obj/item/tool/pen/fountain/pickup(mob/user, silent)
. = ..()
if(!mapload)
RegisterSignal(src, COMSIG_POST_SPAWN_UPDATE, PROC_REF(set_owner))
if(!owner_name)
RegisterSignal(user, COMSIG_POST_SPAWN_UPDATE, PROC_REF(set_owner))

///Sets the owner of the pen to who it spawns with, requires var/source for signals
/obj/item/tool/pen/fountain/proc/set_owner(source = src, mob/living/carbon/human/user)
UnregisterSignal(src, COMSIG_POST_SPAWN_UPDATE)
owner = user
/obj/item/tool/pen/fountain/proc/set_owner(datum/source)
SIGNAL_HANDLER
UnregisterSignal(source, COMSIG_POST_SPAWN_UPDATE)
var/mob/living/carbon/human/user = source
owner_name = user.name

/obj/item/tool/pen/fountain/get_examine_text(mob/user)
. = ..()
. += "There's a laser engraving of [owner] on it."
if(owner_name)
. += "There's a laser engraving of [owner_name] on it."

/obj/item/tool/pen/fountain/attack_self(mob/living/carbon/human/user)
if(on)
Expand Down
26 changes: 18 additions & 8 deletions code/game/objects/items/toys/toys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,15 @@
///Hexadecimal 0-F (0-15)
var/static/list/hexadecimal = list("0", "1", "2", "3" , "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")

/obj/item/toy/plush/therapy/random_color/New(loc, ...)
/obj/item/toy/plush/therapy/random_color/Initialize(mapload, ...)
. = ..()
var/color_code = "#[pick(hexadecimal)][pick(hexadecimal)][pick(hexadecimal)][pick(hexadecimal)][pick(hexadecimal)][pick(hexadecimal)]" //This is dumb and I hope theres a better way I'm missing
color = color_code
desc = "A custom therapy plush, in a unique color. This one is labeled with \"#[color_code]\"."
desc = "A custom therapy plush, in a unique color."

/obj/item/toy/plush/random_plushie //Not using an effect so it can fit into storage from loadout
name = "random plush"
desc = "You should not be seeing this"
desc = "This plush looks awfully standard and bland. Is it actually yours?"
/// Standard plushies for the spawner to pick from
var/list/plush_list = list(
/obj/item/toy/plush/farwa,
Expand All @@ -587,22 +587,32 @@
. = ..()
if(mapload) //Placed in mapping, will be randomized instantly on spawn
create_plushie()
return
RegisterSignal(src, COMSIG_POST_SPAWN_UPDATE, PROC_REF(create_plushie))
return INITIALIZE_HINT_QDEL

/obj/item/toy/plush/random_plushie/pickup(mob/user, silent)
. = ..()
RegisterSignal(user, COMSIG_POST_SPAWN_UPDATE, PROC_REF(create_plushie))

///The randomizer picking and spawning a plushie on either the ground or in the humans backpack. Needs var/source due to signals
/obj/item/toy/plush/random_plushie/proc/create_plushie(source = src, mob/living/user)
UnregisterSignal(src, COMSIG_POST_SPAWN_UPDATE)
/obj/item/toy/plush/random_plushie/proc/create_plushie(datum/source)
SIGNAL_HANDLER
if(source)
UnregisterSignal(source, COMSIG_POST_SPAWN_UPDATE)
var/turf/spawn_location = get_turf(src)
var/plush_list_variety = pick(60; plush_list, 40; therapy_plush_list)
var/random_plushie = pick(plush_list_variety)
var/obj/item/toy/plush/plush = new random_plushie(get_turf(src)) //Starts on floor by default
var/obj/item/toy/plush/plush = new random_plushie(spawn_location) //Starts on floor by default
var/mob/living/carbon/human/user = source

if(!user) //If it didn't spawn on a humanoid
qdel(src)
return

var/obj/item/storage/backpack/storage = locate() in user //If the user has a backpack, put it there
if(storage?.can_be_inserted(plush, user, stop_messages = TRUE))
storage.attempt_item_insertion(plush, TRUE, user)
if(plush.loc == spawn_location) // Still on the ground
user.put_in_hands(plush, drop_on_fail = TRUE)
qdel(src)

//Admin plushies
Expand Down