diff --git a/code/game/objects/items/apc_frame.dm b/code/game/objects/items/apc_frame.dm index 3342d0e8a2f..236e5fbecac 100644 --- a/code/game/objects/items/apc_frame.dm +++ b/code/game/objects/items/apc_frame.dm @@ -14,31 +14,59 @@ return TRUE return ..() -/obj/item/frame/apc/try_build(turf/on_wall) - if (get_dist(on_wall,usr)>1) +/obj/item/frame/apc/try_build(turf/on_wall, mob/user) + if(!istype(user)) + stack_trace("APC being built by a non-mob, somehow!") return - var/ndir = get_dir(usr,on_wall) - if (!(ndir in GLOB.cardinal)) + + if(get_dist(on_wall, user) > 1) return - var/turf/loc = get_turf(usr) - var/area/A = loc.loc - if (!istype(loc, /turf/simulated/floor)) - to_chat(usr, SPAN_WARNING("APC cannot be placed on this spot.")) + + var/ndir = get_dir(user, on_wall) + if(!(ndir in GLOB.cardinal)) + to_chat(user, SPAN_WARNING("You need to stand in front of the wall, directly, to build an APC!")) return - if (A.requires_power == 0 || istype(A, /area/space) || istype(A, /area/mine/unexplored) || istype(A, /area/mine/explored)) - to_chat(usr, SPAN_WARNING("APC cannot be placed in this area.")) + + var/turf/user_turf = get_turf(user) + var/area/A = get_area(user) + + if(!istype(user_turf, /turf/simulated/floor)) + to_chat(user, SPAN_WARNING("APC cannot be placed on this spot.")) return - if (A.get_apc()) - to_chat(usr, SPAN_WARNING("This area already has an APC.")) + + if(A.requires_power == 0 || istype(A, /area/space) || istype(A, /area/mine/unexplored) || istype(A, /area/mine/explored)) + to_chat(user, SPAN_WARNING("APC cannot be placed in this area.")) + return + + if(A.get_apc()) + to_chat(user, SPAN_WARNING("This area already has an APC.")) return //only one APC per area - for(var/obj/machinery/power/terminal/T in loc) + + for(var/obj/machinery/power/terminal/T in user_turf) if (T.master) - to_chat(usr, SPAN_WARNING("There is another network terminal here.")) + to_chat(user, SPAN_WARNING("There is another network terminal here.")) return else - var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(loc) + var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(user_turf) C.amount = 10 - to_chat(usr, "You cut the cables and disassemble the unused power terminal.") + to_chat(user, "You cut the cables and disassemble the unused power terminal.") qdel(T) - new /obj/machinery/power/apc(loc, ndir, 1) + + //Select the correct prefab path based on where the mob is facing + var/apc_path + switch(ndir) + if(NORTH) + apc_path = /obj/machinery/power/apc/north + if(SOUTH) + apc_path = /obj/machinery/power/apc/south + if(EAST) + apc_path = /obj/machinery/power/apc/east + if(WEST) + apc_path = /obj/machinery/power/apc/west + + if(!apc_path) + stack_trace("APC being built by a non-mob, or somehow the direction grabbing or the cardinal directions are fucked!") + return + + new apc_path(user_turf, ndir, TRUE) qdel(src) diff --git a/html/changelogs/fluffyghost-fixapcconstruction.yml b/html/changelogs/fluffyghost-fixapcconstruction.yml new file mode 100644 index 00000000000..4568cabe7cf --- /dev/null +++ b/html/changelogs/fluffyghost-fixapcconstruction.yml @@ -0,0 +1,59 @@ +################################ +# 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: + - bugfix: "Fixed APC construction." + - code_imp: "Cleaned up APC construction try_build() proc."