diff --git a/ConvenientItems.js b/ConvenientItems.js
new file mode 100644
index 0000000..4dffc72
--- /dev/null
+++ b/ConvenientItems.js
@@ -0,0 +1,53 @@
+var hp_potion = 'hpot0'; //+200 HP Potion = 'hpot0', +400 HP Potion = 'hpot1' [always keep '' around it]
+var mp_potion = 'mpot0'; //+300 MP Potion = 'mpot0', +500 MP Potion = 'mpot1' [always keep '' around it]
+
+
+//Returns the item slot and the item given the slot to start from and a filter.
+function find_item_filter(filter, search_slot) {
+ let slot = search_slot;
+ if (!slot)
+ slot = 0
+
+ for (let i = slot; i < character.items.length; i++) {
+ let item = character.items[i];
+
+ if (item && filter(item))
+ return [i, character.items[i]];
+ }
+
+ return [-1, null];
+}
+
+//Returns the item information from parent.G.items of the item.
+function item_info(item) {
+ return parent.G.items[item.name];
+}
+
+function isInsideBank() {
+ //!character.bank
+ return character.map === "bank";
+}
+
+function depositItems() {
+ set_message("GT Bank");
+ smart_move({to: "bank"});
+ if (isInsideBank()) {
+ if (character.esize === 42) return; //empty inventory
+ for (item in character.items) {
+ if (item == 0) continue;
+ if (!character.items[item]) continue;
+ bank_store(item);
+ }
+ }
+}
+
+function turnStuffIn() {
+ use_skill("town");
+ send_gold("TradeyBoy", 1000000);
+ if (character.esize === 42) return; //empty inventory
+ for (item in character.items) {
+ //if (item == 0) continue;
+ if (!character.items[item]) continue;
+ send_item("TradeyBoy", item);
+ }
+}
\ No newline at end of file
diff --git a/Default.js b/Default.js
new file mode 100644
index 0000000..069603e
--- /dev/null
+++ b/Default.js
@@ -0,0 +1,41 @@
+// 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!
+
+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
+// NOTE: If the tab isn't focused, browsers slow down the game
+// NOTE: Use the performance_trick() function as a workaround
\ No newline at end of file
diff --git a/Dialogue/Guardian.js b/Dialogue/Guardian.js
new file mode 100644
index 0000000..6bf8990
--- /dev/null
+++ b/Dialogue/Guardian.js
@@ -0,0 +1,3 @@
+if (character.id.startsWith("Guardian")) {
+ say("I'm a guardian!");
+}
\ No newline at end of file
diff --git a/Follower.js b/Follower.js
new file mode 100644
index 0000000..3469c18
--- /dev/null
+++ b/Follower.js
@@ -0,0 +1,37 @@
+// Follow Lead & Attack Leaders Target
+// Base Code & Auto Compounding stuff Courtesy of: Mark
+// Edits & Additions By: JourneyOver
+// Version 1.5.9
+
+//////////////////////////////
+// Optional Settings Start //
+////////////////////////////
+
+var gui_tl_gold = false; //Enable Kill (or XP) till level & GPH [scripted session] = true, Disable Kill (or XP) till level & GPH [scripted session] = false
+var gui_timer = false; //Enable time till level [scripted session] = true, Disable time till level [scripted session] = false
+var till_level = 0; //Kills till level = 0, XP till level = 1
+// GUI [if either GUI setting is turned on and then you want to turn them off you'll have to refresh the game] //
+
+var uc = false; //Enable Upgrading/Compounding/selling/exchanging of items = true, Disable Upgrading/Compounding/selling/exchanging of items = false
+var upgrade_level = 8; //Max level it will stop upgrading items at if enabled
+var compound_level = 3; //Max level it will stop compounding items at if enabled
+swhitelist = []; //swhitelist is for the selling of items
+ewhitelist = []; //ewhitelist is for the exchanging of items
+uwhitelist = []; //uwhitelist is for the upgrading of items.
+cwhitelist = ['wbook0', 'intamulet', 'stramulet', 'dexamulet', 'intearring', 'strearring', 'dexearring', 'hpbelt', 'hpamulet', 'ringsj', 'amuletofm', 'orbofstr', 'orbofint', 'orbofres', 'orbofhp']; //cwhitelist is for the compounding of items.
+// Upgrading/Compounding/selling/exchanging //
+
+var purchase_pots = false; //Enable Potion Purchasing = true, Disable Potion Purchasing = false
+var buy_hp = false; //Allow HP Pot Purchasing = true, Disallow HP Pot Purchasing = false
+var buy_mp = false; //Allow MP Pot Purchasing = true, Disallow MP Pot Purchasing = false
+var hp_potion = 'hpot0'; //+200 HP Potion = 'hpot0', +400 HP Potion = 'hpot1' [always keep '' around it]
+var mp_potion = 'mpot0'; //+300 MP Potion = 'mpot0', +500 MP Potion = 'mpot1' [always keep '' around it]
+var pots_minimum = 50; //If you have less than this, you will buy more
+var pots_to_buy = 1000; //This is how many you will buy
+// Potion Maintenance //
+
+useInvis = false; //[Rogue Skill] //Enable going invisible on cooldown = true, Disable going invisible on cooldown = false
+useBurst = false; //[Mage Skill] //Enable Using burst on cooldown [only on targets above 6,000 hp] = true, Disable using burst on cooldown = false
+useCharge = false; //[Warrior Skill] //Enable Using charge on cooldown = true, Disable using charge on cooldown = false
+useSupershot = false; //[Ranger Skill] //Enable using supershot on cooldown = true, Disable using supershot on cooldown = false
+// Skill Usage [Only turn on skill for the class you are running, if you want to use skills] //
\ No newline at end of file
diff --git a/LeadHunter.js b/LeadHunter.js
new file mode 100644
index 0000000..cbe4d92
--- /dev/null
+++ b/LeadHunter.js
@@ -0,0 +1,614 @@
+// Basic Grinding
+// Auto Compounding & Upgrading stuff Courtesy of: Mark
+// Version 1.10.3
+
+//////////////////////////
+// Main Settings Start //
+////////////////////////
+load_code("manage_party");
+load_code("7");
+//NOTE: If you use mode 2, targetting will go by character range for searching for a target instead of going for a wider radius of searching for a target. [best used for range classes]
+
+var mode = 0; //Standing still (will move if target is out of range) = 0, Front of target (Moves to front of target before attacking) = 1, Don't move at all (will not move even if target is out of range) = 2
+// Movement //
+
+var mtype = 'bee'; //Monster Type of the enemy you want to attack
+// Preferred Monster [always keep '' around name] //
+
+//If you don't know the monster type of an enemy you can find it here -- http://adventure.draiv.in/
+
+var mtype2 = 'tinycrab'; //Monster Type of the enemy you want to attack if you can't find the first
+// Alternate Monster [always keep '' around name] //
+
+////////////////////////
+// Main Settings End //
+//////////////////////
+
+//////////////////////////////
+// Optional Settings Start //
+////////////////////////////
+
+var gui_tl_gold = false; //Enable kill (or xp) till level & GPH [scripted session] = true, Disable kill (or xp) till level & GPH [scripted session] = false
+var gui_timer = false; //Enable time till level [scripted session] = true, Disable time till level [scripted session] = false
+var till_level = 0; //Kills till level = 0, XP till level = 1
+// GUI [if either GUI setting is turned on and then you want to turn them off you'll have to refresh the game] //
+
+var uc = false; //Enable Upgrading/Compounding/selling/exchanging of items = true, Disable Upgrading/Compounding/selling/exchanging of items = false
+var upgrade_level = 8; //Max level it will stop upgrading items at if enabled
+var compound_level = 3; //Max level it will stop compounding items at if enabled
+swhitelist = []; //swhitelist is for the selling of items
+ewhitelist = []; //ewhitelist is for the exchanging of items
+uwhitelist = []; //uwhitelist is for the upgrading of items.
+cwhitelist = ['wbook0', 'intamulet', 'stramulet', 'dexamulet', 'intearring', 'strearring', 'dexearring', 'hpbelt', 'hpamulet', 'ringsj', 'amuletofm', 'orbofstr', 'orbofint', 'orbofres', 'orbofhp']; //cwhitelist is for the compounding of items.
+// Upgrading/Compounding/selling/exchanging //
+
+var purchase_pots = true; //Enable Potion Purchasing = true, Disable Potion Purchasing = false
+var buy_hp = true; //Allow HP Pot Purchasing = true, Disallow HP Pot Purchasing = false
+var buy_mp = true;
+ //Allow MP Pot Purchasing = true, Disallow MP Pot Purchasing = false
+var hp_potion = 'hpot0'; //+200 HP Potion = 'hpot0', +400 HP Potion = 'hpot1' [always keep '' around it]
+var mp_potion = 'mpot0'; //+300 MP Potion = 'mpot0', +500 MP Potion = 'mpot1' [always keep '' around it]
+var pots_minimum = 50; //If you have less than this, you will buy more
+var pots_to_buy = 1000; //This is how many you will buy
+// Potion Maintenance //
+
+useInvis = false; //[Rogue Skill] //Enable going invisible on cooldown = true, Disable going invisible on cooldown = false
+useBurst = false; //[Mage Skill] //Enable Using burst on cooldown [only on targets above 6,000 hp] = true, Disable using burst on cooldown = false
+useTaunt = false; //[Warrior Skill] //Enable Using taunt on cooldown = true, Disable using taunt on cooldown = false
+useCharge = false; //[Warrior Skill] //Enable Using charge on cooldown = true, Disable using charge on cooldown = false
+useSupershot = true; //[Ranger Skill] //Enable using supershot on cooldown = true, Disable using supershot on cooldown = false
+// Skill Usage [Only turn on skill for the class you are running, if you want to use skills] //
+
+////////////////////////////
+// Optional Settings End //
+//////////////////////////
+
+//draw_circle(character.real_x,character.real_y,character.range);
+//show_json(character);
+//show_json(get_targeted_monster());
+//show_json(parent.M);
+//JSONs
+
+//Grind Code start --------------------------
+setInterval(function () {
+
+ //Monster Searching
+ var target = get_targeted_monster();
+ if (mode == 2 && target && !in_attack_range(target)) target = null;
+ if (!target || (target.target && target.target != character.name)) {
+ target = get_closest_monster({
+ m_type_priority: mtype,
+ m_type_secondary: mtype2,
+ targeting_mode: mode,
+ no_attack: true,
+ path_check: true
+ });
+ if (mode == 2 && target && !in_attack_range(target)) target = null;
+ if (target) {
+ change_target(target);
+ } else {
+ set_message("No Monsters");
+ return;
+ }
+ }
+
+ //Uses Vanish if enabled
+ if (useInvis && character.ctype === 'rogue') {
+ invis();
+ }
+
+ //Uses Burst if enabled [only on targets above 6,000 hp]
+ if (useBurst && target.hp > 6000 && character.ctype === 'mage') {
+ burst(target);
+ }
+
+ //Uses taunt if enabled
+ if (useTaunt && character.ctype === 'warrior') {
+ taunt(target);
+ }
+
+ //Uses Charge if enabled
+ if (useCharge && character.ctype === 'warrior') {
+ charge();
+ }
+
+ //Uses supershot if enabled [only on targets above 6,000 hp]
+ if (useSupershot && target.hp > 6000 && character.ctype === 'ranger') {
+ supershot(target);
+ }
+
+ //Attack
+ if (can_attack(target))
+ attack(target);
+ set_message("Attacking: " + target.mtype);
+
+}, (1 / character.frequency + 50) / 4); //base loop off character frequency
+
+setInterval(function () {
+
+ var target = get_targeted_monster();
+ //Following/Maintaining Distance
+ if (mode == 0) {
+ //Walk half the distance
+ if (target && !in_attack_range(target)) {
+ move(
+ character.real_x + (target.real_x - character.real_x) / 2,
+ character.real_y + (target.real_y - character.real_y) / 2
+ );
+ }
+ } else if (mode == 1) {
+ if (target) {
+ //Move to front of target
+ move(target.real_x + 5, target.real_y + 5);
+ }
+ }
+
+ //Heal and restore mana if required
+ if (character.hp / character.max_hp < 0.4 && new Date() > parent.next_potion) {
+ parent.use('hp');
+ if (character.hp <= 100)
+ parent.socket.emit("transport", {
+ to: "main"
+ });
+ //Panic Button
+ }
+
+ if (character.mp / character.max_mp < 0.3 && new Date() > parent.next_potion)
+ parent.use('mp');
+
+}, 250); //Loop every 250 milliseconds
+
+setInterval(function () {
+
+ //Upgrade/Compound/Sell/Exchange Items
+ if (uc) {
+ seuc_merge(upgrade_level, compound_level);
+ }
+
+ //Purchases Potions when below threshold
+ if (purchase_pots) {
+ purchase_potions(buy_hp, buy_mp);
+ }
+
+}, 1000); //Loop every 1 second.
+
+setInterval(function () {
+
+ //Updates GUI for Till_Level/Gold
+ if (gui_tl_gold) {
+ updateGUI();
+ }
+
+ //Updates GUI for Time Till Level
+ if (gui_timer) {
+ update_xptimer();
+ }
+
+ //Loot available chests
+ loot();
+
+}, 500); //Loop every 500 milliseconds
+
+//--------------------------Grind Code End
+
+//Upgrade/Compound/Sell/Exchange Items
+function seuc_merge(ulevel, clevel) {
+ for (let i = 0; i < character.items.length; i++) {
+ let c = character.items[i];
+ if (c) {
+ if (uwhitelist.includes(c.name) && c.level < ulevel) {
+ let grades = item_info(c).grades;
+ let scrollname;
+ //Gets the item grade from parent.G.items so it only uses the cheapest scroll possible.
+ if (c.level < grades[0])
+ scrollname = 'scroll0';
+ else if (c.level < grades[1])
+ scrollname = 'scroll1';
+ else
+ scrollname = 'scroll2';
+ //Check if the required scroll is in the inventory, buy one if there isn't.
+
+ let [scroll_slot, scroll] = find_item_filter(i => i.name === scrollname);
+ if (!scroll) {
+ parent.buy(scrollname);
+ return;
+ }
+
+ //Upgrade the item.
+ parent.socket.emit('upgrade', {
+ item_num: i,
+ scroll_num: scroll_slot,
+ offering_num: null,
+ clevel: c.level
+ });
+ return;
+ } else if (cwhitelist.includes(c.name) && c.level < clevel) { //There is an item that has to be compounded.
+ let [item2_slot, item2] = find_item_filter((item) => c.name === item.name && c.level === item.level, i + 1); //The second item to compound.
+ let [item3_slot, item3] = find_item_filter((item) => c.name === item.name && c.level === item.level, item2_slot + 1); //The third item to compound.
+ if (item2 && item3) { //If there is a second and third copy of the item compound them.
+ let cscrollname;
+ if (c.level < 2) //Use whitescroll at base and +1.
+ cscrollname = 'cscroll0';
+ else //Use blackscroll at +2 and higher
+ cscrollname = 'cscroll1';
+
+ //Check if the required scroll is in the inventory, buy one if there isn't.
+ let [cscroll_slot, cscroll] = find_item_filter(i => i.name === cscrollname);
+ if (!cscroll) {
+ parent.buy(cscrollname);
+ return;
+ }
+
+ //Compound the items.
+ parent.socket.emit('compound', {
+ items: [i, item2_slot, item3_slot],
+ scroll_num: cscroll_slot,
+ offering_num: null,
+ clevel: c.level
+ });
+ return;
+ }
+ } else if (c && ewhitelist.includes(c.name)) { //There is an item that has to be exchanged.
+
+ //Exchange the items.
+ exchange(i)
+ parent.e_item = i;
+ } else if (c && swhitelist.includes(c.name)) { //There is an item that has to be sold.
+
+ //Sell the items.
+ sell(i);
+ }
+ }
+ }
+}
+
+//Potion Purchasing
+function purchase_potions(buyHP, buyMP) {
+ let [hpslot, hppot] = find_item_filter(i => i.name == hp_potion);
+ let [mpslot, mppot] = find_item_filter(i => i.name == mp_potion);
+
+ if (buyHP && (!hppot || hppot.q < pots_minimum)) {
+ parent.buy(hp_potion, pots_to_buy);
+ set_message("Buying HP pots.");
+ }
+ if (buyMP && (!mppot || mppot.q < pots_minimum)) {
+ parent.buy(mp_potion, pots_to_buy);
+ set_message("Buying MP pots.");
+ }
+}
+
+//Returns the item slot and the item given the slot to start from and a filter.
+function find_item_filter(filter, search_slot) {
+ let slot = search_slot;
+ if (!slot)
+ slot = 0
+
+ for (let i = slot; i < character.items.length; i++) {
+ let item = character.items[i];
+
+ if (item && filter(item))
+ return [i, character.items[i]];
+ }
+
+ return [-1, null];
+}
+
+//Returns the item information from parent.G.items of the item.
+function item_info(item) {
+ return parent.G.items[item.name];
+}
+
+//Custom m_type targetting
+function get_closest_monster(args) {
+ //args:
+ //m_type_priority - the monster you want to attack (bosses)
+ //m_type_secondary - the monster you attack when your boss is not there
+ //target: Only return monsters that target this "name" or player object
+ var min_d = 999999,
+ target = null;
+ var mode = -1;
+ if (args.targeting_mode) {
+ mode = args.targeting_mode
+ if (mode == 2) min_d = character.range;
+ }
+ if (args.m_type_priority == null && args.m_type_secondary == null) return null;
+ 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" || current.dead || (current.target && current.target != character.name)) continue;
+ if (args.no_target && current.target && current.target != null && current.target != character.name) continue;
+ if (args.path_check && !can_move_to(current)) continue;
+ var c_dist = parent.distance(character, current);
+ if (current.mtype == args.m_type_priority) {
+ if (mode != 2) return current;
+ else if (mode == 2 && c_dist < character.range) return current;
+ } else if (c_dist < min_d && current.mtype == args.m_type_secondary) {
+ min_d = c_dist;
+ target = current;
+ }
+ }
+ return target;
+}
+
+//Skill Usage
+
+//Casts Vanish if class is Rogue and enabled and off cooldown
+var lastinvis;
+
+function invis() {
+ //Vanish one invis is off cd (cd is 12sec).
+ if (!lastinvis || new Date() - lastinvis > 12000) {
+ lastinvis = new Date();
+ parent.socket.emit("ability", {
+ name: "invis",
+ });
+ }
+}
+
+//Casts burst if class is mage and enabled and off cooldown
+var lastburst;
+
+function burst(target) {
+ //Cast burst on target whenever you're off cd (cd is 10sec).
+ if (!lastburst || new Date() - lastburst > 10000) {
+ lastburst = new Date();
+ parent.socket.emit("ability", {
+ name: "burst",
+ id: target.id
+ });
+ }
+}
+
+//casts Taunt if class is warrior and enabled and off cooldown
+var lasttaunt;
+
+function taunt(target) {
+ //Taunt only if target hasn't been taunted and if taunt is from cd (cd is 6sec).
+ if ((!lasttaunt || new Date() - lasttaunt > 6000) && !target.taunted) {
+ lasttaunt = new Date();
+ parent.socket.emit("ability", {
+ name: "taunt",
+ id: target.id
+ });
+ }
+}
+
+//casts charge if class is warrior and enabled and off cooldown
+var lastcharge;
+
+function charge() {
+ //Charge only if charge is off of cd (cd is 40sec).
+ if (!lastcharge || new Date() - lastcharge > 40000) {
+ lastcharge = new Date();
+ parent.socket.emit("ability", {
+ name: "charge",
+ });
+ }
+}
+
+//casts supershot when off cooldown and if enabled
+var lastsupershot;
+
+function supershot(target) {
+ //Cast supershot whenever your off cd (cd is 30sec).
+ if (!lastsupershot || new Date() - lastsupershot > 30000) {
+ lastsupershot = new Date();
+ parent.socket.emit("ability", {
+ name: "supershot",
+ id: target.id
+ });
+ }
+}
+
+//GUI Stuff
+var minute_refresh; //how long before the clock refreshes
+var last_target = null;
+var gold = character.gold;
+var date = new Date();
+var p = parent;
+
+function init_xptimer(minref) {
+ minute_refresh = minref || 1;
+ p.add_log(minute_refresh.toString() + ' min until tracker refresh!', 0x00FFFF);
+
+ let $ = p.$;
+ let brc = $('#bottomrightcorner');
+
+ brc.find('#xptimer').remove();
+
+ let xpt_container = $('
').css({
+ background: 'black',
+ border: 'solid gray',
+ borderWidth: '5px 5px',
+ width: '320px',
+ height: '96px',
+ fontSize: '28px',
+ color: '#77EE77',
+ textAlign: 'center',
+ display: 'table',
+ overflow: 'hidden',
+ marginBottom: '-5px'
+ });
+
+ //vertical centering in css is fun
+ let xptimer = $('')
+ .css({
+ display: 'table-cell',
+ verticalAlign: 'middle'
+ })
+ .html('Estimated time until level up:
Loading...
(Kill something!)')
+ .appendTo(xpt_container);
+
+ brc.children().first().after(xpt_container);
+}
+
+var last_minutes_checked = new Date();
+var last_xp_checked_minutes = character.xp;
+var last_xp_checked_kill = character.xp;
+
+//lxc_minutes = xp after {minute_refresh} min has passed, lxc_kill = xp after a kill (the timer updates after each kill)
+
+function update_xptimer() {
+ if (character.xp == last_xp_checked_kill) return;
+
+ let $ = p.$;
+ let now = new Date();
+
+ let time = Math.round((now.getTime() - last_minutes_checked.getTime()) / 1000);
+ if (time < 1) return; //1s safe delay
+ let xp_rate = Math.round((character.xp - last_xp_checked_minutes) / time);
+ if (time > 60 * minute_refresh) {
+ last_minutes_checked = new Date();
+ last_xp_checked_minutes = character.xp;
+ }
+ last_xp_checked_kill = character.xp;
+
+ let xp_missing = p.G.levels[character.level] - character.xp;
+ let seconds = Math.round(xp_missing / xp_rate);
+ let minutes = Math.round(seconds / 60);
+ let hours = Math.round(minutes / 60);
+ let counter = `${hours}h ${minutes % 60}min`;
+
+ $('#xpcounter').text(counter);
+ $('#xprate').text(`${ncomma(xp_rate)} XP/s`);
+}
+
+function initGUI() {
+ let $ = p.$;
+ let brc = $('#bottomrightcorner');
+ let blc = $('#bottomleftcorner2');
+ $('#xpui').css({
+ fontSize: '25px',
+ });
+
+ brc.find('.xpsui').css({
+ background: 'url("https://i.imgur.com/zCb8PGK.png")',
+ backgroundSize: 'cover'
+ });
+
+ blc.find('#goldui').remove();
+ blc.find('#goldgainloss').remove();
+ let gb = $('').css({
+ background: 'black',
+ border: 'solid gray',
+ borderWidth: '5px 5px',
+ width: '320px',
+ height: '34px',
+ lineHeight: '34px',
+ fontSize: '25px',
+ color: '#FFD700',
+ textAlign: 'center',
+ marginBottom: '-5px'
+ });
+ let ggl = $('').css({ //gold gain loss
+ background: 'black',
+ border: 'solid gray',
+ borderWidth: '5px 5px',
+ width: '320px',
+ height: '34px',
+ lineHeight: '34px',
+ fontSize: '25px',
+ color: '#FFD700',
+ textAlign: 'center',
+ marginBottom: '-5px'
+ });
+ $('#bottomleftcorner2').prepend(ggl);
+ $('#bottomleftcorner2').prepend(gb);
+}
+
+if (till_level === 0)
+
+ function updateGUI() {
+ let $ = p.$;
+ let xp_percent = ((character.xp / p.G.levels[character.level]) * 100).toFixed(2);
+ let xp_string = `LV${character.level} ${xp_percent}%`;
+ var goldPerHour = 0;
+ if (p.ctarget && p.ctarget.type == 'monster') {
+ last_target = p.ctarget.mtype;
+ }
+ if (last_target) {
+ let xp_missing = p.G.levels[character.level] - character.xp;
+ let monster_xp = p.G.monsters[last_target].xp;
+ goldPerHour = Math.round((character.gold - gold) / ((new Date() - date) / 3600000));
+ let party_modifier = character.party ? 1.5 / p.party_list.length : 1;
+ let monsters_left = Math.ceil(xp_missing / (monster_xp * party_modifier * character.xpm));
+ xp_string += ` (${ncomma(monsters_left)} kills to go!)`;
+ }
+ $('#xpui').html(xp_string);
+ $('#goldui').html(goldPerHour.toLocaleString('en-US', {
+ minimumFractionDigits: 0
+ }) + " Gold/hour");
+ $('#goldgainloss').html(ncomma(character.gold - gold) + " Gold gain/lost");
+ } else if (till_level === 1)
+
+ function updateGUI() {
+ let $ = p.$;
+ let xp_percent = ((character.xp / G.levels[character.level]) * 100).toFixed(2);
+ let xp_missing = ncomma(G.levels[character.level] - character.xp);
+ let xp_string = `LV${character.level} ${xp_percent}% (${xp_missing}) xp to go!`;
+ var goldPerHour = 0;
+ if (p.ctarget && p.ctarget.type == 'monster') {
+ last_target = p.ctarget.mtype;
+ }
+ goldPerHour = Math.round((character.gold - gold) / ((new Date() - date) / 3600000));
+ let party_modifier = character.party ? 1.5 / p.party_list.length : 1;
+ $('#xpui').html(xp_string);
+ $('#goldui').html(goldPerHour.toLocaleString('en-US', {
+ minimumFractionDigits: 0
+ }) + " Gold/hour");
+ $('#goldgainloss').html(ncomma(character.gold - gold) + " Gold gain/lost");
+ }
+
+function ncomma(x) {
+ return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+}
+
+if (gui_tl_gold) {
+ initGUI();
+}
+
+if (gui_timer) {
+ init_xptimer(5);
+}
+
+//Unusable:
+//sleep()
+//while loops// 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!
+
+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
diff --git a/ManageParty.js b/ManageParty.js
new file mode 100644
index 0000000..8679922
--- /dev/null
+++ b/ManageParty.js
@@ -0,0 +1,50 @@
+// Static party members
+var partyMembers = ["Nosh", "TradeyBoy", "Yunt"];
+var tank = "Nosh";
+var healer = "Nosh";
+var dps = "Nosh";
+
+var characterName = character.name;
+
+// Function to get the current party members
+function get_party() {
+ var party = {};
+ for (var name of parent.party_list) {
+ party[name] = true;
+ }
+ return party;
+}
+
+// Function to manage the party
+function manage_party() {
+ // Check if character is already in a party
+ if (character.party) {
+ var currentParty = get_party();
+
+ // Check if the current party includes all static party members
+ var allMembersPresent = partyMembers.every(function (member) {
+ return currentParty[member];
+ });
+
+ // If all members are present, stop running the script
+ if (allMembersPresent) {
+ log("All members present");
+
+ } else {
+ // Leave the current party
+ leave_party();
+ setTimeout(invite_members, 1000); // Delay inviting to ensure leaving party is processed
+ }
+ } else {
+ invite_members();
+ }
+}
+
+// Function to invite party members
+function invite_members() {
+ for (var i = 0; i < partyMembers.length; i++) {
+ if (partyMembers[i] !== characterName) {
+ send_party_invite(partyMembers[i]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Merchant.js b/Merchant.js
new file mode 100644
index 0000000..53bfa09
--- /dev/null
+++ b/Merchant.js
@@ -0,0 +1,557 @@
+// Author: deez @discord, IGN: shidded
+// credits to spadarfaar and others for large portions of code
+
+game_log("-----------------------")
+game_log("MERCHANT SCRIPT STARTED");
+game_log("-----------------------")
+//load_code(12); // party script
+
+// Merchant stand variables
+var have_stuff_to_sell = false; // Doesnt merchant have anything to sell?
+var saySomething = false; // Should merchant say something?
+var phrase = "Boop boop!"; // What merchant should say
+
+// Exchange variables
+var exchange_item_name = ["candypop", "gem0"];
+var exchange_at = 10;
+var exchange_at_two = 2;
+
+// Upgrade variables
+var item_name = "bow";
+var upgradeMaxLevel = 9; //Max level it will stop upgrading items at if enabled
+var gold_start = 1000000; // start upgrading at this much gold
+var gold_limit = 50000; // stop upgrading at this much gold
+
+// Bank variable
+var bank_at_empty_slots = 1; // Bank at this many empty slots
+
+// Various check variables
+var hasBeenToBank = false;
+var inTown = false;
+var upgrade_status = false;
+var compound_status = false;
+var hasUpgraded = false;
+var hasCompounded = false;
+var finishedUpgrading = false;
+
+// Define our state variables
+var state = "walking_to_town";
+var new_state = "";
+
+// Credits to spadarfaar for upgrade functions, this is basically a C&P of his script
+var upgradeWhitelist =
+ {
+ //ItemName, Max Level
+ pyjamas: upgradeMaxLevel,
+ bunnyears: upgradeMaxLevel,
+ carrotsword: upgradeMaxLevel,
+ firestaff: 7,
+ fireblade: 7,
+ staff: upgradeMaxLevel,
+ bow: upgradeMaxLevel,
+ sshield: 7,
+ shield: 7,
+ gloves: 7,
+ shoes: 7,
+ coat: 7,
+ helmet: 7,
+ pants: 7,
+ gloves1: 7,
+ coat1: 7,
+ helmet1: 7,
+ pants1: 7,
+ shoes1: 7,
+ harbringer: 5,
+ oozingterror: 5,
+ bataxe: 7,
+ spear: 7,
+ xmaspants: 7,
+ xmassweater: 7,
+ xmashat: 7,
+ xmasshoes: 7,
+ mittens: 7,
+ ornamentstaff: 7,
+ candycanesword: 7,
+ warmscarf: 7,
+ t2bow: 7,
+ pmace: 7,
+ basher: 7,
+ harmor: 5,
+ hgloves: 5,
+ wingedboots: 7
+ };
+
+var combineWhitelist =
+ {
+ //ItemName, Max Level
+ wbook0: 3,
+ lostearring: 2,
+ hpamulet: 3,
+ strearring: 3,
+ intearring: 3,
+ dexearring: 2,
+ hpbelt: 3,
+ ringsj: 3,
+ strring: 3,
+ intring: 3,
+ dexring: 2,
+ vitring: 3,
+ dexamulet: 2,
+ intamulet: 3,
+ stramulet: 3,
+ vitearring: 3,
+ dexbelt: 2,
+ intbelt: 3,
+ strbelt: 3
+ }
+
+
+// This function calls our state controller every 3 seconds.
+// Our state controller returns a state then based on that state
+// We preform a function such as banking or upgrading
+setInterval(function () {
+
+ //Determine what state we should be in.
+ state_controller();
+
+ //Switch statement decides what we should do based on the value of 'state'
+ switch (state) {
+ case "upgrading":
+ upgrade_status = true;
+ if (!isAtBlacksmith()) {
+ moveTo(-190, -140); // blacksmith coords
+ }
+ break;
+
+ case "compounding":
+ compound_status = true;
+ if (!isAtBlacksmith()) {
+ moveTo(-190, -140); // blacksmith coords
+ }
+ break;
+
+
+ case "walking_to_town":
+ if (!isInsideBank()) {
+ smart_move({to: "town"});
+ } else {
+ smart_move({to: "town"});
+ }
+ break;
+
+ case "banking":
+ goToBank();
+ break;
+
+ case "merching":
+ break;
+
+ case "at_town":
+ break;
+
+ case "exchange":
+ if (!isAtExchange()) {
+ moveTo(-20, -460);
+ }
+ break;
+
+ }
+
+}, 10000);//Execute every 10 seconds?
+
+var loops = 0;
+var oldState = ""; // for state output
+var stateHolder = "";
+
+// This is where state values are returned based on conditionals
+function state_controller() {
+ var amount_of_exchange_itemsOne = return_item_quantity(exchange_item_name[0]);
+ var amount_of_exchange_itemsTwo = return_item_quantity(exchange_item_name[1]);
+ if (loops < 51) {
+ loops += 1;
+ }
+ if (loops === 1) {
+ loops = 0;
+ if (state != oldState && state != stateHolder) {
+ stateHolder = state;
+ set_message(state);
+ }
+ if (saySomething == true) {
+ say(phrase);
+ }
+ }
+
+ if (amount_of_exchange_itemsOne >= exchange_at || amount_of_exchange_itemsTwo >= exchange_at_two) {
+ new_state = "exchange";
+ state = "exchange";
+ } else if (amount_of_exchange_itemsOne < 10 && state === "exchange" || amount_of_exchange_itemsTwo === 0 && state === "exchange") {
+ new_state = "walking_to_town";
+ state = "walking_to_town";
+ }
+
+ // Check if we're already upgrading
+ if (upgrade_status === true) { // && hasUpgraded === false
+ new_state = "upgrading";
+ }
+
+ if (state === "compounding" && hasCompounded === true || state === "compounding" && returnItemsToCompound() !== "undefined") {
+ new_state = "walking_to_town";
+ }
+
+ if (compound_status === true && returnItemsToCompound() != "undefined") { // && hasUpgraded === false
+ new_state = "compounding";
+ }
+
+ if (state === "compounding" && hasCompounded === true || state === "compounding" && returnItemsToCompound() !== "undefined") {
+ new_state = "walking_to_town";
+ }
+
+ if (state === "upgrading" && hasUpgraded === true && finishedUpgrading == true) {
+ new_state = "walking_to_town";
+ }
+
+ if (state === "at_town" && character.gold > gold_start && hasUpgraded == false) {
+ new_state = "upgrading";
+ state = "upgrading";
+ upgradeStatus = true;
+ return;
+ }
+
+ if (state === "at_town" && returnItemsToCompound() != null && hasCompounded === false) {
+ game_log("set it here...")
+ new_state = "compounding";
+ state = "compounding";
+ compoundStatus = true;
+ return;
+ }
+
+ // If we're not at town or doing anything else, set state walking to town
+ if (state != "at_town" && state != "upgrading" && state != "banking" && state != "merching" && state != "exchange" && state != "compounding") {
+ new_state = "walking_to_town";
+ }
+
+ if (state === "merching" && isMerchStandActive() === false) {
+ openMerchStand();
+ }
+
+ // If character inventory empty spaces are less than or equal to 39
+ // and character has upgraded - set state banking
+ if (character.esize <= bank_at_empty_slots && state != "upgrading") {
+ new_state = "banking";
+ }
+
+ if (state === "at_town" && state != "upgrading" && state != "merching" && state != "exchange") {
+ if (isMerchStandActive() === false && have_stuff_to_sell == true) {
+ moveTo(33, 49);
+ new_state = "merching";
+ state = "merching";
+ }
+ }
+
+ if (state != "merching" && isMerchStandActive()) {
+ closeMerchStand();
+ }
+
+
+ if (!isAtTown() && state === "at_town" && state != "banking" && state != "upgrading" && state != "compounding" && state != "exchange") {
+ new_state = "walking_to_town";
+ }
+
+
+ if (isAtTown() && state != "exchange" && state != "upgrading" && state != "compounding" && upgrade_status === false && state === "walking_to_town") {
+ new_state = "at_town";
+ }
+
+
+ if (state === "walking_to_town" && isInsideBank() === true) {
+ smart_move({to: "town"});
+ }
+
+
+ // If chracter has been to bank and has more than 30 empty spaces
+ // walk to town
+ if (hasBeenToBank === true && character.esize >= 25 && upgrade_status === false) {
+ new_state = "walking_to_town";
+ hasBeenToBank = false;
+ }
+
+ // If in town and not upgrading set state at town
+ if (isAtTown() && upgrade_status === false && state != "upgrading" && state != "exchange") {
+ new_state = "at_town";
+ //inTown = false;
+ }
+ if (character.gold < gold_limit && state === "upgrading" && state != "exchange") {
+ new_state = "walking_to_town";
+ }
+
+ if (upgrade_status === false && hasUpgraded === true && state === "upgrading") {
+ new_state = "walking_to_town";
+ hasUpgraded = false;
+ }
+
+ if (hasUpgraded === true) {
+ upgrade_status = false;
+ }
+ if (state != new_state) {
+ oldState = state;
+ state = new_state;
+
+ }
+
+}
+
+// Move to function
+function moveTo(x, y) {
+ if (x === character.real_x && y == character.real_y) {
+
+ } else {
+ smart_move({x: x, y: y});
+ }
+}
+
+// Exchange loop
+setInterval(function exchangeInterval() {
+ var exchangeItemTwo = return_item_quantity(exchange_item_name[1]);
+ var exchangeItemOne = return_item_quantity(exchange_item_name[0]);
+ if (isAtExchange() && state == "exchange") {
+ if (exchangeItemOne > 0) {
+ exchange(locate_item(exchange_item_name[0]));
+ }
+ if (exchangeItemTwo > 0) {
+ game_log("made it here");
+ exchange(locate_item(exchange_item_name[1]));
+ }
+ } else {
+ // game_log("changing state to walking to town ?? ")
+ new_state = "walking_to_town";
+ }
+
+}, 1000);
+
+
+// Upgrade loop here
+setInterval(function () {
+ if (parent != null && parent.socket != null && state === "upgrading" && !smart.moving && character.gold > gold_limit) {
+ upgrade();
+ compound_items();
+ if (character.gold < gold_limit) {
+ hasUpgraded = true;
+ }
+ } else if (parent != null && parent.socket != null && state === "compounding" && character.gold > 6400) {
+ compound_items();
+ if (returnItemsToCompound() === "undefined" || character.gold < 6400) {
+ hasCompounded = true;
+ compound_status = false;
+ }
+
+ }
+
+
+}, 175);
+
+
+// Upgrade function, modified to buy a specific item set at top of script.
+function upgrade() {
+
+ if (locate_item(item_name) == -1) buy(item_name, 1);
+ for (let i = 0; i < character.items.length; i++) {
+ let c = character.items[i];
+
+ if (c) {
+ var level = upgradeWhitelist[c.name];
+ if (c.level === upgradeMaxLevel) {
+ hasUpgraded = true;
+ finishedUpgrading = true;
+ //break;
+ }
+ if (level && c.level < level) {
+ let grades = get_grade(c);
+ let scrollname;
+ if (c.level < grades[0])
+ scrollname = 'scroll0';
+ else if (c.level < grades[1])
+ scrollname = 'scroll1';
+ else
+ scrollname = 'scroll2';
+ if (c.level >= grades[0]) {
+ hasUpgraded = true;
+ }
+ let [scroll_slot, scroll] = find_item(i => i.name == scrollname);
+ if (!scroll) {
+ parent.buy(scrollname);
+ return;
+ }
+
+ parent.socket.emit('upgrade', {
+ item_num: i,
+ scroll_num: scroll_slot,
+ offering_num: null,
+ clevel: c.level
+ });
+ return;
+ }
+ }
+ }
+}
+
+function returnItemsToCompound() {
+ let to_compound = character.items.reduce((collection, item, index) => {
+ if (item && combineWhitelist[item.name] != null && item.level < combineWhitelist[item.name]) {
+ let key = item.name + item.level;
+ !collection.has(key) ? collection.set(key, [item.level, item_grade(item), index]) : collection.get(key).push(index);
+ }
+ return collection;
+ }, new Map());
+
+ for (var c of to_compound.values()) {
+ for (let i = 2; i + 2 < c.length; i += 3) {
+ return [c[i], c[i + 1], c[i + 2]];
+ }
+ //game_log([c[i], c[i + 1], c[i + 2]],)
+ }
+}
+
+function compound_items() {
+ let to_compound = character.items.reduce((collection, item, index) => {
+ if (item && combineWhitelist[item.name] != null && item.level < combineWhitelist[item.name]) {
+ let key = item.name + item.level;
+ !collection.has(key) ? collection.set(key, [item.level, item_grade(item), index]) : collection.get(key).push(index);
+ }
+ return collection;
+ }, new Map());
+
+ for (var c of to_compound.values()) {
+ let scroll_name = "cscroll" + c[1];
+
+ for (let i = 2; i + 2 < c.length; i += 3) {
+ let [scroll, _] = find_item(i => i.name == scroll_name);
+ if (scroll == -1) {
+ parent.buy(scroll_name);
+ return;
+ }
+ parent.socket.emit('compound', {
+ items: [c[i], c[i + 1], c[i + 2]],
+ scroll_num: scroll,
+ offering_num: null,
+ clevel: c[0]
+ });
+ return;
+ }
+ }
+}
+
+function get_grade(item) {
+ return parent.G.items[item.name].grades;
+}
+
+// Returns the item slot and the item given the slot to start from and a filter.
+function find_item(filter) {
+ for (let i = 0; i < character.items.length; i++) {
+ let item = character.items[i];
+
+ if (item && filter(item))
+ return [i, character.items[i]];
+ }
+
+ return [-1, null];
+}
+
+// Locate items by name
+function locate_item(name) {
+ for (var i = 0; i < 42; i++) {
+ if (character.items[i] && character.items[i].name == name) return i;
+ }
+ return -1;
+}
+
+// Returns an items quantity
+function return_item_quantity(item) {
+ idx = locate_item(item);
+ if (idx != -1) {
+ return character.items[idx].q;
+ } else {
+ return 0;
+ }
+}
+
+// Check is inside bank by map
+function isInsideBank() {
+ //!character.bank
+ return character.map === "bank";
+}
+
+// Check is inside resting coord(THESE MIGHT NEED TO BE EXPANDED) range in town.
+function isAtTown() {
+ if (character.real_x >= -20 && character.real_y < 20 && character.real_x <= 20 && character.real_y >= -20) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Check if in exchange area
+function isAtExchange() {
+ if (character.real_x >= -50 && character.real_y < -300 && character.real_x <= 50 && character.real_y >= -500) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Check if in black smith area
+function isAtBlacksmith() {
+ if (character.real_x >= -200 && character.real_x <= -100 && character.real_y >= -200 && character.real_y <= -100) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Go to bank
+function goToBank() {
+ if (state != "at_town" && state != "upgrading" && state != "walking_to_town") {
+ smart_move({to: "bank"});
+ if (isInsideBank()) {
+ depositItems();
+ hasBeenToBank = true;
+ }
+ }
+}
+
+// Deposit all items to bank
+function depositItems() {
+ if (character.esize === 42) return; //empty inventory
+ for (item in character.items) {
+ if (item == 0) continue;
+ if (!character.items[item]) continue;
+ bank_store(item);
+ }
+}
+
+// check is merch stand is active
+function isMerchStandActive() {
+ return character.stand !== false;
+}
+
+// Open merch stand
+function openMerchStand() {
+ if (!isMerchStandActive()) {
+ parent.open_merchant(0);
+ }
+}
+
+// Close merch stand
+function closeMerchStand() {
+ if (isMerchStandActive()) {
+ parent.close_merchant(0);
+ }
+}
+
+// toggle merch stand (not used yet)
+function toggleMerchStand() {
+ if (isMerchStandActive()) {
+ parent.close_merchant(0);
+ } else {
+ parent.open_merchant(0);
+ }
+}
\ No newline at end of file
diff --git a/Routines/Buy.js b/Routines/Buy.js
new file mode 100644
index 0000000..e69de29
diff --git a/Routines/Sell.js b/Routines/Sell.js
new file mode 100644
index 0000000..e69de29
diff --git a/Routines/Upgrade.js b/Routines/Upgrade.js
new file mode 100644
index 0000000..e69de29
diff --git a/Sandbox.js b/Sandbox.js
new file mode 100644
index 0000000..53bfa09
--- /dev/null
+++ b/Sandbox.js
@@ -0,0 +1,557 @@
+// Author: deez @discord, IGN: shidded
+// credits to spadarfaar and others for large portions of code
+
+game_log("-----------------------")
+game_log("MERCHANT SCRIPT STARTED");
+game_log("-----------------------")
+//load_code(12); // party script
+
+// Merchant stand variables
+var have_stuff_to_sell = false; // Doesnt merchant have anything to sell?
+var saySomething = false; // Should merchant say something?
+var phrase = "Boop boop!"; // What merchant should say
+
+// Exchange variables
+var exchange_item_name = ["candypop", "gem0"];
+var exchange_at = 10;
+var exchange_at_two = 2;
+
+// Upgrade variables
+var item_name = "bow";
+var upgradeMaxLevel = 9; //Max level it will stop upgrading items at if enabled
+var gold_start = 1000000; // start upgrading at this much gold
+var gold_limit = 50000; // stop upgrading at this much gold
+
+// Bank variable
+var bank_at_empty_slots = 1; // Bank at this many empty slots
+
+// Various check variables
+var hasBeenToBank = false;
+var inTown = false;
+var upgrade_status = false;
+var compound_status = false;
+var hasUpgraded = false;
+var hasCompounded = false;
+var finishedUpgrading = false;
+
+// Define our state variables
+var state = "walking_to_town";
+var new_state = "";
+
+// Credits to spadarfaar for upgrade functions, this is basically a C&P of his script
+var upgradeWhitelist =
+ {
+ //ItemName, Max Level
+ pyjamas: upgradeMaxLevel,
+ bunnyears: upgradeMaxLevel,
+ carrotsword: upgradeMaxLevel,
+ firestaff: 7,
+ fireblade: 7,
+ staff: upgradeMaxLevel,
+ bow: upgradeMaxLevel,
+ sshield: 7,
+ shield: 7,
+ gloves: 7,
+ shoes: 7,
+ coat: 7,
+ helmet: 7,
+ pants: 7,
+ gloves1: 7,
+ coat1: 7,
+ helmet1: 7,
+ pants1: 7,
+ shoes1: 7,
+ harbringer: 5,
+ oozingterror: 5,
+ bataxe: 7,
+ spear: 7,
+ xmaspants: 7,
+ xmassweater: 7,
+ xmashat: 7,
+ xmasshoes: 7,
+ mittens: 7,
+ ornamentstaff: 7,
+ candycanesword: 7,
+ warmscarf: 7,
+ t2bow: 7,
+ pmace: 7,
+ basher: 7,
+ harmor: 5,
+ hgloves: 5,
+ wingedboots: 7
+ };
+
+var combineWhitelist =
+ {
+ //ItemName, Max Level
+ wbook0: 3,
+ lostearring: 2,
+ hpamulet: 3,
+ strearring: 3,
+ intearring: 3,
+ dexearring: 2,
+ hpbelt: 3,
+ ringsj: 3,
+ strring: 3,
+ intring: 3,
+ dexring: 2,
+ vitring: 3,
+ dexamulet: 2,
+ intamulet: 3,
+ stramulet: 3,
+ vitearring: 3,
+ dexbelt: 2,
+ intbelt: 3,
+ strbelt: 3
+ }
+
+
+// This function calls our state controller every 3 seconds.
+// Our state controller returns a state then based on that state
+// We preform a function such as banking or upgrading
+setInterval(function () {
+
+ //Determine what state we should be in.
+ state_controller();
+
+ //Switch statement decides what we should do based on the value of 'state'
+ switch (state) {
+ case "upgrading":
+ upgrade_status = true;
+ if (!isAtBlacksmith()) {
+ moveTo(-190, -140); // blacksmith coords
+ }
+ break;
+
+ case "compounding":
+ compound_status = true;
+ if (!isAtBlacksmith()) {
+ moveTo(-190, -140); // blacksmith coords
+ }
+ break;
+
+
+ case "walking_to_town":
+ if (!isInsideBank()) {
+ smart_move({to: "town"});
+ } else {
+ smart_move({to: "town"});
+ }
+ break;
+
+ case "banking":
+ goToBank();
+ break;
+
+ case "merching":
+ break;
+
+ case "at_town":
+ break;
+
+ case "exchange":
+ if (!isAtExchange()) {
+ moveTo(-20, -460);
+ }
+ break;
+
+ }
+
+}, 10000);//Execute every 10 seconds?
+
+var loops = 0;
+var oldState = ""; // for state output
+var stateHolder = "";
+
+// This is where state values are returned based on conditionals
+function state_controller() {
+ var amount_of_exchange_itemsOne = return_item_quantity(exchange_item_name[0]);
+ var amount_of_exchange_itemsTwo = return_item_quantity(exchange_item_name[1]);
+ if (loops < 51) {
+ loops += 1;
+ }
+ if (loops === 1) {
+ loops = 0;
+ if (state != oldState && state != stateHolder) {
+ stateHolder = state;
+ set_message(state);
+ }
+ if (saySomething == true) {
+ say(phrase);
+ }
+ }
+
+ if (amount_of_exchange_itemsOne >= exchange_at || amount_of_exchange_itemsTwo >= exchange_at_two) {
+ new_state = "exchange";
+ state = "exchange";
+ } else if (amount_of_exchange_itemsOne < 10 && state === "exchange" || amount_of_exchange_itemsTwo === 0 && state === "exchange") {
+ new_state = "walking_to_town";
+ state = "walking_to_town";
+ }
+
+ // Check if we're already upgrading
+ if (upgrade_status === true) { // && hasUpgraded === false
+ new_state = "upgrading";
+ }
+
+ if (state === "compounding" && hasCompounded === true || state === "compounding" && returnItemsToCompound() !== "undefined") {
+ new_state = "walking_to_town";
+ }
+
+ if (compound_status === true && returnItemsToCompound() != "undefined") { // && hasUpgraded === false
+ new_state = "compounding";
+ }
+
+ if (state === "compounding" && hasCompounded === true || state === "compounding" && returnItemsToCompound() !== "undefined") {
+ new_state = "walking_to_town";
+ }
+
+ if (state === "upgrading" && hasUpgraded === true && finishedUpgrading == true) {
+ new_state = "walking_to_town";
+ }
+
+ if (state === "at_town" && character.gold > gold_start && hasUpgraded == false) {
+ new_state = "upgrading";
+ state = "upgrading";
+ upgradeStatus = true;
+ return;
+ }
+
+ if (state === "at_town" && returnItemsToCompound() != null && hasCompounded === false) {
+ game_log("set it here...")
+ new_state = "compounding";
+ state = "compounding";
+ compoundStatus = true;
+ return;
+ }
+
+ // If we're not at town or doing anything else, set state walking to town
+ if (state != "at_town" && state != "upgrading" && state != "banking" && state != "merching" && state != "exchange" && state != "compounding") {
+ new_state = "walking_to_town";
+ }
+
+ if (state === "merching" && isMerchStandActive() === false) {
+ openMerchStand();
+ }
+
+ // If character inventory empty spaces are less than or equal to 39
+ // and character has upgraded - set state banking
+ if (character.esize <= bank_at_empty_slots && state != "upgrading") {
+ new_state = "banking";
+ }
+
+ if (state === "at_town" && state != "upgrading" && state != "merching" && state != "exchange") {
+ if (isMerchStandActive() === false && have_stuff_to_sell == true) {
+ moveTo(33, 49);
+ new_state = "merching";
+ state = "merching";
+ }
+ }
+
+ if (state != "merching" && isMerchStandActive()) {
+ closeMerchStand();
+ }
+
+
+ if (!isAtTown() && state === "at_town" && state != "banking" && state != "upgrading" && state != "compounding" && state != "exchange") {
+ new_state = "walking_to_town";
+ }
+
+
+ if (isAtTown() && state != "exchange" && state != "upgrading" && state != "compounding" && upgrade_status === false && state === "walking_to_town") {
+ new_state = "at_town";
+ }
+
+
+ if (state === "walking_to_town" && isInsideBank() === true) {
+ smart_move({to: "town"});
+ }
+
+
+ // If chracter has been to bank and has more than 30 empty spaces
+ // walk to town
+ if (hasBeenToBank === true && character.esize >= 25 && upgrade_status === false) {
+ new_state = "walking_to_town";
+ hasBeenToBank = false;
+ }
+
+ // If in town and not upgrading set state at town
+ if (isAtTown() && upgrade_status === false && state != "upgrading" && state != "exchange") {
+ new_state = "at_town";
+ //inTown = false;
+ }
+ if (character.gold < gold_limit && state === "upgrading" && state != "exchange") {
+ new_state = "walking_to_town";
+ }
+
+ if (upgrade_status === false && hasUpgraded === true && state === "upgrading") {
+ new_state = "walking_to_town";
+ hasUpgraded = false;
+ }
+
+ if (hasUpgraded === true) {
+ upgrade_status = false;
+ }
+ if (state != new_state) {
+ oldState = state;
+ state = new_state;
+
+ }
+
+}
+
+// Move to function
+function moveTo(x, y) {
+ if (x === character.real_x && y == character.real_y) {
+
+ } else {
+ smart_move({x: x, y: y});
+ }
+}
+
+// Exchange loop
+setInterval(function exchangeInterval() {
+ var exchangeItemTwo = return_item_quantity(exchange_item_name[1]);
+ var exchangeItemOne = return_item_quantity(exchange_item_name[0]);
+ if (isAtExchange() && state == "exchange") {
+ if (exchangeItemOne > 0) {
+ exchange(locate_item(exchange_item_name[0]));
+ }
+ if (exchangeItemTwo > 0) {
+ game_log("made it here");
+ exchange(locate_item(exchange_item_name[1]));
+ }
+ } else {
+ // game_log("changing state to walking to town ?? ")
+ new_state = "walking_to_town";
+ }
+
+}, 1000);
+
+
+// Upgrade loop here
+setInterval(function () {
+ if (parent != null && parent.socket != null && state === "upgrading" && !smart.moving && character.gold > gold_limit) {
+ upgrade();
+ compound_items();
+ if (character.gold < gold_limit) {
+ hasUpgraded = true;
+ }
+ } else if (parent != null && parent.socket != null && state === "compounding" && character.gold > 6400) {
+ compound_items();
+ if (returnItemsToCompound() === "undefined" || character.gold < 6400) {
+ hasCompounded = true;
+ compound_status = false;
+ }
+
+ }
+
+
+}, 175);
+
+
+// Upgrade function, modified to buy a specific item set at top of script.
+function upgrade() {
+
+ if (locate_item(item_name) == -1) buy(item_name, 1);
+ for (let i = 0; i < character.items.length; i++) {
+ let c = character.items[i];
+
+ if (c) {
+ var level = upgradeWhitelist[c.name];
+ if (c.level === upgradeMaxLevel) {
+ hasUpgraded = true;
+ finishedUpgrading = true;
+ //break;
+ }
+ if (level && c.level < level) {
+ let grades = get_grade(c);
+ let scrollname;
+ if (c.level < grades[0])
+ scrollname = 'scroll0';
+ else if (c.level < grades[1])
+ scrollname = 'scroll1';
+ else
+ scrollname = 'scroll2';
+ if (c.level >= grades[0]) {
+ hasUpgraded = true;
+ }
+ let [scroll_slot, scroll] = find_item(i => i.name == scrollname);
+ if (!scroll) {
+ parent.buy(scrollname);
+ return;
+ }
+
+ parent.socket.emit('upgrade', {
+ item_num: i,
+ scroll_num: scroll_slot,
+ offering_num: null,
+ clevel: c.level
+ });
+ return;
+ }
+ }
+ }
+}
+
+function returnItemsToCompound() {
+ let to_compound = character.items.reduce((collection, item, index) => {
+ if (item && combineWhitelist[item.name] != null && item.level < combineWhitelist[item.name]) {
+ let key = item.name + item.level;
+ !collection.has(key) ? collection.set(key, [item.level, item_grade(item), index]) : collection.get(key).push(index);
+ }
+ return collection;
+ }, new Map());
+
+ for (var c of to_compound.values()) {
+ for (let i = 2; i + 2 < c.length; i += 3) {
+ return [c[i], c[i + 1], c[i + 2]];
+ }
+ //game_log([c[i], c[i + 1], c[i + 2]],)
+ }
+}
+
+function compound_items() {
+ let to_compound = character.items.reduce((collection, item, index) => {
+ if (item && combineWhitelist[item.name] != null && item.level < combineWhitelist[item.name]) {
+ let key = item.name + item.level;
+ !collection.has(key) ? collection.set(key, [item.level, item_grade(item), index]) : collection.get(key).push(index);
+ }
+ return collection;
+ }, new Map());
+
+ for (var c of to_compound.values()) {
+ let scroll_name = "cscroll" + c[1];
+
+ for (let i = 2; i + 2 < c.length; i += 3) {
+ let [scroll, _] = find_item(i => i.name == scroll_name);
+ if (scroll == -1) {
+ parent.buy(scroll_name);
+ return;
+ }
+ parent.socket.emit('compound', {
+ items: [c[i], c[i + 1], c[i + 2]],
+ scroll_num: scroll,
+ offering_num: null,
+ clevel: c[0]
+ });
+ return;
+ }
+ }
+}
+
+function get_grade(item) {
+ return parent.G.items[item.name].grades;
+}
+
+// Returns the item slot and the item given the slot to start from and a filter.
+function find_item(filter) {
+ for (let i = 0; i < character.items.length; i++) {
+ let item = character.items[i];
+
+ if (item && filter(item))
+ return [i, character.items[i]];
+ }
+
+ return [-1, null];
+}
+
+// Locate items by name
+function locate_item(name) {
+ for (var i = 0; i < 42; i++) {
+ if (character.items[i] && character.items[i].name == name) return i;
+ }
+ return -1;
+}
+
+// Returns an items quantity
+function return_item_quantity(item) {
+ idx = locate_item(item);
+ if (idx != -1) {
+ return character.items[idx].q;
+ } else {
+ return 0;
+ }
+}
+
+// Check is inside bank by map
+function isInsideBank() {
+ //!character.bank
+ return character.map === "bank";
+}
+
+// Check is inside resting coord(THESE MIGHT NEED TO BE EXPANDED) range in town.
+function isAtTown() {
+ if (character.real_x >= -20 && character.real_y < 20 && character.real_x <= 20 && character.real_y >= -20) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Check if in exchange area
+function isAtExchange() {
+ if (character.real_x >= -50 && character.real_y < -300 && character.real_x <= 50 && character.real_y >= -500) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Check if in black smith area
+function isAtBlacksmith() {
+ if (character.real_x >= -200 && character.real_x <= -100 && character.real_y >= -200 && character.real_y <= -100) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Go to bank
+function goToBank() {
+ if (state != "at_town" && state != "upgrading" && state != "walking_to_town") {
+ smart_move({to: "bank"});
+ if (isInsideBank()) {
+ depositItems();
+ hasBeenToBank = true;
+ }
+ }
+}
+
+// Deposit all items to bank
+function depositItems() {
+ if (character.esize === 42) return; //empty inventory
+ for (item in character.items) {
+ if (item == 0) continue;
+ if (!character.items[item]) continue;
+ bank_store(item);
+ }
+}
+
+// check is merch stand is active
+function isMerchStandActive() {
+ return character.stand !== false;
+}
+
+// Open merch stand
+function openMerchStand() {
+ if (!isMerchStandActive()) {
+ parent.open_merchant(0);
+ }
+}
+
+// Close merch stand
+function closeMerchStand() {
+ if (isMerchStandActive()) {
+ parent.close_merchant(0);
+ }
+}
+
+// toggle merch stand (not used yet)
+function toggleMerchStand() {
+ if (isMerchStandActive()) {
+ parent.close_merchant(0);
+ } else {
+ parent.open_merchant(0);
+ }
+}
\ No newline at end of file
diff --git a/Upgrade.js b/Upgrade.js
new file mode 100644
index 0000000..9dfa1ed
--- /dev/null
+++ b/Upgrade.js
@@ -0,0 +1,39 @@
+var item_slot = 3; //Inventory slot of item to be upgraded
+
+var scroll_slot = 1; //Inventory slot of 1000g scroll (T1)
+
+var scroll2_slot = 2; //Inventory slot of 40000g scroll (T2)
+
+var max_item_level = 9; //Max level to be upgraded to
+
+var item_to_upgrade = "bow" //Name of item to be upgraded
+setInterval(function () {
+//Buy an item_to_upgrade if there is nothing in item_slot
+ if (!character.items[item_slot])
+ parent.buy(item_to_upgrade, 1);
+
+//If scroll_slot is empty buy 200 more T1 scrolls
+ if (!character.items[scroll_slot])
+ parent.buy("scroll0", 200);
+
+//If max_item_level is above 7 this will buy a T2 scroll if scroll2_slot is empty
+ if (max_item_level > 7) {
+ if (!character.items[scroll2_slot])
+ parent.buy("scroll1", 1);
+ }
+
+
+//Upgrades items until the max_item_level is reached
+ if (max_item_level <= 7) {
+ if (character.items[item_slot].level < max_item_level) {
+ upgrade(item_slot, scroll_slot); //upgrade using T1 scroll
+ }
+ } else if (max_item_level > 7) {
+ //If the item is below level 7 upgrade using T1 scroll, if the item is level 7 or higher upgrade using T2 scroll
+ if (character.items[item_slot].level <= 6) {
+ upgrade(item_slot, scroll_slot);
+ } else if (character.items[item_slot].level < max_item_level) {
+ upgrade(item_slot, scroll2_slot)
+ }
+ }
+}, 1000 / 2);
\ No newline at end of file