Merged canoe fixes

This commit is contained in:
ceikry 2021-11-16 16:53:33 -06:00
commit 4628775c50
3 changed files with 47 additions and 18 deletions

View file

@ -52,4 +52,5 @@
- Random Events can no longer spawn in the wilderness.
- Fairy rings emit a sound when teleporting.
- Void set effects now work more uniformly.
- Summoning familiars now grant combat xp when attacking
- Summoning familiars now grant combat xp when attacking
- Canoe travel interface now animates correctly

View file

@ -8,12 +8,14 @@ import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.gather.SkillingTool
import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import core.net.packet.PacketRepository
import core.net.packet.context.MinimapStateContext
import core.net.packet.out.MinimapState
import core.tools.RandomFunction
import org.rs09.consts.Components
import rs09.game.interaction.InterfaceListener
import kotlin.math.abs
class CanoeInterfaceListeners : InterfaceListener() {
@ -75,7 +77,7 @@ class CanoeInterfaceListeners : InterfaceListener() {
player.packetDispatch.sendInterfaceConfig(DESTINATION_INTERFACE,49,true)
for(i in 0..3){
if(i == stationIndex) continue
if(Math.abs(i - stationIndex) > maxDistance){
if(abs(i - stationIndex) > maxDistance){
player.packetDispatch.sendInterfaceConfig(DESTINATION_INTERFACE,boatChilds[i],true)
player.packetDispatch.sendInterfaceConfig(DESTINATION_INTERFACE,locationChilds[i],true)
}
@ -88,11 +90,19 @@ class CanoeInterfaceListeners : InterfaceListener() {
val dest = CanoeUtils.getDestinationFromButtonID(buttonID)
val destIndex = CanoeUtils.getStationIndex(dest)
val arrivalMessage = CanoeUtils.getNameByIndex(destIndex)
val stationIndex = CanoeUtils.getStationIndex(player.location)
val interfaceAnimationId = CanoeUtils.getTravelAnimation(stationIndex,destIndex)
var travelAnimDur = 15
val varbit = player.getAttribute("canoe-varbit",VarbitDefinition.forObjectID(0))
if (player.familiarManager.hasFamiliar()) {
player.sendMessage("You can't take a follower on a canoe.")
return@on true
}
if (interfaceAnimationId != 0) {
travelAnimDur = Animation(interfaceAnimationId).duration
}
player.lock()
player.interfaceManager.close()
player.pulseManager.run(object : Pulse(){
@ -102,18 +112,19 @@ class CanoeInterfaceListeners : InterfaceListener() {
0 -> {
player.interfaceManager.openOverlay(Component(Components.FADE_TO_BLACK_120))
player.interfaceManager.open(Component(Components.CANOE_TRAVEL_758))
}
ContentAPI.animateInterface(player, Components.CANOE_TRAVEL_758, 3, interfaceAnimationId)
}
2 -> {
PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2))
player.interfaceManager.hideTabs(0, 1, 2, 3, 4, 5, 6, 11, 12)
}
15 -> player.properties.teleportLocation = dest
16 -> {
travelAnimDur -> player.properties.teleportLocation = dest
travelAnimDur+1 -> {
player.interfaceManager.close(Component(Components.CANOE_TRAVEL_758))
player.interfaceManager.closeOverlay()
player.interfaceManager.openOverlay(Component(Components.FADE_FROM_BLACK_170))
}
18 -> {
travelAnimDur+3 -> {
player.unlock()
player.interfaceManager.restoreTabs()
PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 0))

View file

@ -10,7 +10,13 @@ import core.game.world.update.flag.context.Animation
import org.rs09.consts.Components
object CanoeUtils {
val SHAPE_INTERFACE = Components.CANOE_52
private const val SHAPE_INTERFACE = Components.CANOE_52
private val FROM_LUMBRIDGE = mapOf(4 to 9887, 3 to 9888, 2 to 9889, 1 to 9890)
private val FROM_CHAMPIONS = mapOf(4 to 9891, 3 to 9892, 2 to 9893, 0 to 9906)
private val FROM_BARBARIAN = mapOf(4 to 9894, 3 to 9895, 1 to 9905, 0 to 9906)
private val FROM_EDGE = mapOf(4 to 9896, 2 to 9903, 1 to 9902, 0 to 9901)
private val FROM_WILDERNESS = mapOf(3 to 9900, 2 to 9899, 1 to 9898, 0 to 9897)
fun checkCanoe(player: Player, canoe: Canoe){
if(player.skills.getLevel(Skills.WOODCUTTING) < canoe.requiredLevel) return
@ -39,18 +45,29 @@ object CanoeUtils {
}
}
fun getShapeAnimation(axe: SkillingTool): Animation{
when(axe){
SkillingTool.BRONZE_AXE -> return Animation(6744);
SkillingTool.IRON_AXE -> return Animation(6743);
SkillingTool.STEEL_AXE -> return Animation(6742);
SkillingTool.BLACK_AXE -> return Animation(6741);
SkillingTool.MITHRIL_AXE -> return Animation(6740);
SkillingTool.ADAMANT_AXE -> return Animation(6739);
SkillingTool.RUNE_AXE -> return Animation(6738);
SkillingTool.DRAGON_AXE -> return Animation(6745);
fun getTravelAnimation(stationId: Int, destId: Int): Int {
return when(stationId){
0 -> FROM_LUMBRIDGE.getOrDefault(destId,0)
1 -> FROM_CHAMPIONS.getOrDefault(destId,0)
2 -> FROM_BARBARIAN.getOrDefault(destId,0)
3 -> FROM_EDGE.getOrDefault(destId,0)
4 -> FROM_WILDERNESS.getOrDefault(destId,0)
else -> 0;
}
}
fun getShapeAnimation(axe: SkillingTool): Animation{
return when(axe){
SkillingTool.BRONZE_AXE -> Animation(6744);
SkillingTool.IRON_AXE -> Animation(6743);
SkillingTool.STEEL_AXE -> Animation(6742);
SkillingTool.BLACK_AXE -> Animation(6741);
SkillingTool.MITHRIL_AXE -> Animation(6740);
SkillingTool.ADAMANT_AXE -> Animation(6739);
SkillingTool.RUNE_AXE -> Animation(6738);
SkillingTool.DRAGON_AXE -> Animation(6745);
else -> axe.animation;
}
return axe.animation;
}
fun getDestinationFromButtonID(buttonID: Int): Location {