Moved all currently existing Freminnik Trials option handlers to TFTInteractionListeners.kt, added new library PrimitiveExtensions-1.0.jar

This commit is contained in:
Ceikry 2021-03-13 14:03:45 -06:00
parent b11b0a2e17
commit 1401ab94bb
22 changed files with 321 additions and 603 deletions

View file

@ -29,6 +29,8 @@ dependencies {
implementation 'org.jetbrains.kotlin:kotlin-reflect' implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
implementation files("libs/ConstLib-1.0.jar") implementation files("libs/ConstLib-1.0.jar")
implementation files("libs/PrimitiveExtensions-1.0.jar")
} }
/*sourceSets { /*sourceSets {

Binary file not shown.

View file

@ -0,0 +1,30 @@
package rs09.game.content.dialogue
import core.game.content.dialogue.DialoguePlugin
import core.game.node.entity.player.Player
import core.plugin.Initializable
import rs09.game.content.quest.members.thefremenniktrials.CouncilWorkerFTDialogue
@Initializable
class CouncilWorkerDialogue(player: Player? = null) : DialoguePlugin(player){
override fun open(vararg args: Any?): Boolean {
if(player.questRepository.getStage("Fremennik Trials") in 1..99){
loadFile(CouncilWorkerFTDialogue(1))
}
npc("'Ello there.")
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
return true
}
override fun newInstance(player: Player?): DialoguePlugin {
return CouncilWorkerDialogue(player)
}
override fun getIds(): IntArray {
return intArrayOf(1287)
}
}

View file

@ -1,32 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.interaction.NodeUsageEvent
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import core.plugin.Plugin
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
@Initializable
class BeerOnCouncilWorker : PluginInteraction(1917){
override fun handle(player: Player?, event: NodeUsageEvent?): Boolean {
val with = event?.usedWith
if(with?.id?.equals(1287)!! && with is NPC){
player?.dialogueInterpreter?.open(1287,true,true)
return true
}
return false
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.USEWITH)
return this
}
}

View file

@ -1,52 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.interaction.NodeUsageEvent
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.game.system.task.Pulse
import rs09.game.world.GameWorld
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
@Initializable
class BranchFletcher : PluginInteraction(3692){
class BranchFletchingPulse(val player: Player?) : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player?.animator?.animate(Animation(1248)).also { player!!.lock() }
3 -> player?.inventory?.remove(Item(3692)).also { player?.inventory?.add(Item(3688)); player!!.unlock(); return true}
}
return false
}
}
override fun handle(player: Player?, event: NodeUsageEvent?): Boolean {
val with = event?.usedWith
if(with is Item && with.id == 946) {
player?.let {
if (it.inventory.containsItem(Item(946))) {
GameWorld.submit(BranchFletchingPulse(it))
} else {
it.sendMessage("You need a knife to do this.")
}
}
return true
}
return false
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.USEWITH)
return this
}
}

View file

@ -1,56 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.node.entity.player.Player
import core.game.node.entity.player.info.PlayerDetails
import core.game.node.item.Item
import core.plugin.Initializable
import core.game.content.dialogue.DialoguePlugin
@Initializable
class CouncilWorkerDialogue(player: Player? = null) : DialoguePlugin(player){
override fun open(vararg args: Any?): Boolean {
if(args.size > 1){
npc("Ta very much like. That'll hit the spot nicely.. Here,","You can have this. I picked it up as a souvenir on me","last holz")
player?.inventory?.add(Item(3713)); player?.inventory?.remove(Item(1917)); stage = 10
stage = 100;
} else {
npc("'Ello there.")
stage = 0;
}
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage){
0 -> if(player?.questRepository?.getStage("Fremennik Trials")!! > 0){
player("I know this is an odd question, but are you","a member of the elder council?")
stage++
} else {
end()
}
1 -> {npc("'fraid not, ${if(player?.appearance?.isMale!!) "sir" else "miss"}"); stage++}
2 -> {npc("Say, would you do me a favor? I'm quite parched.","If you bring me a beer, I'll make it worthwhile.");stage++}
3 -> if(player?.inventory?.containsItem(Item(1917))!!){
player("Oh, I have one here! Take it.")
stage++
} else {
end()
}
4 -> {npc("Oh, thank you much ${if(player?.appearance?.isMale!!) "sir" else "miss"}");stage++}
5 -> {npc("Ta very much like. That'll hit the spot nicely.. Here,","You can have this. I picked it up as a souvenir on me","last holz");player?.inventory?.add(Item(3713)); player?.inventory?.remove(Item(1917)); stage = 100}
100 -> end()
}
return true
}
override fun newInstance(player: Player?): DialoguePlugin {
return CouncilWorkerDialogue(player)
}
override fun getIds(): IntArray {
return intArrayOf(1287)
}
}

View file

@ -0,0 +1,42 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.node.item.Item
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
import rs09.tools.START_DIALOGUE
class CouncilWorkerFTDialogue(val questStage: Int,var isBeerInteraction: Boolean = false) : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
if(isBeerInteraction){
when(stage){
START_DIALOGUE -> {npc("Oh, thank you much ${if(player?.appearance?.isMale!!) "sir" else "miss"}");stage++}
1 -> {npc("Ta very much like. That'll hit the spot nicely.. Here,","You can have this. I picked it up as a souvenir on me","last holz");player?.inventory?.add(
Item(3713)
); player?.inventory?.remove(Item(1917)); stage = END_DIALOGUE}
}
}
else if(questStage in 1..99){
when(stage){
START_DIALOGUE -> if(player?.questRepository?.getStage("Fremennik Trials")!! > 0){
player("I know this is an odd question, but are you","a member of the elder council?")
} else {
end()
}
1 -> {npc("'fraid not, ${if(player?.appearance?.isMale!!) "sir" else "miss"}"); stage++}
2 -> {npc("Say, would you do me a favor? I'm quite parched.","If you bring me a beer, I'll make it worthwhile.");stage++}
3 -> if(player?.inventory?.containsItem(Item(1917))!!){
player("Oh, I have one here! Take it.")
stage = 0
isBeerInteraction = true
} else {
stage = END_DIALOGUE
}
}
}
}
}

View file

@ -1,77 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.content.dialogue.FacialExpression
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.interaction.NodeUsageEvent
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.game.system.task.Pulse
import rs09.game.world.GameWorld
import core.plugin.Initializable
import core.plugin.Plugin
@Initializable
class FishOnAltar : PluginInteraction(383, 389, 395){
var fishUsed = 0
override fun handle(player: Player?, event: NodeUsageEvent?): Boolean {
fishUsed = event?.used!!.id
val with = event.usedWith
if(with is GameObject && with.id == 4141){
if(player?.questRepository?.getStage("Fremennik Trials")!! >= 10){
GameWorld.submit(moveToPulse(player,with,fishUsed))
return true
}
}
return false
}
class moveToPulse(val player: Player?, dest: Node, val fish: Int) : MovementPulse(player,dest, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
if(player?.inventory?.containsItem(Item(3689))!!){
GameWorld.submit(spiritPulse(player, fish))
} else {
player.dialogueInterpreter.sendDialogue("I should probably have my lyre with me.")
}
return true
}
}
class spiritPulse(val player: Player?, val fish: Int) : Pulse(){
var counter = 0
val npc = NPC(1273,player?.location)
override fun pulse(): Boolean {
when(counter++){
0 -> npc.init().also { player?.lock() }.also { player?.inventory?.remove(Item(fish)) }
1 -> npc.moveStep()
2 -> npc.face(player).also { player?.face(npc) }
3 -> player?.dialogueInterpreter?.sendDialogues(npc,FacialExpression.HAPPY,"I will kindly accept this offering, and","bestow upon you a gift in return.")
4 -> player?.inventory?.remove(Item(3689))
5 -> when(fish){
383 -> player?.inventory?.add(Item(6125))
389 -> player?.inventory?.add(Item(6126))
395 -> player?.inventory?.add(Item(6127))
}
6 -> player?.unlock()
10 -> npc.clear().also { return true }
}
return false
}
}
override fun fireEvent(identifier: String, vararg args: Any): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.USEWITH)
return this
}
}

View file

@ -4,7 +4,6 @@ import core.game.node.entity.Entity
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
import core.game.system.task.Pulse import core.game.system.task.Pulse
import core.game.world.map.Location import core.game.world.map.Location
import core.plugin.Initializable
import org.rs09.consts.Items import org.rs09.consts.Items
import rs09.game.interaction.InteractionListener import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld.Pulser import rs09.game.world.GameWorld.Pulser
@ -18,10 +17,10 @@ class HunterTalismanListener : InteractionListener() {
override fun defineListeners() { override fun defineListeners() {
on(TALISMAN,ITEM,"locate"){player,_ -> on(TALISMAN,ITEM,"locate"){player,_ ->
var locationString = player?.getAttribute("fremtrials:draugen-loc","none") var locationString = player.getAttribute("fremtrials:draugen-loc","none")
if(locationString == "none"){ if(locationString == "none"){
val newLoc = possibleLocations.random() val newLoc = possibleLocations.random()
player?.setAttribute("/save:fremtrials:draugen-loc","${newLoc.x},${newLoc.y}") player.setAttribute("/save:fremtrials:draugen-loc","${newLoc.x},${newLoc.y}")
locationString = "${newLoc.x},${newLoc.y}" locationString = "${newLoc.x},${newLoc.y}"
} }
val locationComponents = locationString?.split(",") val locationComponents = locationString?.split(",")

View file

@ -1,50 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.interaction.NodeUsageEvent
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.game.world.map.RegionManager
import core.plugin.Initializable
import core.plugin.Plugin
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
@Initializable
class KegOnKegAction : PluginInteraction(3712){
override fun handle(player: Player?, event: NodeUsageEvent?): Boolean {
val used = event?.used
val with = event?.usedWith
if(with?.id?.equals(3711)!! && player?.isInLongHouse()!!){
if(!player.getAttribute("fremtrials:keg-mixed",false)!!){
if(player.getAttribute("fremtrials:cherrybomb",false)) {
player.inventory?.remove(used as? Item)
player.setAttribute("/save:fremtrials:keg-mixed", true)
player.sendMessage("The cherry bomb in the pipe goes off.")
RegionManager.getLocalEntitys(player).stream().forEach { e -> e.sendChat("What was THAT??") }
player.sendMessage("You mix the kegs together.")
return true
} else {
player.dialogueInterpreter?.sendDialogue("I can't do this right now. I should create","a distraction.")
return true
}
}
return false
}
return false
}
fun Player.isInLongHouse(): Boolean{
return this.location.x >= 2655 && this.location.y >= 3665 && this.location.x <= 2662 && this.location.y <= 3681
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.USEWITH)
return this
}
}

View file

@ -1,65 +0,0 @@
package core.plugin.quest.fremtrials
import core.cache.def.impl.ItemDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.entity.impl.Animator
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.game.system.task.Pulse
import rs09.game.world.GameWorld
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import core.plugin.Initializable
import core.plugin.Plugin
@Initializable
class LyreOptionHandler : OptionHandler(){
val ids = arrayListOf(14591,14590,6127,6126,6125,3691,3690)
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
if(player?.questRepository?.getStage("Fremennik Trials")!! < 20){
player.sendMessage("You lack the knowledge to play this.")
return true
}
if(ids.isLast(ids.indexOf(node?.id))){
player.sendMessage("Your lyre is out of charges!")
} else {
player.inventory?.remove(node as Item)
player.inventory?.add(Item(ids.getNext(node?.id)))
player.lock()
GameWorld.submit(telePulse(player))
}
return true
}
class telePulse(val player: Player) : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(Animation(9600,Animator.Priority.VERY_HIGH), Graphics(1682))
6 -> player.properties.teleportLocation = Location.create(2661, 3646, 0)
7 -> player.unlock().also { return true }
}
return false
}
}
override fun newInstance(arg: Any?): Plugin<Any> {
for(id in ids){
ItemDefinition.forId(id).handlers.put("option:play",this)
}
return this
}
private fun <T> ArrayList<T>.getNext(any: Any?): T{ //gets the next member from a list
val indexOfCurrent = this.indexOf(any)
return get(indexOfCurrent + 1)
}
private fun <T> ArrayList<T>.isLast(current: Int): Boolean{
return current + 1 > size - 1
}
}

View file

@ -1,47 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.entity.player.Player
import core.game.node.item.Item
import rs09.game.world.GameWorld
import core.plugin.Initializable
import core.plugin.Plugin
@Initializable
class PipeInserter : PluginInteraction(4162){
override fun handle(player: Player?, node: Node?): Boolean {
class toPipePulse : MovementPulse(player,DestinationFlag.OBJECT.getDestination(player,node)) {
override fun pulse(): Boolean {
if(player?.inventory?.containsItem(Item(3714))!!){
player.sendMessage("You stuff the lit object into the pipe.")
player.setAttribute("/save:fremtrials:cherrybomb",true)
player.inventory?.remove(Item(3714))
} else {
player.sendMessage("What am I supposed to put in there? A shoe?")
}
return true
}
}
if(node is GameObject){
GameWorld.submit(toPipePulse())
return true
}
return false
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.OBJECT)
return this
}
}

View file

@ -1,61 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.game.system.task.Pulse
import rs09.game.world.GameWorld
import core.plugin.Initializable
import core.plugin.Plugin
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
import core.game.node.entity.skill.gather.SkillingTool
@Initializable
class SwayingTreeHandler : PluginInteraction(4142) {
class ChoppingPulse(val player: Player) : Pulse() {
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(SkillingTool.getHatchet(player).animation)
4 -> player.animator.reset().also { player.inventory.add(Item(3692));return true}
}
return false
}
}
override fun handle(player: Player?, node: Node?): Boolean {
class toTreePulse(player: Player) : MovementPulse(player,DestinationFlag.OBJECT.getDestination(player,node)){
override fun pulse(): Boolean {
SkillingTool.getHatchet(player)?.let { GameWorld.submit(ChoppingPulse(player!!)).also { return true } }
player?.sendMessage("You need an axe which you have the woodcutting level to use to do this.")
return true
}
}
if(node is GameObject){
if(!player?.inventory?.containsItem(Item(3692))!!){
GameWorld.submit(toTreePulse(player))
return true
} else {
player.sendMessage("You already have a branch.")
}
}
return false
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.OBJECT)
return this
}
}

View file

@ -1,34 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.entity.player.Player
import core.plugin.Initializable
import core.plugin.Plugin
import core.game.content.dialogue.FacialExpression
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
@Initializable
class SwensenLadder : PluginInteraction(4158){
override fun handle(player: Player?, node: Node?): Boolean {
if(node is GameObject){
if(player?.getAttribute("fremtrials:swensen-accepted",false) == false){
player.dialogueInterpreter?.sendDialogues(1283,FacialExpression.ANGRY,"Where do you think you're going?")
return true
}
}
return false
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.OBJECT)
return this
}
}

View file

@ -1,72 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.entity.player.Player
import rs09.game.world.GameWorld
import core.game.world.map.Location
import core.plugin.Initializable
import core.plugin.Plugin
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
@Initializable
class SwensenPortals : PluginInteraction(2273,2274,2506,2507,2508,2505,2503,2504,5138){
class destRoom(val swx: Int, val swy: Int, val nex: Int, val ney: Int)
fun destRoom.getCenter(): Location{
return Location((swx + nex) / 2, (swy + ney) / 2).transform(1,0,0)
}
override fun handle(player: Player?, node: Node?): Boolean {
val portal: GameObject? = node as GameObject
var toLocation: Location? = Location(0,0,0)
if(portal != null){
class toPortal(val to: GameObject?) : MovementPulse(player,DestinationFlag.OBJECT.getDestination(player,portal)){
override fun pulse(): Boolean {
when(to?.id){
2273 -> toLocation = destRoom(2639,10012,2645,10018).getCenter()
2274 -> toLocation = destRoom(2650,10034,2656,10040).getCenter()
2506 -> toLocation = destRoom(2662,10023,2669,10029).getCenter()
2507 -> toLocation = destRoom(2626,10023,2633,10029).getCenter()
2505 -> toLocation = destRoom(2650,10001,2656,10007).getCenter()
2503 -> toLocation = destRoom(2662,10012,2668,10018).getCenter()
2504 -> {toLocation = destRoom(2662,10034,2668,10039).getCenter(); player?.setAttribute("/save:fremtrials:maze-complete",true)}
5138 -> toLocation = getRandomLocation(player)
}
player?.properties?.teleportLocation = toLocation
return true;
}
}
GameWorld.submit(toPortal(portal))
return true
}
return false
}
fun getRandomLocation(player: Player?): Location{
var obj: GameObject? = null
while(obj?.id != 5138) {
val objects = player?.viewport?.chunks?.random()?.random()?.objects
obj = objects?.random()?.random()
if(obj == null || obj.location?.equals(Location(0,0,0))!!){
continue
}
}
return obj.location
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.OBJECT)
return this
}
}

View file

@ -0,0 +1,226 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.content.dialogue.FacialExpression
import core.game.node.`object`.GameObject
import core.game.node.entity.impl.Animator
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.skill.gather.SkillingTool
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import org.rs09.primextends.getNext
import org.rs09.primextends.isLast
import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld
import rs09.game.world.GameWorld.Pulser
class TFTInteractionListeners : InteractionListener(){
val BEER = Items.BEER_1917
val WORKER = NPCs.COUNCIL_WORKMAN_1287
val FISH_ALTAR = 4141
val LYRE = Items.LYRE_3689
val FISH = intArrayOf(Items.RAW_SHARK_383,Items.RAW_SEA_TURTLE_395,Items.RAW_MANTA_RAY_389)
val LOW_ALC_KEG = Items.LOW_ALCOHOL_KEG_3712
val KEG = Items.KEG_OF_BEER_3711
val TINDERBOX = Items.TINDERBOX_590
val CHERRY_BOMB = Items.STRANGE_OBJECT_3713
val LIT_BOMB = Items.LIT_STRANGE_OBJECT_3714
val PIPE = 4162
val PORTALIDs = intArrayOf(2273,2274,2506,2507,2505,2503,2504,5138)
val SWENSEN_LADDER = 4158
val SWAYING_TREE = 4142
val KNIFE = Items.KNIFE_946
val TREE_BRANCH = Items.BRANCH_3692
val LYRE_IDs = intArrayOf(14591,14590,6127,6126,6125,3691,3690)
override fun defineListeners() {
onUseWith(NPC,BEER,WORKER){ player, _, _ ->
player.dialogueInterpreter.open(CouncilWorkerFTDialogue(0,true), NPC(WORKER))
return@onUseWith true
}
onUseWith(OBJECT,FISH_ALTAR,*FISH){ player, _, fish ->
if(player.inventory.contains(LYRE,1)) {
Pulser.submit(spiritPulse(player, fish.id))
} else {
player.sendMessage("I should probably have my lyre with me.")
}
return@onUseWith true
}
onUseWith(ITEM,LOW_ALC_KEG,KEG){player,lowKeg,_ ->
if(!player.getAttribute("fremtrials:keg-mixed",false)!!){
if(player.getAttribute("fremtrials:cherrybomb",false)) {
player.inventory?.remove(lowKeg.asItem())
player.setAttribute("/save:fremtrials:keg-mixed", true)
player.sendMessage("The cherry bomb in the pipe goes off.")
RegionManager.getLocalEntitys(player).stream().forEach { e -> e.sendChat("What was THAT??") }
player.sendMessage("You mix the kegs together.")
return@onUseWith true
} else {
player.dialogueInterpreter?.sendDialogue("I can't do this right now. I should create","a distraction.")
return@onUseWith true
}
} else return@onUseWith false
}
onUseWith(ITEM,TINDERBOX,CHERRY_BOMB){player,_,bomb ->
player.inventory.remove(bomb.asItem())
player.inventory.add(Item(LIT_BOMB))
player.sendMessage("You light the strange object.")
return@onUseWith true
}
onUseWith(ITEM,KNIFE,TREE_BRANCH){player,knife,_ ->
if (player.inventory.containsItem(knife.asItem())) {
GameWorld.submit(BranchFletchingPulse(player))
} else {
player.sendMessage("You need a knife to do this.")
}
return@onUseWith true
}
on(LYRE_IDs,ITEM,"play"){player,lyre ->
if(player.questRepository?.getStage("Fremennik Trials")!! < 20){
player.sendMessage("You lack the knowledge to play this.")
return@on true
}
if(LYRE_IDs.isLast(lyre.id)){
player.sendMessage("Your lyre is out of charges!")
} else {
player.inventory?.remove(lyre.asItem())
player.inventory?.add(Item(LYRE_IDs.getNext(lyre.id)))
player.lock()
Pulser.submit(telePulse(player))
}
return@on true
}
on(PIPE,OBJECT,"put-inside"){player, _ ->
val bombItem = Item(LIT_BOMB)
if(player.inventory.containsItem(bombItem)){
player.sendMessage("You stuff the lit object into the pipe.")
player.setAttribute("/save:fremtrials:cherrybomb",true)
player.inventory.remove(bombItem)
} else {
player.sendMessage("What am I supposed to put in there? A shoe?")
}
return@on true
}
on(PORTALIDs,OBJECT,"use"){player,portal ->
val toLocation =
when(portal.id){
2273 -> destRoom(2639, 10012, 2645, 10018).getCenter()
2274 -> destRoom(2650, 10034, 2656, 10040).getCenter()
2506 -> destRoom(2662, 10023, 2669, 10029).getCenter()
2507 -> destRoom(2626, 10023, 2633, 10029).getCenter()
2505 -> destRoom(2650, 10001, 2656, 10007).getCenter()
2503 -> destRoom(2662, 10012, 2668, 10018).getCenter()
2504 -> {player.setAttribute("/save:fremtrials:maze-complete",true); destRoom(2662, 10034, 2668, 10039).getCenter()}
else -> getRandomLocation(player)
}
player.properties?.teleportLocation = toLocation
return@on true;
}
on(SWENSEN_LADDER,OBJECT,"climb"){player,_ ->
if(player.getAttribute("fremtrials:swensen-accepted",false) == false){
player.dialogueInterpreter?.sendDialogues(1283,FacialExpression.ANGRY,"Where do you think you're going?")
return@on true
}
return@on true
}
on(SWAYING_TREE,OBJECT,"chop down"){player,_ ->
SkillingTool.getHatchet(player)?.let { Pulser.submit(ChoppingPulse(player)).also { return@on true } }
player.sendMessage("You need an axe which you have the woodcutting level to use to do this.")
return@on true
}
}
class destRoom(val swx: Int, val swy: Int, val nex: Int, val ney: Int)
fun destRoom.getCenter(): Location {
return Location((swx + nex) / 2, (swy + ney) / 2).transform(1,0,0)
}
fun getRandomLocation(player: Player?): Location{
var obj: GameObject? = null
while(obj?.id != 5138) {
val objects = player?.viewport?.chunks?.random()?.random()?.objects
obj = objects?.random()?.random()
if(obj == null || obj.location?.equals(Location(0,0,0))!!){
continue
}
}
return obj.location
}
class spiritPulse(val player: Player?, val fish: Int) : Pulse(){
var counter = 0
val npc = NPC(1273,player?.location)
override fun pulse(): Boolean {
when(counter++){
0 -> npc.init().also { player?.lock() }.also { player?.inventory?.remove(Item(fish)) }
1 -> npc.moveStep()
2 -> npc.face(player).also { player?.face(npc) }
3 -> player?.dialogueInterpreter?.sendDialogues(npc,
FacialExpression.HAPPY,"I will kindly accept this offering, and","bestow upon you a gift in return.")
4 -> player?.inventory?.remove(Item(3689))
5 -> when(fish){
383 -> player?.inventory?.add(Item(6125))
389 -> player?.inventory?.add(Item(6126))
395 -> player?.inventory?.add(Item(6127))
}
6 -> player?.unlock()
10 -> npc.clear().also { return true }
}
return false
}
}
class ChoppingPulse(val player: Player) : Pulse() {
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(SkillingTool.getHatchet(player).animation)
4 -> player.animator.reset().also { player.inventory.add(Item(3692));return true}
}
return false
}
}
class BranchFletchingPulse(val player: Player?) : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player?.animator?.animate(Animation(1248)).also { player!!.lock() }
3 -> player?.inventory?.remove(Item(Items.BRANCH_3692)).also { player?.inventory?.add(Item(Items.UNSTRUNG_LYRE_3688)); player!!.unlock(); return true}
}
return false
}
}
class telePulse(val player: Player) : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(Animation(9600, Animator.Priority.VERY_HIGH), Graphics(1682))
6 -> player.properties.teleportLocation = Location.create(2661, 3646, 0)
7 -> player.unlock().also { return true }
}
return false
}
}
}

View file

@ -1,34 +0,0 @@
package rs09.game.content.quest.members.thefremenniktrials
import core.game.interaction.NodeUsageEvent
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.plugin.Initializable
import core.plugin.Plugin
import core.game.content.quest.PluginInteraction
import core.game.content.quest.PluginInteractionManager
@Initializable
class TinderboxOnBomb : PluginInteraction(3713){
override fun handle(player: Player?, event: NodeUsageEvent?): Boolean {
val with = event?.usedWith
if(with is Item && with.id.equals(590)){
player?.inventory?.remove(event.used as Item)
player?.inventory?.add(Item(3714))
player?.sendMessage("You light the strange object.")
return true
}
return false
}
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
return Unit
}
override fun newInstance(arg: Any?): Plugin<Any> {
PluginInteractionManager.register(this,PluginInteractionManager.InteractionType.USEWITH)
return this
}
}

View file

@ -57,9 +57,9 @@ class BoneGrinderListener : InteractionListener() {
/** /**
* Handle Bone -> Hopper * Handle Bone -> Hopper
*/ */
on(OBJECT,LOADER,*boneIDs){player,_,_ -> onUseWith(OBJECT,LOADER,*boneIDs){ player, _, _ ->
handleFill(player) handleFill(player)
return@on true return@onUseWith true
} }
} }

View file

@ -19,10 +19,10 @@ abstract class InteractionListener : Listener{
fun on(type: Int, vararg option: String, handler: (Player, Node) -> Boolean){ fun on(type: Int, vararg option: String, handler: (Player, Node) -> Boolean){
Listeners.add(option,type,handler) Listeners.add(option,type,handler)
} }
fun on(used: Int, with: Int, type: Int, handler: (Player, Node, Node) -> Boolean){ fun onUseWith(type: Int, used: Int, vararg with: Int, handler: (Player, Node, Node) -> Boolean){
Listeners.add(used,with,type,handler) Listeners.add(type,used,with,handler)
} }
fun on(type: Int,used: Int,vararg with: Int, handler: (Player, Node, Node) -> Boolean){ fun onUseWith(type: Int, used: IntArray, vararg with: Int, handler: (Player, Node, Node) -> Boolean){
Listeners.add(type,used,with,handler) Listeners.add(type,used,with,handler)
} }
} }

View file

@ -115,4 +115,12 @@ object Listeners {
} }
return true return true
} }
fun add(type: Int, used: IntArray, with: IntArray, handler: (Player, Node, Node) -> Boolean) {
for(u in used){
for (w in with){
useWithListeners["$u:$w:$type"] = handler
}
}
}
} }

View file

@ -54,7 +54,7 @@ class CoalTruckInteractionListeners : InteractionListener() {
return@on true return@on true
} }
on(COAL,COAL_TRUCK_2114,OBJECT){player,_,_ -> onUseWith(OBJECT,COAL,COAL_TRUCK_2114){ player, _, _ ->
var coalInTruck = player.getAttribute("coal-truck-inventory", 0) var coalInTruck = player.getAttribute("coal-truck-inventory", 0)
var coalInInventory = player.inventory.getAmount(Items.COAL_453) var coalInInventory = player.inventory.getAmount(Items.COAL_453)
@ -74,7 +74,7 @@ class CoalTruckInteractionListeners : InteractionListener() {
coalInTruck += coalInInventory coalInTruck += coalInInventory
player.setAttribute("/save:coal-truck-inventory",coalInTruck) player.setAttribute("/save:coal-truck-inventory",coalInTruck)
return@on true return@onUseWith true
} }
} }
} }

View file

@ -2,6 +2,10 @@ package rs09.game.node.entity.combat.equipment
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
import core.game.node.item.Item import core.game.node.item.Item
import org.rs09.primextends.getNext
import org.rs09.primextends.isLast
import org.rs09.primextends.isNextLast
/** /**
* Handles equipment degrading * Handles equipment degrading
* @author ceik * @author ceik
@ -81,17 +85,4 @@ class EquipmentDegrader{
} }
return null return null
} }
private fun <T> ArrayList<T>.getNext(any: Any?): T{ //gets the next member from a list
val indexOfCurrent = this.indexOf(any)
return get(indexOfCurrent + 1)
}
private fun <T> ArrayList<T>.isNextLast(current: Int): Boolean{ //checks if the next member in a list is last.
return current + 1 >= size - 1
}
private fun <T> ArrayList<T>.isLast(current: Int): Boolean{
return current + 1 > size - 1
}
} }