diff --git a/runner_functions.js b/runner_functions.js index 816de5f..73ba8a7 100644 --- a/runner_functions.js +++ b/runner_functions.js @@ -1,4 +1,5 @@ //#NOTE: If you want to see a new function/feature, just request it at: https://github.com/kaansoral/adventureland/issues +//#NOTICE: [19/10/16]: The CODE will receive many new features and improvements soon :) var character=parent.character; function get_socket() @@ -16,6 +17,24 @@ function set_message(text) $('#gg').html(text); } +function game_log(message,color) +{ + if(!color) color="#51D2E1"; + parent.add_log(message,color); +} + +function get_target_of(entity) // .target is a Name for Monsters and `id` for Players - this function return whatever the entity in question is targeting +{ + if(!entity || !entity.target) return null; + if(character.id+''==entity.target+'' || character.name+''==entity.target+'') return character; + for(var id in parent.entities) + { + var e=parent.entities[id]; + if(e.id+''==entity.target+'' || e.name+''==entity.target+'') return e; + } + return null; +} + function get_target() { return parent.ctarget; @@ -30,6 +49,7 @@ function get_targeted_monster() function change_target(target) { parent.ctarget=target; + parent.send_target_logic(); } function in_attack_range(target) // also works for priests/heal @@ -66,22 +86,32 @@ function sell(num,quantity) //sell an item from character.items by it's order - parent.sell(num,quantity); } -function upgrade(item_num,scroll_num) //number of the item and scroll on the show_json(character.items) array - 0 to N-1 +function upgrade(item_num,scroll_num,offering_num) //number of the item and scroll on the show_json(character.items) array - 0 to N-1 { parent.u_item=item_num; parent.u_scroll=scroll_num; + parent.u_offering=offering_num; parent.upgrade(); } +function compound(item0,item1,item2,scroll_num,offering_num) // for example -> compound(0,1,2,6) -> 3 items in the first 3 slots, scroll at the 6th spot +{ + parent.c_items=[item0,item1,item2]; + parent.c_last=3; + parent.c_scroll=scroll_num; + parent.c_offering=offering_num; + parent.compound(); +} + function exchange(item_num) { parent.e_item=item_num; parent.exchange(); } -function say(message) +function say(message) // please use "say()" and not socket.emit("say") manually, thank you! :) { - parent.socket.emit("say",{message:message}); + parent.socket.emit("say",{message:message,code:true}); } function move(x,y) @@ -113,11 +143,22 @@ function get_player(name) // returns the player by name, if the player is within function get_nearest_monster(args) { + //args: + // max_att - max attack + // min_xp - min XP + // target: Only return monsters that target this "name" or player object + // no_target: Only pick monsters that don't have any target var min_d=999999,target=null; + + if(!args) args={}; + if(args && args.target && args.target.name) args.target=args.target.name; + for(id in parent.entities) { var current=parent.entities[id]; if(current.type!="monster" || args.min_xp && current.xpargs.max_att || current.dead) continue; + if(args.target && current.target!=args.target) continue; + if(args.no_target && current.target && current.target!=character.name) continue; var c_dist=parent.distance(character,current); if(c_dist