Eastor eggz

This commit is contained in:
Ceikry 2021-03-20 23:54:23 -05:00
parent 7520655d47
commit 3acbf302b8
5 changed files with 146 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import core.game.world.map.zone.ZoneBorders
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.InteractionListener
import rs09.game.interaction.InteractionListeners
import rs09.game.system.config.ItemConfigParser
import rs09.game.world.GameWorld
@ -51,6 +52,7 @@ class EquipHandler : InteractionListener() {
return
}
}
InteractionListeners.run(node.id,player,node,true)
val lock = player.locks.equipmentLock
if (lock != null && lock.isLocked) {
@ -116,6 +118,7 @@ class EquipHandler : InteractionListener() {
return
}
}
InteractionListeners.run(itemId,player,item,false)
if (player.equipment.remove(item)) {
player.audioManager.send(Audio(2238, 10, 1))
player.dialogueInterpreter.close()

View file

@ -28,6 +28,12 @@ abstract class InteractionListener : Listener{
fun onUseWith(type: Int, used: IntArray, vararg with: Int, handler: (player: Player, used: Node, with: Node) -> Boolean){
InteractionListeners.add(type,used,with,handler)
}
fun onEquip(id: Int, handler: (player: Player, node: Node) -> Unit){
InteractionListeners.addEquip(id,handler)
}
fun onUnequip(id:Int, handler: (player: Player, node: Node) -> Unit){
InteractionListeners.addUnequip(id,handler)
}
open fun defineDestinationOverrides(){}

View file

@ -10,6 +10,7 @@ object InteractionListeners {
private val listeners = HashMap<String,(Player, Node) -> Boolean>(1000)
private val useWithListeners = HashMap<String,(Player,Node,Node) -> Boolean>(1000)
private val destinationOverrides = HashMap<String,(Node) -> Location>(100)
private val equipListeners = HashMap<String,(Player,Node) -> Unit>(10)
@JvmStatic
fun add(id: Int, type: Int, option: Array<out String>, method: (Player,Node) -> Boolean){
@ -51,6 +52,26 @@ object InteractionListeners {
}
}
@JvmStatic
fun addEquip(id: Int,method: (Player, Node) -> Unit){
equipListeners["equip:$id"] = method
}
@JvmStatic
fun addUnequip(id: Int, method: (Player,Node) -> Unit){
equipListeners["unequip:$id"] = method
}
@JvmStatic
fun getEquip(id: Int): ((Player,Node) -> Unit)? {
return equipListeners["equip:$id"]
}
@JvmStatic
fun getUnequip(id: Int): ((Player,Node) -> Unit)? {
return equipListeners["unequip:$id"]
}
@JvmStatic
fun get(used: Int, with: Int, type: Int): ((Player,Node,Node) -> Boolean)?{
return useWithListeners["$used:$with:$type"]
@ -102,6 +123,15 @@ object InteractionListeners {
return destinationOverrides["$type:$option"]
}
@JvmStatic
fun run(id: Int, player: Player, node: Node, isEquip: Boolean){
if(isEquip){
equipListeners["equip:$id"]?.invoke(player,node)
} else {
equipListeners["unequip:$id"]?.invoke(player,node)
}
}
@JvmStatic
fun run(used: Node, with: Node, type: Int,player: Player): Boolean{
val flag = when(type){

View file

@ -0,0 +1,51 @@
package rs09.game.interaction.item.withnpc
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.item.Item
import core.game.world.update.flag.context.Graphics
import org.rs09.consts.Items
import rs09.game.content.dialogue.DialogueFile
import rs09.game.interaction.InteractionListener
val graphics = 482
class HatEasterEgg : InteractionListener(){
val MACHINE = 20040
val WIZ_HAT = Items.WIZARD_HAT_579
val NEW_HAT = 14650
override fun defineListeners() {
onUseWith(OBJECT,WIZ_HAT,MACHINE){player, used, with ->
player.dialogueInterpreter.open(HatDialogue(), NPC(872))
return@onUseWith true
}
}
}
class HatDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
when(stage++){
0 -> {
npc("WHAT HAVE YOU DONE?")
player!!.graphics(Graphics(graphics))
}
1 -> player(FacialExpression.AFRAID,"What do you mean?!")
2 -> npc("You've disjointed the fabric assimilation matrix!")
3 -> player(FacialExpression.THINKING,"W-what...?")
4 -> npc("You've put us at risk of ripping Gielinor apart!")
5 -> player(FacialExpression.HALF_GUILTY,"I.. I just wanted a hat...")
6 -> npc("Damn you and damn your hat! You could kill us all!")
7 -> player("I... I'm sorry....")
8 -> npc("*sigh* I've managed to stabilize the flux material inductors.")
9 -> npc("You may just be safe, yet.")
10 -> npc("Here, take your damn hat and get out of here.")
11 -> {
end()
player!!.inventory.remove(Item(Items.WIZARD_HAT_579))
player!!.inventory.add(Item(14650))
}
}
}
}

View file

@ -0,0 +1,56 @@
package rs09.game.interaction.item.withnpc
import core.game.component.Component
import core.game.content.dialogue.FacialExpression
import core.game.node.item.Item
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.interaction.InteractionListener
import rs09.tools.END_DIALOGUE
class MistagEasterEgg : InteractionListener() {
val DIAMOND = Items.DIAMOND_1601
val MISTAG = NPCs.MISTAG_2084
val ZANIK_RING = 14649
override fun defineListeners() {
onUseWith(NPC,DIAMOND,MISTAG){player, _, with ->
val alreadyHasRing = player.inventory.contains(ZANIK_RING,1) || player.bank.contains(ZANIK_RING,1) || player.equipment.contains(ZANIK_RING,1)
player.dialogueInterpreter.open(MistagEasterEggDialogue(alreadyHasRing),with.asNpc())
return@onUseWith true
}
onEquip(ZANIK_RING){player,_ ->
player.appearance.transformNPC(NPCs.ZANIK_3712)
}
onUnequip(ZANIK_RING){player, _ ->
player.appearance.transformNPC(-1)
}
}
}
class MistagEasterEggDialogue(val hasRing: Boolean): DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
if(hasRing){
npc("Lovely gem, adventurer, but I have nothing for you.").also { stage = END_DIALOGUE }
return
}
when(stage++){
0 -> npc("Well thank you adventurer! Here, take this.")
1 -> {
end()
if(player!!.inventory.remove(Item(Items.DIAMOND_1601))){
player!!.inventory.add(Item(14649))
}
}
}
}
override fun npc(vararg messages: String?): Component? {
return super.npc(FacialExpression.OLD_HAPPY,*messages)
}
}