diff --git a/mbchc-local.user.js b/mbchc-local.user.js index 8d62e8d..043b508 100644 --- a/mbchc-local.user.js +++ b/mbchc-local.user.js @@ -34,7 +34,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER RE_PREF_ACTIVITY_ME: /^@/, RE_PREF_ACTIVITY: /^@@/, RE_ACT_CHARS: /^<(\d+)?:(\d+)?>/, - RE_TZ: /(?:GMT|UTC)([+-]\d\d?)/, + RE_TZ: /(?:GMT|UTC)([+-]\d\d?)/i, RGB_MUTE: "#6c2132", RGB_POLLY: "#81b1e7", UTC_OFFSET: new Date().getTimezoneOffset() * 60 * 1000, @@ -163,6 +163,19 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER { Tag: "activity", Description: "[Message]: Send a custom activity (or \"@@Message\", or \"@Message\" as yourself)", Action: (argline, cmdline, args) => { window.MBCHC.command_activity(argline, cmdline, args) } }, { Tag: "do", Description: ": Do an activity, as if clicked on its button (\"/do\" for help)", Action: (argline, cmdline, args) => { window.MBCHC.command_do(argline, cmdline, args) } }, ], + calculate_maps: function() { + this.DO_DATA = {verbs: {}, zones: {}} + for (let [verbs, data] of Object.entries(this.MAP_ACTIONS)) { + let unwound = {} + for (let [zones, actions] of Object.entries(data)) { + let all = (actions.all) ? actions.all.split("|") : [] + let processed = {self: (actions.self) ? actions.self.split("|").concat(all) : all, others: (actions.others) ? actions.others.split("|").concat(all) : all} + for (let zone of zones.split(",")) unwound[`Item${zone}`] = processed + } + for (let verb of verbs.split("|")) this.DO_DATA.verbs[verb] = unwound + } + for (let [ag, zones] of Object.entries(this.MAP_ZONES)) for (let i in zones) this.DO_DATA.zones[zones[i]] = ag + }, settings: function(setting = null) { let settings = window.Player.OnlineSettings.MBCHC || {} return(setting ? settings[setting] : settings) @@ -209,9 +222,15 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER 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) + let activity = window.ActivityAllowedForGroup(char, char.FocusGroup.Name, true).find( a => a.Name === action) if (!activity) throw "invalid activity" - window.ActivityRun(char, activity) + if (activity.Name.endsWith("Item")) { + var dict = [{Tag: "NextAsset", AssetName: "SpankingToys"}, {Tag: "FocusAssetGroup", AssetGroupName: ag}, {Tag: "SourceCharacter", Text: window.CharacterNickname(window.Player), MemberNumber: window.Player.MemberNumber}] + dict.push({Tag: "DestinationCharacter", Text: window.CharacterNickname(char), MemberNumber: char.MemberNumber}) + window.ServerSend("ChatRoomChat", {Type: "Action", Content: `ActionActivity${activity.Name}`, Dictionary: dict}) + } else { + window.ActivityRun(char, activity) + } } finally { char.FocusGroup = null } }, @@ -293,11 +312,11 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER find_timezone: function(char) { let timezones = this.settings("timezones") if (timezones && timezones[char.MemberNumber]) return(timezones[char.MemberNumber]) - let match = char.Description.match(this.RE_TZ) + let match = (char.Description) ? char.Description.match(this.RE_TZ) : null if (match) return(Number.parseInt(match[1])) return(null) }, - player_enters_room: function() { + player_enters_room: function() { // FIXME: Description may not be ready yet this.hello() for (let i in window.ChatRoomCharacter) { let char = window.ChatRoomCharacter[i] @@ -346,25 +365,33 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER } } catch (x) { this.report(x) } }, command_activity: function(argline, cmdline, args) { if (!this.empty(argline)) { try { - let message = this.normalise_message(cmdline.replace(this.RE_ACTIVITY, ''), {trim: true, dot: true, up: true}) - this.send_activity(message) + let message = this.normalise_message(cmdline.replace(this.RE_ACTIVITY, ''), {trim: true, dot: true, up: true}) + this.send_activity(message) } catch (x) { this.report(x) } } }, command_do: function(argline, cmdline, args) { try { - if (args.length < 1) { - } - let char = window.Player - if ("-" !== args[0]) { - let id = Number.parseInt(args[0]) - let char = this.id2char(id) - } - if (!char) throw "invalid member number" - if (args.length < 2) { - } - if (args.length < 3) { - } - let ag = args[1] - let action = args[2] - this.run_activity(char, ag, action) + // 1. verb target + // 2. arousal for items + if (args.length < 1) return(this.inform("