Merge remote-tracking branch 'origin/master'

This commit is contained in:
Woah
2021-03-12 23:59:11 -05:00
14 changed files with 348 additions and 452 deletions
@@ -1,22 +1,17 @@
package rs09.game.content.activity.allfiredup
import core.cache.def.impl.ObjectDefinition
import core.game.content.dialogue.FacialExpression
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.node.entity.skill.Skills
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.world.GameWorld
private val VALID_LOGS = arrayOf(Items.LOGS_1511,
Items.OAK_LOGS_1521,Items.WILLOW_LOGS_1519,Items.MAPLE_LOGS_1517,Items.YEW_LOGS_1515,Items.MAGIC_LOGS_1513)
private val VALID_LOGS = intArrayOf(Items.LOGS_1511, Items.OAK_LOGS_1521,Items.WILLOW_LOGS_1519,Items.MAPLE_LOGS_1517,Items.YEW_LOGS_1515,Items.MAGIC_LOGS_1513)
private val FILL_ANIM = Animation(9136)
private val LIGHT_ANIM = Animation(7307)
@@ -24,44 +19,35 @@ private val LIGHT_ANIM = Animation(7307)
* Handles interactions for beacons
* @author Ceikry
*/
@Initializable
class AFUBeaconHandler : OptionHandler(){
override fun newInstance(arg: Any?): Plugin<Any> {
for(i in 38448..38461)
ObjectDefinition.forId(i).childrenIds.forEach {
ObjectDefinition.forId(it).handlers["option:add-logs"] = this
ObjectDefinition.forId(it).handlers["option:light"] = this
}
return this
}
class AFUBeaconListeners : OptionListener(){
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
player ?: return false
node ?: return false
val beacon = AFUBeacon.forLocation(node.location)
val questComplete = player.questRepository.isComplete("All Fired Up")
val questStage = player.questRepository.getStage("All Fired Up")
override fun defineListeners() {
on(OBJECT,"add-logs","light"){player,node ->
val beacon = AFUBeacon.forLocation(node.location)
val questComplete = player.questRepository.isComplete("All Fired Up")
val questStage = player.questRepository.getStage("All Fired Up")
if ((beacon != AFUBeacon.RIVER_SALVE && beacon != AFUBeacon.RAG_AND_BONE && !questComplete)
if ((beacon != AFUBeacon.RIVER_SALVE && beacon != AFUBeacon.RAG_AND_BONE && !questComplete)
|| (beacon == AFUBeacon.RIVER_SALVE && questStage < 20 && !questComplete)
|| (beacon == AFUBeacon.RAG_AND_BONE && questStage < 50 && !questComplete)) {
player.dialogueInterpreter.sendDialogues(player, FacialExpression.THINKING, "I probably shouldn't mess with this.")
return true
}
player.debug(beacon.getState(player).name)
when (beacon.getState(player)) {
BeaconState.EMPTY -> fillBeacon(player, beacon, questComplete)
BeaconState.DYING -> restoreBeacon(player, beacon, questComplete)
BeaconState.FILLED -> lightBeacon(player, beacon, questComplete)
BeaconState.LIT, BeaconState.WARNING -> {
player.debug("INVALID BEACON STATE")
player.dialogueInterpreter.sendDialogues(player, FacialExpression.THINKING, "I probably shouldn't mess with this.")
return@on true
}
player.debug(beacon.getState(player).name)
when (beacon.getState(player)) {
BeaconState.EMPTY -> fillBeacon(player, beacon, questComplete)
BeaconState.DYING -> restoreBeacon(player, beacon, questComplete)
BeaconState.FILLED -> lightBeacon(player, beacon, questComplete)
BeaconState.LIT, BeaconState.WARNING -> {
player.debug("INVALID BEACON STATE")
}
}
return@on true
}
return true
}
fun fillBeacon(player: Player, beacon: AFUBeacon, questComplete: Boolean){
@@ -1,8 +1,5 @@
package rs09.game.content.activity.allfiredup
import core.cache.def.impl.ObjectDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.entity.impl.ForceMovement
import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills
@@ -12,8 +9,8 @@ import core.game.world.map.Direction
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import java.util.*
/**
@@ -21,27 +18,27 @@ import java.util.*
* @author Ceikry
*/
@Initializable
class AFURepairClimbHandler : OptionHandler() {
override fun newInstance(arg: Any?): Plugin<Any> {
ObjectDefinition.forId(38480).handlers["option:repair"] = this
ObjectDefinition.forId(38470).handlers["option:repair"] = this
ObjectDefinition.forId(38494).handlers["option:repair"] = this
ObjectDefinition.forId(38469).handlers["option:climb"] = this
ObjectDefinition.forId(38471).handlers["option:climb"] = this
ObjectDefinition.forId(38486).handlers["option:climb"] = this
ObjectDefinition.forId(38481).handlers["option:climb"] = this
ObjectDefinition.forId(38469).handlers["option:climb"] = this
return this
}
class AFURepairClimbHandler : OptionListener() {
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
player ?: return false
node ?: return false
var rco: RepairClimbObject = RepairClimbObject.GWD
for(ent in RepairClimbObject.values()) if(ent.destinationDown?.withinDistance(player.location,2) == true || ent.destinationUp?.withinDistance(player.location,2) == true) rco = ent
val repairIDs = intArrayOf(38480,38470,38494)
val climbIDs = intArrayOf(38469,38471,38486,38481,38469)
override fun defineListeners() {
on(repairIDs,OBJECT,"repair"){player,_ ->
var rco: RepairClimbObject = RepairClimbObject.GWD
for(ent in RepairClimbObject.values()) if(ent.destinationDown?.withinDistance(player.location,2) == true || ent.destinationUp?.withinDistance(player.location,2) == true) rco = ent
repair(player,rco)
return@on true
}
on(climbIDs,OBJECT,"climb"){player,node ->
var rco: RepairClimbObject = RepairClimbObject.GWD
for(ent in RepairClimbObject.values()) if(ent.destinationDown?.withinDistance(player.location,2) == true || ent.destinationUp?.withinDistance(player.location,2) == true) rco = ent
climb(player,rco,node.location)
return@on true
}
if(option.equals("repair")) repair(player,rco) else climb(player,rco,node.location)
return true
}
private fun repair(player: Player,rco: RepairClimbObject){
@@ -1,12 +1,8 @@
package rs09.game.content.activity.fishingtrawler
import core.cache.def.impl.ItemDefinition
import core.cache.def.impl.ObjectDefinition
import core.game.content.activity.ActivityManager
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills
import core.game.node.item.GroundItemManager
@@ -15,8 +11,8 @@ import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.node.entity.player.info.stats.FISHING_TRAWLER_LEAKS_PATCHED
import rs09.game.node.entity.player.info.stats.STATS_BASE
import rs09.tools.stringtools.colorize
@@ -27,135 +23,137 @@ import kotlin.math.ceil
* @author Ceikry
*/
@Initializable
class FishingTrawlerOptionHandler : OptionHandler() {
override fun newInstance(arg: Any?): Plugin<Any> {
ObjectDefinition.forId(2178).handlers["option:cross"] = this
ObjectDefinition.forId(2167).handlers["option:fill"] = this
ObjectDefinition.forId(2164).handlers["option:inspect"] = this
ObjectDefinition.forId(2165).handlers["option:inspect"] = this
ObjectDefinition.forId(2166).handlers["option:inspect"] = this
ObjectDefinition.forId(2160).handlers["option:climb-on"] = this
ObjectDefinition.forId(2159).handlers["option:climb-on"] = this
ObjectDefinition.forId(2179).handlers["option:cross"] = this
ObjectDefinition.forId(255).handlers["option:operate"] = this
ItemDefinition.forId(583).handlers["option:bail-with"] = this
ItemDefinition.forId(585).handlers["option:empty"] = this
return this
}
class FishingTrawlerOptionHandler : OptionListener() {
val ENTRANCE_PLANK = 2178
val EXIT_PLANK = 2179
val HOLE = 2167
val NETIDs = intArrayOf(2164,2165)
val REWARD_NET = 2166
val BARREL_IDS = intArrayOf(2159,2160)
val BAILING_BUCKET = 583
val FULL_BAIL_BUCKET = 585
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
player ?: return false
when(node?.id){
2178 -> { //Cross plank onto boat
if(player.skills.getLevel(Skills.FISHING) < 15){
player.dialogueInterpreter.sendDialogue("You need to be at least level 15 fishing to play.")
return true
}
player.properties.teleportLocation = Location.create(2672, 3170, 1)
(ActivityManager.getActivity("fishing trawler") as FishingTrawlerActivity).addPlayer(player)
override fun defineListeners() {
on(ENTRANCE_PLANK,OBJECT,"cross"){player,_ ->
if(player.skills.getLevel(Skills.FISHING) < 15){
player.dialogueInterpreter.sendDialogue("You need to be at least level 15 fishing to play.")
return@on true
}
2167 -> { //Fill hole
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
session ?: return false
player.lock()
player.pulseManager.run(object : Pulse(){
player.properties.teleportLocation = Location.create(2672, 3170, 1)
(ActivityManager.getActivity("fishing trawler") as FishingTrawlerActivity).addPlayer(player)
return@on true
}
on(EXIT_PLANK,OBJECT,"cross"){player,_ ->
player.properties.teleportLocation = Location.create(2676, 3170, 0)
(ActivityManager.getActivity("fishing trawler") as FishingTrawlerActivity).removePlayer(player)
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
session?.players?.remove(player)
player.logoutPlugins.clear()
return@on true
}
on(HOLE,OBJECT,"fill"){player,node ->
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
session ?: return@on false
player.lock()
player.pulseManager.run(object : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(Animation(827)).also { player.lock() }
1 -> session.repairHole(player,node.asObject()).also { player.incrementAttribute("/save:$STATS_BASE:$FISHING_TRAWLER_LEAKS_PATCHED"); player.unlock() }
2 -> return true
}
return false
}
})
return@on true
}
on(NETIDs,OBJECT,"inspect"){player,_ ->
player.dialogueInterpreter.open(18237583)
return@on true
}
on(REWARD_NET,OBJECT,"inspect"){player,_ ->
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
if(session == null || session.boatSank){
player.dialogueInterpreter.sendDialogues(player, FacialExpression.GUILTY,"I'd better not go stealing other people's fish.")
return@on true
}
player.dialogueInterpreter.open(18237582)
return@on true
}
on(BARREL_IDS,OBJECT,"climb-on"){player,_ ->
player.properties.teleportLocation = Location.create(2672, 3222, 0)
player.dialogueInterpreter.sendDialogue("You climb onto the floating barrel and begin to kick your way to the","shore.","You make it to the shore tired and weary.")
player.logoutPlugins.clear()
player.appearance.setDefaultAnimations()
player.appearance.sync()
return@on true
}
on(FULL_BAIL_BUCKET,ITEM,"empty"){player,node ->
player.lock()
player.pulseManager.run(
object : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(Animation(827)).also { player.lock() }
1 -> session.repairHole(player,node.asObject()).also { player.incrementAttribute("/save:$STATS_BASE:$FISHING_TRAWLER_LEAKS_PATCHED"); player.unlock() }
2 -> return true
0 -> player.animator.animate(Animation(2450))
1 -> {
if(player.inventory.remove(node.asItem()))
player.inventory.add(Item(Items.BAILING_BUCKET_583))
player.unlock()
return true
}
}
return false
}
})
}
2164,2165 -> { //inspect net
player.dialogueInterpreter.open(18237583)
}
2166 -> { //inspect reward net
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
if(session == null || session.boatSank){
player.dialogueInterpreter.sendDialogues(player, FacialExpression.GUILTY,"I'd better not go stealing other people's fish.")
return true
}
player.dialogueInterpreter.open(18237582)
}
2179 -> { //plank from boat to dock
player.properties.teleportLocation = Location.create(2676, 3170, 0)
(ActivityManager.getActivity("fishing trawler") as FishingTrawlerActivity).removePlayer(player)
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
session?.players?.remove(player)
player.logoutPlugins.clear()
}
2159,2160 -> { //barrel
player.properties.teleportLocation = Location.create(2672, 3222, 0)
player.dialogueInterpreter.sendDialogue("You climb onto the floating barrel and begin to kick your way to the","shore.","You make it to the shore tired and weary.")
player.logoutPlugins.clear()
player.appearance.setDefaultAnimations()
player.appearance.sync()
}
583 -> { //bail-with bucket
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
session ?: return false
if(!session.isActive){
return false
}
if(player.location.y > 0){
player.sendMessage("You can't scoop water out up here.")
return true
}
player.lock()
player.pulseManager.run(
object : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(Animation(4471))
1 -> if(player.inventory.remove(node.asItem())) {
if (session.waterAmount > 0) {
session.waterAmount -= 20
if (session.waterAmount < 0) session.waterAmount = 0
player.inventory.add(Item(Items.BAILING_BUCKET_585))
} else {
player.sendMessage("There's no water to remove.")
player.inventory.add(node.asItem())
}
}
2 -> player.unlock().also { return true }
}
return false
}
}
)
}
585 -> { //Empty bailing bucket
player.lock()
player.pulseManager.run(
object : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(Animation(2450))
1 -> {
if(player.inventory.remove(node.asItem()))
player.inventory.add(Item(Items.BAILING_BUCKET_583))
player.unlock()
return true
}
}
return false
}
}
)
}
255 -> {//operate winch
player.sendMessage("It seems the winch is jammed - I can't move it.")
}
)
return@on true
}
return true
}
on(BAILING_BUCKET,ITEM,"bail-with") { player, node ->
val session: FishingTrawlerSession? = player.getAttribute("ft-session",null)
session ?: return@on false
if(!session.isActive){
return@on false
}
if(player.location.y > 0){
player.sendMessage("You can't scoop water out up here.")
return@on true
}
player.lock()
player.pulseManager.run(
object : Pulse(){
var counter = 0
override fun pulse(): Boolean {
when(counter++){
0 -> player.animator.animate(Animation(4471))
1 -> if(player.inventory.remove(node.asItem())) {
if (session.waterAmount > 0) {
session.waterAmount -= 20
if (session.waterAmount < 0) session.waterAmount = 0
player.inventory.add(Item(Items.BAILING_BUCKET_585))
} else {
player.sendMessage("There's no water to remove.")
player.inventory.add(node.asItem())
}
}
2 -> player.unlock().also { return true }
}
return false
}
}
)
return@on true
}
}
}
@Initializable
@@ -1,4 +1,4 @@
package core.plugin.quest.fremtrials
package rs09.game.content.quest.members.thefremenniktrials
import core.game.content.dialogue.FacialExpression
import core.game.content.quest.PluginInteraction
@@ -0,0 +1,32 @@
package rs09.game.interaction.city
import core.game.world.map.Location
import core.plugin.Initializable
import rs09.game.interaction.OptionListener
/**
* File to be used for anything Isafdar related.
* Handles the summoning/altar cave enter and exit in Isafdar.
* @author Sir Kermit
*/
@Initializable
class IsafdarListeners : OptionListener() {
val CAVE_ENTRANCE = 4006
val CAVE_EXIT = 4007
val outside = Location.create(2312, 3217, 0)
val inside = Location.create(2314, 9624, 0)
override fun defineListeners() {
on(CAVE_ENTRANCE,OBJECT,"enter"){player,node ->
player.teleport(inside)
return@on true
}
on(CAVE_EXIT,OBJECT,"exit"){player,node ->
player.teleport(outside)
return@on true
}
}
}
@@ -1,58 +0,0 @@
package rs09.game.interaction.city
import core.cache.def.impl.ObjectDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.entity.player.Player
import core.game.world.map.Location
import core.plugin.Initializable
import core.plugin.Plugin
/**
* File to be used for anything Isafdar related.
* Handles the summoning/altar cave enter and exit in Isafdar.
* @author Sir Kermit
*/
@Initializable
class IsafdarPlugin : OptionHandler() {
@Throws(Throwable::class)
override fun newInstance(arg: Any?): Plugin<Any?> {
//Outside Cave
ObjectDefinition.forId(4006).handlers["option:enter"] = this
//Inside Cave
ObjectDefinition.forId(4007).handlers["option:exit"] = this
return this
}
override fun handle(player: Player, node: Node, option: String): Boolean {
val id = (node as GameObject).id
val outside = Location.create(2312, 3217, 0)
val inside = Location.create(2314, 9624, 0)
when (id) {
//Handles sending the player inside of the cave.
4006 -> {
if (node.id == 4006) {
player.teleport(inside)
return true
}
}
//Handles sending the player outside of the cave.
4007 -> {
if (node.id == 4007) {
player.teleport(outside)
return true
}
}
}
return false
}
}
@@ -0,0 +1,47 @@
package rs09.game.interaction.city
import core.game.node.entity.impl.ForceMovement
import core.game.world.map.Direction
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import rs09.game.interaction.OptionListener
/**
* File to be used for anything Morytania related.
* Handles the summoning/altar cave enter and exit in Morytania.
* @author Sir Kermit
*/
@Initializable
class MorytaniaListeners : OptionListener() {
val GROTTO_ENTRANCE = 3516
val GROTTO_EXIT = 3526
val GROTTO_BRIDGE = 3522
val outside = Location.create(3439, 3337, 0)
val inside = Location.create(3442, 9734, 1)
private val RUNNING_ANIM = Animation(1995)
private val JUMP_ANIM = Animation(1603)
override fun defineListeners() {
on(GROTTO_ENTRANCE,OBJECT,"enter"){player,node ->
player.teleport(inside)
return@on true
}
on(GROTTO_EXIT,OBJECT,"exit"){player,node ->
player.teleport(outside)
return@on true
}
on(GROTTO_BRIDGE,OBJECT,"jump"){player,node ->
if (player.location.y == 3328) {
ForceMovement.run(player, node.location, node.location.transform(0, 3, 0), RUNNING_ANIM, JUMP_ANIM, Direction.NORTH, 15).endAnimation = Animation.RESET
} else if (player.location.y == 3332){
ForceMovement.run(player, node.location, node.location.transform(0, -3, 0), RUNNING_ANIM, JUMP_ANIM, Direction.SOUTH, 15).endAnimation = Animation.RESET
}
return@on true
}
}
}
@@ -1,67 +0,0 @@
package rs09.game.interaction.city
import core.cache.def.impl.ObjectDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.entity.impl.ForceMovement
import core.game.node.entity.player.Player
import core.game.world.map.Direction
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
/**
* File to be used for anything Morytania related.
* Handles the summoning/altar cave enter and exit in Morytania.
* @author Sir Kermit
*/
@Initializable
class MorytaniaPlugin : OptionHandler() {
@Throws(Throwable::class)
override fun newInstance(arg: Any?): Plugin<Any?> {
//Outside Grotto
ObjectDefinition.forId(3516).handlers["option:enter"] = this
//Inside Grotto
ObjectDefinition.forId(3526).handlers["option:exit"] = this
//Bridge Outside Grotto
ObjectDefinition.forId(3522).handlers["option:jump"] = this
return this
}
private val RUNNING_ANIM = Animation(1995)
private val JUMP_ANIM = Animation(1603)
override fun handle(player: Player, node: Node, option: String): Boolean {
val id = (node as GameObject).id
val outside = Location.create(3439, 3337, 0)
val inside = Location.create(3442, 9734, 1)
when (id) {
//Handles sending the player inside of the cave.
3516 -> {
if (node.id == 3516) {
player.teleport(inside)
return true
}
}
//Handles sending the player outside of the cave.
3526 -> {
if (node.id == 3526) {
player.teleport(outside)
return true
}
}
//Handles Jumping over grotto bridge
3522 -> if (player.location.y == 3328) {
ForceMovement.run(player, node.location, node.location.transform(0, 3, 0), RUNNING_ANIM, JUMP_ANIM, Direction.NORTH, 15).endAnimation = Animation.RESET
} else if (player.location.y == 3332){
ForceMovement.run(player, node.location, node.location.transform(0, -3, 0), RUNNING_ANIM, JUMP_ANIM, Direction.SOUTH, 15).endAnimation = Animation.RESET
}
}
return false
}
}
@@ -1,32 +1,23 @@
package rs09.game.interaction.item
import core.cache.def.impl.ItemDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.entity.player.Player
import core.plugin.Initializable
import core.plugin.Plugin
import rs09.game.interaction.OptionListener
/**
* Handles the bracelet of clay operate option.
* @author Ceikry
*/
@Initializable
class BraceletOfClayPlugin : OptionHandler() {
class BraceletOfClayPlugin : OptionListener() {
override fun newInstance(arg: Any?): Plugin<Any>? {
ItemDefinition.forId(11074).handlers["option:operate"] = this
return this
}
val BRACELET = 11074
override fun handle(player: Player, node: Node, option: String): Boolean {
var charge = node.asItem().charge
if (charge > 28) charge = 28
player.sendMessage("You have $charge uses left.")
return true
}
override fun defineListeners() {
on(BRACELET,ITEM,"operate"){player,node ->
var charge = node.asItem().charge
if (charge > 28) charge = 28
player.sendMessage("You have $charge uses left.")
return@on true
}
override fun isWalk(): Boolean {
return false
}
}
@@ -1,38 +1,31 @@
package rs09.game.interaction.`object`
import core.cache.def.impl.ObjectDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.entity.player.link.emote.Emotes
import core.game.world.map.RegionManager
import core.plugin.Initializable
import core.plugin.Plugin
import rs09.game.interaction.OptionListener
@Initializable
/**
* Handles taunting of the demon in the wizard's tower
* @author afaroutdude / Ceikry
*/
class DemonTauntHandler : OptionHandler(){
override fun newInstance(arg: Any?): Plugin<Any> {
ObjectDefinition.forId(37668).handlers["option:taunt-through"] = this
return this
}
private const val BARS = 37668
class DemonTauntHandler : OptionListener(){
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
player ?: return false
player.packetDispatch.sendMessage("You taunt the demon, making it growl.")
val localNpcs = RegionManager.getLocalNpcs(player)
player.animator.animate(Emotes.RASPBERRY.animation)
for (npc in localNpcs) {
if (npc.id == 82) {
npc.sendChat("Graaaagh!", 1)
player.faceLocation(npc.location)
override fun defineListeners() {
on(BARS,OBJECT,"taunt-through"){player,_ ->
player.packetDispatch.sendMessage("You taunt the demon, making it growl.")
val localNpcs = RegionManager.getLocalNpcs(player)
player.animator.animate(Emotes.RASPBERRY.animation)
for (npc in localNpcs) {
if (npc.id == 82) {
npc.sendChat("Graaaagh!", 1)
player.faceLocation(npc.location)
}
}
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 13)
return@on true
}
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 13)
return true
}
}
@@ -1,14 +1,10 @@
package rs09.game.interaction.`object`
import core.cache.def.impl.ObjectDefinition
import core.game.component.Component
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.TeleportManager.TeleportType
import core.game.world.map.Location
import core.plugin.Initializable
import core.plugin.Plugin
import rs09.game.interaction.OptionListener
/**
* Handles interactions with fairy rings
@@ -19,30 +15,28 @@ private val RINGS = intArrayOf(12003, 12094, 12095, 14058, 14061, 14064, 14067,
private const val MAIN_RING = 12128
@Initializable
class FairyRingPlugin : OptionHandler() {
override fun newInstance(arg: Any?): Plugin<Any> {
for (i in RINGS) {
ObjectDefinition.forId(i).handlers["option:use"] = this
}
ObjectDefinition.forId(MAIN_RING).handlers["option:use"] = this
return this
}
class FairyRingPlugin : OptionListener() {
override fun handle(player: Player, node: Node, option: String): Boolean {
when (option) {
"use" -> {
if (!player.equipment.contains(772, 1) && !player.equipment.contains(9084, 1)) {
player.sendMessage("The fairy ring only works for those who wield fairy magic.")
return true
}
when (node.id) {
MAIN_RING -> openFairyRing(player)
else -> player.teleporter.send(Location.create(2412, 4434, 0), TeleportType.FAIRY_RING)
}
override fun defineListeners() {
on(RINGS,OBJECT,"use"){player,_ ->
if (!player.equipment.contains(772, 1) && !player.equipment.contains(9084, 1)) {
player.sendMessage("The fairy ring only works for those who wield fairy magic.")
return@on true
}
player.teleporter.send(Location.create(2412, 4434, 0), TeleportType.FAIRY_RING)
return@on true
}
return true
on(MAIN_RING,OBJECT,"use"){player,_ ->
if (!player.equipment.contains(772, 1) && !player.equipment.contains(9084, 1)) {
player.sendMessage("The fairy ring only works for those who wield fairy magic.")
return@on true
}
openFairyRing(player)
return@on true
}
}
private fun reset(player: Player) {
@@ -1,8 +1,5 @@
package rs09.game.interaction.`object`
import core.cache.def.impl.ObjectDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.`object`.ObjectBuilder
import core.game.node.entity.npc.NPC
@@ -11,24 +8,22 @@ import core.game.node.item.GroundItemManager
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.world.GameWorld
import java.util.concurrent.TimeUnit
@Initializable
class GutanothChestOptionHandler : OptionHandler(){
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
player ?: return false
val delay = player.getAttribute("gutanoth-chest-delay", 0L)
GameWorld.Pulser.submit(ChestPulse(player,System.currentTimeMillis() > delay, node as GameObject))
return true
}
private const val CHEST = 2827
class GutanothChestOptionHandler : OptionListener(){
override fun defineListeners() {
on(CHEST,OBJECT,"open"){player,node ->
val delay = player.getAttribute("gutanoth-chest-delay", 0L)
GameWorld.Pulser.submit(ChestPulse(player,System.currentTimeMillis() > delay, node as GameObject))
return@on true
}
override fun newInstance(arg: Any?): Plugin<Any> {
ObjectDefinition.forId(2827).handlers["option:open"] = this
return this
}
class ChestPulse(val player: Player, val isLoot: Boolean, val chest: GameObject): Pulse(){
@@ -1,57 +1,49 @@
package rs09.game.interaction.`object`
import core.cache.def.impl.ObjectDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.`object`.ObjectBuilder
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.world.GameWorld
/**
* Handles the chopping down of dense jungle, mainly to grant access to the Kharazi Jungle.
* @author Ceikry
*/
@Initializable
class JungleBushHandler : OptionHandler(){
class JungleBushHandler : OptionListener(){
val chopped_bush = 2895
val chop_a = Animation(910)
val chop_b = Animation(2382)
val ids = intArrayOf(2892,2893)
override fun newInstance(arg: Any?): Plugin<Any> {
ObjectDefinition.forId(2892).handlers["option:chop-down"] = this
ObjectDefinition.forId(2893).handlers["option:chop-down"] = this
return this
}
override fun defineListeners() {
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
player ?: return false
node ?: return false
val toChop = node.asObject()
if(checkRequirement(player)){
GameWorld.Pulser.submit(object : Pulse(0){
var ticks = 0
override fun pulse(): Boolean {
when(ticks++){
0 -> player.animator.animate(chop_a).also { player.lock() }
1 -> player.animator.animate(chop_b)
2 -> ObjectBuilder.replace(toChop, GameObject(chopped_bush, toChop.location, toChop.rotation),20)
3 -> {player.walkingQueue.reset(); player.walkingQueue.addPath(toChop.location.x, toChop.location.y,true)}
4 -> player.unlock().also { return true }
on(ids,OBJECT,"chop-down"){player,node ->
val toChop = node.asObject()
if(checkRequirement(player)){
GameWorld.Pulser.submit(object : Pulse(0){
var ticks = 0
override fun pulse(): Boolean {
when(ticks++){
0 -> player.animator.animate(chop_a).also { player.lock() }
1 -> player.animator.animate(chop_b)
2 -> ObjectBuilder.replace(toChop, GameObject(chopped_bush, toChop.location, toChop.rotation),20)
3 -> {player.walkingQueue.reset(); player.walkingQueue.addPath(toChop.location.x, toChop.location.y,true)}
4 -> player.unlock().also { return true }
}
return false
}
return false
}
})
} else {
player.sendMessage("You need a machete to get through this dense jungle.")
})
} else {
player.sendMessage("You need a machete to get through this dense jungle.")
}
return@on true
}
return true
}
fun checkRequirement(player: Player): Boolean{
@@ -1,47 +1,43 @@
package rs09.game.interaction.`object`
import core.cache.def.impl.ObjectDefinition
import core.game.interaction.OptionHandler
import core.game.node.Node
import core.game.node.`object`.GameObject
import core.game.node.`object`.ObjectBuilder
import core.game.node.entity.player.Player
import core.game.node.item.GroundItemManager
import core.game.node.item.Item
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
@Initializable
/**
* Handles the muddy chest
* @author Ceikry
*/
class MuddyChestHandler : OptionHandler() {
override fun newInstance(arg: Any?): Plugin<Any> {
ObjectDefinition.forId(170).handlers["option:open"] = this
return this
}
class MuddyChestHandler : OptionListener() {
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
player ?: return false
node ?: return false
val key = Item(Items.MUDDY_KEY_991)
if(player.inventory.containsItem(key)){
player.inventory.remove(key)
player.animator.animate(Animation(536))
ObjectBuilder.replace(node.asObject(),GameObject(171, node.location, node.asObject().rotation),3)
for(item in chestLoot){
if(!player.inventory.add(item)) GroundItemManager.create(item,player)
private val CHEST = 170
override fun defineListeners() {
on(CHEST,OBJECT,"open"){player,node ->
val key = Item(Items.MUDDY_KEY_991)
if(player.inventory.containsItem(key)){
player.inventory.remove(key)
player.animator.animate(Animation(536))
ObjectBuilder.replace(node.asObject(),GameObject(171, node.location, node.asObject().rotation),3)
for(item in chestLoot){
if(!player.inventory.add(item)) GroundItemManager.create(item,player)
}
} else {
player.sendMessage("This chest is locked and needs some sort of key.")
}
} else {
player.sendMessage("This chest is locked and needs some sort of key.")
return@on true
}
return true
}
val chestLoot = arrayListOf(
val chestLoot = arrayOf(
Item(Items.UNCUT_RUBY_1619),
Item(Items.MITHRIL_BAR_2359),
Item(Items.MITHRIL_DAGGER_1209),