From 2bfce70376b8b469a4b2d6e97f1794b430cfc439 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Mon, 24 Nov 2014 09:17:22 +0100 Subject: [PATCH 1/6] Autolathe wiring. --- baystation12.dme | 1 + code/datums/wires/autolathe.dm | 60 ++++++++++ code/game/machinery/autolathe.dm | 188 +++++++++---------------------- 3 files changed, 114 insertions(+), 135 deletions(-) create mode 100644 code/datums/wires/autolathe.dm diff --git a/baystation12.dme b/baystation12.dme index 98342a0dea2..800d7cb44a7 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -167,6 +167,7 @@ #include "code\datums\wires\airlock.dm" #include "code\datums\wires\alarm.dm" #include "code\datums\wires\apc.dm" +#include "code\datums\wires\autolathe.dm" #include "code\datums\wires\camera.dm" #include "code\datums\wires\robot.dm" #include "code\datums\wires\smartfridge.dm" diff --git a/code/datums/wires/autolathe.dm b/code/datums/wires/autolathe.dm new file mode 100644 index 00000000000..1dd4132e481 --- /dev/null +++ b/code/datums/wires/autolathe.dm @@ -0,0 +1,60 @@ +/datum/wires/autolathe + + holder_type = /obj/machinery/autolathe + wire_count = 6 + +var/const/AUTOLATHE_HACK_WIRE = 1 +var/const/AUTOLATHE_SHOCK_WIRE = 2 +var/const/AUTOLATHE_DISABLE_WIRE = 4 + +/datum/wires/autolathe/GetInteractWindow() + var/obj/machinery/autolathe/A = holder + . += ..() + . += "
The red light is [A.disabled ? "off" : "on"]." + . += "
The green light is [A.shocked ? "off" : "on"]." + . += "
The blue light is [A.hacked ? "off" : "on"].
" + +/datum/wires/autolathe/CanUse() + var/obj/machinery/autolathe/A = holder + if(A.panel_open) + return 1 + return 0 + +/datum/wires/autolathe/Interact(var/mob/living/user) + if(CanUse(user)) + var/obj/machinery/autolathe/V = holder + V.attack_hand(user) + +/datum/wires/autolathe/UpdateCut(index, mended) + var/obj/machinery/autolathe/A = holder + switch(index) + if(AUTOLATHE_HACK_WIRE) + A.hacked = !mended + if(AUTOLATHE_SHOCK_WIRE) + A.shocked = !mended + if(AUTOLATHE_DISABLE_WIRE) + A.disabled = !mended + +/datum/wires/autolathe/UpdatePulsed(index) + if(IsIndexCut(index)) + return + var/obj/machinery/autolathe/A = holder + switch(index) + if(AUTOLATHE_HACK_WIRE) + A.hacked = !A.hacked + spawn(50) + if(A && !IsIndexCut(index)) + A.hacked = 0 + Interact(usr) + if(AUTOLATHE_SHOCK_WIRE) + A.shocked = !A.shocked + spawn(50) + if(A && !IsIndexCut(index)) + A.shocked = 0 + Interact(usr) + if(AUTOLATHE_DISABLE_WIRE) + A.disabled = !A.disabled + spawn(50) + if(A && !IsIndexCut(index)) + A.disabled = 0 + Interact(usr) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 6752128279b..6f27a86f949 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -12,16 +12,13 @@ var/list/storage_capacity = list("metal" = 0, "glass" = 0) var/show_category = "All" - var/opened = 0 + var/panel_open = 0 var/hacked = 0 var/disabled = 0 var/shocked = 0 var/busy = 0 - var/list/wires = list() - var/hack_wire - var/disable_wire - var/shock_wire + var/datum/wires/autolathe/wires = null /obj/machinery/autolathe/interact(mob/user as mob) @@ -33,69 +30,64 @@ var/dat = "

Autolathe Control Panel


" - dat += "" - var/material_top = "" - var/material_bottom = "" + if(!panel_open) + dat += "
" + var/material_top = "" + var/material_bottom = "" - for(var/material in stored_material) - material_top += "" - material_bottom += "" + for(var/material in stored_material) + material_top += "" + material_bottom += "" - dat += "[material_top][material_bottom]
[material][stored_material[material]]/[storage_capacity[material]][material][stored_material[material]]/[storage_capacity[material]]

" - dat += "

Printable Designs

Showing: [show_category].

" + dat += "[material_top][material_bottom]

" + dat += "

Printable Designs

Showing: [show_category].

" - var/index = 0 - for(var/datum/autolathe/recipe/R in autolathe_recipes) - index++ - if(R.hidden && !hacked || (show_category != "All" && show_category != R.category)) - continue + var/index = 0 + for(var/datum/autolathe/recipe/R in autolathe_recipes) + index++ + if(R.hidden && !hacked || (show_category != "All" && show_category != R.category)) + continue - var/can_make = 1 - var/material_string = "" - var/multiplier_string = "" - var/max_sheets + var/can_make = 1 + var/material_string = "" + var/multiplier_string = "" + var/max_sheets - var/comma - if(!R.resources || !R.resources.len) - material_string = "No resources required." - else + var/comma + if(!R.resources || !R.resources.len) + material_string = "No resources required." + else - //Make sure it's buildable and list requires resources. - for(var/material in R.resources) - var/sheets = round(stored_material[material]/R.resources[material]) - if(isnull(max_sheets) || max_sheets > sheets) - max_sheets = sheets + //Make sure it's buildable and list requires resources. + for(var/material in R.resources) + var/sheets = round(stored_material[material]/R.resources[material]) + if(isnull(max_sheets) || max_sheets > sheets) + max_sheets = sheets - if(!isnull(stored_material[material]) && stored_material[material] < R.resources[material]) - can_make = 0 - if(!comma) - comma = 1 - else - material_string += ", " - material_string += "[R.resources[material]] [material]" - material_string += ".
" + if(!isnull(stored_material[material]) && stored_material[material] < R.resources[material]) + can_make = 0 + if(!comma) + comma = 1 + else + material_string += ", " + material_string += "[R.resources[material]] [material]" + material_string += ".
" - //Build list of multipliers for sheets. - if(R.is_stack) - if(max_sheets && max_sheets > 0) - multiplier_string += "
" - for(var/i = 5;i 0) + multiplier_string += "
" + for(var/i = 5;i*" : ""][can_make ? "" : ""][R.name][can_make ? "" : ""][R.hidden ? "*" : ""][multiplier_string]
" - - dat += "
[material_string]

" + dat += "[R.hidden ? "*" : ""][can_make ? "" : ""][R.name][can_make ? "" : ""][R.hidden ? "*" : ""][multiplier_string][material_string]" + dat += "
" //Hacking. - if(opened) + else dat += "

Maintenance Panel

" - for(var/wire in wires) - dat += "[wire] Wire: [wires[wire] ? "Mend" : "Cut"] Pulse
" - dat += "
" - dat += "The red light is [disabled ? "off" : "on"].
" - dat += "The green light is [shocked ? "off" : "on"].
" - dat += "The blue light is [hacked ? "off" : "on"].
" + dat += wires.GetInteractWindow() dat += "
" @@ -112,13 +104,13 @@ return if(istype(O, /obj/item/weapon/screwdriver)) - opened = !opened - icon_state = (opened ? "autolathe_t": "autolathe") - user << "You [opened ? "open" : "close"] the maintenance hatch of [src]." + panel_open = !panel_open + icon_state = (panel_open ? "autolathe_t": "autolathe") + user << "You [panel_open ? "open" : "close"] the maintenance hatch of [src]." updateUsrDialog() return - if (opened) + if (panel_open) //Don't eat multitools or wirecutters used on an open lathe. if(istype(O, /obj/item/device/multitool) || istype(O, /obj/item/weapon/wirecutters)) attack_hand(user) @@ -253,65 +245,13 @@ var/obj/item/stack/S = I S.amount = multiplier - if(href_list["act"]) - - var/temp_wire = href_list["wire"] - if(href_list["act"] == "pulse") - - if (!istype(usr.get_active_hand(), /obj/item/device/multitool)) - usr << "You need a multitool!" - return - - if(wires[temp_wire]) - usr << "You can't pulse a cut wire." - return - - if(hack_wire == temp_wire) - hacked = !hacked - - spawn(100) - hacked = !hacked - - if(disable_wire == temp_wire) - disabled = !disabled - shock(usr,50) - - spawn(100) - disabled = !disabled - - if(shock_wire == temp_wire) - shocked = !shocked - shock(usr,50) - - spawn(100) - shocked = !shocked - - else if(href_list["act"] == "wire") - - if (!istype(usr.get_active_hand(), /obj/item/weapon/wirecutters)) - usr << "You need wirecutters!" - return - - wires[temp_wire] = !wires[temp_wire] - - if(hack_wire == temp_wire) - hacked = !hacked - - if(disable_wire == temp_wire) - disabled = !disabled - shock(usr,50) - - if(shock_wire == temp_wire) - shocked = !shocked - shock(usr,50) - updateUsrDialog() /obj/machinery/autolathe/New() ..() - + wires = new(src) //Create global autolathe recipe list if it hasn't been made already. if(isnull(autolathe_recipes)) autolathe_recipes = list() @@ -339,28 +279,6 @@ component_parts += new /obj/item/weapon/stock_parts/console_screen(src) RefreshParts() - //Init wires. - wires = list( - "Light Red" = 0, - "Dark Red" = 0, - "Blue" = 0, - "Green" = 0, - "Yellow" = 0, - "Black" = 0, - "White" = 0, - "Gray" = 0, - "Orange" = 0, - "Pink" = 0 - ) - - //Randomize wires. - var/list/w = list("Light Red","Dark Red","Blue","Green","Yellow","Black","White","Gray","Orange","Pink") - hack_wire = pick(w) - w -= hack_wire - shock_wire = pick(w) - w -= shock_wire - disable_wire = pick(w) - w -= disable_wire //Updates overall lathe storage size. /obj/machinery/autolathe/RefreshParts() From 2d832b19cd3288ef93e51b860037f51d98aadc9f Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Mon, 24 Nov 2014 09:50:19 +0100 Subject: [PATCH 2/6] Mulebot wiring. --- baystation12.dme | 1 + code/datums/wires/mulebot.dm | 65 ++++++++++++++++ code/game/machinery/bots/mulebot.dm | 116 ++++------------------------ 3 files changed, 82 insertions(+), 100 deletions(-) create mode 100644 code/datums/wires/mulebot.dm diff --git a/baystation12.dme b/baystation12.dme index 800d7cb44a7..30fd134ba5f 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -169,6 +169,7 @@ #include "code\datums\wires\apc.dm" #include "code\datums\wires\autolathe.dm" #include "code\datums\wires\camera.dm" +#include "code\datums\wires\mulebot.dm" #include "code\datums\wires\robot.dm" #include "code\datums\wires\smartfridge.dm" #include "code\datums\wires\suit_storage_unit.dm" diff --git a/code/datums/wires/mulebot.dm b/code/datums/wires/mulebot.dm new file mode 100644 index 00000000000..312e6dd7d9a --- /dev/null +++ b/code/datums/wires/mulebot.dm @@ -0,0 +1,65 @@ +/datum/wires/mulebot + random = 1 + holder_type = /obj/machinery/bot/mulebot + wire_count = 10 + +var/const/WIRE_POWER1 = 1 // power connections +var/const/WIRE_POWER2 = 2 +var/const/WIRE_AVOIDANCE = 4 // mob avoidance +var/const/WIRE_LOADCHECK = 8 // load checking (non-crate) +var/const/WIRE_MOTOR1 = 16 // motor wires +var/const/WIRE_MOTOR2 = 32 // +var/const/WIRE_REMOTE_RX = 64 // remote recv functions +var/const/WIRE_REMOTE_TX = 128 // remote trans status +var/const/WIRE_BEACON_RX = 256 // beacon ping recv + +/datum/wires/mulebot/CanUse(var/mob/living/L) + var/obj/machinery/bot/mulebot/M = holder + if(M.open) + return 1 + return 0 + +// So the wires do not open a new window, handle the interaction ourselves. +/datum/wires/mulebot/Interact(var/mob/living/user) + if(CanUse(user)) + var/obj/machinery/bot/mulebot/M = holder + M.interact(user) + +/datum/wires/mulebot/UpdatePulsed(var/index) + switch(index) + if(WIRE_POWER1, WIRE_POWER2) + holder.visible_message("\icon[holder] The charge light flickers.") + if(WIRE_AVOIDANCE) + holder.visible_message("\icon[holder] The external warning lights flash briefly.") + if(WIRE_LOADCHECK) + holder.visible_message("\icon[holder] The load platform clunks.") + if(WIRE_MOTOR1, WIRE_MOTOR2) + holder.visible_message("\icon[holder] The drive motor whines briefly.") + else + holder.visible_message("\icon[holder] You hear a radio crackle.") + +// HELPER PROCS + +/datum/wires/mulebot/proc/Motor1() + return !(wires_status & WIRE_MOTOR1) + +/datum/wires/mulebot/proc/Motor2() + return !(wires_status & WIRE_MOTOR2) + +/datum/wires/mulebot/proc/HasPower() + return !(wires_status & WIRE_POWER1) && !(wires_status & WIRE_POWER2) + +/datum/wires/mulebot/proc/LoadCheck() + return !(wires_status & WIRE_LOADCHECK) + +/datum/wires/mulebot/proc/MobAvoid() + return !(wires_status & WIRE_AVOIDANCE) + +/datum/wires/mulebot/proc/RemoteTX() + return !(wires_status & WIRE_REMOTE_TX) + +/datum/wires/mulebot/proc/RemoteRX() + return !(wires_status & WIRE_REMOTE_RX) + +/datum/wires/mulebot/proc/BeaconRX() + return !(wires_status & WIRE_BEACON_RX) diff --git a/code/game/machinery/bots/mulebot.dm b/code/game/machinery/bots/mulebot.dm index 0ff1bec2775..a2436f9de41 100644 --- a/code/game/machinery/bots/mulebot.dm +++ b/code/game/machinery/bots/mulebot.dm @@ -51,27 +51,13 @@ // the installed power cell // constants for internal wiring bitflags - var/const/wire_power1 = 1 // power connections - var/const/wire_power2 = 2 - var/const/wire_mobavoid = 4 // mob avoidance - var/const/wire_loadcheck = 8 // load checking (non-crate) - var/const/wire_motor1 = 16 // motor wires - var/const/wire_motor2 = 32 // - var/const/wire_remote_rx = 64 // remote recv functions - var/const/wire_remote_tx = 128 // remote trans status - var/const/wire_beacon_rx = 256 // beacon ping recv - var/const/wire_beacon_tx = 512 // beacon ping trans - - var/wires = 1023 // all flags on - - var/list/wire_text // list of wire colours - var/list/wire_order // order of wire indices - + var/datum/wires/mulebot/wires = null var/bloodiness = 0 // count of bloodiness /obj/machinery/bot/mulebot/New() ..() + wires = new(src) botcard = new(src) var/datum/job/cargo_tech/J = new/datum/job/cargo_tech botcard.access = J.get_access() @@ -79,7 +65,6 @@ cell = new(src) cell.charge = 2000 cell.maxcharge = 2000 - setup_wires() spawn(5) // must wait for map loading to finish if(radio_controller) @@ -93,27 +78,6 @@ suffix = "#[count]" name = "Mulebot ([suffix])" - - -// set up the wire colours in random order -// and the random wire display order -// needs 10 wire colours -/obj/machinery/bot/mulebot/proc/setup_wires() - var/list/colours = list("Red", "Green", "Blue", "Magenta", "Cyan", "Yellow", "Black", "White", "Orange", "Grey") - var/list/orders = list("0","1","2","3","4","5","6","7","8","9") - wire_text = list() - wire_order = list() - while(colours.len > 0) - var/colour = colours[ rand(1,colours.len) ] - wire_text += colour - colours -= colour - - var/order = orders[ rand(1,orders.len) ] - wire_order += text2num(order) - orders -= order - - - // attack by item // emag : lock/unlock, // screwdriver: open/close hatch @@ -260,7 +224,7 @@ else dat += "Removed
" - dat += wires() + dat += wires.GetInteractWindow() else dat += "The bot is in maintenance mode and cannot be controlled.
" @@ -268,22 +232,6 @@ onclose(user, "mulebot") return -// returns the wire panel text -/obj/machinery/bot/mulebot/proc/wires() - var/t = "" - for(var/i = 0 to 9) - var/index = 1<0 && (wires & wire_power1) && (wires & wire_power2) + return !open && cell && cell.charge>0 && wires.HasPower() // mousedrop a crate to load the bot // can load anything if emagged @@ -457,7 +373,7 @@ // called to load a crate /obj/machinery/bot/mulebot/proc/load(var/atom/movable/C) - if((wires & wire_loadcheck) && !istype(C,/obj/structure/closet/crate)) + if(wires.LoadCheck() && !istype(C,/obj/structure/closet/crate)) src.visible_message("[src] makes a sighing buzz.", "You hear an electronic buzzing sound.") playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0) return // if not emagged, only allow crates to be loaded @@ -555,7 +471,7 @@ on = 0 return if(on) - var/speed = ((wires & wire_motor1) ? 1:0) + ((wires & wire_motor2) ? 2:0) + var/speed = (wires.Motor1() ? 1:0) + (wires.Motor2() ? 2:0) //world << "speed: [speed]" switch(speed) if(0) @@ -724,7 +640,7 @@ mode = 3 else mode = 2 - icon_state = "mulebot[(wires & wire_mobavoid) == wire_mobavoid]" + icon_state = "mulebot[wires.MobAvoid()]" // starts bot moving to home // sends a beacon query to find @@ -732,7 +648,7 @@ spawn(0) set_destination(home_destination) mode = 4 - icon_state = "mulebot[(wires & wire_mobavoid) == wire_mobavoid]" + icon_state = "mulebot[wires.MobAvoid()]" // called when bot reaches current target /obj/machinery/bot/mulebot/proc/at_target() @@ -747,7 +663,7 @@ // not loaded if(auto_pickup) // find a crate var/atom/movable/AM - if(!(wires & wire_loadcheck)) // if emagged, load first unanchored thing we find + if(!wires.LoadCheck()) // if emagged, load first unanchored thing we find for(var/atom/movable/A in get_step(loc, loaddir)) if(!A.anchored) AM = A @@ -771,7 +687,7 @@ // called when bot bumps into anything /obj/machinery/bot/mulebot/Bump(var/atom/obs) - if(!(wires & wire_mobavoid)) //usually just bumps, but if avoidance disabled knock over mobs + if(!wires.MobAvoid()) //usually just bumps, but if avoidance disabled knock over mobs var/mob/M = obs if(ismob(M)) if(istype(M,/mob/living/silicon/robot)) @@ -828,12 +744,12 @@ */ var/recv = signal.data["command"] // process all-bot input - if(recv=="bot_status" && (wires & wire_remote_rx)) + if(recv=="bot_status" && wires.RemoteRX()) send_status() recv = signal.data["command [suffix]"] - if(wires & wire_remote_rx) + if(wires.RemoteRX()) // process control input switch(recv) if("stop") @@ -873,7 +789,7 @@ // receive response from beacon recv = signal.data["beacon"] - if(wires & wire_beacon_rx) + if(wires.BeaconRX()) if(recv == new_destination) // if the recvd beacon location matches the set destination // the we will navigate there destination = new_destination @@ -883,7 +799,7 @@ loaddir = text2num(direction) else loaddir = 0 - icon_state = "mulebot[(wires & wire_mobavoid) == wire_mobavoid]" + icon_state = "mulebot[wires.MobAvoid()]" calc_path() updateDialog() @@ -894,9 +810,9 @@ // send a radio signal with multiple data key/values /obj/machinery/bot/mulebot/proc/post_signal_multiple(var/freq, var/list/keyval) - if(freq == beacon_freq && !(wires & wire_beacon_tx)) + if(freq == beacon_freq && !wires.BeaconRX()) return - if(freq == control_freq && !(wires & wire_remote_tx)) + if(freq == control_freq && !wires.RemoteTX()) return var/datum/radio_frequency/frequency = radio_controller.return_frequency(freq) From bf24d288eaf9936a1fd928af09e30ce45dc112d8 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Mon, 24 Nov 2014 10:06:19 +0100 Subject: [PATCH 3/6] Particle acceleration wiring. --- baystation12.dme | 1 + code/datums/wires/particle_accelerator.dm | 52 ++++++++++++ .../particle_accelerator/particle_control.dm | 79 +++++++++++-------- 3 files changed, 98 insertions(+), 34 deletions(-) create mode 100644 code/datums/wires/particle_accelerator.dm diff --git a/baystation12.dme b/baystation12.dme index 30fd134ba5f..e2e743d39a9 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -170,6 +170,7 @@ #include "code\datums\wires\autolathe.dm" #include "code\datums\wires\camera.dm" #include "code\datums\wires\mulebot.dm" +#include "code\datums\wires\particle_accelerator.dm" #include "code\datums\wires\robot.dm" #include "code\datums\wires\smartfridge.dm" #include "code\datums\wires\suit_storage_unit.dm" diff --git a/code/datums/wires/particle_accelerator.dm b/code/datums/wires/particle_accelerator.dm new file mode 100644 index 00000000000..83562386922 --- /dev/null +++ b/code/datums/wires/particle_accelerator.dm @@ -0,0 +1,52 @@ +/datum/wires/particle_acc/control_box + wire_count = 5 + holder_type = /obj/machinery/particle_accelerator/control_box + +var/const/PARTICLE_TOGGLE_WIRE = 1 // Toggles whether the PA is on or not. +var/const/PARTICLE_STRENGTH_WIRE = 2 // Determines the strength of the PA. +var/const/PARTICLE_INTERFACE_WIRE = 4 // Determines the interface showing up. +var/const/PARTICLE_LIMIT_POWER_WIRE = 8 // Determines how strong the PA can be. +//var/const/PARTICLE_NOTHING_WIRE = 16 // Blank wire + +/datum/wires/particle_acc/control_box/CanUse(var/mob/living/L) + var/obj/machinery/particle_accelerator/control_box/C = holder + if(C.construction_state == 2) + return 1 + return 0 + +/datum/wires/particle_acc/control_box/UpdatePulsed(var/index) + var/obj/machinery/particle_accelerator/control_box/C = holder + switch(index) + + if(PARTICLE_TOGGLE_WIRE) + C.toggle_power() + + if(PARTICLE_STRENGTH_WIRE) + C.add_strength() + + if(PARTICLE_INTERFACE_WIRE) + C.interface_control = !C.interface_control + + if(PARTICLE_LIMIT_POWER_WIRE) + C.visible_message("\icon[C][C] makes a large whirring noise.") + +/datum/wires/particle_acc/control_box/UpdateCut(var/index, var/mended) + var/obj/machinery/particle_accelerator/control_box/C = holder + switch(index) + + if(PARTICLE_TOGGLE_WIRE) + if(C.active == !mended) + C.toggle_power() + + if(PARTICLE_STRENGTH_WIRE) + + for(var/i = 1; i < 3; i++) + C.remove_strength() + + if(PARTICLE_INTERFACE_WIRE) + C.interface_control = mended + + if(PARTICLE_LIMIT_POWER_WIRE) + C.strength_upper_limit = (mended ? 2 : 3) + if(C.strength_upper_limit < C.strength) + C.remove_strength() diff --git a/code/modules/power/singularity/particle_accelerator/particle_control.dm b/code/modules/power/singularity/particle_accelerator/particle_control.dm index 0ae6a5c3bb4..5b30c000c70 100644 --- a/code/modules/power/singularity/particle_accelerator/particle_control.dm +++ b/code/modules/power/singularity/particle_accelerator/particle_control.dm @@ -14,11 +14,15 @@ construction_state = 0 active = 0 dir = 1 + var/strength_upper_limit = 2 + var/interface_control = 1 var/list/obj/structure/particle_accelerator/connected_parts var/assembled = 0 var/parts = null + var/datum/wires/particle_acc/control_box/wires = null /obj/machinery/particle_accelerator/control_box/New() + wires = new(src) connected_parts = list() active_power_usage = initial(active_power_usage) * (strength + 1) ..() @@ -27,6 +31,8 @@ /obj/machinery/particle_accelerator/control_box/attack_hand(mob/user as mob) if(construction_state >= 3) interact(user) + else if(construction_state == 2) // Wires exposed + wires.Interact(user) /obj/machinery/particle_accelerator/control_box/update_state() if(construction_state < 3) @@ -79,49 +85,51 @@ usr << browse(null, "window=pacontrol") usr.unset_machine() return + if(href_list["togglep"]) - src.toggle_power() - investigate_log("turned [active?"ON":"OFF"] by [usr.key]","singulo") - if (active) - message_admins("PA Control Computer turned ON by [key_name(usr, usr.client)](?) in ([x],[y],[z] - JMP)",0,1) - log_game("PA Control Computer turned ON by [usr.ckey]([usr]) in ([x],[y],[z])") + if(!wires.IsIndexCut(PARTICLE_TOGGLE_WIRE)) + src.toggle_power() else if(href_list["scan"]) src.part_scan() + else if(href_list["strengthup"]) - var/old_strength = strength - strength++ - if(strength > 2) - strength = 2 - else - message_admins("PA Control Computer increased to [strength] by [key_name(usr, usr.client)](?) in ([x],[y],[z] - JMP)",0,1) - log_game("PA Control Computer increased to [strength] by [usr.ckey]([usr]) in ([x],[y],[z])") - investigate_log("increased to [strength] by [usr.key]","singulo") - for(var/obj/structure/particle_accelerator/part in connected_parts) - part.strength = strength - part.update_icon() - - if (strength != old_strength) - active_power_usage = initial(active_power_usage) * (strength + 1) - use_power(0) //update power usage + if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE)) + add_strength() else if(href_list["strengthdown"]) - var/old_strength = strength - strength-- - if(strength < 0) - strength = 0 - else - investigate_log("decreased to [strength] by [usr.key]","singulo") - for(var/obj/structure/particle_accelerator/part in connected_parts) - part.strength = strength - part.update_icon() - - if (strength != old_strength) - active_power_usage = initial(active_power_usage) * (strength + 1) - use_power(0) //update power usage + if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE)) + remove_strength() + src.updateDialog() src.update_icon() return +/obj/machinery/particle_accelerator/control_box/proc/strength_change() + for(var/obj/structure/particle_accelerator/part in connected_parts) + part.strength = strength + part.update_icon() + +/obj/machinery/particle_accelerator/control_box/proc/add_strength(var/s) + if(assembled) + strength++ + if(strength > strength_upper_limit) + strength = strength_upper_limit + else + message_admins("PA Control Computer increased to [strength] by [key_name(usr, usr.client)](?) in ([x],[y],[z] - JMP)",0,1) + log_game("PA Control Computer increased to [strength] by [usr.ckey]([usr]) in ([x],[y],[z])") + investigate_log("increased to [strength] by [usr.key]","singulo") + strength_change() + +/obj/machinery/particle_accelerator/control_box/proc/remove_strength(var/s) + if(assembled) + strength-- + if(strength < 0) + strength = 0 + else + message_admins("PA Control Computer decreased to [strength] by [key_name(usr, usr.client)](?) in ([x],[y],[z] - JMP)",0,1) + log_game("PA Control Computer decreased to [strength] by [usr.ckey]([usr]) in ([x],[y],[z])") + investigate_log("decreased to [strength] by [usr.key]","singulo") + strength_change() /obj/machinery/particle_accelerator/control_box/power_change() ..() @@ -198,6 +206,9 @@ /obj/machinery/particle_accelerator/control_box/proc/toggle_power() src.active = !src.active + investigate_log("turned [active?"ON":"OFF"] by [usr ? usr.key : "outside forces"]","singulo") + message_admins("PA Control Computer turned [active ?"ON":"OFF"] by [key_name(usr, usr.client)](?) in ([x],[y],[z] - JMP)",0,1) + log_game("PA Control Computer turned [active ?"ON":"OFF"] by [usr.ckey]([usr]) in ([x],[y],[z])") if(src.active) update_use_power(2) for(var/obj/structure/particle_accelerator/part in connected_parts) @@ -241,4 +252,4 @@ user << browse(dat, "window=pacontrol;size=420x500") onclose(user, "pacontrol") - return \ No newline at end of file + return From 1e479536db340b8709cc098f671cd5aacf60816e Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Mon, 24 Nov 2014 10:19:57 +0100 Subject: [PATCH 4/6] Radio wires. --- baystation12.dme | 1 + code/datums/wires/radio.dm | 31 ++++++++++++++++ .../game/objects/items/devices/radio/radio.dm | 36 +++++-------------- 3 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 code/datums/wires/radio.dm diff --git a/baystation12.dme b/baystation12.dme index e2e743d39a9..83dfe89d6a5 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -171,6 +171,7 @@ #include "code\datums\wires\camera.dm" #include "code\datums\wires\mulebot.dm" #include "code\datums\wires\particle_accelerator.dm" +#include "code\datums\wires\radio.dm" #include "code\datums\wires\robot.dm" #include "code\datums\wires\smartfridge.dm" #include "code\datums\wires\suit_storage_unit.dm" diff --git a/code/datums/wires/radio.dm b/code/datums/wires/radio.dm new file mode 100644 index 00000000000..45df490e078 --- /dev/null +++ b/code/datums/wires/radio.dm @@ -0,0 +1,31 @@ +/datum/wires/radio + holder_type = /obj/item/device/radio + wire_count = 3 + +var/const/WIRE_SIGNAL = 1 +var/const/WIRE_RECEIVE = 2 +var/const/WIRE_TRANSMIT = 4 + +/datum/wires/radio/CanUse(var/mob/living/L) + var/obj/item/device/radio/R = holder + if(R.b_stat) + return 1 + return 0 + +/datum/wires/radio/Interact(var/mob/living/user) + if(CanUse(user)) + var/obj/item/device/radio/R = holder + R.interact(user) + +/datum/wires/radio/UpdatePulsed(var/index) + var/obj/item/device/radio/R = holder + switch(index) + if(WIRE_SIGNAL) + R.listening = !R.listening + R.broadcasting = R.listening + + if(WIRE_RECEIVE) + R.listening = !R.listening + + if(WIRE_TRANSMIT) + R.broadcasting = !R.broadcasting diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 7a6288a32e6..f818f59ddc6 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -1,5 +1,3 @@ - - /obj/item/device/radio icon = 'icons/obj/radio.dmi' name = "station bounced radio" @@ -12,7 +10,7 @@ var/traitor_frequency = 0 //tune to frequency to unlock traitor supplies var/canhear_range = 3 // the range which mobs can hear this radio from var/obj/item/device/radio/patch_link = null - var/wires = WIRE_SIGNAL | WIRE_RECEIVE | WIRE_TRANSMIT + var/datum/wires/radio/wires = null var/b_stat = 0 var/broadcasting = 0 var/listening = 1 @@ -29,13 +27,8 @@ w_class = 2 matter = list("glass" = 25,"metal" = 75) - - var/const/WIRE_SIGNAL = 1 //sends a signal, like to set off a bomb or electrocute someone - var/const/WIRE_RECEIVE = 2 - var/const/WIRE_TRANSMIT = 4 - var/const/TRANSMISSION_DELAY = 5 // only 2/second/radio var/const/FREQ_LISTENING = 1 - //FREQ_BROADCASTING = 2 + /obj/item/device/radio var/datum/radio_frequency/radio_connection @@ -48,6 +41,7 @@ /obj/item/device/radio/New() ..() + wires = new(src) if(radio_controller) initialize() @@ -102,14 +96,9 @@ return /obj/item/device/radio/proc/text_wires() - if (!b_stat) - return "" - return {" -
- Green Wire: [(wires & 4) ? "Cut" : "Mend"] Wire
- Red Wire: [(wires & 2) ? "Cut" : "Mend"] Wire
- Blue Wire: [(wires & 1) ? "Cut" : "Mend"] Wire
- "} + if (b_stat) + return wires.GetInteractWindow() + return /obj/item/device/radio/proc/text_sec_channel(var/chan_name, var/chan_stat) @@ -156,14 +145,7 @@ channels[chan_name] &= ~FREQ_LISTENING else channels[chan_name] |= FREQ_LISTENING - else if (href_list["wires"]) - var/t1 = text2num(href_list["wires"]) - if (!( istype(usr.get_active_hand(), /obj/item/weapon/wirecutters) )) - return - if (wires & t1) - wires &= ~t1 - else - wires |= t1 + if (!( master )) if (istype(loc, /mob)) interact(loc) @@ -223,7 +205,7 @@ // Uncommenting this. To the above comment: // The permacell radios aren't suppose to be able to transmit, this isn't a bug and this "fix" is just making radio wires useless. -Giacom - if(!(src.wires & WIRE_TRANSMIT)) // The device has to have all its wires and shit intact + if(wires.IsIndexCut(WIRE_TRANSMIT)) // The device has to have all its wires and shit intact return 0 M.last_target_click = world.time @@ -438,7 +420,7 @@ // what the range is in which mobs will hear the radio // returns: -1 if can't receive, range otherwise - if (!(wires & WIRE_RECEIVE)) + if (wires.IsIndexCut(WIRE_RECEIVE)) return -1 if(!listening) return -1 From e98649fa5eafa1c922906185e7bf1cbd54e7a3d8 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Mon, 24 Nov 2014 10:52:08 +0100 Subject: [PATCH 5/6] Plastique wiring. --- baystation12.dme | 2 + code/__HELPERS/turfs.dm | 7 ++ code/datums/wires/explosive.dm | 31 ++++++ code/defines/obj/weapon.dm | 13 --- code/game/objects/items/weapons/explosives.dm | 99 +++++++++++++------ 5 files changed, 110 insertions(+), 42 deletions(-) create mode 100644 code/__HELPERS/turfs.dm create mode 100644 code/datums/wires/explosive.dm diff --git a/baystation12.dme b/baystation12.dme index 83dfe89d6a5..c97ff018818 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -28,6 +28,7 @@ #include "code\__HELPERS\sanitize_values.dm" #include "code\__HELPERS\text.dm" #include "code\__HELPERS\time.dm" +#include "code\__HELPERS\turfs.dm" #include "code\__HELPERS\type2type.dm" #include "code\__HELPERS\unsorted.dm" #include "code\_onclick\adjacent.dm" @@ -169,6 +170,7 @@ #include "code\datums\wires\apc.dm" #include "code\datums\wires\autolathe.dm" #include "code\datums\wires\camera.dm" +#include "code\datums\wires\explosive.dm" #include "code\datums\wires\mulebot.dm" #include "code\datums\wires\particle_accelerator.dm" #include "code\datums\wires\radio.dm" diff --git a/code/__HELPERS/turfs.dm b/code/__HELPERS/turfs.dm new file mode 100644 index 00000000000..57d4b865557 --- /dev/null +++ b/code/__HELPERS/turfs.dm @@ -0,0 +1,7 @@ +// Returns the atom sitting on the turf. +// For example, using this on a disk, which is in a bag, on a mob, will return the mob because it's on the turf. +/proc/get_atom_on_turf(var/atom/movable/M) + var/atom/mloc = M + while(mloc && mloc.loc && !istype(mloc.loc, /turf/)) + mloc = mloc.loc + return mloc diff --git a/code/datums/wires/explosive.dm b/code/datums/wires/explosive.dm new file mode 100644 index 00000000000..6dc8e988ac0 --- /dev/null +++ b/code/datums/wires/explosive.dm @@ -0,0 +1,31 @@ +/datum/wires/explosive + wire_count = 1 + +var/const/WIRE_EXPLODE = 1 + +/datum/wires/explosive/proc/explode() + return + +/datum/wires/explosive/UpdatePulsed(var/index) + switch(index) + if(WIRE_EXPLODE) + explode() + +/datum/wires/explosive/UpdateCut(var/index, var/mended) + switch(index) + if(WIRE_EXPLODE) + if(!mended) + explode() + +/datum/wires/explosive/c4 + holder_type = /obj/item/weapon/plastique + +/datum/wires/explosive/c4/CanUse(var/mob/living/L) + var/obj/item/weapon/plastique/P = holder + if(P.open_panel) + return 1 + return 0 + +/datum/wires/explosive/c4/explode() + var/obj/item/weapon/plastique/P = holder + P.explode(get_turf(P)) diff --git a/code/defines/obj/weapon.dm b/code/defines/obj/weapon.dm index ae3adf9c3bd..6de75c2b9df 100644 --- a/code/defines/obj/weapon.dm +++ b/code/defines/obj/weapon.dm @@ -433,19 +433,6 @@ var/obj/machinery/machine -/obj/item/weapon/plastique - name = "plastic explosives" - desc = "Used to put holes in specific areas without too much extra hole." - gender = PLURAL - icon = 'icons/obj/assemblies.dmi' - icon_state = "plastic-explosive0" - item_state = "plasticx" - flags = FPRINT | TABLEPASS | NOBLUDGEON - w_class = 2.0 - origin_tech = "syndicate=2" - var/timer = 10 - var/atom/target = null - ///////////////////////////////////////Stock Parts ///////////////////////////////// /obj/item/weapon/stock_parts diff --git a/code/game/objects/items/weapons/explosives.dm b/code/game/objects/items/weapons/explosives.dm index d9a72058aee..97e5630d949 100644 --- a/code/game/objects/items/weapons/explosives.dm +++ b/code/game/objects/items/weapons/explosives.dm @@ -1,45 +1,86 @@ +/obj/item/weapon/plastique + name = "plastic explosives" + desc = "Used to put holes in specific areas without too much extra hole." + gender = PLURAL + icon = 'icons/obj/assemblies.dmi' + icon_state = "plastic-explosive0" + item_state = "plasticx" + flags = FPRINT | TABLEPASS | NOBLUDGEON + w_class = 2.0 + origin_tech = "syndicate=2" + var/datum/wires/explosive/c4/wires = null + var/timer = 10 + var/atom/target = null + var/open_panel = 0 + var/image_overlay = null + +/obj/item/weapon/plastique/New() + wires = new(src) + image_overlay = image('icons/obj/assemblies.dmi', "plastic-explosive2") + ..() + +/obj/item/weapon/plastique/attackby(var/obj/item/I, var/mob/user) + if(istype(I, /obj/item/weapon/screwdriver)) + open_panel = !open_panel + user << "You [open_panel ? "open" : "close"] the wire panel." + else if(istype(I, /obj/item/weapon/wirecutters) || istype(I, /obj/item/device/multitool) || istype(I, /obj/item/device/assembly/signaler )) + wires.Interact(user) + else + ..() + /obj/item/weapon/plastique/attack_self(mob/user as mob) var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num - if(newtime < 10) - newtime = 10 - timer = newtime - user << "Timer set for [timer] seconds." + if(user.get_active_hand() == src) + newtime = Clamp(newtime, 10, 60000) + timer = newtime + user << "Timer set for [timer] seconds." -/obj/item/weapon/plastique/afterattack(atom/target as obj|turf, mob/user as mob, flag) +/obj/item/weapon/plastique/afterattack(atom/movable/target, mob/user, flag) if (!flag) return - if (istype(target, /turf/unsimulated) || istype(target, /turf/simulated/shuttle) || istype(target, /obj/item/weapon/storage/)) + if (ismob(target) || istype(target, /turf/unsimulated) || istype(target, /turf/simulated/shuttle) || istype(target, /obj/item/weapon/storage/)) return user << "Planting explosives..." - if(ismob(target)) - - user.attack_log += "\[[time_stamp()]\] [user.real_name] tried planting [name] on [target:real_name] ([target:ckey])" - msg_admin_attack("[user.real_name] ([user.ckey]) tried planting [name] on [target:real_name] ([target:ckey]) (JMP)") - - user.visible_message("\red [user.name] is trying to plant some kind of explosive on [target.name]!") if(do_after(user, 50) && in_range(user, target)) user.drop_item() - target = target + src.target = target loc = null - var/location - if (isturf(target)) location = target - if (isobj(target)) location = target.loc + if (ismob(target)) - target:attack_log += "\[[time_stamp()]\] Had the [name] planted on them by [user.real_name] ([user.ckey])" - user.visible_message("\red [user.name] finished planting an explosive on [target.name]!") - target.overlays += image('icons/obj/assemblies.dmi', "plastic-explosive2") + add_logs(user, target, "planted [name] on") + user.visible_message("[user.name] finished planting an explosive on [target.name]!") + message_admins("[key_name(user, user.client)](?) planted [src.name] on [key_name(target)](?) with [timer] second fuse",0,1) + log_game("[key_name(user)] planted [src.name] on [key_name(target)] with [timer] second fuse") + + else + message_admins("[key_name(user, user.client)](?) planted [src.name] on [target.name] at ([target.x],[target.y],[target.z] - JMP) with [timer] second fuse",0,1) + log_game("[key_name(user)] planted [src.name] on [target.name] at ([target.x],[target.y],[target.z]) with [timer] second fuse") + + target.overlays += image_overlay user << "Bomb has been planted. Timer counting down from [timer]." spawn(timer*10) - if(target) - explosion(location, -1, -1, 2, 3) - if (istype(target, /turf/simulated/wall)) target:dismantle_wall(1) - else target.ex_act(1) - if (isobj(target)) - if (target) - del(target) - if (src) - del(src) + explode(get_turf(target)) + +/obj/item/weapon/plastique/proc/explode(var/location) + if(!target) + target = get_atom_on_turf(src) + if(!target) + target = src + if(location) + explosion(location, -1, -1, 2, 3) + + if(target) + if (istype(target, /turf/simulated/wall)) + var/turf/simulated/wall/W = target + W.dismantle_wall(1) + else if(istype(target, /mob/living)) + target.ex_act(2) // c4 can't gib mobs anymore. + else + target.ex_act(1) + if(target) + target.overlays -= image_overlay + del(src) // qdel /obj/item/weapon/plastique/attack(mob/M as mob, mob/user as mob, def_zone) - return \ No newline at end of file + return From c3a80e4ace2af0898b82f4420bb28a8447815767 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Mon, 24 Nov 2014 15:23:06 +0100 Subject: [PATCH 6/6] Radio wires - Take 2. Can now also cut wiring. --- code/datums/wires/radio.dm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/code/datums/wires/radio.dm b/code/datums/wires/radio.dm index 45df490e078..9da8890ac32 100644 --- a/code/datums/wires/radio.dm +++ b/code/datums/wires/radio.dm @@ -21,11 +21,24 @@ var/const/WIRE_TRANSMIT = 4 var/obj/item/device/radio/R = holder switch(index) if(WIRE_SIGNAL) - R.listening = !R.listening - R.broadcasting = R.listening + R.listening = !R.listening && !IsIndexCut(WIRE_RECEIVE) + R.broadcasting = R.listening && !IsIndexCut(WIRE_TRANSMIT) if(WIRE_RECEIVE) - R.listening = !R.listening + R.listening = !R.listening && !IsIndexCut(WIRE_SIGNAL) if(WIRE_TRANSMIT) - R.broadcasting = !R.broadcasting + R.broadcasting = !R.broadcasting && !IsIndexCut(WIRE_SIGNAL) + +/datum/wires/radio/UpdateCut(var/index, var/mended) + var/obj/item/device/radio/R = holder + switch(index) + if(WIRE_SIGNAL) + R.listening = mended && !IsIndexCut(WIRE_RECEIVE) + R.broadcasting = mended && !IsIndexCut(WIRE_TRANSMIT) + + if(WIRE_RECEIVE) + R.listening = mended && !IsIndexCut(WIRE_SIGNAL) + + if(WIRE_TRANSMIT) + R.broadcasting = mended && !IsIndexCut(WIRE_SIGNAL)