Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pocket Priest
- // Will follow your party around and auto-heal the members based on a priority calculation.
- // It looks at their max hp vs current hp and heals the person with the highest percentage loss.
- //Courtesy of: Sulsaries and JourneyOver
- //Version 1.1.2
- //Grind Code below --------------------------
- var party_list = [{
- name: "Saboth",
- priority: 0.0
- },
- {
- name: "Harold",
- priority: 0.0
- },
- {
- name: "nobodutanks",
- priority: 0.0
- }
- ]
- var party_count = 4;
- //Fills the Party List
- function fill_party_list() {
- var min_d = 999999,
- target = null;
- party_count = 0;
- set_message("Making party_list");
- party_list[party_count].name = character.name;
- party_count++;
- for (id in parent.entities) {
- var current = parent.entities[id];
- if (current.player === false || current.dead || current.party != character.party /* || current.hp==current.max_hp*/ ) {
- continue;
- }
- var c_dist = parent.distance(character, current);
- if (c_dist < min_d && current.player === true) {
- target = current;
- party_list[party_count].name = target.name;
- party_count++;
- set_message("Added a member.");
- }
- }
- return;
- }
- setInterval(function() {
- //Loot available chests
- loot();
- //Re-enable this line if you need to move without using abilities
- //if(character.moving) return;
- //Set target to null;
- var target = null;
- //Update party list
- fill_party_list();
- //show_json(party_list);
- set_message(party_count);
- //set_message(party_list[0].name);
- for (var x = 0; x < party_count; x++) {
- set_message("Setting Priority");
- target = get_player(party_list[x].name);
- set_message("Not broken!");
- set_message(target.name);
- if (target) change_target(target);
- party_list[x].priority = (target.max_hp - target.hp) / target.max_hp;
- set_message(party_list[x].priority);
- set_message("Priority set.");
- }
- var highest_priority = 0;
- for (var x = 0; x < party_count; x++) {
- set_message("Finding highest priority.");
- if (party_list[x].priority > party_list[highest_priority].priority) {
- highest_priority = x;
- }
- }
- set_message("Highest priority found.");
- //target = get_player(party_list[0].name);
- target = get_player(party_list[highest_priority].name);
- if (party_list[highest_priority].priority > .30 && !target.rip) {
- if (target) change_target(target);
- heal(target);
- set_message("Healing " + target.name);
- }
- if (!in_attack_range(target)) {
- move_to(target, character.range);
- set_message("Moving to Priority");
- }
- //set_message(party_count);
- }, 1000 / 3); //Loops every 1/3 seconds.
- function move_to(char, distance) {
- if (!char) return;
- var dist_x = character.real_x - char.real_x;
- var dist_y = character.real_y - char.real_y;
- var from_char = sqrt(dist_x * dist_x + dist_y * dist_y);
- var perc = from_char / distance;
- if (perc > 1.01) {
- move(
- character.real_x - (dist_x - dist_x / perc),
- character.real_y - (dist_y - dist_y / perc)
- );
- return true;
- }
- return false;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement