RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
WildernessDoorInteraction.java
1package com.osroyale.content.skill.impl.agility.obstacle.impl;
2
3import com.osroyale.content.skill.impl.agility.obstacle.ObstacleInteraction;
4import com.osroyale.game.task.Task;
5import com.osroyale.game.world.World;
6import com.osroyale.game.world.entity.mob.player.Player;
7import com.osroyale.game.world.entity.skill.Skill;
8import com.osroyale.game.world.object.ObjectDirection;
9import com.osroyale.game.world.position.Position;
10import com.osroyale.game.world.object.GameObject;
11import com.osroyale.net.packet.out.SendMessage;
12
13public interface WildernessDoorInteraction extends ObstacleInteraction {
14
15
16 @Override
17 default void start(Player player) {
18 }
19
20 @Override
21 default boolean canExecute(Player player, int level) {
22 if (player.skills.getLevel(Skill.AGILITY) < level) {
23 player.dialogueFactory.sendStatement("You need an agility level of " + level + " to do this!").execute();
24 return false;
25 }
26 GameObject object = player.attributes.get("AGILITY_OBJ", GameObject.class);
27 return object != null && object.getDirection() == ObjectDirection.SOUTH;
28 }
29
30 @Override
31 default void onExecution(Player player, Position start, Position end) {
32 boolean entering = player.getPosition().equals(new Position(2998, 3916));
33 Position destination = entering ? new Position(2998, 3930) : new Position(2998, 3917);
34 Position finalDestination = entering ? new Position(2998, 3931) : new Position(2998, 3916);
35// GameObject enterDoor = player.getRegion().getGameObject(new Position(2998, 3917));
36// GameObject leavingDoor1 = player.getRegion().getGameObject(new Position(2997, 3931));
37// GameObject leavingDoor2 = player.getRegion().getGameObject(new Position(2998, 3931));
38
39 player.face(finalDestination);
40
41 World.schedule(new Task(2) {
42 int count = 0;
43
44 @Override
45 public void execute() {
46 if (player.getPosition().equals(destination)) {
47 player.mobAnimation.reset();
48// if (entering) {
49// leavingDoor1.rotate(Direction.EAST);
50// leavingDoor2.rotate(Direction.SOUTH);
51// } else {
52// enterDoor.rotate(Direction.EAST);
53// }
54 player.movement.walk(finalDestination);
55 return;
56 }
57 if (player.getPosition().equals(finalDestination)) {
58 if (entering) {
59// leavingDoor1.rotate(Direction.WEST);
60// leavingDoor2.rotate(Direction.WEST);
61 player.send(new SendMessage("Welcome the the wilderness agility course. Be careful :)"));
62 } else {
63// enterDoor.rotate(Direction.WEST);
64 }
65 cancel();
66 return;
67 }
68 switch (count) {
69 case 0:
70// if (entering) {
71// enterDoor.rotate(Direction.EAST);
72// } else {
73// leavingDoor1.rotate(Direction.EAST);
74// leavingDoor2.rotate(Direction.SOUTH);
75// }
76 player.movement.walk(destination);
77 break;
78 case 1:
79 player.mobAnimation.setWalk(762);
80 player.mobAnimation.setStand(762);
81 break;
82 case 2:
83// if (entering) {
84// enterDoor.rotate(Direction.WEST);
85// } else {
86// leavingDoor1.rotate(Direction.WEST);
87// leavingDoor2.rotate(Direction.WEST);
88// }
89 break;
90 }
91 count++;
92 }
93 });
94 }
95
96 @Override
97 default void onCancellation(Player player) {
98 }
99}