mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 00:38:14 +00:00
Remove plugins.gradle and factor into common extension
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package org.apollo.plugin.entity.following
|
||||
|
||||
import org.apollo.game.action.Action
|
||||
import org.apollo.game.model.Direction
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.Mob
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.net.message.Message
|
||||
import org.apollo.plugin.entity.walkto.walkBehind
|
||||
import org.apollo.plugin.entity.walkto.walkTo
|
||||
|
||||
class FollowAction(player: Player, val target: Player) : Action<Player>(0, true, player) {
|
||||
var lastPosition: Position? = null
|
||||
|
||||
companion object {
|
||||
fun start(player: Player, target: Player, message: Message? = null) {
|
||||
player.startAction(FollowAction(player, target))
|
||||
message?.terminate()
|
||||
}
|
||||
}
|
||||
|
||||
override fun execute() {
|
||||
if (!target.isActive) {
|
||||
stop()
|
||||
return
|
||||
}
|
||||
|
||||
mob.interactingMob = target
|
||||
|
||||
if (target.position == lastPosition) {
|
||||
return
|
||||
}
|
||||
|
||||
val distance = mob.position.getDistance(target.position)
|
||||
if (distance >= 15) {
|
||||
stop()
|
||||
return
|
||||
}
|
||||
|
||||
if (mob.position == target.position) {
|
||||
val directions = Direction.NESW
|
||||
val directionOffset = (Math.random() * directions.size).toInt()
|
||||
|
||||
mob.walkTo(target.position.step(1, directions[directionOffset]))
|
||||
return
|
||||
}
|
||||
|
||||
mob.walkBehind(target)
|
||||
lastPosition = target.position
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import com.google.common.primitives.Ints
|
||||
import org.apollo.game.message.impl.PlayerActionMessage
|
||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||
import org.apollo.plugin.entity.following.FollowAction
|
||||
|
||||
on_player_event { PlayerActionEvent::class }
|
||||
.where { action == PlayerActionType.FOLLOW }
|
||||
.then {
|
||||
FollowAction.start(it, target)
|
||||
terminate()
|
||||
}
|
||||
Reference in New Issue
Block a user