From ef38656c470fff0282f2153e40aae45f77021de5 Mon Sep 17 00:00:00 2001 From: oranges Date: Mon, 31 Oct 2016 01:41:54 +1300 Subject: [PATCH] Tweak Duplicate object proc (#21069) Better typepathing and doesnt try to update_icon on things that don't have an update_icon proc defined Also adds a holoitem flag so admin area copy doesn't make objects immune to lava fire and acid --- code/modules/holodeck/area_copy.dm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/code/modules/holodeck/area_copy.dm b/code/modules/holodeck/area_copy.dm index d2e4a1d05b2..653aac2f9b3 100644 --- a/code/modules/holodeck/area_copy.dm +++ b/code/modules/holodeck/area_copy.dm @@ -1,7 +1,7 @@ -/proc/DuplicateObject(obj/original, var/perfectcopy = 0 , var/sameloc = 0, var/atom/newloc = null, var/nerf = 0) +/proc/DuplicateObject(var/atom/original, var/perfectcopy = TRUE, var/sameloc = FALSE, var/atom/newloc = null, var/nerf = FALSE, var/holoitem=FALSE) if(!original) return null - var/obj/O + var/atom/O if(sameloc) O = new original.type(original.loc) @@ -20,15 +20,19 @@ else O.vars[V] = original.vars[V] - if(istype(O)) - O.resistance_flags = LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF // holoitems do not burn + if(istype(O, /obj)) + var/obj/N = O + if(holoitem) + N.resistance_flags = LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF // holoitems do not burn + if(nerf && istype(O,/obj/item)) var/obj/item/I = O I.damtype = STAMINA // thou shalt not + + N.update_icon() if(istype(O,/obj/machinery)) var/obj/machinery/M = O M.power_change() - O.update_icon() return O @@ -89,13 +93,13 @@ X.icon_state = old_icon_state1 for(var/obj/O in T) - var/obj/O2 = DuplicateObject(O , 1, newloc = X, nerf=nerf_weapons) + var/obj/O2 = DuplicateObject(O , perfect_copy=TRUE, newloc = X, nerf=nerf_weapons, holoitem=TRUE) if(!O2) continue copiedobjs += O2.GetAllContents() for(var/mob/M in T) if(istype(M, /mob/camera)) continue // If we need to check for more mobs, I'll add a variable - var/mob/SM = DuplicateObject(M , 1, newloc = X) + var/mob/SM = DuplicateObject(M , perfect_copy=TRUE, newloc = X, holoitem=TRUE) copiedobjs += SM.GetAllContents() var/global/list/forbidden_vars = list("type","stat","loc","locs","vars", "parent", "parent_type","verbs","ckey","key","x","y","z","contents", "luminosity")