equip graphics

This commit is contained in:
aidan 2026-07-07 09:46:34 -05:00
parent e009d55ab2
commit 4c17d1f37c
2 changed files with 95 additions and 1 deletions

View file

@ -0,0 +1,73 @@
package content.global.handlers.item.equipment
import content.data.Quests
import core.api.*
import core.game.interaction.InteractionListener
import core.game.interaction.QueueStrength
import core.game.node.entity.player.Player
import core.game.world.update.flag.context.Graphics
import org.rs09.consts.Items
/**
* The graphics that run when you equip elemental equipment.
*/
class ElementalEquipmentGraphics : InteractionListener {
// the graphics that run on equip
private val mShieldEquip = 809
private val mHelmEquip = 810
private val eShieldEquip = 244
private val eHelmEquip = 811
override fun defineListeners() {
onEquip(Items.ELEMENTAL_SHIELD_2890) { player, _ ->
equipShield(player, Quests.ELEMENTAL_WORKSHOP_I, eShieldEquip)
}
onEquip(Items.MIND_SHIELD_9731) { player, _ ->
equipShield(player, Quests.ELEMENTAL_WORKSHOP_II, mShieldEquip)
}
onEquip(Items.ELEMENTAL_HELMET_9729) { player, _ ->
equipHelm(player, Quests.ELEMENTAL_WORKSHOP_II, eHelmEquip)
}
onEquip(Items.MIND_HELMET_9733) { player, _ ->
equipHelm(player, Quests.ELEMENTAL_WORKSHOP_II, mHelmEquip)
}
}
private fun equipShield(player: Player, quest: Quests, gfxId: Int): Boolean {
if (!isQuestComplete(player, quest)) {
sendMessage(player, "You need to have completed ${quest.questName} to equip this.")
return false
}
// hide the shield while the gfx plays
player.appearance.isHideShield = true
player.updateAppearance()
visualize(player, -1, Graphics(gfxId, 95))
// unhide the shield
queueScript(player, 2, QueueStrength.SOFT) {
player.appearance.isHideShield = false
player.updateAppearance()
stopExecuting(player)
}
return true
}
private fun equipHelm(player: Player, quest: Quests, gfxId: Int): Boolean {
if (!isQuestComplete(player, quest)) {
sendMessage(player, "You need to have completed ${quest.questName} to equip this.")
return false
}
// play the graphics
visualize(player, -1, gfxId)
return true
}
}

View file

@ -64,6 +64,11 @@ public final class Appearance {
*/
private boolean ridingMinecart;
/**
* If the player's shield should be hidden (like when equipping elemental shields).
*/
private boolean hideShield;
/**
* Constructs a new {@code Appearance} {@code Object}.
* @param player the player of this appearance.
@ -279,7 +284,7 @@ public final class Appearance {
} else {
clearBodyPart(3);
}
if (shield != null) {
if (shield != null && !hideShield) {
drawItem(5, shield);
} else {
clearBodyPart(5);
@ -682,6 +687,22 @@ public final class Appearance {
this.ridingMinecart = ridingMinecart;
}
/**
* Gets the hideShield
* @return the hideShield
*/
public boolean isHideShield() {
return hideShield;
}
/**
* Sets the hideShield
* @param hideShield the hideShield to set.
*/
public void setHideShield(boolean hideShield) {
this.hideShield = hideShield;
}
/**
* Represents a class of cached appearance related information.
* @author 'Vexia