mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Fixed failed sheep shearing movement
This commit is contained in:
parent
dbb8b5a133
commit
af4a316fa1
1 changed files with 23 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ import core.game.interaction.InteractionListener
|
||||||
import core.game.node.entity.combat.DeathTask
|
import core.game.node.entity.combat.DeathTask
|
||||||
import core.game.node.entity.npc.NPC
|
import core.game.node.entity.npc.NPC
|
||||||
import core.game.node.entity.npc.NPCBehavior
|
import core.game.node.entity.npc.NPCBehavior
|
||||||
|
import core.game.node.entity.player.Player
|
||||||
import core.game.system.task.Pulse
|
import core.game.system.task.Pulse
|
||||||
import core.game.world.GameWorld
|
import core.game.world.GameWorld
|
||||||
import core.game.world.update.flag.context.Animation
|
import core.game.world.update.flag.context.Animation
|
||||||
|
|
@ -14,6 +15,8 @@ import core.tools.RandomFunction
|
||||||
import org.rs09.consts.Items
|
import org.rs09.consts.Items
|
||||||
import org.rs09.consts.NPCs
|
import org.rs09.consts.NPCs
|
||||||
import org.rs09.consts.Sounds
|
import org.rs09.consts.Sounds
|
||||||
|
import core.game.world.map.Location
|
||||||
|
import core.game.world.map.Direction
|
||||||
|
|
||||||
private val sheepIds = intArrayOf(
|
private val sheepIds = intArrayOf(
|
||||||
NPCs.SHEEP_42,
|
NPCs.SHEEP_42,
|
||||||
|
|
@ -76,9 +79,9 @@ class SheepBehavior : NPCBehavior(*sheepIds), InteractionListener {
|
||||||
}
|
}
|
||||||
animate(player, Animation(893))
|
animate(player, Animation(893))
|
||||||
playAudio(player, Sounds.PENGUINSHEEP_ESCAPE_686)
|
playAudio(player, Sounds.PENGUINSHEEP_ESCAPE_686)
|
||||||
sendMessage(player, "The... whatever it is... manages to get away from you!")
|
|
||||||
animate(sheep, Animation(3570))
|
animate(sheep, Animation(3570))
|
||||||
sheep.moveStep()
|
|
||||||
|
sheepBackAway(player, sheep, "The... whatever it is... manages to get away from you!")
|
||||||
return@on true
|
return@on true
|
||||||
}
|
}
|
||||||
if (!inInventory(player, Items.SHEARS_1735)) {
|
if (!inInventory(player, Items.SHEARS_1735)) {
|
||||||
|
|
@ -110,10 +113,26 @@ class SheepBehavior : NPCBehavior(*sheepIds), InteractionListener {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
sendMessage(player, "The sheep manages to get away from you!")
|
sheepBackAway(player, sheep, "The sheep manages to get away from you!")
|
||||||
sheep.moveStep()
|
|
||||||
}
|
}
|
||||||
return@on true
|
return@on true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun sheepBackAway(player: Player, sheep: NPC, messagePlayer: String)
|
||||||
|
{
|
||||||
|
val playerLocation = player.getLocation()
|
||||||
|
val sheepLocation = sheep.getLocation()
|
||||||
|
val sheepDirection = Direction.getDirection(sheepLocation, playerLocation) // Get direction sheep is facing, from the player's location
|
||||||
|
val sheepOppositeDirection = sheepDirection.getOpposite() // Switch to opposite direction
|
||||||
|
|
||||||
|
val xWalkLocation = sheepLocation.getX() + (sheepOppositeDirection.getStepX() * 3) // Gets x location, if set, 3 steps away from player
|
||||||
|
val yWalkLocation = sheepLocation.getY() + (sheepOppositeDirection.getStepY() * 3) // Gets y location, if set, 3 steps away from player
|
||||||
|
val sheepWalkToLocation = Location(xWalkLocation, yWalkLocation, sheepLocation.getZ()); // New location for pathfinding
|
||||||
|
|
||||||
|
sendMessage(player, messagePlayer)
|
||||||
|
|
||||||
|
unlock(sheep) //Force unlock of entity movement, to allow moving away
|
||||||
|
forceWalk(sheep, sheepWalkToLocation, "dumb")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue