Skip to content

Commit

Permalink
Delayed Narration
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Nov 5, 2023
1 parent 186dbe9 commit ec8b577
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 20 deletions.
60 changes: 60 additions & 0 deletions code/datums/components/atom_narrate.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#define NARRATION_METHOD_SAY "Say"
#define NARRATION_METHOD_ME "Me"
#define NARRATION_METHOD_DIRECT "Direct"

/datum/component/atom_narrate
var/message
var/narration_type
var/narrator

/datum/component/atom_narrate/Initialize(message, narration_type, delayed, narrator)
. = ..()

src.message = message
src.narration_type = narration_type
src.narrator = narrator

if(!delayed)
send_narration()
return

var/turf/parent_turf = get_turf(parent)

if(!parent_turf)
return COMPONENT_INCOMPATIBLE

var/list/message_turfs = block(locate(max(parent_turf.x - 4, 1), max(parent_turf.y - 4, 1), parent_turf.z), locate(parent_turf.x + 4, parent_turf.y + 4, parent_turf.z))

for(var/turf/cycled_turf as anything in message_turfs)
RegisterSignal(cycled_turf, COMSIG_TURF_ENTERED, PROC_REF(send_message_on_movement))

/datum/component/atom_narrate/proc/send_message_on_movement(turf/source, atom/movable/entered)
SIGNAL_HANDLER

if(!istype(entered, /mob/living/carbon/human))
return

send_narration()
qdel(src)

/datum/component/atom_narrate/proc/send_narration()
var/atom/atom_parent = parent

if(!atom_parent)
qdel(src)
return

var/list/heard = get_mobs_in_view(world_view_size, atom_parent)

switch(narration_type)
if(NARRATION_METHOD_SAY)
atom_parent.langchat_speech(message, heard, GLOB.all_languages, skip_language_check = TRUE)
atom_parent.visible_message("<b>[atom_parent]</b> says, \"[message]\"")
if(NARRATION_METHOD_ME)
atom_parent.langchat_speech(message, heard, GLOB.all_languages, skip_language_check = TRUE, animation_style = 2, additional_styles = list("langchat_small", "emote"))
atom_parent.visible_message("<b>[atom_parent]</b> [message]")
if(NARRATION_METHOD_DIRECT)
atom_parent.visible_message("[message]")

log_admin("[narrator] sent an Atom Narrate with message \"[message]\" from [atom_parent].")
message_admins("[narrator] sent an Atom Narrate with message \"[message]\" from [atom_parent].")
25 changes: 5 additions & 20 deletions code/modules/admin/verbs/mob_verbs.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#define NARRATION_METHOD_SAY "Say"
#define NARRATION_METHOD_ME "Me"
#define NARRATION_METHOD_DIRECT "Direct"

// Converted this into a proc. Verb will be separate
/client/proc/change_ckey(mob/M in GLOB.mob_list, a_ckey = null)
var/new_ckey = a_ckey
Expand Down Expand Up @@ -210,30 +206,19 @@
if(!check_rights(R_MOD))
return

var/type = tgui_input_list(mob,"What type of narration?", "Narration", list(NARRATION_METHOD_SAY, NARRATION_METHOD_ME, NARRATION_METHOD_DIRECT))
var/delayed = tgui_alert(mob, "Do you want this narration to occur when someone walks nearby?", "Confirmation", list("Yes", "No")) == "Yes"

var/narration_type = tgui_input_list(mob,"What type of narration?", "Narration", list(NARRATION_METHOD_SAY, NARRATION_METHOD_ME, NARRATION_METHOD_DIRECT))

if(!type)
if(!narration_type)
return

var/message = tgui_input_text(mob, "What should it say?", "Narrating as [selected]")

if(!message)
return

var/list/heard = get_mobs_in_view(world_view_size, selected)

switch(type)
if(NARRATION_METHOD_SAY)
selected.langchat_speech(message, heard, GLOB.all_languages, skip_language_check = TRUE)
selected.visible_message("<b>[selected]</b> says, \"[message]\"")
if(NARRATION_METHOD_ME)
selected.langchat_speech(message, heard, GLOB.all_languages, skip_language_check = TRUE, animation_style = LANGCHAT_FAST_POP, additional_styles = list("langchat_small", "emote"))
selected.visible_message("<b>[selected]</b> [message]")
if(NARRATION_METHOD_DIRECT)
selected.visible_message("[message]")

log_admin("[key_name(src)] sent an Atom Narrate with message [message].")
message_admins("[key_name(src)] sent an Atom Narrate with message [message].")
selected.AddComponent(/datum/component/atom_narrate, message, narration_type, delayed, key_name(src))

/client/proc/cmd_admin_direct_narrate(mob/M)
set name = "Narrate"
Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
#include "code\datums\balloon_alerts\balloon_alerts.dm"
#include "code\datums\components\_component.dm"
#include "code\datums\components\armor_link.dm"
#include "code\datums\components\atom_narrate.dm"
#include "code\datums\components\bad_leg.dm"
#include "code\datums\components\bonus_damage_stack.dm"
#include "code\datums\components\cluster_stack.dm"
Expand Down

0 comments on commit ec8b577

Please sign in to comment.