diff --git a/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt b/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt index 92cae5489..d7d1a59db 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt @@ -35,4 +35,8 @@ abstract class InteractionListener : Listener{ fun setDest(type:Int, vararg options: String, handler: (Node) -> Location){ InteractionListeners.addDestOverrides(type,options,handler) } + + fun setDest(type: Int, ids: IntArray, vararg options: String, handler: (Node) -> Location){ + InteractionListeners.addDestOverrides(type,ids,options,handler) + } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt index ac3c00241..895531d3f 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt @@ -78,6 +78,20 @@ object InteractionListeners { } } + @JvmStatic + fun addDestOverrides(type: Int, ids: IntArray,options: Array, method: (Node) -> Location){ + for(id in ids){ + for(opt in options){ + destinationOverrides["$type:$id:${opt.toLowerCase()}"] = method + } + } + } + + @JvmStatic + fun getOverride(type: Int, id:Int, option: String): ((Node) -> Location)?{ + return destinationOverrides["$type:$id:${option.toLowerCase()}"] + } + @JvmStatic fun getOverride(type: Int,id: Int): ((Node) -> Location)?{ return destinationOverrides["$type:$id"] @@ -130,7 +144,7 @@ object InteractionListeners { if(player.locks.isInteractionLocked) return false val method = get(id,type,option) ?: get(option,type) ?: return false - val destOverride = getOverride(type,node.id) ?: getOverride(type,option.toLowerCase()) + val destOverride = getOverride(type, id, option) ?: getOverride(type,node.id) ?: getOverride(type,option.toLowerCase()) if(type != 0) { if(player.locks.isMovementLocked) return false diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeStationListener.kt b/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeStationListener.kt index 75e96dbe4..b378c7ea8 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeStationListener.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeStationListener.kt @@ -10,22 +10,27 @@ import rs09.game.interaction.InteractionListener class CanoeStationListener : InteractionListener() { - val STATION_IDs = intArrayOf(12140, 12141, 12142, 12143, 12145, 12146, 12147, 12148, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12144, 12146, 12149, 12150, 12157) - val CHOP_STATION = intArrayOf(12144) - val STAGE_TREE_NONINTERACTABLE = 9 - val STAGE_LOG_CHOPPED = 10 + private val STATION_IDs = intArrayOf(12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12144, 12146, 12149, 12150, 12157) + private val STAGE_TREE_NONINTERACTABLE = 9 + private val STAGE_LOG_CHOPPED = 10 private val SHAPING_INTERFACE = Components.CANOE_52 private val PUSH = Animation(3301) - private val ROW = Animation(3302) private val FALL = Animation(3303) private val FLOAT = Animation(3304) - private val SINK = Animation(3305) + + override fun defineDestinationOverrides() { + setDest(OBJECT,STATION_IDs,"chop-down"){node -> + return@setDest CanoeUtils.getChopLocation(node.location) + } + setDest(OBJECT,STATION_IDs,"shape-canoe","float canoe","float log","float waka"){node -> + return@setDest CanoeUtils.getCraftFloatLocation(node.location) + } + } override fun defineListeners() { - on(CHOP_STATION,OBJECT,"chop-down"){player, node -> + on(STATION_IDs,OBJECT,"chop-down"){player, node -> val axe: SkillingTool? = SkillingTool.getHatchet(player) val varbit = node.asObject().definition.configFile - if(varbit.getValue(player) != 0){ player.varpManager.setVarbit(varbit,0) } @@ -39,6 +44,8 @@ class CanoeStationListener : InteractionListener() { return@on true } player.lock() + player.varpManager.get(varbit.configId).clearBitRange(0,31) + player.faceLocation(CanoeUtils.getFaceLocation(player.location)) player.animate(axe.animation) player.varpManager.setVarbit(varbit,STAGE_TREE_NONINTERACTABLE) player.pulseManager.run(object : Pulse(4){ @@ -59,6 +66,7 @@ class CanoeStationListener : InteractionListener() { player.varpManager.setVarbit(varbit,0) return@on true } + player.faceLocation(CanoeUtils.getFaceLocation(player.location)) player.interfaceManager.open(Component(SHAPING_INTERFACE)) player.setAttribute("canoe-varbit",varbit) return@on true @@ -69,6 +77,7 @@ class CanoeStationListener : InteractionListener() { val canoe = CanoeUtils.getCanoeFromVarbit(player,varbit) player.animator.animate(PUSH) player.lock() + player.faceLocation(CanoeUtils.getFaceLocation(player.location)) player.pulseManager.run(object : Pulse(){ override fun pulse(): Boolean { player.varpManager.setVarbit(varbit,CanoeUtils.getCraftValue(canoe,true)) diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeUtils.kt b/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeUtils.kt index 6dc726245..8d6783ec0 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeUtils.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeUtils.kt @@ -59,4 +59,32 @@ object CanoeUtils { } } + fun getFaceLocation(location: Location): Location{ + return when(getStationIndex(location)){ + 1 -> location.transform(0,-1,0) + 0,2,3 -> location.transform(-1,0,0) + else -> location + } + } + + fun getChopLocation(location: Location): Location{ + return when(getStationIndex(location)){ + 0 -> Location.create(3243, 3235, 0) + 1 -> Location.create(3204, 3343, 0) + 2 -> Location.create(3112, 3409, 0) + 3 -> Location.create(3132, 3508, 0) + else -> Location.create(0,0) + } + } + + fun getCraftFloatLocation(location: Location): Location{ + return when(getStationIndex(location)){ + 0 -> Location.create(3243, 3237, 0) + 1 -> Location.create(3202, 3343, 0) + 2 -> Location.create(3112, 3411, 0) + 3 -> Location.create(3132, 3510, 0) + else -> Location.create(0,0) + } + } + } \ No newline at end of file