Rewrote shooing of stray dog, and feeding of stray dog
Feeding of stray dog now supports more meats
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
}
|
||||
@@ -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<Object> 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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user