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)]"