teralove лет назад: 8
Родитель
Сommit
4b7c7d893e
4 измененных файлов с 103 добавлено и 50 удалено
  1. 12 2
      README.MD
  2. 19 0
      config.js
  3. 66 46
      index.js
  4. 6 2
      manifest.json

+ 12 - 2
README.MD

@@ -4,6 +4,7 @@ tera-proxy module that skips lockons and instantly heals and cleanses party memb
 ## Info
 ## Info
 - Skills will instantly lockon and heal/cleanse party members. Heals prioritize the lowest HP.
 - Skills will instantly lockon and heal/cleanse party members. Heals prioritize the lowest HP.
 - Mystic's cleanse only works in parties of 5 members or less. Disabled in raids.
 - Mystic's cleanse only works in parties of 5 members or less. Disabled in raids.
+- Auto-casting can be disabled (Skills will pre-lockon onto targets and need to be manually pressed again to cast).
 
 
 | Skills affected                 |
 | Skills affected                 |
 | ------------------------------- |
 | ------------------------------- |
@@ -26,6 +27,11 @@ tera-proxy module that skips lockons and instantly heals and cleanses party memb
 - Default is on
 - Default is on
 ### `autocleanse [on/off]`
 ### `autocleanse [on/off]`
 - Enables/disables auto-cleansing
 - Enables/disables auto-cleansing
+### `autocast`
+- Toggle on/off
+- Default is on
+### `autocast [on/off]`
+- Enables/disables auto-casting
 
 
 ## Issues
 ## Issues
 - Skills can ghost if proxy is also using Skill-Prediction (You see animation but nothing happens). Workaround is to disable the skills in SP. [Click here to see how](https://i.imgur.com/bS4VkbX.png)
 - Skills can ghost if proxy is also using Skill-Prediction (You see animation but nothing happens). Workaround is to disable the skills in SP. [Click here to see how](https://i.imgur.com/bS4VkbX.png)
@@ -33,18 +39,22 @@ tera-proxy module that skips lockons and instantly heals and cleanses party memb
 ## Changelog
 ## Changelog
 <details>
 <details>
 
 
+    1.60
+    - New: autocast command and feature
+    - New: Configs stored in separate file
+    - New: Debug command
     1.52
     1.52
     - Fix: Lockons ignoring berserkers with negative health
     - Fix: Lockons ignoring berserkers with negative health
     - Fix: Locking onto kicked party members
     - Fix: Locking onto kicked party members
     1.51
     1.51
     - New: Added support for Caali auto-update.
     - New: Added support for Caali auto-update.
-    1.5
+    1.50
     - New: autoheal and autocleanse commands toggle only their respectable behaviours. 
     - New: autoheal and autocleanse commands toggle only their respectable behaviours. 
     - New: autoheal command has argument to set HP cutoff.
     - New: autoheal command has argument to set HP cutoff.
     - New: autoheal command has argument to toggle on/off explicitly ('autoheal on/off')
     - New: autoheal command has argument to toggle on/off explicitly ('autoheal on/off')
     - New: autocleanse command has argument to toggle on/off explicitly ('autocleanse on/off')
     - New: autocleanse command has argument to toggle on/off explicitly ('autocleanse on/off')
     - New: Vertical distance check.
     - New: Vertical distance check.
-    - Fixed: Sometimes still locking onto dead players.
+    - ~~Fixed: Sometimes still locking onto dead players.~~
     - Fixed: Locking onto players that left the party.
     - Fixed: Locking onto players that left the party.
     - Fixed: Mod would only start working on players when they had moved.
     - Fixed: Mod would only start working on players when they had moved.
     - Fixed: Mod would briefly stop working when a dead party member resses.
     - Fixed: Mod would briefly stop working when a dead party member resses.

+ 19 - 0
config.js

@@ -0,0 +1,19 @@
+module.exports = {
+     Skills: {
+        6: [ // Priest
+            19, // Focus Heal
+            37  // Immersion
+        ],
+        7: [ // Mystic
+            5, // Titanic Favor
+            9  // Arun's Cleansing Touch
+        ]
+    },
+    
+    autoCast: true,     // true = skills auto lockon and cast. false = pre-lockon onto targets and casting is done manually
+    autoCleanse: true,  // enable mystic cleanse
+    autoHeal: true,     // enable healing skills
+    hpCutoff: 97,       // (healing only) ignore members that have more HP% than this
+    maxDistance: 35,    // in-game meters. can work up to 35m
+    maxVertical: 25     // (ignore targets at top of CS ladders, etc). can also be 35m
+}

+ 66 - 46
index.js

@@ -1,71 +1,74 @@
 const Command = require('command');
 const Command = require('command');
-
+const config = require('./config.js');
+    
 module.exports = function AutoHeal(dispatch) {
 module.exports = function AutoHeal(dispatch) {
     const command = Command(dispatch);
     const command = Command(dispatch);
     
     
-    const Skills = {
-        6: [ // Priest
-            19, // Focus Heal
-            37  // Immersion
-        ],
-        7: [ // Mystic
-            5, // Titanic Favor
-            9  // Arun's Cleansing Touch
-        ]
-    };
-    
-    const MaxDistance = 35; // in-game meters. can work up to 35m
-    const MaxVertical = 28; // (Ignore targets at top of CS ladders, etc). Can also be 35m
-    
-    let autoHeal = true,
-        autoCleanse = true,
-        hpCutoff = 97,   // (healing only) ignore members that have more HP% than this
-        enabled = false, // gets enabled if you log in as a healer
+    let enabled = false, // gets enabled when you log in as a healer
+        debug = false,
         playerId = 0,
         playerId = 0,
         gameId = 0,
         gameId = 0,
         playerLocation = {},
         playerLocation = {},
         partyMembers = [],
         partyMembers = [],
         job = -1,
         job = -1,
         glyphs = null;
         glyphs = null;
-        
+    
     command.add('autoheal', (p1)=> {
     command.add('autoheal', (p1)=> {
         if (p1 == null) {
         if (p1 == null) {
-            autoHeal = !autoHeal;
+            config.autoHeal = !config.autoHeal;
         } else if (p1.toLowerCase() === 'off') {
         } else if (p1.toLowerCase() === 'off') {
-            autoHeal = false;
+            config.autoHeal = false;
         } else if (p1.toLowerCase() === 'on') {
         } else if (p1.toLowerCase() === 'on') {
-            autoHeal = true;
+            config.autoHeal = true;
+        } else if (p1.toLowerCase() === 'debug') {
+            debug = !debug;
+            command.message('(auto-heal) Debug ' + (debug ? 'enabled' : 'disabled'));
+            return;
         } else if (!isNaN(p1)) {
         } else if (!isNaN(p1)) {
-            autoHeal = true;
-            hpCutoff = (p1 < 0 ? 0 : p1 > 100 ? 100 : p1);
+            config.autoHeal = true;
+            config.hpCutoff = (p1 < 0 ? 0 : p1 > 100 ? 100 : p1);
         } else {
         } else {
             command.message('(auto-heal) ' + p1 +' is an invalid argument');
             command.message('(auto-heal) ' + p1 +' is an invalid argument');
             return;
             return;
         }        
         }        
-        command.message('(auto-heal) Healing ' + (autoHeal ? 'enabled (' + hpCutoff + '%)' : 'disabled'));
+        command.message('(auto-heal) Healing ' + (config.autoHeal ? 'enabled (' + config.hpCutoff + '%)' : 'disabled'));
     });
     });
     
     
     command.add('autocleanse', (p1) => {
     command.add('autocleanse', (p1) => {
         if (p1 == null) {
         if (p1 == null) {
-            autoCleanse = !autoCleanse;
+            config.autoCleanse = !config.autoCleanse;
         } else if (p1.toLowerCase() === 'off') {
         } else if (p1.toLowerCase() === 'off') {
-            autoCleanse = false;
+            config.autoCleanse = false;
         } else if (p1.toLowerCase() === 'on') {
         } else if (p1.toLowerCase() === 'on') {
-            autoCleanse = true;
+            config.autoCleanse = true;
         } else {
         } else {
             command.message('(auto-heal) ' + p1 +' is an invalid argument for cleanse command');
             command.message('(auto-heal) ' + p1 +' is an invalid argument for cleanse command');
             return;
             return;
         }
         }
-        command.message('(auto-heal) Cleansing ' + (autoCleanse ? 'enabled' : 'disabled'));
+        command.message('(auto-heal) Cleansing ' + (config.autoCleanse ? 'enabled' : 'disabled'));
+    });
+    
+    command.add('autocast', (p1)=> {
+        if (p1 == null) {
+            config.autoCast = !config.autoCast;
+        } else if (p1.toLowerCase() === 'off') {
+            config.autoCast = false;
+        } else if (p1.toLowerCase() === 'on') {
+            config.autoCast = true;
+        } else {
+            command.message('(auto-heal) ' + p1 +' is an invalid argument for cast command');
+            return;
+        }        
+        command.message('(auto-heal) Casting ' + (config.autoCast ? 'enabled' : 'disabled'));
     });
     });
     
     
     dispatch.hook('S_LOGIN', 10, (event) => {
     dispatch.hook('S_LOGIN', 10, (event) => {
         playerId = event.playerId;
         playerId = event.playerId;
         gameId = event.gameId;
         gameId = event.gameId;
         job = (event.templateId - 10101) % 100;
         job = (event.templateId - 10101) % 100;
-        enabled = (Skills[job]) ? true : false;
+        enabled = (config.Skills[job]) ? true : false;
     })
     })
-    
+       
     dispatch.hook('S_PARTY_MEMBER_LIST', 6, (event) => {
     dispatch.hook('S_PARTY_MEMBER_LIST', 6, (event) => {
         if (!enabled) return;
         if (!enabled) return;
         // refresh locations of existing party members.
         // refresh locations of existing party members.
@@ -208,7 +211,7 @@ module.exports = function AutoHeal(dispatch) {
                 return;
                 return;
             }
             }
         }
         }
-    });
+    });    
     
     
     dispatch.hook('C_START_SKILL', 5, (event) => {
     dispatch.hook('C_START_SKILL', 5, (event) => {
         if (!enabled) return;
         if (!enabled) return;
@@ -219,10 +222,10 @@ module.exports = function AutoHeal(dispatch) {
         }
         }
         let skill = Math.floor((event.skill - 0x4000000) / 10000);
         let skill = Math.floor((event.skill - 0x4000000) / 10000);
         
         
-        if(Skills[job] && Skills[job].includes(skill)) {
-            if(skill != 9 && !autoHeal) return; // skip heal if disabled
-            if(skill == 9 && !autoCleanse) return; // skip cleanse if disabled
-            if(skill == 9 && partyMembers.length > 4) return; // skip cleanse if in a raid
+        if(config.Skills[job] && config.Skills[job].includes(skill)) {
+            if (skill != 9 && !config.autoHeal) return; // skip heal if disabled
+            if (skill == 9 && !config.autoCleanse) return; // skip cleanse if disabled
+            if (skill == 9 && partyMembers.length > 4) return; // skip cleanse if in a raid
             
             
             let targetMembers = [];
             let targetMembers = [];
             let maxTargetCount = getMaxTargets(skill);
             let maxTargetCount = getMaxTargets(skill);
@@ -231,10 +234,10 @@ module.exports = function AutoHeal(dispatch) {
                 if (partyMembers[i].online &&
                 if (partyMembers[i].online &&
                     partyMembers[i].hpP != undefined &&
                     partyMembers[i].hpP != undefined &&
                     partyMembers[i].hpP != 0 &&
                     partyMembers[i].hpP != 0 &&
-                    ((skill == 9) ? true : partyMembers[i].hpP <= hpCutoff) && // (cleanse) ignore max hp
+                    ((skill == 9) ? true : partyMembers[i].hpP <= config.hpCutoff) && // (cleanse) ignore max hp
                     partyMembers[i].loc != undefined &&
                     partyMembers[i].loc != undefined &&
-                    (partyMembers[i].loc.dist3D(playerLocation.loc) / 25) <= MaxDistance && 
-                    (Math.abs(partyMembers[i].loc.z - playerLocation.loc.z) / 25) <= MaxVertical)
+                    (partyMembers[i].loc.dist3D(playerLocation.loc) / 25) <= config.maxDistance && 
+                    (Math.abs(partyMembers[i].loc.z - playerLocation.loc.z) / 25) <= config.maxVertical)
                     {
                     {
                         targetMembers.push(partyMembers[i]);
                         targetMembers.push(partyMembers[i]);
                         if (targetMembers.length == maxTargetCount) break;
                         if (targetMembers.length == maxTargetCount) break;
@@ -242,20 +245,23 @@ module.exports = function AutoHeal(dispatch) {
             }
             }
             
             
             if (targetMembers.length > 0) {
             if (targetMembers.length > 0) {
+                if (debug) outputDebug(skill);
                 for (let i = 0; i < targetMembers.length; i++) {
                 for (let i = 0; i < targetMembers.length; i++) {
                     setTimeout(() => {
                     setTimeout(() => {
                         dispatch.toServer('C_CAN_LOCKON_TARGET', 1, {target: targetMembers[i].gameId, skill: event.skill});
                         dispatch.toServer('C_CAN_LOCKON_TARGET', 1, {target: targetMembers[i].gameId, skill: event.skill});
                     }, 5);
                     }, 5);
                 }
                 }
                 
                 
-                setTimeout(() => {
-                    dispatch.toServer('C_START_SKILL', 5, Object.assign({}, event, {w: playerLocation.w, skill: (event.skill + 10)}));
-                }, 10);
+                if (config.autoCast) {
+                    setTimeout(() => {
+                        dispatch.toServer('C_START_SKILL', 5, Object.assign({}, event, {w: playerLocation.w, skill: (event.skill + 10)}));
+                    }, 10);
+                }
             }
             }
         }
         }
         
         
     })
     })
-    
+
     dispatch.hook('S_CREST_INFO', 2, (event) => {
     dispatch.hook('S_CREST_INFO', 2, (event) => {
         if (!enabled) return;
         if (!enabled) return;
         glyphs = event.crests;
         glyphs = event.crests;
@@ -295,5 +301,19 @@ module.exports = function AutoHeal(dispatch) {
             return parseFloat(a.hpP) - parseFloat(b.hpP);
             return parseFloat(a.hpP) - parseFloat(b.hpP);
         });
         });
     }
     }
-    
-}
+        
+    function outputDebug(skill) {
+        let out = '\nAutoheal Debug... Skill: ' + skill + '\tpartyMemebers.length: ' + partyMembers.length;
+        for (let i = 0; i < partyMembers.length; i++) {
+            out += '\n' + i + '\t';
+            let name = partyMembers[i].name;
+            name += ' '.repeat(21-name.length);
+            let hp = '\tHP: ' + partyMembers[i].hpP.toFixed(2);
+            let dist = '\tDist: ' + (partyMembers[i].loc.dist3D(playerLocation.loc) / 25).toFixed(2);
+            let vert = '\tVert: ' + (Math.abs(partyMembers[i].loc.z - playerLocation.loc.z) / 25).toFixed(2);
+            let online = '\tOnline: ' + partyMembers[i].online;
+            out += name + hp + dist + vert + online;
+        }
+        console.log(out)
+    }
+}

+ 6 - 2
manifest.json

@@ -1,8 +1,12 @@
 {
 {
   "files": {
   "files": {
-    "index.js": "eb8be16ad662ac514b986394ba5bbfcc34ce19c03eaa65a5fc71876d8bd6aff3",
+    "config.json": {
+        "overwrite": false,
+        "hash": "2fca7244ab4ae074bd8402283528915879eaf143239505e9de98e32ac680e6f5"
+    },
+    "index.js": "33186b416b5fe63cabd25ed92092c4d9fa351bd19a4a90c6564c3254bee37532",
     "module.json": "b2dd6257290c3587ab1a8429cc5628194e3d9bc5aaf7c5425ae077d05fb1667d",
     "module.json": "b2dd6257290c3587ab1a8429cc5628194e3d9bc5aaf7c5425ae077d05fb1667d",
-    "README.MD": "6be8e9bc6d51eb04217281218966d207b67f204fba1473225f6dd984c7756422"
+    "README.MD": "7d0d4c1e4e6dbe4eac7e3a7a6aad3a1d98a9ba305742b50c5faf0db7e7965a82"
   },
   },
   "defs": {
   "defs": {
     "S_LOGIN": 10,
     "S_LOGIN": 10,