Advertisement
Guest User

cut out of priest stuff from JO

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. // Pocket Priest
  2. // Will follow your party around and auto-heal the members based on a priority calculation.
  3. // It looks at their max hp vs current hp and heals the person with the highest percentage loss.
  4. //Courtesy of: Sulsaries and JourneyOver
  5. //Version 1.1.2
  6.  
  7.  
  8. //Grind Code below --------------------------
  9. var party_list = [{
  10.     name: "Saboth",
  11.     priority: 0.0
  12.   },
  13.   {
  14.     name: "Harold",
  15.     priority: 0.0
  16.   },
  17.   {
  18.     name: "nobodutanks",
  19.     priority: 0.0
  20.   }
  21. ]
  22.  
  23. var party_count = 4;
  24. //Fills the Party List
  25. function fill_party_list() {
  26.   var min_d = 999999,
  27.     target = null;
  28.   party_count = 0;
  29.   set_message("Making party_list");
  30.   party_list[party_count].name = character.name;
  31.   party_count++;
  32.   for (id in parent.entities) {
  33.  
  34.     var current = parent.entities[id];
  35.     if (current.player === false || current.dead || current.party != character.party /* || current.hp==current.max_hp*/ ) {
  36.  
  37.       continue;
  38.     }
  39.     var c_dist = parent.distance(character, current);
  40.     if (c_dist < min_d && current.player === true) {
  41.       target = current;
  42.       party_list[party_count].name = target.name;
  43.       party_count++;
  44.       set_message("Added a member.");
  45.     }
  46.   }
  47.   return;
  48. }
  49.  
  50. setInterval(function() {
  51.  
  52.  
  53.  
  54.   //Loot available chests
  55.   loot();
  56.  
  57.   //Re-enable this line if you need to move without using abilities
  58.   //if(character.moving) return;
  59.  
  60.   //Set target to null;
  61.   var target = null;
  62.   //Update party list
  63.   fill_party_list();
  64.   //show_json(party_list);
  65.   set_message(party_count);
  66.   //set_message(party_list[0].name);
  67.  
  68.   for (var x = 0; x < party_count; x++) {
  69.     set_message("Setting Priority");
  70.     target = get_player(party_list[x].name);
  71.     set_message("Not broken!");
  72.     set_message(target.name);
  73.     if (target) change_target(target);
  74.     party_list[x].priority = (target.max_hp - target.hp) / target.max_hp;
  75.     set_message(party_list[x].priority);
  76.     set_message("Priority set.");
  77.   }
  78.  
  79.   var highest_priority = 0;
  80.   for (var x = 0; x < party_count; x++) {
  81.     set_message("Finding highest priority.");
  82.     if (party_list[x].priority > party_list[highest_priority].priority) {
  83.       highest_priority = x;
  84.     }
  85.   }
  86.   set_message("Highest priority found.");
  87.  
  88.   //target = get_player(party_list[0].name);
  89.  
  90.   target = get_player(party_list[highest_priority].name);
  91.   if (party_list[highest_priority].priority > .30 && !target.rip) {
  92.     if (target) change_target(target);
  93.     heal(target);
  94.     set_message("Healing " + target.name);
  95.   }
  96.  
  97.   if (!in_attack_range(target)) {
  98.     move_to(target, character.range);
  99.  
  100.     set_message("Moving to Priority");
  101.   }
  102.  
  103.   //set_message(party_count);
  104.  
  105. }, 1000 / 3); //Loops every 1/3 seconds.
  106.  
  107.  
  108. function move_to(char, distance) {
  109.   if (!char) return;
  110.   var dist_x = character.real_x - char.real_x;
  111.   var dist_y = character.real_y - char.real_y;
  112.  
  113.   var from_char = sqrt(dist_x * dist_x + dist_y * dist_y);
  114.  
  115.   var perc = from_char / distance;
  116.  
  117.   if (perc > 1.01) {
  118.     move(
  119.       character.real_x - (dist_x - dist_x / perc),
  120.       character.real_y - (dist_y - dist_y / perc)
  121.     );
  122.     return true;
  123.   }
  124.   return false;
  125. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement