diff --git a/Server/data/configs/item_configs.json b/Server/data/configs/item_configs.json index 16609aa7a..6fade0e39 100644 --- a/Server/data/configs/item_configs.json +++ b/Server/data/configs/item_configs.json @@ -25493,6 +25493,7 @@ { "shop_price": "140", "grand_exchange_price": "140", + "examine": "Bones are for burying!", "durability": null, "name": "Bones", "tradeable": "true", @@ -30805,55 +30806,62 @@ "examine": "These blackened Jogre bones have been somehow burnt.", "durability": null, "name": "Burnt jogre bones", + "tradeable": "false", "weight": "0.8", "archery_ticket_price": "0", "id": "3127" }, { - "examine": "See article", + "examine": "Burnt Jogre bones smothered with raw Karambwanji Paste.", "durability": null, "name": "Pasty jogre bones", - "weight": "1", + "tradeable": "false", + "weight": "0.8", "archery_ticket_price": "0", "id": "3128" }, { - "examine": "See article", + "examine": "Burnt Jogre bones smothered with cooked Karambwanji paste.", "durability": null, "name": "Pasty jogre bones", - "weight": "1", + "tradeable": "false", + "weight": "0.8", "archery_ticket_price": "0", "id": "3129" }, { - "examine": "Burnt Jogre bones marinated in lovely Karambwanji sauce. Perfect./Burnt Jogre bones marinated in lovely Karabwanji sauce. Not quite right.", + "examine": "Burnt Jogre bones marinated in a lovely Karambwanji sauce. Perfect.", "durability": null, "name": "Marinated j' bones", - "weight": "1", + "tradeable": "false", + "weight": "0.8", "archery_ticket_price": "0", "id": "3130" }, { - "examine": "See article", + "examine": "Jogre bones smothered with raw Karambwanji paste.", "durability": null, "name": "Pasty jogre bones", - "weight": "1", + "tradeable": "false", + "weight": "0.8", "archery_ticket_price": "0", "id": "3131" }, { - "examine": "See article", + "examine": "Jogre bones smothered with cooked Karambwanji paste.", "durability": null, "name": "Pasty jogre bones", - "weight": "1", + "tradeable": "false", + "weight": "0.8", "archery_ticket_price": "0", "id": "3132" }, { - "examine": "Burnt Jogre bones marinated in lovely Karambwanji sauce. Perfect./Burnt Jogre bones marinated in lovely Karabwanji sauce. Not quite right.", + "examine": "Jogre Bones marinated in Karambwanji sauce. Not quite right.", "durability": null, "name": "Marinated j' bones", - "weight": "1", + "tradeable": "false", + "weight": "0.8", "archery_ticket_price": "0", "id": "3133" }, @@ -31352,7 +31360,7 @@ "id": "3178" }, { - "examine": "These are small/medium sized monkey bones.", + "examine": "These are smallish monkey bones.", "grand_exchange_price": "383", "durability": null, "name": "Monkey bones", @@ -31362,7 +31370,7 @@ "id": "3179" }, { - "examine": "These are small/medium sized monkey bones.", + "examine": "These are medium sized monkey bones.", "grand_exchange_price": "383", "durability": null, "name": "Monkey bones", @@ -31372,7 +31380,7 @@ "id": "3180" }, { - "examine": "These are small/medium sized monkey bones.", + "examine": "These are quite large monkey bones.", "grand_exchange_price": "383", "durability": null, "name": "Monkey bones", @@ -31382,7 +31390,7 @@ "id": "3181" }, { - "examine": "These are small/medium sized monkey bones.", + "examine": "These are quite large monkey bones.", "grand_exchange_price": "383", "durability": null, "name": "Monkey bones", @@ -31393,7 +31401,7 @@ }, { "ge_buy_limit": "10000", - "examine": "These are small/medium sized monkey bones.", + "examine": "These are small monkey bones.", "grand_exchange_price": "588", "durability": null, "name": "Monkey bones", @@ -31412,7 +31420,7 @@ "id": "3184" }, { - "examine": "These are small/medium sized monkey bones.", + "examine": "These are smallish monkey bones. They smell extremely nauseating.", "grand_exchange_price": "383", "durability": null, "name": "Monkey bones", @@ -31422,7 +31430,7 @@ "id": "3185" }, { - "examine": "These are small/medium sized monkey bones.", + "examine": "These are small monkey bones. They smell extremely nauseating.", "grand_exchange_price": "383", "durability": null, "name": "Monkey bones", @@ -38950,7 +38958,7 @@ "id": "4255" }, { - "examine": "A pot of crushed bones.", + "examine": "A pot of crushed small ninja monkey bones.", "durability": null, "name": "Bonemeal", "weight": "1", @@ -38974,7 +38982,7 @@ "id": "4258" }, { - "examine": "A pot of crushed monkey bones.", + "examine": "A pot of crushed burnt jogre bones.", "durability": null, "name": "Bonemeal", "weight": "1", @@ -39062,7 +39070,7 @@ "id": "4269" }, { - "examine": "A pot of crushed [type of bones].", + "examine": "A pot of crushed medium ninja monkey bones.", "durability": null, "name": "Bonemeal", "weight": "1", @@ -44036,7 +44044,7 @@ "id": "4854" }, { - "examine": "A pot of crushed [type of bones].", + "examine": "A pot of crushed gorilla monkey bones.", "durability": null, "name": "Bonemeal", "weight": "1", @@ -50115,7 +50123,7 @@ "stand_turn_anim": "330" }, { - "examine": "A pot of crushed [type of bones].", + "examine": "A pot of crushed bearded gorilla monkey bones.", "durability": null, "name": "Bonemeal", "weight": "1", @@ -61087,7 +61095,7 @@ "id": "6727" }, { - "examine": "A pot of crushed [type of bones].", + "examine": "A pot of crushed small zombie monkey bones.", "durability": null, "name": "Bonemeal", "weight": "1", @@ -61847,7 +61855,7 @@ "bonuses": "0,0,0,-31,-18,43,45,41,-4,68,20,0,0,0,0" }, { - "examine": "A pot of crushed [type of bones].", + "examine": "A pot of crushed large zombie monkey bones.", "durability": null, "name": "Bonemeal", "weight": "1", @@ -130993,4 +131001,4 @@ "name": "ASDT Slot", "id": "14430" } -] +] \ No newline at end of file diff --git a/Server/src/main/content/global/bots/GreenDragonKiller.kt b/Server/src/main/content/global/bots/GreenDragonKiller.kt index 6c8dcd82e..740fb7cd0 100644 --- a/Server/src/main/content/global/bots/GreenDragonKiller.kt +++ b/Server/src/main/content/global/bots/GreenDragonKiller.kt @@ -1,5 +1,7 @@ package content.global.bots +import content.global.skill.prayer.BoneBuryListener +import core.api.submitIndividualPulse import core.game.interaction.DestinationFlag import core.game.interaction.MovementPulse import core.game.node.entity.Entity @@ -7,7 +9,6 @@ import core.game.node.entity.combat.CombatStyle import core.game.node.entity.combat.InteractionType import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills -import content.global.skill.prayer.BoneBuryingOptionPlugin import core.game.node.item.Item import core.game.system.task.Pulse import core.game.world.map.Location @@ -21,6 +22,7 @@ import core.game.bots.CombatBotAssembler import core.game.bots.Script import core.game.interaction.IntType import core.game.interaction.InteractionListeners +import core.game.node.Node import core.game.node.entity.combat.CombatSwingHandler import core.game.node.entity.combat.MeleeSwingHandler import kotlin.random.Random @@ -224,7 +226,7 @@ class GreenDragonKiller(val style: CombatStyle, area: ZoneBorders? = null) : Scr private fun attemptToBuryBone() { if (bot.inventory.containsAtLeastOneItem(Items.DRAGON_BONES_536)) { - BoneBuryingOptionPlugin().handle(bot, bot.inventory.get(Item(Items.DRAGON_BONES_536)), "bury") + InteractionListeners.run(Items.DRAGON_BONES_536, IntType.ITEM, "bury", bot, bot.inventory.get(Item(Items.DRAGON_BONES_536))) } } diff --git a/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java b/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java index 70a5eeb81..e681c861d 100644 --- a/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java +++ b/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java @@ -36,12 +36,12 @@ public class BoneOfferPlugin extends UseWithHandler { * The offer Animation. */ private final Animation ANIM = new Animation(896); - + /** * Constructor. */ public BoneOfferPlugin() { - super(526, 2859, 528, 3183, 3179, 530, 532, 3125, 4812, 3123, 534, 6812, 536, 4830, 4832, 6729, 4834, 14693); + super(526, 528, 530, 532, 534, 536, 2530, 2859, 3123, 3125, 3127, 3179, 3180, 3181, 3182, 3183, 3185, 3186, 3187, 4812, 4830, 4832, 4834, 6729, 6812); } @Override diff --git a/Server/src/main/content/global/skill/prayer/BoneBuryListener.kt b/Server/src/main/content/global/skill/prayer/BoneBuryListener.kt new file mode 100644 index 000000000..e8b93e25c --- /dev/null +++ b/Server/src/main/content/global/skill/prayer/BoneBuryListener.kt @@ -0,0 +1,74 @@ +package content.global.skill.prayer + +import core.api.* +import core.game.event.BoneBuryEvent +import core.game.interaction.Clocks +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.player.Player +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import org.rs09.consts.Animations +import org.rs09.consts.Sounds + +class BoneBuryListener : InteractionListener { + override fun defineListeners() { + /** + * Handles the bury options for bones in Bones.kt + */ + on(Bones.array, IntType.ITEM, "bury") { player, node -> + val bones = Bones.forId(node.id) ?: return@on true + + // Checks if the player is delayed from burying a bone and begins the clock if none exists. + if (!clockReady(player, Clocks.SKILLING)) { + return@on true + } else { + delayClock(player, Clocks.SKILLING, 2) + } + + // Verifies the bones are in the player's inventory. + if (!inInventory(player, bones.itemId)) { + return@on true + } + + // Replaces the bones slot in the inventory with nothing and checks that the bones are removed. + if (replaceSlot(player, node.asItem().slot, Item()) != node.asItem()) { + sendMessage(player, "The gods intervene and you keep your bones!") + return@on true + } + + buryBones(player, bones) + return@on true + } + } + + /** + * Buries the bones + * @param player the player burying the bones + * @param bones the bones being buried + */ + private fun buryBones(player: Player, bones: Bones): Boolean { + queueScript(player, 0) { stage -> + when (stage) { + 0 -> { + stopWalk(player) + lock(player, 2) + animate(player, Animations.HUMAN_BURYING_BONES_827) + playAudio(player, Sounds.BONES_DOWN_2738) + sendMessage(player, "You dig a hole in the ground.") + return@queueScript delayScript(player, 2) + } + + 1 -> { + sendMessage(player, "You bury the bones.") + rewardXP(player, Skills.PRAYER, bones.experience) + player.dispatch(BoneBuryEvent(bones.itemId)) + return@queueScript stopExecuting(player) + } + + else -> return@queueScript stopExecuting(player) + } + } + return true + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/prayer/BoneBuryingOptionPlugin.java b/Server/src/main/content/global/skill/prayer/BoneBuryingOptionPlugin.java deleted file mode 100644 index f11feebe3..000000000 --- a/Server/src/main/content/global/skill/prayer/BoneBuryingOptionPlugin.java +++ /dev/null @@ -1,83 +0,0 @@ -package content.global.skill.prayer; - -import core.cache.def.impl.ItemDefinition; -import core.game.event.BoneBuryEvent; -import core.plugin.Initializable; -import core.game.node.entity.skill.Skills; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.game.system.task.Pulse; -import core.game.world.GameWorld; -import core.game.world.update.flag.context.Animation; -import core.plugin.Plugin; -import org.rs09.consts.Sounds; - -import static core.api.ContentAPIKt.playAudio; - -/** - * Represents the bone bury option plugin. - * @author Vexia - */ -@Initializable -public final class BoneBuryingOptionPlugin extends OptionHandler { - - /** - * Represents the animation to use. - */ - private static final Animation ANIMATION = new Animation(827); - - - @Override - public boolean handle(final Player player, Node node, String option) { - if (player.getAttribute("delay:bury", -1) > GameWorld.getTicks()) { - return true; - } - player.setAttribute("delay:bury", GameWorld.getTicks() + 2); - final Item item = (Item) node; - Bones bone = Bones.forId(item.getId()); - if (bone == null) { - bone = Bones.BONES; - } - if (item.getSlot() < 0) { - return false; - } - boolean remove = true; - if (!remove) { - player.sendMessage("The gods intervene and you keep your bones!"); - } - if (remove) { - if (player.getInventory().replace(null, item.getSlot()) != item) { - return false; - } - } - player.lock(2); - player.animate(ANIMATION); - player.getPacketDispatch().sendMessage("You dig a hole in the ground..."); - playAudio(player, Sounds.BONES_DOWN_2738); - final Bones bonee = bone; - GameWorld.getPulser().submit(new Pulse(2, player) { - @Override - public boolean pulse() { - player.getPacketDispatch().sendMessage("You bury the bones."); - player.getSkills().addExperience(Skills.PRAYER, bonee.equals(Bones.LAVA_DRAGON_BONES) && player.getLocation().getY() >= 3794 && player.getLocation().getY() <= 3859 ? bonee.getExperience() * 3 : bonee.getExperience(), true); - player.dispatch(new BoneBuryEvent(bonee.getItemId())); - return true; - } - }); - return true; - } - - @Override - public boolean isWalk() { - return false; - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - ItemDefinition.setOptionHandler("bury", this); - return this; - } - -} diff --git a/Server/src/main/content/global/skill/prayer/Bones.kt b/Server/src/main/content/global/skill/prayer/Bones.kt index f6c47f01d..755a8062b 100644 --- a/Server/src/main/content/global/skill/prayer/Bones.kt +++ b/Server/src/main/content/global/skill/prayer/Bones.kt @@ -1,73 +1,64 @@ package content.global.skill.prayer -import core.game.node.item.Item -import java.util.ArrayList -import java.util.HashMap +import org.rs09.consts.Items /** * Represents the type of bones. * @author Apache Ah64 */ -enum class Bones -/** - * Construct a new `Bones` `Object`. - * @param itemId The item id. - * @param experience The experience given by burying the bone. - */( - /** - * The bone item id. - */ - val itemId: Int, - /** - * The experience given by burying the bone. - */ - val experience: Double) { - BONES(2530, 4.5), - BONES_2(526, 4.5), - WOLF_BONES(2859, 4.5), - BURNT_BONES(528, 4.5), - MONKEY_BONES(3183, 5.0), - MONKEY_BONES2(3179, 5.0), - BAT_BONES(530, 5.3), - BIG_BONES(532, 15.0), - JOGRE_BONES(3125, 15.0), - ZOGRE_BONES(4812, 12.5), - SHAIKAHAN_BONES(3123, 25.0), - BABY_DRAGON_BONES(534, 30.0), - WYVERN_BONES(6812, 50.0), - DRAGON_BONES(536, 72.0), - FAYRG(4830, 84.0), - RAURG_BONES(4832, 96.0), - DAGANNOTH(6729, 125.0), - OURG_BONES(4834, 140.0), - LAVA_DRAGON_BONES(14693, 85.0); +enum class Bones( /** - * Get the bone experience given when you bury the bone. - * @return The experience. + * Construct a new `Bones` `Object`. + * @param itemId The item id. + * @param experience The experience given by burying the bone. */ /** - * Gets the bone meal item. - * @return the item. + * The bone item id. */ - val boneMeal: Item - get() { - return when(this){ - FAYRG -> Item(4852) - RAURG_BONES -> Item(4853) - OURG_BONES -> Item(4854) - else -> Item(4255 + ordinal) - } - } + val itemId: Int, /** - * Gets the config value for the bone type. - * @param hopper the hopper. - * @return the value. + * The experience given by burying the bone. */ - fun getConfigValue(hopper: Boolean): Int { - return (if (this == BONES_2) ordinal else ordinal - 1) or (if (hopper) 4 else 8) shl 16 - } + val experience: Double, + + /** + * The bones' bonemeal item id if applicable. + */ + val bonemealId: Int?, +) { + BONES(Items.BONES_526, 4.5, Items.BONEMEAL_4255), + BONES_2(Items.BONES_2530, 4.5, Items.BONEMEAL_4255), + BONES_3(Items.BONES_3187, 4.5, Items.BONEMEAL_4255), + WOLF_BONES(Items.WOLF_BONES_2859, 4.5, Items.BONEMEAL_4257), + BURNT_BONES(Items.BURNT_BONES_528, 4.5, Items.BONEMEAL_4258), + SMALL_NINJA_MONKEY_BONES(Items.MONKEY_BONES_3179, 16.0, Items.BONEMEAL_4256), + MEDIUM_NINJA_MONKEY_BONES(Items.MONKEY_BONES_3180, 18.0, Items.BONEMEAL_4270), + GORILLA_BONES(Items.MONKEY_BONES_3181, 18.0, Items.BONEMEAL_4855), + BEARDED_GORILLA_BONES(Items.MONKEY_BONES_3182, 18.0, Items.BONEMEAL_5615), + KARAMJA_MONKEY_BONES(Items.MONKEY_BONES_3183, 5.0, Items.BONEMEAL_4260), + SMALL_ZOMBIE_MONKEY_BONES(Items.MONKEY_BONES_3185, 5.0, Items.BONEMEAL_6728), + LARGE_ZOMBIE_MONKEY_BONES(Items.MONKEY_BONES_3186, 5.0, Items.BONEMEAL_6810), + BAT_BONES(Items.BAT_BONES_530, 5.3, Items.BONEMEAL_4261), + BIG_BONES(Items.BIG_BONES_532, 15.0, Items.BONEMEAL_4262), + JOGRE_BONES(Items.JOGRE_BONES_3125, 15.0, Items.BONEMEAL_4263), + ZOGRE_BONES(Items.ZOGRE_BONES_4812, 22.5, Items.BONEMEAL_4264), + SHAIKAHAN_BONES(Items.SHAIKAHAN_BONES_3123, 25.0, Items.BONEMEAL_4265), + BABY_DRAGON_BONES(Items.BABYDRAGON_BONES_534, 30.0, Items.BONEMEAL_4266), + WYVERN_BONES(Items.WYVERN_BONES_6812, 50.0, Items.BONEMEAL_4267), //The bonemeal id should be 6810 + DRAGON_BONES(Items.DRAGON_BONES_536, 72.0, Items.BONEMEAL_4268), + FAYRG(Items.FAYRG_BONES_4830, 84.0, Items.BONEMEAL_4852), + RAURG_BONES(Items.RAURG_BONES_4832, 96.0, Items.BONEMEAL_4853), + DAGANNOTH(Items.DAGANNOTH_BONES_6729, 125.0, Items.BONEMEAL_4271), // The bonemeal id should be 6728 + OURG_BONES(Items.OURG_BONES_4834, 140.0, Items.BONEMEAL_4854), + BURNT_JOGRE_BONES(Items.BURNT_JOGRE_BONES_3127, 16.0, Items.BONEMEAL_4259), + BURNT_RAW_PASTY_JOGRE_BONES(Items.PASTY_JOGRE_BONES_3128, 17.0, null), + BURNT_COOKED_PASTY_JOGRE_BONES(Items.PASTY_JOGRE_BONES_3129, 17.0, null), + MARINATED_JOGRE_BONES(Items.MARINATED_J_BONES_3130, 18.0, null), + RAW_PASTY_JOGRE_BONES(Items.PASTY_JOGRE_BONES_3131, 17.0, null), + COOKED_PASTY_JOGRE_BONES(Items.PASTY_JOGRE_BONES_3132, 17.0, null), + MARINATED_JOGRE_BONES_BAD(Items.MARINATED_J_BONES_3133, 18.0, null); companion object { /** @@ -83,23 +74,7 @@ enum class Bones @JvmStatic fun forBoneMeal(itemId: Int): Bones? { for (bone in values()) { - if (bone.boneMeal.id == itemId) { - return bone - } - } - return null - } - - /** - * Gets the config value for the bone. - * @param value the value. - * @param hopper hopper. - * @return `True` if so. - */ - @JvmStatic - fun forConfigValue(value: Int, hopper: Boolean): Bones? { - for (bone in values()) { - if (bone.getConfigValue(hopper) == value) { + if (bone.bonemealId == itemId) { return bone } } diff --git a/Server/src/main/content/region/morytania/phas/handlers/BoneGrinderListener.kt b/Server/src/main/content/region/morytania/phas/handlers/BoneGrinderListener.kt index 1a7a7ab82..9f333e5b2 100644 --- a/Server/src/main/content/region/morytania/phas/handlers/BoneGrinderListener.kt +++ b/Server/src/main/content/region/morytania/phas/handlers/BoneGrinderListener.kt @@ -1,23 +1,23 @@ package content.region.morytania.phas.handlers -import core.api.Container -import core.api.* import content.global.skill.prayer.Bones +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener import core.game.node.entity.impl.PulseType import core.game.node.entity.player.Player import core.game.node.item.Item import core.game.system.task.Pulse +import core.game.world.GameWorld.Pulser import core.game.world.map.Location import core.game.world.update.flag.context.Animation import org.rs09.consts.Items -import core.game.interaction.InteractionListener -import core.game.interaction.IntType -import core.game.world.GameWorld.Pulser +import org.rs09.consts.Scenery import org.rs09.consts.Sounds -private const val LOADER = 11162 -private const val BONE_GRINDER = 11163 -private const val BIN = 11164 +private const val LOADER = Scenery.LOADER_11162 +private const val BONE_GRINDER = Scenery.BONE_GRINDER_11163 +private const val BIN = Scenery.BIN_11164 private const val LOADED_BONE_KEY = "/save:bonegrinder-bones" private const val BONE_HOPPER_KEY = "/save:bonegrinder-hopper" @@ -73,8 +73,12 @@ class BoneGrinderListener : InteractionListener { fun handleFill(player: Player): Boolean{ val bone = getBone(player) - if(bone == null){ - sendMessage(player,"You have no bones to grind.") + if((bone == null) || (bone.bonemealId == null)) { + if (inInventory(player, Items.MARINATED_J_BONES_3130) || inInventory(player, Items.MARINATED_J_BONES_3133)) { + sendDialogue(player, "These bones could break the bone grinder. Perhaps I should find some different bones.") + } else { + sendMessage(player, "You have no bones to grind.") + } return true } if(getAttribute(player, BONE_HOPPER_KEY,false)){ @@ -240,7 +244,7 @@ class BoneGrinderListener : InteractionListener { } SCOOP_ANIM.duration -> { if(removeItem(player,Item(Items.EMPTY_POT_1931),Container.INVENTORY)){ - addItem(player,bone.boneMeal.id) + addItem(player, bone.bonemealId!!) } return true } diff --git a/Server/src/main/content/region/morytania/phas/handlers/PhasmatysZone.java b/Server/src/main/content/region/morytania/phas/handlers/PhasmatysZone.java index 08f4009d8..70131a4ba 100644 --- a/Server/src/main/content/region/morytania/phas/handlers/PhasmatysZone.java +++ b/Server/src/main/content/region/morytania/phas/handlers/PhasmatysZone.java @@ -1,9 +1,8 @@ package content.region.morytania.phas.handlers; -import static core.api.ContentAPIKt.*; - +import content.global.skill.agility.AgilityHandler; import content.global.skill.prayer.Bones; -import content.region.morytania.phas.dialogue.*; +import content.region.morytania.phas.dialogue.NecrovarusDialogue; import core.game.global.action.ClimbActionHandler; import core.game.interaction.Option; import core.game.node.Node; @@ -11,23 +10,24 @@ import core.game.node.entity.Entity; import core.game.node.entity.npc.NPC; import core.game.node.entity.player.Player; import core.game.node.entity.skill.Skills; -import content.global.skill.agility.AgilityHandler; import core.game.node.item.Item; import core.game.node.scenery.Scenery; import core.game.node.scenery.SceneryBuilder; -import core.game.system.task.Pulse; import core.game.world.map.Direction; import core.game.world.map.Location; import core.game.world.map.zone.MapZone; import core.game.world.map.zone.ZoneBorders; import core.game.world.map.zone.ZoneBuilder; import core.game.world.update.flag.context.Animation; +import core.plugin.ClassScanner; import core.plugin.Initializable; import core.plugin.Plugin; import org.rs09.consts.NPCs; -import core.plugin.ClassScanner; import org.rs09.consts.Sounds; +import static core.api.ContentAPIKt.playAudio; +import static core.api.ContentAPIKt.sendMessage; + /** * Handles the phasmatys zone area. * @@ -39,8 +39,6 @@ public final class PhasmatysZone extends MapZone implements Plugin { Bones[] bones; Player player; Bones bone; - boolean notFirst; - /** * Constructs a new {@code PhasmatysZone} {@code Object}. @@ -58,7 +56,6 @@ public final class PhasmatysZone extends MapZone implements Plugin { return this; } - @Override public boolean interact(Entity e, Node target, Option option) { if (e.isPlayer()) { @@ -132,64 +129,6 @@ public final class PhasmatysZone extends MapZone implements Plugin { return super.interact(e, target, option); } - public Pulse emptyPulse = new Pulse(5) { - //the bin - Scenery emptyobj = new Scenery(11164, 3658, 3525, 1); - - @Override - public boolean pulse() { - //player.getProperties().setTeleportLocation(new Location(3658,3524,1)); - player.faceLocation(new Location(3658, 3525, 1)); - empty(player, emptyobj); - player.getWalkingQueue().reset(); - player.getWalkingQueue().addPath(3660, 3524, true); - player.setAttribute("bgfirst?", false); - player.getPulseManager().run(fillPulse); - return true; - } - }; - public Pulse windPulse = new Pulse(5) { - //the crank - Scenery windobj = new Scenery(11163, 3659, 3525, 1); - - @Override - public boolean pulse() { - //player.getProperties().setTeleportLocation(new Location(3659,3524,1)); - player.faceLocation(new Location(3659, 3525, 1)); - wind(player, windobj); - player.getWalkingQueue().reset(); - player.getWalkingQueue().addPath(3658, 3524, true); - player.getPulseManager().run(emptyPulse); - return true; - } - }; - public Pulse fillPulse = new Pulse(5) { - //the hopper - @Override - public boolean pulse() { - if (hasBoneInInventory(player)) { - bone = getBone(player); - } else { - player.debug("No bones in inventory, or bones not in bones array."); - player.setAttribute("bgfirst?", true); - return true; - } - - player.faceLocation(new Location(3660, 3525, 1)); - if (player.getInventory().remove(new Item(bone.getItemId()))) { - player.getLocks().lockInteractions(2); - player.debug("Using bone " + bone.getItemId() + " on grinder.. bone info:" + b); - player.animate(Animation.create(1649)); - setVarp(player, 408, bone.getConfigValue(true), true); - player.sendMessage("You put some bones in the grinder's hopper.", 1); - player.getWalkingQueue().reset(); - player.getWalkingQueue().addPath(3659, 3524, true); - player.getPulseManager().run(windPulse); - } - return true; - } - }; - /** * Checks if the player has the amulet equipped. * @@ -200,108 +139,6 @@ public final class PhasmatysZone extends MapZone implements Plugin { return player.getEquipment().contains(552, 1); } - /** - * Checks the status of a grinder. - * - * @param player the player. - * @param object the object. - */ - private void checkStatus(Player player, Scenery object) { - String status = "The grinder is empty."; - if (hasBones(player, object, true)) { - status = "There are some bones in the hopper."; - } else if (hasBones(player, object, false)) { - status = "There are some crushed bones in the bin."; - } - player.sendMessage(status); - } - - /** - * Emptys the grinder. - * - * @param player the player. - * @param object the object. - */ - private void empty(Player player, Scenery object) { - if (hasBones(player, object, true)) { - player.sendMessage("You need to wind the handle to grind the bones."); - return; - } - if (!hasBones(player, object, false)) { - player.sendMessage("The grinder is already empty."); - return; - } - if (!player.getInventory().contains(1931, 1)) { - player.sendMessage("You need an empty pot to put the crushed bones into."); - return; - } - final Bones bone = Bones.forConfigValue(getVarp(player, 408), false); - player.getLocks().lockInteractions(2); - player.animate(Animation.create(1650)); - setVarp(player, 408, 0, true); - player.sendMessage("You fill a pot with crushed bones."); - player.getInventory().replace(bone.getBoneMeal(), player.getInventory().getSlot(new Item(1931))); - } - - /** - * Windws the grinder. - * - * @param player the player. - * @param object the object. - */ - private void wind(Player player, Scenery object) { - final Bones bone = Bones.forConfigValue(getVarp(player, 408), true); - player.getLocks().lockInteractions(3); - player.animate(Animation.create(1648)); - player.sendMessage("You wind the grinder handle."); - if (hasBones(player, object, true)) { - setVarp(player, 408, bone.getConfigValue(false), true); - player.sendMessage("Some crushed bones pour into the bin.", 3); - } - } - - /** - * Checks if bones are in the hopper. - * - * @param player the player. - * @param inHopper in the hopper or in the bin. - * @param object the object. - * @return {@code True} if so. - */ - public static boolean hasBones(Player player, Scenery object, boolean inHopper) { - int value = getVarp(player, 408); - for (Bones bone : Bones.values()) { - if (bone.getConfigValue(inHopper) == value) { - return true; - } - } - return false; - } - - public static boolean hasBoneInInventory(Player player) { - Bones[] bones = Bones.values(); - for (int c = 0; c < bones.length; c++) { - Bones bone = bones[c]; - int boneId = bone.getItemId(); - if (player.getInventory().containsItem(new Item(boneId))) { - return true; - } - } - return false; - } - - public static Bones getBone(Player player) { - Bones[] bones = Bones.values(); - for (int b = 0; b < bones.length; b++) { - Bones bone = bones[b]; - int boneId = bone.getItemId(); - if (player.getInventory().containsItem(new Item(boneId))) { - return bone; - } - } - return null; - } - /** * Worships the ectofuntus. * @@ -331,7 +168,7 @@ public final class PhasmatysZone extends MapZone implements Plugin { player.getDialogueInterpreter().sendDialogue("You need ectoplasm to put into the Ectofuntus."); return; } - if (player.getInventory().remove(bone.getBoneMeal(), new Item(4286, 1))) { + if (player.getInventory().remove(new Item(bone.getBonemealId()), new Item(4286, 1))) { player.lock(1); player.animate(Animation.create(1651)); playAudio(player, Sounds.PRAYER_BOOST_2671);