diff --git a/runner_functions.js b/runner_functions.js index 11910fd..9fb0775 100644 --- a/runner_functions.js +++ b/runner_functions.js @@ -175,6 +175,15 @@ function swap(a,b) // inventory move/swap parent.socket.emit("imove",{a:a,b:b}); } +function locate_item(name) +{ + for(var i=0;i compound(0,1,2,6) -> 3 items in the first 3 slots, scroll at the 6th spot @@ -480,12 +489,13 @@ function get_nearest_monster(args) if(!args) args={}; if(args && args.target && args.target.name) args.target=args.target.name; - if(args && args.type=="monster") game_log("You used monster.type, which is always 'monster', use monster.mtype instead"); + if(args && args.type=="monster") game_log("get_nearest_monster: you used monster.type, which is always 'monster', use monster.mtype instead"); + if(args && args.mtype) game_log("get_nearest_monster: you used 'mtype', you should use 'type'"); for(id in parent.entities) { var current=parent.entities[id]; - if(current.type!="monster" || current.dead) continue; + if(current.type!="monster" || !current.visible || current.dead) continue; if(args.type && current.mtype!=args.type) continue; if(args.min_xp && current.xpargs.max_att) continue; @@ -508,7 +518,7 @@ function get_nearest_hostile(args) // mainly as an example [08/02/17] for(id in parent.entities) { var current=parent.entities[id]; - if(current.type!="character" || current.rip || current.invincible || current.npc) continue; + if(current.type!="character" || !current.visible || current.rip || current.invincible || current.npc) continue; if(current.party && character.party==current.party) continue; if(current.guild && character.guild==current.guild) continue; if(args.friendship && in_arr(current.owner,parent.friends)) continue; @@ -614,17 +624,6 @@ function respawn() parent.socket.emit('respawn'); } -function handle_death() -{ - // When a character dies, character.rip is true, you can override handle_death and manually respawn - // IDEA: A Resident PVP-Dweller, with an evasive Code + irregular respawning - // respawn current has a 12 second cooldown, best wait 15 seconds before respawning [24/11/16] - // setTimeout(respawn,15000); - // return true; - // NOTE: Add `if(character.rip) {respawn(); return;}` to your main loop/interval too, just in case - return -1; -} - function handle_command(command,args) // command's are things like "/party" that are entered through Chat - args is a string { // game_log("Command: /"+command+" Args: "+args); @@ -639,11 +638,6 @@ function send_cm(to,data) parent.send_code_message(to,data); } -function on_cm(name,data) -{ - game_log("Received a code message from: "+name); -} - function on_disappear(entity,data) { // game_log("disappear: "+entity.id+" "+JSON.stringify(data)); @@ -810,7 +804,7 @@ character.trigger=function(event,args){ } catch(e) { - game_log("Listener Exception ("+l.event+") "+e,code_color); + game_log("Listener Exception ("+l.event+") "+e,colors.code_error); } if(l.once || l.f && l.f.delete) to_delete.push(l.id); } @@ -857,7 +851,7 @@ game.trigger=function(event,args){ } catch(e) { - game_log("Listener Exception ("+l.event+") "+e,code_color); + game_log("Listener Exception ("+l.event+") "+e,colors.code_error); } if(l.once || l.f && l.f.delete) to_delete.push(l.id); } @@ -963,7 +957,7 @@ function pget(name) function load_code(name,onerror) // onerror can be a function that will be executed if load_code fails { - if(!onerror) onerror=function(){ game_log("load_code: Failed to load","#E13758"); } + if(!onerror) onerror=function(){ game_log("load_code: Failed to load",colors.code_error); } var xhrObj = new XMLHttpRequest(); xhrObj.open('GET',"/code.js?name="+encodeURIComponent(name)+"×tamp="+(new Date().getTime()), false); xhrObj.send(''); @@ -979,7 +973,9 @@ var smart={ map:"main",x:0,y:0, on_done:function(){}, plot:null, - edge:20, + edge:20, // getting 20px close to the target is enough + baby_edge:80, // start treading lightly when 60px close to the target or starting point + try_exact_spot: false, use_town:false, prune:{ smooth:true, @@ -1081,6 +1077,8 @@ function stop(action) var queue=[],visited={},start=0,best=null; var moves=[[0,15],[0,-15],[15,0],[-15,0]]; +var baby_steps=[[0,5],[0,-5],[5,0],[-5,0]]; +// baby_steps is a new logic, used just around the target or starting point, to get out of tough spots [08/03/19] function plot(index) { @@ -1122,11 +1120,16 @@ function bfs() while(start