Refactored archeological finds to use Initialize() instead of New() where possible (#18964)

Refactored archeological finds to use Initialize() instead of New()
where possible
This commit is contained in:
Fluffy
2024-04-18 23:35:07 +00:00
committed by GitHub
parent 08945fb517
commit f9e8a7cd69
4 changed files with 86 additions and 17 deletions
+2 -2
View File
@@ -426,9 +426,9 @@ var/list/mineral_can_smooth_with = list(
//otherwise, they come out inside a chunk of rock
var/obj/item/X
if(prob_clean)
X = new /obj/item/archaeological_find(src, new_item_type = F.find_type)
X = new /obj/item/archaeological_find(src, F.find_type)
else
var/obj/item/ore/strangerock/SR = new /obj/item/ore/strangerock(src, inside_item_type = F.find_type)
var/obj/item/ore/strangerock/SR = new /obj/item/ore/strangerock(src, F.find_type)
SR.geologic_data = get_geodata()
X = SR
@@ -32,12 +32,12 @@
var/method = 0// 0 = fire, 1 = brush, 2 = pick
origin_tech = list(TECH_MATERIAL = 5)
/obj/item/ore/strangerock/New(loc, var/inside_item_type = 0)
..(loc)
/obj/item/ore/strangerock/Initialize(mapload, inside_item_type)
. = ..()
//method = rand(0,2)
if(inside_item_type)
inside = new/obj/item/archaeological_find(src, new_item_type = inside_item_type)
inside = new/obj/item/archaeological_find(src, inside_item_type)
if(!inside)
inside = locate() in contents
@@ -84,7 +84,9 @@
icon_state = "ano01"
var/find_type = 0
/obj/item/archaeological_find/New(loc, var/new_item_type)
/obj/item/archaeological_find/Initialize(mapload, new_item_type)
. = ..()
if(new_item_type)
find_type = new_item_type
else
@@ -409,7 +411,7 @@
apply_image_decorations = 0
if(29)
//fossil bone/skull
//new_item = new /obj/item/fossil/base(src.loc)
new_item = new /obj/item/fossil/base(src.loc)
//the replacement item propogation isn't working, and it's messy code anyway so just do it here
var/list/candidates = list("/obj/item/fossil/bone"=9,"/obj/item/fossil/skull"=3,
@@ -553,7 +555,7 @@
if(talkative)
new_item.talking_atom = new(new_item)
QDEL_IN(src, 1 SECOND)
return INITIALIZE_HINT_QDEL
else if(talkative)
src.talking_atom = new(src)
@@ -9,21 +9,24 @@
desc = "It's a fossil."
var/animal = 1
/obj/item/fossil/base/New()
/obj/item/fossil/base/Initialize(mapload, ...)
. = ..()
var/list/l = list("/obj/item/fossil/bone"=9,"/obj/item/fossil/skull"=3,
"/obj/item/fossil/skull/horned"=2)
var/t = pickweight(l)
var/obj/item/W = new t(src.loc)
var/turf/T = get_turf(src)
if(istype(T, /turf/simulated/mineral))
T:last_find = W
qdel(src)
var/turf/simulated/mineral/the_mineral_turf = T
the_mineral_turf.last_find = W
return INITIALIZE_HINT_QDEL
/obj/item/fossil/bone
name = "fossilised bone"
desc = "It's a fossilised bone."
/obj/item/fossil/bone/New()
/obj/item/fossil/bone/Initialize(mapload, ...)
. = ..()
icon_state = "bone[rand(1, 3)]"
/obj/item/fossil/skull
@@ -31,14 +34,16 @@
icon_state = "skull"
desc = "It's a foss1ilised skull."
/obj/item/fossil/skull/New()
/obj/item/fossil/skull/Initialize(mapload, ...)
. = ..()
icon_state = "skull[rand(1, 3)]"
/obj/item/fossil/skull/horned
icon_state = "horned_skull1"
desc = "It's a fossilised, horned skull."
/obj/item/fossil/skull/horned/New()
/obj/item/fossil/skull/horned/Initialize(mapload, ...)
. = ..()
icon_state = "horned_skull[rand(1, 2)]"
/obj/item/fossil/skull/attackby(obj/item/attacking_item, mob/user)
@@ -61,7 +66,9 @@
var/bstate = 0
var/plaque_contents = "Unnamed alien creature"
/obj/skeleton/New()
/obj/skeleton/Initialize(mapload, ...)
. = ..()
src.breq = rand(3)+3
src.desc = "An incomplete skeleton, looks like it could use [src.breq-src.bnum] more bones."
@@ -102,7 +109,8 @@
icon_state = "shell"
desc = "It's a fossilised shell."
/obj/item/fossil/shell/New()
/obj/item/fossil/shell/Initialize(mapload, ...)
. = ..()
icon_state = "shell[rand(1, 2)]"
/obj/item/fossil/plant
@@ -111,5 +119,6 @@
desc = "It's fossilised plant remains."
animal = 0
/obj/item/fossil/plant/New()
/obj/item/fossil/plant/Initialize(mapload, ...)
. = ..()
icon_state = "plant[rand(1,4)]"
+58
View File
@@ -0,0 +1,58 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# - (fixes bugs)
# wip
# - (work in progress)
# qol
# - (quality of life)
# soundadd
# - (adds a sound)
# sounddel
# - (removes a sound)
# rscadd
# - (adds a feature)
# rscdel
# - (removes a feature)
# imageadd
# - (adds an image or sprite)
# imagedel
# - (removes an image or sprite)
# spellcheck
# - (fixes spelling or grammar)
# experiment
# - (experimental change)
# balance
# - (balance changes)
# code_imp
# - (misc internal code change)
# refactor
# - (refactors code)
# config
# - (makes a change to the config files)
# admin
# - (makes changes to administrator tools)
# server
# - (miscellaneous changes to server)
#################################
# Your name.
author: FluffyGhost
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
changes:
- refactor: "Refactored archeological finds to use Initialize() instead of New() where possible."