-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
146 lines (128 loc) · 5.43 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
135
136
137
138
139
140
141
142
143
144
145
146
/* global ngapp, xelib, registerPatcher, patcherUrl */
// patcher for Mortal enemies
registerPatcher({
info: info,
gameModes: [xelib.gmSSE, xelib.gmTES5],
settings: {
label: "Mortal Enemiez Patcher",
hide: false,
templateUrl: `${patcherUrl}/partials/settings.html`,
defaultSettings: {
patchFileName: 'mortal_enemiez_patch.esp',
attackCommitment: "0"
}
},
requiredFiles: [],
getFilesToPatch: function(filenames) {
return filenames;
},
execute: (patchFile, helpers, settings, locals) => ({
initialize: function() {
helpers.logMessage('Mod: Mortal Enemiez Patcher');
helpers.logMessage('Version: 0.0.2');
helpers.logMessage('Author: holaholacocacola');
let attackConfig = require(patcherPath + '\\data\\attacks.json');
let moveTypeConfig = require(patcherPath + '\\data\\move_types.json');
locals.races = attackConfig["classifications"];
locals.raceAttackData = attackConfig["attackData"];
locals.raceCache = {}; // lets cache matches to not look up twice
locals.commitmentData = null;
//load commitmentData if applicable
if (settings.attackCommitment != "0") {
//helpers.logMessage("Loading commitment Data")
locals.commitmentData = require(patcherPath + '\\data\\move_types.json');
/* Load rival remix settings.
Rival remix adds a +15 offset to Rotate in place walk, run, while moving for the attacking movetypes
*/
if (settings.attackCommitment == "2") {
let attacksToModify = ["NPC_Attacking_MT", "NPC_PowerAttacking_MT", "NPC_Attacking2H_MT"];
for ( moveType of attacksToModify) {
locals.commitmentData[moveType]["Rotate in Place Walk"] += 15.00000;
locals.commitmentData[moveType]["Rotate in Place Run"] += 15.00000 ;
locals.commitmentData[moveType]["Rotate while Moving Run"] += 15.00000 ;
}
// This one adds 25 instead of 15. Oversight????
locals.commitmentData["NPC_PowerAttacking_MT"]["Rotate while Moving Run"] = 45.00000;
}
}
},
process: [{
// update move type
load: {
signature: 'MOVT',
filter: function(record) {
if (locals.commitmentData == null) { // I know the look on your face right now. Just know I write this with maximum shame :).
return false;
}
let recordId = xelib.GetValue(record, 'EDID');
return recordId in locals.commitmentData;
}
},
patch: function (record) {
let recordId = xelib.GetValue(record, 'EDID');
helpers.logMessage(recordId + ': updating movt');
for (moveType in locals.commitmentData[recordId]) {
helpers.logMessage(moveType);
xelib.SetFloatValue(record, `SPED\\${moveType}`, locals.commitmentData[recordId][moveType]);
}
}
},
{
/*
Try and match races by editor id, or full name
*/
load: {
signature: 'RACE',
filter: function(record) {
let recordId = xelib.GetValue(record, 'EDID');
//helpers.logMessage("record id is: " + recordId);
// First try and do a race match for vanilla. If that fails, try and do a match based on raceName likeness
if (recordId in locals.races) {
helpers.logMessage( recordId + " has vanilla entry");
locals.raceCache[recordId] = recordId;
return true;
}
if (xelib.HasElement(record, 'FULL')) {
let raceName = xelib.FullName(record);
let hasMatch = false;
for (var key in locals.races) {
let validSubRaces = locals.races[key];
if (validSubRaces.includes(raceName)) {
locals.raceCache[recordId] = key;
return true;
}
}
}
return false;
}
},
patch: function (record) {
let recordId = xelib.GetValue(record, 'EDID');
helpers.logMessage("Processing attack data for " + recordId);
let raceAttackData = locals.raceAttackData[locals.raceCache[recordId]];
xelib.SetFloatValue(record, 'DATA\\Angular Acceleration Rate', raceAttackData["Angular Acceleration"]);
xelib.SetFloatValue(record, 'DATA\\Unarmed Reach', raceAttackData["Unarmed Reach"]);
xelib.SetFloatValue(record, 'DATA\\Aim Angle Tolerance', raceAttackData["Angle Tolerance"]);
if (!xelib.HasElement(record, "Attacks") || Object.keys(raceAttackData["Attacks"]).length == 0) {
helpers.logMessage(recordId + " has no attack data");
return;
}
let attacks = xelib.GetElements(record, 'Attacks');
attacks.forEach(attack => {
let attackName = xelib.GetValue(attack, 'ATKE');
helpers.logMessage("Attack name is: " + attackName);
if ( attackName in raceAttackData["Attacks"]) {
// helpers.logMessage("Matched attack: " + attackName);
xelib.SetFloatValue(attack, 'ATKD\\Strike Angle', raceAttackData["Attacks"][attackName]["Strike Angle"]);
if ("Attack Angle" in raceAttackData["Attacks"][attackName]) {
xelib.SetFloatValue(attack, 'ATKD\\Attack Angle', raceAttackData["Attacks"][attackName]["Attack Angle"]);
}
}
});
}
}],
finalize: function() {
//what more do you want??
}
})
});