-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
134 lines (130 loc) · 4.51 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
String.prototype.clr = function (hexColor) { return `<font color='#${hexColor}'>${this}</font>` }
const path = require('path')
const fs = require('fs')
const SettingsUI = require('tera-mod-ui').Settings
module.exports = function MoreDressingRoomItems(mod) {
mod.dispatch.addDefinition('S_REQUEST_STYLE_SHOP_MARK_PRODUCTLIST', 1, path.join(__dirname,'./defs/S_REQUEST_STYLE_SHOP_MARK_PRODUCTLIST.1.def'))
mod.dispatch.addOpcode('S_REQUEST_STYLE_SHOP_MARK_PRODUCTLIST', 20078)
let data = reloadJSON('./data/dressingroom.json'),
jobs = ['warrior','lancer','slayer','berserker','sorcerer','archer','priest','mystic','reaper','gunner','brawler','ninja','valkyrie'],
races = ['human-male','human-female','elf-male','elf-female','aman-male','aman-female','castanic-male','castanic-female','popori','elin','baraka'],
genders = ['male','female','male','female','male','female','male','female','male','female','male'],
my = { gameId:0, race:-1, job:-1 },
itemList = [],
debug = false
mod.hook('S_LOGIN', 14, event => {
my.gameId = event.gameId
my.race = Math.floor((event.templateId - 10101) / 100)
my.job = (event.templateId - 10101) % 100
loadData()
})
mod.hook('S_REQUEST_CONTRACT', 1, event => {
if (!mod.settings.enabled) return
if (debug) console.log('S_REQUEST_CONTRACT', JSON.stringify(event))
if (Number(event.type) == 77) {
mod.send('S_REQUEST_STYLE_SHOP_MARK_PRODUCTLIST', 1, {
list: itemList
})
}
if (debug) console.log('inDressingRoom', inDressingRoom)
})
mod.hook('S_REQUEST_STYLE_SHOP_MARK_PRODUCTLIST', 1, () => {
if (!mod.settings.enabled) return
return false
})
mod.command.add('dr', (arg1, arg2, arg3) => {
if(arg1 && arg1.length > 0) arg1 = arg1.toLowerCase()
if(arg2 && arg2.length > 0) arg2 = arg2.toLowerCase()
if(arg3 && arg3.length > 0) arg3 = arg3.toLowerCase()
switch (arg1) {
case 'ui':
case 'gui':
showGui()
break
case 'r':
case 'reload':
data = reloadJSON('./data/dressingroom.json')
loadData()
mod.command.message('data reloaded')
break
default:
mod.settings.enabled = !mod.settings.enabled
mod.command.message(mod.settings.enabled?'Enabled'.clr('56B4E9'):'Disabled'.clr('E69F00'))
break
}
return false
})
function reloadJSON(fileName) {
let file = {}
try {
file = JSON.parse(fs.readFileSync(path.join(__dirname, fileName), 'utf8'))
} catch (e) {
return
}
return file
}
function convertList(list) {
let convertedList = []
for (let item of list) {
convertedList.push({
type: 0,
id: item,
unk1: 0xFFFFFFFF,
unk2: 0,
unk3: 0,
unk4: false,
unk5: 0,
unk6: 1,
unk7: false,
string: ""
})
}
return convertedList
}
function loadData() {
itemList = []
// style weapon
if (mod.settings.weapon) { for (let item of data.weapon[jobs[my.job]]) { itemList.push(item) }}
// style body
if (mod.settings.body) { for (let item of data.body[races[my.race]]) { itemList.push(item) }}
// style face
if (mod.settings.face) { for (let item of data.face) { itemList.push(item) }}
// style hair
if (mod.settings.hair) { for (let item of data.hair[genders[my.race]]) { itemList.push(item) }}
// style back
if (mod.settings.back) { for (let item of data.back) { itemList.push(item) }}
// style effect
if (mod.settings.effect) { for (let item of data.effect) { itemList.push(item) }}
// style underwear
if (mod.settings.underwear) { for (let item of data.underwear) { itemList.push(item) }}
// style mount
if (mod.settings.mount) { for (let item of data.mount) { itemList.push(item) }}
// style servant
if (mod.settings.servant) { for (let item of data.servant) { itemList.push(item) }}
// style service
if (mod.settings.service) { for (let item of data.service[genders[my.race]]) { itemList.push(item) }}
itemList = convertList(itemList)
}
let gui = null;
if (global.TeraProxy.GUIMode) {
gui = new SettingsUI(mod, require('./settings_structure'), mod.settings, { height: 370, resizable: false });
gui.on('update', settings => { mod.settings = settings; loadData() });
this.destructor = () => {
if (gui) {
gui.close();
gui = null;
}
};
}
function showGui() {
if (!gui) return;
gui.show();
if (gui.ui.window) {
gui.ui.window.webContents.on("did-finish-load", () => {
gui.ui.window.webContents.executeJavaScript(
"!function(){var e=document.getElementById('close-btn');e.style.cursor='default',e.onclick=function(){window.parent.close()}}();"
);
});
}
}
}