mirror of
https://github.com/gooba42/adventureland.git
synced 2026-10-14 18:39:27 -05:00
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
{%if user|is_user_newb %}// 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!
|
|
|
|
{%endif%}var attack_mode=false
|
|
|
|
setInterval(function(){
|
|
|
|
use_hp_or_mp();
|
|
loot();
|
|
|
|
if(!attack_mode || character.rip || is_moving(character)) 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;
|
|
}
|
|
}
|
|
|
|
if(!is_in_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))
|
|
{
|
|
set_message("Attacking");
|
|
attack(target);
|
|
}
|
|
|
|
},1000/4); // Loops every 1/4 seconds.
|
|
|
|
// Learn Javascript: https://www.codecademy.com/learn/introduction-to-javascript
|
|
// Write your own CODE: https://github.com/kaansoral/adventureland{% if not domain.electron%}
|
|
// NOTE: If the tab isn't focused, browsers slow down the game
|
|
// NOTE: Use the performance_trick() function as a workaround{%endif%}
|