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