mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Repackage following plugin
This commit is contained in:
+6
-8
@@ -3,13 +3,12 @@ package org.apollo.plugin.entity.following
|
|||||||
import org.apollo.game.action.Action
|
import org.apollo.game.action.Action
|
||||||
import org.apollo.game.model.Direction
|
import org.apollo.game.model.Direction
|
||||||
import org.apollo.game.model.Position
|
import org.apollo.game.model.Position
|
||||||
import org.apollo.game.model.entity.Mob
|
|
||||||
import org.apollo.game.model.entity.Player
|
import org.apollo.game.model.entity.Player
|
||||||
import org.apollo.net.message.Message
|
import org.apollo.net.message.Message
|
||||||
import org.apollo.plugin.entity.walkto.walkBehind
|
import org.apollo.plugin.entity.pathing.walkBehind
|
||||||
import org.apollo.plugin.entity.walkto.walkTo
|
import org.apollo.plugin.entity.pathing.walkTo
|
||||||
|
|
||||||
class FollowAction(player: Player, val target: Player) : Action<Player>(0, true, player) {
|
class FollowAction(player: Player, private val target: Player) : Action<Player>(0, true, player) {
|
||||||
var lastPosition: Position? = null
|
var lastPosition: Position? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -42,11 +41,10 @@ class FollowAction(player: Player, val target: Player) : Action<Player>(0, true,
|
|||||||
val directionOffset = (Math.random() * directions.size).toInt()
|
val directionOffset = (Math.random() * directions.size).toInt()
|
||||||
|
|
||||||
mob.walkTo(target.position.step(1, directions[directionOffset]))
|
mob.walkTo(target.position.step(1, directions[directionOffset]))
|
||||||
return
|
} else {
|
||||||
|
mob.walkBehind(target)
|
||||||
|
lastPosition = target.position
|
||||||
}
|
}
|
||||||
|
|
||||||
mob.walkBehind(target)
|
|
||||||
lastPosition = target.position
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
-2
@@ -1,10 +1,12 @@
|
|||||||
|
package org.apollo.plugin.entity.following
|
||||||
|
|
||||||
import org.apollo.game.plugin.entity.actions.PlayerActionEvent
|
import org.apollo.game.plugin.entity.actions.PlayerActionEvent
|
||||||
import org.apollo.game.plugin.entity.actions.PlayerActionType
|
import org.apollo.game.plugin.entity.actions.PlayerActionType
|
||||||
import org.apollo.plugin.entity.following.FollowAction
|
import org.apollo.plugin.entity.following.FollowAction
|
||||||
|
|
||||||
on_player_event { PlayerActionEvent::class }
|
on_player_event { PlayerActionEvent::class }
|
||||||
.where { action == PlayerActionType.FOLLOW }
|
.where { action == PlayerActionType.FOLLOW }
|
||||||
.then {
|
.then { player ->
|
||||||
FollowAction.start(it, target)
|
FollowAction.start(player, target)
|
||||||
terminate()
|
terminate()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user