加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
海比天蓝 提交于 2022-12-20 14:19 . tryHook
const fs = require('fs')
const path = require('path')
const UI = require('tera-mod-ui').Settings
exports.NetworkMod = function(mod) {
/* 增加映射码 add_Opcode */
const parseMap = require('tera-data-parser').parsers.Map;
const filename = `protocol.${mod.clientInterface.info.protocolVersion}.map`
const customMap = parseMap(path.join(__dirname, 'opcodes', filename))
for (var code in customMap) {
mod.dispatch.addOpcode(code, customMap[code])
}
/* UI设置 */
if (!global.TeraProxy.GUIMode) return
let ui = null, npcContact = null
let settings = { id: null, index: 0, questReward: -1, unk: -1 }
let structure = [{
key: "index", name: "副本传送石 快捷按钮", type: "select", options: [{ name: "-请手动选择-", key: 0 }]
}]
ui = new UI(mod, structure, settings, { height: 60 })
ui.on('update', result => {
if (!npcContact || !settings.id || settings.index==0) return
mod.send('C_DIALOG', 1, settings)
ui.close()
})
this.destructor = () => { if (ui) ui.close(), ui = null }
mod.hook('C_NPC_CONTACT', 2, e => {
npcContact = e.gameId
})
mod.hook('S_DIALOG', 3, e => {
if (!npcContact || !e.specialActionButton.enabled || mod.game.me.inDungeon) return
settings.id = e.id
e.buttons.forEach(btn => {
var zone = btn.text.replace(/[^\d]/g,"").substring(0, 4)
btn.key = btn.index
mod.queryData('/StrSheet_Dungeon/String@id=?', [Number(zone)]).then(result => {
if (!result || !result.attributes || !result.attributes.string) return
btn.name = result.attributes.string
})
structure[0].options.push(btn)
})
if (structure[0].options.length < 2) return
mod.send('S_CUSTOM_STYLE_SYSTEM_MESSAGE', 1, {
style: 44, message: `<font size="40">矮子才用命令进本</font>`
})
ui.show()
})
mod.tryHook('S_SOCIAL_CANCEL', 1, e => {
if (!npcContact || npcContact!=e.target) return
settings = { id: null, index: 0, questReward: -1, unk: -1 }
structure[0].options = [{name: "-请手动选择-", key: 0}]
npcContact = null
ui.update(settings)
ui.close()
})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化