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

+ 8 - 3
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();
 	let config = getConfig(), hpPot = getHP(), mpPot = getMP();
-	let gPot = null, inUpdate = false, TmpData = [];
+	let gPot = null, inUpdate = false, TmpData = [], aRes = {cd: null, delay = 3000};
 	mod.game.initialize(['me', 'contract']);
 	mod.game.initialize(['me', 'contract']);
 
 
 	if (!map.has(mod.dispatch || mod)) {
 	if (!map.has(mod.dispatch || mod)) {
@@ -194,6 +194,11 @@ module.exports = function AutoPOT(mod) {
 		}
 		}
 	});
 	});
 	
 	
+	mod.game.me.on('resurrect', () => { 
+		if (aRes.cd) clearTimeout(aRes.cd);
+		aRes.cd = setTimeout(() => {aRes.cd = null;}, aRes.delay);
+	});
+	
 	mod.hook('S_INVEN', mod.majorPatchVersion > 79 ? 18 : 17, e => {
 	mod.hook('S_INVEN', mod.majorPatchVersion > 79 ? 18 : 17, e => {
 		if (!inUpdate) {
 		if (!inUpdate) {
 			inUpdate = true;
 			inUpdate = true;
@@ -225,7 +230,7 @@ module.exports = function AutoPOT(mod) {
 	});
 	});
 	
 	
 	function useHP(nowHP) {
 	function useHP(nowHP) {
-		if (config.hp && (mod.game.isIngame && !mod.game.isInLoadingScreen && mod.game.me.alive && !mod.game.me.mounted && !mod.game.contract.active)) {
+		if (config.hp && (mod.game.isIngame && !mod.game.isInLoadingScreen && !aRes.cd && mod.game.me.alive && !mod.game.me.mounted && !mod.game.contract.active)) {
 			for (let hp = 0; hp < hpPot.length; hp++) {
 			for (let hp = 0; hp < hpPot.length; hp++) {
 				if (!hpPot[hp][1].inCd && hpPot[hp][1].amount > 0 && ((!config.slaying && nowHP <= hpPot[hp][1].use_at && (hpPot[hp][1].inCombat ? mod.game.me.inCombat : true)) || (config.slaying && nowHP <= hpPot[hp][1].slay_at && mod.game.me.inCombat)) && (hpPot[hp][1].inBattleground ? (mod.game.me.inBattleground || mod.game.me.zone === 152) : !mod.game.me.inBattleground)) {
 				if (!hpPot[hp][1].inCd && hpPot[hp][1].amount > 0 && ((!config.slaying && nowHP <= hpPot[hp][1].use_at && (hpPot[hp][1].inCombat ? mod.game.me.inCombat : true)) || (config.slaying && nowHP <= hpPot[hp][1].slay_at && mod.game.me.inCombat)) && (hpPot[hp][1].inBattleground ? (mod.game.me.inBattleground || mod.game.me.zone === 152) : !mod.game.me.inBattleground)) {
 					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);
@@ -236,7 +241,7 @@ module.exports = function AutoPOT(mod) {
 	}
 	}
 	
 	
 	function useMP(nowMP) {
 	function useMP(nowMP) {
-		if (config.mp && (mod.game.isIngame && !mod.game.isInLoadingScreen && mod.game.me.alive && !mod.game.me.mounted && !mod.game.contract.active)) {
+		if (config.mp && (mod.game.isIngame && !mod.game.isInLoadingScreen && !aRes.cd && mod.game.me.alive && !mod.game.me.mounted && !mod.game.contract.active)) {
 			for (let mp = 0; mp < mpPot.length; mp++) {
 			for (let mp = 0; mp < mpPot.length; mp++) {
 				if (!mpPot[mp][1].inCd && mpPot[mp][1].amount > 0 && nowMP <= mpPot[mp][1].use_at && (mpPot[mp][1].inCombat ? mod.game.me.inCombat : true) && (mpPot[mp][1].inBattleground ? (mod.game.me.inBattleground || mod.game.me.zone === 152) : !mod.game.me.inBattleground)) {
 				if (!mpPot[mp][1].inCd && mpPot[mp][1].amount > 0 && nowMP <= mpPot[mp][1].use_at && (mpPot[mp][1].inCombat ? mod.game.me.inCombat : true) && (mpPot[mp][1].inBattleground ? (mod.game.me.inBattleground || mod.game.me.zone === 152) : !mod.game.me.inBattleground)) {
 					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);

+ 1 - 1
manifest.json

@@ -1,6 +1,6 @@
 {
 {
 	"files": {
 	"files": {
-		"index.js": "c025c019945c2e9aeec48b2f3a734b1d6640fd047195c1f7e2bc6a0d3834dc70"
+		"index.js": "26d4558c874b1cc31f4d6f451f7d46c7b5b1e89c0bea33a8606d318669e036da"
 	},
 	},
 	"defs": {
 	"defs": {
 		"C_ADMIN": 1,
 		"C_ADMIN": 1,