Fukki лет назад: 7
Родитель
Сommit
95fe84d786
2 измененных файлов с 14 добавлено и 22 удалено
  1. 11 19
      index.js
  2. 3 3
      manifest.json

+ 11 - 19
index.js

@@ -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;
 			}
 			}
 		});
 		});

+ 3 - 3
manifest.json

@@ -1,6 +1,6 @@
 {
 {
 	"files": {
 	"files": {
-		"index.js": "666af348a17abac4777b9203119c9ce35262c57ec0645e894c99d83ceb5d9b47"
+		"index.js": "d1b615d83660750334eae6a9f34b73fc622f3cf6030f7cc054b3330c22e8038d"
 	},
 	},
 	"defs": {
 	"defs": {
 		"C_ADMIN": 1,
 		"C_ADMIN": 1,
@@ -9,8 +9,8 @@
 		"C_USE_ITEM": 3,
 		"C_USE_ITEM": 3,
 		"S_ANNOUNCE_UPDATE_NOTIFICATION": 1,
 		"S_ANNOUNCE_UPDATE_NOTIFICATION": 1,
 		"S_CREATURE_CHANGE_HP": 6,
 		"S_CREATURE_CHANGE_HP": 6,
-		"S_INVEN": 19,
-		"S_ITEMLIST": 1,
+		"S_INVEN": "raw",
+		"S_ITEMLIST": "raw",
 		"S_PLAYER_CHANGE_MP": 1,
 		"S_PLAYER_CHANGE_MP": 1,
 		"S_RETURN_TO_LOBBY": "raw",
 		"S_RETURN_TO_LOBBY": "raw",
 		"S_SPAWN_ME": 3
 		"S_SPAWN_ME": 3