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

+ 8 - 4
index.js

@@ -2,7 +2,7 @@ const path = require('path'); const fs = require('fs');
 module.exports = function AutoPOT(mod) {
 	const cmd = mod.command || mod.require.command;
 	let config = getConfig(), hpPot = getHP(), mpPot = getMP();
-	let gameId = null, VehicleEx = null, getInv = false;
+	let gameId = null, VehicleEx = null, getInv = false, useCombat = false;
 	let isAlive = false, isCombat = false, isBG = false, isSlaying = false;
 	let zoneBG = 0, nowHP = 0, nowMP = 0, isCon = false, isMount = false;
 
@@ -77,7 +77,7 @@ module.exports = function AutoPOT(mod) {
 
 	mod.hook('S_UNMOUNT_VEHICLE_EX', 1, e => {if (e.target.equals(gameId)) VehicleEx = null;});
 	
-	mod.hook('S_USER_STATUS', 3, e => {if (e.gameId.equals(gameId)) isCombat = (e.status === 1);});
+	mod.hook('S_USER_STATUS', 3, e => {if (e.gameId === gameId) isCombat = (e.status === 1);});
 	
 	mod.hook('S_BATTLE_FIELD_ENTRANCE_INFO', 1, e => {zoneBG = e.zone;});
 	
@@ -101,7 +101,8 @@ module.exports = function AutoPOT(mod) {
 		if (config.enabled && config.hp) {
 			nowHP = Math.round(parseInt(e.hp) / parseInt(e.maxHp) * 100);
 			for (let hp = 0; hp < hpPot.length; hp++) {
-				if (!hpPot[hp][1].inCd && ((!isSlaying && nowHP <= hpPot[hp][1].use_at) || (isSlaying && nowHP <= hpPot[hp][1].slay_at)) && hpPot[hp][1].amount > 0 && isCombat && isAlive && !isBG) {
+				useCombat = hpPot[hp][1].inCombat ? isCombat : true;
+				if (!hpPot[hp][1].inCd && ((!isSlaying && nowHP <= hpPot[hp][1].use_at) || (isSlaying && nowHP <= hpPot[hp][1].slay_at)) && hpPot[hp][1].amount > 0 && isAlive && useCombat && !isBG && !isCon && !isMount) {
 					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.`);
 				}
@@ -110,7 +111,8 @@ module.exports = function AutoPOT(mod) {
 		if (config.enabled && config.mp) {
 			nowMP = Math.round(parseInt(e.mp) / parseInt(e.maxMp) * 100);
 			for (let mp = 0; mp < mpPot.length; mp++) {
-				if (!mpPot[mp][1].inCd && nowMP <= mpPot[mp][1].use_at && mpPot[mp][1].amount > 0 && isAlive && !isBG && !isCon && !isMount) {
+				useCombat = mpPot[mp][1].inCombat ? isCombat : true;
+				if (!mpPot[mp][1].inCd && nowMP <= mpPot[mp][1].use_at && mpPot[mp][1].amount > 0 && isAlive && useCombat && !isBG && !isCon && !isMount) {
 					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.`);
 				}
@@ -150,6 +152,7 @@ module.exports = function AutoPOT(mod) {
 		} catch (e) {
 			data[6552] = {
 				name: 'Prime Recovery Potable',
+				inCombat: true,
 				use_at: 80,
 				slay_at: 30,
 				cd: 10
@@ -166,6 +169,7 @@ module.exports = function AutoPOT(mod) {
 		} catch (e) {
 			data[6562] = {
 				name: 'Prime Replenishment Potable',
+				inCombat: false,
 				use_at: 50,
 				cd: 10
 			}

+ 1 - 1
manifest.json

@@ -1,6 +1,6 @@
 {
 	"files": {
-		"index.js": "151155e628180c1a8b7457de6574a362ab73d76c359cd41e759bfd373c94b4c0"
+		"index.js": "f08c2330cd1a4b06662b5351e47beaf72d41098d554a1b087aced97ebad6c718"
 	},
 	"defs": {
 		"C_BIND_ITEM_EXECUTE": "raw",