mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-06 00:32:01 +00:00
Cleanup part 1 (#213)
* Clean up part 1 - Removed lots of dead code - Removed unncessary files not in use - Cleaned up small bits of code - Removed a few warnings - Server.java ---> GameEngine.java - Constants.java ---> GameConstants.java * Cape Dye Rewrote cape dying * Packaging - redone ----> com.rebotted * PacketSender/clean up - ActionSender ---> PacketSender - Moved many more packets to packetsender - Cleaned up more dead code * Merge Client/Player - Merged Client.java with Player.java (both were doing same thing so redundant to have both) - Removed some more dead code - Tidy a few small things up * Quests/more clean up - Removed more dead code - Made quests static in order to clean them up a bit * More cleanup - Removed some more of the dead quest code - Correcting naming of some of the shop variables
This commit is contained in:
committed by
Daniel Ginovker
parent
3d1ae1b288
commit
d876a923b9
@@ -0,0 +1,53 @@
|
||||
package com.rebotted.game.content.random;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.Random;
|
||||
import com.rebotted.GameEngine;
|
||||
import com.rebotted.game.objects.Objects;
|
||||
import com.rebotted.game.players.Player;
|
||||
|
||||
public class Balloons extends Objects {
|
||||
|
||||
static Random r = new Random();
|
||||
public static int item, amount;
|
||||
public static int x, y;
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public Balloons(int id, int x, int y, int height, int face, int type,
|
||||
int ticks, int item, int amount) {
|
||||
super(id, x, y, height, face, type, ticks);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public static void popBalloon(Player player, int x, int y) {
|
||||
PartyRoom.coords.remove(getCoords());
|
||||
Balloons empty = remove(x, y);
|
||||
GameEngine.itemHandler.createGroundItem(player, item, x, y, amount, player.playerId);
|
||||
item = 0;
|
||||
amount = 0;
|
||||
GameEngine.objectHandler.addObject(empty);
|
||||
GameEngine.objectHandler.placeObject(empty);
|
||||
player.startAnimation(794);
|
||||
}
|
||||
|
||||
public static Point getCoords() {
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
public static Balloons getBalloon(int item, int amount) {
|
||||
return new Balloons(115 + r.nextInt(5), 2730 + r.nextInt(13),
|
||||
3462 + r.nextInt(13), 0, 0, 10, 0, item, amount);
|
||||
}
|
||||
|
||||
public static Balloons getEmpty() {
|
||||
return new Balloons(115 + r.nextInt(5), 2730 + r.nextInt(13),
|
||||
3462 + r.nextInt(13), 0, 0, 10, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static Balloons remove(int x, int y) {
|
||||
return new Balloons(-1, x, y, 0, 0, 10, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.rebotted.game.content.random;
|
||||
|
||||
import com.rebotted.GameConstants;
|
||||
import com.rebotted.game.players.PlayerHandler;
|
||||
|
||||
/**
|
||||
* Holiday Drops
|
||||
* @author Andrew (Mr Extremez)
|
||||
*/
|
||||
|
||||
public enum HolidayDrops {
|
||||
EASTER(1961, "Easter", false), HALLOWEEN(1053, "Halloween", false), CHRISTMAS(962, "Christmas", false);
|
||||
|
||||
private final int item;// holiday item
|
||||
private final String name;// holiday name
|
||||
private final boolean whichHoliday;// if true, this holiday will be dropped
|
||||
public final int DROP_DISTANCE = 40;// distance of drops
|
||||
public int count = 0;// count starts at 0 and ends at 400 can be changed
|
||||
public final int drops = 7;// this is just for random number of the drops
|
||||
public static int DROP_AMOUNT = PlayerHandler.playerCount * 5;// players
|
||||
// online *
|
||||
// 5 = drop
|
||||
// amount
|
||||
public static int dropAmount() {
|
||||
int amount = DROP_AMOUNT;
|
||||
if (GameConstants.SERVER_DEBUG) {
|
||||
return amount * 60;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
private HolidayDrops(int item, String name, boolean whichHoliday) {
|
||||
this.item = item;
|
||||
this.name = name;
|
||||
this.whichHoliday = whichHoliday;
|
||||
}
|
||||
|
||||
public int getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean getHoliday() {
|
||||
return whichHoliday;
|
||||
}
|
||||
|
||||
public final int[][] COORDS = { { 3214, 3424 }, // Varrock
|
||||
{ 3222, 3218 }, // Lumbridge
|
||||
{ 2964, 3378 }, // Falador
|
||||
{ 3082, 3419 }, // Barb
|
||||
{ 3082, 3249 }, // Draynor
|
||||
{ 3293, 3180 }, // Al Kharid
|
||||
{ 3034, 3246 }, // Rimmington
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.rebotted.game.content.random;
|
||||
|
||||
import com.rebotted.GameEngine;
|
||||
import com.rebotted.event.CycleEvent;
|
||||
import com.rebotted.event.CycleEventContainer;
|
||||
import com.rebotted.event.CycleEventHandler;
|
||||
import com.rebotted.game.players.Client;
|
||||
import com.rebotted.game.players.Player;
|
||||
import com.rebotted.game.players.PlayerHandler;
|
||||
import com.rebotted.util.Misc;
|
||||
|
||||
/**
|
||||
* Holiday Drops
|
||||
* @author Andrew (I'm A Boss on Rune-Server, Mr Extremez on Moparscape & Runelocus)
|
||||
*/
|
||||
|
||||
public class Holidays {
|
||||
|
||||
public static void startDropping(Client c) {
|
||||
for (final HolidayDrops holiday : HolidayDrops.values()) {
|
||||
for (Player player : PlayerHandler.players) {
|
||||
if (player != null) {
|
||||
Client p1 = (Client) player;
|
||||
if (holiday.getHoliday()) {
|
||||
if (p1.playerRights > 2) {
|
||||
p1.getPacketSender().sendMessage("Currently dropping " + HolidayDrops.dropAmount() + " items.");
|
||||
}
|
||||
p1.getPacketSender().sendMessage("The " + holiday.getName() + " event has started, goodluck!");
|
||||
dropItems(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void dropItems(Client client) {
|
||||
CycleEventHandler.getSingleton().addEvent(client, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
for (int j = 0; j < PlayerHandler.players.length; j++) {
|
||||
if (PlayerHandler.players[j] != null) {
|
||||
Client p1 = (Client) PlayerHandler.players[j];
|
||||
for (HolidayDrops holiday : HolidayDrops.values()) {
|
||||
if (holiday.count >= HolidayDrops.dropAmount() && holiday.getHoliday()) {
|
||||
stop();
|
||||
p1.getPacketSender().sendMessage("The " + holiday.getName() + " event has ended, good luck finding the rest of the items!");
|
||||
} else if (holiday.count < HolidayDrops.dropAmount() && holiday.getHoliday()) {
|
||||
switch (Misc.random(holiday.drops)) {
|
||||
case 0:// Varrock
|
||||
GameEngine.itemHandler.createGroundItem(p1, holiday.getItem(), 3214 + Misc.random(holiday.DROP_DISTANCE), 3424 - Misc.random(holiday.DROP_DISTANCE), 1, j);
|
||||
holiday.count++;
|
||||
break;
|
||||
case 1:// Lumbridge
|
||||
GameEngine.itemHandler.createGroundItem(p1, holiday.getItem(), 3222 + Misc.random(holiday.DROP_DISTANCE), 3218 - Misc.random(holiday.DROP_DISTANCE), 1, j);
|
||||
holiday.count++;
|
||||
break;
|
||||
case 2:// Falador
|
||||
GameEngine.itemHandler.createGroundItem(p1, holiday.getItem(), 2964 + Misc.random(holiday.DROP_DISTANCE), 3378 - Misc.random(holiday.DROP_DISTANCE), 1, j);
|
||||
holiday.count++;
|
||||
break;
|
||||
case 3:// Barb Village
|
||||
GameEngine.itemHandler.createGroundItem(p1, holiday.getItem(), 3082 + Misc.random(holiday.DROP_DISTANCE), 3419 - Misc.random(holiday.DROP_DISTANCE), 1, j);
|
||||
holiday.count++;
|
||||
break;
|
||||
case 4:// Draynor
|
||||
GameEngine.itemHandler.createGroundItem(p1, holiday.getItem(), 3082 + Misc.random(holiday.DROP_DISTANCE), 3249 - Misc.random(holiday.DROP_DISTANCE), 1, j);
|
||||
holiday.count++;
|
||||
break;
|
||||
case 5:// Al Kharid
|
||||
GameEngine.itemHandler.createGroundItem(p1, holiday.getItem(), 3293 + Misc.random(holiday.DROP_DISTANCE), 3180 - Misc.random(holiday.DROP_DISTANCE), 1, j);
|
||||
holiday.count++;
|
||||
break;
|
||||
case 6:// Rimmington
|
||||
GameEngine.itemHandler.createGroundItem(p1, holiday.getItem(), 3034 + Misc.random(holiday.DROP_DISTANCE), 3246 - Misc.random(holiday.DROP_DISTANCE), 1, j);
|
||||
holiday.count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void stop() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package com.rebotted.game.content.random;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import com.rebotted.GameConstants;
|
||||
import com.rebotted.GameEngine;
|
||||
import com.rebotted.game.items.Item;
|
||||
import com.rebotted.game.objects.Objects;
|
||||
import com.rebotted.game.players.Player;
|
||||
|
||||
public class PartyRoom {
|
||||
|
||||
static Random r = new Random();
|
||||
static int[] roomItems = new int[50];
|
||||
static int[] roomItemsN = new int[50];
|
||||
static long lastAnnouncment;
|
||||
static int announcmentFrequency = 1; // announcment frequency in mins
|
||||
static ArrayList<Point> coords = new ArrayList<Point>();
|
||||
|
||||
public static int getAmount() {
|
||||
int amount = 0;
|
||||
for (int roomItem : roomItems) {
|
||||
if (roomItem > 0) {
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static void startTimer(Player c) {
|
||||
if (System.currentTimeMillis() - lastAnnouncment > 1000 * 60 * announcmentFrequency) {
|
||||
dropAll();
|
||||
lastAnnouncment = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dropAll() {
|
||||
int trys = 0;
|
||||
int amount = getAmount();
|
||||
if (amount < 1) {
|
||||
return;
|
||||
}
|
||||
for (int x = 0; x < roomItems.length; x++) {
|
||||
if (roomItemsN[x] > 0) {
|
||||
Balloons b = null;
|
||||
do {
|
||||
b = Balloons.getBalloon(roomItems[x], roomItemsN[x]);
|
||||
trys++;
|
||||
} while (coords.contains(Balloons.getCoords()) && trys < 100);
|
||||
GameEngine.objectHandler.addObject(b);
|
||||
GameEngine.objectHandler.placeObject(b);
|
||||
}
|
||||
if (trys > 100) {
|
||||
break;
|
||||
}
|
||||
roomItems[x] = 0;
|
||||
roomItemsN[x] = 0;
|
||||
}
|
||||
trys = 0;
|
||||
for (int x = 0; x < amount * 2; x++) {
|
||||
Objects o;
|
||||
do {
|
||||
o = Balloons.getEmpty();
|
||||
} while (coords.contains(new Point(o.objectX, o.objectY))
|
||||
&& trys < 100);
|
||||
if (trys > 100) {
|
||||
break;
|
||||
}
|
||||
GameEngine.objectHandler.addObject(o);
|
||||
GameEngine.objectHandler.placeObject(o);
|
||||
}
|
||||
coords.clear();
|
||||
}
|
||||
|
||||
public static int arraySlot(int[] array, int target) {
|
||||
int spare = -1;
|
||||
for (int x = 0; x < array.length; x++) {
|
||||
if (array[x] == target) {
|
||||
return x;
|
||||
} else if (spare == -1 && array[x] <= 0) {
|
||||
spare = x;
|
||||
}
|
||||
}
|
||||
return spare;
|
||||
}
|
||||
|
||||
public static void open(Player player) {
|
||||
if (!GameConstants.PARTY_ROOM_DISABLED) {
|
||||
updateGlobal(player);
|
||||
updateDeposit(player);
|
||||
player.getItemAssistant().resetItems(5064);
|
||||
player.getPacketSender().sendFrame248(2156, 5063);
|
||||
} else {
|
||||
player.getPacketSender().sendMessage("The partyroom has been disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void accept(Player c) {
|
||||
for (int x = 0; x < c.party.length; x++) {
|
||||
if (c.partyN[x] > 0) {
|
||||
if (Item.itemStackable[c.party[x]]) {
|
||||
int slot = arraySlot(roomItems, c.party[x]);
|
||||
if (slot < 0) {
|
||||
c.getPacketSender().sendMessage(
|
||||
"Theres not enough space left in the chest.");
|
||||
break;
|
||||
}
|
||||
if (roomItems[slot] != c.party[x]) {
|
||||
roomItems[slot] = c.party[x];
|
||||
roomItemsN[slot] = c.partyN[x];
|
||||
} else {
|
||||
roomItemsN[slot] += c.partyN[x];
|
||||
}
|
||||
c.party[x] = -1;
|
||||
c.partyN[x] = 0;
|
||||
} else {
|
||||
int left = c.partyN[x];
|
||||
for (int y = 0; y < left; y++) {
|
||||
int slot = arraySlot(roomItems, -2);
|
||||
if (slot < 0) {
|
||||
c.getPacketSender()
|
||||
.sendMessage(
|
||||
"Theres not enough space left in the chest.");
|
||||
break;
|
||||
}
|
||||
roomItems[slot] = c.party[x];
|
||||
roomItemsN[slot] = 1;
|
||||
c.partyN[x]--;
|
||||
}
|
||||
if (c.partyN[x] <= 0) {
|
||||
c.party[x] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateDeposit(c);
|
||||
updateGlobal(c);
|
||||
}
|
||||
|
||||
// public static void updateAll() {
|
||||
// for (int x = 0; x < PlayerHandler.getPlayers().length; x++) {
|
||||
// updateGlobal((Client) PlayerHandler.getPlayers()[x]);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void fix(Player c) {
|
||||
for (int x = 0; x < 8; x++) {
|
||||
if (c.party[x] < 0) {
|
||||
c.partyN[x] = 0;
|
||||
} else if (c.partyN[x] <= 0) {
|
||||
c.party[x] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void depositItem(Player player, int id, int amount) {
|
||||
int slot = arraySlot(player.party, id);
|
||||
for (int i : GameConstants.ITEM_TRADEABLE) {
|
||||
if (i == id) {
|
||||
player.getPacketSender().sendMessage("You can't deposit this item.");
|
||||
return;
|
||||
}
|
||||
if (id == 995) {
|
||||
player.getPacketSender().sendMessage("You can't deposit coins!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (player.getItemAssistant().getItemAmount(id) < amount) {
|
||||
amount = player.getItemAssistant().getItemAmount(id);
|
||||
}
|
||||
if (!player.getItemAssistant().playerHasItem(id, amount)) {
|
||||
player.getPacketSender().sendMessage(
|
||||
"You don't have that many items!");
|
||||
return;
|
||||
}
|
||||
if (slot == -1) {
|
||||
player.getPacketSender().sendMessage(
|
||||
"You cant deposit more than 8 items at once.");
|
||||
return;
|
||||
}
|
||||
player.getItemAssistant().deleteItem(id, amount);
|
||||
if (player.party[slot] != id) {
|
||||
player.party[slot] = id;
|
||||
player.partyN[slot] = amount;
|
||||
} else {
|
||||
player.party[slot] = id;
|
||||
player.partyN[slot] += amount;
|
||||
}
|
||||
updateDeposit(player);
|
||||
}
|
||||
|
||||
public static void withdrawItem(Player c, int slot) {
|
||||
if (c.party[slot] >= 0 && c.getItemAssistant().freeSlots() > 0) {
|
||||
c.getItemAssistant().addItem(c.party[slot], c.partyN[slot]);
|
||||
c.party[slot] = 0;
|
||||
c.partyN[slot] = 0;
|
||||
}
|
||||
updateDeposit(c);
|
||||
updateGlobal(c);
|
||||
}
|
||||
|
||||
public static void updateDeposit(Player player) {
|
||||
player.getItemAssistant().resetItems(5064);
|
||||
for (int x = 0; x < 8; x++) {
|
||||
if (player.partyN[x] <= 0) {
|
||||
itemOnInterface(player, 2274, x, -1, 0);
|
||||
} else {
|
||||
itemOnInterface(player, 2274, x, player.party[x], player.partyN[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateGlobal(Player player) {
|
||||
for (int x = 0; x < roomItems.length; x++) {
|
||||
if (roomItemsN[x] <= 0) {
|
||||
itemOnInterface(player, 2273, x, -1, 0);
|
||||
} else {
|
||||
itemOnInterface(player, 2273, x, roomItems[x], roomItemsN[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void itemOnInterface(Player player, int frame, int slot, int id, int amount) {
|
||||
player.outStream.createFrameVarSizeWord(34);
|
||||
player.outStream.writeWord(frame);
|
||||
player.outStream.writeByte(slot);
|
||||
player.outStream.writeWord(id + 1);
|
||||
player.outStream.writeByte(255);
|
||||
player.outStream.writeDWord(amount);
|
||||
player.outStream.endFrameVarSizeWord();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user