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!
- //global switches for itervals
- //combat switches/modifiers
- var attack_mode=true;
- var take_hp_modifier = 0.9;
- var take_mp_modifier = 0.8;
- var potion_alert = false;
- //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 even_split = character.gold/2;
- var max_hp_potions = 35;
- var max_mp_potions = 35;
- var min_hp_potions = 10;
- var min_mp_potions = 10;
- //intervals
- //travel loop
- setInterval(function()
- {
- // travel loop interaptors.
- if (travel_mod)
- {
- //potion alert
- if (potion_alert && !destination_set)
- {
- smart_move(0,0);
- destination_set = true;
- }
- //buying potions
- 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
- {
- even_split = (character.gold/2)/20;
- buy("hpot0",
- (max_hp_potions - quantity("hpot0"))-even_split
- );
- buy("mpot0",
- (max_mp_potions - quantity("mpot0"))-even_split
- );
- }
- }
- //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
- //combat loop
- setInterval(function(){
- //potion use conditions
- if (character.hp < character.max_hp*take_hp_modifier ||
- character.mp < character.max_mp*take_mp_modifier)
- {
- use_hp_or_mp();
- }
- loot();
- // combat loop intraptors
- 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;
- }
- //setting target
- 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;
- }
- }
- // if we are more then 50 pixels away use the speed.
- if (
- sqrt(
- ((character.x - target.x)*(character.x - target.x))-
- ((character.y - target.y)*(character.y - target.y))
- ) > 50
- )
- {
- parent.use_skill("charge");
- }
- //attacking coditions
- 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/6 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