Skip to content

Commit

Permalink
Peddling Purple Prose: Porting the 'Do' action from F13 (#725)
Browse files Browse the repository at this point in the history
* Initial commit of Do roleplay action

* Link in correct keybind signal

* Update unit tests

* I want to throw eslint down a well

* Move to mob/living and change to use hearers instead of view()

* Apply suggestions from code review

Co-authored-by: Bloop <[email protected]>

* Fix compile issues

* Yabba dabba Do

* Allow AI to Do from their eyeobj position (and also hear from it as well)

---------

Co-authored-by: Bloop <[email protected]>
  • Loading branch information
2 people authored and StealsThePRs committed Feb 28, 2024
1 parent 7c2ec91 commit 3f8d6a4
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 0 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/~nova_defines/keybindings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
#define COMSIG_KB_CLIENT_WHISPER_DOWN "keybinding_client_whisper_down"
#define COMSIG_KB_LIVING_COMBAT_INDICATOR "keybinding_living_combat_indicator"
#define COMSIG_KB_CARBON_TOGGLE_SAFETY "keybinding_carbon_toggle_safety"
#define COMSIG_KB_CLIENT_DO_DOWN "keybinding_client_do_down"
#define COMSIG_KB_CLIENT_DO_LONGER_DOWN "keybinding_client_do_longer_down"
1 change: 1 addition & 0 deletions code/__DEFINES/~nova_defines/say.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define MAX_FLAVOR_LEN 4096 //double the maximum message length.
#define LOOC_CHANNEL "LOOC" // LOOC
#define WHIS_CHANNEL "Whis" // Whisper
#define DO_CHANNEL "Do" // Do
2 changes: 2 additions & 0 deletions code/modules/tgui_input/say_modal/speech.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
if(WHIS_CHANNEL)
client.mob.whisper_verb(entry)
return TRUE
if(DO_CHANNEL)
client.mob.do_verb(entry)
// NOVA EDIT ADDITION END
return FALSE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,33 @@
return
winset(user, null, "command=[user.tgui_say_create_open_command(WHIS_CHANNEL)]")
return TRUE

/datum/keybinding/client/communication/Do
hotkey_keys = list("K")
name = DO_CHANNEL
full_name = "Do"
keybind_signal = COMSIG_KB_CLIENT_DO_DOWN

/datum/keybinding/client/communication/Do/down(client/user)
. = ..()
if(.)
return
winset(user, null, "command=[user.tgui_say_create_open_command(DO_CHANNEL)]")
return TRUE

/datum/keybinding/client/communication/Do_longer
hotkey_keys = list("CtrlK")
name = "do_longer"
full_name = "Do (Longer)"
keybind_signal = COMSIG_KB_CLIENT_DO_LONGER_DOWN

/datum/keybinding/client/communication/Do_longer/down(client/user)
. = ..()
if(.)
return
var/message_text = tgui_input_text(user, "Write out your Do action:", "Do (Longer)", null, MAX_MESSAGE_LEN, TRUE)
if (!message_text)
return

user.mob.do_verb(message_text)
return TRUE
20 changes: 20 additions & 0 deletions modular_nova/modules/roleplay_do/code/do_checks.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/mob/living/proc/doverb_checks(message)
if(!length(message))
return FALSE

if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, span_danger("Speech is currently admin-disabled."))
return FALSE

//quickly calc our name stub again: duplicate this in say.dm override
var/name_stub = " (<b>[usr]</b>)"
if(length(message) > (MAX_MESSAGE_LEN - length(name_stub)))
to_chat(usr, message)
to_chat(usr, span_warning("^^^----- The preceding message has been DISCARDED for being over the maximum length of [MAX_MESSAGE_LEN]. It has NOT been sent! -----^^^"))
return FALSE

if(usr.stat != CONSCIOUS)
to_chat(usr, span_notice("You cannot send a Do in your current condition."))
return FALSE

return TRUE
48 changes: 48 additions & 0 deletions modular_nova/modules/roleplay_do/code/do_verbs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/mob/verb/do_verb(message as message)
set name = "Do"
set category = "IC"
set instant = TRUE

if(GLOB.say_disabled)
to_chat(usr, span_danger("Speech is currently admin-disabled."))
return

if(message)
QUEUE_OR_CALL_VERB_FOR(VERB_CALLBACK(src, TYPE_VERB_REF(/mob/living, do_actual_verb), message), SSspeech_controller)

/mob/living/verb/do_actual_verb(message as message)
if (!message || !doverb_checks(message))
return

if (!try_speak(message)) // ensure we pass the vibe check (filters, etc)
return

var/name_stub = " (<b>[usr]</b>)"
message = usr.say_emphasis(message)
message = trim(copytext_char(message, 1, (MAX_MESSAGE_LEN - length(name_stub))))
var/message_with_name = message + name_stub

usr.log_message(message, LOG_EMOTE)

var/list/viewers = get_hearers_in_view(DEFAULT_MESSAGE_RANGE, usr)

if(istype(usr, /mob/living/silicon/ai))
var/mob/living/silicon/ai/ai = usr
viewers = get_hearers_in_view(DEFAULT_MESSAGE_RANGE, ai.eyeobj)

var/obj/effect/overlay/holo_pad_hologram/hologram = GLOB.hologram_impersonators[usr]
if(hologram)
viewers |= get_hearers_in_view(1, hologram)

for(var/mob/living/silicon/ai/ai as anything in GLOB.ai_list)
if(ai.client && !(ai in viewers) && (ai.eyeobj in viewers))
viewers += ai

for(var/mob/ghost as anything in GLOB.dead_mob_list)
if((ghost.client?.prefs.chat_toggles & CHAT_GHOSTSIGHT) && !(ghost in viewers))
ghost.show_message(span_emote(message_with_name))

for(var/mob/reciever in viewers)
reciever.show_message(span_emote(message_with_name), alt_msg = span_emote(message_with_name))
if (reciever.client?.prefs.read_preference(/datum/preference/toggle/enable_runechat))
create_chat_message(usr, null, message, null, EMOTE_MESSAGE)
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -7947,6 +7947,8 @@
#include "modular_nova\modules\robot_limb_detach\code\robot_limb_detach_quirk.dm"
#include "modular_nova\modules\rod-stopper\code\immovable_nova.dm"
#include "modular_nova\modules\rod-stopper\code\rodstopper.dm"
#include "modular_nova\modules\roleplay_do\code\do_checks.dm"
#include "modular_nova\modules\roleplay_do\code\do_verbs.dm"
#include "modular_nova\modules\roundstart_implants\code\loadout_implants.dm"
#include "modular_nova\modules\roundstart_implants\code\loadout_subtypes.dm"
#include "modular_nova\modules\roundstart_implants\code\tool_subtypes.dm"
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-say/ChannelIterator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('ChannelIterator', () => {
// NOVA EDIT ADDITION START
expect(channelIterator.next()).toBe('Whis');
expect(channelIterator.next()).toBe('LOOC');
expect(channelIterator.next()).toBe('Do');
// NOVA EDIT ADDITION END
expect(channelIterator.next()).toBe('OOC');
expect(channelIterator.next()).toBe('Say'); // Admin is blacklisted so it should be skipped
Expand Down
2 changes: 2 additions & 0 deletions tgui/packages/tgui-say/ChannelIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type Channel =
// NOVA EDIT ADDITION START
| 'Whis'
| 'LOOC'
| 'Do'
// NOVA EDIT ADDITION END
| 'OOC'
| 'Admin';
Expand All @@ -24,6 +25,7 @@ export class ChannelIterator {
// NOVA EDIT ADDITION
'Whis',
'LOOC',
'Do',
// NOVA EDIT ADDITION
'OOC',
'Admin',
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-say/constants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const CHANNELS = [
'Me',
'Whis', // NOVA EDIT ADDITION - CUSTOMIZATION
'LOOC', // NOVA EDIT ADDITION - CUSTOMIZATION
'Do', // NOVA EDIT ADDITION - Do roleplay addition
'OOC',
'Admin',
] as const;
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui-say/styles/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $_channel_map: (
'Synd': #8f4a4b,
// NOVA EDIT ADDITION
'Whis': #7c7fd9,
'Do': #59da7e,
);

$channel_keys: map.keys($_channel_map) !default;
Expand Down

0 comments on commit 3f8d6a4

Please sign in to comment.