Skip to content

Commit

Permalink
Rename setExactMove
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed Jan 23, 2025
1 parent c419ac2 commit a22de59
Show file tree
Hide file tree
Showing 26 changed files with 38 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fun Character.setExactMovement(
flagExactMovement()
}

fun Character.setExactMove(delta: Delta, delay: Int = tile.distanceTo(tile.add(delta)) * 30, direction: Direction = Direction.NONE) {
fun Character.exactMove(delta: Delta, delay: Int = tile.distanceTo(tile.add(delta)) * 30, direction: Direction = Direction.NONE) {
val start = tile
tele(delta)
if (this is Player) {
Expand All @@ -186,12 +186,12 @@ fun Character.setExactMove(delta: Delta, delay: Int = tile.distanceTo(tile.add(d
setExactMovement(Delta.EMPTY, delay, start.delta(tile), direction = direction)
}

context(SuspendableContext<*>) suspend fun Character.exactMove(delta: Delta, delay: Int = tile.distanceTo(tile.add(delta)) * 30, direction: Direction = Direction.NONE) {
character.setExactMove(delta, delay, direction)
context(SuspendableContext<*>) suspend fun Character.exactMoveDelay(delta: Delta, delay: Int = tile.distanceTo(tile.add(delta)) * 30, direction: Direction = Direction.NONE) {
character.exactMove(delta, delay, direction)
delay(delay / 30)
}

fun Character.setExactMove(target: Tile, delay: Int = tile.distanceTo(target) * 30, direction: Direction = Direction.NONE, startDelay: Int = 0) {
fun Character.exactMove(target: Tile, delay: Int = tile.distanceTo(target) * 30, direction: Direction = Direction.NONE, startDelay: Int = 0) {
val start = tile
tele(target)
if (this is Player) {
Expand All @@ -200,8 +200,8 @@ fun Character.setExactMove(target: Tile, delay: Int = tile.distanceTo(target) *
setExactMovement(Delta.EMPTY, delay, start.delta(tile), startDelay, direction = direction)
}

context(SuspendableContext<*>) suspend fun Character.exactMove(target: Tile, delay: Int = tile.distanceTo(target) * 30, direction: Direction = Direction.NONE, startDelay: Int = 0) {
character.setExactMove(target, delay, direction, startDelay)
context(SuspendableContext<*>) suspend fun Character.exactMoveDelay(target: Tile, delay: Int = tile.distanceTo(target) * 30, direction: Direction = Direction.NONE, startDelay: Int = 0) {
character.exactMove(target, delay, direction, startDelay)
delay((startDelay + delay) / 30)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import world.gregs.voidps.engine.data.Settings
import world.gregs.voidps.engine.data.definition.data.Rock
import world.gregs.voidps.engine.data.settingsReload
import world.gregs.voidps.engine.entity.World
import world.gregs.voidps.engine.entity.character.setExactMove
import world.gregs.voidps.engine.entity.character.exactMove
import world.gregs.voidps.engine.entity.character.mode.interact.Interact
import world.gregs.voidps.engine.entity.character.move.walkTo
import world.gregs.voidps.engine.entity.character.npc.NPC
Expand Down Expand Up @@ -120,7 +120,7 @@ fun startCrashedStarEvent() {
for (player in under) {
player.damage(random.nextInt(10, 50))
val direction = Direction.all.first { !player.blocked(it) }
player.setExactMove(direction.delta, 1, direction = direction.inverse())
player.exactMove(direction.delta, 1, direction = direction.inverse())
player.setAnimation("step_back_startled")
}
World.queue("falling_star_object_removal", 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.gregs.voidps.world.activity.skill.agility.course

import world.gregs.voidps.engine.entity.character.exactMoveDelay
import world.gregs.voidps.engine.entity.character.exactMove
import world.gregs.voidps.engine.entity.character.setExactMove
import world.gregs.voidps.engine.entity.character.face
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.move.walkTo
Expand All @@ -25,7 +25,7 @@ objectOperate("Run-up", "barbarian_outpost_run_wall") {
player.setAnimation("barbarian_wall_jump_climb")
delay(7)
player.setAnimation("barbarian_wall_jump")
player.exactMove(Tile(2538, 3545, 2), 30, Direction.NORTH)
player.exactMoveDelay(Tile(2538, 3545, 2), 30, Direction.NORTH)
delay(1)
player.exp(Skill.Agility, 15.0)
player.agilityStage(3)
Expand Down Expand Up @@ -53,7 +53,7 @@ objectOperate("Fire", "barbarian_outpost_spring") {
delay(1)
player.tele(2533, 3547, 3)
player.setAnimation("barbarian_spring_shoot")
player.exactMove(Tile(2532, 3553, 3), 60, Direction.NORTH)
player.exactMoveDelay(Tile(2532, 3553, 3), 60, Direction.NORTH)
target.animate("barbarian_spring_reset")
delay(2)
player.exp(Skill.Agility, 15.0)
Expand All @@ -65,7 +65,7 @@ objectOperate("Cross", "barbarian_outpost_balance_beam") {
delay()
player.setAnimation("circus_cartwheel")
delay()
player.exactMove(Tile(2536, 3553, 3), 45, Direction.EAST)
player.exactMoveDelay(Tile(2536, 3553, 3), 45, Direction.EAST)
player.renderEmote("beam_balance")
delay()
player.exp(Skill.Agility, 15.0)
Expand All @@ -85,9 +85,9 @@ objectOperate("Jump-over", "barbarian_outpost_gap") {

objectOperate("Slide-down", "barbarian_outpost_roof") {
player.setAnimation("barbarian_slide_start")
player.exactMove(player.tile.copy(x = 2540), 30, Direction.EAST)
player.exactMoveDelay(player.tile.copy(x = 2540), 30, Direction.EAST)
player.setAnimation("barbarian_slide")
player.setExactMove(player.tile.copy(x = 2543, level = 1), 90, Direction.EAST)
player.exactMove(player.tile.copy(x = 2543, level = 1), 90, Direction.EAST)
delay()
player.setAnimation("barbarian_slide")
delay()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package world.gregs.voidps.world.activity.skill.agility.course

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.data.Settings
import world.gregs.voidps.engine.entity.character.exactMoveDelay
import world.gregs.voidps.engine.entity.character.exactMove
import world.gregs.voidps.engine.entity.character.setExactMove
import world.gregs.voidps.engine.entity.character.face
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.move.walkOver
Expand Down Expand Up @@ -36,7 +36,7 @@ objectOperate("Squeeze-through", "barbarian_outpost_entrance") {
}
player.setAnimation("climb_through_pipe")
val end = if (player.tile.y >= 3560) 3558 else 3561
player.exactMove(Tile(2552, end), 60, direction = if (player.tile.y >= 3560) Direction.SOUTH else Direction.NORTH)
player.exactMoveDelay(Tile(2552, end), 60, direction = if (player.tile.y >= 3560) Direction.SOUTH else Direction.NORTH)
}

objectOperate("Swing-on", "barbarian_outpost_rope_swing") {
Expand All @@ -51,12 +51,12 @@ objectOperate("Swing-on", "barbarian_outpost_rope_swing") {
target.animate("swing_rope")
delay()
if (success) {
player.setExactMove(player.tile.copy(y = 3549), 60, Direction.SOUTH)
player.exactMove(player.tile.copy(y = 3549), 60, Direction.SOUTH)
delay()
player.exp(Skill.Agility, 22.0)
player.message("You skillfully swing across.", ChatType.Filter)
} else {
player.exactMove(player.tile.copy(y = 3550), 50, Direction.SOUTH)
player.exactMoveDelay(player.tile.copy(y = 3550), 50, Direction.SOUTH)
delay(1)
player.tele(player.tile.copy(y = 9950))
player.damage(50)
Expand Down Expand Up @@ -156,7 +156,7 @@ objectOperate("Climb-over", "barbarian_outpost_crumbling_wall") {
}
player.message("You climb the low wall...", ChatType.Filter)
player.setAnimation("climb_over_wall")
player.setExactMove(target.tile.addX(1), 60, Direction.EAST)
player.exactMove(target.tile.addX(1), 60, Direction.EAST)
delay()
if (target.tile.equals(2542, 3553)) {
if (player.agilityStage == 5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ objectApproach("Run-across", "gnome_sign_post_advanced") {
player.setAnimation("gnome_wall_${if (success) "run" else "fail"}")
delay(1)
if (!success) {
player.exactMove(Tile(2480, 3418, 3), 30, Direction.EAST)
player.exactMoveDelay(Tile(2480, 3418, 3), 30, Direction.EAST)
delay(5)
}
player.exactMove(Tile(2484, 3418, 3), if (success) 60 else 210, Direction.EAST)
player.exactMoveDelay(Tile(2484, 3418, 3), if (success) 60 else 210, Direction.EAST)
if (success) {
player.exp(Skill.Agility, 25.0)
} else {
Expand All @@ -75,14 +75,14 @@ objectApproach("Swing-to", "gnome_pole_advanced") {
player.face(Direction.NORTH)
delay()
player.setAnimation("gnome_run_up")
player.exactMove(tile.copy(y = 3421), 60, Direction.NORTH)
player.exactMoveDelay(tile.copy(y = 3421), 60, Direction.NORTH)
player.setAnimation("gnome_jump")
player.exactMove(tile.copy(y = 3425), 30, Direction.NORTH)
player.exactMoveDelay(tile.copy(y = 3425), 30, Direction.NORTH)
player.setAnimation("gnome_swing")
delay(4)
player.exactMove(tile.copy(y = 3429), 30, Direction.NORTH)
player.exactMoveDelay(tile.copy(y = 3429), 30, Direction.NORTH)
delay(4)
player.exactMove(tile.copy(y = 3432), 30, Direction.NORTH)
player.exactMoveDelay(tile.copy(y = 3432), 30, Direction.NORTH)
delay(1)
player.agilityStage(6)
player.exp(Skill.Agility, 25.0)
Expand All @@ -91,7 +91,7 @@ objectApproach("Swing-to", "gnome_pole_advanced") {
objectOperate("Jump-over", "gnome_barrier_advanced") {
player.setAnimation("gnome_jump_barrier")
delay()
player.exactMove(Tile(2485, 3434, 3), 30, Direction.NORTH)
player.exactMoveDelay(Tile(2485, 3434, 3), 30, Direction.NORTH)
delay(1)
player.tele(2485, 3436, 0)
player.setAnimation("gnome_pipe_land")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package world.gregs.voidps.world.activity.skill.agility.course

import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.npc.NPCs
import world.gregs.voidps.type.Zone
import world.gregs.voidps.type.random
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.gregs.voidps.world.activity.skill.agility.course

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.entity.character.exactMove
import world.gregs.voidps.engine.entity.character.exactMoveDelay
import world.gregs.voidps.engine.entity.character.face
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.move.walkOver
Expand Down Expand Up @@ -101,11 +101,11 @@ objectOperate("Squeeze-through", "gnome_obstacle_pipe_*") {
player.message("You pull yourself through the pipes..", ChatType.Filter)
delay()
player.setAnimation("climb_through_pipe")
player.exactMove(target.tile.addY(2))
player.exactMoveDelay(target.tile.addY(2))
player.face(Direction.NORTH)
player.tele(target.tile.addY(3))
player.setAnimation("climb_through_pipe", delay = 1)
player.exactMove(target.tile.addY(6))
player.exactMoveDelay(target.tile.addY(6))
if (player.agilityStage == 6) {
player.agilityStage = 0
player.inc("gnome_course_laps")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package world.gregs.voidps.world.activity.skill.agility.course

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.data.Settings
import world.gregs.voidps.engine.entity.character.exactMove
import world.gregs.voidps.engine.entity.character.exactMoveDelay
import world.gregs.voidps.engine.entity.character.face
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.move.walkOver
Expand Down Expand Up @@ -98,7 +98,7 @@ suspend fun SuspendableContext<Player>.fallIntoPit() {
player.setAnimation("rope_walk_fall_down")
player.message("You lose your footing and fall into the wolf pit.", ChatType.Filter)
delay()
player.exactMove(Tile(3001, 3923), 25, Direction.SOUTH)
player.exactMoveDelay(Tile(3001, 3923), 25, Direction.SOUTH)
}

objectOperate("Squeeze-through", "wilderness_obstacle_pipe") {
Expand All @@ -110,11 +110,11 @@ objectOperate("Squeeze-through", "wilderness_obstacle_pipe") {
player.walkTo(target.tile.addY(-1))
}
player.setAnimation("climb_through_pipe", delay = 30)
player.exactMove(Tile(3004, 3940), startDelay = 30, delay = 96, direction = Direction.NORTH)
player.exactMoveDelay(Tile(3004, 3940), startDelay = 30, delay = 96, direction = Direction.NORTH)
player.tele(3004, 3947)
delay()
player.setAnimation("climb_through_pipe", delay = 30)
player.exactMove(Tile(3004, 3950), startDelay = 30, delay = 96, direction = Direction.NORTH)
player.exactMoveDelay(Tile(3004, 3950), startDelay = 30, delay = 96, direction = Direction.NORTH)
player.exp(Skill.Agility, 12.5)
player.agilityStage(1)
}
Expand All @@ -129,11 +129,11 @@ objectOperate("Swing-on", "wilderness_rope_swing") {
target.animate("swing_rope")
delay()
if (success) {
player.exactMove(player.tile.copy(y = 3958), 60, Direction.NORTH)
player.exactMoveDelay(player.tile.copy(y = 3958), 60, Direction.NORTH)
player.exp(Skill.Agility, 20.0)
player.message("You skillfully swing across.", ChatType.Filter)
} else {
player.exactMove(player.tile.copy(y = 3957), 50, Direction.NORTH)
player.exactMoveDelay(player.tile.copy(y = 3957), 50, Direction.NORTH)
delay(1)
player.tele(3004, 10357)
player.damage((player.levels.get(Skill.Constitution) * 0.15).toInt() + 10)
Expand All @@ -149,7 +149,7 @@ objectOperate("Cross", "wilderness_stepping_stone") {
for (i in 0..5) {
player.setAnimation("stepping_stone_jump")
player.playSound("jump")
player.exactMove(target.tile.addX(-i), delay = 30, direction = Direction.WEST, startDelay = 15)
player.exactMoveDelay(target.tile.addX(-i), delay = 30, direction = Direction.WEST, startDelay = 15)
delay(1)
if (i == 2 && !Settings["agility.disableCourseFailure", false] && !Level.success(player.levels.get(Skill.Agility), 180..250)) {
player.setAnimation("rope_walk_fall_down")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package world.gregs.voidps.world.activity.skill.runecrafting
import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.data.definition.AreaDefinitions
import world.gregs.voidps.engine.entity.character.face
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.npc.NPC
import world.gregs.voidps.engine.entity.character.player.Player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import world.gregs.voidps.engine.data.definition.AnimationDefinitions
import world.gregs.voidps.engine.data.definition.data.Pocket
import world.gregs.voidps.engine.entity.World
import world.gregs.voidps.engine.entity.character.face
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.npc.NPC
import world.gregs.voidps.engine.entity.character.npc.npcApproach
import world.gregs.voidps.engine.entity.character.player.Player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package world.gregs.voidps.world.interact.entity.npc

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.mode.EmptyMode
import world.gregs.voidps.engine.entity.character.setAnimation
import world.gregs.voidps.engine.entity.npcSpawn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package world.gregs.voidps.world.interact.entity.npc.move

import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.mode.EmptyMode
import world.gregs.voidps.engine.entity.character.mode.Follow
import world.gregs.voidps.engine.entity.character.mode.Wander
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package world.gregs.voidps.world.interact.entity.player.combat.consume.drink

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.ui.interact.itemOnItem
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.inv.charges
import world.gregs.voidps.engine.inv.discharge
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.gregs.voidps.world.interact.entity.player.combat.consume.food

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.player.chat.ChatType
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.type.random
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import world.gregs.voidps.engine.client.variable.remaining
import world.gregs.voidps.engine.client.variable.start
import world.gregs.voidps.engine.client.variable.stop
import world.gregs.voidps.engine.data.definition.SpellDefinitions
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.entity.character.setAnimation
import world.gregs.voidps.engine.entity.character.setGraphic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package world.gregs.voidps.world.interact.entity.player.combat.melee.special

import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.entity.character.setAnimation
import world.gregs.voidps.engine.entity.character.setGraphic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package world.gregs.voidps.world.interact.entity.player.combat.melee.special

import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.entity.character.setAnimation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package world.gregs.voidps.world.interact.entity.player.combat.melee.special

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.variable.hasClock
import world.gregs.voidps.engine.entity.character.setExactMove
import world.gregs.voidps.engine.entity.character.exactMove
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.engine.entity.character.setAnimation
import world.gregs.voidps.engine.entity.character.setGraphic
Expand Down Expand Up @@ -41,6 +41,6 @@ specialAttack("shove") { player ->
val direction = target.tile.delta(actual).toDirection()
val delta = direction.delta
if (!target.blocked(direction)) {
target.setExactMove(delta, 30, direction.inverse())
target.exactMove(delta, 30, direction.inverse())
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.gregs.voidps.world.map.ardougne

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.npc.NPCOption
import world.gregs.voidps.engine.entity.character.npc.npcOperate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import world.gregs.voidps.engine.client.ui.event.interfaceClose
import world.gregs.voidps.engine.client.ui.event.interfaceOpen
import world.gregs.voidps.engine.client.ui.interfaceOption
import world.gregs.voidps.engine.data.definition.EnumDefinitions
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.npc.NPCOption
import world.gregs.voidps.engine.entity.character.npc.NPCs
import world.gregs.voidps.engine.entity.character.npc.npcOperate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.gregs.voidps.world.map.karamja

import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate
import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.mode.interact.TargetInteraction
import world.gregs.voidps.engine.entity.character.npc.NPC
import world.gregs.voidps.engine.entity.character.npc.npcOperate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package world.gregs.voidps.world.map.lumbridge

import world.gregs.voidps.engine.entity.character.say
import world.gregs.voidps.engine.entity.character.mode.Retreat
import world.gregs.voidps.engine.entity.character.npc.npcOperate
import world.gregs.voidps.world.interact.dialogue.EvilLaugh
Expand Down
Loading

0 comments on commit a22de59

Please sign in to comment.