From f9ee7ab01be9c9817960848bdcbdc569a364d818 Mon Sep 17 00:00:00 2001 From: hobnob13 Date: Mon, 18 Aug 2008 15:30:55 +0000 Subject: [PATCH] Add missing weldingtool.dm Split /obj/machinery/pump to separate file --- Code/Item/Weapon/weldingtool.dm | 105 ++++++++++++++++++ Code/Machinery/pipes.dm | 187 -------------------------------- Code/Machinery/pump.dm | 186 +++++++++++++++++++++++++++++++ Code/datumvars.dm | 2 +- spacestation13.dme | 10 +- 5 files changed, 294 insertions(+), 196 deletions(-) create mode 100644 Code/Item/Weapon/weldingtool.dm create mode 100644 Code/Machinery/pump.dm diff --git a/Code/Item/Weapon/weldingtool.dm b/Code/Item/Weapon/weldingtool.dm new file mode 100644 index 0000000..a422634 --- /dev/null +++ b/Code/Item/Weapon/weldingtool.dm @@ -0,0 +1,105 @@ +/* + * Weldingtool - used for a variety of purposes, including cutting, burning, etc. + * + * Uses fuel when used, can be refueled at a weldfueltank. + */ + +/obj/item/weapon/weldingtool + name = "weldingtool" + icon_state = "welder" + flags = 322.0 + force = 3.0 + throwforce = 5.0 + throwspeed = 5.0 + w_class = 2.0 + + var/welding = 0 // true if welding (turned on) + var/weldfuel = 20 // number of fuel units left + var/processing = 0 // true if running a process loop + + + // Note: most welding functionality is contained in the attackby() proc of the target atoms + + + // Standard examine proc + + examine() + set src in usr + + usr << "\icon[src] [src.name] contains [src.weldfuel] units of fuel left!" + return + + + // Afterattack - called by atom/DblClick() after calling src.attackby(weapon, user) + // Use up fuel, and turn of welder if no fuel left + + afterattack(obj/O, mob/user) + if (src.welding) + src.weldfuel-- + if (src.weldfuel <= 0) + usr << "\blue Need more fuel!" // no fuel left, so set welder to off state + src.welding = 0 + src.force = 3 + src.damtype = "brute" + src.icon_state = "welder" + var/turf/location = user.loc // also ignite turf if welder was used in plasma + if (!( istype(location, /turf) )) + return + location.firelevel = location.poison + 1 + return + + + // Attack self - toggle between welding and not welding, if there's fuel left. + // Note having the welder on doesn't use fuel, only when it is used on something (pilot light?) + + attack_self(mob/user) + src.welding = !( src.welding ) + if (src.welding) + if (src.weldfuel <= 0) + user << "\blue Need more fuel!" + src.welding = 0 + return 0 + user << "\blue You will now weld when you attack." + src.force = 15 + src.damtype = "fire" + src.icon_state = "welder1" + spawn(0) + process() // run process loop to check for plasma ignition + else + user << "\blue Not welding anymore." + src.force = 3 + src.damtype = "brute" + src.icon_state = "welder" + return + + + // Process loop, spawned when turning on the welding tool + // Every second, check whether we're on a turf or in a mob's hand + // if so, set the local firelevel to the poison level (+1), will ignite any plasma present + // setting "processing" variable prevents multiple loops being started for the same tool. + + proc/process() + + if(processing) // a processing loop is already running, so don't start this one + return // needed so rapidly toggling a welder doesn't start multiple loops + processing = 1 + + while(welding) // repeat while the tool is turned on + + var/turf/location = src.loc // location of the tool + + if(ismob(location)) // if tool in contents of a mob + var/mob/M = location + + if(M.l_hand == src || M.r_hand == src) // if tool in a mob's hand + location = M.loc // update location to mob's location + + // "location" is now turf the tool is on, or turf the mob is on if it's in the mob's hands + // note if the mob is inside something else (closet etc.), location will not be a turf, and fail the next check + + if(isturf(location)) // if located on a turf + location.firelevel = location.poison + 1 // start a fire if plasma present + + sleep(10) // sleep for 1 second + + processing = 0 // tool has stopped welding, so exit the loop \ No newline at end of file diff --git a/Code/Machinery/pipes.dm b/Code/Machinery/pipes.dm index d3eab45..a032ea7 100644 --- a/Code/Machinery/pipes.dm +++ b/Code/Machinery/pipes.dm @@ -390,190 +390,3 @@ obj/machinery/pipes density = 1 capacity = 1.8E7 - -obj/machinery/pump - name = "Gas Pump" - desc = "A gas pump" - icon = 'pipes.dmi' - icon_state = "one-way" - anchored = 1 - density = 0 - capmult = 1 - - var - status = 0 // 0 = off, 1 = on - rate = 400000 - maxrate = 1e22 - - obj/substance/gas/gas1 = null - obj/substance/gas/ngas1 = null - - obj/substance/gas/gas2 = null - obj/substance/gas/ngas2 = null - - capacity = 1e22 - - obj/machinery/node1 = null // the physical pipe object to the south - obj/machinery/node2 = null // the physical pipe object to the north - - obj/machinery/vnode1 // the pipeline object - obj/machinery/vnode2 // the pipeline object - - - New() - ..() - gas1 = new/obj/substance/gas(src) - gas1.maximum = capacity - gas2 = new/obj/substance/gas(src) - gas2.maximum = capacity - - ngas1 = new/obj/substance/gas() - ngas2 = new/obj/substance/gas() - - gasflowlist += src - - proc/update() - p_dir = text2num(icon_state) - - buildnodes() - var/turf/n1 - var/turf/n2 - if (src.dir == 1) - n1 = get_step(src, SOUTH) - n2 = get_step(src, NORTH) - if (src.dir == 8) - n1 = get_step(src, EAST) - n2 = get_step(src, WEST) - if (src.dir == 2) - n1 = get_step(src, NORTH) - n2 = get_step(src, SOUTH) - if (src.dir == 4) - n1 = get_step(src, WEST) - n2 = get_step(src, EAST) - for(var/obj/machinery/M in n1) - -// if(M && (M.p_dir & 1)) - node1 = M - break - - for(var/obj/machinery/M in n2) - -// if(M && (M.p_dir & 2)) - node2 = M - break - - - if(node1) vnode1 = node1.getline() - - if(node2) vnode2 = node2.getline() - - - -/* proc/control(var/on, var/prate) - - rate = prate/100*maxrate - - if(status == 1) - if(!on) - status = 2 - spawn(30) - if(status == 2) //Most of the pump code is shamefully swiped and hacked from circulators :p - status = 0 -// updateicon() - else if(status == 0) - if(on) - status = 1 - else // status ==2 - if(on) - status = 1*/ - - - - - gas_flow() - - gas1.replace_by(ngas1) - gas2.replace_by(ngas2) - - - - process() - - if(! (stat & NOPOWER) ) - if(status==1 || status==2) - gas2.transfer_from(gas1, 1e22) - use_power(rate/capacity * 100) - ngas1.replace_by(gas1) - ngas2.replace_by(gas2) - - - // now do standard gas flow process - - var/delta_gt - - if(vnode1) - delta_gt = FLOWFRAC * ( vnode1.get_gas_val(src) - gas1.tot_gas() / capmult) - calc_delta( src, gas1, ngas1, vnode1, delta_gt) - else - leak_to_turf(1) - - if(vnode2) - delta_gt = FLOWFRAC * ( vnode2.get_gas_val(src) - gas2.tot_gas() / capmult) - calc_delta( src, gas2, ngas2, vnode2, delta_gt) - else - leak_to_turf(2) - - - // If nothing connected to either pipe node, leak the gas to the turf instead - - proc/leak_to_turf(var/port) - - var/turf/T - - switch(port) - if(1) - T = get_step(src, SOUTH) - if(2) - T = get_step(src, NORTH) - - if(T.density) - T = src.loc - if(T.density) - return - - switch(port) - if(1) - flow_to_turf(gas1, ngas1, T) - if(2) - flow_to_turf(gas2, ngas2, T) - - - // Get the current gas fill level. Note since we have two reservoirs, value depends on which node is enquiring - - get_gas_val(from) - - if(from == vnode1) - return gas1.tot_gas()/capmult - else - return gas2.tot_gas()/capmult - - - // Get the gas reservoir object connected to node "from" - - get_gas(from) - - if(from == vnode1) - return gas1 - else - return gas2 - - attack_hand(var/mob/user) - - if (src.status == 0) - user.show_message("\blue You activate the pump") - src.status = 1 - src.rate = 1e22 - else - user.show_message("\blue You deactivate the pump") - src.status = 0 - src.rate = 400000 diff --git a/Code/Machinery/pump.dm b/Code/Machinery/pump.dm new file mode 100644 index 0000000..b76f339 --- /dev/null +++ b/Code/Machinery/pump.dm @@ -0,0 +1,186 @@ +obj/machinery/pump + name = "Gas Pump" + desc = "A gas pump" + icon = 'pipes.dmi' + icon_state = "one-way" + anchored = 1 + density = 0 + capmult = 1 + + var + status = 0 // 0 = off, 1 = on + rate = 400000 + maxrate = 1e22 + + obj/substance/gas/gas1 = null + obj/substance/gas/ngas1 = null + + obj/substance/gas/gas2 = null + obj/substance/gas/ngas2 = null + + capacity = 1e22 + + obj/machinery/node1 = null // the physical pipe object to the south + obj/machinery/node2 = null // the physical pipe object to the north + + obj/machinery/vnode1 // the pipeline object + obj/machinery/vnode2 // the pipeline object + + + New() + ..() + gas1 = new/obj/substance/gas(src) + gas1.maximum = capacity + gas2 = new/obj/substance/gas(src) + gas2.maximum = capacity + + ngas1 = new/obj/substance/gas() + ngas2 = new/obj/substance/gas() + + gasflowlist += src + + proc/update() + p_dir = text2num(icon_state) + + buildnodes() + var/turf/n1 + var/turf/n2 + if (src.dir == 1) + n1 = get_step(src, SOUTH) + n2 = get_step(src, NORTH) + if (src.dir == 8) + n1 = get_step(src, EAST) + n2 = get_step(src, WEST) + if (src.dir == 2) + n1 = get_step(src, NORTH) + n2 = get_step(src, SOUTH) + if (src.dir == 4) + n1 = get_step(src, WEST) + n2 = get_step(src, EAST) + for(var/obj/machinery/M in n1) + +// if(M && (M.p_dir & 1)) + node1 = M + break + + for(var/obj/machinery/M in n2) + +// if(M && (M.p_dir & 2)) + node2 = M + break + + + if(node1) vnode1 = node1.getline() + + if(node2) vnode2 = node2.getline() + + + +/* proc/control(var/on, var/prate) + + rate = prate/100*maxrate + + if(status == 1) + if(!on) + status = 2 + spawn(30) + if(status == 2) //Most of the pump code is shamefully swiped and hacked from circulators :p + status = 0 +// updateicon() + else if(status == 0) + if(on) + status = 1 + else // status ==2 + if(on) + status = 1*/ + + + + + gas_flow() + + gas1.replace_by(ngas1) + gas2.replace_by(ngas2) + + + + process() + + if(! (stat & NOPOWER) ) + if(status==1 || status==2) + gas2.transfer_from(gas1, 1e22) + use_power(rate/capacity * 100) + ngas1.replace_by(gas1) + ngas2.replace_by(gas2) + + + // now do standard gas flow process + + var/delta_gt + + if(vnode1) + delta_gt = FLOWFRAC * ( vnode1.get_gas_val(src) - gas1.tot_gas() / capmult) + calc_delta( src, gas1, ngas1, vnode1, delta_gt) + else + leak_to_turf(1) + + if(vnode2) + delta_gt = FLOWFRAC * ( vnode2.get_gas_val(src) - gas2.tot_gas() / capmult) + calc_delta( src, gas2, ngas2, vnode2, delta_gt) + else + leak_to_turf(2) + + + // If nothing connected to either pipe node, leak the gas to the turf instead + + proc/leak_to_turf(var/port) + + var/turf/T + + switch(port) + if(1) + T = get_step(src, SOUTH) + if(2) + T = get_step(src, NORTH) + + if(T.density) + T = src.loc + if(T.density) + return + + switch(port) + if(1) + flow_to_turf(gas1, ngas1, T) + if(2) + flow_to_turf(gas2, ngas2, T) + + + // Get the current gas fill level. Note since we have two reservoirs, value depends on which node is enquiring + + get_gas_val(from) + + if(from == vnode1) + return gas1.tot_gas()/capmult + else + return gas2.tot_gas()/capmult + + + // Get the gas reservoir object connected to node "from" + + get_gas(from) + + if(from == vnode1) + return gas1 + else + return gas2 + + attack_hand(var/mob/user) + + if (src.status == 0) + user.show_message("\blue You activate the pump") + src.status = 1 + src.rate = 1e22 + else + user.show_message("\blue You deactivate the pump") + src.status = 0 + src.rate = 400000 diff --git a/Code/datumvars.dm b/Code/datumvars.dm index 92adffe..cc35b66 100644 --- a/Code/datumvars.dm +++ b/Code/datumvars.dm @@ -45,7 +45,7 @@ #ifdef VARSICON var/rnd = rand(1,10000) // use random number in filename to avoid conflicts - user:client_mob() << browse_rsc(val, "tmp\ref[val][rnd].png") // precache the icon image file + user << browse_rsc(val, "tmp\ref[val][rnd].png") // precache the icon image file t+="" // and add the icon to the HTML #endif diff --git a/spacestation13.dme b/spacestation13.dme index 677a298..a844fb7 100644 --- a/spacestation13.dme +++ b/spacestation13.dme @@ -3,12 +3,6 @@ // New source code should be placed in .dm files: choose File/New --> Code File. // BEGIN_INTERNALS -/* -FILE: Code\Machinery\Door\airlock.dm -DIR: Code Code\CTF Code\Effects Code\Item Code\Item\Weapon Code\Machinery Code\Machinery\Atmoalter Code\Machinery\Computer Code\Machinery\Door Code\Machinery\Power Code\mob -MAP_ICON_TYPE: 0 -AUTO_FILE_DIR: ON -*/ // END_INTERNALS // BEGIN_FILE_DIR #define FILE_DIR . @@ -25,11 +19,10 @@ AUTO_FILE_DIR: ON #define FILE_DIR "Code/mob" #define FILE_DIR "Icons" #define FILE_DIR "Interface" -#define FILE_DIR "players" -#define FILE_DIR "supporting-docs" // END_FILE_DIR // BEGIN_PREFERENCES +#define DEBUG // END_PREFERENCES // BEGIN_INCLUDE @@ -103,6 +96,7 @@ AUTO_FILE_DIR: ON #include "Code\Machinery\pipeline.dm" #include "Code\Machinery\pipes.dm" #include "Code\Machinery\pod.dm" +#include "Code\Machinery\pump.dm" #include "Code\Machinery\recharger.dm" #include "Code\Machinery\recon.dm" #include "Code\Machinery\sec_lock.dm"