Megaphone Say Signals (#12926)

This commit is contained in:
Geeves
2022-04-16 21:32:00 +02:00
committed by GitHub
parent 91ed8d4fd5
commit 532e07b244
21 changed files with 163 additions and 117 deletions
+10 -10
View File
@@ -350,8 +350,7 @@
/obj/item/proc/pickup(mob/user)
pixel_x = 0
pixel_y = 0
if(flags & HELDMAPTEXT)
addtimer(CALLBACK(src, .proc/check_maptext), 1) // invoke async does not work here
addtimer(CALLBACK(src, .proc/handle_pickup_drop, user), 1) // invoke async does not work here
do_pickup_animation(user)
// called when this item is removed from a storage item, which is passed on as S. The loc variable is already set to the new destination before this is called.
@@ -524,8 +523,7 @@ var/list/global/slot_flags_enumeration = list(
// override for give shenanigans
/obj/item/proc/on_give(var/mob/giver, var/mob/receiver)
if(flags & HELDMAPTEXT)
check_maptext()
handle_pickup_drop(giver, FALSE)
//This proc is executed when someone clicks the on-screen UI button. To make the UI button show, set the 'icon_action_button' to the icon_state of the image of the button in screen1_action.dmi
//The default action is attack_self().
@@ -905,15 +903,13 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
else
maptext = ""
/obj/item/throw_at()
/obj/item/throw_at(atom/target, range, speed, thrower, do_throw_animation)
..()
if(flags & HELDMAPTEXT)
check_maptext()
handle_pickup_drop(thrower, FALSE)
/obj/item/dropped(var/mob/user)
..()
if(flags & HELDMAPTEXT)
check_maptext()
handle_pickup_drop(user, FALSE)
// used to check whether the item is capable of popping things like balloons, inflatable barriers, or cutting police tape.
/obj/item/proc/can_puncture()
@@ -956,9 +952,13 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
/obj/item/proc/get_head_examine_text(var/mob/user)
return "on [user.get_pronoun("his")] head"
/obj/item/proc/should_equip() // when you press E with an empty hand, will this item be pulled from suit storage / back slot and put into your hand
return FALSE
/obj/item/proc/can_swap_hands(var/mob/user)
return TRUE
/obj/item/proc/handle_pickup_drop(var/mob/M, var/picked_up = TRUE)
if(flags & HELDMAPTEXT)
check_maptext()
+33 -50
View File
@@ -10,59 +10,42 @@
w_class = ITEMSIZE_SMALL
flags = CONDUCT
var/spamcheck = 0
var/emagged = 0
var/insults = 0
var/list/insultmsg = list("FUCK EVERYONE!", "I'M A TATER!", "ALL SECURITY TO SHOOT ME ON SIGHT!", "I HAVE A BOMB!", "CAPTAIN IS A COMDOM!", "FOR THE SYNDICATE!")
var/activation_sound = 'sound/items/megaphone.ogg'
var/needs_user_location = TRUE
var/active = FALSE
var/speech_sound = 'sound/items/megaphone.ogg'
/obj/item/device/megaphone/attack_self(mob/living/user as mob)
if(user.client)
if(user.client.prefs.muted & MUTE_IC)
to_chat(src, SPAN_WARNING("You cannot speak in IC (muted)."))
return
if(!ishuman(user))
to_chat(user, SPAN_WARNING("You don't know how to use this!"))
return
if(user.silent)
return
if(spamcheck > world.time)
to_chat(user, SPAN_WARNING("\The [src] needs to recharge!"))
return
/obj/item/device/megaphone/handle_pickup_drop(var/mob/M, var/picked_up = TRUE)
..()
handle_signals(M, !picked_up)
var/message = sanitize(input(user, "Shout a message?", "Megaphone", null) as text)
if(!message)
return
message = capitalize(message)
if ((user.stat == CONSCIOUS))
if(needs_user_location)
if(!src.loc == user)
return
if(emagged)
if(insults)
user.audible_message("<B>[user]</B> broadcasts, <FONT size=3>\"[pick(insultmsg)]\"</FONT>", "<B>[user]</B> speaks into \the [src].", 7)
insults--
/obj/item/device/megaphone/equipped(mob/user, slot, assisted_equip)
. = ..()
if(!(slot in list(slot_r_hand, slot_l_hand)))
handle_signals(user, TRUE)
/obj/item/device/megaphone/attack_self(mob/user)
active = !active
to_chat(user, SPAN_NOTICE("You turn \the [src] [active ? "on" : "off"]."))
handle_signals(user)
/obj/item/device/megaphone/proc/handle_signals(var/mob/M, var/disable = FALSE)
if(active && !disable)
RegisterSignal(M, COMSIG_SAY_MODIFIER, .proc/modify_say)
else
UnregisterSignal(M, COMSIG_SAY_MODIFIER)
/obj/item/device/megaphone/proc/modify_say(var/mob/M, var/list/say_modifiers)
if(say_modifiers[SAY_MOD_FONT_SIZE] < FONT_SIZE_LARGE)
say_modifiers[SAY_MOD_FONT_SIZE] = FONT_SIZE_LARGE
say_modifiers[SAY_MOD_VERB] = "broadcasts"
var/turf/T = get_turf(src)
if(T)
playsound(T, speech_sound, 100, FALSE, 1)
for(var/mob/living/carbon/human/H in range(T, 2) - M)
if(get_dist(T, H) < 1) // within one tile
H.earpain(3, TRUE, 2)
else
to_chat(user, SPAN_WARNING("*BZZZZzzzzzt*"))
else
user.audible_message("<B>[user]</B> broadcasts, <FONT size=3>\"[message]\"</FONT>", "<B>[user]</B> speaks into \the [src].", 7)
if(activation_sound)
playsound(loc, activation_sound, 100, 0, 1)
for (var/mob/living/carbon/human/C in range(user, 2) - user)
if (C in range(user, 1))
C.earpain(3, TRUE, 2)
else
C.earpain(2, TRUE, 2)
spamcheck = world.time + 50
return
/obj/item/device/megaphone/emag_act(var/remaining_charges, var/mob/user)
if(!emagged)
to_chat(user, SPAN_WARNING("You overload \the [src]'s voice synthesizer."))
emagged = 1
insults = rand(1, 3)//to prevent dickflooding
return 1
H.earpain(2, TRUE, 2)
/obj/item/device/megaphone/red
name = "red megaphone"