|
@@ -2,7 +2,7 @@ const path = require('path'); const fs = require('fs');
|
|
|
module.exports = function AutoPOT(mod) {
|
|
module.exports = function AutoPOT(mod) {
|
|
|
const cmd = mod.command || mod.require.command, map = new WeakMap();
|
|
const cmd = mod.command || mod.require.command, map = new WeakMap();
|
|
|
let config = getConfig(), hpPot = getHP(), mpPot = getMP(), TmpData = [], aRes = null, aLoc = null, wLoc = 0, invUpdate = false, gPot = null;
|
|
let config = getConfig(), hpPot = getHP(), mpPot = getMP(), TmpData = [], aRes = null, aLoc = null, wLoc = 0, invUpdate = false, gPot = null;
|
|
|
- mod.game.initialize(['me', 'contract']);
|
|
|
|
|
|
|
+ mod.game.initialize(['me', 'contract', 'inventory']);
|
|
|
|
|
|
|
|
if (!map.has(mod.dispatch || mod)) {
|
|
if (!map.has(mod.dispatch || mod)) {
|
|
|
map.set(mod.dispatch || mod, {});
|
|
map.set(mod.dispatch || mod, {});
|
|
@@ -232,32 +232,24 @@ module.exports = function AutoPOT(mod) {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if (mod.majorPatchVersion => 85) {
|
|
if (mod.majorPatchVersion => 85) {
|
|
|
- mod.hook('S_ITEMLIST', 1, e => {
|
|
|
|
|
|
|
+ mod.hook('S_ITEMLIST', 'raw', e => {
|
|
|
if (!invUpdate && e.gameId === mod.game.me.gameId) {
|
|
if (!invUpdate && e.gameId === mod.game.me.gameId) {
|
|
|
invUpdate = true;
|
|
invUpdate = true;
|
|
|
- for(let hp = 0; hp < hpPot.length; hp++) {
|
|
|
|
|
- gPot = e.items.filter(item => item.id === s2n(hpPot[hp][0]));
|
|
|
|
|
- if (gPot.length > 0) hpPot[hp][1].amount = gPot.reduce(function (a, b) {return a + b.amount;}, 0);
|
|
|
|
|
- }
|
|
|
|
|
- for(let mp = 0; mp < mpPot.length; mp++) {
|
|
|
|
|
- gPot = e.items.filter(item => item.id === s2n(mpPot[mp][0]));
|
|
|
|
|
- if (gPot.length > 0) mpPot[mp][1].amount = gPot.reduce(function (a, b) {return a + b.amount;}, 0);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for(let hp = 0; hp < hpPot.length; hp++)
|
|
|
|
|
+ hpPot[hp][1].amount = mod.game.inventory.getTotalAmount(s2n(hpPot[hp][0]));
|
|
|
|
|
+ for(let mp = 0; mp < mpPot.length; mp++)
|
|
|
|
|
+ mpPot[mp][1].amount = mod.game.inventory.getTotalAmount(s2n(mpPot[mp][0]));
|
|
|
invUpdate = false;
|
|
invUpdate = false;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
- mod.hook('S_INVEN', 19, e => {
|
|
|
|
|
|
|
+ mod.hook('S_INVEN', 'raw', e => {
|
|
|
if (!invUpdate && e.gameId === mod.game.me.gameId) {
|
|
if (!invUpdate && e.gameId === mod.game.me.gameId) {
|
|
|
invUpdate = true;
|
|
invUpdate = true;
|
|
|
- for(let hp = 0; hp < hpPot.length; hp++) {
|
|
|
|
|
- gPot = e.items.filter(item => item.id === s2n(hpPot[hp][0]));
|
|
|
|
|
- if (gPot.length > 0) hpPot[hp][1].amount = gPot.reduce(function (a, b) {return a + b.amount;}, 0);
|
|
|
|
|
- }
|
|
|
|
|
- for(let mp = 0; mp < mpPot.length; mp++) {
|
|
|
|
|
- gPot = e.items.filter(item => item.id === s2n(mpPot[mp][0]));
|
|
|
|
|
- if (gPot.length > 0) mpPot[mp][1].amount = gPot.reduce(function (a, b) {return a + b.amount;}, 0);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for(let hp = 0; hp < hpPot.length; hp++)
|
|
|
|
|
+ hpPot[hp][1].amount = mod.game.inventory.getTotalAmount(s2n(hpPot[hp][0]));
|
|
|
|
|
+ for(let mp = 0; mp < mpPot.length; mp++)
|
|
|
|
|
+ mpPot[mp][1].amount = mod.game.inventory.getTotalAmount(s2n(mpPot[mp][0]));
|
|
|
invUpdate = false;
|
|
invUpdate = false;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|