maintenance update

* s/bce/fbc where is makes sense
* quick and dirty keydown filtering
* R84
* penetrators now use AllowActivity instead of Attribute
This commit is contained in:
Mute 2022-09-29 18:00:14 +00:00
parent 4930e5111b
commit ef41dd1dce

View File

@ -25,7 +25,7 @@
if (window.MBCHC) throw "MBCHC found, aborting loading"
window.MBCHC = {
VERSION: "trunk",
TARGET_VERSION: "R82",
TARGET_VERSION: "R84",
NEXT_MESSAGE: 1,
LOG_MESSAGES: false,
RETHROW: false,
@ -35,7 +35,6 @@
HISTORY_MODE: false,
RE_TITLE: /^[a-zA-Z]+$/,
RE_PREF_ACTIVITY_ME: /^@/,
// RE_PREF_ACTIVITY_ME_APO: /^@'/,
RE_PREF_ACTIVITY: /^@@/,
RE_ACT_CIDS: /^<(\d+)?:(\d+)?>/,
RE_TZ: /(?:GMT|UTC)([+-]\d\d?)/i,
@ -157,7 +156,7 @@
"ItemEars": ["ear", "ears", "earlobe", "earlobes"],
"ItemHead": ["head", "face", "hair", "eyes", "forehead"],
},
BCE_TESTER_PATCHES: [
FBC_TESTER_PATCHES: [
[/^\^('s)?( )?/g, "^SourceCharacter$1\\s+"],
[/([^\\])\$/g, "$1\\.?$$"],
],
@ -353,28 +352,28 @@
for (let name of this.HAND_PENETRATORS) {
let option = options.find(o => o.Name === name)
if (option && option.Property) {
if (!option.Property.Attribute) option.Property.Attribute = []
if (option.Property.Attribute.indexOf("PenetrateItem") < 0) option.Property.Attribute.push("PenetrateItem")
if (!option.Property.AllowActivity) option.Property.AllowActivity = []
if (option.Property.AllowActivity.indexOf("PenetrateItem") < 0) option.Property.AllowActivity.push("PenetrateItem")
}
}
},
copy_bce_trigger: function(trigger) {
copy_fbc_trigger: function(trigger) {
let result = {
Type: "Action",
Event: trigger.Event,
Matchers: trigger.Matchers.map(m => ({Tester: new RegExp(this.BCE_TESTER_PATCHES.reduce((ax,[f,r]) => ax.replaceAll(f,r), m.Tester.source), "u")}))
Matchers: trigger.Matchers.map(m => ({Tester: new RegExp(this.FBC_TESTER_PATCHES.reduce((ax,[f,r]) => ax.replaceAll(f,r), m.Tester.source), "u")}))
}
return(result)
},
patch_bce: function() {
this.remove_bce_hook()
delete this.remove_bce_hook
window.bce_ActivityTriggers.push(...window.bce_ActivityTriggers.filter(t => "Emote" === t.Type).map(t => this.copy_bce_trigger(t)))
/* (["anim", "pose"]).forEach(tag => {let cmd = window.Commands.find(c => tag === c.Tag); if (cmd) cmd.AutoComplete = this[`complete_bce_${tag}`]}) */ // this line explodes, don't ask me why
patch_fbc: function() {
this.remove_fbc_hook()
delete this.remove_fbc_hook
window.bce_ActivityTriggers.push(...window.bce_ActivityTriggers.filter(t => "Emote" === t.Type).map(t => this.copy_fbc_trigger(t)))
/* (["anim", "pose"]).forEach(tag => {let cmd = window.Commands.find(c => tag === c.Tag); if (cmd) cmd.AutoComplete = this[`complete_fbc_${tag}`]}) */ // this line explodes, don't ask me why
let cmd = window.Commands.find(c => "anim" === c.Tag)
if (cmd) cmd.AutoComplete = this.complete_bce_anim
if (cmd) cmd.AutoComplete = this.complete_fbc_anim
cmd = window.Commands.find(c => "pose" === c.Tag)
if (cmd) cmd.AutoComplete = this.complete_bce_pose
if (cmd) cmd.AutoComplete = this.complete_fbc_pose
},
gather_versions: function() { return(window.ChatRoomCharacter.filter(c => c.MBCHC).map(c => ({name: c.dn, cid: c.cid, version: c.MBCHC.VERSION}))) },
need_load_hook: function(module, screen) {
@ -511,14 +510,14 @@
}
mbchc.bell()
},
complete_bce_anim: function(args, locase, cmdline) { const [mbchc, input, tokens] = window.MBCHC.complete_common(); // `this` is command object
complete_fbc_anim: function(args, locase, cmdline) { const [mbchc, input, tokens] = window.MBCHC.complete_common(); // `this` is command object
if (tokens.length < 1) return
if (tokens.length < 2) return(mbchc.complete([`${mbchc.CommandsKey}${this.Tag}`]))
if (tokens.length > 2) return(mbchc.bell())
let anim = tokens[1].toLocaleLowerCase()
return(mbchc.complete(Object.keys(window.bce_EventExpressions).filter(a => a.toLocaleLowerCase().startsWith(anim))))
},
complete_bce_pose: function(args, locase, cmdline) { const [mbchc, input, tokens] = window.MBCHC.complete_common(); // `this` is command object
complete_fbc_pose: function(args, locase, cmdline) { const [mbchc, input, tokens] = window.MBCHC.complete_common(); // `this` is command object
if (tokens.length < 1) return
if (tokens.length < 2) return(mbchc.complete([`${mbchc.CommandsKey}${this.Tag}`]))
let pose = tokens[tokens.length - 1].toLocaleLowerCase()
@ -620,8 +619,6 @@
let input = window.ElementValue("InputChat")
if (!input.startsWith("@@@") && input.startsWith("@")) {
input = input.replace(window.MBCHC.RE_PREF_ACTIVITY, window.MBCHC.PREF_ACTIVITY)
// input = input.replace(window.MBCHC.RE_PREF_ACTIVITY_ME_APO, `${window.MBCHC.PREF_ACTIVITY}<${window.Player.cid}:>SourceCharacter'`)
// input = input.replace(window.MBCHC.RE_PREF_ACTIVITY_ME, `${window.MBCHC.PREF_ACTIVITY}<${window.Player.cid}:>SourceCharacter `)
input = input.replace(window.MBCHC.RE_PREF_ACTIVITY_ME, window.MBCHC.replace_me)
window.ElementValue("InputChat", input)
}
@ -672,7 +669,8 @@
window.MBCHC.sdk.hookFunction("DocumentKeyDown", 0, (nextargs, next) => {
let [event] = nextargs
if ("InputChat" === document.activeElement.id || "bce-message-input" === document.activeElement.id) return(next(nextargs))
if ("inline" === document.getElementById("InputChat")?.style.display) window.ElementFocus("InputChat")
if ("inline" === document.getElementById("InputChat")?.style.display && [event.altKey, event.ctrlKey, event.metaKey].every(i => !i)) window.ElementFocus("InputChat") // alt, ctrl and meta should all be false
// TODO: this is not ideal, but it will have to do for now
return(next(nextargs))
})
window.MBCHC.sdk.hookFunction("ChatRoomKeyDown", 0, (nextargs, next) => {
@ -692,8 +690,8 @@
window.MBCHC.complete_hint_hide()
return(next(nextargs))
})
window.MBCHC.remove_bce_hook = window.MBCHC.sdk.hookFunction("MainRun", 0, (nextargs, next) => {
if (window.bce_ActivityTriggers) window.MBCHC.patch_bce()
window.MBCHC.remove_fbc_hook = window.MBCHC.sdk.hookFunction("MainRun", 0, (nextargs, next) => {
if (window.bce_ActivityTriggers) window.MBCHC.patch_fbc()
return(next(nextargs))
})