From 2537c36ad0c4bd6da8a62502640ec556bfe868a7 Mon Sep 17 00:00:00 2001 From: Beck <2421110-beckrickert@users.noreply.gitlab.com> Date: Sun, 19 Apr 2026 09:42:35 +0000 Subject: [PATCH] Rewrote shooing of stray dog, and feeding of stray dog Feeding of stray dog now supports more meats --- .../handlers/item/withnpc/BonesOnStrayDog.kt | 84 ------------- .../handlers/item/withnpc/FeedOnStrayDog.kt | 118 ++++++++++++++++++ .../handlers/npc/ShooAwayStrayDogListener.kt | 80 ++++++++++++ .../handlers/ShooAwayStrayDogPlugin.java | 43 ------- 4 files changed, 198 insertions(+), 127 deletions(-) delete mode 100644 Server/src/main/content/global/handlers/item/withnpc/BonesOnStrayDog.kt create mode 100644 Server/src/main/content/global/handlers/item/withnpc/FeedOnStrayDog.kt create mode 100644 Server/src/main/content/global/handlers/npc/ShooAwayStrayDogListener.kt delete mode 100644 Server/src/main/content/region/misthalin/varrock/handlers/ShooAwayStrayDogPlugin.java diff --git a/Server/src/main/content/global/handlers/item/withnpc/BonesOnStrayDog.kt b/Server/src/main/content/global/handlers/item/withnpc/BonesOnStrayDog.kt deleted file mode 100644 index e6e7fd03a..000000000 --- a/Server/src/main/content/global/handlers/item/withnpc/BonesOnStrayDog.kt +++ /dev/null @@ -1,84 +0,0 @@ -package content.global.handlers.item.withnpc - -import core.api.removeItem -import core.api.sendChat -import core.api.sendMessage -import content.global.skill.prayer.Bones -import core.game.node.entity.npc.NPC -import core.game.node.item.Item -import org.rs09.consts.Items -import org.rs09.consts.NPCs -import core.game.interaction.InteractionListener -import core.game.interaction.IntType - -class BonesOnStrayDog : InteractionListener { - override fun defineListeners() { - val bones = Bones.array - - val dogs = intArrayOf( - NPCs.STRAY_DOG_4766, - NPCs.STRAY_DOG_4767, - NPCs.STRAY_DOG_5917, - NPCs.STRAY_DOG_5918 - ) - - onUseWith(IntType.NPC, bones, *dogs) { player, used, with -> - used as Item; with as NPC - - var woof = "Woof" - - if (removeItem(player, used)) { - sendMessage( - player, - "You feed the ${with.definition.name.lowercase()} your ${used.definition.name.lowercase()}." - ) - - when (used.id) { - Items.BURNT_BONES_528 -> { - sendMessage( - player, - "The dog looks at you, disappointed, but takes the bones anyway." - ) - - woof = "Woof..." - } - - Items.FAYRG_BONES_4830, - Items.RAURG_BONES_4832, - Items.OURG_BONES_4834 -> { - sendMessage( - player, - "The dog looks at you, confused, but takes the bones anyway." - ) - - woof = "Woof..?" - } - - Items.BABYDRAGON_BONES_534, - Items.BIG_BONES_532 -> { - sendMessage( - player, - "The dog seems to be very happy." - ) - - woof = "Woof!" - } - - Items.WYVERN_BONES_6812, - Items.DRAGON_BONES_536 -> { - sendMessage( - player, - "The dog seems to be extremely overjoyed." - ) - - woof = "WOOF!" - } - } - - sendChat(with, woof) - } - - return@onUseWith true - } - } -} \ No newline at end of file diff --git a/Server/src/main/content/global/handlers/item/withnpc/FeedOnStrayDog.kt b/Server/src/main/content/global/handlers/item/withnpc/FeedOnStrayDog.kt new file mode 100644 index 000000000..1c1013ac4 --- /dev/null +++ b/Server/src/main/content/global/handlers/item/withnpc/FeedOnStrayDog.kt @@ -0,0 +1,118 @@ +package content.global.handlers.item.withnpc + +import core.api.removeItem +import core.api.sendChat +import core.api.sendMessage +import content.global.skill.prayer.Bones +import core.game.node.entity.npc.NPC +import core.game.node.item.Item +import org.rs09.consts.Items +import org.rs09.consts.NPCs +import core.game.interaction.InteractionListener +import core.game.interaction.IntType +import content.data.Meat +import content.data.MeatState +import core.api.animate +import core.game.world.update.flag.context.Animation +import org.rs09.consts.Animations + +/** + * Represents the option Listener use-with on a stray dog. + * Use bones, raw & cooked meats + */ +class FeedOnStrayDog : InteractionListener { + override fun defineListeners() { + + val bones = Bones.array + + val consumableMeats = Meat.values() + .filter { it.state == MeatState.INEDIBLE_RAW || it.state == MeatState.EDIBLE_COOKED } + .map { it.id } + .toIntArray() + + val allAllowedItems = bones + consumableMeats + + val dogs = intArrayOf( + NPCs.STRAY_DOG_4766, + NPCs.STRAY_DOG_4767, + NPCs.STRAY_DOG_5917, + NPCs.STRAY_DOG_5918 + ) + + onUseWith(IntType.NPC, allAllowedItems, *dogs) { player, used, with -> + used as Item; with as NPC + + var woof = "Woof" + + if (removeItem(player, used)) { + sendMessage( + player, + "You feed the ${with.definition.name.lowercase()} your ${used.definition.name.lowercase()}." + ) + + animate(player, Animations.HUMAN_BURYING_BONES_827) + + when { + bones.contains(used.id) -> { + when (used.id) { + Items.BURNT_BONES_528 -> { + sendMessage( + player, + "The dog looks at you, disappointed, but takes the bones anyway." + ) + + woof = "Woof..." + } + + Items.FAYRG_BONES_4830, + Items.RAURG_BONES_4832, + Items.OURG_BONES_4834 -> { + sendMessage( + player, + "The dog looks at you, confused, but takes the bones anyway." + ) + + woof = "Woof..?" + } + + Items.BABYDRAGON_BONES_534, + Items.BIG_BONES_532 -> { + sendMessage( + player, + "The dog seems to be very happy." + ) + + woof = "Woof!" + } + + Items.WYVERN_BONES_6812, + Items.DRAGON_BONES_536 -> { + sendMessage( + player, + "The dog seems to be extremely overjoyed." + ) + + woof = "WOOF!" + } + } + } + + consumableMeats.contains(used.id) -> { + sendMessage( + player, + "The dog wagged its tail happily." + ) + + animate(with, Animation(4777)) + + woof = "Woof woof!" + } + } + + sendChat(with, woof) + } + + return@onUseWith true + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/handlers/npc/ShooAwayStrayDogListener.kt b/Server/src/main/content/global/handlers/npc/ShooAwayStrayDogListener.kt new file mode 100644 index 000000000..e159f89ab --- /dev/null +++ b/Server/src/main/content/global/handlers/npc/ShooAwayStrayDogListener.kt @@ -0,0 +1,80 @@ +package content.global.handlers.npc + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import org.rs09.consts.NPCs +import core.game.node.entity.npc.NPC +import core.game.node.entity.npc.NPCBehavior +import core.game.world.update.flag.context.Animation +import core.game.node.entity.player.Player +import core.game.world.map.Direction +import core.game.world.map.Location +import org.rs09.consts.Animations +import org.rs09.consts.Sounds + +private val strayDogsIds = intArrayOf( + NPCs.STRAY_DOG_4766, + NPCs.STRAY_DOG_4767, + NPCs.STRAY_DOG_5917, + NPCs.STRAY_DOG_5918 +) + +/** + * Represents the option Listener used to 'shoo-away' a stray dog. + * Convert from legacy plugin src/main/content/region/misthalin/varrock/handlers/ShooAwayStrayDogPlugin.java + * @author Vexia + beckrickert + * + */ +class ShooAwayStrayDogListener : NPCBehavior(*strayDogsIds), InteractionListener { + override fun defineListeners() { + + on(strayDogsIds,IntType.NPC, "shoo-away") { player, node -> + + val theDog = node as NPC + + //Pause dog location + lock(theDog, 2) + stopWalk(theDog) + theDog.faceTemporary(player, 1) + + sendChat(player,"Thbbbbt!") + animate(player, Animations.HUMAN_BLOW_RASPBERRY_2110) + + //Dog whine sound + playAudio(player, Sounds.WOLF_DEATH_911) + sendChat(theDog,"Whine!") + + //Dog whine kneeling down animation + animate(theDog, Animation(4774)) + + //run away from player + dogWhineRunAway(player, theDog) + + return@on true + } + } +} + +fun dogWhineRunAway(player: Player, theDog: NPC) { + val playerCurLoc = player.getLocation() + val dogCurLoc = theDog.getLocation() + + //Get dog direction is facing from player's location + val dogDirection = Direction.getDirection(dogCurLoc, playerCurLoc) + val dogDirectionOpp = dogDirection.opposite + + val xWalkLoc = dogCurLoc.x + (dogDirectionOpp.stepX * 12) + val yWalkLoc = dogCurLoc.y + (dogDirectionOpp.stepY * 12) + val dogWalkToNewLoc = Location(xWalkLoc, yWalkLoc, dogCurLoc.z) + + //unlock entity movement so it can run away + unlock(theDog) + + //allow to "moon-walk" to the new location + //Does weird stuff or ignores this when in 'following' mode + //theDog.face(player) + + forceWalk(theDog, dogWalkToNewLoc, "dumb") + +} \ No newline at end of file diff --git a/Server/src/main/content/region/misthalin/varrock/handlers/ShooAwayStrayDogPlugin.java b/Server/src/main/content/region/misthalin/varrock/handlers/ShooAwayStrayDogPlugin.java deleted file mode 100644 index d21dee850..000000000 --- a/Server/src/main/content/region/misthalin/varrock/handlers/ShooAwayStrayDogPlugin.java +++ /dev/null @@ -1,43 +0,0 @@ -package content.region.misthalin.varrock.handlers; - -import core.cache.def.impl.NPCDefinition; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.npc.NPC; -import core.game.node.entity.player.Player; -import core.game.world.update.flag.context.Animation; -import core.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Represents the option plugin used to shoo away a dog. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class ShooAwayStrayDogPlugin extends OptionHandler { - - /** - * Represents the animatio to use. - */ - private static final Animation ANIMATION = new Animation(2110); - - @Override - public Plugin newInstance(Object arg) throws Throwable { - NPCDefinition.forId(5917).getHandlers().put("option:shoo-away", this); - NPCDefinition.setOptionHandler("shoo-away", this); - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - player.sendChat("Thbbbbt!"); - player.animate(ANIMATION); - NPC dog = (NPC) node; - dog.sendChat("Whine!"); - dog.moveStep(); - dog.getPulseManager().clear(); - return true; - } - -}