TeraProxy лет назад: 8
Родитель
Сommit
d37aa1e25b
4 измененных файлов с 58 добавлено и 62 удалено
  1. 8 2
      README.md
  2. 3 0
      config.json
  3. 43 57
      index.js
  4. 4 3
      manifest.json

+ 8 - 2
README.md

@@ -20,7 +20,7 @@ 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 are playing on a non-NA server, you need to replace "ITEMS_NOSTRUM" in "index.js" with the matching item id.  
+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.  
   
 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.  
@@ -36,6 +36,11 @@ The script makes sure that you are not dead, mounted, in a battleground or in a
 Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 
 ## Changelog
+<details>
+### 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
 * [+] Rewrote code to use Caali's "tera-game-state" module in order to reduce overhead
@@ -60,4 +65,5 @@ Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 ### 1.1.0
 * [+] Added !essentials command to toggle between "on" and "off" in non-whisper chats
 ### 1.0.0
-* [~] Initial Release
+* [~] Initial Release
+</details>

+ 3 - 0
config.json

@@ -0,0 +1,3 @@
+{
+	"elite": true
+}

+ 43 - 57
index.js

@@ -1,34 +1,33 @@
-// Version 1.3.3
+// Version 1.3.4
 // Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 
 'use strict'
 
 const Command = require('command'),
-	GameState = require('tera-game-state')
+	GameState = require('tera-game-state'),
+	elite = require('./config.json').elite
 
 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,
-	BUFF_NOSTRUM_TD = 4030, // Nostrum abnormality for Tanks and Damage Dealers
-	BUFF_NOSTRUM_H = 4031, // Nostrum abnormality for Healers
+	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, // Complete Crystalbind abnormality
 	BUFF_ConCB = 5020003, // Continuous Crystalbind abnormality
 	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)
 
-	let gameId = null,
-		slot = -1,
+	let slot = -1,
 		timeout = null,
 		timeoutCCB = null,
 		cooldown = 0,
 		nextUse = 0,
 		bgZone = -1,
-		alive = false,
-		mounted = false,
 		inContract = false,
 		inBG = false,
 		hasccb = false,
@@ -40,27 +39,31 @@ module.exports = function Essentials(dispatch) {
 	// ############# //
 
 	game.on('enter_game', () => {
-		gameId = game.me.gameId
 		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_character_lobby', () => { nostrum(true) })
-	
 	game.on('enter_loading_screen', () => {
-		mounted = inContract = false
+		inContract = false
 		inBG = game.me.zone == bgZone
-
 		nostrum(true)
 	})
-
 	game.on('leave_loading_screen', () => {
-		dispatch.hookOnce('C_PLAYER_LOCATION', 'raw', () => {
-			nostrum(!(alive = game.me.alive))
-		})
+		dispatch.hookOnce('C_PLAYER_LOCATION', 'raw', () => { nostrum() })
 	})
+	
+	game.me.on('die', () => {
+		inContract = false
+		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,20 +81,6 @@ module.exports = function Essentials(dispatch) {
 
 	dispatch.hook('S_BATTLE_FIELD_ENTRANCE_INFO', 1, event => { bgZone = event.zone })
 
-	dispatch.hook('S_CREATURE_LIFE', 2, event => {
-		if(game.me.is(event.gameId) && alive != event.alive) {
-			nostrum(!(alive = event.alive))
-			
-			if(!alive) {
-				nextUse = 0
-				mounted = inContract = false
-			}
-		}
-	})
-
-	dispatch.hook('S_MOUNT_VEHICLE', 2, mount.bind(null, true))
-	dispatch.hook('S_UNMOUNT_VEHICLE', 2, mount.bind(null, false))
-
 	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))
@@ -102,47 +91,41 @@ module.exports = function Essentials(dispatch) {
 	// ################# //
 
 	function abnormality(type, event) {
-		if(game.me.is(event.target) && (event.id == BUFF_NOSTRUM_TD || event.id == BUFF_NOSTRUM_H)) {
-			if (type == 'S_ABNORMALITY_END') {
-				nextUse = 0
-				nostrum()
+		if(game.me.is(event.target)) {
+			if(BUFF_NOSTRUM_TD.includes(event.id) || BUFF_NOSTRUM_H.includes(event.id)) {
+				if(type == 'S_ABNORMALITY_END') {
+					nextUse = 0
+					nostrum()
+				}
 			}
-		}
-		if(game.me.is(event.target) && (event.id == BUFF_CCB || event.id == BUFF_ConCB)) {
-			if (type == 'S_ABNORMALITY_END') {
-				hasccb = false
-				ccb()
+			if(event.id == BUFF_CCB || event.id == BUFF_ConCB) {
+				hasccb = type != 'S_ABNORMALITY_END'
+				if(!hasccb) ccb()
 			}
-			else hasccb = true
-		}
-		if(game.me.is(event.target) && event.id == BUFF_BLESSING) {
-			if (type == 'S_ABNORMALITY_END') {
-				iAmBlessed = false
-				nextUse = 0
-				nostrum()
+			if(event.id == BUFF_BLESSING) {
+				iAmBlessed = type != 'S_ABNORMALITY_END'
+				if(!iAmBlessed) {
+					nextUse = 0
+					nostrum()
+				}
 			}
-			else iAmBlessed = true
 		}
 	}
 
-	function mount(enter, event) {
-		if(game.me.is(event.gameId)) nostrum(mounted = enter)
-	}
-
 	function contract(enter) {
 		nostrum(inContract = enter)
 	}
 
 	function nostrum(disable) {
 		clearTimeout(timeout)
-		if(!disable && alive && !mounted && !inContract && !inBG && slot != -1 && !iAmBlessed)
+		if(!disable && game.me.alive && !game.me.mounted && !inContract && !inBG && slot != -1 && !iAmBlessed)
 			timeout = setTimeout(useNostrum, nextUse - Date.now())
 	}
 
 	function ccb() {
 		clearTimeout(timeoutCCB)
 		
-		if(!hasccb && alive && !mounted && !inContract && !inBG) useItem(ITEM_CCB)
+		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
 	}
 
@@ -150,7 +133,10 @@ module.exports = function Essentials(dispatch) {
 		let time = Date.now()
 
 		if(time >= cooldown) {
-			if(enabled) dispatch.toServer('C_PCBANGINVENTORY_USE_SLOT', 1, {slot})
+			if(enabled) {
+				if(elite) dispatch.toServer('C_PCBANGINVENTORY_USE_SLOT', 1, {slot})
+				else useItem(ITEMS_PLEB_NOSTRUM)
+			}
 			nextUse = Date.now() + randomNumber(RANDOM_MIN_MAX)
 			nostrum()
 		}
@@ -160,7 +146,7 @@ module.exports = function Essentials(dispatch) {
 	function useItem(item) {
 		if(!enabled) return
 		dispatch.toServer('C_USE_ITEM', 2, {
-			ownerId: gameId,
+			ownerId: game.me.gameId,
 			id: item,
 			uniqueId: 0,
 			targetId: 0,

+ 4 - 3
manifest.json

@@ -1,9 +1,10 @@
 {
 	"files": {
-		"index.js": "fa7b56c5a75f3ca52c3246cda5dd699ecdb97b8e4eb7d2e0174abb46e825bc8a",
+		"index.js": "22f11a4112ab57f62677398fc0b72a893f8bbd4a65a5ddfcea84025ea10d572f",
 		"LICENSE": "589ed823e9a84c56feb95ac58e7cf384626b9cbf4fda2a907bc36e103de1bad2",
-		"README.md": "e7a6f7d54fdce33525c58f14d868cb95b0b67023b1fe3940407393d4d74fd37c",
-		"module.json": "4475b48560557f54b45de6542301c25a0f6fbb50d2d4489906ded2ddd8ac7f5f"
+		"README.md": "0ee25124196be9619d8e6c7694c09a11f9321f618d2dd84b199bfc5c6a8702dc",
+		"module.json": "4475b48560557f54b45de6542301c25a0f6fbb50d2d4489906ded2ddd8ac7f5f",
+		"config.json": "df657ab942d4ab588649efed8d63682958d4de73cdaa14005b65cb7730787bb5"
 	},
 	"defs": {
 		"C_PCBANGINVENTORY_USE_SLOT": 1,