Ranger Example Script - lordachoo/adventureland GitHub Wiki
Ranger Example Code Description
- Has
attack_mode
default crap, move_mode
, attack_spell
variable, huntersMarkMode
toggles casting hunters mark spell
- Move mode will force bot to be stationary so they don't go wandering off
attack_spell
lets you change the rangers default spell/action - supershot
, huntersmark
, etc
debug
toggles console.log
messages
- Basic potion function
use_potions()
- set potionHealAmount
and potionManaAmount
so extra potion capacity isn't wasted.
- Basic functionality: Finds targets. Attacks targets. Cast
attack_spell
on targets. That's it.
- TODO: Poison arrow, check to make sure it has reagant item, etc
- Has the party code for LordAchoo, LordAsneeze, LordApriest to always create/maintain group
Code
3 Shot Example
function threeShot() {
var targets=[];
for(id in parent.entities)
if(parent.entities[id].type=="monster" && is_in_range(parent.entities[id],"3shot") && targets.length<3)
targets.push(parent.entities[id]);
// Use 3-Shot with a Ranger on 3 targets
use_skill("3shot",targets);
}
if(!is_on_cooldown("3shot") && character.mp > 199) threeShot();
Combined Code
var attack_mode=true
var move_mode=false
var attack_spell="supershot"
var huntersMarkMode=true
async function use_potions() {
var potionHealAmount=200
var potionManaAmount=300
if (character.hp < character.max_hp - potionHealAmount || character.mp < character.max_mp - potionManaAmount) {
set_message("Using Potion");
use_hp_or_mp();
}
}
setInterval(function(){
use_potions();
loot();
if(!attack_mode || character.rip || is_moving(character)) return;
var target=get_targeted_monster();
if(!target)
{
target=get_nearest_monster({min_xp:100,max_att:120});
if(target) change_target(target);
else
{
set_message("No Monsters");
return;
}
}
if(!is_in_range(target))
{
if(move_mode) {
set_message("MOVING...");
move(
character.x+(target.x-character.x)/2,
character.y+(target.y-character.y)/2
);
}
// Walk half the distance - IF move_mode == true
}
else if(can_attack(target))
{
set_message("Attacking");
if(!is_on_cooldown(attack_spell) && character.mp > 399)
{
set_message("attack_spelll");
use_skill(attack_spell);
}
if(huntersMarkMode) {
if(!is_on_cooldown("huntersmark") && character.mp >= 240)
{
set_message("Mark Tgt!");
use_skill("huntersmark");
}
}
attack(target);
}
},1000/4); // Loops every 1/4 seconds.
/*
* PARTY CODE
*/
var group = ["LordAchoo", "LordAsneeze", "LordApriest"];
setInterval(function () {
if(parent.party_list.length < 3 ){
if (character.name == group[0]) {
for (let i = 1; i < group.length; i++) {
let name = group[i];
send_party_invite(name);
}
} else {
if (character.party) {
if (character.party != group[0]) {
parent.socket.emit("party", {event: "leave"})
}
} else {
send_party_request(group[0]);
}
}
}
}, 1000 * 10);
function on_party_request(name) {
console.log("Party Request");
if (group.indexOf(name) != -1) {
accept_party_request(name);
}
}
function on_party_invite(name) {
console.log("Party Invite");
if (group.indexOf(name) != -1) {
accept_party_invite(name);
}
}