From ad39e8b8519f050120b6b11987cb12ac2cdebaed Mon Sep 17 00:00:00 2001 From: Kaan Soral Date: Fri, 8 Feb 2019 22:37:46 +0300 Subject: [PATCH] Update runner_functions.js --- runner_functions.js | 92 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 4 deletions(-) diff --git a/runner_functions.js b/runner_functions.js index f53f493..2dbd4cd 100644 --- a/runner_functions.js +++ b/runner_functions.js @@ -57,6 +57,11 @@ function get_active_characters() return parent.get_active_characters() } +function change_server(region,name) // change_server("EU","I") or change_server("ASIA","PVP") or change_server("US","III") +{ + parent.window.location.href="/character/"+character.name+"/in/"+region+"/"+name+"/"; +} + function is_pvp() { return G.maps[character.map].pvp || server.is_pvp; @@ -118,9 +123,65 @@ function use_skill(name,target) parent.use_skill(name,target); } -function transport(map,spawn) +function bank_deposit(gold) { - parent.socket.emit("transport",{to:map,s:spawn}); + if(!character.bank) return game_log("Not inside the bank"); + parent.socket.emit("bank",{operation:"deposit",amount:gold}); +} + +function bank_withdraw(gold) +{ + if(!character.bank) return game_log("Not inside the bank"); + parent.socket.emit("bank",{operation:"withdraw",amount:gold}); +} + +function bank_store(num,pack,pack_slot) +{ + // bank_store(0) - Stores the first item in inventory in the first/best spot in bank + // parent.socket.emit("bank",{operation:"swap",pack:pack,str:num,inv:num}); + // Above call can be used manually to pull items, swap items and so on - str is from 0 to 41, it's the storage slot # + // parent.socket.emit("bank",{operation:"swap",pack:pack,str:num,inv:-1}); <- this call would pull an item to the first inventory slot available + // pack is one of ["items0","items1","items2","items3","items4","items5","items6","items7"] + if(!character.bank) return game_log("Not inside the bank"); + if(!character.items[num]) return game_log("No item in that spot"); + if(!pack_slot) pack_slot=-1; // the server interprets -1 as first slot available + if(!pack) + { + var cp=undefined,cs=undefined; + bank_packs.forEach(function(cpack){ + if(!character.bank[cpack]) return; + for(var i=0;i<42;i++) + { + if(pack) return; + if(can_stack(character.bank[cpack][i],character.items[num])) // the item we want to store and this bank item can stack - best case scenario + { + pack=cpack; + } + if(!character.bank[cpack][i] && !cp) + { + cp=cpack; + } + } + }); + if(!pack && !cp) return game_log("Bank is full!"); + if(!pack) pack=cp; + } + parent.socket.emit("bank",{operation:"swap",pack:pack,str:-1,inv:num}); +} + +function swap(a,b) // inventory move/swap +{ + parent.socket.emit("imove",{a:a,b:b}); +} + +function quantity(name) +{ + var q=0; + for(var i=0;i