Keybindable emotes followup (#47868)

Keybindable emotes followup
This commit is contained in:
Emmett Gaines
2019-11-20 00:54:30 +00:00
committed by Rob Bailey
parent eb4a43cab5
commit 53952e7622
7 changed files with 50 additions and 9 deletions

View File

@@ -153,7 +153,7 @@
return FALSE
/mob/living/split_personality/emote(act, m_type = null, message = null, intentional = FALSE)
return
return FALSE
///////////////BRAINWASHING////////////////////

View File

@@ -23,6 +23,7 @@
var/sound //Sound to play when emote is called
var/vary = FALSE //used for the honk borg emote
var/only_forced_audio = FALSE //can only code call this event instead of the player.
var/cooldown = 0.8 SECONDS
/datum/emote/New()
if (ispath(mob_type_allowed_typecache))
@@ -75,6 +76,17 @@
else
user.visible_message(msg)
/// For handling emote cooldown, return true to allow the emote to happen
/datum/emote/proc/check_cooldown(mob/user, intentional)
if(!intentional)
return TRUE
if(user.emotes_used && user.emotes_used[src] + cooldown > world.time)
return FALSE
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.

View File

@@ -12,4 +12,4 @@
/datum/keybinding/emote/down(client/user)
. = ..()
user.mob.emote(emote_key)
return user.mob.emote(emote_key, intentional=TRUE)

View File

@@ -24,4 +24,4 @@
return FALSE
/mob/camera/emote(act, m_type=1, message = null, intentional = FALSE)
return
return FALSE

View File

@@ -7,18 +7,22 @@
param = copytext(act, custom_param + 1, length(act) + 1)
act = copytext(act, 1, custom_param)
var/list/key_emotes = GLOB.emote_list[act]
if(!length(key_emotes))
if(intentional)
to_chat(src, "<span class='notice'>'[act]' emote does not exist. Say *help for a list.</span>")
return
return FALSE
var/silenced = FALSE
for(var/datum/emote/P in key_emotes)
if(!P.check_cooldown(src, intentional))
silenced = TRUE
continue
if(P.run_emote(src, param, m_type, intentional))
return
if(intentional)
return TRUE
if(intentional && !silenced)
to_chat(src, "<span class='notice'>Unusable emote '[act]'. Say *help for a list.</span>")
return FALSE
/datum/emote/flip
key = "flip"
@@ -32,6 +36,28 @@
if(.)
user.SpinAnimation(7,1)
/datum/emote/flip/check_cooldown(mob/user, intentional)
. = ..()
if(.)
return
if(!can_run_emote(user, intentional=intentional))
return
if(isliving(user))
var/mob/living/flippy_mcgee = user
if(prob(20))
flippy_mcgee.Knockdown(1 SECONDS)
flippy_mcgee.visible_message(
"<span class='notice'>[flippy_mcgee] attempts to do a flip and falls over, what a doofus!</span>",
"<span class='notice'>You attempt to do a flip while still off balance from the last flip and fall down!</span>"
)
if(prob(50))
flippy_mcgee.adjustBruteLoss(1)
else
flippy_mcgee.visible_message(
"<span class='notice'>[flippy_mcgee] stumbles a bit after their flip.</span>",
"<span class='notice'>You stumble a bit from still being off balance from your last flip.</span>"
)
/datum/emote/spin
key = "spin"
key_third_person = "spins"

View File

@@ -358,8 +358,8 @@
/mob/living/simple_animal/emote(act, m_type=1, message = null, intentional = FALSE)
if(stat)
return
. = ..()
return FALSE
return ..()
/mob/living/simple_animal/proc/set_varspeed(var_value)
speed = var_value

View File

@@ -205,3 +205,6 @@
var/bloody_hands = 0
var/datum/focus //What receives our keyboard inputs. src by default
/// Used for tracking last uses of emotes for cooldown purposes
var/list/emotes_used