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

@ -53,3 +53,4 @@
- Fairy rings emit a sound when teleporting. - Fairy rings emit a sound when teleporting.
- Void set effects now work more uniformly. - 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.Skills
import core.game.node.entity.skill.gather.SkillingTool import core.game.node.entity.skill.gather.SkillingTool
import core.game.system.task.Pulse import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import core.net.packet.PacketRepository import core.net.packet.PacketRepository
import core.net.packet.context.MinimapStateContext import core.net.packet.context.MinimapStateContext
import core.net.packet.out.MinimapState import core.net.packet.out.MinimapState
import core.tools.RandomFunction import core.tools.RandomFunction
import org.rs09.consts.Components import org.rs09.consts.Components
import rs09.game.interaction.InterfaceListener import rs09.game.interaction.InterfaceListener
import kotlin.math.abs
class CanoeInterfaceListeners : InterfaceListener() { class CanoeInterfaceListeners : InterfaceListener() {
@ -75,7 +77,7 @@ class CanoeInterfaceListeners : InterfaceListener() {
player.packetDispatch.sendInterfaceConfig(DESTINATION_INTERFACE,49,true) player.packetDispatch.sendInterfaceConfig(DESTINATION_INTERFACE,49,true)
for(i in 0..3){ for(i in 0..3){
if(i == stationIndex) continue 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,boatChilds[i],true)
player.packetDispatch.sendInterfaceConfig(DESTINATION_INTERFACE,locationChilds[i],true) player.packetDispatch.sendInterfaceConfig(DESTINATION_INTERFACE,locationChilds[i],true)
} }
@ -88,11 +90,19 @@ class CanoeInterfaceListeners : InterfaceListener() {
val dest = CanoeUtils.getDestinationFromButtonID(buttonID) val dest = CanoeUtils.getDestinationFromButtonID(buttonID)
val destIndex = CanoeUtils.getStationIndex(dest) val destIndex = CanoeUtils.getStationIndex(dest)
val arrivalMessage = CanoeUtils.getNameByIndex(destIndex) 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)) val varbit = player.getAttribute("canoe-varbit",VarbitDefinition.forObjectID(0))
if (player.familiarManager.hasFamiliar()) { if (player.familiarManager.hasFamiliar()) {
player.sendMessage("You can't take a follower on a canoe.") player.sendMessage("You can't take a follower on a canoe.")
return@on true return@on true
} }
if (interfaceAnimationId != 0) {
travelAnimDur = Animation(interfaceAnimationId).duration
}
player.lock() player.lock()
player.interfaceManager.close() player.interfaceManager.close()
player.pulseManager.run(object : Pulse(){ player.pulseManager.run(object : Pulse(){
@ -102,18 +112,19 @@ class CanoeInterfaceListeners : InterfaceListener() {
0 -> { 0 -> {
player.interfaceManager.openOverlay(Component(Components.FADE_TO_BLACK_120)) player.interfaceManager.openOverlay(Component(Components.FADE_TO_BLACK_120))
player.interfaceManager.open(Component(Components.CANOE_TRAVEL_758)) player.interfaceManager.open(Component(Components.CANOE_TRAVEL_758))
ContentAPI.animateInterface(player, Components.CANOE_TRAVEL_758, 3, interfaceAnimationId)
} }
2 -> { 2 -> {
PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2)) PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2))
player.interfaceManager.hideTabs(0, 1, 2, 3, 4, 5, 6, 11, 12) player.interfaceManager.hideTabs(0, 1, 2, 3, 4, 5, 6, 11, 12)
} }
15 -> player.properties.teleportLocation = dest travelAnimDur -> player.properties.teleportLocation = dest
16 -> { travelAnimDur+1 -> {
player.interfaceManager.close(Component(Components.CANOE_TRAVEL_758)) player.interfaceManager.close(Component(Components.CANOE_TRAVEL_758))
player.interfaceManager.closeOverlay() player.interfaceManager.closeOverlay()
player.interfaceManager.openOverlay(Component(Components.FADE_FROM_BLACK_170)) player.interfaceManager.openOverlay(Component(Components.FADE_FROM_BLACK_170))
} }
18 -> { travelAnimDur+3 -> {
player.unlock() player.unlock()
player.interfaceManager.restoreTabs() player.interfaceManager.restoreTabs()
PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 0)) 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 import org.rs09.consts.Components
object CanoeUtils { 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){ fun checkCanoe(player: Player, canoe: Canoe){
if(player.skills.getLevel(Skills.WOODCUTTING) < canoe.requiredLevel) return if(player.skills.getLevel(Skills.WOODCUTTING) < canoe.requiredLevel) return
@ -39,18 +45,29 @@ object CanoeUtils {
} }
} }
fun getShapeAnimation(axe: SkillingTool): Animation{ fun getTravelAnimation(stationId: Int, destId: Int): Int {
when(axe){ return when(stationId){
SkillingTool.BRONZE_AXE -> return Animation(6744); 0 -> FROM_LUMBRIDGE.getOrDefault(destId,0)
SkillingTool.IRON_AXE -> return Animation(6743); 1 -> FROM_CHAMPIONS.getOrDefault(destId,0)
SkillingTool.STEEL_AXE -> return Animation(6742); 2 -> FROM_BARBARIAN.getOrDefault(destId,0)
SkillingTool.BLACK_AXE -> return Animation(6741); 3 -> FROM_EDGE.getOrDefault(destId,0)
SkillingTool.MITHRIL_AXE -> return Animation(6740); 4 -> FROM_WILDERNESS.getOrDefault(destId,0)
SkillingTool.ADAMANT_AXE -> return Animation(6739); else -> 0;
SkillingTool.RUNE_AXE -> return Animation(6738); }
SkillingTool.DRAGON_AXE -> return Animation(6745); }
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 { fun getDestinationFromButtonID(buttonID: Int): Location {