Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hey there!
- // This is CODE, lets you control your character with code.
- // If you don't know how to code, don't worry, It's easy.
- // Just set attack_mode to true and ENGAGE!
- // combat switches/modifiers
- var attack_mode=true
- var potion_alert = false;
- var safe_distence = 2; // how close will the taget get before starting to kite.
- //travel switches/modifiers
- var travel_mod = false;
- var destination_set = false;
- var return_to_x = 0;
- var return_to_y = 0;
- //invetory stock modifiers
- var max_hp_potions = 50;
- var max_mp_potions = 150;
- var min_hp_potions = 10;
- var min_mp_potions = 10;
- //travel loop
- setInterval(function()
- {
- // travel loop interaptors.
- if (travel_mod)
- {
- //potion alert
- //test
- if (potion_alert && !destination_set){
- destination_set = true
- smart_move("potions",
- () => {
- buy
- (
- "hpot0",max_hp_potions - quantity("hpot0")
- );
- buy
- (
- "mpot0",max_mp_potions - quantity("mpot0")
- );
- smart_move({x:return_to_x,y:return_to_y},() =>
- {
- trave_mod = false;
- potion_alert = false;
- destination_set = false;
- }
- );
- }
- )
- }
- /*
- if (potion_alert && !destination_set)
- {
- smart_move(0,0);
- destination_set = true;
- }
- //buying potions if at town
- else if (potion_alert && character.x == 0 && character.y == 0)
- {
- //if we have enough potions we set the alert off
- if (potion_alert &&
- quantity("mpot0") >= max_mp_potions &&
- quantity("hpot0") >= max_hp_potions
- )
- {
- potion_alert = false;
- destination_set = false;
- }
- else //buy potions
- {
- if(!(quantity("hpot0") >= max_hp_potions))
- {
- buy("hpot0",
- (max_hp_potions - quantity("hpot0"))
- );
- }
- if(!(quantity("mpot0") >= max_mp_potions))
- {
- buy("mpot0",
- (max_mp_potions - quantity("mpot0"))
- );
- }
- }
- }
- //returning back to where we whare
- if (
- !potion_alert &&
- !destination_set
- )
- {
- game_log("potion alert off");
- smart_move(return_to_x,return_to_y);
- destination_set = true;
- }
- //travel end conditions
- if (destination_set &&
- !potion_alert
- )
- {
- if (character.x == return_to_x &&
- character.y == return_to_y)
- {
- destination_set = false;
- travel_mod = false;
- }
- }
- */
- }
- } ,3000); // do every 3 sec
- setInterval(function(){
- if (character.hp < character.max_hp-200){
- use(0);
- }
- if (character.mp < character.max_mp-300){
- use(1);
- }
- loot();
- if(!travel_mod &&
- attack_mode && !character.rip && !is_moving(character)
- )
- {
- //potion alert condition
- if (quantity("hpot0") < min_hp_potions ||
- quantity("mpot0") < min_mp_potions)
- {
- game_log("potion alert");
- return_to_x = character.x;
- return_to_y = character.y;
- potion_alert = true;
- travel_mod = true;
- 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;
- }
- }
- var dist_monster = abs
- (sqrt
- (
- (character.x-target.x)*(character.x-target.x)
- +
- (character.y-target.y)*(character.y-target.y)
- )
- );
- //kiting
- if (floor(dist_monster) < parent.ctarget.range*safe_distence){
- //when target is nearing attack range.
- var to_travel = (target.hp/character.attack)*character.speed
- game_log(to_travel);
- }
- if(!in_attack_range(target))
- {
- move(
- character.x+(target.x-character.x)/2,
- character.y+(target.y-character.y)/2
- );
- // Walk half the distance
- }
- else if(can_attack(target))
- {
- attack(target);
- }
- }
- },1000/6); // Loops every 1/4 seconds.
- // Learn Javascript: https://www.codecademy.com/learn/learn-javascript
- // Write your own CODE: https://github.com/kaansoral/adventureland
- // NOTE: If the tab isn't focused, browsers slow down the game
- // NOTE: Use the performance_trick() function as a workaround
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement