mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 03:33:21 +00:00
Mulebot wiring.
This commit is contained in:
@@ -169,6 +169,7 @@
|
|||||||
#include "code\datums\wires\apc.dm"
|
#include "code\datums\wires\apc.dm"
|
||||||
#include "code\datums\wires\autolathe.dm"
|
#include "code\datums\wires\autolathe.dm"
|
||||||
#include "code\datums\wires\camera.dm"
|
#include "code\datums\wires\camera.dm"
|
||||||
|
#include "code\datums\wires\mulebot.dm"
|
||||||
#include "code\datums\wires\robot.dm"
|
#include "code\datums\wires\robot.dm"
|
||||||
#include "code\datums\wires\smartfridge.dm"
|
#include "code\datums\wires\smartfridge.dm"
|
||||||
#include "code\datums\wires\suit_storage_unit.dm"
|
#include "code\datums\wires\suit_storage_unit.dm"
|
||||||
|
|||||||
65
code/datums/wires/mulebot.dm
Normal file
65
code/datums/wires/mulebot.dm
Normal file
@@ -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("<span class='notice'>\icon[holder] The charge light flickers.</span>")
|
||||||
|
if(WIRE_AVOIDANCE)
|
||||||
|
holder.visible_message("<span class='notice'>\icon[holder] The external warning lights flash briefly.</span>")
|
||||||
|
if(WIRE_LOADCHECK)
|
||||||
|
holder.visible_message("<span class='notice'>\icon[holder] The load platform clunks.</span>")
|
||||||
|
if(WIRE_MOTOR1, WIRE_MOTOR2)
|
||||||
|
holder.visible_message("<span class='notice'>\icon[holder] The drive motor whines briefly.</span>")
|
||||||
|
else
|
||||||
|
holder.visible_message("<span class='notice'>\icon[holder] You hear a radio crackle.</span>")
|
||||||
|
|
||||||
|
// 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)
|
||||||
@@ -51,27 +51,13 @@
|
|||||||
// the installed power cell
|
// the installed power cell
|
||||||
|
|
||||||
// constants for internal wiring bitflags
|
// constants for internal wiring bitflags
|
||||||
var/const/wire_power1 = 1 // power connections
|
var/datum/wires/mulebot/wires = null
|
||||||
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/bloodiness = 0 // count of bloodiness
|
var/bloodiness = 0 // count of bloodiness
|
||||||
|
|
||||||
/obj/machinery/bot/mulebot/New()
|
/obj/machinery/bot/mulebot/New()
|
||||||
..()
|
..()
|
||||||
|
wires = new(src)
|
||||||
botcard = new(src)
|
botcard = new(src)
|
||||||
var/datum/job/cargo_tech/J = new/datum/job/cargo_tech
|
var/datum/job/cargo_tech/J = new/datum/job/cargo_tech
|
||||||
botcard.access = J.get_access()
|
botcard.access = J.get_access()
|
||||||
@@ -79,7 +65,6 @@
|
|||||||
cell = new(src)
|
cell = new(src)
|
||||||
cell.charge = 2000
|
cell.charge = 2000
|
||||||
cell.maxcharge = 2000
|
cell.maxcharge = 2000
|
||||||
setup_wires()
|
|
||||||
|
|
||||||
spawn(5) // must wait for map loading to finish
|
spawn(5) // must wait for map loading to finish
|
||||||
if(radio_controller)
|
if(radio_controller)
|
||||||
@@ -93,27 +78,6 @@
|
|||||||
suffix = "#[count]"
|
suffix = "#[count]"
|
||||||
name = "Mulebot ([suffix])"
|
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
|
// attack by item
|
||||||
// emag : lock/unlock,
|
// emag : lock/unlock,
|
||||||
// screwdriver: open/close hatch
|
// screwdriver: open/close hatch
|
||||||
@@ -260,7 +224,7 @@
|
|||||||
else
|
else
|
||||||
dat += "<A href='byond://?src=\ref[src];op=cellinsert'>Removed</A><BR>"
|
dat += "<A href='byond://?src=\ref[src];op=cellinsert'>Removed</A><BR>"
|
||||||
|
|
||||||
dat += wires()
|
dat += wires.GetInteractWindow()
|
||||||
else
|
else
|
||||||
dat += "The bot is in maintenance mode and cannot be controlled.<BR>"
|
dat += "The bot is in maintenance mode and cannot be controlled.<BR>"
|
||||||
|
|
||||||
@@ -268,22 +232,6 @@
|
|||||||
onclose(user, "mulebot")
|
onclose(user, "mulebot")
|
||||||
return
|
return
|
||||||
|
|
||||||
// returns the wire panel text
|
|
||||||
/obj/machinery/bot/mulebot/proc/wires()
|
|
||||||
var/t = ""
|
|
||||||
for(var/i = 0 to 9)
|
|
||||||
var/index = 1<<wire_order[i+1]
|
|
||||||
t += "[wire_text[i+1]] wire: "
|
|
||||||
if(index & wires)
|
|
||||||
t += "<A href='byond://?src=\ref[src];op=wirecut;wire=[index]'>(cut)</A> <A href='byond://?src=\ref[src];op=wirepulse;wire=[index]'>(pulse)</A><BR>"
|
|
||||||
else
|
|
||||||
t += "<A href='byond://?src=\ref[src];op=wiremend;wire=[index]'>(mend)</A><BR>"
|
|
||||||
|
|
||||||
return t
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/obj/machinery/bot/mulebot/Topic(href, href_list)
|
/obj/machinery/bot/mulebot/Topic(href, href_list)
|
||||||
if(..())
|
if(..())
|
||||||
return
|
return
|
||||||
@@ -393,38 +341,6 @@
|
|||||||
usr.unset_machine()
|
usr.unset_machine()
|
||||||
usr << browse(null,"window=mulebot")
|
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()
|
updateDialog()
|
||||||
//src.updateUsrDialog()
|
//src.updateUsrDialog()
|
||||||
else
|
else
|
||||||
@@ -436,7 +352,7 @@
|
|||||||
|
|
||||||
// returns true if the bot has power
|
// returns true if the bot has power
|
||||||
/obj/machinery/bot/mulebot/proc/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
|
// mousedrop a crate to load the bot
|
||||||
// can load anything if emagged
|
// can load anything if emagged
|
||||||
@@ -457,7 +373,7 @@
|
|||||||
|
|
||||||
// called to load a crate
|
// called to load a crate
|
||||||
/obj/machinery/bot/mulebot/proc/load(var/atom/movable/C)
|
/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.")
|
src.visible_message("[src] makes a sighing buzz.", "You hear an electronic buzzing sound.")
|
||||||
playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0)
|
playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0)
|
||||||
return // if not emagged, only allow crates to be loaded
|
return // if not emagged, only allow crates to be loaded
|
||||||
@@ -555,7 +471,7 @@
|
|||||||
on = 0
|
on = 0
|
||||||
return
|
return
|
||||||
if(on)
|
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]"
|
//world << "speed: [speed]"
|
||||||
switch(speed)
|
switch(speed)
|
||||||
if(0)
|
if(0)
|
||||||
@@ -724,7 +640,7 @@
|
|||||||
mode = 3
|
mode = 3
|
||||||
else
|
else
|
||||||
mode = 2
|
mode = 2
|
||||||
icon_state = "mulebot[(wires & wire_mobavoid) == wire_mobavoid]"
|
icon_state = "mulebot[wires.MobAvoid()]"
|
||||||
|
|
||||||
// starts bot moving to home
|
// starts bot moving to home
|
||||||
// sends a beacon query to find
|
// sends a beacon query to find
|
||||||
@@ -732,7 +648,7 @@
|
|||||||
spawn(0)
|
spawn(0)
|
||||||
set_destination(home_destination)
|
set_destination(home_destination)
|
||||||
mode = 4
|
mode = 4
|
||||||
icon_state = "mulebot[(wires & wire_mobavoid) == wire_mobavoid]"
|
icon_state = "mulebot[wires.MobAvoid()]"
|
||||||
|
|
||||||
// called when bot reaches current target
|
// called when bot reaches current target
|
||||||
/obj/machinery/bot/mulebot/proc/at_target()
|
/obj/machinery/bot/mulebot/proc/at_target()
|
||||||
@@ -747,7 +663,7 @@
|
|||||||
// not loaded
|
// not loaded
|
||||||
if(auto_pickup) // find a crate
|
if(auto_pickup) // find a crate
|
||||||
var/atom/movable/AM
|
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))
|
for(var/atom/movable/A in get_step(loc, loaddir))
|
||||||
if(!A.anchored)
|
if(!A.anchored)
|
||||||
AM = A
|
AM = A
|
||||||
@@ -771,7 +687,7 @@
|
|||||||
|
|
||||||
// called when bot bumps into anything
|
// called when bot bumps into anything
|
||||||
/obj/machinery/bot/mulebot/Bump(var/atom/obs)
|
/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
|
var/mob/M = obs
|
||||||
if(ismob(M))
|
if(ismob(M))
|
||||||
if(istype(M,/mob/living/silicon/robot))
|
if(istype(M,/mob/living/silicon/robot))
|
||||||
@@ -828,12 +744,12 @@
|
|||||||
*/
|
*/
|
||||||
var/recv = signal.data["command"]
|
var/recv = signal.data["command"]
|
||||||
// process all-bot input
|
// process all-bot input
|
||||||
if(recv=="bot_status" && (wires & wire_remote_rx))
|
if(recv=="bot_status" && wires.RemoteRX())
|
||||||
send_status()
|
send_status()
|
||||||
|
|
||||||
|
|
||||||
recv = signal.data["command [suffix]"]
|
recv = signal.data["command [suffix]"]
|
||||||
if(wires & wire_remote_rx)
|
if(wires.RemoteRX())
|
||||||
// process control input
|
// process control input
|
||||||
switch(recv)
|
switch(recv)
|
||||||
if("stop")
|
if("stop")
|
||||||
@@ -873,7 +789,7 @@
|
|||||||
|
|
||||||
// receive response from beacon
|
// receive response from beacon
|
||||||
recv = signal.data["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
|
if(recv == new_destination) // if the recvd beacon location matches the set destination
|
||||||
// the we will navigate there
|
// the we will navigate there
|
||||||
destination = new_destination
|
destination = new_destination
|
||||||
@@ -883,7 +799,7 @@
|
|||||||
loaddir = text2num(direction)
|
loaddir = text2num(direction)
|
||||||
else
|
else
|
||||||
loaddir = 0
|
loaddir = 0
|
||||||
icon_state = "mulebot[(wires & wire_mobavoid) == wire_mobavoid]"
|
icon_state = "mulebot[wires.MobAvoid()]"
|
||||||
calc_path()
|
calc_path()
|
||||||
updateDialog()
|
updateDialog()
|
||||||
|
|
||||||
@@ -894,9 +810,9 @@
|
|||||||
// send a radio signal with multiple data key/values
|
// send a radio signal with multiple data key/values
|
||||||
/obj/machinery/bot/mulebot/proc/post_signal_multiple(var/freq, var/list/keyval)
|
/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
|
return
|
||||||
if(freq == control_freq && !(wires & wire_remote_tx))
|
if(freq == control_freq && !wires.RemoteTX())
|
||||||
return
|
return
|
||||||
|
|
||||||
var/datum/radio_frequency/frequency = radio_controller.return_frequency(freq)
|
var/datum/radio_frequency/frequency = radio_controller.return_frequency(freq)
|
||||||
|
|||||||
Reference in New Issue
Block a user