mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Refactored some runecrafting code
Corrected the Ourania altar reward, now fully authentic
This commit is contained in:
parent
39634b6caf
commit
9af776e3c6
1 changed files with 84 additions and 87 deletions
|
|
@ -2,6 +2,7 @@ package content.global.skill.runecrafting;
|
||||||
|
|
||||||
import content.global.handlers.item.equipment.fistofguthixgloves.FOGGlovesManager;
|
import content.global.handlers.item.equipment.fistofguthixgloves.FOGGlovesManager;
|
||||||
import core.ServerConstants;
|
import core.ServerConstants;
|
||||||
|
import core.api.Container;
|
||||||
import core.game.container.impl.EquipmentContainer;
|
import core.game.container.impl.EquipmentContainer;
|
||||||
import core.game.node.entity.impl.Animator.Priority;
|
import core.game.node.entity.impl.Animator.Priority;
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.entity.player.Player;
|
||||||
|
|
@ -28,6 +29,7 @@ import java.util.Arrays;
|
||||||
* A class used to craft runes.
|
* A class used to craft runes.
|
||||||
*
|
*
|
||||||
* @author Vexia
|
* @author Vexia
|
||||||
|
* @author Player Name
|
||||||
*/
|
*/
|
||||||
public final class RuneCraftPulse extends SkillPulse<Item> {
|
public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
|
|
||||||
|
|
@ -111,36 +113,36 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
if (!hasRequirement(player, "Legacy of Seergaze"))
|
if (!hasRequirement(player, "Legacy of Seergaze"))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!altar.isOurania() && player.getSkills().getLevel(Skills.RUNECRAFTING) < rune.getLevel()) {
|
if (!altar.isOurania() && getDynLevel(player, Skills.RUNECRAFTING) < rune.getLevel()) {
|
||||||
player.getPacketDispatch().sendMessage("You need a Runecrafting level of at least " + rune.getLevel() + " to craft this rune.");
|
sendMessage(player, "You need a Runecrafting level of at least " + rune.getLevel() + " to craft this rune.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (combination && !player.getInventory().containsItem(PURE_ESSENCE)) {
|
if (combination && amountInInventory(player, PURE_ESSENCE.getId()) == 0) {
|
||||||
player.getPacketDispatch().sendMessage("You need pure essence to craft this rune.");
|
sendMessage(player, "You need pure essence to craft this rune.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!altar.isOurania() && !rune.isNormal() && !player.getInventory().containsItem(PURE_ESSENCE)) {
|
if (!altar.isOurania() && !rune.isNormal() && amountInInventory(player, PURE_ESSENCE.getId()) == 0) {
|
||||||
player.getPacketDispatch().sendMessage("You need pure essence to craft this rune.");
|
sendMessage(player, "You need pure essence to craft this rune.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!altar.isOurania() && rune.isNormal() && !player.getInventory().containsItem(PURE_ESSENCE) && !player.getInventory().containsItem(RUNE_ESSENCE)) {
|
if (!altar.isOurania() && rune.isNormal() && amountInInventory(player, PURE_ESSENCE.getId()) == 0 && amountInInventory(player, RUNE_ESSENCE.getId()) == 0) {
|
||||||
player.getPacketDispatch().sendMessage("You need rune essence or pure essence in order to craft this rune.");
|
sendMessage(player, "You need rune essence or pure essence in order to craft this rune.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (altar.isOurania() && !player.getInventory().containsItem(PURE_ESSENCE)) {
|
if (altar.isOurania() && amountInInventory(player, PURE_ESSENCE.getId()) == 0) {
|
||||||
player.getPacketDispatch().sendMessage("You need pure essence to craft this rune.");
|
sendMessage(player, "You need pure essence to craft this rune.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (combination && player.getSkills().getLevel(Skills.RUNECRAFTING) < combo.getLevel()) {
|
if (combination && getDynLevel(player, Skills.RUNECRAFTING) < combo.getLevel()) {
|
||||||
player.getPacketDispatch().sendMessage("You need a Runecrafting level of at least " + combo.getLevel() + " to combine this rune.");
|
sendMessage(player, "You need a Runecrafting level of at least " + combo.getLevel() + " to combine this rune.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
if (node.getName().contains("rune") && !hasSpellImbue()) {
|
if (node.getName().contains("rune") && !hasSpellImbue()) {
|
||||||
final Rune r = Rune.forItem(node);
|
final Rune r = Rune.forItem(node);
|
||||||
final Talisman t = Talisman.forName(r.name());
|
final Talisman t = Talisman.forName(r.name());
|
||||||
if (!player.getInventory().containsItem(t.getTalisman())) {
|
if (amountInInventory(player, t.getTalisman().getId()) == 0) {
|
||||||
player.getPacketDispatch().sendMessage("You don't have the correct talisman to combine this rune.");
|
sendMessage(player, "You don't have the correct talisman to combine this rune.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
talisman = t;
|
talisman = t;
|
||||||
|
|
@ -167,23 +169,61 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int[][] OuraniaTable = { //https://x.com/JagexAsh/status/1312893446395506688/photo/1
|
||||||
|
/*level up to 9*/ { 2, 7, 15, 30, 60, 105, 165, 250, 400, 700,1300,2500,5000,10000},
|
||||||
|
/*level up to 19*/ { 3, 9, 21, 45, 85, 145, 225, 400,1000,2200,4600,6700,8500,10000},
|
||||||
|
/*level up to 29*/ { 8, 23, 55, 110, 220, 430, 850,1650,3250,4750,6150,7500,8800,10000},
|
||||||
|
/*level up to 39*/ { 20, 60, 120, 250, 500,1000,2000,4000,5300,6500,7600,8500,9300,10000},
|
||||||
|
/*level up to 49*/ { 40, 120, 240, 500,1000,2000,4000,5500,6500,7300,8050,8750,9400,10000},
|
||||||
|
/*level up to 59*/ { 80, 250, 600,1300,2650,4150,5250,6250,7000,7700,8350,8950,9500,10000},
|
||||||
|
/*level up to 69*/ {100, 300, 700,1500,3050,4450,5500,6450,7200,7900,8500,9050,9550,10000},
|
||||||
|
/*level up to 79*/ {200, 700,1700,3500,5000,6200,7100,7800,8300,8700,9100,9400,9700,10000},
|
||||||
|
/*level up to 89*/ {400,1000,2450,3900,5250,6300,7100,7800,8400,8900,9300,9600,9800,10000},
|
||||||
|
/*level up to 98*/ {650,1650,3300,4750,6100,7100,7800,8400,8900,9300,9600,9800,9900,10000},
|
||||||
|
/*level up to 99*/ {900,2200,3750,5200,6550,7500,8100,8600,9000,9300,9600,9800,9900,10000}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used to craft runes.
|
* Method used to craft runes.
|
||||||
*/
|
*/
|
||||||
private void craft() {
|
private void craft() {
|
||||||
final Item item = new Item(getEssence().getId(), getEssenceAmount());
|
final Item item = getEssenceItem();
|
||||||
int amount = player.getInventory().getAmount(item);
|
int amount = player.getInventory().getAmount(item);
|
||||||
if (!altar.isOurania()) {
|
if (altar.isOurania()) {
|
||||||
|
if (removeItem(player, item, Container.INVENTORY)) {
|
||||||
|
sendMessage(player, "You bind the temple's power into runes.");
|
||||||
|
player.incrementAttribute("/save:" + STATS_BASE + ":" + STATS_RC, amount);
|
||||||
|
|
||||||
|
int[] OuraniaValues;
|
||||||
|
if (getDynLevel(player, Skills.RUNECRAFTING) == 99) {
|
||||||
|
OuraniaValues = OuraniaTable[10];
|
||||||
|
} else {
|
||||||
|
int index = getDynLevel(player, Skills.RUNECRAFTING) / 10;
|
||||||
|
OuraniaValues = OuraniaTable[index];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
int roll = RandomFunction.random(10000);
|
||||||
|
Rune rune = null;
|
||||||
|
for (int j = 0; j < 14; j++) {
|
||||||
|
if (roll < OuraniaValues[j]) {
|
||||||
|
rune = Rune.values()[13 - j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rewardXP(player, Skills.RUNECRAFTING, rune.getExperience() * 2);
|
||||||
|
addItemOrDrop(player, rune.getRune().getId(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for(int j = 0; j < amount; j++) {
|
for(int j = 0; j < amount; j++) {
|
||||||
// since getMultiplier is stochastic, roll `amount` independent copies
|
// since getMultiplier is stochastic, roll `amount` independent copies
|
||||||
total += getMultiplier();
|
total += getMultiplier();
|
||||||
}
|
}
|
||||||
Item i = new Item(rune.getRune().getId(), total);
|
|
||||||
|
|
||||||
if (player.getInventory().remove(item) && player.getInventory().hasSpaceFor(i)) {
|
if (removeItem(player, item, Container.INVENTORY)) {
|
||||||
player.getPacketDispatch().sendMessage("You bind the temple's power into " + (combination ? combo.getRune().getName().toLowerCase() : rune.getRune().getName().toLowerCase()) + "s.");
|
sendMessage(player, "You bind the temple's power into " + (combination ? combo.getRune().getName().toLowerCase() : rune.getRune().getName().toLowerCase()) + "s.");
|
||||||
player.getInventory().add(i);
|
addItemOrDrop(player, rune.getRune().getId(), total);
|
||||||
player.incrementAttribute("/save:" + STATS_BASE + ":" + STATS_RC, amount);
|
player.incrementAttribute("/save:" + STATS_BASE + ":" + STATS_RC, amount);
|
||||||
|
|
||||||
// Fist of guthix gloves
|
// Fist of guthix gloves
|
||||||
|
|
@ -193,7 +233,7 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
|| (altar == Altar.EARTH && inEquipment(player, Items.EARTH_RUNECRAFTING_GLOVES_12865, 1))) {
|
|| (altar == Altar.EARTH && inEquipment(player, Items.EARTH_RUNECRAFTING_GLOVES_12865, 1))) {
|
||||||
xp += xp * FOGGlovesManager.updateCharges(player, amount) / amount;
|
xp += xp * FOGGlovesManager.updateCharges(player, amount) / amount;
|
||||||
}
|
}
|
||||||
player.getSkills().addExperience(Skills.RUNECRAFTING, xp, true);
|
rewardXP(player, Skills.RUNECRAFTING, xp);
|
||||||
|
|
||||||
// Achievement Diary handling
|
// Achievement Diary handling
|
||||||
// Craft some nature runes
|
// Craft some nature runes
|
||||||
|
|
@ -201,7 +241,7 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 2, 3);
|
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 2, 3);
|
||||||
}
|
}
|
||||||
// Craft 196 or more air runes simultaneously
|
// Craft 196 or more air runes simultaneously
|
||||||
if (altar == Altar.AIR && i.getAmount() >= 196) {
|
if (altar == Altar.AIR && total >= 196) {
|
||||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.FALADOR, 2, 2);
|
player.getAchievementDiaryManager().finishTask(player, DiaryType.FALADOR, 2, 2);
|
||||||
}
|
}
|
||||||
// Craft a water rune at the Water Altar
|
// Craft a water rune at the Water Altar
|
||||||
|
|
@ -210,58 +250,34 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (player.getInventory().remove(item)) {
|
|
||||||
player.getPacketDispatch().sendMessage("You bind the temple's power into runes.");
|
|
||||||
player.incrementAttribute("/save:" + STATS_BASE + ":" + STATS_RC, amount);
|
|
||||||
for (int i = 0; i < amount; i++) {
|
|
||||||
Rune rune = null;
|
|
||||||
while (rune == null) {
|
|
||||||
final Rune temp = Rune.values()[RandomFunction.random(Rune.values().length)];
|
|
||||||
if (player.getSkills().getLevel(Skills.RUNECRAFTING) >= temp.getLevel()) {
|
|
||||||
rune = temp;
|
|
||||||
} else {
|
|
||||||
if (RandomFunction.random(3) == 1) {
|
|
||||||
rune = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.getSkills().addExperience(Skills.RUNECRAFTING, rune.getExperience() * 2, true);
|
|
||||||
Item runeItem = rune.getRune();
|
|
||||||
player.getInventory().add(runeItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used to combine runes.
|
* Method used to combine runes.
|
||||||
*/
|
*/
|
||||||
private final void combine() {
|
private void combine() {
|
||||||
final Item remove = node.getName().contains("talisman") ? node : talisman != null ? talisman.getTalisman() : Talisman.forName(Rune.forItem(node).name()).getTalisman();
|
final Item remove = node.getName().contains("talisman") ? node : talisman != null ? talisman.getTalisman() : Talisman.forName(Rune.forItem(node).name()).getTalisman();
|
||||||
boolean imbued = hasSpellImbue();
|
boolean imbued = hasSpellImbue();
|
||||||
if (!imbued ? player.getInventory().remove(remove) : imbued) {
|
if (!imbued ? removeItem(player, remove, Container.INVENTORY) : imbued) {
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
int essenceAmt = player.getInventory().getAmount(PURE_ESSENCE);
|
int essenceAmt = player.getInventory().getAmount(PURE_ESSENCE);
|
||||||
final Item rune = node.getName().contains("rune") ? Rune.forItem(node).getRune() : Rune.forName(Talisman.forItem(node).name()).getRune();
|
final Item rune = node.getName().contains("rune") ? Rune.forItem(node).getRune() : Rune.forName(Talisman.forItem(node).name()).getRune();
|
||||||
int runeAmt = player.getInventory().getAmount(rune);
|
int runeAmt = player.getInventory().getAmount(rune);
|
||||||
if (essenceAmt > runeAmt) {
|
amount = Math.min(essenceAmt, runeAmt);
|
||||||
amount = runeAmt;
|
if (removeItem(player, new Item(PURE_ESSENCE.getId(), amount), Container.INVENTORY) && removeItem(player, new Item(rune.getId(), amount), Container.INVENTORY)) {
|
||||||
} else {
|
|
||||||
amount = essenceAmt;
|
|
||||||
}
|
|
||||||
if (player.getInventory().remove(new Item(PURE_ESSENCE.getId(), amount)) && player.getInventory().remove(new Item(rune.getId(), amount))) {
|
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
if (RandomFunction.random(1, 3) == 1 || hasBindingNecklace()) {
|
if (RandomFunction.random(1, 3) == 1 || hasBindingNecklace()) {
|
||||||
player.getInventory().add(new Item(combo.getRune().getId(), 1));
|
addItemOrDrop(player, combo.getRune().getId(), 1);
|
||||||
player.getSkills().addExperience(Skills.RUNECRAFTING, combo.getExperience(), true);
|
rewardXP(player, Skills.RUNECRAFTING, combo.getExperience());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasBindingNecklace()) {
|
if (hasBindingNecklace()) {
|
||||||
player.getEquipment().get(EquipmentContainer.SLOT_AMULET).setCharge(player.getEquipment().get(EquipmentContainer.SLOT_AMULET).getCharge() - 1);
|
player.getEquipment().get(EquipmentContainer.SLOT_AMULET).setCharge(player.getEquipment().get(EquipmentContainer.SLOT_AMULET).getCharge() - 1);
|
||||||
if (1000 - player.getEquipment().get(EquipmentContainer.SLOT_AMULET).getCharge() > 14) {
|
if (1000 - player.getEquipment().get(EquipmentContainer.SLOT_AMULET).getCharge() > 14) {
|
||||||
player.getEquipment().remove(BINDING_NECKLACE, true);
|
if (player.getEquipment().remove(BINDING_NECKLACE, true)) {
|
||||||
player.getPacketDispatch().sendMessage("Your binding necklace crumbles into dust.");
|
sendMessage(player, "Your binding necklace crumbles into dust.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -278,39 +294,21 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the essence amount.
|
* Gets the rune essence item.
|
||||||
*
|
*
|
||||||
* @return the amount of essence.
|
* @return the rune essence item.
|
||||||
*/
|
*/
|
||||||
private int getEssenceAmount() {
|
private Item getEssenceItem() {
|
||||||
if (altar.isOurania() && player.getInventory().containsItem(PURE_ESSENCE)) {
|
if (altar.isOurania() && amountInInventory(player, PURE_ESSENCE.getId()) > 0) {
|
||||||
return player.getInventory().getAmount(PURE_ESSENCE);
|
return new Item(PURE_ESSENCE.getId(), amountInInventory(player, PURE_ESSENCE.getId()));
|
||||||
}
|
}
|
||||||
if (!rune.isNormal() && player.getInventory().containsItem(PURE_ESSENCE)) {
|
if (!rune.isNormal() && amountInInventory(player, PURE_ESSENCE.getId()) > 0) {
|
||||||
return player.getInventory().getAmount(PURE_ESSENCE);
|
return new Item(PURE_ESSENCE.getId(), amountInInventory(player, PURE_ESSENCE.getId()));
|
||||||
} else if (rune.isNormal() && player.getInventory().containsItem(PURE_ESSENCE)) {
|
|
||||||
return player.getInventory().getAmount(PURE_ESSENCE);
|
|
||||||
} else {
|
|
||||||
return player.getInventory().getAmount(RUNE_ESSENCE);
|
|
||||||
}
|
}
|
||||||
|
if (rune.isNormal() && amountInInventory(player, RUNE_ESSENCE.getId()) > 0) {
|
||||||
|
return new Item(RUNE_ESSENCE.getId(), amountInInventory(player, RUNE_ESSENCE.getId()));
|
||||||
}
|
}
|
||||||
|
return new Item(PURE_ESSENCE.getId(), amountInInventory(player, PURE_ESSENCE.getId()));
|
||||||
/**
|
|
||||||
* Gets the rune essence that needs to be defined.
|
|
||||||
*
|
|
||||||
* @return the item.
|
|
||||||
*/
|
|
||||||
private Item getEssence() {
|
|
||||||
if (altar.isOurania() && player.getInventory().containsItem(PURE_ESSENCE)) {
|
|
||||||
return PURE_ESSENCE;
|
|
||||||
}
|
|
||||||
if (!rune.isNormal() && player.getInventory().containsItem(PURE_ESSENCE)) {
|
|
||||||
return PURE_ESSENCE;
|
|
||||||
} else if (rune.isNormal() && player.getInventory().containsItem(PURE_ESSENCE)) {
|
|
||||||
return PURE_ESSENCE;
|
|
||||||
} else {
|
|
||||||
return RUNE_ESSENCE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -322,7 +320,7 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
if (altar.isOurania()) {
|
if (altar.isOurania()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int rcLevel = player.getSkills().getLevel(Skills.RUNECRAFTING);
|
int rcLevel = getDynLevel(player, Skills.RUNECRAFTING);
|
||||||
int runecraftingFormulaRevision = ServerConstants.RUNECRAFTING_FORMULA_REVISION;
|
int runecraftingFormulaRevision = ServerConstants.RUNECRAFTING_FORMULA_REVISION;
|
||||||
boolean lumbridgeDiary = player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).isComplete(1);
|
boolean lumbridgeDiary = player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).isComplete(1);
|
||||||
return RuneCraftPulse.getMultiplier(rcLevel, rune, runecraftingFormulaRevision, lumbridgeDiary);
|
return RuneCraftPulse.getMultiplier(rcLevel, rune, runecraftingFormulaRevision, lumbridgeDiary);
|
||||||
|
|
@ -374,5 +372,4 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
||||||
public Altar getAltar() {
|
public Altar getAltar() {
|
||||||
return altar;
|
return altar;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue