From 9009e3a861352f7cf75b1b7718cfe58d8fc54b17 Mon Sep 17 00:00:00 2001 From: warriorstar-orion Date: Thu, 21 Nov 2024 00:05:03 -0500 Subject: [PATCH] refactor: /New -> /Initialize: simple animals (#27265) --- .../simple_animal/friendly/butterfly.dm | 4 +- .../mob/living/simple_animal/friendly/cat.dm | 4 +- .../simple_animal/friendly/diona_nymph.dm | 5 +- .../simple_animal/friendly/farm_animals.dm | 10 ++-- .../living/simple_animal/friendly/mouse.dm | 9 +-- .../mob/living/simple_animal/parrot.dm | 55 +++++++++++-------- .../living/simple_animal/posessed_object.dm | 4 +- 7 files changed, 52 insertions(+), 39 deletions(-) diff --git a/code/modules/mob/living/simple_animal/friendly/butterfly.dm b/code/modules/mob/living/simple_animal/friendly/butterfly.dm index e928fd850a83..70268a03723f 100644 --- a/code/modules/mob/living/simple_animal/friendly/butterfly.dm +++ b/code/modules/mob/living/simple_animal/friendly/butterfly.dm @@ -24,8 +24,8 @@ gold_core_spawnable = FRIENDLY_SPAWN initial_traits = list(TRAIT_FLYING, TRAIT_EDIBLE_BUG) -/mob/living/simple_animal/butterfly/New() - ..() +/mob/living/simple_animal/butterfly/Initialize(mapload) + . = ..() color = rgb(rand(0, 255), rand(0, 255), rand(0, 255)) /mob/living/simple_animal/butterfly/npc_safe(mob/user) diff --git a/code/modules/mob/living/simple_animal/friendly/cat.dm b/code/modules/mob/living/simple_animal/friendly/cat.dm index b716622e685a..0a36ef2f09b7 100644 --- a/code/modules/mob/living/simple_animal/friendly/cat.dm +++ b/code/modules/mob/living/simple_animal/friendly/cat.dm @@ -42,9 +42,9 @@ var/list/family = list() var/list/children = list() //Actual mob instances of children -/mob/living/simple_animal/pet/cat/Runtime/New() +/mob/living/simple_animal/pet/cat/Runtime/Initialize(mapload) + . = ..() SSpersistent_data.register(src) - ..() /mob/living/simple_animal/pet/cat/Runtime/Destroy() SSpersistent_data.registered_atoms -= src diff --git a/code/modules/mob/living/simple_animal/friendly/diona_nymph.dm b/code/modules/mob/living/simple_animal/friendly/diona_nymph.dm index 77c8b8aeb0ac..2043aa8e15d0 100644 --- a/code/modules/mob/living/simple_animal/friendly/diona_nymph.dm +++ b/code/modules/mob/living/simple_animal/friendly/diona_nymph.dm @@ -81,8 +81,9 @@ var/mob/living/simple_animal/diona/user = owner user.steal_blood() -/mob/living/simple_animal/diona/New() - ..() +/mob/living/simple_animal/diona/Initialize(mapload) + . = ..() + if(name == initial(name)) //To stop Pun-Pun becoming generic. name = "[name] ([rand(1, 1000)])" real_name = name diff --git a/code/modules/mob/living/simple_animal/friendly/farm_animals.dm b/code/modules/mob/living/simple_animal/friendly/farm_animals.dm index 04f71eb69595..32aace078b5a 100644 --- a/code/modules/mob/living/simple_animal/friendly/farm_animals.dm +++ b/code/modules/mob/living/simple_animal/friendly/farm_animals.dm @@ -221,8 +221,9 @@ gold_core_spawnable = FRIENDLY_SPAWN footstep_type = FOOTSTEP_MOB_CLAW -/mob/living/simple_animal/chick/New() - ..() +/mob/living/simple_animal/chick/Initialize(mapload) + . = ..() + pixel_x = rand(-6, 6) pixel_y = rand(0, 10) @@ -294,8 +295,8 @@ GLOBAL_VAR_INIT(chicken_count, 0) gold_core_spawnable = FRIENDLY_SPAWN footstep_type = FOOTSTEP_MOB_CLAW -/mob/living/simple_animal/chicken/New() - ..() +/mob/living/simple_animal/chicken/Initialize(mapload) + . = ..() if(!body_color) body_color = pick(validColors) icon_state = "[icon_prefix]_[body_color]" @@ -303,6 +304,7 @@ GLOBAL_VAR_INIT(chicken_count, 0) icon_dead = "[icon_prefix]_[body_color]_dead" pixel_x = rand(-6, 6) pixel_y = rand(0, 10) + update_appearance(UPDATE_ICON_STATE) GLOB.chicken_count += 1 /mob/living/simple_animal/chicken/death(gibbed) diff --git a/code/modules/mob/living/simple_animal/friendly/mouse.dm b/code/modules/mob/living/simple_animal/friendly/mouse.dm index 73232630370d..ed87da7cc89e 100644 --- a/code/modules/mob/living/simple_animal/friendly/mouse.dm +++ b/code/modules/mob/living/simple_animal/friendly/mouse.dm @@ -75,15 +75,16 @@ else if(prob(0.5)) lay_down() -/mob/living/simple_animal/mouse/New() - ..() +/mob/living/simple_animal/mouse/Initialize(mapload) + . = ..() + if(!mouse_color) - mouse_color = pick( list("brown","gray","white") ) + mouse_color = pick("brown", "gray", "white") icon_state = "mouse_[mouse_color]" icon_living = "mouse_[mouse_color]" icon_dead = "mouse_[mouse_color]_dead" icon_resting = "mouse_[mouse_color]_sleep" - update_appearance(UPDATE_DESC) + update_appearance(UPDATE_ICON_STATE|UPDATE_DESC) /mob/living/simple_animal/mouse/update_desc() . = ..() diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index 4968aabfb456..034401c0e127 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -67,8 +67,8 @@ var/parrot_speed = 5 //"Delay in world ticks between movement." according to byond. Yeah, that's BS but it does directly affect movement. Higher number = slower. var/parrot_been_shot = 0 //Parrots get a speed bonus after being shot. This will deincrement every process_ai() and at 0 the parrot will return to regular speed. - var/list/speech_buffer - var/list/available_channels + var/list/speech_buffer = list() + var/list/available_channels = list() //Headset for Poly to yell at engineers :) var/obj/item/radio/headset/ears = null @@ -80,35 +80,43 @@ //Parrots will generally sit on their pertch unless something catches their eye. //These vars store their preffered perch and if they dont have one, what they can use as a perch var/obj/parrot_perch = null - var/obj/desired_perches = null + var/list/desired_perches //Parrots are kleptomaniacs. This variable ... stores the item a parrot is holding. var/obj/item/held_item = null initial_traits = list(TRAIT_FLYING) gold_core_spawnable = FRIENDLY_SPAWN -/mob/living/simple_animal/parrot/New() - ..() - speech_buffer = list() - available_channels = list() +/mob/living/simple_animal/parrot/Initialize(mapload) + . = ..() + GLOB.hear_radio_list += src update_speak() parrot_sleep_dur = parrot_sleep_max //In case someone decides to change the max without changing the duration var - verbs.Add(/mob/living/simple_animal/parrot/proc/steal_from_ground, \ - /mob/living/simple_animal/parrot/proc/steal_from_mob, \ - /mob/living/simple_animal/parrot/verb/drop_held_item_player, \ - /mob/living/simple_animal/parrot/proc/perch_player) - - desired_perches = typecacheof(list(/obj/structure/computerframe, /obj/structure/displaycase, \ - /obj/structure/filingcabinet, /obj/machinery/teleport, \ - /obj/machinery/suit_storage_unit,/obj/machinery/clonepod, \ - /obj/machinery/dna_scannernew, /obj/machinery/tcomms, \ - /obj/machinery/nuclearbomb, /obj/machinery/particle_accelerator, \ - /obj/machinery/recharge_station, /obj/machinery/smartfridge, \ - /obj/machinery/computer)) - + verbs.Add(list( + /mob/living/simple_animal/parrot/proc/steal_from_ground, + /mob/living/simple_animal/parrot/proc/steal_from_mob, + /mob/living/simple_animal/parrot/verb/drop_held_item_player, + /mob/living/simple_animal/parrot/proc/perch_player + )) + + desired_perches = typecacheof(list( + /obj/machinery/clonepod, + /obj/machinery/computer, + /obj/machinery/dna_scannernew, + /obj/machinery/nuclearbomb, + /obj/machinery/particle_accelerator, + /obj/machinery/recharge_station, + /obj/machinery/smartfridge, + /obj/machinery/suit_storage_unit, + /obj/machinery/tcomms, + /obj/machinery/teleport, + /obj/structure/computerframe, + /obj/structure/displaycase, + /obj/structure/filingcabinet + )) /mob/living/simple_animal/parrot/add_strippable_element() AddElement(/datum/element/strippable, GLOB.strippable_parrot_items) @@ -669,12 +677,13 @@ ) unique_pet = TRUE gold_core_spawnable = NO_SPAWN + available_channels = list(":e") + +/mob/living/simple_animal/parrot/Poly/Initialize(mapload) + . = ..() -/mob/living/simple_animal/parrot/Poly/New() ears = new /obj/item/radio/headset/headset_eng(src) - available_channels = list(":e") clean_speak += "Danger! Crystal hyperstructure integrity faltering! Integrity: [rand(75, 99)]%" // Has to be here cause of the `rand()`. - ..() /mob/living/simple_animal/parrot/Poly/npc_safe(mob/user) // Hello yes, I have universal speak and I follow people around and shout out antags return FALSE diff --git a/code/modules/mob/living/simple_animal/posessed_object.dm b/code/modules/mob/living/simple_animal/posessed_object.dm index c437c30957e9..7505d6ec02e2 100644 --- a/code/modules/mob/living/simple_animal/posessed_object.dm +++ b/code/modules/mob/living/simple_animal/posessed_object.dm @@ -91,8 +91,8 @@ to_chat(src, "Your spirit has entered [src] and possessed it.
You are able to do most things a humanoid would be able to do with a [src] in their hands.
If you want to end your ghostly possession, use the 'ghost' verb, it won't penalize your ability to respawn.
") -/mob/living/simple_animal/possessed_object/New(atom/loc as obj) - ..() +/mob/living/simple_animal/possessed_object/Initialize(mapload) + . = ..() if(!isitem(loc)) // Some silly motherfucker spawned us directly via the game panel. message_admins("Possessed object improperly spawned, deleting.") // So silly admins with debug off will see the message too and not spam these things.