diff --git a/runner_functions.js b/runner_functions.js index eb69d02..8047eba 100644 --- a/runner_functions.js +++ b/runner_functions.js @@ -1,7 +1,22 @@ -//#NOTE: If you want to see a new function/feature, just request it at: https://github.com/kaansoral/adventureland/issues -var character=parent.character; -var G=parent.G; // Game data -var safeties=true; +// #NOTE: If you want to see a new function/feature, just request it at: https://github.com/kaansoral/adventureland/issues +// Or at #feedback in Discord: https://discord.gg/4SXJGU + +var character={ + // This object proxies the real parent.character + // Normal entities have normal coordinates, their {x,y}'s are equal to their {real_x,real_y}'s + // The character object is special, it's always in the middle of the screen, so it has static {x,y}'s + // Added this wrapper so instead of using .real_x and .real_y on all entities, .x and .y's can be used uniformly + "note":"This is a proxy object, the real character is in parent.character", + "properties":["x","y"], +} + +Object.defineProperty(character,'x',{get:function(){return parent.character.real_x;},set:function(){game_log("You can't set coordinates manually, use the move(x,y) function!");}}); +Object.defineProperty(character,'y',{get:function(){return parent.character.real_y;},set:function(){game_log("You can't set coordinates manually, use the move(x,y) function!");}}); +for(var p in parent.character) proxy(p); // Not all properties are sadly available right away, new properties are captured imperfectly +// var character=parent.character; // Old [25/06/2018] + +var G=parent.G; // Game Data - Use show_json(Object.keys(G)); and inspect individual data with show_json(G.skills) and alike +var safeties=true; // Prevents common delay based issues that cause many requests to be sent to the server in a burst that triggers the server to disconnect the character server={ mode:parent.gameplay, // "normal", "hardcore", "test" @@ -97,6 +112,7 @@ function use(name,target) // a multi-purpose use function, works for skills too function use_skill(name,target) { + // for blink: use_skill("blink",[x,y]) if(!target) target=get_target(); parent.use_skill(name,target); } @@ -204,7 +220,7 @@ function change_target(target,public) function can_move_to(x,y) { if(is_object(x)) y=x.real_y,x=x.real_x; - return can_move({map:character.map,x:character.real_x,y:character.real_y,going_x:x,going_y:y}); + return can_move({map:character.map,x:character.real_x,y:character.real_y,going_x:x,going_y:y,base:character.base}); } function xmove(x,y) @@ -326,12 +342,12 @@ function exchange(item_num) parent.exchange(1); } -function say(message) // please use responsibly, thank you! :) +function say(message) // please use MORE responsibly, thank you! :) { parent.say(message,1); } -function pm(name,message) // please use MORE responsibly, thank you! :) +function pm(name,message) // please use responsibly, thank you! :) { parent.private_say(name,message,0) } @@ -339,15 +355,7 @@ function pm(name,message) // please use MORE responsibly, thank you! :) function move(x,y) { if(!can_walk(character)) return; - var map=parent.map,move=parent.calculate_move(parent.M,character.real_x,character.real_y,parseFloat(x)||0,parseFloat(y)||0); - character.from_x=character.real_x; - character.from_y=character.real_y; - character.going_x=move.x; - character.going_y=move.y; - character.moving=true; - parent.calculate_vxy(character); - // parent.console.log("engaged move "+character.angle); - parent.socket.emit("move",{x:character.real_x,y:character.real_y,going_x:character.going_x,going_y:character.going_y,m:character.m}); + parent.move(x,y); } function show_json(e) // renders the object as json inside the game @@ -376,6 +384,7 @@ 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"); for(id in parent.entities) { @@ -438,8 +447,9 @@ function loot(commander) var chest=parent.chests[id]; if(safeties && (chest.items>character.esize || chest.last_loot && mssince(chest.last_loot)<1600)) continue; chest.last_loot=last_loot; - if(commander) parent.parent.socket.emit("open_chest",{id:id}); - else parent.socket.emit("open_chest",{id:id}); + if(commander) parent.parent.open_chest(id); + else parent.open_chest(id); + // parent.socket.emit("open_chest",{id:id}); old version [02/07/18] looted++; if(looted==2) break; } @@ -570,6 +580,7 @@ var buttons=parent.code_buttons; function draw_line(x,y,x2,y2,size,color) { // keep in mind that drawings could significantly slow redraws, especially if you don't .destroy() them + if(!game.graphics) return; if(!color) color=0xF38D00; if(!size) size=1; e=new PIXI.Graphics(); @@ -585,6 +596,7 @@ function draw_line(x,y,x2,y2,size,color) // Example: draw_circle(character.real_x,character.real_y,character.range) :) [22/10/16] function draw_circle(x,y,radius,size,color) { + if(!game.graphics) return; if(!color) color=0x00F33E; if(!size) size=1; e=new PIXI.Graphics(); @@ -732,6 +744,55 @@ function preview_item(def,args) parent.prop_cache={}; } +function set_skillbar() // example: set_skillbar("1","2","3","4","R") or set_skillbar(["1","2","3","4","R"]) +{ + var arr=["1"]; + if(is_array(arguments[0])) arr=arguments[0]; + else + { + arr=[]; + for(var i=0;i"+output+""); + if(json_output!==undefined) parent.show_json(json_output); +} + +function performance_trick() +{ + parent.performance_trick(); // Just plays an empty sound file, so browsers don't throttle JS, only way to prevent it, interesting cheat [05/07/18] +} + function doneify(fn,s_event,f_event) { return function(a,b,c,d,e,f){