mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Thread now correctly disappears every 5 items crafted, including bug fixes related to the fact
Ring of forging now correctly disappears every 140 iron ores smelt, including bug fixes related to the fact
This commit is contained in:
parent
59075798ea
commit
2b460b64f2
7 changed files with 24 additions and 76 deletions
|
|
@ -95,9 +95,6 @@ public final class DragonCraftPulse extends SkillPulse<Item> {
|
||||||
player.getInventory().add(item);
|
player.getInventory().add(item);
|
||||||
player.getSkills().addExperience(Skills.CRAFTING, hide.getExperience(), true);
|
player.getSkills().addExperience(Skills.CRAFTING, hide.getExperience(), true);
|
||||||
LeatherCrafting.decayThread(player);
|
LeatherCrafting.decayThread(player);
|
||||||
if (LeatherCrafting.isLastThread(player)) {
|
|
||||||
LeatherCrafting.removeThread(player);
|
|
||||||
}
|
|
||||||
amount--;
|
amount--;
|
||||||
}
|
}
|
||||||
return amount < 1;
|
return amount < 1;
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,6 @@ public final class HardCraftPulse extends SkillPulse<Item> {
|
||||||
player.getInventory().add(item);
|
player.getInventory().add(item);
|
||||||
player.getSkills().addExperience(Skills.CRAFTING, 35, true);
|
player.getSkills().addExperience(Skills.CRAFTING, 35, true);
|
||||||
LeatherCrafting.decayThread(player);
|
LeatherCrafting.decayThread(player);
|
||||||
if (LeatherCrafting.isLastThread(player)) {
|
|
||||||
LeatherCrafting.removeThread(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
amount--;
|
amount--;
|
||||||
return amount < 1;
|
return amount < 1;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
package content.global.skill.crafting.armour;
|
package content.global.skill.crafting.armour;
|
||||||
|
|
||||||
|
import core.api.Container;
|
||||||
import core.game.component.Component;
|
import core.game.component.Component;
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.entity.player.Player;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
|
import org.rs09.consts.Items;
|
||||||
|
|
||||||
|
import static core.api.ContentAPIKt.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a useful class for leather crafting related information.
|
* Represents a useful class for leather crafting related information.
|
||||||
|
|
@ -40,52 +44,17 @@ public final class LeatherCrafting {
|
||||||
*/
|
*/
|
||||||
private static final Component COMPONENT = new Component(154);
|
private static final Component COMPONENT = new Component(154);
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if its the last thrad.
|
|
||||||
* @return {@code True} if so.
|
|
||||||
*/
|
|
||||||
public static boolean isLastThread(final Player player) {
|
|
||||||
final Item thread = getThread(player);
|
|
||||||
if (thread == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int charge = thread.getCharge();
|
|
||||||
return charge >= 1004;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used to decay thread.
|
* Method used to decay thread.
|
||||||
|
* @author Player Name
|
||||||
*/
|
*/
|
||||||
public static void decayThread(final Player player) {
|
public static void decayThread(final Player player) {
|
||||||
final Item thread = getThread(player);
|
int charges = getAttribute(player, "threadCharges", 5) - 1;
|
||||||
if (thread == null) {
|
if (charges <= 0 && removeItem(player, Items.THREAD_1734, Container.INVENTORY)) {
|
||||||
return;
|
charges = 5;
|
||||||
|
sendMessage(player, "You use a reel of your thread.");
|
||||||
}
|
}
|
||||||
int charge = thread.getCharge();
|
setAttribute(player, "/save:threadCharges", charges);
|
||||||
thread.setCharge(charge + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method used to remove thread.
|
|
||||||
* @param player the player.
|
|
||||||
*/
|
|
||||||
public static void removeThread(final Player player) {
|
|
||||||
if (player.getInventory().remove(THREAD)) {
|
|
||||||
player.getPacketDispatch().sendMessage("You use a reel of your thread.");
|
|
||||||
Item thread = getThread(player);
|
|
||||||
if (thread != null) {
|
|
||||||
thread.setCharge(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the thread.
|
|
||||||
* @param player the player.
|
|
||||||
* @return the item.
|
|
||||||
*/
|
|
||||||
public static Item getThread(final Player player) {
|
|
||||||
return player.getInventory().get(player.getInventory().getSlot(THREAD));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,6 @@ public final class SnakeSkinPulse extends SkillPulse<Item> {
|
||||||
player.getInventory().add(item);
|
player.getInventory().add(item);
|
||||||
player.getSkills().addExperience(Skills.CRAFTING, skin.getExperience(), true);
|
player.getSkills().addExperience(Skills.CRAFTING, skin.getExperience(), true);
|
||||||
LeatherCrafting.decayThread(player);
|
LeatherCrafting.decayThread(player);
|
||||||
if (LeatherCrafting.isLastThread(player)) {
|
|
||||||
LeatherCrafting.removeThread(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
amount--;
|
amount--;
|
||||||
return amount < 1;
|
return amount < 1;
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,6 @@ public final class SoftCraftPulse extends SkillPulse<Item> {
|
||||||
player.getInventory().add(item);
|
player.getInventory().add(item);
|
||||||
player.getSkills().addExperience(Skills.CRAFTING, soft.getExperience(), true);
|
player.getSkills().addExperience(Skills.CRAFTING, soft.getExperience(), true);
|
||||||
LeatherCrafting.decayThread(player);
|
LeatherCrafting.decayThread(player);
|
||||||
if (LeatherCrafting.isLastThread(player)) {
|
|
||||||
LeatherCrafting.removeThread(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (soft == LeatherCrafting.SoftLeather.GLOVES) {
|
if (soft == LeatherCrafting.SoftLeather.GLOVES) {
|
||||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 1, 3);
|
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 1, 3);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
package content.global.skill.smithing.smelting;
|
package content.global.skill.smithing.smelting;
|
||||||
|
|
||||||
import static core.api.ContentAPIKt.*;
|
import static core.api.ContentAPIKt.*;
|
||||||
|
|
||||||
|
import core.api.Container;
|
||||||
import core.api.EquipmentSlot;
|
import core.api.EquipmentSlot;
|
||||||
import core.game.event.ResourceProducedEvent;
|
import core.game.event.ResourceProducedEvent;
|
||||||
import core.game.container.impl.EquipmentContainer;
|
import core.game.container.impl.EquipmentContainer;
|
||||||
|
import core.tools.Log;
|
||||||
import org.rs09.consts.Items;
|
import org.rs09.consts.Items;
|
||||||
import core.game.world.map.Location;
|
import core.game.world.map.Location;
|
||||||
import core.game.node.entity.skill.SkillPulse;
|
import core.game.node.entity.skill.SkillPulse;
|
||||||
|
|
@ -174,16 +177,6 @@ public class SmeltingPulse extends SkillPulse<Item> {
|
||||||
return amount < 1;
|
return amount < 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the player has a ring of forging.
|
|
||||||
*
|
|
||||||
* @param player the player.
|
|
||||||
* @return {@code True} if so.
|
|
||||||
*/
|
|
||||||
public boolean hasForgingRing(Player player) {
|
|
||||||
return player.getEquipment().containsItem(RING_OF_FORGING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the forging is a succes.
|
* Checks if the forging is a succes.
|
||||||
*
|
*
|
||||||
|
|
@ -192,16 +185,18 @@ public class SmeltingPulse extends SkillPulse<Item> {
|
||||||
*/
|
*/
|
||||||
public boolean success(Player player) {
|
public boolean success(Player player) {
|
||||||
if (bar == Bar.IRON && !superHeat) {
|
if (bar == Bar.IRON && !superHeat) {
|
||||||
if (hasForgingRing(player)) {
|
if (inEquipment(player, Items.RING_OF_FORGING_2568, 1)) {
|
||||||
Item ring = getItemFromEquipment(player, EquipmentSlot.RING);
|
int charges = getAttribute(player, "ringOfForgingCharges", 140) - 1;
|
||||||
if(ring != null){
|
if (charges <= 0) {
|
||||||
if(getCharge(ring) == 1000) setCharge(ring, 140);
|
if (removeItem(player, Items.RING_OF_FORGING_2568, Container.EQUIPMENT)) {
|
||||||
adjustCharge(ring, -1);
|
charges = 140;
|
||||||
if(getCharge(ring) == 0){
|
|
||||||
player.getEquipment().remove(ring);
|
|
||||||
sendMessage(player, "Your ring of forging uses up its last charge and disintegrates.");
|
sendMessage(player, "Your ring of forging uses up its last charge and disintegrates.");
|
||||||
|
} else {
|
||||||
|
log(this.getClass(), Log.ERR, "Failed to delete empty ring of forging for player " + player.getName());
|
||||||
|
return false; //unfair but prevents exploit if the impossible happens
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setAttribute(player, "/save:ringOfForgingCharges", charges);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return RandomFunction.nextBool();
|
return RandomFunction.nextBool();
|
||||||
|
|
|
||||||
|
|
@ -135,9 +135,6 @@ public class YakArmourPlugin extends UseWithHandler {
|
||||||
player.getInventory().add(node);
|
player.getInventory().add(node);
|
||||||
player.getSkills().addExperience(Skills.CRAFTING, 32, true);
|
player.getSkills().addExperience(Skills.CRAFTING, 32, true);
|
||||||
LeatherCrafting.decayThread(player);
|
LeatherCrafting.decayThread(player);
|
||||||
if (LeatherCrafting.isLastThread(player)) {
|
|
||||||
LeatherCrafting.removeThread(player);
|
|
||||||
}
|
|
||||||
player.sendMessage("You make " + node.getName().toLowerCase() + ".");
|
player.sendMessage("You make " + node.getName().toLowerCase() + ".");
|
||||||
}
|
}
|
||||||
amount--;
|
amount--;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue