diff --git a/baystation12.dme b/baystation12.dme index e2e743d39a..83dfe89d6a 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 0000000000..45df490e07 --- /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 7a6288a32e..f818f59ddc 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