RuneHive-Game
Loading...
Searching...
No Matches
WalkEvent.kt
Go to the documentation of this file.
1package org.jire.runehiveps.event.player
2
3import com.runehive.content.activity.Activity
4import com.runehive.content.activity.impl.duelarena.DuelArenaActivity
5import com.runehive.content.activity.impl.duelarena.DuelRule
6import com.runehive.game.Animation
7import com.runehive.game.world.entity.mob.data.LockType
8import com.runehive.game.world.entity.mob.data.PacketType
9import com.runehive.game.world.entity.mob.player.Player
10import com.runehive.game.world.entity.mob.player.PlayerRight
11import com.runehive.game.world.position.Position
12import com.runehive.net.packet.out.SendMessage
13import org.jire.runehiveps.event.Event
14import java.util.*
15
16/**
17 * @author Jire
18 */
19class WalkEvent(
20 val targetX: Int,
21 val targetY: Int,
22 val runQueue: Boolean
23) : Event {
24
25 override fun handle(player: Player) {
26 if (player.isGambleLocked) return
27
28 if (player.locking.locked(PacketType.WALKING)) {
29 if (player.locking.locked(LockType.STUN)) {
30 player.send(SendMessage("You are currently stunned."))
31 player.combat.reset()
32 }
33 if (player.locking.locked(LockType.FREEZE)) {
34 player.send(SendMessage("A magical force stops you from moving!", true))
35 player.combat.reset()
36 }
37 return
38 }
39
40 if (Activity.search(player, DuelArenaActivity::class.java).isPresent) {
41 val activity = Activity.search(
42 player,
43 DuelArenaActivity::class.java
44 ).get()
45 if (activity.rules.contains(DuelRule.NO_MOVEMENT)) {
46 player.send(SendMessage("You cannot move in the duel arena."))
47 player.combat.reset()
48 return
49 }
50 }
51
52 player.skills.resetSkilling()
53
54 if (player.resting) {
55 player.animate(Animation.RESET, true)
56 player.resting = false
57 }
58
59 /* Dialogues */
60
61 /* Dialogues */if (player.dialogue.isPresent) {
62 player.dialogue = Optional.empty()
63 }
64
65 /* Idle */
66
67 /* Idle */if (player.idle) {
68 player.idle = false
69 }
70
71 /* Dialogue factory */
72
73 /* Dialogue factory */if (!player.dialogueFactory.chain.isEmpty()) {
74 player.dialogueFactory.clear()
75 }
76
77 /* Dialogue options */
78
79 /* Dialogue options */if (player.optionDialogue.isPresent) {
80 player.optionDialogue = Optional.empty()
81 }
82
83 if (!player.interfaceManager.isMainClear) {
84 player.interfaceManager.close()
85 }
86
87 if (!player.interfaceManager.isDialogueClear) {
88 player.dialogueFactory.clear()
89 }
90
91 /* Reset the face. */
92
93 /* Reset the face. */player.resetFace()
94
95 /* Clear non walkable actions */
96
97 /* Clear non walkable actions */player.action.clearNonWalkableActions()
98 player.resetWaypoint()
99 player.combat.reset()
100
101 // the tile the player is trying to get to
102
103 // the tile the player is trying to get to
104 val destination = Position.create(targetX, targetY, player.height)
105
106 // prevents the player from hacking the client to make the player walk really far distances.
107
108 // prevents the player from hacking the client to make the player walk really far distances.
109 if (player.position.getDistance(destination) > 32) {
110 return
111 }
112
113 if (runQueue && PlayerRight.isDeveloper(player)) {
114 player.move(destination)
115 return
116 }
117 player.movement.isRunningQueue = runQueue
118 player.movement.dijkstraPath(destination)
119 }
120
121}