TeraProxy лет назад: 8
Родитель
Сommit
f5a402cba4
4 измененных файлов с 59 добавлено и 78 удалено
  1. 7 2
      README.md
  2. 5 0
      config_1-3-6.json
  3. 39 61
      index.js
  4. 8 15
      manifest.json

+ 7 - 2
README.md

@@ -20,7 +20,8 @@ If you enjoy my work and wish to support future development, feel free to drop m
 A tera-proxy module that automatically uses the items "Elite Everful Nostrum" and "Complete Crystal Bind" whenever needed.  
 
 ## Usage
-If you don't have Elite/Club status, you can open up "config.json" and change "elite" from true to false in order to use Prime Battle Solution instead of Everful Nostrum.  
+If you don't have Elite/Club status, you can open up "config.json" and change "ELITE" from true to false in order to use Prime Battle Solution instead of Everful Nostrum.  
+You can change the used non-Elite/Club items by editing the item IDs in "config.json".  
   
 While in game, open a proxy chat session by typing "/proxy" or "/8" in chat and hitting the space bar.  
 This serves as the script's command interface.  
@@ -38,11 +39,15 @@ Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 ## Changelog
 <details>
 
+### 1.3.6
+* [+] Added option for using different CCB items to config file
+* [+] Added option for using different non-elite nostrums to config file ("ELITE" has to be set to false to use these)
+* [+] Added Phoenix mount revival invincibility check
+* [*] Code optimizations
 ### 1.3.5
 * [*] Fixed trying to use CCB when you are under the influence of the 1h CCB
 ### 1.3.4
 * [+] Added option to use Prime Battle Solution instead of Everful Nostrum
-* [*] Fixed a weird case-sensitivity issue
 * [*] More code cleanup
 ### 1.3.3
 * [+] Now supports all regions

+ 5 - 0
config_1-3-6.json

@@ -0,0 +1,5 @@
+{
+	"elite": true,
+	"ccb": 70000,
+	"nostrum": 200999
+}

+ 39 - 61
index.js

@@ -1,68 +1,59 @@
-// Version 1.3.5
-// Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
+// Version 1.3.6
+// Based on true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 
 'use strict'
 
 const Command = require('command'),
 	GameState = require('tera-game-state'),
-	elite = require('./config.json').elite
+	Config = require('./config_1-3-6')
 
 const ITEMS_NOSTRUM = [152898, 184659, 201005, 201006, 201007, 201008, 201022, 855604], // EU, NA, RU, TW, ?, ?, ?, TH
-	ITEMS_PLEB_NOSTRUM = 200999,
-	ITEM_CCB = 70000,
-	BUFF_BLESSING = 1134,
+	ELITE = Config.elite,
+	ITEM_PLEB_NOSTRUM = Config.nostrum,
+	ITEM_CCB = Config.ccb,
+	BUFF_INVINCIBILITY = [1134, 6007], // Invincibility abnormality (Goddess Blessing, Phoenix)
 	BUFF_NOSTRUM_TD = [4020, 4030], // Nostrum abnormality for Tanks and Damage Dealers (pleb, elite)
 	BUFF_NOSTRUM_H = [4021, 4031], // Nostrum abnormality for Healers (pleb, elite)
 	BUFF_CCB = [4610, 4612, 5020003], // Complete Crystalbind abnormality (12h, 1h, elite)
 	RANDOM_MIN_MAX = [600000, 1500000], // Random Nostrum reapplication time (10 - 25 minutes)
 	RANDOM_SHORT = [4000, 8000] // Random Nostrum reapplication time after loading (4 - 8 seconds)
 
-module.exports = function essentials(dispatch) {
+module.exports = function Essentials(dispatch) {
 	const command = Command(dispatch),
 		game = GameState(dispatch)
+	game.initialize("contract")
 
-	let slot = -1,
-		timeout = null,
+	let slot = null,
+		timeoutNostrum = null,
 		timeoutCCB = null,
 		cooldown = 0,
 		nextUse = 0,
-		bgZone = -1,
-		inContract = false,
-		inBG = false,
 		hasccb = false,
 		enabled = true,
-		iAmBlessed = false
+		iAmInvincible = false
 
 	// ############# //
 	// ### Hooks ### //
 	// ############# //
 
 	game.on('enter_game', () => {
+		hasccb = false
+
 		dispatch.hookOnce('C_PLAYER_LOCATION', 'raw', () => {
 			nextUse = Date.now() + randomNumber(RANDOM_SHORT)
 			setTimeout(ccb, randomNumber(RANDOM_SHORT)) // check if you have a CCB shortly after moving for the first time
 		})
 	})
-	game.on('leave_game', () => { nostrum(true) })
 
-	game.on('enter_loading_screen', () => {
-		inContract = false
-		inBG = game.me.zone == bgZone
-		nostrum(true)
-	})
 	game.on('leave_loading_screen', () => {
 		dispatch.hookOnce('C_PLAYER_LOCATION', 'raw', () => { nostrum() })
 	})
-	
-	game.me.on('die', () => {
-		inContract = false
+
+	game.me.on('die', () => { 
 		nextUse = 0
 		nostrum()
 	})
 	game.me.on('resurrect', () => { nostrum() })
-	
-	game.me.on('mount', () => { nostrum() })
-	game.me.on('dismount', () => { nostrum() })
 
 	dispatch.hook('S_PCBANGINVENTORY_DATALIST', 1, event => {
 		for(let item of event.inventory)
@@ -78,13 +69,6 @@ module.exports = function essentials(dispatch) {
 	dispatch.hook('S_ABNORMALITY_REFRESH', 1, abnormality.bind(null, 'S_ABNORMALITY_REFRESH'))
 	dispatch.hook('S_ABNORMALITY_END', 1, abnormality.bind(null, 'S_ABNORMALITY_END'))
 
-	dispatch.hook('S_BATTLE_FIELD_ENTRANCE_INFO', 1, event => { bgZone = event.zone })
-
-	dispatch.hook('S_REQUEST_CONTRACT', 1, contract.bind(null, true))
-	dispatch.hook('S_ACCEPT_CONTRACT', 1, contract.bind(null, false))
-	dispatch.hook('S_REJECT_CONTRACT', 1, contract.bind(null, false))
-	dispatch.hook('S_CANCEL_CONTRACT', 1, contract.bind(null, false))
-
 	// ################# //
 	// ### Functions ### //
 	// ################# //
@@ -92,18 +76,18 @@ module.exports = function essentials(dispatch) {
 	function abnormality(type, event) {
 		if(game.me.is(event.target)) {
 			if(BUFF_NOSTRUM_TD.includes(event.id) || BUFF_NOSTRUM_H.includes(event.id)) {
-				if(type == 'S_ABNORMALITY_END') {
+				if(type === 'S_ABNORMALITY_END') {
 					nextUse = 0
 					nostrum()
 				}
 			}
-			if(BUFF_CCB.includes(event.id)) {
-				hasccb = type != 'S_ABNORMALITY_END'
+			else if(BUFF_CCB.includes(event.id)) {
+				hasccb = type !== 'S_ABNORMALITY_END'
 				if(!hasccb) ccb()
 			}
-			if(event.id == BUFF_BLESSING) {
-				iAmBlessed = type != 'S_ABNORMALITY_END'
-				if(!iAmBlessed) {
+			else if(BUFF_INVINCIBILITY.includes(event.id)) {
+				iAmInvincible = type !== 'S_ABNORMALITY_END'
+				if(!iAmInvincible) {
 					nextUse = 0
 					nostrum()
 				}
@@ -111,21 +95,18 @@ module.exports = function essentials(dispatch) {
 		}
 	}
 
-	function contract(enter) {
-		nostrum(inContract = enter)
-	}
-
-	function nostrum(disable) {
-		clearTimeout(timeout)
-		if(!disable && game.me.alive && !game.me.mounted && !inContract && !inBG && slot != -1 && !iAmBlessed)
-			timeout = setTimeout(useNostrum, nextUse - Date.now())
+	function nostrum() {
+		clearTimeout(timeoutNostrum)
+		
+		if(game.isIngame && game.me.alive && !game.isInLoadingScreen && !game.me.mounted && !game.contract.active && !game.me.inBattleground && slot && !iAmInvincible)
+			timeoutNostrum = setTimeout(useNostrum, nextUse - Date.now())
 	}
 
 	function ccb() {
 		clearTimeout(timeoutCCB)
 		
-		if(!hasccb && game.me.alive && !game.me.mounted && !inContract && !inBG) useItem(ITEM_CCB)
-		else if(!hasccb) timeoutCCB = setTimeout(ccb, 10000) // retry in 10 seconds if you were busy
+		if(!hasccb && game.isIngame && game.me.alive && !game.isInLoadingScreen && !game.me.mounted && !game.contract.active && !game.me.inBattleground) useItem(ITEM_CCB)
+		else if(!hasccb) timeoutCCB = setTimeout(ccb, 10000) // retry in 10 seconds if we were busy
 	}
 
 	function useNostrum() {
@@ -133,29 +114,26 @@ module.exports = function essentials(dispatch) {
 
 		if(time >= cooldown) {
 			if(enabled) {
-				if(elite) dispatch.toServer('C_PCBANGINVENTORY_USE_SLOT', 1, {slot})
-				else useItem(ITEMS_PLEB_NOSTRUM)
+				if(ELITE) dispatch.toServer('C_PCBANGINVENTORY_USE_SLOT', 1, {slot})
+				else useItem(ITEM_PLEB_NOSTRUM)
 			}
 			nextUse = Date.now() + randomNumber(RANDOM_MIN_MAX)
 			nostrum()
 		}
-		else timeout = setTimeout(useNostrum, cooldown - time)
+		else timeoutNostrum = setTimeout(useNostrum, cooldown - time)
 	}
 	
 	function useItem(item) {
 		if(!enabled) return
-		dispatch.toServer('C_USE_ITEM', 2, {
-			ownerId: game.me.gameId,
+		
+		dispatch.toServer('C_USE_ITEM', 3, {
+			gameId: game.me.gameId,
 			id: item,
-			uniqueId: 0,
-			targetId: 0,
+			dbid: 0,
+			target: 0,
 			amount: 1,
-			targetX: 0,
-			targetY: 0,
-			targetZ: 0,
-			x: 0, 
-			y: 0, 
-			z: 0, 
+			dest: {x: 0, y: 0, z: 0},
+			loc: {x: 0, y: 0, z: 0},
 			w: 0, 
 			unk1: 0,
 			unk2: 0,

+ 8 - 15
manifest.json

@@ -1,13 +1,14 @@
 {
+	"force_clean": true,
 	"files": {
-		"index.js": "d96170ed32c5a90e53fa078224d1beee98afbfe99c117fb19ed30254884de9c0",
+		"config_1-3-6.json": {
+			"overwrite": false,
+			"hash": "add4c2e726e87d83b70a4bb057a82d7680f9839d26c3dd7da9acba953e070f9b"
+		},
+		"index.js": "c6e6bb6b35fa3958c83a9c78a1566df4dc84c7503a7dd58a3fe310b27a6ce016",
 		"LICENSE": "589ed823e9a84c56feb95ac58e7cf384626b9cbf4fda2a907bc36e103de1bad2",
-		"README.md": "cac516045935ec10424b56ee391afecee7640f59bd6162ce86d1159c3078291f",
 		"module.json": "4475b48560557f54b45de6542301c25a0f6fbb50d2d4489906ded2ddd8ac7f5f",
-		"config.json": {
-			"overwrite": false,
-			"hash": "df657ab942d4ab588649efed8d63682958d4de73cdaa14005b65cb7730787bb5"
-		}
+		"README.md": "71fcb3e47cf75325c263248ebc2fca505fd95cceedce80a542847d10b0064975"
 	},
 	"defs": {
 		"C_PCBANGINVENTORY_USE_SLOT": 1,
@@ -15,14 +16,6 @@
 		"S_ABNORMALITY_BEGIN": 2,
 		"S_ABNORMALITY_END": 1,
 		"S_ABNORMALITY_REFRESH": 1,
-		"S_ACCEPT_CONTRACT": 1,
-		"S_BATTLE_FIELD_ENTRANCE_INFO": 1,
-		"S_CANCEL_CONTRACT": 1,
-		"S_CREATURE_LIFE": 2,
-		"S_MOUNT_VEHICLE": 2,
-		"S_PCBANGINVENTORY_DATALIST": 1,
-		"S_REJECT_CONTRACT": 1,
-		"S_REQUEST_CONTRACT": 1,
-		"S_UNMOUNT_VEHICLE": 2
+		"S_PCBANGINVENTORY_DATALIST": 1
 	}
 }