Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 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.  
  7. //global switches for itervals
  8.  
  9. //combat switches/modifiers
  10. var attack_mode=true;
  11. var take_hp_modifier = 0.9;
  12. var take_mp_modifier = 0.8;
  13. var potion_alert = false;
  14.  
  15.  
  16. //travel switches/modifiers
  17. var travel_mod = false;
  18. var destination_set = false;
  19. var return_to_x = 0;
  20. var return_to_y = 0;
  21.  
  22. //invetory stock modifiers
  23. var even_split = character.gold/2;
  24. var max_hp_potions = 35;
  25. var max_mp_potions = 35;
  26. var min_hp_potions = 10;
  27. var min_mp_potions = 10;
  28.  
  29. //intervals
  30.  
  31. //travel loop
  32. setInterval(function()
  33. {
  34. // travel loop interaptors.
  35. if (travel_mod)
  36. {
  37. //potion alert
  38. if (potion_alert && !destination_set)
  39. {
  40. smart_move(0,0);
  41. destination_set = true;
  42. }
  43. //buying potions
  44. else if (potion_alert && character.x == 0 && character.y == 0)
  45. {
  46. //if we have enough potions we set the alert off
  47. if (potion_alert &&
  48. quantity("mpot0") >= max_mp_potions &&
  49. quantity("hpot0") >= max_hp_potions
  50. )
  51. {
  52. potion_alert = false;
  53. destination_set = false;
  54.  
  55. }
  56. else //buy potions
  57. {
  58. even_split = (character.gold/2)/20;
  59. buy("hpot0",
  60. (max_hp_potions - quantity("hpot0"))-even_split
  61. );
  62. buy("mpot0",
  63. (max_mp_potions - quantity("mpot0"))-even_split
  64. );
  65. }
  66. }
  67.  
  68.  
  69. //returning back to where we whare
  70. if (
  71.  
  72. !potion_alert &&
  73. !destination_set
  74. )
  75. {
  76. game_log("potion alert off");
  77. smart_move(return_to_x,return_to_y);
  78. destination_set = true;
  79. }
  80. //travel end conditions
  81. if (destination_set &&
  82. !potion_alert
  83. )
  84. {
  85. if (character.x == return_to_x &&
  86. character.y == return_to_y)
  87. {
  88. destination_set = false;
  89. travel_mod = false;
  90. }
  91. }
  92.  
  93.  
  94.  
  95.  
  96. }
  97. } ,3000); // do every 3 sec
  98.  
  99. //combat loop
  100. setInterval(function(){
  101.  
  102. //potion use conditions
  103. if (character.hp < character.max_hp*take_hp_modifier ||
  104. character.mp < character.max_mp*take_mp_modifier)
  105. {
  106. use_hp_or_mp();
  107. }
  108. loot();
  109. // combat loop intraptors
  110. if(
  111. !travel_mod &&
  112. (attack_mode && !character.rip || !is_moving(character)))
  113.  
  114. {
  115.  
  116.  
  117. //potion alert condition
  118. if (quantity("hpot0") < min_hp_potions ||
  119. quantity("mpot0") < min_mp_potions)
  120. {
  121. game_log("potion alert");
  122. return_to_x = character.x;
  123. return_to_y = character.y;
  124. potion_alert = true;
  125. travel_mod = true;
  126. return;
  127. }
  128. //setting target
  129. var target=get_targeted_monster();
  130. if(!target)
  131. {
  132. target=get_nearest_monster({min_xp:100,max_att:120});
  133. if(target) change_target(target);
  134. else
  135. {
  136. set_message("No Monsters");
  137. return;
  138. }
  139. }
  140. // if we are more then 50 pixels away use the speed.
  141. if (
  142. sqrt(
  143. ((character.x - target.x)*(character.x - target.x))-
  144. ((character.y - target.y)*(character.y - target.y))
  145. ) > 50
  146. )
  147. {
  148. parent.use_skill("charge");
  149. }
  150.  
  151. //attacking coditions
  152. if(!in_attack_range(target))
  153. {
  154. move(
  155. character.x+(target.x-character.x)/2,
  156. character.y+(target.y-character.y)/2
  157. );
  158. // Walk half the distance
  159. }
  160. else if(can_attack(target))
  161. {
  162. attack(target);
  163. }
  164. }
  165. },1000/6); // Loops every 1/6 seconds.
  166.  
  167. // Learn Javascript: https://www.codecademy.com/learn/learn-javascript
  168. // Write your own CODE: https://github.com/kaansoral/adventureland
  169. // NOTE: If the tab isn't focused, browsers slow down the game
  170. // NOTE: Use the performance_trick() function as a workaround
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement