From 769244d40a058e0d77ca86906637b82d4a826dea Mon Sep 17 00:00:00 2001 From: Citinited Date: Sat, 8 Apr 2017 07:01:57 +0100 Subject: [PATCH] Improves legibility of rpd.dm and somewhat improves the code Minor text fixes --- code/game/objects/items/weapons/rpd.dm | 224 ++++++++++++------------- 1 file changed, 106 insertions(+), 118 deletions(-) diff --git a/code/game/objects/items/weapons/rpd.dm b/code/game/objects/items/weapons/rpd.dm index f640b031e46..7db79cdd06f 100644 --- a/code/game/objects/items/weapons/rpd.dm +++ b/code/game/objects/items/weapons/rpd.dm @@ -9,17 +9,17 @@ icon_state = "rpd" opacity = 0 density = 0 - anchored = 0.0 + anchored = 0 flags = CONDUCT - force = 10.0 - throwforce = 10.0 + force = 10 + throwforce = 10 throw_speed = 3 throw_range = 5 w_class = 3 materials = list(MAT_METAL = 30000, MAT_GLASS = 5000) origin_tech = "engineering=4;materials=2" var/iconrotation = 0 //used to orient icons and pipes - var/initialised = 0 //This stops us unnecessarily checking the cache for icons + var/initialised //This stops us unnecessarily checking the cache for icons var/mode = 1 //Disposals, atmospherics var/pipemenu = 1 //For nanoUI menus var/pipetype = 1//For nanoUI menus @@ -37,56 +37,56 @@ //List of things follow here -//Pipename, pipe type (see construction.dm), pipe category, number of orientations this pipe has, name of pipe in the icon file, is this pipe bendy? +//Pipename, pipe type (see construction.dm), pipe category, number of unique orientations, name of pipe icon, is this pipe bendy? var/list/pipelist = list( - list("key1" = "Straight pipe", "key2" = "0", "key3" = "1", "key4" = "2", "key5" = "simple", "key6" = "0"), - list("key1" = "Bent pipe", "key2" = "1", "key3" = "1", "key4" = "4", "key5" = "simple", "key6" = "1"), - list("key1" = "T-manifold", "key2" = "5", "key3" = "1", "key4" = "4", "key5" = "manifold", "key6" = "0"), - list("key1" = "4-way manifold", "key2" = "19", "key3" = "1", "key4" = "1", "key5" = "manifold4w", "key6" = "0"), - list("key1" = "Pipe cap", "key2" = "20", "key3" = "1", "key4" = "4", "key5" = "cap", "key6" = "0"), - list("key1" = "Manual valve", "key2" = "8", "key3" = "1", "key4" = "2", "key5" = "mvalve", "key6" = "0"), - list("key1" = "Digital valve", "key2" = "35", "key3" = "1", "key4" = "2", "key5" = "dvalve", "key6" = "0"), - list("key1" = "Manual T-valve", "key2" = "18", "key3" = "1", "key4" = "4", "key5" = "tvalve", "key6" = "0"), - list("key1" = "Digital T-valve", "key2" = "38", "key3" = "1", "key4" = "4", "key5" = "dtvalve", "key6" = "0"), - list("key1" = "Straight supply pipe", "key2" = "24", "key3" = "2", "key4" = "2", "key5" = "simple", "key6" = "0"), - list("key1" = "Bent supply pipe", "key2" = "25", "key3" = "2", "key4" = "4", "key5" = "simple", "key6" = "1"), - list("key1" = "Supply T-manifold", "key2" = "28", "key3" = "2", "key4" = "4", "key5" = "manifold", "key6" = "0"), - list("key1" = "4-way supply manifold", "key2" = "30", "key3" = "2", "key4" = "1", "key5" = "manifold4w", "key6" = "0"), - list("key1" = "Supply pipe cap", "key2" = "32", "key3" = "2", "key4" = "4", "key5" = "cap", "key6" = "0"), - list("key1" = "Straight scrubbers pipe", "key2" = "26", "key3" = "3", "key4" = "2", "key5" = "simple", "key6" = "0"), - list("key1" = "Bent scrubbers pipe", "key2" = "27", "key3" = "3", "key4" = "4", "key5" = "simple", "key6" = "1"), - list("key1" = "Scrubbers T-manifold", "key2" = "29", "key3" = "3", "key4" = "4", "key5" = "manifold", "key6" = "0"), - list("key1" = "4-way scrubbers manifold", "key2" = "31", "key3" = "3", "key4" = "1", "key5" = "manifold4w", "key6" = "0"), - list("key1" = "Scrubbers pipe cap", "key2" = "33", "key3" = "3", "key4" = "4", "key5" = "cap", "key6" = "0"), - list("key1" = "Universal pipe adapter", "key2" = "23", "key3" = "4", "key4" = "2", "key5" = "universal", "key6" = "0"), - list("key1" = "Unary vent", "key2" = "7", "key3" = "4", "key4" = "4", "key5" = "uvent", "key6" = "0"), - list("key1" = "Scrubber", "key2" = "10", "key3" = "4", "key4" = "4", "key5" = "scrubber", "key6" = "0"), - list("key1" = "Air injector", "key2" = "34", "key3" = "4", "key4" = "4", "key5" = "injector", "key6" = "0"), - list("key1" = "Gas pump", "key2" = "9", "key3" = "4", "key4" = "4", "key5" = "pump", "key6" = "0"), - list("key1" = "Volume pump", "key2" = "16", "key3" = "4", "key4" = "4", "key5" = "volumepump", "key6" = "0"), - list("key1" = "Passive gate", "key2" = "15", "key3" = "4", "key4" = "4", "key5" = "passivegate", "key6" = "0"), - list("key1" = "Connector", "key2" = "4", "key3" = "4", "key4" = "4", "key5" = "connector", "key6" = "0"), - list("key1" = "Gas sensor", "key2" = "98", "key3" = "4", "key4" = "1", "key5" = "sensor", "key6" = "0"), - list("key1" = "Meter", "key2" = "99", "key3" = "4", "key4" = "1", "key5" = "meter", "key6" = "0"), - list("key1" = "Gas filter", "key2" = "13", "key3" = "4", "key4" = "4", "key5" = "filter", "key6" = "0"), - list("key1" = "Gas mixer", "key2" = "14", "key3" = "4", "key4" = "4", "key5" = "mixer", "key6" = "0"), - list("key1" = "Dual-port vent pump", "key2" = "36", "key3" = "4", "key4" = "2", "key5" = "dual-port vent", "key6" = "0"), - list("key1" = "Passive vent", "key2" = "37", "key3" = "4", "key4" = "4", "key5" = "passive vent", "key6" = "0"), - list("key1" = "Straight HE pipe", "key2" = "2", "key3" = "5", "key4" = "2", "key5" = "he", "key6" = "0"), - list("key1" = "Bent HE pipe", "key2" = "3", "key3" = "5", "key4" = "4", "key5" = "he", "key6" = "1"), - list("key1" = "Junction", "key2" = "6", "key3" = "5", "key4" = "4", "key5" = "junction", "key6" = "0"), - list("key1" = "Heat exchanger", "key2" = "17", "key3" = "5", "key4" = "4", "key5" = "heunary", "key6" = "0")) + list("key1" = "Straight pipe", "key2" = "0", "key3" = "1", "key4" = "2", "key5" = "simple", "key6" = "0"), + list("key1" = "Bent pipe", "key2" = "1", "key3" = "1", "key4" = "4", "key5" = "simple", "key6" = "1"), + list("key1" = "T-manifold", "key2" = "5", "key3" = "1", "key4" = "4", "key5" = "manifold", "key6" = "0"), + list("key1" = "4-way manifold", "key2" = "19", "key3" = "1", "key4" = "1", "key5" = "manifold4w", "key6" = "0"), + list("key1" = "Pipe cap", "key2" = "20", "key3" = "1", "key4" = "4", "key5" = "cap", "key6" = "0"), + list("key1" = "Manual valve", "key2" = "8", "key3" = "1", "key4" = "2", "key5" = "mvalve", "key6" = "0"), + list("key1" = "Digital valve", "key2" = "35", "key3" = "1", "key4" = "2", "key5" = "dvalve", "key6" = "0"), + list("key1" = "Manual T-valve", "key2" = "18", "key3" = "1", "key4" = "4", "key5" = "tvalve", "key6" = "0"), + list("key1" = "Digital T-valve", "key2" = "38", "key3" = "1", "key4" = "4", "key5" = "dtvalve", "key6" = "0"), + list("key1" = "Straight supply pipe", "key2" = "24", "key3" = "2", "key4" = "2", "key5" = "simple", "key6" = "0"), + list("key1" = "Bent supply pipe", "key2" = "25", "key3" = "2", "key4" = "4", "key5" = "simple", "key6" = "1"), + list("key1" = "Supply T-manifold", "key2" = "28", "key3" = "2", "key4" = "4", "key5" = "manifold", "key6" = "0"), + list("key1" = "4-way supply manifold", "key2" = "30", "key3" = "2", "key4" = "1", "key5" = "manifold4w", "key6" = "0"), + list("key1" = "Supply pipe cap", "key2" = "32", "key3" = "2", "key4" = "4", "key5" = "cap", "key6" = "0"), + list("key1" = "Straight scrubbers pipe", "key2" = "26", "key3" = "3", "key4" = "2", "key5" = "simple", "key6" = "0"), + list("key1" = "Bent scrubbers pipe", "key2" = "27", "key3" = "3", "key4" = "4", "key5" = "simple", "key6" = "1"), + list("key1" = "Scrubbers T-manifold", "key2" = "29", "key3" = "3", "key4" = "4", "key5" = "manifold", "key6" = "0"), + list("key1" = "4-way scrubbers manifold", "key2" = "31", "key3" = "3", "key4" = "1", "key5" = "manifold4w", "key6" = "0"), + list("key1" = "Scrubbers pipe cap", "key2" = "33", "key3" = "3", "key4" = "4", "key5" = "cap", "key6" = "0"), + list("key1" = "Universal pipe adapter", "key2" = "23", "key3" = "4", "key4" = "2", "key5" = "universal", "key6" = "0"), + list("key1" = "Unary vent", "key2" = "7", "key3" = "4", "key4" = "4", "key5" = "uvent", "key6" = "0"), + list("key1" = "Scrubber", "key2" = "10", "key3" = "4", "key4" = "4", "key5" = "scrubber", "key6" = "0"), + list("key1" = "Air injector", "key2" = "34", "key3" = "4", "key4" = "4", "key5" = "injector", "key6" = "0"), + list("key1" = "Gas pump", "key2" = "9", "key3" = "4", "key4" = "4", "key5" = "pump", "key6" = "0"), + list("key1" = "Volume pump", "key2" = "16", "key3" = "4", "key4" = "4", "key5" = "volumepump", "key6" = "0"), + list("key1" = "Passive gate", "key2" = "15", "key3" = "4", "key4" = "4", "key5" = "passivegate", "key6" = "0"), + list("key1" = "Connector", "key2" = "4", "key3" = "4", "key4" = "4", "key5" = "connector", "key6" = "0"), + list("key1" = "Gas sensor", "key2" = "98", "key3" = "4", "key4" = "1", "key5" = "sensor", "key6" = "0"), + list("key1" = "Meter", "key2" = "99", "key3" = "4", "key4" = "1", "key5" = "meter", "key6" = "0"), + list("key1" = "Gas filter", "key2" = "13", "key3" = "4", "key4" = "4", "key5" = "filter", "key6" = "0"), + list("key1" = "Gas mixer", "key2" = "14", "key3" = "4", "key4" = "4", "key5" = "mixer", "key6" = "0"), + list("key1" = "Dual-port vent pump", "key2" = "36", "key3" = "4", "key4" = "2", "key5" = "dual-port vent", "key6" = "0"), + list("key1" = "Passive vent", "key2" = "37", "key3" = "4", "key4" = "4", "key5" = "passive vent", "key6" = "0"), + list("key1" = "Straight HE pipe", "key2" = "2", "key3" = "5", "key4" = "2", "key5" = "he", "key6" = "0"), + list("key1" = "Bent HE pipe", "key2" = "3", "key3" = "5", "key4" = "4", "key5" = "he", "key6" = "1"), + list("key1" = "Junction", "key2" = "6", "key3" = "5", "key4" = "4", "key5" = "junction", "key6" = "0"), + list("key1" = "Heat exchanger", "key2" = "17", "key3" = "5", "key4" = "4", "key5" = "heunary", "key6" = "0")) -//Pipename, pipe type, no. of unique orientations, name of pipe icon +//Pipename, pipe type, number of unique orientations, name of pipe icon var/list/dpipelist = list( - list("key1" = "Straight pipe", "key2" = "0", "key3" = "2", "key4" = "conpipe-s"), - list("key1" = "Bent pipe", "key2" = "1", "key3" = "4", "key4" = "conpipe-c"), - list("key1" = "Junction", "key2" = "2", "key3" = "4", "key4" = "conpipe-j1"), - list("key1" = "Y-junction", "key2" = "4", "key3" = "4", "key4" = "conpipe-y"), - list("key1" = "Trunk", "key2" = "5", "key3" = "4", "key4" = "conpipe-t"), - list("key1" = "Bin", "key2" = "6", "key3" = "1", "key4" = "condisposal"), - list("key1" = "Outlet", "key2" = "7", "key3" = "4", "key4" = "outlet"), - list("key1" = "Chute", "key2" = "8", "key3" = "4", "key4" = "intake")) + list("key1" = "Straight pipe", "key2" = "0", "key3" = "2", "key4" = "conpipe-s"), + list("key1" = "Bent pipe", "key2" = "1", "key3" = "4", "key4" = "conpipe-c"), + list("key1" = "Junction", "key2" = "2", "key3" = "4", "key4" = "conpipe-j1"), + list("key1" = "Y-junction", "key2" = "4", "key3" = "4", "key4" = "conpipe-y"), + list("key1" = "Trunk", "key2" = "5", "key3" = "4", "key4" = "conpipe-t"), + list("key1" = "Bin", "key2" = "6", "key3" = "1", "key4" = "condisposal"), + list("key1" = "Outlet", "key2" = "7", "key3" = "4", "key4" = "outlet"), + list("key1" = "Chute", "key2" = "8", "key3" = "4", "key4" = "intake")) //Procs @@ -94,7 +94,7 @@ var/list/dpipelist = list( playsound(loc, soundfile, 50, 1) if(prob(15)) spark_system.start() - if(delay == 1) + if(delay) cooldown = 1 spawn(spawndelay) cooldown = 0 @@ -108,44 +108,39 @@ var/list/dpipelist = list( //This proc puts each necessary icon into the initial user's cache for later use. It then sets initialised = 1 to avoid calling itself unnecessarily. /obj/item/weapon/rpd/proc/Initialiseicons() - if(initialised == 1) - return var/F var/I + var/list/filenames var/disposalsfile = "icons/obj/pipes/disposal.dmi" var/pipefile = "icons/obj/pipe-item.dmi" - var/list/filenames for(I in pipelist) if(I["key6"] == "1")//Bendy pipe icons - filenames = list( - list(I["key5"] + "-southeast.png", SOUTHEAST), - list(I["key5"] + "-southwest.png", SOUTHWEST), - list(I["key5"] + "-northwest.png", NORTHWEST), - list(I["key5"] + "-northeast.png", NORTHEAST)) - else if(I["key4"] == "2") //Dual state icons - filenames = list( - list(I["key5"] + "-north.png", NORTH), - list(I["key5"] + "-east.png", EAST)) - else if(I["key4"] == "4")//All other pipes that need icons - filenames = list( - list(I["key5"] + "-north.png", NORTH), - list(I["key5"] + "-east.png", EAST), - list(I["key5"] + "-south.png", SOUTH), - list(I["key5"] + "-west.png", WEST)) - else - filenames = . - for(F in filenames) - var/icon/iconfile = icon(pipefile, icon_state = I["key5"], dir = F[2]) - usr << browse_rsc(iconfile, F[1]) - for(I in dpipelist) //All disposals pipes have four states so we don't need to bother checking direction - filenames = list( - list(I["key4"] + "-north.png", NORTH), - list(I["key4"] + "-east.png", EAST), - list(I["key4"] + "-south.png", SOUTH), - list(I["key4"] + "-west.png", WEST)) - for(F in filenames) - var/icon/iconfile = icon(disposalsfile, icon_state = I["key4"], dir = F[2]) - usr << browse_rsc(iconfile, F[1]) + filenames += list( + list(pipefile, I["key5"], I["key5"] + "-southeast.png", SOUTHEAST), + list(pipefile, I["key5"], I["key5"] + "-southwest.png", SOUTHWEST), + list(pipefile, I["key5"], I["key5"] + "-northwest.png", NORTHWEST), + list(pipefile, I["key5"], I["key5"] + "-northeast.png", NORTHEAST)) + continue + if(I["key4"] == "2" || I["key4"] == "4") //Dual state icons + filenames += list( + list(pipefile, I["key5"], I["key5"] + "-north.png", NORTH), + list(pipefile, I["key5"], I["key5"] + "-east.png", EAST)) + if(I["key4"] == "4")//All other pipes that need icons + filenames += list( + list(pipefile, I["key5"], I["key5"] + "-south.png", SOUTH), + list(pipefile, I["key5"], I["key5"] + "-west.png", WEST)) + for(I in dpipelist) + if(I["key3"] == "2" || I["key3"] == "4") + filenames += list( + list(disposalsfile, I["key4"], I["key4"] + "-north.png", NORTH), + list(disposalsfile, I["key4"], I["key4"] + "-east.png", EAST)) + if(I["key3"] == "4") + filenames += list( + list(disposalsfile, I["key4"], I["key4"] + "-south.png", SOUTH), + list(disposalsfile, I["key4"], I["key4"] + "-west.png", WEST)) + for(F in filenames) + var/icon/iconfile = icon(F[1], icon_state = F[2], dir = F[4]) + usr << browse_rsc(iconfile, F[3]) initialised = 1 return @@ -167,7 +162,8 @@ var/list/dpipelist = list( if(!ui) ui = new(user, src, ui_key, "rpd.tmpl", "[name]", 600, 650, state = state) ui.open() - Initialiseicons() + if(!initialised) + Initialiseicons() ui.set_auto_update(1) /obj/item/weapon/rpd/ui_data(mob/user, ui_key = "main", datum/topic_state/state = inventory_state) @@ -212,9 +208,8 @@ var/list/dpipelist = list( else if(href_list["mode"]) mode = text2num(href_list["mode"]) else if(href_list["refresh"]) - to_chat(usr, "You press the reset button, refreshing all settings on the [src].") + to_chat(usr, "You press the reset button, refreshing all settings on the [src].") iconrotation = 0 - initialised = 0 mode = 1 pipemenu = 1 pipetype = 1 @@ -231,52 +226,45 @@ var/list/dpipelist = list( /obj/item/weapon/rpd/afterattack(atom/target, mob/user as mob, proximity) var/turf/T = get_turf(target) - if(!proximity) + if(!proximity || cooldown == 1) return - else if(cooldown == 1) - return - else if(!isturf(target) && !istype(target, /obj/item/pipe) && !istype(target, /obj/item/pipe_meter) && !istype(target, /obj/item/pipe_gsensor) && !istype(target, /obj/structure/disposalconstruct)) - return - else if(istype(target, /turf/simulated/shuttle)) + else if(!isturf(target) && !istype(target, /obj/item/pipe) && !istype(target, /obj/item/pipe_meter) && !istype(target, /obj/item/pipe_gsensor) && !istype(target, /obj/structure/disposalconstruct) || istype(target, /turf/simulated/shuttle)) return else if(mode == 1) //Atmos mode if(istype(T, /turf/simulated/wall)) //Drilling into walls takes time and we don't want to do anything else while drilling cooldown = 1 playsound(get_turf(src), "sound/weapons/circsawhit.ogg", 50, 1) - usr.visible_message("[usr] starts drilling a hole in [T]...", "You start drilling a hole in [T]...", "You hear a drill.") + usr.visible_message("[usr] starts drilling a hole in [T]...", "You start drilling a hole in [T]...", "You hear a drill.") if(do_after(usr, walldelay, target = T)) - usr.visible_message("[usr] finishes drilling a hole in [T]!", "You finish drilling a hole in [T]!", "You hear clanking.") + usr.visible_message("[usr] finishes drilling a hole in [T]!", "You finish drilling a hole in [T]!", "You hear clanking.") else cooldown = 0 return if(whatpipe == 98)//need to check if it's a meter or a gas sensor separately ayylmao new /obj/item/pipe_gsensor(T) - to_chat(usr, "[src] dispenses a sensor!") - Activaterpd("sound/machines/click.ogg", 1) - return - if(whatpipe == 99) + to_chat(usr, "[src] dispenses a sensor!") + else if(whatpipe == 99) new /obj/item/pipe_meter(T) - to_chat(usr, "[src] dispenses a meter!") - Activaterpd("sound/machines/click.ogg", 1) - return - var/obj/item/pipe/P = new(T, pipe_type=whatpipe, dir = usr.dir) //Now we make the pipes - if(iconrotation == 0 && Checkifbent(P.pipe_type) == 1) //Automatic rotation of dispensed pipes - P.dir = turn(usr.dir, 135) - else if(iconrotation == 0 && P.pipe_type in list(4, 7, 10, 17, 20, 32, 33, 34, 37)) //Some pipes dispense oppositely to what you'd expect, but we don't want to do anything if they selected a direction - call(P, /obj/item/pipe/verb/flip)() - else if(iconrotation != 0 && Checkifbent(P.pipe_type) == 1) //If they selected a rotation and the pipe is bent - P.dir = turn(iconrotation, -45) - else if(iconrotation != 0) - P.dir = iconrotation - P.update() - to_chat(usr, "[src] rapidly dispenses [P]!") + to_chat(usr, "[src] dispenses a meter!") + else + var/obj/item/pipe/P = new(T, pipe_type=whatpipe, dir = usr.dir) //Now we make the pipes + if(iconrotation == 0 && Checkifbent(P.pipe_type) == 1) //Automatic rotation of dispensed pipes + P.dir = turn(usr.dir, 135) + else if(iconrotation == 0 && P.pipe_type in list(4, 7, 10, 17, 20, 32, 33, 34, 37)) //Some pipes dispense oppositely to what you'd expect, but we don't want to do anything if they selected a direction + call(P, /obj/item/pipe/verb/flip)() + else if(iconrotation != 0 && Checkifbent(P.pipe_type) == 1) //If they selected a rotation and the pipe is bent + P.dir = turn(iconrotation, -45) + else if(iconrotation != 0) + P.dir = iconrotation + P.update() + to_chat(usr, "[src] rapidly dispenses [P]!") Activaterpd("sound/machines/click.ogg", 1) else if(mode == 2) //Disposals mode if(istype(T, /turf/simulated/wall)) - to_chat(usr, "That type of pipe won't fit on [T]!") + to_chat(usr, "That type of pipe won't fit on [T]!") return if(is_blocked_turf(T) == 1 && whatdpipe in list(6, 7, 8))//We need to check if the targetted turf is already dense, in case some goofball sticks 100 bins in front of security or something - to_chat(usr, "You can't dispense that on [T] because something is in the way!") + to_chat(usr, "You can't dispense that on [T] because something is in the way!") return var/obj/structure/disposalconstruct/P = new(T) //Now we make the pipe P.dir = iconrotation @@ -288,7 +276,7 @@ var/list/dpipelist = list( if(iconrotation == 0 && whatdpipe != 2) //Disposals pipes are in the opposite direction to atmos pipes, so we need to flip them. Junctions don't have this quirk though call(P, /obj/structure/disposalconstruct/verb/flip)() P.update() - to_chat(usr, "[src] rapidly dispenses [P]!") + to_chat(usr, "[src] rapidly dispenses [P]!") Activaterpd("sound/machines/click.ogg", 1) return else if(mode == 3) //Rotate mode @@ -306,10 +294,10 @@ var/list/dpipelist = list( qdel(W) eaten = 1 if(eaten == 1) - to_chat(usr, "[src] sucks up the loose pipes on [T]!") + to_chat(usr, "[src] sucks up the loose pipes on [T]!") Activaterpd("sound/items/Deconstruct.ogg", 1) else - to_chat(usr, "There were no loose pipes on [T].") + to_chat(usr, "There were no loose pipes on [T].") return else //Finished. return