From 0d9e284d4442cf66b4b8a90312dcbec170ff99ec Mon Sep 17 00:00:00 2001 From: mute Date: Mon, 27 Jun 2022 20:36:31 +0000 Subject: [PATCH] Update 'mbchc-dev.user.js' --- mbchc-dev.user.js | 96 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/mbchc-dev.user.js b/mbchc-dev.user.js index 406e419..5543a4d 100644 --- a/mbchc-dev.user.js +++ b/mbchc-dev.user.js @@ -18,6 +18,8 @@ // Static data window.MBCHC = { + NEXT_MESSAGE: 1, + LOG_MESSAGES: false, LOADED: false, VERSION: 'dev', AUTOHACK_ENABLED: false, @@ -69,11 +71,73 @@ } catch (x) { window.ChatRoomSendLocal(`(Error: ${x.toString()})`) } }, }, + { Tag: "nod", + Description: ": Nod", + Action: (argline, cmdline, args) => { + try { + window.MBCHC.run_activity(window.Player, "ItemHead", "Nod") + } catch (x) { window.ChatRoomSendLocal(`(Error: ${x.toString()})`) } + }, + }, + { Tag: "shake", + Description: ": Shake your head", + Action: (argline, cmdline, args) => { + try { + window.MBCHC.run_activity(window.Player, "ItemHead", "Wiggle") + } catch (x) { window.ChatRoomSendLocal(`(Error: ${x.toString()})`) } + }, + }, + { Tag: "shrug", + Description: ": Shrug", + Action: (argline, cmdline, args) => { + try { + window.MBCHC.send_activity(`${window.CharacterNickname(window.Player)} shrugs.`) + } catch (x) { window.ChatRoomSendLocal(`(Error: ${x.toString()})`) } + }, + }, + { Tag: "myself", + Description: "[Message]: Send a custom activity as yourself (or \"@Message\")", + Action: (argline, cmdline, args) => { + if (!window.MBCHC.empty(argline)) { + try { + let message = window.MBCHC.add_full_stop(argline) + window.MBCHC.send_activity(`${window.CharacterNickname(window.Player)} ${message}`) + } catch (x) { window.ChatRoomSendLocal(`(Error: ${x.toString()})`) } + } + }, + }, + { Tag: "activity", + Description: "[Message]: Send a custom activity (or \"@@Message\")", + Action: (argline, cmdline, args) => { + if (!window.MBCHC.empty(argline)) { + try { + let message = window.MBCHC.add_full_stop(window.MBCHC.capitalise(argline)) + window.MBCHC.send_activity(message) + } catch (x) { window.ChatRoomSendLocal(`(Error: ${x.toString()})`) } + } + }, + }, ], log: function(msg) {return("MBCHC: " + msg.toString())}, + empty: function(text) { + if (!text) return(true) + if (String(text).trim().length < 1) return(true) + return(false) + }, + add_full_stop: function(text) { + if (text.endsWith('.')) return(text) + return(`${text}.`) + }, + capitalise: function(text, lower = false) { + let first = text.at(0).toLocaleUpperCase() + let rest = text.slice(1) + if (lower) rest = rest.toLocaleLowerCase() + return(first + rest) + }, orig_AsylumGGTSSAddItems: window.AsylumGGTSSAddItems, orig_ChatRoomMessageInvolvesPlayer: window.ChatRoomMessageInvolvesPlayer, orig_ChatRoomReceiveSuitcaseMoney: window.ChatRoomReceiveSuitcaseMoney, + orig_ChatRoomSendChat: window.ChatRoomSendChat, } // MBCHC // Loader @@ -101,7 +165,20 @@ window.ServerSend("ChatRoomChat", {Content: "ReceiveSuitcaseMoney", Type: "Hidden", Target: id}) return({cost: cost, name: (char.Nickname || char.Name)}) } - + window.MBCHC.run_activity = function(char, ag, action) { + try { + char.FocusGroup = window.AssetGroupGet(char.AssetFamily, ag) + if (!char.FocusGroup) throw "invalid AssetGroup" + let activity = window.ActivityAllowedForGroup(char, char.FocusGroup.Name).find( a => a.Name === action) + if (!activity) throw "invalid activity" + window.ActivityRun(char, activity) + } finally { + char.FocusGroup = null + } + } + window.MBCHC.send_activity = function(msg) { + window.ServerSend("ChatRoomChat", {Type: "Action", Content: "lef_wie234jf_owhwi", Dictionary: [{Tag: 'MISSING PLAYER DIALOG: lef_wie234jf_owhwi', Text: msg}]}) + } // Command actions window.MBCHC.action_title = function(args) { let title = args.shift() @@ -130,8 +207,12 @@ // Hooks window.ChatRoomMessageInvolvesPlayer = function(data) { -//console.log({data: data}) - if (("ReceiveSuitcaseMoney" === data.Content) && ("Hidden" === data.Type)) { window.MBCHC.LAST_HACKED = data.Sender } + if (!data.MBCHC_ID) { + data.MBCHC_ID = window.MBCHC.NEXT_MESSAGE + window.MBCHC.NEXT_MESSAGE += 1 + if (window.MBCHC.LOG_MESSAGES) console.debug(data) + if (("ReceiveSuitcaseMoney" === data.Content) && ("Hidden" === data.Type)) { window.MBCHC.LAST_HACKED = data.Sender } + } return(window.MBCHC.orig_ChatRoomMessageInvolvesPlayer(data)) } window.ChatRoomReceiveSuitcaseMoney = function() { @@ -143,6 +224,15 @@ } return(result) } + window.ChatRoomSendChat = function() { + let input = window.ElementValue("InputChat") + if (!input.startsWith("@@@")) { + input = input.replace(/^@@/, "/activity ") + input = input.replace(/^@/, "/myself ") + window.ElementValue("InputChat", input) + } + return(window.MBCHC.orig_ChatRoomSendChat()) + } // Actions window.CommandCombine(window.MBCHC.COMMANDS)