diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index ba7ec354d82..136f78203df 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -4,6 +4,24 @@ * A large number of misc global procs. */ + /* Get the direction of startObj relative to endObj. + * Return values: To the right, 1. Below, 2. To the left, 3. Above, 4. Not found adjacent in cardinal directions, 0. + */ +/proc/getRelativeDirection(var/atom/movable/startObj, var/atom/movable/endObj) + if(endObj.x == startObj.x + 1 && endObj.y == startObj.y) + return EAST + + if(endObj.x == startObj.x - 1 && endObj.y == startObj.y) + return WEST + + if(endObj.y == startObj.y + 1 && endObj.x == startObj.x) + return NORTH + + if(endObj.y == startObj.y - 1 && endObj.x == startObj.x) + return SOUTH + + return 0 + //Inverts the colour of an HTML string /proc/invertHTML(HTMLstring) diff --git a/code/game/objects/effects/decals/contraband.dm b/code/game/objects/effects/decals/contraband.dm index 4a51e7df7e9..5dd0707fcb9 100644 --- a/code/game/objects/effects/decals/contraband.dm +++ b/code/game/objects/effects/decals/contraband.dm @@ -80,8 +80,13 @@ obj/structure/sign/poster var/ruined = 0 var/subtype = 0 -obj/structure/sign/poster/New(serial,subtype) +obj/structure/sign/poster/legit // For mappers looking to pre-spawn NT approved posters. + subtype = 1 + +obj/structure/sign/poster/New(serial,var/subtypeIn = -1) serial_number = serial + if(subtypeIn != -1) + subtype = subtypeIn if(serial_number == loc) if(subtype == 0) @@ -332,7 +337,11 @@ obj/structure/sign/poster/attackby(obj/item/I, mob/user, params) return /obj/structure/sign/poster/proc/roll_and_drop(turf/location) - var/obj/item/weapon/contraband/poster/P = new(src, serial_number) + var/obj/item/weapon/contraband/poster/P + if(subtype == 1) + P = new/obj/item/weapon/contraband/poster/legit/(src, serial_number) + else + P = new(src, serial_number) P.resulting_poster = src P.loc = location loc = P @@ -358,8 +367,27 @@ obj/structure/sign/poster/attackby(obj/item/I, mob/user, params) var/obj/structure/sign/poster/D = P.resulting_poster var/temp_loc = user.loc + + switch(getRelativeDirection(user, src)) + if(NORTH) + D.pixel_x = 0 + D.pixel_y = 32 + if(EAST) + D.pixel_x = 32 + D.pixel_y = 0 + if(SOUTH) + D.pixel_x = 0 + D.pixel_y = -32 + if(WEST) + D.pixel_x = -32 + D.pixel_y = 0 + else + user << "You cannot reach the wall from here!" + return + flick("poster_being_set",D) - D.loc = src + D.loc = temp_loc + qdel(P) //delete it now to cut down on sanity checks afterwards. Agouri's code supports rerolling it anyway playsound(D.loc, 'sound/items/poster_being_created.ogg', 100, 1)