RuneHive-Game
Loading...
Searching...
No Matches
GodwarsActivity.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.godwars;
2
3import com.runehive.Config;
4import com.runehive.content.activity.Activity;
5import com.runehive.content.activity.ActivityType;
6import com.runehive.content.activity.panel.ActivityPanel;
7import com.runehive.content.event.impl.ObjectInteractionEvent;
8import com.runehive.game.Animation;
9import com.runehive.game.Graphic;
10import com.runehive.game.world.entity.mob.Mob;
11import com.runehive.game.world.entity.mob.player.Player;
12import com.runehive.game.world.entity.mob.player.PlayerRight;
13import com.runehive.game.world.object.GameObject;
14import com.runehive.game.world.position.Area;
15import com.runehive.game.world.position.Position;
16
17import java.util.Optional;
18
19/**
20 * Handles the godwars activity.
21 *
22 * TODO: Add a way to get back up after climbing down to Saradomin chambers
23 *
24 * @author Daniel
25 */
26public class GodwarsActivity extends Activity {
27 /** The indexes for the god wars kill count. */
28 static final int ARMADYL = 0, BANDOS = 1, SARADOMIN = 2, ZAMORAK = 3;
29
30 /** The player instance of this activity. */
31 private final Player player;
32
33 /** The kill count array. */
34 private int[] killCount = new int[4];
35
36 /** The combat listener for the god wars activity. */
37 private final GodwarsListener listener = new GodwarsListener(this);
38
39 /** Constructs a new <code>GodwarsActivity</code>. */
41 super(1, Mob.DEFAULT_INSTANCE);
42 this.player = player;
43 }
44
45 /** Creates the godwars activity for the player. */
48 activity.add(player);
49 activity.update();
50 return activity;
51 }
52
53 /** Increments the godwars kill count and updates the interface. */
54 void increment(int index) {
55 killCount[index]++;
56 update();
57 }
58
59 /** Checks if the player can enter the godwars chambers. */
60 private boolean canEnter(int index) {
62 return true;
63 }
64 if (player.inventory.contains(11942, 1)) {
65 player.inventory.remove(11942);
66 player.message("You have used your Ecumencial key to enter the room.");
67 return true;
68 }
69 if (killCount[index] < 5) {
70 player.message("You need 5 kills before accessing this door!");
71 return false;
72 }
73 return true;
74 }
75
76 @Override
77 protected void start() {
78 pause();
79 }
80
81 @Override
82 public void finish() {
83 remove(player);
84 }
85
86 @Override
87 public void cleanup() {
89 }
90
91 @Override
92 public void update() {
93 String armadyl = "Armadyl kills: <col=ffffff>" + killCount[ARMADYL];
94 String bandos = "Bandos kills: <col=ffffff>" + killCount[BANDOS];
95 String saradomin = "Saradomin kills: <col=ffffff>" + killCount[SARADOMIN];
96 String zamorak = "Zamorak kills: <col=ffffff>" + killCount[ZAMORAK];
97 ActivityPanel.update(player, -1, "God Wars", "", "", armadyl, bandos, saradomin, zamorak);
98 }
99
100 @Override
102 GameObject object = event.getObject();
103 int identification = object.getId();
104
105 switch (identification) {
106 case 26502:
107 if (canEnter(ARMADYL) && player.getPosition().getY() < object.getPosition().getY()) {
108 player.move(new Position(player.getX(), player.getY() + 2, 2));
109 } else if (player.getPosition().getY() > object.getPosition().getY()) {
110 player.move(new Position(player.getX(), player.getY() - 2, 2));
111 }
112 return true;
113 case 26503:
114 if (canEnter(BANDOS) && player.getPosition().getX() < object.getPosition().getX()) {
115 player.move(new Position(player.getX() + 2, player.getY(), player.getHeight()));
116 } else if (player.getPosition().getX() > object.getPosition().getX()) {
117 player.move(new Position(player.getX() - 2, player.getY(), player.getHeight()));
118 }
119 return true;
120 case 26504:
121 if (player.getPosition().getX() < object.getPosition().getX()) {
122 player.move(new Position(player.getX() + 2, player.getY(), 0));
123 } else if (canEnter(SARADOMIN) && player.getPosition().getX() > object.getPosition().getX()) {
124 player.move(new Position(player.getX() - 2, player.getY(), 0));
125 }
126 return true;
127 case 26505:
128 if (canEnter(ZAMORAK) && player.getPosition().getY() > object.getPosition().getY()) {
129 player.move(new Position(player.getX(), player.getY() - 2, 2));
130 } else if (player.getPosition().getY() < object.getPosition().getY()) {
131 player.move(new Position(player.getX(), player.getY() + 2, 2));
132 }
133 return true;
134 case 26518:
135 if (player.getY() == 5332) {
136 player.move(new Position(2885, 5345, 2));
137 } else {
138 player.move(new Position(2885, 5332, 2));
139 }
140 return true;
141 case 26380:
142 if (player.getY() == 5269) {
143 player.move(new Position(2871, 5279, 2));
144 } else {
145 player.move(new Position(2871, 5269, 2));
146 }
147 return true;
148 case 26461:
149 if (player.getX() >= 2851) {
150 player.move(new Position(2850, 5333, 2));
151 } else {
152 player.move(new Position(2851, 5333, 2));
153 }
154 return true;
155 case 26561:
156 player.move(new Position(2918, 5300, 1));
157 return true;
158 case 26562:
159 player.move(new Position(2919, 5274, 0));
160 return true;
161 }
162 return false;
163 }
164
165 @Override
167 if (!Area.inGodwars(player)) {
168 finish();
169 }
170 }
171
172 @Override
173 public boolean canTeleport(Player player) {
174 return true;
175 }
176 @Override
177 public void onDeath(Mob mob) {
178 if (mob.isPlayer()) {
179 cleanup();
181 mob.animate(Animation.RESET, true);
182 mob.graphic(Graphic.RESET, true);
183 }
184 }
185 @Override
187 return ActivityType.GODWARS;
188 }
189
190 @Override
191 protected Optional<GodwarsListener> getListener() {
192 return Optional.of(listener);
193 }
194}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final Position DEFAULT_POSITION
The default, i.e.
Definition Config.java:197
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
Definition Activity.java:55
final void pause()
Sets the cooldown flag to PAUSE.
GodwarsActivity(Player player)
Constructs a new GodwarsActivity.
void cleanup()
Cleans up the activity when finished.
final GodwarsListener listener
The combat listener for the god wars activity.
Optional< GodwarsListener > getListener()
Gets an Optional of the ActivityListener for this activity.
void increment(int index)
Increments the godwars kill count and updates the interface.
boolean clickObject(Player player, ObjectInteractionEvent event)
static GodwarsActivity create(Player player)
Creates the godwars activity for the player.
void onRegionChange(Player player)
Called when the player changes region.
final Player player
The player instance of this activity.
boolean canEnter(int index)
Checks if the player can enter the godwars chambers.
static final int ARMADYL
The indexes for the god wars kill count.
boolean canTeleport(Player player)
Called when the player attempts to teleport.
The combat listener for the god wars activity.
static void update(Player player, int amount, String title, String footer, String... strings)
Sends all the information for the activity panel.
static void clear(Player player)
Clears the activity panel.
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
static final Graphic RESET
Definition Graphic.java:17
Handles the mob class.
Definition Mob.java:66
void move(Position position)
Moves the mob to a set position.
Definition Mob.java:340
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
Optional< Graphic > graphic
Definition Mob.java:91
This class represents a character controlled by a player.
Definition Player.java:125
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inGodwars(Interactable entity)
Definition Area.java:133
Represents a single tile on the game world.
Definition Position.java:14
Holds all activity types that are timed.
default int getId()
Gets the object id.