Browse Source

patch 85.x

Fukki 7 years ago
parent
commit
9878c9055b
2 changed files with 31 additions and 13 deletions
  1. 29 12
      index.js
  2. 2 1
      manifest.json

+ 29 - 12
index.js

@@ -231,20 +231,37 @@ module.exports = function AutoPOT(mod) {
 			useMP(Math.round(s2n(e.currentMp) / s2n(e.maxMp) * 100));
 	});
 	
-	mod.hook('S_INVEN', 19, e => {
-		if (!invUpdate) {
-			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);
+	if (mod.majorPatchVersion => 85) {
+		mod.hook('S_ITEMLIST', 1, e => {
+			if (!invUpdate && e.gameId === mod.game.me.gameId) {
+				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);
+				}
+				invUpdate = false;
 			}
-			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);
+		});
+	} else {
+		mod.hook('S_INVEN', 19, e => {
+			if (!invUpdate && e.gameId === mod.game.me.gameId) {
+				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);
+				}
+				invUpdate = false;
 			}
-			invUpdate = false;
-		}
-	});
+		});
+	}
 	
 	mod.hook('S_RETURN_TO_LOBBY', 'raw', () => {
 		for (let hp = 0; hp < hpPot.length; hp++)

+ 2 - 1
manifest.json

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