JavaScript Attack Script -- 2
Budget: $10 – $30 AUD
I’ve already added an “Attack” entry to Highspell’s right-click menu, but it’s still an empty stub. I just need a concise JavaScript snippet that plugs into the existing userscript so that, when “Auto Attack” is chosen, the following happens:
• Capture my current X,Y as the home spot, start a loop, and repeatedly find the nearest hostile NPC (that is selected) within the game’s normal aggro radius (range is simply centred on the player’s present position).
• Swing at that NPC, wait the usual combat delay, and keep swinging until the server reports its death.
• On death, immediately search again for the next NPC in range and repeat.
• If no valid target exists, walk the character straight back to the saved home X,Y and keep scanning.
• While the loop runs, check the ground for loot; if an object’s ID matches anything in a simple array I’ll edit (e.g. const desiredLoot = [123, 456];), have the character pick it up.
• Pressing F2 must shut the whole routine down cleanly and restore normal controls.
I trigger the routine exclusively from the right-click menu; no keyboard toggle is needed besides the universal F2 kill-switch.
Please return:
1. The updated .js file with clear, inline comments so I can tweak wait times and loot IDs easily.
2. A short note (or README) explaining any helper functions you added and where to paste the script back into my current file.
No external libraries—plain, readable JavaScript that respects the game’s existing event hooks is all I’m after.
https://highspell.com/game
• Capture my current X,Y as the home spot, start a loop, and repeatedly find the nearest hostile NPC (that is selected) within the game’s normal aggro radius (range is simply centred on the player’s present position).
• Swing at that NPC, wait the usual combat delay, and keep swinging until the server reports its death.
• On death, immediately search again for the next NPC in range and repeat.
• If no valid target exists, walk the character straight back to the saved home X,Y and keep scanning.
• While the loop runs, check the ground for loot; if an object’s ID matches anything in a simple array I’ll edit (e.g. const desiredLoot = [123, 456];), have the character pick it up.
• Pressing F2 must shut the whole routine down cleanly and restore normal controls.
I trigger the routine exclusively from the right-click menu; no keyboard toggle is needed besides the universal F2 kill-switch.
Please return:
1. The updated .js file with clear, inline comments so I can tweak wait times and loot IDs easily.
2. A short note (or README) explaining any helper functions you added and where to paste the script back into my current file.
No external libraries—plain, readable JavaScript that respects the game’s existing event hooks is all I’m after.
https://highspell.com/game