mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
* commit 1 - get me out * she lives * adds wizards * thing * surprise end hits take 1 * s * d * surprise end hits take 2 * montreal * REAl * strangelight * guilford fall * natural disasters * envelope * h * lady elect * test 321 * test 123 Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> * hot toes test * ss * redundancy * s * test 2 * s² * s³ * s²³ * a pray! * life and limb * epic problem * hmm * update * fixes something * fixes something² * adds slaughter demons to the game * rend it * hmm * restores something * adds clockwork cult into the game * adds changelings to the game * cassevetes * test 101 * :) * against * shut the door * adds darkspawn to the game * sad * cashout * adds vampires to the game * 2 * summer freeze * pink frosty * test111 * adds game to the game * 2 * syndrome * test * test 2 * test 3 * test 4 * adds replay to the game? * maybe? * slo * hrn * test II * test III * test IV * new technique * ahm hum * d * sensible * c * ss13 * a * v * f --------- Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
227 lines
7.5 KiB
Plaintext
227 lines
7.5 KiB
Plaintext
#define EMOTE_VISIBLE 1
|
|
#define EMOTE_AUDIBLE 2
|
|
|
|
/datum/emote
|
|
/// What calls the emote.
|
|
var/key = ""
|
|
/// This will also call the emote.
|
|
var/key_third_person = ""
|
|
/// Message displayed when emote is used.
|
|
var/message = ""
|
|
/// Message displayed if the user is a mime.
|
|
var/message_mime = ""
|
|
/// Message displayed if the user is a grown alien.
|
|
var/message_alien = ""
|
|
/// Message displayed if the user is an alien larva.
|
|
var/message_larva = ""
|
|
/// Message displayed if the user is a robot.
|
|
var/message_robot = ""
|
|
/// Message displayed if the user is an AI.
|
|
var/message_AI = ""
|
|
/// Message displayed if the user is a monkey.
|
|
var/message_monkey = ""
|
|
/// Message to display if the user is an IPC
|
|
var/message_ipc = ""
|
|
/// Message to display if the user is a simple_animal or basic mob.
|
|
var/message_simple = ""
|
|
/// Message with %t at the end to allow adding params to the message, like for mobs doing an emote relatively to something else.
|
|
var/message_param = ""
|
|
/// Whether the emote is visible and/or audible bitflag
|
|
var/emote_type = EMOTE_VISIBLE
|
|
/// Checks if the mob can use its hands before performing the emote.
|
|
var/hands_use_check = FALSE
|
|
/// Will only work if the emote is EMOTE_AUDIBLE.
|
|
var/muzzle_ignore = FALSE
|
|
/// Types that are allowed to use that emote.
|
|
var/list/mob_type_allowed_typecache = /mob
|
|
/// Types that are NOT allowed to use that emote.
|
|
var/list/mob_type_blacklist_typecache
|
|
/// Types that can use this emote regardless of their state.
|
|
var/list/mob_type_ignore_stat_typecache
|
|
/// In which state can you use this emote? (Check stat.dm for a full list of them)
|
|
var/stat_allowed = CONSCIOUS
|
|
/// Sound to play when emote is called.
|
|
var/sound
|
|
/// Used for the honk borg emote.
|
|
var/vary = FALSE
|
|
/// Can only code call this event instead of the player.
|
|
var/only_forced_audio = FALSE
|
|
/// The cooldown between the uses of the emote.
|
|
var/cooldown = 0.8 SECONDS
|
|
|
|
/datum/emote/New()
|
|
if (ispath(mob_type_allowed_typecache))
|
|
switch (mob_type_allowed_typecache)
|
|
if (/mob)
|
|
mob_type_allowed_typecache = GLOB.typecache_mob
|
|
if (/mob/living)
|
|
mob_type_allowed_typecache = GLOB.typecache_living
|
|
else
|
|
mob_type_allowed_typecache = typecacheof(mob_type_allowed_typecache)
|
|
else
|
|
mob_type_allowed_typecache = typecacheof(mob_type_allowed_typecache)
|
|
mob_type_blacklist_typecache = typecacheof(mob_type_blacklist_typecache)
|
|
mob_type_ignore_stat_typecache = typecacheof(mob_type_ignore_stat_typecache)
|
|
|
|
/datum/emote/proc/run_emote(mob/user, params, type_override, intentional = FALSE)
|
|
. = TRUE
|
|
if(!can_run_emote(user, TRUE, intentional))
|
|
return FALSE
|
|
var/msg = select_message_type(user, intentional)
|
|
if(params && message_param)
|
|
msg = select_param(user, params)
|
|
|
|
msg = replace_pronoun(user, msg)
|
|
|
|
if(isliving(user))
|
|
var/mob/living/L = user
|
|
for(var/obj/item/implant/I in L.implants)
|
|
I.trigger(key, L)
|
|
|
|
if(!msg)
|
|
return
|
|
|
|
user.log_message(msg, LOG_EMOTE)
|
|
var/dchatmsg = "<b>[user]</b> [msg]"
|
|
|
|
var/tmp_sound = get_sound(user)
|
|
if(tmp_sound && (!only_forced_audio || !intentional))
|
|
playsound(user, tmp_sound, 50, vary)
|
|
|
|
for(var/mob/M in GLOB.dead_mob_list)
|
|
if(!M.client || isnewplayer(M))
|
|
continue
|
|
var/T = get_turf(user)
|
|
if(M.stat == DEAD && M.client && (M.client.prefs.chat_toggles & CHAT_GHOSTSIGHT) && !(M in viewers(T, null)))
|
|
M.show_message("[FOLLOW_LINK(M, user)] [dchatmsg]")
|
|
|
|
if(emote_type == EMOTE_AUDIBLE)
|
|
user.audible_message(msg, audible_message_flags = EMOTE_MESSAGE)
|
|
else
|
|
user.visible_message(msg, visible_message_flags = EMOTE_MESSAGE)
|
|
|
|
/// For handling emote cooldown, return true to allow the emote to happen
|
|
/datum/emote/proc/check_cooldown(mob/user, intentional, update=TRUE, is_keybind = FALSE)
|
|
if(!intentional)
|
|
return TRUE
|
|
var/cd = cooldown
|
|
if (is_keybind)
|
|
cd = 2 SECONDS // cooldown when used as a keybind
|
|
if(user.emotes_used && user.emotes_used[src] + cd > world.time)
|
|
return FALSE
|
|
if(!update)
|
|
return TRUE
|
|
if(!user.emotes_used)
|
|
user.emotes_used = list()
|
|
user.emotes_used[src] = world.time
|
|
return TRUE
|
|
|
|
/datum/emote/proc/get_sound(mob/living/user)
|
|
return sound //by default just return this var.
|
|
|
|
/datum/emote/proc/replace_pronoun(mob/user, message)
|
|
if(findtext(message, "their"))
|
|
message = replacetext(message, "their", user.p_their())
|
|
if(findtext(message, "them"))
|
|
message = replacetext(message, "them", user.p_them())
|
|
if(findtext(message, "%s"))
|
|
message = replacetext(message, "%s", user.p_s())
|
|
return message
|
|
|
|
/datum/emote/proc/select_message_type(mob/user, intentional)
|
|
. = message
|
|
if(!muzzle_ignore && user.is_muzzled() && emote_type == EMOTE_AUDIBLE)
|
|
return "makes a [pick("strong ", "weak ", "")]noise."
|
|
if(user.mind && user.mind.miming && message_mime)
|
|
. = message_mime
|
|
if(isalienadult(user) && message_alien)
|
|
. = message_alien
|
|
else if(islarva(user) && message_larva)
|
|
. = message_larva
|
|
else if(iscyborg(user) && message_robot)
|
|
. = message_robot
|
|
else if(isAI(user) && message_AI)
|
|
. = message_AI
|
|
else if(ismonkey(user) && message_monkey)
|
|
. = message_monkey
|
|
else if(isipc(user) && message_ipc)
|
|
. = message_ipc
|
|
else if(isanimal(user) && message_simple)
|
|
. = message_simple
|
|
|
|
/datum/emote/proc/select_param(mob/user, params)
|
|
return replacetext(message_param, "%t", params)
|
|
|
|
/**
|
|
* Check to see if the user is allowed to run the emote.
|
|
*
|
|
* Arguments:
|
|
* * user - Person that is trying to send the emote.
|
|
* * status_check - Bool that says whether we should check their stat or not.
|
|
* * intentional - Bool that says whether the emote was forced (FALSE) or not (TRUE).
|
|
*
|
|
* Returns a bool about whether or not the user can run the emote.
|
|
*/
|
|
/datum/emote/proc/can_run_emote(mob/user, status_check = TRUE, intentional = FALSE)
|
|
if(!is_type_in_typecache(user, mob_type_allowed_typecache))
|
|
return FALSE
|
|
if(is_type_in_typecache(user, mob_type_blacklist_typecache))
|
|
return FALSE
|
|
if(status_check && !is_type_in_typecache(user, mob_type_ignore_stat_typecache))
|
|
if(user.stat > stat_allowed)
|
|
if(!intentional)
|
|
return FALSE
|
|
switch(user.stat)
|
|
if(SOFT_CRIT)
|
|
to_chat(user, span_notice("You cannot [key] while in a critical condition."))
|
|
if(UNCONSCIOUS)
|
|
to_chat(user, span_notice("You cannot [key] while unconscious."))
|
|
if(DEAD)
|
|
to_chat(user, span_notice("You cannot [key] while dead."))
|
|
return FALSE
|
|
if(hands_use_check && HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
|
|
if(!intentional)
|
|
return FALSE
|
|
to_chat(user, span_warning("You cannot use your hands to [key] right now!"))
|
|
return FALSE
|
|
|
|
if(HAS_TRAIT(user, TRAIT_EMOTEMUTE))
|
|
return FALSE
|
|
|
|
return TRUE
|
|
|
|
/**
|
|
* Allows the intrepid coder to send a basic emote
|
|
* Takes text as input, sends it out to those who need to know after some light parsing
|
|
* If you need something more complex, make it into a datum emote
|
|
* Arguments:
|
|
* * text - The text to send out
|
|
*/
|
|
/mob/proc/manual_emote(text) //Just override the song and dance
|
|
. = TRUE
|
|
if(findtext(text, "their"))
|
|
text = replacetext(text, "their", p_their())
|
|
if(findtext(text, "them"))
|
|
text = replacetext(text, "them", p_them())
|
|
if(findtext(text, "%s"))
|
|
text = replacetext(text, "%s", p_s())
|
|
|
|
if(stat != CONSCIOUS)
|
|
return
|
|
|
|
if(!text)
|
|
CRASH("Someone passed nothing to manual_emote(), fix it")
|
|
|
|
log_message(text, LOG_EMOTE)
|
|
|
|
var/ghost_text = "<b>[src]</b> " + text //Sin I know
|
|
|
|
for(var/mob/M in GLOB.dead_mob_list)
|
|
if(!M.client || isnewplayer(M))
|
|
continue
|
|
var/T = get_turf(src)
|
|
if(M.stat == DEAD && M.client && (M.client.prefs.chat_toggles & CHAT_GHOSTSIGHT) && !(M in viewers(T, null)))
|
|
M.show_message("[FOLLOW_LINK(M, src)] [ghost_text]")
|
|
|
|
visible_message(text, visible_message_flags = EMOTE_MESSAGE)
|