mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-14 10:30:20 -07:00
More handlers converted to listeners
This commit is contained in:
parent
a2a8d32d4b
commit
1de42426de
9 changed files with 257 additions and 331 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue