Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. // Hey there!
  2. // This is CODE, lets you control your character with code.
  3. // If you don't know how to code, don't worry, It's easy.
  4. // Just set attack_mode to true and ENGAGE!
  5.  
  6. // combat switches/modifiers
  7. var attack_mode=true
  8. var potion_alert = false;
  9. var safe_distence = 2; // how close will the taget get before starting to kite.
  10.  
  11. //travel switches/modifiers
  12. var travel_mod = false;
  13. var destination_set = false;
  14. var return_to_x = 0;
  15. var return_to_y = 0;
  16.  
  17. //invetory stock modifiers
  18. var max_hp_potions = 50;
  19. var max_mp_potions = 150;
  20. var min_hp_potions = 10;
  21. var min_mp_potions = 10;
  22.  
  23.  
  24.  
  25. //travel loop
  26. setInterval(function()
  27. {
  28. // travel loop interaptors.
  29. if (travel_mod)
  30. {
  31.  
  32. //potion alert
  33. //test
  34. if (potion_alert && !destination_set){
  35. destination_set = true
  36. smart_move("potions",
  37. () => {
  38. buy
  39. (
  40. "hpot0",max_hp_potions - quantity("hpot0")
  41. );
  42. buy
  43. (
  44. "mpot0",max_mp_potions - quantity("mpot0")
  45. );
  46. smart_move({x:return_to_x,y:return_to_y},() =>
  47. {
  48. trave_mod = false;
  49. potion_alert = false;
  50. destination_set = false;
  51. }
  52. );
  53. }
  54.  
  55. )
  56.  
  57.  
  58. }
  59.  
  60.  
  61.  
  62. /*
  63. if (potion_alert && !destination_set)
  64. {
  65. smart_move(0,0);
  66. destination_set = true;
  67. }
  68. //buying potions if at town
  69. else if (potion_alert && character.x == 0 && character.y == 0)
  70. {
  71. //if we have enough potions we set the alert off
  72. if (potion_alert &&
  73. quantity("mpot0") >= max_mp_potions &&
  74. quantity("hpot0") >= max_hp_potions
  75. )
  76. {
  77. potion_alert = false;
  78. destination_set = false;
  79.  
  80. }
  81. else //buy potions
  82. {
  83. if(!(quantity("hpot0") >= max_hp_potions))
  84. {
  85. buy("hpot0",
  86. (max_hp_potions - quantity("hpot0"))
  87. );
  88. }
  89. if(!(quantity("mpot0") >= max_mp_potions))
  90. {
  91. buy("mpot0",
  92. (max_mp_potions - quantity("mpot0"))
  93. );
  94. }
  95. }
  96. }
  97.  
  98.  
  99. //returning back to where we whare
  100. if (
  101.  
  102. !potion_alert &&
  103. !destination_set
  104. )
  105. {
  106. game_log("potion alert off");
  107. smart_move(return_to_x,return_to_y);
  108. destination_set = true;
  109. }
  110. //travel end conditions
  111. if (destination_set &&
  112. !potion_alert
  113. )
  114. {
  115. if (character.x == return_to_x &&
  116. character.y == return_to_y)
  117. {
  118. destination_set = false;
  119. travel_mod = false;
  120. }
  121. }
  122. */
  123.  
  124.  
  125.  
  126. }
  127. } ,3000); // do every 3 sec
  128.  
  129.  
  130. setInterval(function(){
  131. if (character.hp < character.max_hp-200){
  132. use(0);
  133. }
  134. if (character.mp < character.max_mp-300){
  135. use(1);
  136. }
  137. loot();
  138.  
  139. if(!travel_mod &&
  140. attack_mode && !character.rip && !is_moving(character)
  141. )
  142. {
  143.  
  144.  
  145.  
  146.  
  147. //potion alert condition
  148. if (quantity("hpot0") < min_hp_potions ||
  149. quantity("mpot0") < min_mp_potions)
  150. {
  151. game_log("potion alert");
  152. return_to_x = character.x;
  153. return_to_y = character.y;
  154. potion_alert = true;
  155. travel_mod = true;
  156. return;
  157. }
  158. var target=get_targeted_monster();
  159. if(!target)
  160. {
  161. target=get_nearest_monster({min_xp:100,max_att:120});
  162. if(target)
  163. {
  164. change_target(target)
  165.  
  166. }
  167. else
  168. {
  169. set_message("No Monsters");
  170. return;
  171. }
  172. }
  173. var dist_monster = abs
  174. (sqrt
  175. (
  176. (character.x-target.x)*(character.x-target.x)
  177. +
  178. (character.y-target.y)*(character.y-target.y)
  179. )
  180. );
  181. //kiting
  182.  
  183. if (floor(dist_monster) < parent.ctarget.range*safe_distence){
  184. //when target is nearing attack range.
  185. var to_travel = (target.hp/character.attack)*character.speed
  186. game_log(to_travel);
  187.  
  188. }
  189.  
  190.  
  191. if(!in_attack_range(target))
  192. {
  193.  
  194. move(
  195. character.x+(target.x-character.x)/2,
  196. character.y+(target.y-character.y)/2
  197. );
  198. // Walk half the distance
  199. }
  200. else if(can_attack(target))
  201. {
  202. attack(target);
  203. }
  204. }
  205. },1000/6); // Loops every 1/4 seconds.
  206.  
  207. // Learn Javascript: https://www.codecademy.com/learn/learn-javascript
  208. // Write your own CODE: https://github.com/kaansoral/adventureland
  209. // NOTE: If the tab isn't focused, browsers slow down the game
  210. // NOTE: Use the performance_trick() function as a workaround
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement