diff --git a/code/game/objects/effects/contraband.dm b/code/game/objects/effects/contraband.dm index 105376f8739..8a74fc6b60a 100644 --- a/code/game/objects/effects/contraband.dm +++ b/code/game/objects/effects/contraband.dm @@ -155,7 +155,7 @@ qdel(src) else to_chat(user, span_notice("You carefully remove the poster from the wall.")) - roll_and_drop(user.loc) + roll_and_drop(Adjacent(user) ? get_turf(user) : loc) /obj/structure/sign/poster/attack_hand(mob/user, list/modifiers) . = ..() @@ -191,29 +191,29 @@ return FALSE return (!user.gloves && !HAS_TRAIT(user, TRAIT_PIERCEIMMUNE)) -/obj/structure/sign/poster/proc/roll_and_drop(loc) +/obj/structure/sign/poster/proc/roll_and_drop(atom/location) pixel_x = 0 pixel_y = 0 - var/obj/item/poster/P = new poster_item_type(loc, src) - forceMove(P) - return P + var/obj/item/poster/rolled_poster = new poster_item_type(location, src) // /obj/structure/sign/poster/wanted/roll_and_drop() has some snowflake handling due to icon memes, if you make a major change to this, don't forget to update it too. <3 + forceMove(rolled_poster) + return rolled_poster //separated to reduce code duplication. Moved here for ease of reference and to unclutter r_wall/attackby() -/turf/closed/wall/proc/place_poster(obj/item/poster/P, mob/user) - if(!P.poster_structure) - to_chat(user, span_warning("[P] has no poster... inside it? Inform a coder!")) +/turf/closed/wall/proc/place_poster(obj/item/poster/rolled_poster, mob/user) + if(!rolled_poster.poster_structure) + to_chat(user, span_warning("[rolled_poster] has no poster... inside it? Inform a coder!")) return // Deny placing posters on currently-diagonal walls, although the wall may change in the future. if (smoothing_flags & SMOOTH_DIAGONAL_CORNERS) - for (var/O in overlays) - var/image/I = O - if(copytext(I.icon_state, 1, 3) == "d-") //3 == length("d-") + 1 + for (var/overlay in overlays) + var/image/new_image = overlay + if(copytext(new_image.icon_state, 1, 3) == "d-") //3 == length("d-") + 1 return var/stuff_on_wall = 0 - for(var/obj/O in contents) //Let's see if it already has a poster on it or too much stuff - if(istype(O, /obj/structure/sign/poster)) + for(var/obj/contained_object in contents) //Let's see if it already has a poster on it or too much stuff + if(istype(contained_object, /obj/structure/sign/poster)) to_chat(user, span_warning("The wall is far too cluttered to place a poster!")) return stuff_on_wall++ @@ -223,23 +223,22 @@ to_chat(user, span_notice("You start placing the poster on the wall...") ) - var/obj/structure/sign/poster/D = P.poster_structure + var/obj/structure/sign/poster/placed_poster = rolled_poster.poster_structure - var/temp_loc = get_turf(user) - flick("poster_being_set",D) - D.forceMove(src) //deletion of the poster is handled in poster/Exited(), so don't have to worry about P anymore. - playsound(D.loc, 'sound/items/poster_being_created.ogg', 100, TRUE) + flick("poster_being_set", placed_poster) + placed_poster.forceMove(src) //deletion of the poster is handled in poster/Exited(), so don't have to worry about P anymore. + playsound(src, 'sound/items/poster_being_created.ogg', 100, TRUE) - if(do_after(user, PLACE_SPEED, target=src)) - if(!D || QDELETED(D)) - return + var/turf/user_drop_location = get_turf(user) //cache this so it just falls to the ground if they move. also no tk memes allowed. + if(!do_after(user, PLACE_SPEED, placed_poster, extra_checks = CALLBACK(placed_poster, /obj/structure/sign/poster.proc/snowflake_wall_turf_check, src))) + to_chat(user, span_notice("The poster falls down!")) + placed_poster.roll_and_drop(user_drop_location) + return - if(iswallturf(src) && user && user.loc == temp_loc) //Let's check if everything is still there - D.on_placed_poster(user) - return + placed_poster.on_placed_poster(user) - to_chat(user, span_notice("The poster falls down!")) - D.roll_and_drop(get_turf(user)) +/obj/structure/sign/poster/proc/snowflake_wall_turf_check(atom/hopefully_still_a_wall_turf) //since turfs never get deleted but instead change type, make sure we're still being placed on a wall. + return iswallturf(hopefully_still_a_wall_turf) /obj/structure/sign/poster/proc/on_placed_poster(mob/user) to_chat(user, span_notice("You place the poster!")) diff --git a/code/game/objects/effects/wanted_poster.dm b/code/game/objects/effects/wanted_poster.dm index a32a6b2f3d9..c5608a567d6 100644 --- a/code/game/objects/effects/wanted_poster.dm +++ b/code/game/objects/effects/wanted_poster.dm @@ -21,8 +21,12 @@ postHeaderText = "MISSING" // MAX 7 Characters postHeaderColor = "#0000FF" -/obj/item/poster/wanted/Initialize(mapload, icon/person_icon, wanted_name, description, headerText) - . = ..(mapload, new /obj/structure/sign/poster/wanted(src, person_icon, wanted_name, description, headerText, postHeaderColor, background, postName, postDesc)) + +/obj/item/poster/wanted/Initialize(mapload, icon/person_icon, wanted_name, description, headerText, posterHeaderColor) + if(posterHeaderColor) + postHeaderColor = posterHeaderColor + var/obj/structure/sign/poster/wanted/wanted_poster = new (src, person_icon, wanted_name, description, headerText, postHeaderColor, background, postName, postDesc) + . = ..(mapload, wanted_poster) name = "[postName] ([wanted_name])" desc = "[postDesc] [wanted_name]." postHeaderText = headerText @@ -33,6 +37,7 @@ var/postDesc var/posterHeaderText var/posterHeaderColor + var/icon/original_icon //cache the passed icon incase we ever get torn down and need to regenerate it. poster_item_type = /obj/item/poster/wanted @@ -51,6 +56,7 @@ desc = description person_icon = icon(person_icon, dir = SOUTH)//copy the image so we don't mess with the one in the record. + original_icon = icon(person_icon) //cache this incase it gets torn down var/icon/the_icon = icon("icon" = 'icons/obj/poster_wanted.dmi', "icon_state" = background) person_icon.Shift(SOUTH, 7) person_icon.Crop(7,4,26,30) @@ -87,11 +93,9 @@ poster_icon.Blend(letter_icon, ICON_OVERLAY) startX = startX + 4 -/obj/structure/sign/poster/wanted/roll_and_drop(turf/location) - var/obj/item/poster/wanted/P = ..(location) - P.name = "[postName] ([wanted_name])" - P.desc = "[postDesc] [wanted_name]." - P.postHeaderText = posterHeaderText - P.postHeaderColor = posterHeaderColor - return P - +/obj/structure/sign/poster/wanted/roll_and_drop(atom/location) + pixel_x = 0 + pixel_y = 0 + var/obj/item/poster/rolled_poster = new poster_item_type(location, original_icon, wanted_name, desc, posterHeaderText, posterHeaderColor) + forceMove(rolled_poster) + return rolled_poster diff --git a/code/game/turfs/closed/walls.dm b/code/game/turfs/closed/walls.dm index 887995232cc..87b0fedb10f 100644 --- a/code/game/turfs/closed/walls.dm +++ b/code/game/turfs/closed/walls.dm @@ -233,7 +233,7 @@ F.attach(src, user) return TRUE //Poster stuff - else if(istype(W, /obj/item/poster)) + else if(istype(W, /obj/item/poster) && Adjacent(user)) //no tk memes. place_poster(W,user) return TRUE