In-game Functions: Difference between revisions

From Melvor Idle
m (Replace all getObjectByID with getObjectSafe to prevent entering invalid IDs)
 
(42 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{V|1.1}}
{{UserContentVersion|1.3}}
{| class="warningbox"
| '''Various sections of this page are incomplete or reference pages which have not been updated. Due to this, certain functions may not have all the information easily available on the wiki at this time.'''
|}
In-game functions are responsible for most things in the game. It is possible to interact directly with them through the console. This can be used to add items, levels, GP and more. These functions can be executed though the console. To access the console open Developer Tools (usually by pressing F12) in your browser and navigate to the console. Then, simply paste the code in the input field and press enter. Most functions will require you to fill out variables in the code before executing them. Note that all code is case sensitive.
In-game functions are responsible for most things in the game. It is possible to interact directly with them through the console. This can be used to add items, levels, GP and more. These functions can be executed though the console. To access the console open Developer Tools (usually by pressing F12) in your browser and navigate to the console. Then, simply paste the code in the input field and press enter. Most functions will require you to fill out variables in the code before executing them. Note that all code is case sensitive.


'''Disclaimer:''' Blindly adding items and experience will most likely take away game enjoyment. It is highly encouraged only to use this to either test things or recoup lost items/progress due to lost saves.
'''Disclaimer:''' Blindly adding items and experience will most likely take away game enjoyment. It is highly encouraged only to use this to either test things or recoup lost items/progress due to lost saves.


{| class="warningbox"
{{Disclaimer|You are playing around with the code of the game, as such if you make mistakes it is possible that could corrupt your game. It is highly recommended to '''BACKUP YOUR SAVE''' before running any in-game functions.}}
| You are playing around with the code of the game if you make mistakes, it is possible that could corrupt your game. It is highly recommended to '''BACKUP YOUR SAVE''' before running any in-game functions.
 
|}
<div class="toclimit-ex">__TOC__</div>
 
==Using In-game Functions==
Players can use the [https://mod.io/g/melvoridle/m/devconsole dev.Console mod] to execute these functions within the Steam, Epic, Android, and iOS versions of Melvor Idle.


==Using In-game Functions On Steam==
On Web, Steam, and Epic, the console can be opened with F12. If using Steam or Epic, you must [[Mod_Creation/Enabling_DevTools_for_the_Steam_and_Epic_Clients|enable the dev console first]] before you are able to open it.
Players should refer to the [[Scripting and Extensions Instructions#Steam Console and Scripts|Scripting and Extensions Instructions]] page for a step-by-step guide on using these functions with the Steam version of Melvor Idle.


== Add Item to Bank ==
== Add Item to Bank ==
The addItemByID function can be used to add any item in the game to the bank.
The <code>addItemByID</code> function can be used to add any item in the game to the bank.
<nowiki>game.bank.addItemByID(itemID, quantity, logLost, found, ignoreSpace)</nowiki>
<syntaxhighlight lang="js">game.bank.addItemByID(itemID, quantity, logLost, found, ignoreSpace, notify)</syntaxhighlight>


=== Attributes ===
=== Attributes ===
Line 23: Line 22:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| itemID || string || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]
| itemID || string || No || || The ID of the item.
 
For a complete list of items, see: [[Table of Items]]. Item IDs are on their respective wiki page.
 
To search for a specific item by name, the following can be used. Replace <code>REPLACEME</code> with the full or partial name of the item (case insensitive).
<syntaxhighlight lang="js">
let searchTerm = 'REPLACEME';
console.log(game.items.filter(x => x.name.toLowerCase().includes(searchTerm.toLowerCase())).map((a) => a.id + ' - ' + a.name).join('\n'))
</syntaxhighlight>
|-
|-
| quantity || int || No || || Quantity of item to add. Will remove items from the bank if a negative value is specified
| quantity || int || No || || Quantity of item to add.
|-
|-
| logLost || boolean || Yes || false || If <code>true</code>, items that did not fit into the bank will be logged as lost
| logLost || boolean || Yes || false || If <code>true</code>, items that did not fit into the bank will be logged as lost
|-
|-
| found || boolean || Yes || false || Determines if it will show in item completion log
| found || boolean || Yes || false || Determines if items added by this function will be included within the "Times Found" statistic for that item within the completion log. Therefore, unless this parameter is set to <code>true</code>, any items added in this way will not contribute towards the player's item completion percentage.
<br/><br/>{{Disclaimer|'''Note:''' When adding {{ItemIcon|Bank Slot Token|Bank Slot Tokens}}, it is suggested that this parameter is set to <code>true</code>, otherwise this may cause issues with the way the game calculates the amount of bank space a player has.}}
|-
|-
| ignoreSpace || boolean || Yes || false || If <code>true</code>, the item will be added to the bank even if the bank is already full
| ignoreSpace || boolean || Yes || false || If <code>true</code>, the item will be added to the bank even if the bank is already full
|-
| notify || boolean || Yes || true || If <code>true</code>, there will be a notification that the item was added along with the quantity.
|}
|}


=== Examples ===
=== Examples ===
<nowiki>game.bank.addItemByID("melvorD:Oak_Logs", 10, true, true, false);</nowiki>
<syntaxhighlight lang="js">game.bank.addItemByID("melvorD:Oak_Logs", 10, true, true, false);</syntaxhighlight>
The above code will result in attempting to add 10 Oak Logs to the Bank. If they do not fit, 10 will be added to the # of Oak Logs lost on the item's stats. Additionally, Oak Logs will be marked as discovered in the Completion Log.
The above code will result in attempting to add 10 {{ItemIcon|Oak Logs}} to the Bank. If they do not fit, 10 will be added to the # of Oak Logs lost on the item's stats. Additionally, Oak Logs will be marked as discovered in the Completion Log.
<syntaxhighlight lang="js">game.items.forEach((item) => game.bank.addItem(item, 1000000, false, true, true, false));</syntaxhighlight>
The above code will add 1,000,000 of every item in the game. The items will be forced into the bank even if you do not have room and there will be no notifications upon adding the items.


== Remove Item from Bank ==
== Remove Item from Bank ==
The removeItemQuantity function can be used to remove any item from the bank
The <code>removeItemQuantityByID</code> function can be used to remove any item from the bank
<nowiki>game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</nowiki>
<syntaxhighlight lang="js">game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</syntaxhighlight>
 
Note that if an item's quantity is in an invalid state, such as <syntaxhighlight lang="js" inline>NaN</syntaxhighlight> or <syntaxhighlight lang="js" inline>Infinity</syntaxhighlight>, then this function will not be able to remove that item from the bank. For any such items, use the below snippet instead:
{{SpoilerBox
|color=default
|title=Code
|text=First, enter the below into the console:
<syntaxhighlight lang="js">function removeItemByID(itemID) {
const item = game.items.getObjectSafe(itemID);
const bankItem = game.bank.items.get(item);
if (bankItem === undefined)
throw new Error(
`Tried to remove quantity from bank, but item is not in bank.`
);
bankItem.quantity = 1;
game.bank.removeItemQuantity(item, 1, true);
}</syntaxhighlight>
After this, invoke the newly-created function with the appropriate item ID to remove items from the bank. For example: <syntaxhighlight lang="js" inline>removeItemByID('melvorD:Oak_Logs');</syntaxhighlight>
}}


=== Attributes ===
=== Attributes ===
Line 47: Line 77:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| itemID || string || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]*Not currently updated
| itemID || string || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]
|-
|-
| quantity || int || No || || The number of items to remove.
| quantity || int || No || || The number of items to remove.
Line 55: Line 85:


=== Examples ===
=== Examples ===
<nowiki>game.bank.removeItemQuantityByID("melvorD:Oak_Logs", 10);</nowiki>
<syntaxhighlight lang="js">game.bank.removeItemQuantityByID('melvorD:Oak_Logs', 10);</syntaxhighlight>
The above code will result in 10 of item ID "melvorD:Oak_Logs" being removed from the bank.
The above code will result in 10 {{ItemIcon|Oak Logs}} being removed from the bank.
 
== Adjust Shop Purchases ==
The below script will add a shop purchase into <code>upgradesPurchased</code> which is where all purchases are stored. Alternatively, <code>game.shop.buyItemOnClick(purchase, true);</code> can be used however using this function will remove the costs of the purchase as well.


== Add GP ==
The gp.add function can be used to add [[Currency#Gold Pieces|GP]] to a player.
<nowiki>game.gp.add(amount)</nowiki>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
| purchaseID || string || No || The ID of the Purchase. A complete list of purchase IDs can be generated with: <syntaxhighlight lang="js" inline>console.log(game.shop.purchases.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</syntaxhighlight>
 
To search for a specific purchase by name, the following can be used. Replace <code>REPLACEME</code> with the full or partial name of the purchase (case insensitive).
<syntaxhighlight lang="js">
let searchTerm = 'REPLACEME';
console.log(game.shop.purchases.filter(x => x.name.toLowerCase().includes(searchTerm.toLowerCase())).map((a) => a.id + ' - ' + a.name).join('\n'))
</syntaxhighlight>
|-
|-
| amount|| int || No || || The quantity of GP to add
| quantity || int || No || The number of purchases to buy
|}
|}
=== Examples ===
<nowiki>game.gp.add(1);</nowiki>
The above code will add 1 gp to the player.


== Remove GP ==
==== Examples ====
The gp.remove function can be used to remove [[Currency#Gold Pieces|GP]] from a player. If the amount specified is greater than the amount the player currently has, then GP will go into the negatives.
<syntaxhighlight lang="js">
<nowiki>game.gp.remove(amount)</nowiki>
// Settings //
=== Attributes ===
let purchase = game.shop.purchases.getObjectSafe('melvorD:Extra_Bank_Slot');
let quantity = 100;
// End of Settings //
game.shop.upgradesPurchased.set(purchase, (game.shop.upgradesPurchased.get(purchase) || 0) + quantity);
game.shop.computeProvidedStats();
shopMenu.tabs.get(purchase.category).menu.updateItemSelection();
game.shop.renderQueue.costs = true;
</syntaxhighlight>
The above will add 100 Bank Slot purchases then do the necessary render.
 
== Adjust Currencies ==
All [[Currency|Currencies]] within the game, being {{GP}} [[GP]], {{AP}} [[Abyssal Pieces]] (AP), {{SC}} [[Slayer Coins]] (SC), {{ASC}} [[Abyssal Slayer Coins]] (ASC), and {{RC}} [[Raid Coins]] (RC) can be adjusted using the same set of functions:
* To adjust GP, use <syntaxhighlight lang="js" inline>game.gp</syntaxhighlight>
* To adjust AP, use <syntaxhighlight lang="js" inline>game.abyssalPieces</syntaxhighlight>
* To adjust SC, use <syntaxhighlight lang="js" inline>game.slayerCoins</syntaxhighlight>
* To adjust ASC, use <syntaxhighlight lang="js" inline>game.abyssalSlayerCoins</syntaxhighlight>
* To adjust RC, use <syntaxhighlight lang="js" inline>game.raidCoins</syntaxhighlight>
 
The following functions are used to add, remove, and set currencies. <code>set</code> may be of particular use to players who have inadvertently found their currency balance is set to an invalid value such as <code>NaN</code>.
<syntaxhighlight lang="js">
game.<currency>.add(amount);
game.<currency>.remove(amount);
game.<currency>.set(amount);
</syntaxhighlight>
 
==== Attributes ====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| amount|| int || No || || The quantity of GP to remove
| amount || int || No || The amount to adjust the specified currency's balance by
|}
|}
=== Examples ===
<nowiki>game.gp.remove(1);</nowiki>
The above code will remove 1 GP from the player.


== Add Slayer Coins ==
==== Examples ====
The slayerCoins.add function can be used to add slayer coins to a player.
<syntaxhighlight lang="js">
<nowiki>game.slayerCoins.add(amount)</nowiki>
game.gp.add(1000);
game.abyssalSlayerCoins.remove(2500);
game.raidCoins.set(10000);
</syntaxhighlight>
The first function will add {{GP|1000}}, the second function will remove {{ASC|2500}} and lastly, the third function will set the balance of {{RC}} [[Raid Coins]] to 10,000.
 
== Adjust Prayer Points or Soul Points ==
The <code>addPrayerPoints</code> and <code>addSoulPoints</code> functions can be used to add prayer points or soul points to a player.
<syntaxhighlight lang="js">
game.combat.player.addPrayerPoints(amount);
game.combat.player.addSoulPoints(amount);
</syntaxhighlight>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| amount || int || No || || The quantity of slayer coins to add.
| amount || int || No || The quantity of prayer or soul points to add. A negative value will remove points.
|}
|}
=== Examples ===
=== Examples ===
<nowiki>game.slayerCoins.add(1);</nowiki>
<syntaxhighlight lang="js">
The above code will add 1 slayer coin to the player.
game.combat.player.addPrayerPoints(1);
game.combat.player.addSoulPoints(-50);
</syntaxhighlight>
The first line will add 1 prayer point to the player while the second will remove 50 soul points.


== Remove Slayer Coins ==
== Adjust XP and Abyssal XP ==
The slayerCoins.remove function can be used to remove slayer coins from a player. If the amount specified is greater than the amount the player currently has, then slayer coins will go into the negatives.
The <code>addXP</code> and <code>addAbyssalXP</code> functions can be used to add or remove experience and abyssal experience from any skill. The <code>setXP</code> and <code>setAbyssalXP</code> can be used to set the new experience or abyssal experience value.
<nowiki>game.slayerCoins.remove(amount)</nowiki>
<syntaxhighlight lang="js">
game.<skill>.addXP(xp);
game.<skill>.addAbyssalXP(xp);
game.<skill>.setXP(xp);
game.<skill>.setAbyssalXP(xp);
</syntaxhighlight>
where <code><skill></code> is the lowercase name of the skill you are adding experience to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| amount || int || No || || The quantity of slayer coins to remove
| xp || int || No || Amount of experience to add. A negative number will remove experience. When removing XP, it's best to use the Set function as these will also visually update your current level if the removed experience results in a lower level.
|}
|}
=== Examples ===
=== Examples ===
<nowiki>game.slayerCoins.remove(1);</nowiki>
<syntaxhighlight lang="js">
The above code will remove 1 slayer coin from the player.
game.thieving.addXP(1000);
game.astrology.setAbyssalXP(game.astrology.abyssalXP - 700); // For XP, use game.astrology.xp with the addXP function
game.attack.setXP(exp.levelToXP(120) + 1); // For Abyssal XP, use abyssalExp.levelToXP with the setAbyssalXP function
</syntaxhighlight>
The first line will result in 1,000 experience being added to {{Skill|Thieving}}. The second line will remove 700 abyssal xp from Astrology. The third line will set Attack's level to 120.


== Add Raid Coins==
== Adjust Mastery XP ==
The raidCoins.add function can be used to add [[Currency#Raid Coins|raid coins]] to a player.
The <code>addMasteryXP</code> function can be used to add experience to any specific {{Icon|Mastery}} in a skill.
<nowiki>game.raidCoins.add(amount)</nowiki>
<syntaxhighlight lang="js">game.<skill>.addMasteryXP(masteryAction, xp)</syntaxhighlight>
where <code><skill></code> is the lowercase name of the skill you are adding mastery experience to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
| masteryAction || object || No || The action to add Mastery XP to. Obtained with <syntaxhighlight lang="js" inline>game.<skill>.actions.getObjectSafe(id);</syntaxhighlight>.
 
A list of actions IDs can be generated with <syntaxhighlight lang="js" inline>console.log(game.<skill>.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'));</syntaxhighlight>
 
In both of the provided functions, <code><skill></code> must be replaced with the name of the skill (all lowercase).
|-
|-
| amount || int || Yes || 0 || The quantity of raid coins to be added.
| xp || int || Yes || Amount of experience to add. A negative value will remove mastery xp.
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>game.raidCoins.add(1);</nowiki>
<syntaxhighlight lang="js">
The above will add 1 raid coin to the player.
  game.farming.addMasteryXP(game.farming.actions.getObjectSafe('melvorD:Carrot'), 300);
game.farming.addMasteryXP(game.farming.actions.getObjectSafe('melvorTotH:Starfruit'), -500);
</syntaxhighlight>
The first line will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for {{ItemIcon|Carrot Seeds}} whereas the second line will remove 500 Mastery XP from {{ItemIcon|Starfruit}}.
 
<syntaxhighlight lang="js">game.masterySkills.forEach(skill => skill.actions.forEach(action => skill.addMasteryXP(action, 5000)));</syntaxhighlight>
The above code will result in 5,000 {{Icon|Mastery}} XP being added to every action within every skill with a mastery action.


== Remove Raid Coins==
== Adjust Mastery Pool XP ==
The raidCoins.remove function can be used to remove [[Currency#Raid Coins|raid coins]] from a player.
The <code>addMasteryPoolXP</code> function can be used to add [[Mastery#The_Mastery_Pool|Mastery Pool]] experience to a skill
<nowiki>game.raidCoins.remove(amount)</nowiki>
<syntaxhighlight lang="js">game.<skill>.addMasteryPoolXP(realm, xp)</syntaxhighlight>
where <code><skill></code> is the lowercase name of the skill you are adding mastery experience to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
| realm || object || No || The realm to add the Mastery Pool XP to. Obtained with <code>game.realms.getObjectSafe(realmID)</code>.
 
A list of realm IDs can be obtained by entering the following into the console: <code>console.log(game.realms.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</code>.
|-
|-
| amount || int || Yes || 0 || The quantity of raid coins to be removed.
| xp || int || Yes || Amount of experience to add. A negative value will remove mastery pool xp.
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>game.raidCoins.remvoe(1);</nowiki>
<syntaxhighlight lang="js">
The above will remove 1 raid coin from the player.
game.woodcutting.addMasteryPoolXP(game.realms.getObjectSafe('melvorD:Melvor'), 600);
game.woodcutting.addMasteryPoolXP(game.realms.getObjectSafe('melvorItA:Abyssal'), -400);
  </syntaxhighlight>
The first line will result in 600 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to {{Skill|Woodcutting}} in the Melvor Realm whereas the second line will remove 400 mastery pool xp from Woodcutting in the abyssal realm.
 
<syntaxhighlight lang="js">game.realms.forEach(realm => game.masterySkills.forEach(skill => skill.addMasteryPoolXP(realm, 1000)));</syntaxhighlight>
The above code will result in 1,000 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to all skills in every realm.


== Add Prayer Points ==
== Unlock a Pet ==
The combat.player.addPrayerPoints function can be used to add prayer points to a player.
The <code>unlockPetByID</code> function is used to unlock [[Pets]].
<nowiki>game.combat.player.addPrayerPoints(amount)</nowiki>
<syntaxhighlight lang="js">game.petManager.unlockPetByID(petID)</syntaxhighlight>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| amount || int || No || || The quantity of prayer points to add.
| petID || string || No || The ID of the pet, which can be found on the individual pet pages (such as {{PetIcon|Ty}} for example) or by using the following function: <code>console.log(game.pets.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</code>
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>game.combat.player.addPrayerPoints(1);</nowiki>
<syntaxhighlight lang="js">
The above code will add 1 prayer point to the player, and update player stats.
game.petManager.unlockPetByID('melvorD:CoolRock');
game.petManager.unlocked.delete(game.pets.getObjectSafe('melvorD:CoolRock'));game.petManager.computeProvidedStats();
  </syntaxhighlight>
The first line will result in the unlocking of {{PetIcon|Cool Rock}} while the second line will remove the Cool Rock then reload the player's stats.
<syntaxhighlight lang="js">game.pets.forEach(pet => game.petManager.unlockPet(pet));</syntaxhighlight>
The above code will unlock every single pet.


== Add XP ==
== Discover Summoning Marks ==
The addXP function can be used to add experience to any skill.
The <code>discoverMark</code> function is used to discover [[Summoning#Summoning Marks|Summoning Marks]].
<nowiki>game.skill.addXP(xp)</nowiki>
<syntaxhighlight lang="js">game.summoning.discoverMark(mark)</syntaxhighlight>
where <code>skill</code> is the lowercase name of the skill you are adding experience to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| xp || int || No || || Amount of experience to add.
| mark || object || No || The mark to discover. Obtained with <syntaxhighlight lang="js" inline>game.summoning.actions.getObjectSafe(markID)</syntaxhighlight> where <code>markID</code> is the ID of the mark.
 
A list of mark IDs can be obtained by entering the following into the console: <syntaxhighlight lang="js" inline>console.log(game.summoning.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</syntaxhighlight>.
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>game.thieving.addXP(1000);</nowiki>
<syntaxhighlight lang="js">
The above code will result in 1000 experience being added to Theiving.
game.summoning.discoverMark(game.summoning.actions.getObjectSafe('melvorF:Dragon'));
game.summoning.marksUnlocked.delete(game.summoning.actions.getObjectSafe('melvorF:Dragon'));
  </syntaxhighlight>
The first line discovers a single mark for the {{ItemIcon|Dragon}} familiar whereas the second line removes all marks from the Dragon.
<syntaxhighlight lang="js">
game.summoning.actions.forEach((mark) => {
game.summoning.marksUnlocked.set(mark, (mark.realm.id === 'melvorD:Melvor') ? 61 : 31);
game.summoning.renderQueue.markCount.add(mark);
game.summoning.renderQueue.markState.add(mark);
});
</syntaxhighlight>
The above code will set every single mark to level 61 if it's in the Melvor Realm and 31 if it's in the Abyssal Realm then update the mark count and mark states.


== Add Mastery XP ==
== Locate an Ancient Relic ==
The addMasteryXP function can be used to add experience to any specific Mastery in a skill.
The <code>locateAncientRelic</code> function is used to locate [[Ancient Relics#List_of_Ancient_Relics|Ancient Relics]].
<nowiki>game.skill.addMasteryXP(masteryAction, xp)</nowiki>
<syntaxhighlight lang="js">game.<skill>.locateAncientRelic(relicSet, relic)</syntaxhighlight>
where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to.
 
where <code><skill></code> is the lowercase name of the skill you wish to add a relic to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| masteryAction || object || No || || The action to add Mastery XP to. Obtained with <code>game.skill.actions.allObjects[n]</code> where n is the ID of the action, starting at 0. Also obtainable with <code>game.skill.actions.getObjectByID(id)</code> where id is the string ID of the action.
| relicSet || object || No || The relicSet that the relic belongs to. Obtained with <syntaxhighlight lang="js" inline>game.<skill>.ancientRelicSets.get(realm)</syntaxhighlight>
 
A list of realms IDs can be obtained by entering the following into the console: <syntaxhighlight lang="js" inline>console.log(game.realms.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</syntaxhighlight>. To convert the realmID into a realm object, use <syntaxhighlight lang="js" inline>game.realms.getObjectSafe(realmID)</syntaxhighlight>.
|-
|-
| xp || int || Yes || 0 || Amount of experience to add.
| relic || object || No || The relic that you wish to add.
 
The relic can be obtained with <code>relicSet.relicDrops[#].relic;</code> where <code>#</code> is replaced with the relic number, starting from 0 for the first relic and ending with 4 for the 5th relic.
|}
|}


=== Examples ===
=== Examples ===
<nowiki>game.farming.addMasteryXP(game.farming.actions.allObjects[13], 300);</nowiki>
<syntaxhighlight lang="js">
The above code will result in 300 Mastery XP being added to Farming for Mastery ID 13 (Carrot Seeds).
let realm = game.realms.getObjectSafe('melvorD:Melvor');
let relicSet = game.woodcutting.ancientRelicSets.get(realm);
let relic = relicSet.relicDrops[0].relic;
if (!relicSet.foundRelics.has(relic))
game.woodcutting.locateAncientRelic(relicSet, relic);
</syntaxhighlight>
The above code locates Woodcutting Relic 1 in the Melvor Realm.
<syntaxhighlight lang="js">
game.skills.forEach(skill => {
game.realms.forEach(realm => {
let relicSet = skill.ancientRelicSets.get(realm);
if (skill.hasAncientRelics && relicSet !== undefined)
relicSet.relicDrops.forEach(({ relic }) => {
if (!relicSet.foundRelics.has(relic))
skill.locateAncientRelic(relicSet, relic)
});
});
});
</syntaxhighlight>
The above will add all the ancient relics to every skill, including modded skills, for all realms that have relics.


<nowiki>game.firemaking.addMasteryXP(game.firemaking.actions.allObjects[3], 3000);</nowiki>
== Reset all Equipment Quick Equip Items ==
The above code will result in 3000 Mastery XP being added to Firemaking for Mastery ID 3 (Teak Logs).
The below script will reset the Equipment Quick Equip items back to an empty item. These are the Quick Equip items that are found when clicking on an equipment slot, not the ones found in the skilling minibar (that are set through the bank settings).
=== Examples ===
<syntaxhighlight lang="js">
game.combat.player.equipment.equippedArray.forEach(equipped => {
equipped.quickEquipItems = [game.emptyEquipmentItem, game.emptyEquipmentItem, game.emptyEquipmentItem];
equipped.trimQuickEquipItems();
});
</syntaxhighlight>
The above code will reset all the quick equip items for the '''current''' equipment set.
<syntaxhighlight lang="js">
game.combat.player.equipmentSets.forEach(({ equipment }) => {
equipment.equippedArray.forEach(equipped => {
equipped.quickEquipItems = [game.emptyEquipmentItem, game.emptyEquipmentItem, game.emptyEquipmentItem];
equipped.trimQuickEquipItems();
});
});
</syntaxhighlight>
The above code will reset all the quick equip items for '''all''' equipment sets.


== Add Mastery XP to Pool==
== Adjust Dungeon Completions ==
The addMasteryPoolXP function can be used to add mastery pool experience to a skill
The <code>addDungeonCompletion</code> and <code>setDungeonCompleteCount</code> functions are used to modify a dungeon's completion count.
<nowiki>game.skill.addMasteryPoolXP(xp)</nowiki>
<syntaxhighlight lang="js">
where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to.
game.combat.player.manager.addDungeonCompletion(dungeon);
game.combat.player.manager.setDungeonCompleteCount(dungeon, amount);
</syntaxhighlight>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| xp || int || Yes || 0 || Amount of experience to add.
| dungeon || object || No || The dungeon you wish to add a completion to. Obtained with <syntaxhighlight lang="js" inline>game.dungeons.getObjectSafe(dungeonID);</syntaxhighlight> where <code>dungeonID</code> is the ID of the dungeon.
|}
 
=== Examples ===
A list of dungeon IDs can be obtained by entering the following into the console: <syntaxhighlight lang="js" inline>console.log(game.dungeons.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</syntaxhighlight>.
<nowiki>game.woodcutting.addMasterPoolXP(600);</nowiki>
The above code will result in 600 Mastery Pool XP being added to Woodcutting.


== Unlock Pet ==
If an invalid dungeonID is entered, your game will be unable to be saved until the entry is either removed or the game is reloaded. You can remove the undefined entry with <code>game.combat.player.manager.dungeonCompletion.delete(undefined)</code> which should return <code>true</code> and the errors should stop appearing.
The petManager.unlockPetByID function is used to unlock [[Pets]]. Note that unlocking a pet is permanent - there is no supported method to lock a pet once again.
<nowiki>game.petManager.unlockPetByID(petID)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| petID || string || No || || The ID of the pet, which can be found on the individual pet pages (such as {{PetIcon|Ty}} for example).
| amount || number || No || The amount of dungeons clears you wish to add when using <code>setDungeonCompleteCount</code>. An amount is only required for setDungeonCompleteCount.
|}
|}
=== Examples ===
=== Examples ===
<nowiki>game.petManager.unlockPetByID("melvorD:CoolRock");</nowiki>
<syntaxhighlight lang="js">
The above code will result in the unlocking of {{PetIcon|Cool Rock}}.
let dungeon = game.dungeons.getObjectSafe('melvorF:Into_the_Mist');
game.combat.player.manager.addDungeonCompletion(dungeon);


== Discover Mark ==
let dungeon = game.dungeons.getObjectSafe('melvorItA:Into_The_Abyss')
The discoverMark function is used to discover [[Summoning#Summoning Marks|Summoning Marks]]. Once discovered, there is no supported method to allow a mark to become undiscovered again.
game.combat.player.manager.setDungeonCompleteCount(dungeon, 15);
  <nowiki>game.summoning.discoverMark(mark)</nowiki>
</syntaxhighlight>
=== Attributes ===
The first example will add a single completion to {{ZoneIcon|Into the Mist}} while the second example will set {{ZoneIcon|Into the Abyss}} completions to 15.
 
After modifying the dungeon completion count, run <code>game.queueRequirementRenders();</code> to apply UI updates without having to restart the game.
 
== Ancient Relics Level Caps ==
=== Increasing or Setting level caps ===
The <code>increaseLevelCap</code> and <code>setLevelCap</code> functions are used to modify the current level cap of a given skill in the {{AoD}} {{Icon|Ancient Relics}} [[gamemode]].
<syntaxhighlight lang="js">
game.<skill>.increaseLevelCap(value);
game.<skill>.setLevelCap(value);
  game.<skill>.increaseAbyssalLevelCap(value);
game.<skill>.setAbyssalLevelCap(value);
</syntaxhighlight>
 
==== Attributes ====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Description
|-
|-
| mark || object || No || || The mark to discover. Obtained with <code>game.summoning.actions.allObjects[n]</code> where n is the ID of the mark, starting at 0. Also obtainable with <code>game.summoning.actions.getObjectByID(id)</code> where id is the string ID of the action.
| value || int || No || The value to increase the level cap by, or set the level cap to
|}
|}
=== Examples ===
 
  <nowiki>game.summoning.discoverMark(game.summoning.actions.allObjects[15]);</nowiki>
==== Examples ====
The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar.
<syntaxhighlight lang="js">
game.slayer.increaseLevelCap(20);
  game.thieving.setAbyssalLevelCap(45);
</syntaxhighlight>
The first line will increase {{Skill|Slayer|Slayer's}} level cap by 20 levels whereas the second line will set {{AbyssalSkill|Thieving|Thieving's}} level cap to 45.
<syntaxhighlight lang="js">
game.skills.forEach(skill => {
skill.setLevelCap(skill.maxLevelCap);
if (skill.hasAbyssalLevels)
skill.setAbyssalLevelCap(skill.maxAbyssalLevelCap);
});
</syntaxhighlight>
The above code will set both the level caps and abyssal level caps of all skills to their maximum value.
=== Awarding random level caps ===
The below script will award random level cap increases without increasing combat level caps. The only value that must be changed is the <code>capType</code> at the beginning of the script. 0 is a pre-Bane level cap increase, 2 is a TotH level cap increase, and 4 is an ItA level cap increase.
<syntaxhighlight lang="js">
let capType = 0; // 0 = pre-Bane, 2 = TotH, 4 = ItA
let capIncrease = game.currentGamemode.levelCapIncreases[capType];
game.validateRandomLevelCapIncreases();
if (capIncrease.randomIncreases.length > 0 && capIncrease.randomCount > 0) {
if (capIncrease.randomIncreasesLeft === 0)
game.levelCapIncreasesBeingSelected.push(capIncrease);
capIncrease.randomIncreasesLeft += capIncrease.randomCount;
game.renderQueue.sidebarSkillUnlock = true;
game.queueNextRandomLevelCapModal();
}
</syntaxhighlight>
If you wish to also increase combat level caps then the following can be used.
<syntaxhighlight lang="js">
let capType = 0; // 0 = pre-Bane, 2 = TotH, 4 = ItA
let capIncrease = game.currentGamemode.levelCapIncreases[capType];
game.increaseSkillLevelCaps(capIncrease, capIncrease.requirementSets.get(0));
</syntaxhighlight>
 
{{Menu}}

Latest revision as of 22:27, 26 October 2024

In-game functions are responsible for most things in the game. It is possible to interact directly with them through the console. This can be used to add items, levels, GP and more. These functions can be executed though the console. To access the console open Developer Tools (usually by pressing F12) in your browser and navigate to the console. Then, simply paste the code in the input field and press enter. Most functions will require you to fill out variables in the code before executing them. Note that all code is case sensitive.

Disclaimer: Blindly adding items and experience will most likely take away game enjoyment. It is highly encouraged only to use this to either test things or recoup lost items/progress due to lost saves.

You are playing around with the code of the game, as such if you make mistakes it is possible that could corrupt your game. It is highly recommended to BACKUP YOUR SAVE before running any in-game functions.

Using In-game Functions

Players can use the dev.Console mod to execute these functions within the Steam, Epic, Android, and iOS versions of Melvor Idle.

On Web, Steam, and Epic, the console can be opened with F12. If using Steam or Epic, you must enable the dev console first before you are able to open it.

Add Item to Bank

The addItemByID function can be used to add any item in the game to the bank.

game.bank.addItemByID(itemID, quantity, logLost, found, ignoreSpace, notify)

Attributes

Attribute Type Optional? Default Value Description
itemID string No The ID of the item.

For a complete list of items, see: Table of Items. Item IDs are on their respective wiki page.

To search for a specific item by name, the following can be used. Replace REPLACEME with the full or partial name of the item (case insensitive).

let searchTerm = 'REPLACEME';
console.log(game.items.filter(x => x.name.toLowerCase().includes(searchTerm.toLowerCase())).map((a) => a.id + ' - ' + a.name).join('\n'))
quantity int No Quantity of item to add.
logLost boolean Yes false If true, items that did not fit into the bank will be logged as lost
found boolean Yes false Determines if items added by this function will be included within the "Times Found" statistic for that item within the completion log. Therefore, unless this parameter is set to true, any items added in this way will not contribute towards the player's item completion percentage.

Note: When adding Bank Slot Tokens, it is suggested that this parameter is set to true, otherwise this may cause issues with the way the game calculates the amount of bank space a player has.
ignoreSpace boolean Yes false If true, the item will be added to the bank even if the bank is already full
notify boolean Yes true If true, there will be a notification that the item was added along with the quantity.

Examples

game.bank.addItemByID("melvorD:Oak_Logs", 10, true, true, false);

The above code will result in attempting to add 10 Oak Logs to the Bank. If they do not fit, 10 will be added to the # of Oak Logs lost on the item's stats. Additionally, Oak Logs will be marked as discovered in the Completion Log.

game.items.forEach((item) => game.bank.addItem(item, 1000000, false, true, true, false));

The above code will add 1,000,000 of every item in the game. The items will be forced into the bank even if you do not have room and there will be no notifications upon adding the items.

Remove Item from Bank

The removeItemQuantityByID function can be used to remove any item from the bank

game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)

Note that if an item's quantity is in an invalid state, such as NaN or Infinity, then this function will not be able to remove that item from the bank. For any such items, use the below snippet instead:

Code
First, enter the below into the console:
function removeItemByID(itemID) {
	const item = game.items.getObjectSafe(itemID);
	const bankItem = game.bank.items.get(item);
	if (bankItem === undefined)
	throw new Error(
	`Tried to remove quantity from bank, but item is not in bank.`
	);
	bankItem.quantity = 1;
	game.bank.removeItemQuantity(item, 1, true);
}

After this, invoke the newly-created function with the appropriate item ID to remove items from the bank. For example: removeItemByID('melvorD:Oak_Logs');

Attributes

Attribute Type Optional? Default Value Description
itemID string No The ID of the item.
For a complete list of items and their IDs, see: Table of Items
quantity int No The number of items to remove.
removeItemCharges boolean Yes true If true, the count of glove charges will be set to 0 if the itemID is for a pair of gloves with charges.

Examples

game.bank.removeItemQuantityByID('melvorD:Oak_Logs', 10);

The above code will result in 10 Oak Logs being removed from the bank.

Adjust Shop Purchases

The below script will add a shop purchase into upgradesPurchased which is where all purchases are stored. Alternatively, game.shop.buyItemOnClick(purchase, true); can be used however using this function will remove the costs of the purchase as well.

Attributes

Attribute Type Optional? Description
purchaseID string No The ID of the Purchase. A complete list of purchase IDs can be generated with: console.log(game.shop.purchases.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))

To search for a specific purchase by name, the following can be used. Replace REPLACEME with the full or partial name of the purchase (case insensitive).

let searchTerm = 'REPLACEME';
console.log(game.shop.purchases.filter(x => x.name.toLowerCase().includes(searchTerm.toLowerCase())).map((a) => a.id + ' - ' + a.name).join('\n'))
quantity int No The number of purchases to buy

Examples

// Settings //
let purchase = game.shop.purchases.getObjectSafe('melvorD:Extra_Bank_Slot');
let quantity = 100;
// End of Settings //
game.shop.upgradesPurchased.set(purchase, (game.shop.upgradesPurchased.get(purchase) || 0) + quantity);
game.shop.computeProvidedStats();
shopMenu.tabs.get(purchase.category).menu.updateItemSelection();
game.shop.renderQueue.costs = true;

The above will add 100 Bank Slot purchases then do the necessary render.

Adjust Currencies

All Currencies within the game, being GP GP, AP Abyssal Pieces (AP), SC Slayer Coins (SC), ASC Abyssal Slayer Coins (ASC), and RC Raid Coins (RC) can be adjusted using the same set of functions:

  • To adjust GP, use game.gp
  • To adjust AP, use game.abyssalPieces
  • To adjust SC, use game.slayerCoins
  • To adjust ASC, use game.abyssalSlayerCoins
  • To adjust RC, use game.raidCoins

The following functions are used to add, remove, and set currencies. set may be of particular use to players who have inadvertently found their currency balance is set to an invalid value such as NaN.

game.<currency>.add(amount);
game.<currency>.remove(amount);
game.<currency>.set(amount);

Attributes

Attribute Type Optional? Description
amount int No The amount to adjust the specified currency's balance by

Examples

game.gp.add(1000);
game.abyssalSlayerCoins.remove(2500);
game.raidCoins.set(10000);

The first function will add 1,000GP, the second function will remove 2,500ASC and lastly, the third function will set the balance of RC Raid Coins to 10,000.

Adjust Prayer Points or Soul Points

The addPrayerPoints and addSoulPoints functions can be used to add prayer points or soul points to a player.

 game.combat.player.addPrayerPoints(amount);
 game.combat.player.addSoulPoints(amount);

Attributes

Attribute Type Optional? Description
amount int No The quantity of prayer or soul points to add. A negative value will remove points.

Examples

 game.combat.player.addPrayerPoints(1);
 game.combat.player.addSoulPoints(-50);

The first line will add 1 prayer point to the player while the second will remove 50 soul points.

Adjust XP and Abyssal XP

The addXP and addAbyssalXP functions can be used to add or remove experience and abyssal experience from any skill. The setXP and setAbyssalXP can be used to set the new experience or abyssal experience value.

game.<skill>.addXP(xp);
game.<skill>.addAbyssalXP(xp);
game.<skill>.setXP(xp);
game.<skill>.setAbyssalXP(xp);

where <skill> is the lowercase name of the skill you are adding experience to.

Attributes

Attribute Type Optional? Description
xp int No Amount of experience to add. A negative number will remove experience. When removing XP, it's best to use the Set function as these will also visually update your current level if the removed experience results in a lower level.

Examples

game.thieving.addXP(1000);
game.astrology.setAbyssalXP(game.astrology.abyssalXP - 700); // For XP, use game.astrology.xp with the addXP function
game.attack.setXP(exp.levelToXP(120) + 1); // For Abyssal XP, use abyssalExp.levelToXP with the setAbyssalXP function

The first line will result in 1,000 experience being added to

Error creating thumbnail: File missing
Thieving

. The second line will remove 700 abyssal xp from Astrology. The third line will set Attack's level to 120.

Adjust Mastery XP

The addMasteryXP function can be used to add experience to any specific

Error creating thumbnail: File missing
Mastery

in a skill.

game.<skill>.addMasteryXP(masteryAction, xp)

where <skill> is the lowercase name of the skill you are adding mastery experience to.

Attributes

Attribute Type Optional? Description
masteryAction object No The action to add Mastery XP to. Obtained with game.<skill>.actions.getObjectSafe(id);.

A list of actions IDs can be generated with console.log(game.<skill>.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'));

In both of the provided functions, <skill> must be replaced with the name of the skill (all lowercase).

xp int Yes Amount of experience to add. A negative value will remove mastery xp.

Examples

 game.farming.addMasteryXP(game.farming.actions.getObjectSafe('melvorD:Carrot'), 300);
 game.farming.addMasteryXP(game.farming.actions.getObjectSafe('melvorTotH:Starfruit'), -500);

The first line will result in 300

Error creating thumbnail: File missing
Mastery

XP being added to

Error creating thumbnail: File missing
Farming

for Carrot Seeds whereas the second line will remove 500 Mastery XP from Starfruit.

game.masterySkills.forEach(skill => skill.actions.forEach(action => skill.addMasteryXP(action, 5000)));

The above code will result in 5,000

Error creating thumbnail: File missing
Mastery

XP being added to every action within every skill with a mastery action.

Adjust Mastery Pool XP

The addMasteryPoolXP function can be used to add Mastery Pool experience to a skill

game.<skill>.addMasteryPoolXP(realm, xp)

where <skill> is the lowercase name of the skill you are adding mastery experience to.

Attributes

Attribute Type Optional? Description
realm object No The realm to add the Mastery Pool XP to. Obtained with game.realms.getObjectSafe(realmID).

A list of realm IDs can be obtained by entering the following into the console: console.log(game.realms.allObjects.map((a) => a.id + ' - ' + a.name).join('\n')).

xp int Yes Amount of experience to add. A negative value will remove mastery pool xp.

Examples

 game.woodcutting.addMasteryPoolXP(game.realms.getObjectSafe('melvorD:Melvor'), 600);
 game.woodcutting.addMasteryPoolXP(game.realms.getObjectSafe('melvorItA:Abyssal'), -400);

The first line will result in 600 Mastery Pool XP being added to

Error creating thumbnail: File missing
Woodcutting

in the Melvor Realm whereas the second line will remove 400 mastery pool xp from Woodcutting in the abyssal realm.

game.realms.forEach(realm => game.masterySkills.forEach(skill => skill.addMasteryPoolXP(realm, 1000)));

The above code will result in 1,000 Mastery Pool XP being added to all skills in every realm.

Unlock a Pet

The unlockPetByID function is used to unlock Pets.

game.petManager.unlockPetByID(petID)

Attributes

Attribute Type Optional? Description
petID string No The ID of the pet, which can be found on the individual pet pages (such as
Error creating thumbnail: File missing
Ty
for example) or by using the following function: console.log(game.pets.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))

Examples

 game.petManager.unlockPetByID('melvorD:CoolRock');
 game.petManager.unlocked.delete(game.pets.getObjectSafe('melvorD:CoolRock'));game.petManager.computeProvidedStats();

The first line will result in the unlocking of

Error creating thumbnail: File missing
Cool Rock

while the second line will remove the Cool Rock then reload the player's stats.

game.pets.forEach(pet => game.petManager.unlockPet(pet));

The above code will unlock every single pet.

Discover Summoning Marks

The discoverMark function is used to discover Summoning Marks.

game.summoning.discoverMark(mark)

Attributes

Attribute Type Optional? Description
mark object No The mark to discover. Obtained with game.summoning.actions.getObjectSafe(markID) where markID is the ID of the mark.

A list of mark IDs can be obtained by entering the following into the console: console.log(game.summoning.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n')).

Examples

 game.summoning.discoverMark(game.summoning.actions.getObjectSafe('melvorF:Dragon'));
 game.summoning.marksUnlocked.delete(game.summoning.actions.getObjectSafe('melvorF:Dragon'));

The first line discovers a single mark for the

Error creating thumbnail: File missing
Dragon

familiar whereas the second line removes all marks from the Dragon.

game.summoning.actions.forEach((mark) => {
	game.summoning.marksUnlocked.set(mark, (mark.realm.id === 'melvorD:Melvor') ? 61 : 31);
	game.summoning.renderQueue.markCount.add(mark);
	game.summoning.renderQueue.markState.add(mark);
});

The above code will set every single mark to level 61 if it's in the Melvor Realm and 31 if it's in the Abyssal Realm then update the mark count and mark states.

Locate an Ancient Relic

The locateAncientRelic function is used to locate Ancient Relics.

game.<skill>.locateAncientRelic(relicSet, relic)

where <skill> is the lowercase name of the skill you wish to add a relic to.

Attributes

Attribute Type Optional? Description
relicSet object No The relicSet that the relic belongs to. Obtained with game.<skill>.ancientRelicSets.get(realm)

A list of realms IDs can be obtained by entering the following into the console: console.log(game.realms.allObjects.map((a) => a.id + ' - ' + a.name).join('\n')). To convert the realmID into a realm object, use game.realms.getObjectSafe(realmID).

relic object No The relic that you wish to add.

The relic can be obtained with relicSet.relicDrops[#].relic; where # is replaced with the relic number, starting from 0 for the first relic and ending with 4 for the 5th relic.

Examples

let realm = game.realms.getObjectSafe('melvorD:Melvor');
let relicSet = game.woodcutting.ancientRelicSets.get(realm);
let relic = relicSet.relicDrops[0].relic;
if (!relicSet.foundRelics.has(relic))
	game.woodcutting.locateAncientRelic(relicSet, relic);

The above code locates Woodcutting Relic 1 in the Melvor Realm.

game.skills.forEach(skill => {
	game.realms.forEach(realm => {
		let relicSet = skill.ancientRelicSets.get(realm);
		if (skill.hasAncientRelics && relicSet !== undefined)
			relicSet.relicDrops.forEach(({ relic }) => {
				if (!relicSet.foundRelics.has(relic))
					skill.locateAncientRelic(relicSet, relic)
			});
	});
});

The above will add all the ancient relics to every skill, including modded skills, for all realms that have relics.

Reset all Equipment Quick Equip Items

The below script will reset the Equipment Quick Equip items back to an empty item. These are the Quick Equip items that are found when clicking on an equipment slot, not the ones found in the skilling minibar (that are set through the bank settings).

Examples

game.combat.player.equipment.equippedArray.forEach(equipped => {
	equipped.quickEquipItems = [game.emptyEquipmentItem, game.emptyEquipmentItem, game.emptyEquipmentItem];
	equipped.trimQuickEquipItems();
});

The above code will reset all the quick equip items for the current equipment set.

game.combat.player.equipmentSets.forEach(({ equipment }) => {
	equipment.equippedArray.forEach(equipped => {
		equipped.quickEquipItems = [game.emptyEquipmentItem, game.emptyEquipmentItem, game.emptyEquipmentItem];
		equipped.trimQuickEquipItems();
	});
});

The above code will reset all the quick equip items for all equipment sets.

Adjust Dungeon Completions

The addDungeonCompletion and setDungeonCompleteCount functions are used to modify a dungeon's completion count.

game.combat.player.manager.addDungeonCompletion(dungeon);
game.combat.player.manager.setDungeonCompleteCount(dungeon, amount);

Attributes

Attribute Type Optional? Description
dungeon object No The dungeon you wish to add a completion to. Obtained with game.dungeons.getObjectSafe(dungeonID); where dungeonID is the ID of the dungeon.

A list of dungeon IDs can be obtained by entering the following into the console: console.log(game.dungeons.allObjects.map((a) => a.id + ' - ' + a.name).join('\n')).

If an invalid dungeonID is entered, your game will be unable to be saved until the entry is either removed or the game is reloaded. You can remove the undefined entry with game.combat.player.manager.dungeonCompletion.delete(undefined) which should return true and the errors should stop appearing.

amount number No The amount of dungeons clears you wish to add when using setDungeonCompleteCount. An amount is only required for setDungeonCompleteCount.

Examples

 let dungeon = game.dungeons.getObjectSafe('melvorF:Into_the_Mist');
 game.combat.player.manager.addDungeonCompletion(dungeon);

 let dungeon = game.dungeons.getObjectSafe('melvorItA:Into_The_Abyss')
 game.combat.player.manager.setDungeonCompleteCount(dungeon, 15);

The first example will add a single completion to

Error creating thumbnail: File missing
Into the Mist

while the second example will set

Error creating thumbnail: File missing
Into the Abyss

completions to 15.

After modifying the dungeon completion count, run game.queueRequirementRenders(); to apply UI updates without having to restart the game.

Ancient Relics Level Caps

Increasing or Setting level caps

The increaseLevelCap and setLevelCap functions are used to modify the current level cap of a given skill in the AoD.png Ancient Relics gamemode.

 game.<skill>.increaseLevelCap(value);
 game.<skill>.setLevelCap(value);
 game.<skill>.increaseAbyssalLevelCap(value);
 game.<skill>.setAbyssalLevelCap(value);

Attributes

Attribute Type Optional? Description
value int No The value to increase the level cap by, or set the level cap to

Examples

 game.slayer.increaseLevelCap(20);
 game.thieving.setAbyssalLevelCap(45);

The first line will increase

Error creating thumbnail: File missing
Slayer's

level cap by 20 levels whereas the second line will set

Error creating thumbnail: File missing
Thieving

level cap to 45.

 game.skills.forEach(skill => {
	 skill.setLevelCap(skill.maxLevelCap);
	 if (skill.hasAbyssalLevels)
		 skill.setAbyssalLevelCap(skill.maxAbyssalLevelCap);
 });

The above code will set both the level caps and abyssal level caps of all skills to their maximum value.

Awarding random level caps

The below script will award random level cap increases without increasing combat level caps. The only value that must be changed is the capType at the beginning of the script. 0 is a pre-Bane level cap increase, 2 is a TotH level cap increase, and 4 is an ItA level cap increase.

let capType = 0; // 0 = pre-Bane, 2 = TotH, 4 = ItA
let capIncrease = game.currentGamemode.levelCapIncreases[capType];
game.validateRandomLevelCapIncreases();
if (capIncrease.randomIncreases.length > 0 && capIncrease.randomCount > 0) {
	if (capIncrease.randomIncreasesLeft === 0)
		game.levelCapIncreasesBeingSelected.push(capIncrease);
	capIncrease.randomIncreasesLeft += capIncrease.randomCount;
	game.renderQueue.sidebarSkillUnlock = true;
	game.queueNextRandomLevelCapModal();
}

If you wish to also increase combat level caps then the following can be used.

let capType = 0; // 0 = pre-Bane, 2 = TotH, 4 = ItA
let capIncrease = game.currentGamemode.levelCapIncreases[capType];
game.increaseSkillLevelCaps(capIncrease, capIncrease.requirementSets.get(0));