Rewrote bone burying and corrected xp rates

This commit is contained in:
Bonesy 2024-03-16 12:05:46 +00:00 committed by Ryan
parent d9355ec85f
commit dbbcf5601e
8 changed files with 184 additions and 367 deletions

View file

@ -25493,6 +25493,7 @@
{ {
"shop_price": "140", "shop_price": "140",
"grand_exchange_price": "140", "grand_exchange_price": "140",
"examine": "Bones are for burying!",
"durability": null, "durability": null,
"name": "Bones", "name": "Bones",
"tradeable": "true", "tradeable": "true",
@ -30805,55 +30806,62 @@
"examine": "These blackened Jogre bones have been somehow burnt.", "examine": "These blackened Jogre bones have been somehow burnt.",
"durability": null, "durability": null,
"name": "Burnt jogre bones", "name": "Burnt jogre bones",
"tradeable": "false",
"weight": "0.8", "weight": "0.8",
"archery_ticket_price": "0", "archery_ticket_price": "0",
"id": "3127" "id": "3127"
}, },
{ {
"examine": "See article", "examine": "Burnt Jogre bones smothered with raw Karambwanji Paste.",
"durability": null, "durability": null,
"name": "Pasty jogre bones", "name": "Pasty jogre bones",
"weight": "1", "tradeable": "false",
"weight": "0.8",
"archery_ticket_price": "0", "archery_ticket_price": "0",
"id": "3128" "id": "3128"
}, },
{ {
"examine": "See article", "examine": "Burnt Jogre bones smothered with cooked Karambwanji paste.",
"durability": null, "durability": null,
"name": "Pasty jogre bones", "name": "Pasty jogre bones",
"weight": "1", "tradeable": "false",
"weight": "0.8",
"archery_ticket_price": "0", "archery_ticket_price": "0",
"id": "3129" "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, "durability": null,
"name": "Marinated j' bones", "name": "Marinated j' bones",
"weight": "1", "tradeable": "false",
"weight": "0.8",
"archery_ticket_price": "0", "archery_ticket_price": "0",
"id": "3130" "id": "3130"
}, },
{ {
"examine": "See article", "examine": "Jogre bones smothered with raw Karambwanji paste.",
"durability": null, "durability": null,
"name": "Pasty jogre bones", "name": "Pasty jogre bones",
"weight": "1", "tradeable": "false",
"weight": "0.8",
"archery_ticket_price": "0", "archery_ticket_price": "0",
"id": "3131" "id": "3131"
}, },
{ {
"examine": "See article", "examine": "Jogre bones smothered with cooked Karambwanji paste.",
"durability": null, "durability": null,
"name": "Pasty jogre bones", "name": "Pasty jogre bones",
"weight": "1", "tradeable": "false",
"weight": "0.8",
"archery_ticket_price": "0", "archery_ticket_price": "0",
"id": "3132" "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, "durability": null,
"name": "Marinated j' bones", "name": "Marinated j' bones",
"weight": "1", "tradeable": "false",
"weight": "0.8",
"archery_ticket_price": "0", "archery_ticket_price": "0",
"id": "3133" "id": "3133"
}, },
@ -31352,7 +31360,7 @@
"id": "3178" "id": "3178"
}, },
{ {
"examine": "These are small/medium sized monkey bones.", "examine": "These are smallish monkey bones.",
"grand_exchange_price": "383", "grand_exchange_price": "383",
"durability": null, "durability": null,
"name": "Monkey bones", "name": "Monkey bones",
@ -31362,7 +31370,7 @@
"id": "3179" "id": "3179"
}, },
{ {
"examine": "These are small/medium sized monkey bones.", "examine": "These are medium sized monkey bones.",
"grand_exchange_price": "383", "grand_exchange_price": "383",
"durability": null, "durability": null,
"name": "Monkey bones", "name": "Monkey bones",
@ -31372,7 +31380,7 @@
"id": "3180" "id": "3180"
}, },
{ {
"examine": "These are small/medium sized monkey bones.", "examine": "These are quite large monkey bones.",
"grand_exchange_price": "383", "grand_exchange_price": "383",
"durability": null, "durability": null,
"name": "Monkey bones", "name": "Monkey bones",
@ -31382,7 +31390,7 @@
"id": "3181" "id": "3181"
}, },
{ {
"examine": "These are small/medium sized monkey bones.", "examine": "These are quite large monkey bones.",
"grand_exchange_price": "383", "grand_exchange_price": "383",
"durability": null, "durability": null,
"name": "Monkey bones", "name": "Monkey bones",
@ -31393,7 +31401,7 @@
}, },
{ {
"ge_buy_limit": "10000", "ge_buy_limit": "10000",
"examine": "These are small/medium sized monkey bones.", "examine": "These are small monkey bones.",
"grand_exchange_price": "588", "grand_exchange_price": "588",
"durability": null, "durability": null,
"name": "Monkey bones", "name": "Monkey bones",
@ -31412,7 +31420,7 @@
"id": "3184" "id": "3184"
}, },
{ {
"examine": "These are small/medium sized monkey bones.", "examine": "These are smallish monkey bones. They smell extremely nauseating.",
"grand_exchange_price": "383", "grand_exchange_price": "383",
"durability": null, "durability": null,
"name": "Monkey bones", "name": "Monkey bones",
@ -31422,7 +31430,7 @@
"id": "3185" "id": "3185"
}, },
{ {
"examine": "These are small/medium sized monkey bones.", "examine": "These are small monkey bones. They smell extremely nauseating.",
"grand_exchange_price": "383", "grand_exchange_price": "383",
"durability": null, "durability": null,
"name": "Monkey bones", "name": "Monkey bones",
@ -38950,7 +38958,7 @@
"id": "4255" "id": "4255"
}, },
{ {
"examine": "A pot of crushed bones.", "examine": "A pot of crushed small ninja monkey bones.",
"durability": null, "durability": null,
"name": "Bonemeal", "name": "Bonemeal",
"weight": "1", "weight": "1",
@ -38974,7 +38982,7 @@
"id": "4258" "id": "4258"
}, },
{ {
"examine": "A pot of crushed monkey bones.", "examine": "A pot of crushed burnt jogre bones.",
"durability": null, "durability": null,
"name": "Bonemeal", "name": "Bonemeal",
"weight": "1", "weight": "1",
@ -39062,7 +39070,7 @@
"id": "4269" "id": "4269"
}, },
{ {
"examine": "A pot of crushed [type of bones].", "examine": "A pot of crushed medium ninja monkey bones.",
"durability": null, "durability": null,
"name": "Bonemeal", "name": "Bonemeal",
"weight": "1", "weight": "1",
@ -44036,7 +44044,7 @@
"id": "4854" "id": "4854"
}, },
{ {
"examine": "A pot of crushed [type of bones].", "examine": "A pot of crushed gorilla monkey bones.",
"durability": null, "durability": null,
"name": "Bonemeal", "name": "Bonemeal",
"weight": "1", "weight": "1",
@ -50115,7 +50123,7 @@
"stand_turn_anim": "330" "stand_turn_anim": "330"
}, },
{ {
"examine": "A pot of crushed [type of bones].", "examine": "A pot of crushed bearded gorilla monkey bones.",
"durability": null, "durability": null,
"name": "Bonemeal", "name": "Bonemeal",
"weight": "1", "weight": "1",
@ -61087,7 +61095,7 @@
"id": "6727" "id": "6727"
}, },
{ {
"examine": "A pot of crushed [type of bones].", "examine": "A pot of crushed small zombie monkey bones.",
"durability": null, "durability": null,
"name": "Bonemeal", "name": "Bonemeal",
"weight": "1", "weight": "1",
@ -61847,7 +61855,7 @@
"bonuses": "0,0,0,-31,-18,43,45,41,-4,68,20,0,0,0,0" "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, "durability": null,
"name": "Bonemeal", "name": "Bonemeal",
"weight": "1", "weight": "1",

View file

@ -1,5 +1,7 @@
package content.global.bots package content.global.bots
import content.global.skill.prayer.BoneBuryListener
import core.api.submitIndividualPulse
import core.game.interaction.DestinationFlag import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse import core.game.interaction.MovementPulse
import core.game.node.entity.Entity 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.combat.InteractionType
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills import core.game.node.entity.skill.Skills
import content.global.skill.prayer.BoneBuryingOptionPlugin
import core.game.node.item.Item import core.game.node.item.Item
import core.game.system.task.Pulse import core.game.system.task.Pulse
import core.game.world.map.Location import core.game.world.map.Location
@ -21,6 +22,7 @@ import core.game.bots.CombatBotAssembler
import core.game.bots.Script import core.game.bots.Script
import core.game.interaction.IntType import core.game.interaction.IntType
import core.game.interaction.InteractionListeners import core.game.interaction.InteractionListeners
import core.game.node.Node
import core.game.node.entity.combat.CombatSwingHandler import core.game.node.entity.combat.CombatSwingHandler
import core.game.node.entity.combat.MeleeSwingHandler import core.game.node.entity.combat.MeleeSwingHandler
import kotlin.random.Random import kotlin.random.Random
@ -224,7 +226,7 @@ class GreenDragonKiller(val style: CombatStyle, area: ZoneBorders? = null) : Scr
private fun attemptToBuryBone() { private fun attemptToBuryBone() {
if (bot.inventory.containsAtLeastOneItem(Items.DRAGON_BONES_536)) { 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)))
} }
} }

View file

@ -41,7 +41,7 @@ public class BoneOfferPlugin extends UseWithHandler {
* Constructor. * Constructor.
*/ */
public BoneOfferPlugin() { 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 @Override

View file

@ -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
}
}

View file

@ -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<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("bury", this);
return this;
}
}

View file

@ -1,73 +1,64 @@
package content.global.skill.prayer package content.global.skill.prayer
import core.game.node.item.Item import org.rs09.consts.Items
import java.util.ArrayList
import java.util.HashMap
/** /**
* Represents the type of bones. * Represents the type of bones.
* @author Apache Ah64 * @author Apache Ah64
*/ */
enum class Bones 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);
/** /**
* Get the bone experience given when you bury the bone. * Construct a new `Bones` `Object`.
* @return The experience. * @param itemId The item id.
* @param experience The experience given by burying the bone.
*/ */
/** /**
* Gets the bone meal item. * The bone item id.
* @return the item.
*/ */
val boneMeal: Item val itemId: Int,
get() {
return when(this){
FAYRG -> Item(4852)
RAURG_BONES -> Item(4853)
OURG_BONES -> Item(4854)
else -> Item(4255 + ordinal)
}
}
/** /**
* Gets the config value for the bone type. * The experience given by burying the bone.
* @param hopper the hopper.
* @return the value.
*/ */
fun getConfigValue(hopper: Boolean): Int { val experience: Double,
return (if (this == BONES_2) ordinal else ordinal - 1) or (if (hopper) 4 else 8) shl 16
} /**
* 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 { companion object {
/** /**
@ -83,23 +74,7 @@ enum class Bones
@JvmStatic @JvmStatic
fun forBoneMeal(itemId: Int): Bones? { fun forBoneMeal(itemId: Int): Bones? {
for (bone in values()) { for (bone in values()) {
if (bone.boneMeal.id == itemId) { if (bone.bonemealId == 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) {
return bone return bone
} }
} }

View file

@ -1,23 +1,23 @@
package content.region.morytania.phas.handlers package content.region.morytania.phas.handlers
import core.api.Container
import core.api.*
import content.global.skill.prayer.Bones 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.impl.PulseType
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 core.game.system.task.Pulse import core.game.system.task.Pulse
import core.game.world.GameWorld.Pulser
import core.game.world.map.Location import core.game.world.map.Location
import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items import org.rs09.consts.Items
import core.game.interaction.InteractionListener import org.rs09.consts.Scenery
import core.game.interaction.IntType
import core.game.world.GameWorld.Pulser
import org.rs09.consts.Sounds import org.rs09.consts.Sounds
private const val LOADER = 11162 private const val LOADER = Scenery.LOADER_11162
private const val BONE_GRINDER = 11163 private const val BONE_GRINDER = Scenery.BONE_GRINDER_11163
private const val BIN = 11164 private const val BIN = Scenery.BIN_11164
private const val LOADED_BONE_KEY = "/save:bonegrinder-bones" private const val LOADED_BONE_KEY = "/save:bonegrinder-bones"
private const val BONE_HOPPER_KEY = "/save:bonegrinder-hopper" private const val BONE_HOPPER_KEY = "/save:bonegrinder-hopper"
@ -73,8 +73,12 @@ class BoneGrinderListener : InteractionListener {
fun handleFill(player: Player): Boolean{ fun handleFill(player: Player): Boolean{
val bone = getBone(player) val bone = getBone(player)
if(bone == null){ if((bone == null) || (bone.bonemealId == null)) {
sendMessage(player,"You have no bones to grind.") 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 return true
} }
if(getAttribute(player, BONE_HOPPER_KEY,false)){ if(getAttribute(player, BONE_HOPPER_KEY,false)){
@ -240,7 +244,7 @@ class BoneGrinderListener : InteractionListener {
} }
SCOOP_ANIM.duration -> { SCOOP_ANIM.duration -> {
if(removeItem(player,Item(Items.EMPTY_POT_1931),Container.INVENTORY)){ if(removeItem(player,Item(Items.EMPTY_POT_1931),Container.INVENTORY)){
addItem(player,bone.boneMeal.id) addItem(player, bone.bonemealId!!)
} }
return true return true
} }

View file

@ -1,9 +1,8 @@
package content.region.morytania.phas.handlers; 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.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.global.action.ClimbActionHandler;
import core.game.interaction.Option; import core.game.interaction.Option;
import core.game.node.Node; 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.npc.NPC;
import core.game.node.entity.player.Player; import core.game.node.entity.player.Player;
import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.Skills;
import content.global.skill.agility.AgilityHandler;
import core.game.node.item.Item; import core.game.node.item.Item;
import core.game.node.scenery.Scenery; import core.game.node.scenery.Scenery;
import core.game.node.scenery.SceneryBuilder; import core.game.node.scenery.SceneryBuilder;
import core.game.system.task.Pulse;
import core.game.world.map.Direction; import core.game.world.map.Direction;
import core.game.world.map.Location; import core.game.world.map.Location;
import core.game.world.map.zone.MapZone; import core.game.world.map.zone.MapZone;
import core.game.world.map.zone.ZoneBorders; import core.game.world.map.zone.ZoneBorders;
import core.game.world.map.zone.ZoneBuilder; import core.game.world.map.zone.ZoneBuilder;
import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Animation;
import core.plugin.ClassScanner;
import core.plugin.Initializable; import core.plugin.Initializable;
import core.plugin.Plugin; import core.plugin.Plugin;
import org.rs09.consts.NPCs; import org.rs09.consts.NPCs;
import core.plugin.ClassScanner;
import org.rs09.consts.Sounds; import org.rs09.consts.Sounds;
import static core.api.ContentAPIKt.playAudio;
import static core.api.ContentAPIKt.sendMessage;
/** /**
* Handles the phasmatys zone area. * Handles the phasmatys zone area.
* *
@ -39,8 +39,6 @@ public final class PhasmatysZone extends MapZone implements Plugin<Object> {
Bones[] bones; Bones[] bones;
Player player; Player player;
Bones bone; Bones bone;
boolean notFirst;
/** /**
* Constructs a new {@code PhasmatysZone} {@code Object}. * Constructs a new {@code PhasmatysZone} {@code Object}.
@ -58,7 +56,6 @@ public final class PhasmatysZone extends MapZone implements Plugin<Object> {
return this; return this;
} }
@Override @Override
public boolean interact(Entity e, Node target, Option option) { public boolean interact(Entity e, Node target, Option option) {
if (e.isPlayer()) { if (e.isPlayer()) {
@ -132,64 +129,6 @@ public final class PhasmatysZone extends MapZone implements Plugin<Object> {
return super.interact(e, target, option); 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. * Checks if the player has the amulet equipped.
* *
@ -200,108 +139,6 @@ public final class PhasmatysZone extends MapZone implements Plugin<Object> {
return player.getEquipment().contains(552, 1); 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. * Worships the ectofuntus.
* *
@ -331,7 +168,7 @@ public final class PhasmatysZone extends MapZone implements Plugin<Object> {
player.getDialogueInterpreter().sendDialogue("You need ectoplasm to put into the Ectofuntus."); player.getDialogueInterpreter().sendDialogue("You need ectoplasm to put into the Ectofuntus.");
return; 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.lock(1);
player.animate(Animation.create(1651)); player.animate(Animation.create(1651));
playAudio(player, Sounds.PRAYER_BOOST_2671); playAudio(player, Sounds.PRAYER_BOOST_2671);