mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
Implemented Falador farm sheepdog interactions, can now be fed bones and meat
This commit is contained in:
parent
ac87c2ff51
commit
c54abe696c
5 changed files with 116 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ enum class Bones
|
|||
BONES(2530, 4.5),
|
||||
BONES_2(526, 4.5),
|
||||
WOLF_BONES(2859, 4.5),
|
||||
BURNST_BONES(528, 4.5),
|
||||
BURNT_BONES(528, 4.5),
|
||||
MONKEY_BONES(3183, 5.0),
|
||||
MONKEY_BONES2(3179, 5.0),
|
||||
BAT_BONES(530, 5.3),
|
||||
|
|
|
|||
53
Server/src/main/java/core/game/content/global/Meat.kt
Normal file
53
Server/src/main/java/core/game/content/global/Meat.kt
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package core.game.content.global
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
enum class MeatState {
|
||||
INEDIBLE_RAW,
|
||||
INEDIBLE_BURNT,
|
||||
INEDIBLE_SPECIAL, // could be a quest item
|
||||
EDIBLE_COOKED,
|
||||
}
|
||||
|
||||
enum class Meat(val id: Int, val state: MeatState) {
|
||||
ENCHANTED_BEEF(522, MeatState.INEDIBLE_SPECIAL),
|
||||
ENCHANTED_RAT_MEAT(523, MeatState.INEDIBLE_SPECIAL),
|
||||
ENCHANTED_BEAR_MEAT(524, MeatState.INEDIBLE_SPECIAL),
|
||||
ENCHANTED_CHICKEN(525, MeatState.INEDIBLE_SPECIAL),
|
||||
RAW_UGTHANKI_MEAT(1859, MeatState.INEDIBLE_RAW),
|
||||
UGTHANKI_MEAT(1861, MeatState.EDIBLE_COOKED),
|
||||
RAW_BEEF(2132, MeatState.INEDIBLE_RAW),
|
||||
RAW_RAT_MEAT(2134, MeatState.INEDIBLE_RAW),
|
||||
RAW_BEAR_MEAT(2136, MeatState.INEDIBLE_RAW),
|
||||
RAW_CHICKEN(2138, MeatState.INEDIBLE_RAW),
|
||||
COOKED_CHICKEN(2140, MeatState.EDIBLE_COOKED),
|
||||
BURNT_CHICKEN(2140, MeatState.INEDIBLE_BURNT),
|
||||
COOKED_MEAT(2142, MeatState.EDIBLE_COOKED),
|
||||
BURNT_MEAT(2146, MeatState.INEDIBLE_BURNT),
|
||||
THIN_SNAIL_MEAT(3369, MeatState.EDIBLE_COOKED),
|
||||
LEAN_SNAIL_MEAT(3371, MeatState.EDIBLE_COOKED),
|
||||
FAT_SNAIL_MEAT(3373, MeatState.EDIBLE_COOKED),
|
||||
RAW_BEEF_UNDEAD(4287, MeatState.INEDIBLE_RAW),
|
||||
RAW_CHICKEN_UNDEAD(4289, MeatState.INEDIBLE_RAW),
|
||||
COOKED_CHICKEN_UNDEAD(4291, MeatState.EDIBLE_COOKED),
|
||||
COOKED_MEAT_UNDEAD(4293, MeatState.EDIBLE_COOKED),
|
||||
RAW_CRAB_MEAT(7518, MeatState.INEDIBLE_RAW),
|
||||
BURNT_CRAB_MEAT(7520, MeatState.INEDIBLE_BURNT),
|
||||
COOKED_CRAB_MEAT_5(7521, MeatState.EDIBLE_COOKED),
|
||||
COOKED_CRAB_MEAT_4(7523, MeatState.EDIBLE_COOKED),
|
||||
COOKED_CRAB_MEAT_3(7524, MeatState.EDIBLE_COOKED),
|
||||
COOKED_CRAB_MEAT_2(7525, MeatState.EDIBLE_COOKED),
|
||||
COOKED_CRAB_MEAT_1(7526, MeatState.EDIBLE_COOKED),
|
||||
GROUND_CRAB_MEAT(7527, MeatState.INEDIBLE_RAW),
|
||||
LOCUST_MEAT(9052, MeatState.EDIBLE_COOKED),
|
||||
RAW_BIRD_MEAT(9978, MeatState.INEDIBLE_RAW),
|
||||
ROAST_BIRD_MEAT(9980, MeatState.EDIBLE_COOKED),
|
||||
BURNT_BIRD_MEAT(9982, MeatState.INEDIBLE_BURNT),
|
||||
SKEWERED_BIRD_MEAT(9982, MeatState.INEDIBLE_RAW),
|
||||
RAW_BEAST_MEAT(9986, MeatState.INEDIBLE_RAW),
|
||||
ROAST_BEAST_MEAT(9988, MeatState.EDIBLE_COOKED),
|
||||
BURNT_BEAST_MEAT(9990, MeatState.INEDIBLE_BURNT),
|
||||
RAW_YAK_MEAT(10816, MeatState.INEDIBLE_RAW),
|
||||
RAW_PAWYA_MEAT(12535, MeatState.INEDIBLE_RAW),
|
||||
ENCHANTED_PAWYA_MEAT(12546, MeatState.INEDIBLE_SPECIAL);
|
||||
}
|
||||
|
|
@ -34,6 +34,9 @@ interface InteractionListener : ContentInterface{
|
|||
fun onUseWith(type: Int, used: IntArray, vararg with: Int, handler: (player: Player, used: Node, with: Node) -> Boolean){
|
||||
InteractionListeners.add(type,used,with,handler)
|
||||
}
|
||||
fun onUseAnyWith(type: Int, vararg with: Int, handler: (player: Player, used: Node, with: Node) -> Boolean) {
|
||||
InteractionListeners.add(type, with, handler)
|
||||
}
|
||||
// Note: wildcard listeners incur overhead on every use-with interaction, only use them as a space-time tradeoff when something
|
||||
// is actually supposed to have a response to every item used with it (e.g. imp boxes, certain quest npcs)
|
||||
fun onUseWithWildcard(type: Int, predicate: (used: Int, with: Int) -> Boolean, handler: (player: Player, used: Node, with: Node) -> Boolean) {
|
||||
|
|
@ -53,7 +56,7 @@ interface InteractionListener : ContentInterface{
|
|||
ids.forEach{ id -> InteractionListeners.addUnequip(id,handler) }
|
||||
}
|
||||
|
||||
open fun defineDestinationOverrides(){}
|
||||
fun defineDestinationOverrides(){}
|
||||
|
||||
fun setDest(type: Int, id: Int,handler: (Entity, Node) -> Location){
|
||||
InteractionListeners.addDestOverride(type,id,handler)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import rs09.game.system.SystemLogger
|
|||
object InteractionListeners {
|
||||
private val listeners = HashMap<String,(Player, Node) -> Boolean>(1000)
|
||||
private val useWithListeners = HashMap<String,(Player,Node,Node) -> Boolean>(1000)
|
||||
private val useAnyWithListeners = HashMap<String, (Player, Node, Node) -> Boolean>(10)
|
||||
private val useWithWildcardListeners = HashMap<Int, ArrayList<Pair<(Int, Int) -> Boolean, (Player, Node, Node) -> Boolean>>>(10)
|
||||
private val destinationOverrides = HashMap<String,(Entity, Node) -> Location>(100)
|
||||
private val equipListeners = HashMap<String,(Player,Node) -> Boolean>(10)
|
||||
|
|
@ -88,7 +89,7 @@ object InteractionListeners {
|
|||
|
||||
@JvmStatic
|
||||
fun get(used: Int, with: Int, type: Int): ((Player,Node,Node) -> Boolean)? {
|
||||
var method = useWithListeners["$used:$with:$type"]
|
||||
val method = useWithListeners["$used:$with:$type"] ?: useAnyWithListeners["$with:$type"]
|
||||
if(method != null) {
|
||||
return method
|
||||
}
|
||||
|
|
@ -250,4 +251,10 @@ object InteractionListeners {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun add(type: Int, with: IntArray, handler: (Player, Node, Node) -> Boolean) {
|
||||
for (w in with) {
|
||||
useAnyWithListeners["$w:$type"] = handler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package rs09.game.interaction.item.withnpc
|
||||
|
||||
import api.*
|
||||
import core.game.content.global.Bones
|
||||
import core.game.content.global.Meat
|
||||
import core.game.content.global.MeatState
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import org.rs09.consts.Animations
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class FeedFaladorSheepdog : InteractionListener {
|
||||
companion object {
|
||||
private const val SHEEP_DOG_NPC = NPCs.SHEEPDOG_2311
|
||||
private val FEED_ANIMATION = Animation(Animations.HUMAN_BURYING_BONES_827)
|
||||
private val CONSUMABLE_BONES = Bones.array
|
||||
.filter { it != Items.BURNT_BONES_528 }
|
||||
.toHashSet()
|
||||
private val CONSUMABLE_MEATS = Meat.values()
|
||||
.filter { it.state == MeatState.INEDIBLE_RAW || it.state == MeatState.EDIBLE_COOKED }
|
||||
.map { it.id }
|
||||
.toHashSet()
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
onUseAnyWith(NPC, SHEEP_DOG_NPC) { player, used, with ->
|
||||
if (CONSUMABLE_BONES.contains(used.id)) {
|
||||
if (!removeItem(player, used.asItem())) {
|
||||
return@onUseAnyWith true
|
||||
}
|
||||
sendDialogue(player, "You give the dog some nice ${used.name.toLowerCase()}. It happily gnaws on them.")
|
||||
} else if (CONSUMABLE_MEATS.contains(used.id)) {
|
||||
if (!removeItem(player, used.asItem())) {
|
||||
return@onUseAnyWith true
|
||||
}
|
||||
sendDialogue(player, "You give the dog a nice piece of meat. It gobbles it up.")
|
||||
} else {
|
||||
sendMessage(player, "The dog doesn't seem interested in that.")
|
||||
sendChat(with.asNpc(), "Grrrr!")
|
||||
return@onUseAnyWith true
|
||||
}
|
||||
|
||||
animate(player, FEED_ANIMATION)
|
||||
sendChat(with.asNpc(), "Woof woof!")
|
||||
|
||||
return@onUseAnyWith true
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue