Просмотр исходного кода

1.3.3

* [+] Now supports all regions
* [+] Rewrote code to use Caali's "tera-game-state" module in order to reduce overhead
* [+] Now supports auto-updating via Caali's tera-proxy
TeraProxy лет назад: 8
Родитель
Сommit
77155d29ba
4 измененных файлов с 110 добавлено и 58 удалено
  1. 30 15
      README.md
  2. 52 43
      index.js
  3. 24 0
      manifest.json
  4. 4 0
      module.json

+ 30 - 15
README.md

@@ -1,32 +1,47 @@
 ##### :heavy_exclamation_mark: Status :heavy_exclamation_mark:
 ##### :heavy_exclamation_mark: Status :heavy_exclamation_mark:
-Working on NA Godsfall patch with the latest https://github.com/meishuu/tera-data.  
-Please always keep your tera-data up-to-date.  
-Other regions will work if the opcodes are mapped but I personally only test modules on NA.  
+Should work on all regions as long as the opcodes are mapped but I personally only test modules on NA with Caali's tera-proxy: https://discord.gg/maqBmJV  
+
+##### :heavy_exclamation_mark: Installation for Caali's tera-proxy :heavy_exclamation_mark:
+1) Download Essentials: https://github.com/TeraProxy/Essentials/archive/master.zip
+2) Extract the contents of the zip file into "\tera-proxy\bin\node_modules\"
+3) Done! (the module will auto-update when a new version is released)
+
+##### :heavy_exclamation_mark: Installation for PinkiePie's tera-proxy :heavy_exclamation_mark:
+1) Update your tera-data: https://github.com/meishuu/tera-data
+2) Download Essentials: https://github.com/TeraProxy/Essentials/archive/master.zip
+3) Download tera-game-state: https://github.com/hackerman-caali/tera-game-state/archive/master.zip
+4) Extract the contents of both zip files into "\tera-proxy\bin\node_modules\"
+5) Done!
+6) Check back here once in a while for updates
 
 
 If you enjoy my work and wish to support future development, feel free to drop me a small donation: [![Donate](https://www.paypalobjects.com/webstatic/en_US/i/buttons/PP_logo_h_100x26.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=A3KBZUCSEQ5RJ&lc=US&item_name=TeraProxy&curency_code=USD&no_note=1&no_shipping=1&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)
 If you enjoy my work and wish to support future development, feel free to drop me a small donation: [![Donate](https://www.paypalobjects.com/webstatic/en_US/i/buttons/PP_logo_h_100x26.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=A3KBZUCSEQ5RJ&lc=US&item_name=TeraProxy&curency_code=USD&no_note=1&no_shipping=1&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)
-  
+
 # Essentials
 # Essentials
 A tera-proxy module that automatically uses the items "Elite Everful Nostrum" and "Complete Crystal Bind" whenever needed.  
 A tera-proxy module that automatically uses the items "Elite Everful Nostrum" and "Complete Crystal Bind" whenever needed.  
-  
-## Usage  
+
+## 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 are playing on a non-NA server, you need to replace "ITEMS_NOSTRUM" in "index.js" with the matching item id.  
   
   
 While in game, open a proxy chat session by typing "/proxy" or "/8" in chat and hitting the space bar.  
 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.  
 This serves as the script's command interface.  
 The following commands are supported:  
 The following commands are supported:  
   
   
-* essentials - enable/disable Essentials  
-  
+* essentials - enable/disable Essentials
+
 ## Safety
 ## Safety
 Whatever you send to the proxy chat in game is intercepted client-side. The chat is NOT sent to the server.  
 Whatever you send to the proxy chat in game is intercepted client-side. The chat is NOT sent to the server.  
-The script makes sure that you are not dead, mounted, in a battleground or in a negotiation before using an item.  
-  
-## Credits  
-Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi  
-  
+The script makes sure that you are not dead, mounted, in a battleground or in a negotiation before using an item.
+
+## Credits
+Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
+
 ## Changelog
 ## Changelog
+### 1.3.3
+* [+] Now supports all regions
+* [+] Rewrote code to use Caali's "tera-game-state" module in order to reduce overhead
+* [+] Now supports auto-updating via Caali's tera-proxy
 ### 1.3.2
 ### 1.3.2
-* [*] Updated hook versions for compatibility with the latest Tera-Proxy programs
+* [*] Updated hook versions for compatibility with the latest tera-proxy
 ### 1.3.1
 ### 1.3.1
 * [*] Fixed an issue of Nostrum not being reapplied when ressurecting quickly with Grace/Vow
 * [*] Fixed an issue of Nostrum not being reapplied when ressurecting quickly with Grace/Vow
 ### 1.3.0
 ### 1.3.0
@@ -45,4 +60,4 @@ Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 ### 1.1.0
 ### 1.1.0
 * [+] Added !essentials command to toggle between "on" and "off" in non-whisper chats
 * [+] Added !essentials command to toggle between "on" and "off" in non-whisper chats
 ### 1.0.0
 ### 1.0.0
-* [*] Initial Release
+* [~] Initial Release

+ 52 - 43
index.js

@@ -1,9 +1,13 @@
-// Version 1.3.2
+// Version 1.3.3
 // Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 // Contains code from true-everful-nostrum by Pinkie Pie https://github.com/pinkipi
 
 
-const Command = require('command')
+'use strict'
 
 
-const ITEMS_NOSTRUM = [152898, 184659, 201005], // EU 152898, NA 184659, RU 201005
+const Command = require('command'),
+	GameState = require('tera-game-state')
+
+const ITEMS_NOSTRUM = [152898, 184659, 201005, 201006, 201007, 201008, 201022, 855604], // EU, NA, RU, TW, ?, ?, ?, TH
+	ITEM_CCB = 70000,
 	BUFF_BLESSING = 1134,
 	BUFF_BLESSING = 1134,
 	BUFF_NOSTRUM_TD = 4030, // Nostrum abnormality for Tanks and Damage Dealers
 	BUFF_NOSTRUM_TD = 4030, // Nostrum abnormality for Tanks and Damage Dealers
 	BUFF_NOSTRUM_H = 4031, // Nostrum abnormality for Healers
 	BUFF_NOSTRUM_H = 4031, // Nostrum abnormality for Healers
@@ -13,7 +17,10 @@ const ITEMS_NOSTRUM = [152898, 184659, 201005], // EU 152898, NA 184659, RU 2010
 	RANDOM_SHORT = [4000, 8000] // Random Nostrum reapplication time after loading (4 - 8 seconds)
 	RANDOM_SHORT = [4000, 8000] // Random Nostrum reapplication time after loading (4 - 8 seconds)
 
 
 module.exports = function Essentials(dispatch) {
 module.exports = function Essentials(dispatch) {
-	let cid = null,
+	const command = Command(dispatch),
+		game = GameState(dispatch)
+
+	let gameId = null,
 		slot = -1,
 		slot = -1,
 		timeout = null,
 		timeout = null,
 		timeoutCCB = null,
 		timeoutCCB = null,
@@ -28,15 +35,32 @@ module.exports = function Essentials(dispatch) {
 		enabled = true,
 		enabled = true,
 		iAmBlessed = false
 		iAmBlessed = false
 
 
-	dispatch.hook('S_LOGIN', 10, event => {
-		cid = event.gameId
-		dispatch.hookOnce('C_PLAYER_LOCATION', 1, () => {
+	// ############# //
+	// ### Hooks ### //
+	// ############# //
+
+	game.on('enter_game', () => {
+		gameId = game.me.gameId
+		dispatch.hookOnce('C_PLAYER_LOCATION', 'raw', () => {
 			nextUse = Date.now() + randomNumber(RANDOM_SHORT)
 			nextUse = Date.now() + randomNumber(RANDOM_SHORT)
 			setTimeout(ccb, randomNumber(RANDOM_SHORT)) // check if you have a CCB shortly after moving for the first time
 			setTimeout(ccb, randomNumber(RANDOM_SHORT)) // check if you have a CCB shortly after moving for the first time
 		})
 		})
 	})
 	})
 
 
-	dispatch.hook('S_RETURN_TO_LOBBY', 'raw', () => { nostrum(true) })
+	game.on('enter_character_lobby', () => { nostrum(true) })
+	
+	game.on('enter_loading_screen', () => {
+		mounted = 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.hook('S_PCBANGINVENTORY_DATALIST', 1, event => {
 	dispatch.hook('S_PCBANGINVENTORY_DATALIST', 1, event => {
 		for(let item of event.inventory)
 		for(let item of event.inventory)
@@ -54,23 +78,8 @@ module.exports = function Essentials(dispatch) {
 
 
 	dispatch.hook('S_BATTLE_FIELD_ENTRANCE_INFO', 1, event => { bgZone = event.zone })
 	dispatch.hook('S_BATTLE_FIELD_ENTRANCE_INFO', 1, event => { bgZone = event.zone })
 
 
-	dispatch.hook('S_LOAD_TOPO', 3, event => {
-		nextUse = Date.now() + randomNumber(RANDOM_SHORT)
-		
-		mounted = inContract = false
-		inBG = event.zone == bgZone
-
-		nostrum(true)
-	})
-	
-	dispatch.hook('S_SPAWN_ME', 2, event => { 
-		dispatch.hookOnce('C_PLAYER_LOCATION', 'raw', () => {
-			nostrum(!(alive = event.alive))
-		})
-	})
-	
 	dispatch.hook('S_CREATURE_LIFE', 2, event => {
 	dispatch.hook('S_CREATURE_LIFE', 2, event => {
-		if(event.gameId.equals(cid) && alive != event.alive) {
+		if(game.me.is(event.gameId) && alive != event.alive) {
 			nostrum(!(alive = event.alive))
 			nostrum(!(alive = event.alive))
 			
 			
 			if(!alive) {
 			if(!alive) {
@@ -88,34 +97,36 @@ module.exports = function Essentials(dispatch) {
 	dispatch.hook('S_REJECT_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))
 	dispatch.hook('S_CANCEL_CONTRACT', 1, contract.bind(null, false))
 
 
+	// ################# //
+	// ### Functions ### //
+	// ################# //
+
 	function abnormality(type, event) {
 	function abnormality(type, event) {
-		if(event.target.equals(cid) && (event.id == BUFF_NOSTRUM_TD || event.id == BUFF_NOSTRUM_H)) {
+		if(game.me.is(event.target) && (event.id == BUFF_NOSTRUM_TD || event.id == BUFF_NOSTRUM_H)) {
 			if (type == 'S_ABNORMALITY_END') {
 			if (type == 'S_ABNORMALITY_END') {
 				nextUse = 0
 				nextUse = 0
 				nostrum()
 				nostrum()
 			}
 			}
 		}
 		}
-		if(event.target.equals(cid) && (event.id == BUFF_CCB || event.id == BUFF_ConCB)) {
+		if(game.me.is(event.target) && (event.id == BUFF_CCB || event.id == BUFF_ConCB)) {
 			if (type == 'S_ABNORMALITY_END') {
 			if (type == 'S_ABNORMALITY_END') {
 				hasccb = false
 				hasccb = false
 				ccb()
 				ccb()
 			}
 			}
 			else hasccb = true
 			else hasccb = true
 		}
 		}
-		if(event.target.equals(cid) && (event.id == BUFF_BLESSING)) {
+		if(game.me.is(event.target) && event.id == BUFF_BLESSING) {
 			if (type == 'S_ABNORMALITY_END') {
 			if (type == 'S_ABNORMALITY_END') {
 				iAmBlessed = false
 				iAmBlessed = false
 				nextUse = 0
 				nextUse = 0
 				nostrum()
 				nostrum()
 			}
 			}
-			else {
-				iAmBlessed = true
-			}
+			else iAmBlessed = true
 		}
 		}
 	}
 	}
 
 
 	function mount(enter, event) {
 	function mount(enter, event) {
-		if(event.gameId.equals(cid)) nostrum(mounted = enter)
+		if(game.me.is(event.gameId)) nostrum(mounted = enter)
 	}
 	}
 
 
 	function contract(enter) {
 	function contract(enter) {
@@ -124,15 +135,14 @@ module.exports = function Essentials(dispatch) {
 
 
 	function nostrum(disable) {
 	function nostrum(disable) {
 		clearTimeout(timeout)
 		clearTimeout(timeout)
-		if(!disable && alive && !mounted && !inContract && !inBG && slot != -1 && !iAmBlessed) {
+		if(!disable && alive && !mounted && !inContract && !inBG && slot != -1 && !iAmBlessed)
 			timeout = setTimeout(useNostrum, nextUse - Date.now())
 			timeout = setTimeout(useNostrum, nextUse - Date.now())
-		}
 	}
 	}
 
 
 	function ccb() {
 	function ccb() {
 		clearTimeout(timeoutCCB)
 		clearTimeout(timeoutCCB)
 		
 		
-		if(!hasccb && alive && !mounted && !inContract && !inBG) useCCB()
+		if(!hasccb && alive && !mounted && !inContract && !inBG) useItem(ITEM_CCB)
 		else if(!hasccb) timeoutCCB = setTimeout(ccb, 10000) // retry in 10 seconds if you were busy
 		else if(!hasccb) timeoutCCB = setTimeout(ccb, 10000) // retry in 10 seconds if you were busy
 	}
 	}
 
 
@@ -147,11 +157,11 @@ module.exports = function Essentials(dispatch) {
 		else timeout = setTimeout(useNostrum, cooldown - time)
 		else timeout = setTimeout(useNostrum, cooldown - time)
 	}
 	}
 	
 	
-	function useCCB() {
+	function useItem(item) {
 		if(!enabled) return
 		if(!enabled) return
 		dispatch.toServer('C_USE_ITEM', 2, {
 		dispatch.toServer('C_USE_ITEM', 2, {
-			ownerId: cid,
-			id: 70000,
+			ownerId: gameId,
+			id: item,
 			uniqueId: 0,
 			uniqueId: 0,
 			targetId: 0,
 			targetId: 0,
 			amount: 1,
 			amount: 1,
@@ -172,12 +182,11 @@ module.exports = function Essentials(dispatch) {
 	function randomNumber([min, max]) {
 	function randomNumber([min, max]) {
 		return Math.floor(Math.random() * (max - min + 1) + min)
 		return Math.floor(Math.random() * (max - min + 1) + min)
 	}
 	}
-	
-	// ################# //
-	// ### Chat Hook ### //
-	// ################# //
-	
-	const command = Command(dispatch)
+
+	// ################ //
+	// ### Commands ### //
+	// ################ //
+
 	command.add('essentials', () => {
 	command.add('essentials', () => {
 		enabled = !enabled
 		enabled = !enabled
 		command.message('[Essentials] ' + (enabled ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'))
 		command.message('[Essentials] ' + (enabled ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'))

+ 24 - 0
manifest.json

@@ -0,0 +1,24 @@
+{
+	"files": {
+		"index.js": "fa7b56c5a75f3ca52c3246cda5dd699ecdb97b8e4eb7d2e0174abb46e825bc8a",
+		"LICENSE": "589ed823e9a84c56feb95ac58e7cf384626b9cbf4fda2a907bc36e103de1bad2",
+		"README.md": "e7a6f7d54fdce33525c58f14d868cb95b0b67023b1fe3940407393d4d74fd37c",
+		"module.json": "4475b48560557f54b45de6542301c25a0f6fbb50d2d4489906ded2ddd8ac7f5f"
+	},
+	"defs": {
+		"C_PCBANGINVENTORY_USE_SLOT": 1,
+		"C_USE_ITEM": 2,
+		"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
+	}
+}

+ 4 - 0
module.json

@@ -0,0 +1,4 @@
+{
+    "servers": ["https://raw.githubusercontent.com/TeraProxy/Essentials/master/"],
+    "supportUrl": "https://github.com/TeraProxy/Essentials/issues"
+}