From 7187a5e8e5691a989f6134869a32531ed3a52c6b Mon Sep 17 00:00:00 2001 From: VampyrBytes Date: Mon, 13 Jun 2016 18:12:05 +0100 Subject: [PATCH] Bugfixes --- code/datums/Emote_system/emote.dm | 83 ++++++++++++++------- code/datums/Emote_system/emote_handler.dm | 16 +++-- code/datums/Emote_system/emotes.dm | 88 +++++++++++++++++++---- code/modules/mob/dead/observer/say.dm | 3 + code/modules/mob/emote.dm | 4 +- code/modules/mob/say.dm | 7 +- 6 files changed, 147 insertions(+), 54 deletions(-) diff --git a/code/datums/Emote_system/emote.dm b/code/datums/Emote_system/emote.dm index 3015d42f4ac..ee06d9f78ab 100644 --- a/code/datums/Emote_system/emote.dm +++ b/code/datums/Emote_system/emote.dm @@ -8,6 +8,7 @@ VampyrBytes *******************************************************************************************************/ #define EMOTE_COOLDOWN 20 //Time in deciseconds that the cooldown lasts #define HEARING_RANGE 7 +#define INVALID -1 //Using -1 as I can't see how a negative number could be a valid input /datum/emote var/name = "" @@ -15,7 +16,7 @@ VampyrBytes var/list/commands[0] // commands that trigger the emote. Set these in New() var/text = "" var/selfText = "" // the version of text that you should see - eg, if text is screams, you want scream here, as You screams is bad grammer - var/startText = "" // if you need to put something in before [user]. Should end with a space + var/startText = "" // if you need to put something in before [user] var/selfStart = 1 // whether the start text is used in what you see var/audible = 0 @@ -71,7 +72,7 @@ VampyrBytes params = getParams(user) for(var/p in params) - if(params[p] == "invalid") + if(params[p] == INVALID) return if(text) @@ -82,7 +83,7 @@ VampyrBytes . = processMessage(user, params, message) if(!doMime(user) && (!muzzleAffected || !isMuzzled(user))) - if(playSound(user, vol)) + if(playSound(user, params)) . = 2 doAction(user, params) @@ -101,13 +102,21 @@ VampyrBytes var/list/params[0] if(takesNumber) + user.set_typing_indicator(1) + user.hud_typing = 1 params["num"] = getNumber(user) + user.hud_typing = 0 + user.set_typing_indicator(0) if(canTarget) + user.set_typing_indicator(1) + user.hud_typing = 1 params["target"] = getTarget(user) + user.hud_typing = 0 + user.set_typing_indicator(0) return params -// return "invalid" from either of these getters if you've tested the input and it's failed +// return INVALID from either of these getters if you've tested the input and it's failed /datum/emote/proc/getNumber(var/mob/user) var/number = input("How many?", "Enter number") as null|num return number @@ -120,11 +129,11 @@ VampyrBytes return getAtomTarget(user) /datum/emote/proc/getMobTarget(var/mob/user) - var/mob/target = input("Select target", "Target Mob") as null|mob in view() + var/mob/target = input("Select target", "Target Mob") as null|mob in view(getLoc(user)) return target /datum/emote/proc/getAtomTarget(var/mob/user) - var/atom/target = input("Select target", "Target") as null|mob|obj|turf in oview() + var/atom/target = input("Select target", "Target") as null|mob|obj|turf in oview(getLoc(user)) return target // returns the reason the user can't currently do the emote @@ -264,14 +273,9 @@ VampyrBytes if(doMime(user)) visualOrAudible = 1 - var/location = checkForHolopad(user) - if(!location) - location = user - log_emote("[user.name]/[user.key] : [message]") sendToDead(message) - testing(message) - for(var/mob/M in getRecipients(location, visualOrAudible)) + for(var/mob/M in getRecipients(getLoc(user, message), visualOrAudible)) var/msg = "" if(M==user) @@ -326,14 +330,21 @@ VampyrBytes msg = replaceMobWithYou(M, msg, user) to_chat(M, msg) -/datum/emote/proc/checkForHolopad(var/mob/user, var/message) +/datum/emote/proc/getLoc(var/mob/user, var/message = "") + var/loc = checkForHolopad(user, message) + if(loc) + return loc + return user + +/datum/emote/proc/checkForHolopad(var/mob/user, var/message = "") if(!isAI(user)) return var/mob/living/silicon/ai/AI = user var/obj/machinery/hologram/holopad/T = AI.holo if(!(T && T.hologram && T.master == AI)) return - to_chat(AI, "Holopad action relayed, [AI.real_name] [message]") + if(message) + to_chat(AI, "Holopad action relayed, [message]") return T /datum/emote/proc/handleListeningObjects(var/mob/user, var/message = "") @@ -410,7 +421,7 @@ VampyrBytes /datum/emote/proc/swapHisToYour(var/mob/user, var/message = "") var/his = getHis(user) - message = replacetext(message, his, "your") + message = replacetext(message, " [his] ", " your ") return message /datum/emote/proc/getHimself(var/mob/user) @@ -420,7 +431,7 @@ VampyrBytes /datum/emote/proc/swapHimselfToYourself(var/mob/user, var/message) var/himself = getHimself(user) - message = replacetext(message, himself, "yourself") + message = replacetext(message, "[himself]", "yourself") return message /****************************************************************************************** @@ -446,7 +457,7 @@ VampyrBytes return owner = user emote = toAccess - name = emote.name + name = "[emote]" loc = user user.verbs += new/obj/emoteVerb/proc/runEmote(src, emote.commands[1], emote.desc) @@ -468,17 +479,17 @@ obj/emoteVerb/custom/New(var/mob/user) name = "custom" user.verbs += new/obj/emoteVerb/proc/runEmote(src, "custom", "Make your own emote") -/obj/emoteVerb/custom/runEmote(message as text, audible as num) +/obj/emoteVerb/custom/runEmote() set src = usr.contents set category = "Emotes" - return usr.emoteHandler.runEmote("me", null, message, audible) + return usr.emoteHandler.runEmote("me") + /************************************************************************************************************************** Custom Emotes As these are made as needed, they aren't searched for the appropriate one. As such, you need to specify conditions for which -one is used in /datum/emote_handler/customEmote(). As the checks for the type are done there, you chouldn't need to override -available, but if you do, make sure you return ..() so the check for use_me is still done - VampyrBytes +one is used in /datum/emote_handler/customEmote(). ***************************************************************************************************************************/ @@ -492,17 +503,27 @@ available, but if you do, make sure you return ..() so the check for use_me is s text = message audible = isAudible - /datum/emote/custom/proc/getMessage(var/mob/user) - var/input = sanitize(copytext(input(user,"Choose an emote to display.") as text|null,1,MAX_MESSAGE_LEN)) +// user.set_typing_indicator(1) +// user.hud_typing = 1 + var/input = sanitize(copytext(input(user,"What do you want to emote?.", "Custom emote") as text|null,1,MAX_MESSAGE_LEN)) +// user.hud_typing = 0 +// user.set_typing_indicator(0) + input = strip_html_properly(input) return input /datum/emote/custom/available(var/mob/user) - if(user.use_me) - return 1 + return 1 + +/datum/emote/custom/prevented(var/mob/user) + if(!user.use_me) + return "you are prevented from using custom emotes" // Yeah, no -/datum/emote/custom/createSelfMessage(var/mob/user, var/message = "") +/datum/emote/custom/createSelfMessage(var/mob/user, var/list/params, var/message = "") + return + +/datum/emote/custom/replaceMobWithYou(var/mob/M, var/message = "", var/mob/user) return message /datum/emote/custom/ghost @@ -511,6 +532,9 @@ available, but if you do, make sure you return ..() so the check for use_me is s emoteSpanClass = "game deadsay" /datum/emote/custom/ghost/prevented(var/mob/user) + . = ..() + if(.) + return if(user.client.prefs.muted & MUTE_DEADCHAT) return "you are muted from deadchat" if(!(user.client.prefs.toggles & CHAT_DEAD)) @@ -519,7 +543,12 @@ available, but if you do, make sure you return ..() so the check for use_me is s if(!config.dsay_allowed) return "deadchat is globally muted" -/datum/emote/custom/ghost/processMessage(var/mob/user, var/message = "") +/datum/emote/custom/ghost/getMessage(var/mob/user) + var/input = sanitize(copytext(input(user,"What do you want to emote?.", "Custom emote") as text|null,1,MAX_MESSAGE_LEN)) + input = strip_html_properly(input) + return input + +/datum/emote/custom/ghost/processMessage(var/mob/user, var/list/params, var/message = "") if(!message) return log_emote("Ghost/[user.key] : [message]") diff --git a/code/datums/Emote_system/emote_handler.dm b/code/datums/Emote_system/emote_handler.dm index 1417e83f9a8..0e2b8fd0238 100644 --- a/code/datums/Emote_system/emote_handler.dm +++ b/code/datums/Emote_system/emote_handler.dm @@ -32,15 +32,23 @@ return 1 var/datum/emote/emote + + if(copytext(command, 1, 3) == "me" && !message && lentext(command) >= 4) + message = copytext(command, 4) + command = "me" + if(command == "me") emote = customEmote(message, audible) if(!emote) return 0 + if(!commands[command] && !(command == "me")) to_chat(owner, "Unknown emote, please check *help for emotes available to your character") return 0 + if(!emote) emote = commands[command] + if(!emote.available(owner)) // something's changed, remake the commands list, then try again to see if they've got a different version setupCommands() return runEmote(command, message, audible) @@ -77,10 +85,6 @@ return emote /datum/emoteHandler/proc/customEmote(var/custom, var/audible) - var/datum/emote/custom/emote if(isobserver(owner)) - emote = new /datum/emote/custom/ghost - else - emote = new /datum/emote/custom(owner, custom, audible) - if (emote.available(owner)) - return emote + return new /datum/emote/custom/ghost(owner, custom, audible) + return new /datum/emote/custom(owner, custom, audible) diff --git a/code/datums/Emote_system/emotes.dm b/code/datums/Emote_system/emotes.dm index 190759df693..3e7058d3f7a 100644 --- a/code/datums/Emote_system/emotes.dm +++ b/code/datums/Emote_system/emotes.dm @@ -2,7 +2,7 @@ Emotes New() must call ..() to set the baseLevel for the emoteHandler search. As the commands are set in New(), this means that the emote will pick up all the commands from the emotes -above it. If you don't want this, make the call to ..() then use commands.cut() +above it. If you don't want this, make the call to ..() then use commands = new /list() *************************************************************************************/ /datum/emote/airguitar @@ -456,6 +456,12 @@ above it. If you don't want this, make the call to ..() then use commands.cut() var/message = "\The [user] [U.species.death_message]" return message +/datum/emote/deathgasp/human/createSelfMessage(var/mob/user, var/list/params, var/message) + return message + +/datum/emote/deathgasp/human/replaceMobWithYou(var/mob/user, var/message) + return message + /datum/emote/deathgasp/robot text = "shudders violently for a moment, then becomes motionless, its eyes slowly darkening." selfText = "shudder violently for a moment, then become motionless, your eyes slowly darkening." @@ -576,8 +582,8 @@ above it. If you don't want this, make the call to ..() then use commands.cut() if(TOXIC_FARTS in user.mutations) message = "\The [user] unleashes a [pick("horrible","terrible","foul","disgusting","awful")] fart." - else - message = "\The [user] [pick("passes wind","farts")]." + return message + message = "\The [user] [pick("passes wind","farts")]." return message /datum/emote/fart/createSelfMessage(var/mob/user, var/list/params, var/message) @@ -929,6 +935,10 @@ above it. If you don't want this, make the call to ..() then use commands.cut() ..() commands += "handshake" +/datum/emote/handshake/available(var/mob/user) + if(ishuman(user)) + return 1 + /datum/emote/handshake/prevented(var/mob/user) . = ..() if(!. && user.r_hand) @@ -936,9 +946,10 @@ above it. If you don't want this, make the call to ..() then use commands.cut() /datum/emote/handshake/getMobTarget(var/mob/user) var/mob/target = ..() - if(!target) - to_chat(user, "You need someone to shake hands with") - return "invalid" + if(target) + return target + to_chat(user, "You need someone to shake hands with") + return INVALID /datum/emote/handshake/addTarget(var/mob/user, var/list/params, var/message) var/mob/target = params["target"] @@ -970,6 +981,7 @@ above it. If you don't want this, make the call to ..() then use commands.cut() selfText = "hug" canTarget = 1 targetMob = 1 + targetText = "" /datum/emote/hug/New() ..() @@ -1026,7 +1038,7 @@ above it. If you don't want this, make the call to ..() then use commands.cut() if(target && target != user) return target to_chat(user, "You need a target that isn't yourself") - return "invalid" + return INVALID /datum/emote/johnny/createMessage(var/mob/user, var/params) if(doMime(user)) @@ -1048,6 +1060,10 @@ above it. If you don't want this, make the call to ..() then use commands.cut() return message return ..() +/datum/emote/johnny/createBlindMessage(var/mob/user, var/list/params, var/message) + message = "You hear someone say \"[params["target"]], please, They had a family\"" + return message + /datum/emote/jump name = "jump" desc = "Makes the mob jump" @@ -1060,7 +1076,9 @@ above it. If you don't want this, make the call to ..() then use commands.cut() commands += "jumps" /datum/emote/jump/available(var/mob/user) - if(islarva(user)) + if(islarva(user) || isalienadult(user)) + return 1 + if(issmall(user)) return 1 /datum/emote/laugh @@ -1140,6 +1158,12 @@ above it. If you don't want this, make the call to ..() then use commands.cut() if(isrobot(user)) return 1 +/datum/emote/look/addTarget(var/mob/user, var/list/params, var/message) + if(!params["target"]) + message += " around" + return message + return ..() + /datum/emote/moan name = "moan" desc = "Makes the mob moan" @@ -1348,6 +1372,8 @@ above it. If you don't want this, make the call to ..() then use commands.cut() /datum/emote/roll/available(var/mob/user) if(islarva(user)) return 1 + if(issmall(user)) + return 1 /datum/emote/salute name = "salute" @@ -1374,6 +1400,12 @@ above it. If you don't want this, make the call to ..() then use commands.cut() if(!. && user.buckled) return "you are buckled to something" +/datum/emote/salute/getMobTarget(var/mob/user) + var/mob/target = ..() + if(target == user) + return + return target + /datum/emote/scratch name = "scratch" desc = "Makes the mob scratch" @@ -1389,6 +1421,8 @@ above it. If you don't want this, make the call to ..() then use commands.cut() /datum/emote/scratch/available(var/mob/user) if(islarva(user) || isalienadult(user)) return 1 + if(issmall(user)) + return 1 /datum/emote/scream name = "scream" @@ -1487,6 +1521,9 @@ above it. If you don't want this, make the call to ..() then use commands.cut() if(ishuman(user)) return 1 +/datum/emote/shiver/createBlindMessage(var/mob/user, var/list/params, var/message) + message = "you hear someone's teeth chattering together" + /datum/emote/shrug name = "shrug" desc = "Makes the mob shrug" @@ -1542,7 +1579,7 @@ above it. If you don't want this, make the call to ..() then use commands.cut() var/number = ..() if(number == null) to_chat(user, "You need a number to sign") - return "invalid" + return INVALID return number /datum/emote/sign/paramMessage(var/mob/user, var/list/params) @@ -1560,8 +1597,8 @@ above it. If you don't want this, make the call to ..() then use commands.cut() /datum/emote/sign/fingers/getNumber(var/mob/user) var/number = ..() - if(number == "invalid") - return "invalid" + if(number == INVALID) + return INVALID var/fingersAvailable = 0 if(!user.r_hand) fingersAvailable += 5 @@ -1569,7 +1606,7 @@ above it. If you don't want this, make the call to ..() then use commands.cut() fingersAvailable += 5 if(fingersAvailable < number) to_chat(user, "You don't have enough fingers free") - return "invalid" + return INVALID return number /datum/emote/sign/fingers/paramMessage(var/mob/user, var/list/params) @@ -1602,6 +1639,11 @@ above it. If you don't want this, make the call to ..() then use commands.cut() target = user return target +/datum/emote/slap/createBlindMessage(var/mob/user, var/list/params, var/message) + message = ..() + message = replacetext(message, "someone", "a") + return message + /datum/emote/slap/doAction(var/mob/user, var/list/params) if(user == params["target"]) var/mob/living/U = user @@ -1663,6 +1705,7 @@ above it. If you don't want this, make the call to ..() then use commands.cut() if(!params["prob"]) return message message += " right off!" + return message /datum/emote/snap/playSound(var/mob/user, var/list/params) if(params["prob"]) @@ -1670,6 +1713,14 @@ above it. If you don't want this, make the call to ..() then use commands.cut() return 1 return ..() +/datum/emote/snap/createBlindMessage(var/mob/user, var/list/params, var/message) + message = ..() + message += " their fingers" + return message + +/datum/emote/snap/createDeafMessage(var/mob/user, var/list/params, var/message) + return message + /datum/emote/sneeze name = "sneeze" desc = "Makes the mob sneezze" @@ -1815,6 +1866,8 @@ above it. If you don't want this, make the call to ..() then use commands.cut() /datum/emote/tail/available(var/mob/user) if(islarva(user) || isalienadult(user)) return 1 + if(issmall(user)) + return 1 /datum/emote/tail/wag name = "wag" @@ -1829,6 +1882,8 @@ above it. If you don't want this, make the call to ..() then use commands.cut() commands += "wags" /datum/emote/tail/wag/available(var/mob/user) + if(issmall(user)) + return if(ishuman(user)) return 1 @@ -1869,9 +1924,12 @@ above it. If you don't want this, make the call to ..() then use commands.cut() commands += "swags" // seemingly no way to tell if a mob is wagging it's tail! VB -/datum/emote/tail/wag/stop/available(var/mob/user) +/datum/emote/tail/wag/stop/prevented(var/mob/user) + . = ..() + if(.) + return var/mob/living/carbon/human/H = user - if(!H.species.bodyflags & TAIL_WAGGING && !H.body_accessory) + if(!(H.species.bodyflags & TAIL_WAGGING) && !H.body_accessory) return "you can't stop wagging a tail you don't have!" /datum/emote/tail/wag/stop/doAction(var/mob/user, var/list/params) @@ -2004,7 +2062,7 @@ above it. If you don't want this, make the call to ..() then use commands.cut() name = "wink" desc = "Makes the mob wink" text = "winks" - desc = "wink" + selfText = "wink" /datum/emote/wink/New() ..() diff --git a/code/modules/mob/dead/observer/say.dm b/code/modules/mob/dead/observer/say.dm index 022fbb85a5d..f3e22bbea50 100644 --- a/code/modules/mob/dead/observer/say.dm +++ b/code/modules/mob/dead/observer/say.dm @@ -14,6 +14,9 @@ if (src.client.handle_spam_prevention(message,MUTE_DEADCHAT)) return + if(copytext(message,1,2) == "*") + return emote(copytext(message,2)) + . = src.say_dead(message) /* diff --git a/code/modules/mob/emote.dm b/code/modules/mob/emote.dm index 2832d70c90a..f4accd830b8 100644 --- a/code/modules/mob/emote.dm +++ b/code/modules/mob/emote.dm @@ -15,9 +15,9 @@ //--FalseIncarnate */ // All mobs should have custom emote, really.. -/mob/proc/custom_emote(var/m_type=1,var/message = null) +/mob/proc/custom_emote(var/m_type=0, var/message = null) - return emoteHandler.runEmote("me", null, message, m_type) + return emoteHandler.runEmote("me", message, m_type) /* if(stat || !use_me && usr == src) to_chat(usr, "You are unable to emote.") diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm index 9d0790c3789..4b332cca061 100644 --- a/code/modules/mob/say.dm +++ b/code/modules/mob/say.dm @@ -27,14 +27,13 @@ set_typing_indicator(0) usr.say(message) -/mob/verb/me_verb(message as text) + +/mob/verb/me_verb() set name = "Me" set category = "Emotes" - message = strip_html_properly(message) + return emoteHandler.runEmote("me") - set_typing_indicator(0) - return emoteHandler.runEmote("me", null, message) /mob/proc/say_dead(var/message) if(!(client && client.holder))