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

some reformat, ci fix, commands rework, fix despawn logic

SaltyMonkey лет назад: 6
Родитель
Сommit
54db1c66dd
9 измененных файлов с 88 добавлено и 41 удалено
  1. 6 1
      .github/workflows/ci.yml
  2. 3 4
      README.md
  3. 11 1
      data/staticData.json
  4. 25 0
      lib/helpers/enums.js
  5. 6 6
      lib/unitControl.js
  6. 23 19
      lib/unitFps.js
  7. 4 3
      lib/unitState.js
  8. 6 3
      settings/presets/common.json
  9. 4 4
      settings/settings.json

+ 6 - 1
.github/workflows/ci.yml

@@ -12,6 +12,11 @@ jobs:
       uses: actions/setup-node@v1
       uses: actions/setup-node@v1
       with:
       with:
         node-version: 12
         node-version: 12
+    - name: Lint source code
+      run: |
+          npm ci
+          npm run lint
+          npm ci --only=production
     - name: Generate manifest
     - name: Generate manifest
       run: npm run manifest
       run: npm run manifest
     - name: Commit changes
     - name: Commit changes
@@ -19,5 +24,5 @@ jobs:
           git config --global core.autocrlf false
           git config --global core.autocrlf false
           git config --global user.name 'SaltyMonkey'
           git config --global user.name 'SaltyMonkey'
           git config --global user.email 'SaltyMonkey@users.noreply.github.com'
           git config --global user.email 'SaltyMonkey@users.noreply.github.com'
-          git commit -am "Automated manifest update"
+          git commit -am "[CI] Automatic commit"
           git push
           git push

+ 3 - 4
README.md

@@ -11,26 +11,25 @@ FPS Manager is modern and extremely customizable module for Tera Toolbox which c
 - Zoom zoom! (created with modern javascript without slow strings manipulations or memory leaks)
 - Zoom zoom! (created with modern javascript without slow strings manipulations or memory leaks)
 - Detailed documentation
 - Detailed documentation
 - Readable codebase (FPS Manager developed with strict codebase styling/best practice rules and zero deprecated runtime functions)
 - Readable codebase (FPS Manager developed with strict codebase styling/best practice rules and zero deprecated runtime functions)
-- CI/DI (Every update verified for possible issues and autoupdate files being generated automatically, developer notified instantly if issues detected)
+- CI/DI (Every update verified for possible issues and manifest file generated automatically, developer notified instantly if issues detected)
 - Supports latest Tera Toolbox features (be on the edge of progress :) )
 - Supports latest Tera Toolbox features (be on the edge of progress :) )
 - Client data usage (most of data grabbed from client instead of manual update by developer) 
 - Client data usage (most of data grabbed from client instead of manual update by developer) 
 - Protection from another mods (fps manager trying to catch all data before average mods and apply changes after them so nothing can affect expected result)
 - Protection from another mods (fps manager trying to catch all data before average mods and apply changes after them so nothing can affect expected result)
 - Event driven ideology (setup mod one time and apply your configuration based on ingame events automatically)
 - Event driven ideology (setup mod one time and apply your configuration based on ingame events automatically)
 - Easy start (readable options names and zero dangerous/critical options available)
 - Easy start (readable options names and zero dangerous/critical options available)
-- Fully clientside (FPS Manager will never send something to server) *(1)*
+- Fully clientside (FPS Manager will never send something to server)
 - Class based configuration (just ingame events not enough? Enjoy custom settings combinations automatic switch based on game class)
 - Class based configuration (just ingame events not enough? Enjoy custom settings combinations automatic switch based on game class)
 - Shareable configuration (friend want to use your settings? It is not issue anymore. Just drag and drop them!)
 - Shareable configuration (friend want to use your settings? It is not issue anymore. Just drag and drop them!)
 - Dynamic configuration (FPS Manager can detect presets changes at your drive without game restart!)
 - Dynamic configuration (FPS Manager can detect presets changes at your drive without game restart!)
 - Custom modes (don't like predefined settings for configurations or they can't fit your gameplay? just rename everything or create personal configurations)
 - Custom modes (don't like predefined settings for configurations or they can't fit your gameplay? just rename everything or create personal configurations)
 - Optional commands (commands IS OPTIONAL and can be disabled in settings)
 - Optional commands (commands IS OPTIONAL and can be disabled in settings)
-- Silent mode (don't want to see any mod related messages in your chat? Not issue!)
 - Interactive messages (Want to know details about mod automation decisions? Just use interactive mode)
 - Interactive messages (Want to know details about mod automation decisions? Just use interactive mode)
 - Manual mode (can apply your custom settings in middle of combat - use advanced commands to overwrite automation)
 - Manual mode (can apply your custom settings in middle of combat - use advanced commands to overwrite automation)
 
 
 ## Installation
 ## Installation
 
 
 Manual installation:
 Manual installation:
-- Create a folder called `fpsmanager` in `<tera-toolbox>/mods` and download >> [`module.json`]() << (right-click this link and press save as button...) into created folder
+- Create a folder called `fps-manager` in `<tera-toolbox>/mods` and download >> [`module.json`]() << (right-click this link and press save as button...) into created folder
 
 
 Automatic installation:
 Automatic installation:
 - Open Tera Toolbox, open `Get More Mods` tab and install it as simple mod.
 - Open Tera Toolbox, open `Get More Mods` tab and install it as simple mod.

+ 11 - 1
data/staticData.json

@@ -14,7 +14,17 @@
 		"SMT_CANNOT_TAKE_EQUIPMENT_EXP",
 		"SMT_CANNOT_TAKE_EQUIPMENT_EXP",
 		"SMT_BAN_PARTY_PARTYPLAYER_BF_FAIL",
 		"SMT_BAN_PARTY_PARTYPLAYER_BF_FAIL",
 		"SMT_HUNTINGZONE_EVENT_ANNOUNCE",
 		"SMT_HUNTINGZONE_EVENT_ANNOUNCE",
-		"SMT_GOLDENBELL_MESSAGE"
+		"SMT_GOLDENBELL_MESSAGE",
+		"SMT_GQUEST_NORMAL_ACCEPT",
+		"SMT_GQUEST_NORMAL_COMPLETE",
+		"SMT_GQUEST_NORMAL_FAIL_OVERTIME",
+		"SMT_GQUEST_NORMAL_END_NOTICE",
+		"SMT_GQUEST_NORMAL_CARRYOUT",
+		"SMT_GQUEST_OCCUPY_ACCEPT",
+		"SMT_GQUEST_OCCUPY_COMPLETE",
+		"SMT_GQUEST_OCCUPY_FAIL_OVERTIME",
+		"SMT_GQUEST_NORMAL_CANCEL",
+		"SMT_GQUEST_FAIL_ACCEPT"
 	],
 	],
 	"blockedProto": [
 	"blockedProto": [
 		"S_ITEM_CUSTOM_STRING",
 		"S_ITEM_CUSTOM_STRING",

+ 25 - 0
lib/helpers/enums.js

@@ -86,4 +86,29 @@ exports.EVENTS = Object.freeze(
 	{
 	{
 		"RECONFIGURE": "changeMode"
 		"RECONFIGURE": "changeMode"
 	}
 	}
+);
+
+/**
+ * Enum creature change hp
+ * @readonly
+ * @enum {string}
+ */
+exports.HPCHANGE = Object.freeze(
+	{
+		"NORMAL": 10,
+		"BYFALLING": 2
+	}
+);
+
+/**
+ * Enum creature change mp
+ * @readonly
+ * @enum {string}
+ */
+exports.MPCHANGE = Object.freeze(
+	{
+		"DEFAULT": 0,
+		"BYABNORMAL": 1,
+		"BYPASSIVE": 4
+	}
 );
 );

+ 6 - 6
lib/unitControl.js

@@ -22,9 +22,6 @@ class unitControl {
 
 
 		console.log("DEBUG: unitControl -> constructor");
 		console.log("DEBUG: unitControl -> constructor");
 
 
-		if (deps.mod.settings.customCommandTag && deps.mod.settings.customCommandTag.length)
-			prefixes.push(deps.mod.settings.customCommandTag);
-
 		const infoHandler = () => {
 		const infoHandler = () => {
 			deps.mod.command.message("FPS Manager information.");
 			deps.mod.command.message("FPS Manager information.");
 		};
 		};
@@ -35,8 +32,8 @@ class unitControl {
 		};
 		};
 
 
 		const autoSettingHandler = () => {
 		const autoSettingHandler = () => {
-			deps.mod.settings.applyTriggers = !deps.mod.settings.applyTriggers;
-			deps.mod.command.message(`Triggers ${deps.mod.settings.applyTriggers ? "a" : "dea"}ctivated.`);
+			deps.mod.settings.enableEvents = !deps.mod.settings.enableEvents;
+			deps.mod.command.message(`Triggers ${deps.mod.settings.enableEvents ? "a" : "dea"}ctivated.`);
 		};
 		};
 
 
 		const classBasedPresetSettingHandler = () => {
 		const classBasedPresetSettingHandler = () => {
@@ -76,7 +73,10 @@ class unitControl {
 			"debug": debugSettingsHandler
 			"debug": debugSettingsHandler
 		};
 		};
 
 
-		if (deps.mod.settings.enableCommands)
+		if (deps.mod.settings.customCommandsTag && deps.mod.settings.customCommandTag.length)
+			prefixes.push(deps.mod.settings.customCommandsTag);
+
+		if (deps.mod.settings.registerCommands)
 			deps.mod.command.add(prefixes, commands);
 			deps.mod.command.add(prefixes, commands);
 	}
 	}
 }
 }

+ 23 - 19
lib/unitFps.js

@@ -11,7 +11,7 @@
 */
 */
 
 
 const utils = require("./helpers/utils");
 const utils = require("./helpers/utils");
-const { ENTITY_HOOK_TYPE, RAW_HOOK_MODE, HOOK_SETTINGS, DESPAWN_TYPES, EVENTS } = require("./helpers/enums");
+const { ENTITY_HOOK_TYPE, RAW_HOOK_MODE, HOOK_SETTINGS, DESPAWN_TYPES, EVENTS, HPCHANGE, MPCHANGE } = require("./helpers/enums");
 
 
 class unitFps {
 class unitFps {
 	/**
 	/**
@@ -238,17 +238,21 @@ class unitFps {
 			if (data.activeMode.blockOnScreenEffectsBuffs && data.onScreenEffectsBuffs.has(event.id)) return false;
 			if (data.activeMode.blockOnScreenEffectsBuffs && data.onScreenEffectsBuffs.has(event.id)) return false;
 		};
 		};
 
 
-		const blockHpPopups = (event) => {
-			if (data.activeMode.blockHpPopups && isMe(event.target)) {
-				event.type = 10;
-				return true;
+		const creatureChangeHpHandler = (event) => {
+			if (data.activeMode.blockNumbersPopups && data.activeMode.blockNumbersPopupsOptions.hp && isMe(event.target)) {
+				if (event.type !== HPCHANGE.NORMAL) {
+					event.type = HPCHANGE.NORMAL;
+					return true;
+				}
 			}
 			}
 		};
 		};
 
 
-		const blockMpPopups = (event) => {
-			if (data.activeMode.blockMpPopups && isMe(event.target)) {
-				event.type = 0;
-				return true;
+		const creatureChangeMpHandler = (event) => {
+			if (data.activeMode.blockNumbersPopups && data.activeMode.blockNumbersPopupsOptions.mp && isMe(event.target)) {
+				if (event.type !== MPCHANGE.DEFAULT) {
+					event.type = MPCHANGE.DEFAULT;
+					return true;
+				}
 			}
 			}
 		};
 		};
 
 
@@ -269,7 +273,7 @@ class unitFps {
 
 
 					res = true;
 					res = true;
 				}
 				}
-				if (data.activeMode.blockDamageNumbers) {
+				if (data.activeMode.blockNumbersPopups && data.activeMode.blockNumbersPopupsOptions.damage) {
 					// eslint-disable-next-line no-magic-numbers
 					// eslint-disable-next-line no-magic-numbers
 					event.value = BigInt(0);
 					event.value = BigInt(0);
 					res = true;
 					res = true;
@@ -296,7 +300,7 @@ class unitFps {
 			}
 			}
 		};
 		};
 
 
-		const fontSwapHandler = () => (data.activeMode.blockDamageNumbers ? false : undefined);
+		const fontSwapHandler = () => (data.activeMode.blockNumbersPopups && data.activeMode.blockNumbersPopupsOptions.damage ? false : undefined);
 
 
 		const dropIfBlockedHandler = (event) => {
 		const dropIfBlockedHandler = (event) => {
 			let id = event.target || event.gameId;
 			let id = event.target || event.gameId;
@@ -375,8 +379,8 @@ class unitFps {
 		// Combined hooks with complicated logic
 		// Combined hooks with complicated logic
 		//---------------------------------------
 		//---------------------------------------
 		mod.hook(...proto.getData("S_INSTANCE_ARROW"), RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.LAST, blockAdditionalSkillEffectsHandler);
 		mod.hook(...proto.getData("S_INSTANCE_ARROW"), RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.LAST, blockAdditionalSkillEffectsHandler);
-		mod.hook(...proto.getData("S_CREATURE_CHANGE_HP"), HOOK_SETTINGS.LAST, blockHpPopups);
-		mod.hook(...proto.getData("S_PLAYER_CHANGE_MP"), HOOK_SETTINGS.LAST, blockMpPopups);
+		mod.hook(...proto.getData("S_CREATURE_CHANGE_HP"), HOOK_SETTINGS.LAST, creatureChangeHpHandler);
+		mod.hook(...proto.getData("S_PLAYER_CHANGE_MP"), HOOK_SETTINGS.LAST, creatureChangeMpHandler);
 
 
 		mod.hook(...proto.getData("S_EACH_SKILL_RESULT"), HOOK_SETTINGS.LAST, eachSkillResultHandler);
 		mod.hook(...proto.getData("S_EACH_SKILL_RESULT"), HOOK_SETTINGS.LAST, eachSkillResultHandler);
 		mod.hook("S_FONT_SWAP_INFO", RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.LAST, fontSwapHandler);
 		mod.hook("S_FONT_SWAP_INFO", RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.LAST, fontSwapHandler);
@@ -407,7 +411,7 @@ class unitFps {
 				switch (data.activeMode.blockCollections) {
 				switch (data.activeMode.blockCollections) {
 					case (true):
 					case (true):
 						for (const value of tracker.spawnedCollections.values()) {
 						for (const value of tracker.spawnedCollections.values()) {
-							mod.send(...proto.getData("S_DESPAWN_COLLECTION"), value);
+							mod.send(...proto.getData("S_DESPAWN_COLLECTION"), { "gameId": value.gameId, "collected": false });
 						}
 						}
 						break;
 						break;
 					case (false):
 					case (false):
@@ -420,7 +424,7 @@ class unitFps {
 			for (const [key, value] of tracker.spawnedDrop.entries()) {
 			for (const [key, value] of tracker.spawnedDrop.entries()) {
 				let needBlock = isDropBlockable(value);
 				let needBlock = isDropBlockable(value);
 				if (needBlock && !blockedDrop.has(key)) {
 				if (needBlock && !blockedDrop.has(key)) {
-					mod.send(...proto.getData("S_DESPAWN_DROPITEM"), value);
+					mod.send(...proto.getData("S_DESPAWN_DROPITEM"), { "gameId": value.gameId });
 					blockedDrop.add(key);
 					blockedDrop.add(key);
 				}
 				}
 				else if (!needBlock && blockedDrop.has(key)) {
 				else if (!needBlock && blockedDrop.has(key)) {
@@ -432,7 +436,7 @@ class unitFps {
 			for (const [key, value] of tracker.spawnedPlayers.entries()) {
 			for (const [key, value] of tracker.spawnedPlayers.entries()) {
 				let needBlock = isUserBlockable(value);
 				let needBlock = isUserBlockable(value);
 				if (needBlock && !blockedPlayers.has(key)) {
 				if (needBlock && !blockedPlayers.has(key)) {
-					mod.send(...proto.getData("S_DESPAWN_USER"), value);
+					mod.send(...proto.getData("S_DESPAWN_USER"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW });
 					blockedPlayers.add(key);
 					blockedPlayers.add(key);
 				}
 				}
 				else if (!needBlock && blockedPlayers.has(key)) {
 				else if (!needBlock && blockedPlayers.has(key)) {
@@ -444,7 +448,7 @@ class unitFps {
 			for (const [key, value] of tracker.spawnedServants.entries()) {
 			for (const [key, value] of tracker.spawnedServants.entries()) {
 				let needBlock = isServantBlockable(value);
 				let needBlock = isServantBlockable(value);
 				if (needBlock && !blockedServants.has(key)) {
 				if (needBlock && !blockedServants.has(key)) {
-					mod.send(...proto.getData("S_REQUEST_DESPAWN_SERVANT"), value);
+					mod.send(...proto.getData("S_REQUEST_DESPAWN_SERVANT"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW });
 					blockedServants.add(key);
 					blockedServants.add(key);
 				}
 				}
 				else if (!needBlock && blockedServants.has(key)) {
 				else if (!needBlock && blockedServants.has(key)) {
@@ -456,7 +460,7 @@ class unitFps {
 			for (const [key, value] of tracker.spawnedSummons.entries()) {
 			for (const [key, value] of tracker.spawnedSummons.entries()) {
 				let needBlock = isSummonsBlockable(value);
 				let needBlock = isSummonsBlockable(value);
 				if (needBlock && !blockedSummons.has(key)) {
 				if (needBlock && !blockedSummons.has(key)) {
-					mod.send(...proto.getData("S_DESPAWN_NPC"), value);
+					mod.send(...proto.getData("S_DESPAWN_NPC"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW, "loc": value.loc });
 					blockedSummons.add(key);
 					blockedSummons.add(key);
 				}
 				}
 				else if (!needBlock && blockedSummons.has(key)) {
 				else if (!needBlock && blockedSummons.has(key)) {
@@ -468,7 +472,7 @@ class unitFps {
 			for (const [key, value] of tracker.spawnedNPCS.entries()) {
 			for (const [key, value] of tracker.spawnedNPCS.entries()) {
 				let needBlock = isSummonsBlockable(value);
 				let needBlock = isSummonsBlockable(value);
 				if (needBlock && !blockedNpcs.has(key)) {
 				if (needBlock && !blockedNpcs.has(key)) {
-					mod.send(...proto.getData("S_DESPAWN_NPC"), value);
+					mod.send(...proto.getData("S_DESPAWN_NPC"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW, "loc": value.loc });
 					blockedNpcs.add(key);
 					blockedNpcs.add(key);
 				}
 				}
 				else if (!needBlock && blockedNpcs.has(key)) {
 				else if (!needBlock && blockedNpcs.has(key)) {

+ 4 - 3
lib/unitState.js

@@ -16,6 +16,7 @@ const EventEmitter = require("events").EventEmitter;
 
 
 const rfdc = require("rfdc")({ "proto": true });
 const rfdc = require("rfdc")({ "proto": true });
 const utils = require("./helpers/utils");
 const utils = require("./helpers/utils");
+//const watchdog = require("./helpers/watchdog");
 
 
 //import enums 
 //import enums 
 const { RAW_HOOK_MODE, HOOK_SETTINGS, ABN, EVENTS } = require("./helpers/enums");
 const { RAW_HOOK_MODE, HOOK_SETTINGS, ABN, EVENTS } = require("./helpers/enums");
@@ -99,7 +100,7 @@ class unitState extends EventEmitter {
 		});
 		});
 
 
 		this.__mod.hook(...this.__proto.getData("S_LOAD_TOPO"), HOOK_SETTINGS.FIRST, (event) => {
 		this.__mod.hook(...this.__proto.getData("S_LOAD_TOPO"), HOOK_SETTINGS.FIRST, (event) => {
-			if (!this.__mod.settings["applyTrigger"] || equal(this.prevMode, this.activeMode)) return;
+			if (!this.__mod.settings["enableEvents"] || equal(this.prevMode, this.activeMode)) return;
 
 
 			this.prevMode = rfdc(this.activeMode);
 			this.prevMode = rfdc(this.activeMode);
 
 
@@ -119,7 +120,7 @@ class unitState extends EventEmitter {
 		});
 		});
 
 
 		this.__mod.hook("S_FIELD_EVENT_ON_ENTER", RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.FIRST, () => {
 		this.__mod.hook("S_FIELD_EVENT_ON_ENTER", RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.FIRST, () => {
-			if (!this.__mod.settings["applyTrigger"] || equal(this.prevMode, this.activeMode)) return;
+			if (!this.__mod.settings["enableEvents"] || equal(this.prevMode, this.activeMode)) return;
 
 
 			this.prevMode = rfdc(this.activeMode);
 			this.prevMode = rfdc(this.activeMode);
 
 
@@ -128,7 +129,7 @@ class unitState extends EventEmitter {
 		});
 		});
 
 
 		this.__mod.hook("S_FIELD_EVENT_ON_LEAVE", RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.FIRST, () => {
 		this.__mod.hook("S_FIELD_EVENT_ON_LEAVE", RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.FIRST, () => {
-			if (!this.__mod.settings["applyTrigger"] || equal(this.prevMode, this.activeMode)) return;
+			if (!this.__mod.settings["enableEvents"] || equal(this.prevMode, this.activeMode)) return;
 
 
 			this.activeMode = rfdc(this.prevMode);
 			this.activeMode = rfdc(this.prevMode);
 
 

+ 6 - 3
settings/presets/common.json

@@ -24,14 +24,17 @@
 		"blockShakeEffects": false,
 		"blockShakeEffects": false,
 		"blockAreaHits": false,
 		"blockAreaHits": false,
 		"blockOwnHits": false,
 		"blockOwnHits": false,
-		"blockDamageNumbers": false,
-		"blockHpPopups": false,
-		"blockMpPopups": false,
 		"blockOwnServants": false,
 		"blockOwnServants": false,
 		"blockAreaServants": false,
 		"blockAreaServants": false,
 		"blockOwnSummons": false,
 		"blockOwnSummons": false,
 		"blockAreaSummons": false,
 		"blockAreaSummons": false,
 		"blockCollections": false,
 		"blockCollections": false,
+		"blockNumbersPopups": false,
+		"blockNumbersPopupsOptions": {
+			"hp": false,
+			"mp": false,
+			"damage": false
+		},
 		"blockAdditionalSkillEffects": false,
 		"blockAdditionalSkillEffects": false,
 		"blockAdditionalSkillEffectsOptions": {
 		"blockAdditionalSkillEffectsOptions": {
 			"own": false,
 			"own": false,

+ 4 - 4
settings/settings.json

@@ -1,9 +1,9 @@
 {
 {
-	"enableCommands": true,
-	"customCommandTag": "",
-	"interactiveMode": true,
+	"registerCommands": true,
+	"customCommandsTag": "",
+	"interactive": true,
 	"debugMode": false,
 	"debugMode": false,
 	"classBasedPresets": true,
 	"classBasedPresets": true,
-	"applyTriggers": true,
+	"enableEvents": true,
 	"trackPresetsChanges": true
 	"trackPresetsChanges": true
 }
 }