Code:
package com.rs.game.player.actions.skills.runecrafting;
import com.rs.cache.loaders.ItemDefinitions;
import com.rs.game.Animation;
import com.rs.game.Graphics;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;
import com.rs.game.player.content.tasksystem.TaskManager.Tasks;
public class Runecrafting {
public final static int RUNE_ESSENCE = 1436, PURE_ESSENCE = 7936, AIR_TIARA = 5527, MIND_TIARA = 5529,
WATER_TIARA = 5531, BODY_TIARA = 5533, EARTH_TIARA = 5535, FIRE_TIARA = 5537, COSMIC_TIARA = 5539,
NATURE_TIARA = 5541, CHAOS_TIARA = 5543, LAW_TIARA = 5545, DEATH_TIARA = 5547, BLOOD_TIARA = 5549,
SOUL_TIARA = 5551, ASTRAL_TIARA = 9106, OMNI_TIARA = 13655, AIR_TALISMAN = 1438;
public static boolean isTiara(int id) {
return id == AIR_TIARA || id == MIND_TIARA || id == WATER_TIARA || id == BODY_TIARA || id == EARTH_TIARA
|| id == FIRE_TIARA || id == COSMIC_TIARA || id == NATURE_TIARA || id == CHAOS_TIARA || id == LAW_TIARA
|| id == DEATH_TIARA || id == BLOOD_TIARA || id == SOUL_TIARA || id == ASTRAL_TIARA || id == OMNI_TIARA;
}
public static boolean hasRcingSuit(Player player) {
if (player.getEquipment().getHatId() == 21485 && player.getEquipment().getChestId() == 21484
&& player.getEquipment().getLegsId() == 21486 && player.getEquipment().getBootsId() == 21487)
return true;
return false;
}
protected static RunecraftingStore[] storeData = RunecraftingStore.values();
protected static MultiRunes[] multiData = MultiRunes.values();
/**
* Store all runecrafting runes, level, exp along with talismans & tiaras
*
*/
public enum RunecraftingStore {
AIR_RUNE(2478, 556, 1, 5, AIR_TALISMAN, false, AIR_TIARA, OMNI_TIARA);
int altarId;
int runeId;
int level;
double exp;
int inventory;
boolean pureEssence;
int[] items;
RunecraftingStore(int altarId, int runeId, int level, double exp, int inventory, boolean pureEssence,
int... items) {
this.altarId = altarId;
this.runeId = runeId;
this.level = level;
this.exp = exp;
this.inventory = inventory;
this.pureEssence = pureEssence;
this.items = items;
}
}
/**
* Multiple runes depending on level
*
*/
public enum MultiRunes {
AIR(556, 11, 2, 22, 3, 33, 4, 44, 5, 55, 6, 66, 7, 77, 8, 88, 9, 99, 10);
int runeId;
/**
* level, amount, level, amount...
*/
int[] multipliers;
MultiRunes(int runeId, int... multipliers) {
this.runeId = runeId;
this.multipliers = multipliers;
}
}
public static void craftRune(Player player, int runeId, int level, double exp, boolean pureEssence) {
int actualLevel = player.getSkills().getLevel(Skills.RUNECRAFTING);
if (actualLevel < level) {
player.getPackets().sendGameMessage("You need a runecrafting level of " + level + " to craft this rune.");
return;
}
int runes = player.getInventory().getItems().getNumberOf(PURE_ESSENCE);
if (runes > 0)
player.getInventory().deleteItem(PURE_ESSENCE, runes);
if (!pureEssence) {
int normalEss = player.getInventory().getItems().getNumberOf(RUNE_ESSENCE);
if (normalEss > 0) {
player.getInventory().deleteItem(RUNE_ESSENCE, normalEss);
runes += normalEss;
}
}
if (runes == 0) {
player.getPackets().sendGameMessage("You don't have " + (pureEssence ? "pure" : "rune") + " essence.");
return;
}
for (MultiRunes multi : multiData) {
if (multi != null) {
if (multi.runeId == runeId) {
for (int i = multi.multipliers.length - 2; i >= 0; i -= 2) {
if (actualLevel >= multi.multipliers[i + 1]) {
runes *= multi.multipliers[i];
break;
}
}
}
}
}
double totalXp = exp * runes;
if (hasRcingSuit(player))
totalXp *= 1.025;
player.getSkills().addXp(Skills.RUNECRAFTING, totalXp);
player.setNextGraphics(new Graphics(186));
player.setNextAnimation(new Animation(791));
player.lock(1);
player.getInventory().addItem(runeId, runes);
if (!player.getTaskManager().completedTask(Tasks.CRAFT_AIR_RUNE)) {
if (runeId == 556)
player.getTaskManager().completeTask(Tasks.CRAFT_AIR_RUNE);
}
if (!player.getTaskManager().completedTask(Tasks.CRAFT_BLOOD_RUNE)) {
if (runeId == 565)
player.getTaskManager().completeTask(Tasks.CRAFT_BLOOD_RUNE);
}
player.getPackets().sendGameMessage("You bind the temple's power into "
+ ItemDefinitions.getItemDefinitions(runeId).getName().toLowerCase() + "s.");
}
}