Fukki 8 years ago
parent
commit
9e9eb6d8f6
2 changed files with 14 additions and 4 deletions
  1. 13 3
      index.js
  2. 1 1
      manifest.json

+ 13 - 3
index.js

@@ -1,6 +1,6 @@
 const path = require('path'); const fs = require('fs');
 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;
+	const cmd = mod.command || mod.require.command, proxyRegion = mod.region.toLowerCase();
 	let config = getConfig(), hpPot = getHP(), mpPot = getMP();
 	let config = getConfig(), hpPot = getHP(), mpPot = getMP();
 	let getInv = false, useCombat = false, isSlaying = false, nowHP = 0, nowMP = 0;
 	let getInv = false, useCombat = false, isSlaying = false, nowHP = 0, nowMP = 0;
 
 
@@ -68,7 +68,7 @@ module.exports = function AutoPOT(mod) {
 			nowHP = Math.round(parseInt(e.hp) / parseInt(e.maxHp) * 100);
 			nowHP = Math.round(parseInt(e.hp) / parseInt(e.maxHp) * 100);
 			for (let hp = 0; hp < hpPot.length; hp++) {
 			for (let hp = 0; hp < hpPot.length; hp++) {
 				useCombat = hpPot[hp][1].inCombat ? mod.game.me.inCombat : true;
 				useCombat = hpPot[hp][1].inCombat ? mod.game.me.inCombat : true;
-				if (!hpPot[hp][1].inCd && ((!isSlaying && nowHP <= hpPot[hp][1].use_at && useCombat) || (isSlaying && nowHP <= hpPot[hp][1].slay_at && mod.game.me.inCombat)) && hpPot[hp][1].amount > 0 && mod.game.me.alive && !mod.game.me.inBattleground &&!mod.game.me.mounted) {
+				if (!hpPot[hp][1].inCd && ((!isSlaying && nowHP <= hpPot[hp][1].use_at && useCombat) || (isSlaying && nowHP <= hpPot[hp][1].slay_at && mod.game.me.inCombat)) && hpPot[hp][1].amount > 0 && mod.game.me.alive && inContract() && !mod.game.me.inBattleground &&!mod.game.me.mounted) {
 					useItem(hpPot[hp]); hpPot[hp][1].inCd = true; hpPot[hp][1].amount--; setTimeout(function () {hpPot[hp][1].inCd = false;}, hpPot[hp][1].cd * 1000);
 					useItem(hpPot[hp]); hpPot[hp][1].inCd = true; hpPot[hp][1].amount--; setTimeout(function () {hpPot[hp][1].inCd = false;}, hpPot[hp][1].cd * 1000);
 					if (config.notice) msg(`Used ${hpPot[hp][1].name}, still have ${(hpPot[hp][1].amount)} left.`);
 					if (config.notice) msg(`Used ${hpPot[hp][1].name}, still have ${(hpPot[hp][1].amount)} left.`);
 				}
 				}
@@ -78,13 +78,23 @@ module.exports = function AutoPOT(mod) {
 			nowMP = Math.round(parseInt(e.mp) / parseInt(e.maxMp) * 100);
 			nowMP = Math.round(parseInt(e.mp) / parseInt(e.maxMp) * 100);
 			for (let mp = 0; mp < mpPot.length; mp++) {
 			for (let mp = 0; mp < mpPot.length; mp++) {
 				useCombat = mpPot[mp][1].inCombat ? mod.game.me.inCombat : true;
 				useCombat = mpPot[mp][1].inCombat ? mod.game.me.inCombat : true;
-				if (!mpPot[mp][1].inCd && nowMP <= mpPot[mp][1].use_at && mpPot[mp][1].amount > 0 && mod.game.me.alive && useCombat && !mod.game.me.inBattleground && !mod.game.me.mounted) {
+				if (!mpPot[mp][1].inCd && nowMP <= mpPot[mp][1].use_at && mpPot[mp][1].amount > 0 && mod.game.me.alive && useCombat && inContract() && !mod.game.me.inBattleground && !mod.game.me.mounted) {
 					useItem(mpPot[mp]); mpPot[mp][1].inCd = true; mpPot[mp][1].amount--; setTimeout(function () {mpPot[mp][1].inCd = false;}, mpPot[mp][1].cd * 1000);
 					useItem(mpPot[mp]); mpPot[mp][1].inCd = true; mpPot[mp][1].amount--; setTimeout(function () {mpPot[mp][1].inCd = false;}, mpPot[mp][1].cd * 1000);
 					if (config.notice) msg(`Used ${mpPot[mp][1].name}, still have ${(mpPot[mp][1].amount)} left.`);
 					if (config.notice) msg(`Used ${mpPot[mp][1].name}, still have ${(mpPot[mp][1].amount)} left.`);
 				}
 				}
 			}
 			}
 		}
 		}
 	});
 	});
+	
+	function inContract() {
+		//Why contract always error only in NA
+		switch (proxyRegion) {
+			case 'na'
+				return true;
+			case else
+				return !mod.game.contract.active;
+		}
+	}
 
 
 	function useItem(itemId) {
 	function useItem(itemId) {
 		mod.send('C_USE_ITEM', 3, {
 		mod.send('C_USE_ITEM', 3, {

+ 1 - 1
manifest.json

@@ -1,6 +1,6 @@
 {
 {
 	"files": {
 	"files": {
-		"index.js": "43605d476af5f84a5f4f82620c1c2eb9ebfa03e8215bf6c520a445058d29757c"
+		"index.js": "81a4636c4521a2c0e43e8c5581a2aa3e8af30aea3a66d9f60da55e41c12ce99f"
 	},
 	},
 	"defs": {
 	"defs": {
 		"C_USE_ITEM": 3,
 		"C_USE_ITEM": 3,