Fixed loss of draconic visages if used on an anvil without an anti-dragon shield in the player's inventory

Fixed dragonfire shield and dragon square shield smithing not checking for a hammer in inventory
This commit is contained in:
Player Name 2025-02-01 13:18:19 +00:00 committed by Ryan
parent 6c386e6ed2
commit 57f5617fe8

View file

@ -1,55 +1,23 @@
package content.global.skill.smithing; package content.global.skill.smithing;
import content.global.skill.skillcapeperks.SkillcapePerks;
import core.api.Container;
import core.game.dialogue.DialoguePlugin; import core.game.dialogue.DialoguePlugin;
import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player; import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.plugin.Initializable; import core.plugin.Initializable;
import core.game.world.update.flag.context.Animation; import org.rs09.consts.Items;
import static core.api.ContentAPIKt.*;
/** /**
* Represents the dialogue plugin used for making a dragon shield. * Represents the dialogue plugin used for making a dragon shield.
* @author 'Vexia * @author 'Vexia
* @version 1.0 * @author Player Name
* @version 1.1
*/ */
@Initializable @Initializable
public final class DragonShieldDialogue extends DialoguePlugin { public final class DragonShieldDialogue extends DialoguePlugin {
/**
* Represents the item shield parts.
*/
private static final Item[] SHIELD_PARTS = new Item[] { new Item(2366), new Item(2368) };
/**
* Represents th edraconic visage item.
*/
private static final Item DRACONIC_VISAGE = new Item(11286);
/**
* Represents the anti dragon fire shield.
*/
private static final Item ANTI_DRAGONSHIELD = new Item(1540);
/**
* Represents the dragon fire shield item.
*/
private static final Item DRAGON_FIRESHIELD = new Item(11284);
/**
* Represents the shield item.
*/
private static final Item SQ_SHIELD = new Item(1187);
/**
* Represents the hammering animation.
*/
private static Animation ANIMATION = new Animation(898);
/**
* Represents the shield type.
*/
private int type;
/** /**
* Constructs a new {@code DragonShieldDialogue} {@code Object}. * Constructs a new {@code DragonShieldDialogue} {@code Object}.
*/ */
@ -74,11 +42,26 @@ public final class DragonShieldDialogue extends DialoguePlugin {
@Override @Override
public boolean open(Object... args) { public boolean open(Object... args) {
type = (int) args[0]; if (!inInventory(player, Items.HAMMER_2347, 1) && !SkillcapePerks.isActive(SkillcapePerks.BAREFISTED_SMITHING, player)) {
interpreter.sendDialogue("You need a hammer to work the metal with.");
}
int type = (int) args[0];
if (type == 1) { if (type == 1) {
interpreter.sendDialogue("You set to work trying to fix the ancient shield. It's seen some", "heavy reward and needs some serious work doing to it."); if (!(inInventory(player, Items.SHIELD_RIGHT_HALF_2368, 1) && inInventory(player, Items.SHIELD_LEFT_HALF_2366, 1))) {
interpreter.sendDialogue("You need the other half of the shield."); //todo authentic message
return false;
}
interpreter.sendDialogue("You set to work trying to fix the ancient shield. It's seen some", "heavy action and needs some serious work doing to it.");
stage = 0; stage = 0;
} else { } else {
if (!inInventory(player, Items.ANTI_DRAGON_SHIELD_1540, 1)) {
interpreter.sendDialogue("You need an anti-dragon shield to attach the visage to."); //todo authentic message
return false;
}
if (!inInventory(player, Items.DRACONIC_VISAGE_11286, 1)) {
interpreter.sendDialogue("You don't have anything you could attach to the shield."); //todo authentic message
return false;
}
interpreter.sendDialogue("You set to work, trying to attach the ancient draconic", "visage to your anti-dragonbreath shield. It's not easy to", "work with the ancient artifact and it takes all of your", "skills as a master smith."); interpreter.sendDialogue("You set to work, trying to attach the ancient draconic", "visage to your anti-dragonbreath shield. It's not easy to", "work with the ancient artifact and it takes all of your", "skills as a master smith.");
stage = 10; stage = 10;
} }
@ -89,26 +72,26 @@ public final class DragonShieldDialogue extends DialoguePlugin {
public boolean handle(int interfaceId, int buttonId) { public boolean handle(int interfaceId, int buttonId) {
switch (stage) { switch (stage) {
case 0: case 0:
player.lock(5); lock(player, 5);
player.animate(ANIMATION); animate(player, 898, false);
interpreter.sendDialogue("Even for an experienced armourer it is not an easy task, but", "eventually it is ready. You have restored the dragon square shield to", "its former glory."); if (removeItem(player, Items.SHIELD_RIGHT_HALF_2368, Container.INVENTORY) && removeItem(player, Items.SHIELD_LEFT_HALF_2366, Container.INVENTORY)) {
if (player.getInventory().remove(SHIELD_PARTS)) { interpreter.sendDialogue("Even for an experienced armourer it is not an easy task, but", "eventually it is ready. You have restored the dragon square shield to", "its former glory.");
player.getInventory().add(SQ_SHIELD); addItem(player, Items.DRAGON_SQ_SHIELD_1187, 1, Container.INVENTORY);
rewardXP(player, Skills.SMITHING, 75);
} }
player.getSkills().addExperience(Skills.SMITHING, 75, true);
stage = 1; stage = 1;
break; break;
case 1: case 1:
end(); end();
break; break;
case 10: case 10:
player.lock(5); lock(player, 5);
player.animate(ANIMATION); animate(player, 898, false);
interpreter.sendDialogue("Even for an experienced armourer it is not an easy task, but", "eventually it is ready. You have crafted the", "draconic visage and anti-dragonbreath shield into a", "dragonfire shield."); if (removeItem(player, Items.ANTI_DRAGON_SHIELD_1540, Container.INVENTORY) && removeItem(player, Items.DRACONIC_VISAGE_11286, Container.INVENTORY)) {
if (player.getInventory().remove(DRACONIC_VISAGE, ANTI_DRAGONSHIELD)) { interpreter.sendDialogue("Even for an experienced armourer it is not an easy task, but", "eventually it is ready. You have crafted the", "draconic visage and anti-dragonbreath shield into a", "dragonfire shield.");
player.getInventory().add(DRAGON_FIRESHIELD); addItem(player, Items.DRAGONFIRE_SHIELD_11284, 1, Container.INVENTORY);
rewardXP(player, Skills.SMITHING, 2000);
} }
player.getSkills().addExperience(Skills.SMITHING, 2000);
stage = 1; stage = 1;
break; break;
} }