This is a command that drops random Rares around the world, Not too many either. The amount is set to 15, but you can change easily. You can also change the ID's of the items in ChristmasDrop.java. Lets begin.
Pictures:
In Item.java add this anywhere: (Server folder, Src -- org -- rscdaemon -- server -- model)
Code:
public long droppedBy = 0;
public Item(int id, int x, int y, int amount, Player owner, long spawnTime) {
setID(id);
setAmount(amount);
this.owner = owner;
if(owner != null) {
droppedBy = owner.getUsernameHash();
}
spawnedTime = spawnTime;
setLocation(Point.location(x, y));
}
In Point.java find: (Server folder, Src -- org -- rscdaemon -- server -- model)
Code:
private Point(int x, int y) {
Replace that with
Code:
public Point(int x, int y) {
Now go into your minigames folder, src -- org -- rscdaemon -- server -- minigames. if you do not have it create it there. Then inside that create a new folder called Christmas and then inside that create a new file called ChristmasDrop.java:
Code:
package org.rscdaemon.server.minigames.christmas;
/**
* Imports
*/
import org.rscdaemon.server.util.DataConversions;
import org.rscdaemon.server.event.MiniEvent;
import org.rscdaemon.server.model.Player;
import org.rscdaemon.server.model.World;
import org.rscdaemon.server.model.Point;
import org.rscdaemon.server.model.Item;
public class ChristmasDrop {
/**
* Christmas World Drop
* @author Yong Min
*/
private static final World world = World.getWorld();
private static final int[] randomDropItem = { 575, 576, 577, 578, 579, 580, 581, 593, 594, 597, 1276, 1277, 81, 93, 112, 400, 401, 402, 404, 406, 407,
677, 828, 831, 832, 1156, 971 };
private static Point[] dropLocations = {
new Point(291, 568),
new Point(219, 642),
new Point(136, 507),
new Point(220, 432)
};
private static int randomItem = 0;
public static void startCountDown() {
world.getDelayedEventHandler().add(new MiniEvent(null, 1000) {
public void action() {
for(final Player p : world.getPlayers()) {
p.getActionSender().sendMessage("@red@[Christmas Drop] @ora@The Christmas World Drop will begin in 3 seconds!");
world.getDelayedEventHandler().add(new MiniEvent(null, 1000) {
public void action() {
p.getActionSender().sendMessage("@red@[Christmas Drop] @ora@The Christmas World Drop will begin in 2 seconds!");
world.getDelayedEventHandler().add(new MiniEvent(null, 1000) {
public void action() {
p.getActionSender().sendMessage("@red@[Christmas Drop] @ora@The Christmas World Drop will begin in 1 seconds!");
world.getDelayedEventHandler().add(new MiniEvent(null, 1000) {
public void action() {
startWorldDrop();
}
});
}
});
}
});
}
}
});
}
public static void startWorldDrop() {
world.getDelayedEventHandler().add(new MiniEvent(null, 3000) {
public void action() {
for(int itemAmount = 0; itemAmount < 15; itemAmount++) {
Point dropCoordinates = dropLocations[DataConversions.random(0, dropLocations.length - 1)];
int x = dropCoordinates.getX() + (DataConversions.random(0, 1) == 1 ? - 20 : 0) + DataConversions.random(0, 20);
int y = dropCoordinates.getY() + (DataConversions.random(0, 1) == 1 ? - 20 : 0) + DataConversions.random(0, 20);
while(world.getTile(x, y).hasGameObject()) {
x = dropCoordinates.getX() + (DataConversions.random(0, 1) == 1 ? - 20 : 0) + DataConversions.random(0, 20);
y = dropCoordinates.getY() + (DataConversions.random(0, 1) == 1 ? - 20 : 0) + DataConversions.random(0, 20);
}
setRandomItem();
world.registerItem(new Item(randomItem, x, y, 1, null, System.currentTimeMillis() - DataConversions.random(45000, 60000)));
}
for(Player p : world.getPlayers()) {
p.getActionSender().sendAlert("@ran@Merry Christmas!" + "@whi@ The World Drop has now dropped items around the following locations: Draynor, Falador, Edgeville & Varrock! Happy Hunting!", false);
}
}
});
}
public static void setRandomItem() {
randomItem = (randomDropItem[(int)(Math.random() * randomDropItem.length)]);
}
}
In CommandHandler.java Import: (src -- org -- rscdaemon -- server -- packethandler -- client -- org -- client)
Code:
import org.rscdaemon.server.minigames.christmas.ChristmasDrop;
Then add this Code:
Code:
if (cmd.equals("xmasdrop")) && (player.isAdmin())) {
ChristmasDrop.startCountDown();
}
If you get an error with the command change the code to this:
Code:
if((cmd.equals("xmasdrop")) && (player.isAdmin())) {
ChristmasDrop.startCountDown();
}
I Hope you Like it! Enjoy!