Radio wires.

This commit is contained in:
PsiOmega
2014-11-24 10:19:57 +01:00
parent bf24d288ea
commit 1e479536db
3 changed files with 41 additions and 27 deletions

View File

@@ -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"

View File

@@ -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

View File

@@ -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 {"
<hr>
Green Wire: <A href='byond://?src=\ref[src];wires=4'>[(wires & 4) ? "Cut" : "Mend"] Wire</A><BR>
Red Wire: <A href='byond://?src=\ref[src];wires=2'>[(wires & 2) ? "Cut" : "Mend"] Wire</A><BR>
Blue Wire: <A href='byond://?src=\ref[src];wires=1'>[(wires & 1) ? "Cut" : "Mend"] Wire</A><BR>
"}
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