Add ringers (#3414)

Adds ringers at Juani's request. Pretty much a console you can use your PDA on to add it to a list, then, there is a button someone can click and it will ping you.
This commit is contained in:
Alberyk
2017-09-12 15:59:43 -05:00
committed by Lohikar
parent e56f459a71
commit ee2c01c1ec
5 changed files with 155 additions and 9 deletions
+3 -2
View File
@@ -435,10 +435,10 @@
#include "code\game\gamemodes\mixed\infiltration.dm"
#include "code\game\gamemodes\mixed\intrigue.dm"
#include "code\game\gamemodes\mixed\paranoia.dm"
#include "code\game\gamemodes\mixed\veilparty.dm"
#include "code\game\gamemodes\mixed\siege.dm"
#include "code\game\gamemodes\mixed\traitorling.dm"
#include "code\game\gamemodes\mixed\uprising.dm"
#include "code\game\gamemodes\mixed\veilparty.dm"
#include "code\game\gamemodes\mixed\visitors.dm"
#include "code\game\gamemodes\ninja\ninja.dm"
#include "code\game\gamemodes\nuclear\nuclear.dm"
@@ -513,6 +513,7 @@
#include "code\game\machinery\recharger.dm"
#include "code\game\machinery\rechargestation.dm"
#include "code\game\machinery\requests_console.dm"
#include "code\game\machinery\ringer.dm"
#include "code\game\machinery\robot_fabricator.dm"
#include "code\game\machinery\seed_extractor.dm"
#include "code\game\machinery\Sleeper.dm"
@@ -1985,6 +1986,7 @@
#include "code\modules\research\rdmachines.dm"
#include "code\modules\research\research.dm"
#include "code\modules\research\server.dm"
#include "code\modules\research\stockparts.dm"
#include "code\modules\research\designs\AI_modules_designs.dm"
#include "code\modules\research\designs\circuit_designs.dm"
#include "code\modules\research\designs\medical_designs.dm"
@@ -1994,7 +1996,6 @@
#include "code\modules\research\designs\stock_parts_designs.dm"
#include "code\modules\research\designs\tcom_designs.dm"
#include "code\modules\research\designs\weapon_designs.dm"
#include "code\modules\research\stockparts.dm"
#include "code\modules\research\xenoarchaeology\chemistry.dm"
#include "code\modules\research\xenoarchaeology\geosample.dm"
#include "code\modules\research\xenoarchaeology\manuals.dm"
+146
View File
@@ -0,0 +1,146 @@
/obj/machinery/ringer
name = "ringer terminal"
desc = "A ringer terminal, PDAs can be linked to it."
icon = 'icons/obj/terminals.dmi'
icon_state = "bell_standby"
anchored = TRUE
req_access = list() //what access it needs to link your pda
var/id = null
var/list/obj/item/device/pda/rings_pdas = list() //A list of PDAs to alert upon someone touching the machine
var/listener/ringers
var/on = TRUE
var/department = "Somewhere" //whatever department/desk you put this thing
var/pinged = FALSE //for cooldown
/obj/machinery/ringer/Initialize()
. = ..()
if (id)
ringers = new(id, src)
/obj/machinery/ringer/power_change()
..()
update_icon()
/obj/machinery/ringer/Destroy()
QDEL_NULL(ringers)
return ..()
/obj/machinery/ringer/update_icon()
if(stat & NOPOWER)
icon_state = "bell_off"
return
if (rings_pdas || rings_pdas.len)
icon_state = "bell_active"
if(pinged)
icon_state = "bell_alert"
if(!on)
icon_state = "bell_off"
else
icon_state = "bell_standby"
/obj/machinery/ringer/attackby(obj/item/C as obj, mob/living/user as mob)
if(stat & (BROKEN|NOPOWER) || !istype(user,/mob/living))
return
if (istype(C, /obj/item/device/pda))
if(!check_access(C))
user << "<span class='warning'>Access Denied.</span>"
return
else if (C in rings_pdas)
user << "<span class='notice'>You unlink \the [C] from \the [src].</span>"
remove_pda(C)
return
user << "<span class='notice'>You link \the [C] to \the [src], it will now ring upon someone using \the [src].</span>"
rings_pdas += C
C.OnDestroy(CALLBACK(src, .proc/remove_pda, C))
update_icon()
else
..()
/obj/machinery/ringer/attack_hand(mob/user as mob)
if(..())
return
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER) || !istype(usr,/mob/living))
return
if(!on)
user << "<span class='notice'>You turn \the [src] on, now all PDAs linked to it will be notified.</span>"
on = TRUE
else
user << "<span class='notice'>You turn \the [src] off.</span>"
on = FALSE
update_icon()
/obj/machinery/ringer/proc/ring_pda()
if (!on || pinged)
return
pinged = TRUE
playsound(src.loc, 'sound/machines/ringer.ogg', 50, 1)
if (!rings_pdas || !rings_pdas.len)
return
for (var/obj/item/device/pda/pda in rings_pdas)
if (pda.toff || pda.message_silent)
continue
var/message = "Notification from \the [department]!"
pda.new_info(pda.message_silent, pda.ttone, "\icon[pda] <b>[message]</b>")
addtimer(CALLBACK(src, .proc/unping), 45 SECONDS)
/obj/machinery/ringer/proc/unping(var/obj/item/device/pda/pda)
pinged = FALSE
update_icon()
/obj/machinery/ringer/proc/remove_pda(var/obj/item/device/pda/pda)
if (istype(pda))
rings_pdas -= pda
/obj/machinery/ringer_button
name = "ringer button"
desc = "Use this to get someone's attention, or to annoy them."
icon = 'icons/obj/terminals.dmi'
icon_state = "ringer"
anchored = TRUE
var/id = ""
/obj/machinery/ringer_button/Initialize(mapload, newid)
. = ..()
if(!id)
id = newid
update_icon()
/obj/machinery/ringer_button/power_change()
..()
update_icon()
/obj/machinery/ringer_button/update_icon()
if(stat & NOPOWER)
icon_state = "ringer_off"
else
icon_state = "ringer"
/obj/machinery/ringer_button/attack_hand(mob/living/user)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
if(use_power)
use_power(active_power_usage)
for (var/thing in GET_LISTENERS(id))
var/listener/L = thing
var/obj/machinery/ringer/C = L.target
if (istype(C))
C.ring_pda()
+6 -7
View File
@@ -1,8 +1,8 @@
//-------------------------------
// Buttons
// Sender: intended to be used by buttons, when the button is pressed it will call activate() on all connected /button
// Sender: intended to be used by buttons, when the button is pressed it will call activate() on all connected /button
// receivers.
// Receiver: does whatever the subtype does. deactivate() by default calls activate(), so you will have to override in
// Receiver: does whatever the subtype does. deactivate() by default calls activate(), so you will have to override in
// it in a subtype if you want it to do something.
//-------------------------------
/datum/wifi/sender/button/activate(mob/living/user)
@@ -24,7 +24,7 @@
//-------------------------------
// Doors
// Sender: sends an open/close request to all connected /door receivers. Utilises spawn_sync to trigger all doors to
// Sender: sends an open/close request to all connected /door receivers. Utilises spawn_sync to trigger all doors to
// open at approximately the same time. Waits until all doors have finished opening before returning.
// Receiver: will try to open/close the parent door when activate/deactivate is called.
//-------------------------------
@@ -35,7 +35,7 @@
return
var/datum/spawn_sync/S = new()
for (var/thing in GET_LISTENERS(id))
var/listener/L = thing
var/datum/wifi/receiver/button/door/D = L.target
@@ -102,7 +102,7 @@
var/obj/machinery/power/emitter/E = parent
if(istype(E) && !E.active)
E.activate(user) //if the emitter is not active, trigger the activate proc to toggle it
/datum/wifi/receiver/button/emitter/deactivate(mob/living/user)
var/obj/machinery/power/emitter/E = parent
if(istype(E) && E.active)
@@ -159,7 +159,6 @@
var/obj/machinery/igniter/I = parent
if(I.on)
I.ignite()
//-------------------------------
// Sparker
// Triggers the parent /sparker to ignite().
@@ -172,7 +171,7 @@
//-------------------------------
// Mass Driver
// Sender: carries out a sequence of first opening all connected doors, then activating all connected mass drivers,
// Sender: carries out a sequence of first opening all connected doors, then activating all connected mass drivers,
// then closes all connected doors. It will wait before continuing the sequence after opening/closing the doors.
// Receiver: Triggers the parent mass dirver to activate.
//-------------------------------
Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.