diff --git a/baystation12.dme b/baystation12.dme
index 800d7cb44a..30fd134ba5 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 0000000000..312e6dd7d9
--- /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 0ff1bec277..a2436f9de4 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<(cut) (pulse)
"
- else
- t += "(mend)
"
-
- return t
-
-
-
-
/obj/machinery/bot/mulebot/Topic(href, href_list)
if(..())
return
@@ -393,38 +341,6 @@
usr.unset_machine()
usr << browse(null,"window=mulebot")
-
- if("wirecut")
- if(istype(usr.get_active_hand(), /obj/item/weapon/wirecutters))
- var/wirebit = text2num(href_list["wire"])
- wires &= ~wirebit
- else
- usr << "\blue You need wirecutters!"
- if("wiremend")
- if(istype(usr.get_active_hand(), /obj/item/weapon/wirecutters))
- var/wirebit = text2num(href_list["wire"])
- wires |= wirebit
- else
- usr << "\blue You need wirecutters!"
-
- if("wirepulse")
- if(istype(usr.get_active_hand(), /obj/item/device/multitool))
- switch(href_list["wire"])
- if("1","2")
- usr << "\blue \icon[src] The charge light flickers."
- if("4")
- usr << "\blue \icon[src] The external warning lights flash briefly."
- if("8")
- usr << "\blue \icon[src] The load platform clunks."
- if("16", "32")
- usr << "\blue \icon[src] The drive motor whines briefly."
- else
- usr << "\blue \icon[src] You hear a radio crackle."
- else
- usr << "\blue You need a multitool!"
-
-
-
updateDialog()
//src.updateUsrDialog()
else
@@ -436,7 +352,7 @@
// returns true if the bot has power
/obj/machinery/bot/mulebot/proc/has_power()
- return !open && cell && cell.charge>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)