Merge pull request #839 from tigercat2000/MassDriveVG

Code rework of placing things on walls.
This commit is contained in:
ZomgPonies
2015-04-21 17:31:45 -04:00
20 changed files with 217 additions and 310 deletions
+3 -2
View File
@@ -1511,7 +1511,8 @@ var/list/WALLITEMS = list(
"/obj/machinery/newscaster", "/obj/machinery/firealarm", "/obj/structure/noticeboard", "/obj/machinery/door_control",
"/obj/machinery/computer/security/telescreen", "/obj/machinery/embedded_controller/radio/simple_vent_controller",
"/obj/item/weapon/storage/secure/safe", "/obj/machinery/door_timer", "/obj/machinery/flasher", "/obj/machinery/keycard_auth",
"/obj/structure/mirror", "/obj/structure/closet/fireaxecabinet", "/obj/machinery/computer/security/telescreen/entertainment"
"/obj/structure/mirror", "/obj/structure/closet/fireaxecabinet", "/obj/machinery/computer/security/telescreen/entertainment",
"/obj/structure/sign"
)
/proc/gotwallitem(loc, dir)
for(var/obj/O in loc)
@@ -1541,7 +1542,7 @@ var/list/WALLITEMS = list(
for(var/obj/O in get_step(loc, dir))
for(var/item in WALLITEMS)
if(istype(O, text2path(item)))
if(O.pixel_x == 0 && O.pixel_y == 0)
if(abs(O.pixel_x) <= 10 && abs(O.pixel_y) <= 10)
return 1
return 0
+3 -95
View File
@@ -1014,10 +1014,9 @@
else if(istype(W, /obj/item/weapon/wrench))
user << "You remove the fire alarm assembly from the wall!"
var/obj/item/alarm_frame/frame = new /obj/item/alarm_frame()
frame.loc = user.loc
new /obj/item/mounted/frame/alarm_frame(get_turf(user))
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 50, 1)
del(src)
qdel(src)
return 0
@@ -1049,50 +1048,6 @@ Just a object used in constructing air alarms
m_amt = 50
g_amt = 50
/*
AIR ALARM ITEM
Handheld air alarm frame, for placing on walls
Code shamelessly copied from apc_frame
*/
/obj/item/alarm_frame
name = "air alarm frame"
desc = "Used for building Air Alarms"
icon = 'icons/obj/monitors.dmi'
icon_state = "alarm_bitem"
flags = CONDUCT
/obj/item/alarm_frame/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
if (istype(W, /obj/item/weapon/wrench))
new /obj/item/stack/sheet/metal( get_turf(src.loc), 2 )
del(src)
return
..()
/obj/item/alarm_frame/proc/try_build(turf/on_wall)
if (get_dist(on_wall,usr)>1)
return
var/ndir = get_dir(on_wall,usr)
if (!(ndir in cardinal))
return
var/turf/loc = get_turf_loc(usr)
var/area/A = loc.loc
if (!istype(loc, /turf/simulated/floor))
usr << "\red Air Alarm cannot be placed on this spot."
return
if (A.requires_power == 0 || A.name == "Space")
usr << "\red Air Alarm cannot be placed in this area."
return
if(gotwallitem(loc, ndir))
usr << "\red There's already an item on this wall!"
return
new /obj/machinery/alarm(loc, ndir, 1)
del(src)
/*
FIRE ALARM
*/
@@ -1213,8 +1168,7 @@ FIRE ALARM
else if(istype(W, /obj/item/weapon/wrench))
user << "You remove the fire alarm assembly from the wall!"
var/obj/item/firealarm_frame/frame = new /obj/item/firealarm_frame()
frame.loc = user.loc
new /obj/item/mounted/frame/firealarm(get_turf(user))
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 50, 1)
del(src)
return
@@ -1385,52 +1339,6 @@ Just a object used in constructing fire alarms
m_amt = 50
g_amt = 50
/*
FIRE ALARM ITEM
Handheld fire alarm frame, for placing on walls
Code shamelessly copied from apc_frame
*/
/obj/item/firealarm_frame
name = "fire alarm frame"
desc = "Used for building Fire Alarms"
icon = 'icons/obj/monitors.dmi'
icon_state = "fire_bitem"
flags = CONDUCT
/obj/item/firealarm_frame/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
if (istype(W, /obj/item/weapon/wrench))
new /obj/item/stack/sheet/metal( get_turf(src.loc), 2 )
del(src)
return
..()
/obj/item/firealarm_frame/proc/try_build(turf/on_wall)
if (get_dist(on_wall,usr)>1)
return
var/ndir = get_dir(on_wall,usr)
if (!(ndir in cardinal))
return
var/turf/loc = get_turf_loc(usr)
var/area/A = loc.loc
if (!istype(loc, /turf/simulated/floor))
usr << "\red Fire Alarm cannot be placed on this spot."
return
if (A.requires_power == 0 || A.name == "Space")
usr << "\red Fire Alarm cannot be placed in this area."
return
if(gotwallitem(loc, ndir))
usr << "\red There's already an item on this wall!"
return
new /obj/machinery/firealarm(loc, ndir, 1)
del(src)
/obj/machinery/partyalarm
name = "\improper PARTY BUTTON"
desc = "Cuban Pete is in the house!"
+2 -32
View File
@@ -40,7 +40,7 @@
src.backup_author = ""
src.censored = 0
src.is_admin_channel = 0
/datum/feed_channel/proc/announce_news()
return "Breaking news from [channel_name]!"
@@ -55,36 +55,6 @@ var/datum/feed_network/news_network = new /datum/feed_network //The global n
var/list/obj/machinery/newscaster/allCasters = list() //Global list that will contain reference to all newscasters in existence.
/obj/item/newscaster_frame
name = "newscaster frame"
desc = "Used to build newscasters, just secure to the wall."
icon_state = "newscaster"
item_state = "syringe_kit"
m_amt = 14000
g_amt = 8000
/obj/item/newscaster_frame/proc/try_build(turf/on_wall)
if (get_dist(on_wall,usr)>1)
return
var/ndir = get_dir(usr,on_wall)
if (!(ndir in cardinal))
return
var/turf/loc = get_turf(usr)
var/area/A = loc.loc
if (!istype(loc, /turf/simulated/floor))
usr << "<span class='alert'>Newscaster cannot be placed on this spot.</span>"
return
if (A.requires_power == 0 || A.name == "Space")
usr << "<span class='alert'>Newscaster cannot be placed in this area.</span>"
return
for(var/obj/machinery/newscaster/T in loc)
usr << "<span class='alert'>There is another newscaster here.</span>"
return
var/obj/machinery/newscaster/N = new(loc)
N.pixel_y -= (loc.y - on_wall.y) * 32
N.pixel_x -= (loc.x - on_wall.x) * 32
qdel(src)
/obj/machinery/newscaster
name = "newscaster"
desc = "A standard Nanotrasen-licensed newsfeed handler for use in commercial space stations. All the news you absolutely have no use for, in one place!"
@@ -741,7 +711,7 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co
user << "<span class='notice'>Now [anchored ? "un" : ""]securing [name]</span>"
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
if(do_after(user, 60))
new /obj/item/newscaster_frame(loc)
new /obj/item/mounted/frame/newscaster_frame(loc)
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
qdel(src)
return
-43
View File
@@ -1,43 +0,0 @@
// APC HULL
/obj/item/apc_frame
name = "APC frame"
desc = "Used for repairing or building APCs"
icon = 'icons/obj/apc_repair.dmi'
icon_state = "apc_frame"
flags = CONDUCT
/obj/item/apc_frame/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
..()
if (istype(W, /obj/item/weapon/wrench))
new /obj/item/stack/sheet/metal( get_turf(src.loc), 2 )
del(src)
/obj/item/apc_frame/proc/try_build(turf/on_wall)
if (get_dist(on_wall,usr)>1)
return
var/ndir = get_dir(usr,on_wall)
if (!(ndir in cardinal))
return
var/turf/loc = get_turf(usr)
var/area/A = loc.loc
if (!istype(loc, /turf/simulated/floor))
usr << "\red APC cannot be placed on this spot."
return
if (A.requires_power == 0 || A.name == "Space")
usr << "\red APC cannot be placed in this area."
return
if (A.get_apc())
usr << "\red This area already has APC."
return //only one APC per area
for(var/obj/machinery/power/terminal/T in loc)
if (T.master)
usr << "\red There is another network terminal here."
return
else
var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(loc)
C.amount = 10
usr << "You cut the cables and disassemble the unused power terminal."
del(T)
new /obj/machinery/power/apc(loc, ndir, 1)
del(src)
@@ -0,0 +1,16 @@
/*
AIR ALARM ITEM
Handheld air alarm frame, for placing on walls
Code shamelessly copied from apc_frame
*/
/obj/item/mounted/frame/alarm_frame
name = "air alarm frame"
desc = "Used for building Air Alarms"
icon = 'icons/obj/monitors.dmi'
icon_state = "alarm_bitem"
m_amt = 2000
mount_reqs = list("simfloor", "nospace")
/obj/item/mounted/frame/alarm_frame/do_build(turf/on_wall, mob/user)
new /obj/machinery/alarm(get_turf(src), get_dir(on_wall, user), 1)
qdel(src)
@@ -0,0 +1,29 @@
/obj/item/mounted/frame/apc_frame
name = "APC frame"
desc = "Used for repairing or building APCs"
icon = 'icons/obj/apc_repair.dmi'
icon_state = "apc_frame"
mount_reqs = list("simfloor", "nospace")
/obj/item/mounted/frame/apc_frame/try_build(turf/on_wall, mob/user)
if(..())
var/turf/turf_loc = get_turf(user)
var/area/area_loc = turf_loc.loc
if (area_loc.get_apc())
user << "<span class='rose'>This area already has an APC.</span>"
return //only one APC per area
for(var/obj/machinery/power/terminal/T in turf_loc)
if (T.master)
user << "<span class='rose'>There is another network terminal here.</span>"
return
else
var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(turf_loc)
C.amount = 10
user << "You cut the cables and disassemble the unused power terminal."
qdel(T)
return 1
return
/obj/item/mounted/frame/apc_frame/do_build(turf/on_wall, mob/user)
new /obj/machinery/power/apc(get_turf(src), get_dir(user, on_wall), 1)
qdel(src)
@@ -0,0 +1,10 @@
/obj/item/mounted/frame/firealarm
name = "fire alarm frame"
desc = "Used for building Fire Alarms"
icon = 'icons/obj/monitors.dmi'
icon_state = "fire_bitem"
mount_reqs = list("simfloor", "nospace")
/obj/item/mounted/frame/firealarm/do_build(turf/on_wall, mob/user)
new /obj/machinery/firealarm(get_turf(src), get_dir(on_wall, user), 1)
qdel(src)
@@ -0,0 +1,25 @@
/obj/item/mounted/frame
name = "mountable frame"
desc = "Place it on a wall."
var/sheets_refunded = 2
var/list/mount_reqs = list() //can contain simfloor, nospace. Used in try_build to see if conditions are needed, then met
/obj/item/mounted/frame/attackby(obj/item/weapon/W, mob/user)
..()
if (istype(W, /obj/item/weapon/wrench) && sheets_refunded)
//new /obj/item/stack/sheet/metal( get_turf(src.loc), sheets_refunded )
var/obj/item/stack/sheet/metal/M = getFromPool(/obj/item/stack/sheet/metal, get_turf(src))
M.amount = sheets_refunded
qdel(src)
/obj/item/mounted/frame/try_build(turf/on_wall, mob/user)
if(..()) //if we pass the parent tests
var/turf/turf_loc = get_turf(user)
if (src.mount_reqs.Find("simfloor") && !istype(turf_loc, /turf/simulated/floor))
user << "<span class='rose'>[src] cannot be placed on this spot.</span>"
return
if (src.mount_reqs.Find("nospace") && (areaMaster.requires_power == 0 || areaMaster.name == "Space"))
user << "<span class='rose'>[src] cannot be placed in this area.</span>"
return
return 1
@@ -0,0 +1,39 @@
/obj/item/mounted/frame/light_fixture
name = "light fixture frame"
desc = "Used for building lights."
icon = 'icons/obj/lighting.dmi'
icon_state = "tube-construct-item"
var/fixture_type = "tube"
mount_reqs = list("simfloor")
/obj/item/mounted/frame/light_fixture/do_build(turf/on_wall, mob/user)
user << "You begin attaching [src] to \the [on_wall]."
playsound(get_turf(src), 'sound/machines/click.ogg', 75, 1)
var/constrdir = user.dir
var/constrloc = get_turf(user)
if (!do_after(user, 30))
return
var/obj/machinery/light_construct/newlight
switch(fixture_type)
if("bulb")
newlight = new /obj/machinery/light_construct/small(constrloc)
if("tube")
newlight = new /obj/machinery/light_construct(constrloc)
else
newlight = new /obj/machinery/light_construct/small(constrloc)
newlight.dir = constrdir
newlight.fingerprints = src.fingerprints
newlight.fingerprintshidden = src.fingerprintshidden
newlight.fingerprintslast = src.fingerprintslast
user.visible_message("[user] attaches \the [src] to \the [on_wall].", \
"You attach \the [src] to \the [on_wall].")
qdel(src)
/obj/item/mounted/frame/light_fixture/small
name = "small light fixture frame"
desc = "Used for building small lights."
icon = 'icons/obj/lighting.dmi'
icon_state = "bulb-construct-item"
fixture_type = "bulb"
sheets_refunded = 1
@@ -0,0 +1,34 @@
/obj/item/mounted
var/list/buildon_types = list(/turf/simulated/wall)
/obj/item/mounted/afterattack(var/atom/A, mob/user, proximity_flag)
var/found_type = 0
for(var/turf_type in src.buildon_types)
if(istype(A, turf_type))
found_type = 1
break
if(found_type)
if(try_build(A, user, proximity_flag))
return do_build(A, user)
else
..()
/obj/item/mounted/proc/try_build(turf/on_wall, mob/user, proximity_flag) //checks
if(!on_wall || !user)
return
if (proximity_flag != 1) //if we aren't next to the wall
return
if (!( get_dir(on_wall,user) in cardinal))
user << "<span class='rose'>You need to be standing next to a wall to place \the [src].</span>"
return
if(gotwallitem(get_turf(user), get_dir(on_wall,user)))
user << "<span class='rose'>There's already an item on this wall!</span>"
return
return 1
/obj/item/mounted/proc/do_build(turf/on_wall, mob/user) //the buildy bit after we pass the checks
return
@@ -0,0 +1,32 @@
/obj/item/mounted/frame/newscaster_frame
name = "newscaster frame"
desc = "Used to build newscasters, just secure to the wall."
icon_state = "newscaster"
item_state = "syringe_kit"
m_amt = 14000
g_amt = 8000
mount_reqs = list("simfloor", "nospace")
/obj/item/mounted/frame/newscaster_frame/try_build(turf/on_wall, mob/user)
if(..())
var/turf/loc = get_turf(usr)
var/area/A = loc.loc
if (!istype(loc, /turf/simulated/floor))
usr << "<span class='alert'>Newscaster cannot be placed on this spot.</span>"
return
if (A.requires_power == 0 || A.name == "Space")
usr << "<span class='alert'>Newscaster cannot be placed in this area.</span>"
return
for(var/obj/machinery/newscaster/T in loc)
usr << "<span class='alert'>There is another newscaster here.</span>"
return
return 1
return
/obj/item/mounted/frame/newscaster_frame/do_build(turf/on_wall, mob/user)
var/obj/machinery/newscaster/N = new /obj/machinery/newscaster(get_turf(src), get_dir(on_wall, user), 1)
N.pixel_y -= (loc.y - on_wall.y) * 32
N.pixel_x -= (loc.x - on_wall.x) * 32
qdel(src)
@@ -64,12 +64,12 @@ var/global/list/datum/stack_recipe/metal_recipes = list ( \
), 4), \
null, \
new/datum/stack_recipe("grenade casing", /obj/item/weapon/grenade/chem_grenade), \
new/datum/stack_recipe("light fixture frame", /obj/item/light_fixture_frame, 2), \
new/datum/stack_recipe("small light fixture frame", /obj/item/light_fixture_frame/small, 1), \
new/datum/stack_recipe("light fixture frame", /obj/item/mounted/frame/light_fixture, 2), \
new/datum/stack_recipe("small light fixture frame", /obj/item/mounted/frame/light_fixture/small, 1), \
null, \
new/datum/stack_recipe("apc frame", /obj/item/apc_frame, 2), \
new/datum/stack_recipe("air alarm frame", /obj/item/alarm_frame, 2), \
new/datum/stack_recipe("fire alarm frame", /obj/item/firealarm_frame, 2), \
new/datum/stack_recipe("apc frame", /obj/item/mounted/frame/apc_frame, 2), \
new/datum/stack_recipe("air alarm frame", /obj/item/mounted/frame/alarm_frame, 2), \
new/datum/stack_recipe("fire alarm frame", /obj/item/mounted/frame/firealarm, 2), \
null, \
)
+1 -38
View File
@@ -451,46 +451,9 @@
O.show_message("<span class='warning'>The wall was sliced apart by [user]!</span>", 1, "<span class='warning'>You hear metal being sliced apart and sparks flying.</span>", 2)
return
else if(istype(W,/obj/item/apc_frame))
var/obj/item/apc_frame/AH = W
AH.try_build(src)
else if(istype(W,/obj/item/mounted)) //if we place it, we don't want to have a silly message
return
else if(istype(W,/obj/item/newscaster_frame))
var/obj/item/newscaster_frame/AH = W
AH.try_build(src)
return 1
else if(istype(W,/obj/item/alarm_frame))
var/obj/item/alarm_frame/AH = W
AH.try_build(src)
return
else if(istype(W,/obj/item/firealarm_frame))
var/obj/item/firealarm_frame/AH = W
AH.try_build(src)
return
else if(istype(W,/obj/item/light_fixture_frame))
var/obj/item/light_fixture_frame/AH = W
AH.try_build(src)
return
else if(istype(W,/obj/item/light_fixture_frame/small))
var/obj/item/light_fixture_frame/small/AH = W
AH.try_build(src)
return
/*
else if(istype(W,/obj/item/rust_fuel_compressor_frame))
var/obj/item/rust_fuel_compressor_frame/AH = W
AH.try_build(src)
return
else if(istype(W,/obj/item/rust_fuel_assembly_port_frame))
var/obj/item/rust_fuel_assembly_port_frame/AH = W
AH.try_build(src)
return
*/
//Poster stuff
else if(istype(W,/obj/item/weapon/contraband/poster))
place_poster(W,user)
+1 -26
View File
@@ -284,32 +284,7 @@
del(MS)
//APC
else if( istype(W,/obj/item/apc_frame) )
var/obj/item/apc_frame/AH = W
AH.try_build(src)
else if(istype(W,/obj/item/newscaster_frame))
var/obj/item/newscaster_frame/AH = W
AH.try_build(src)
return 1
else if( istype(W,/obj/item/alarm_frame) )
var/obj/item/alarm_frame/AH = W
AH.try_build(src)
else if(istype(W,/obj/item/firealarm_frame))
var/obj/item/firealarm_frame/AH = W
AH.try_build(src)
return
else if(istype(W,/obj/item/light_fixture_frame))
var/obj/item/light_fixture_frame/AH = W
AH.try_build(src)
return
else if(istype(W,/obj/item/light_fixture_frame/small))
var/obj/item/light_fixture_frame/small/AH = W
AH.try_build(src)
else if(istype(W,/obj/item/mounted))
return
//Poster stuff
@@ -14,10 +14,10 @@
/obj/item/weapon/airlock_electronics,
/obj/item/weapon/module/power_control,
/obj/item/weapon/stock_parts,
/obj/item/light_fixture_frame,
/obj/item/apc_frame,
/obj/item/alarm_frame,
/obj/item/firealarm_frame,
/obj/item/mounted/frame/light_fixture,
/obj/item/mounted/frame/apc_frame,
/obj/item/mounted/frame/alarm_frame,
/obj/item/mounted/frame/firealarm,
/obj/item/weapon/table_parts,
/obj/item/weapon/rack_parts,
/obj/item/weapon/camera_assembly,
+3 -3
View File
@@ -525,14 +525,14 @@
"You disassembled the broken APC frame.",\
"\red You hear welding.")
else
new /obj/item/apc_frame(loc)
new /obj/item/mounted/frame/apc_frame(loc)
user.visible_message(\
"\red [src] has been cut from the wall by [user.name] with the weldingtool.",\
"You cut the APC frame from the wall.",\
"\red You hear welding.")
del(src)
return
else if (istype(W, /obj/item/apc_frame) && opened && emagged)
else if (istype(W, /obj/item/mounted/frame/apc_frame) && opened && emagged)
emagged = 0
if (opened==2)
opened = 1
@@ -541,7 +541,7 @@
"You replace the damaged APC frontal panel with a new one.")
del(W)
update_icon()
else if (istype(W, /obj/item/apc_frame) && opened && ((stat & BROKEN) || malfhack))
else if (istype(W, /obj/item/mounted/frame/apc_frame) && opened && ((stat & BROKEN) || malfhack))
if (has_electronics)
user << "You cannot repair this APC until you remove the electronics still inside."
return
-58
View File
@@ -9,64 +9,6 @@
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3
/obj/item/light_fixture_frame
name = "light fixture frame"
desc = "Used for building lights."
icon = 'icons/obj/lighting.dmi'
icon_state = "tube-construct-item"
flags = CONDUCT
var/fixture_type = "tube"
var/obj/machinery/light/newlight = null
var/sheets_refunded = 2
/obj/item/light_fixture_frame/attackby(obj/item/weapon/W as obj, mob/living/user as mob, params)
if (istype(W, /obj/item/weapon/wrench))
new /obj/item/stack/sheet/metal( get_turf(src.loc), sheets_refunded )
del(src)
return
..()
/obj/item/light_fixture_frame/proc/try_build(turf/on_wall)
if (get_dist(on_wall,usr)>1)
return
var/ndir = get_dir(usr,on_wall)
if (!(ndir in cardinal))
return
var/turf/loc = get_turf_loc(usr)
if (!istype(loc, /turf/simulated/floor))
usr << "\red [src.name] cannot be placed on this spot."
return
usr << "Attaching [src] to the wall."
playsound(src.loc, 'sound/machines/click.ogg', 75, 1)
var/constrdir = usr.dir
var/constrloc = usr.loc
if (!do_after(usr, 30))
return
switch(fixture_type)
if("bulb")
newlight = new /obj/machinery/light_construct/small(constrloc)
if("tube")
newlight = new /obj/machinery/light_construct(constrloc)
newlight.dir = constrdir
newlight.fingerprints = src.fingerprints
newlight.fingerprintshidden = src.fingerprintshidden
newlight.fingerprintslast = src.fingerprintslast
usr.visible_message("[usr.name] attaches [src] to the wall.", \
"You attach [src] to the wall.")
del(src)
/obj/item/light_fixture_frame/small
name = "small light fixture frame"
desc = "Used for building small lights."
icon = 'icons/obj/lighting.dmi'
icon_state = "bulb-construct-item"
flags = CONDUCT
fixture_type = "bulb"
sheets_refunded = 1
/obj/machinery/light_construct
name = "light fixture frame"
desc = "A light fixture under construction."
@@ -255,7 +255,7 @@
id = "newscaster_frame"
build_type = AUTOLATHE
materials = list("$metal" = 14000, "$glass" = 8000)
build_path = /obj/item/newscaster_frame
build_path = /obj/item/mounted/frame/newscaster_frame
category = list("initial", "Construction")
/datum/design/rcd_ammo