1
General / Re: Random events
« on: January 09, 2013, 06:25:05 pm »
Fixed.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
package server.game.content.randoms;
import server.game.npcs.NPCHandler;
import server.game.players.Client;
import server.util.Misc;
public class EvilChicken {
private static int[][] chicken = {
{3, 10, 2463, 19, 1},
{11, 20, 2464, 40, 1},
{21, 40, 2465, 60, 2},
{41, 60, 2466, 80, 3},
{61, 90, 2467, 105, 4},
{91, 138, 2468, 120, 5},
};
public static void spawnChicken(Client c) {
for (int[] aChicken : chicken) {
if (c.combatLevel >= aChicken[0] && c.combatLevel <= aChicken[1]) {
NPCHandler.spawnNpc(c, aChicken[2], c.absX + Misc.random(1), c.absY + Misc.random(1), c.heightLevel, 0, aChicken[3], aChicken[4], aChicken[4] * 10, aChicken[4] * 10, true, false);
}
}
}
}
package server.game.content.randoms;
import server.game.players.Client;
import server.util.Misc;
public class FreakyForester extends EventHandler {
public static void teleportToLocation(final Client c) {
if (TutorialIsland.getTutorialIslandStage() <= 15)
return;
c.teleportToX = 2602;
c.teleportToY = 4775;
c.lastX = c.absX;
c.lastY = c.absY;
c.lastH = c.heightLevel;
c.sendMessage("Talk to the freaky forester to get out.");
}
private static String[] pheasant = {
"one", "two", "three", "four",
};
public static String getPheasant(Client c) {
if(c.getPheasent < 0) {
c.getPheasent = Misc.random(3);
}
return pheasant[c.getPheasent] +" tailed";
}
public static void leaveArea(Client c) {
if(c.killedPheasant[c.getPheasent]) {
c.getPA().movePlayer(c.lastX, c.lastY, c.lastH);
c.cantTeleport = false;
c.sendMessage("Congratulations, you've completed the freaky forester event!");
c.getItems().addItem(6180 + Misc.random(2), 1);
} else {
failEvent(c);
}
for(int i = 0; i < 4; i++ ) {
c.killedPheasant[i] = false;
}
c.getPheasent = -1;
c.canLeaveArea = false;
}
public static void killedPheasant(Client c, int p) {
for(int i = 0; i < 4; i++ ) {
c.killedPheasant[i] = false;
}
c.killedPheasant[p] = true;
}
public static boolean hasKilledPheasant(Client c) {
for(int i = 0; i < 4; i++ ) {
if(c.killedPheasant[i]) {
return true;
}
}
return false;
}
}
Freaky Forester Dialogue ("parts") Don't forget Import. case 2:
if (c.canLeaveArea) {
c.getDH().sendNpcChat2("Just step through the glowing portal when you're ready", "to leave, and I'll ensure you get a nice reward.", c.talkingNpc, "Freaky Forester");
} else if (FreakyForester.hasKilledPheasant(c) && c.getItems().playerHasItem(6178, 1)) {
c.getDH().sendNpcChat1("Thank you. I take that pheasant, you can leave now.", c.talkingNpc, "Freaky Forester");
c.canLeaveArea = true;
c.getItems().deleteItem(6178, c.getItems().getItemSlot(6178), c.getItems().getItemAmount(6178));
} else {
c.getDH().sendNpcChat2("Hello there mate. Can you please kill a " + FreakyForester.getPheasant(c) + " and", "bring it back to me and I shall let you leave.", c.talkingNpc, "Freaky Forester");
}
c.nextChat = 0;
break;//Respawn Place.
case 3:
c.getDH().sendNpcChat1("Come back mate! You can't leave yet!", c.talkingNpc, "Freaky Forester");
c.nextChat = 0;
break;
private static final int
GOLEM_LEVEL_14 = 413,
GOLEM_LEVEL_29 = 414,
GOLEM_LEVEL_49 = 415,
GOLEM_LEVEL_79 = 416,
GOLEM_LEVEL_120 = 417,
GOLEM_LEVEL_159 = 418;
public static boolean randomGolemSpawn(Client c) {
if (c.playerHasRandomEvent == false) {
if (c.combatLevel >= 3 && c.combatLevel < 29) {
NPCHandler.spawnNpc(c, GOLEM_LEVEL_14, c.absX, c.absY + 1, c.heightLevel, 0, 28, 1, 10, 10, true, false);
c.playerHasRandomEvent = true;
return true;
} else if (c.combatLevel >= 29 && c.combatLevel < 49) {
NPCHandler.spawnNpc(c, GOLEM_LEVEL_29, c.absX, c.absY + 1, c.heightLevel, 0, 36, 3, 50, 50, true, false);
c.playerHasRandomEvent = true;
return true;
} else if (c.combatLevel >= 49 && c.combatLevel < 79) {
NPCHandler.spawnNpc(c, GOLEM_LEVEL_49, c.absX, c.absY + 1, c.heightLevel, 0, 36, 3, 75, 75, true, false);
c.playerHasRandomEvent = true;
return true;
} else if (c.combatLevel >= 79 && c.combatLevel < 100) {
NPCHandler.spawnNpc(c, GOLEM_LEVEL_79, c.absX, c.absY + 1, c.heightLevel, 0, 36, 3, 100, 100, true, false);
c.playerHasRandomEvent = true;
return true;
} else if (c.combatLevel >= 100 && c.combatLevel < 110) {
NPCHandler.spawnNpc(c, GOLEM_LEVEL_120, c.absX, c.absY + 1, c.heightLevel, 0, 36, 3, 100, 100, true, false);
c.playerHasRandomEvent = true;
return true;
} else if (c.combatLevel >= 110) {
NPCHandler.spawnNpc(c, GOLEM_LEVEL_159, c.absX, c.absY + 1, c.heightLevel, 0, 36, 3, 100, 100, true, false);
c.playerHasRandomEvent = true;
return true;
}
}
return false;
}
}
Sandwich Lady:package server.game.content.randoms;
import server.game.players.Client;
import server.util.Misc;
public class SandwhichLady extends EventHandler {
public static void handleOptions(Client c, int actionbuttonId) {
switch (actionbuttonId) {
case 63013:
if(c.pieSelect == 1 && c.eventTimer + 1800 > System.currentTimeMillis()) {
c.getPA().closeAllWindows();
c.getItems().addItem(2323, 1);
c.sendMessage("Congratulations, you have completed the random event!");
c.eventTimer = System.currentTimeMillis();
} else {
c.sendMessage("You have chosen the wrong Item!");
failEvent(c);
}
break;
case 63014:
if(c.kebabSelect == 1 && c.eventTimer + 1800 > System.currentTimeMillis()) {
c.getPA().closeAllWindows();
c.getItems().addItem(1971, 1);
c.sendMessage("Congratulations, you have completed the random event!");
c.eventTimer = System.currentTimeMillis();
} else {
c.sendMessage("You have chosen the wrong Item!");
failEvent(c);
}
break;
case 63015:
if(c.chocSelect == 1 && c.eventTimer + 1800 > System.currentTimeMillis()) {
c.getPA().closeAllWindows();
c.getItems().addItem(1973, 1);
c.sendMessage("Congratulations, you have completed the random event!");
c.eventTimer = System.currentTimeMillis();
} else {
c.sendMessage("You have chosen the wrong Item!");
failEvent(c);
}
break;
case 63009:
if(c.bagelSelect == 1 && c.eventTimer + 1800 > System.currentTimeMillis()) {
c.getPA().closeAllWindows();
c.getItems().addItem(6961, 10);
c.sendMessage("Congratulations, you have completed the random event!");
c.eventTimer = System.currentTimeMillis();
} else {
c.sendMessage("You have chosen the wrong Item!");
failEvent(c);
}
break;
case 63010:
if(c.triangleSandwich == 1 && c.eventTimer + 1800 > System.currentTimeMillis()) {
c.getPA().closeAllWindows();
c.getItems().addItem(6962, 1);
c.sendMessage("Congratulations, you have completed the random event!");
c.eventTimer = System.currentTimeMillis();
} else {
c.sendMessage("You have chosen the wrong Item!");
failEvent(c);
}
break;
case 63011:
if(c.squareSandwich == 1 && c.eventTimer + 1800 > System.currentTimeMillis()) {
c.getPA().closeAllWindows();
c.getItems().addItem(6965, 1);
c.sendMessage("Congratulations, you have completed the random event!");
c.eventTimer = System.currentTimeMillis();
} else {
c.sendMessage("You have chosen the wrong Item!");
failEvent(c);
}
break;
case 63012:
if(c.breadSelect == 1 && c.eventTimer + 1800 > System.currentTimeMillis()) {
c.getPA().closeAllWindows();
c.getItems().addItem(2309, 1);
c.sendMessage("Congratulations, you have completed the random event!");
c.eventTimer = System.currentTimeMillis();
} else {
c.sendMessage("You have chosen the wrong Item!");
failEvent(c);
}
}
}
public static void randomEvent(Client c) {
c.getPA().sendFrame126(" ", 16131);
c.getPA().showInterface(16135);
int randomMessage = Misc.random(6);
switch (randomMessage) {
case 0:
c.getPA().sendFrame126("Please select the pie.", 16145);
c.pieSelect = 1;
break;
case 1:
c.getPA().sendFrame126("Please select the kebab.", 16145);
c.kebabSelect = 1;
break;
case 2:
c.getPA().sendFrame126("Please select the chocolate.", 16145);
c.chocSelect = 1;
break;
case 3:
c.getPA().sendFrame126("Please select the bagel.", 16145);
c.bagelSelect = 1;
break;
case 4:
c.getPA().sendFrame126("Please select the triangle sandwich.", 16145);
c.triangleSandwich = 1;
break;
case 5:
c.getPA().sendFrame126("Please select the square sandwich.", 16145);
c.squareSandwich = 1;
break;
case 6:
c.getPA().sendFrame126("Please select the bread.", 16145);
c.breadSelect = 1;
break;
}
}
}
Zombie base:package server.game.content.randoms;
import server.game.npcs.NPCHandler;
import server.game.players.Client;
import server.util.Misc;
public class Zombie {
private static int[][] zombie = {{3, 10, 419}, {11, 20, 420}, {21, 40, 421}, {61, 90, 422}, {91, 110, 423}, {111, 138, 424}};
public static void spawnZombie(Client c) {
for (int[] element : zombie) {
if (Misc.random(300) == 4) {
if (c.combatLevel >= element[0] && c.combatLevel <= element[1]) {
NPCHandler.spawnNpc(c, element[2], c.absX, c.absY, c.heightLevel, 0, element[3], element[4], element[4] * 10, element[4] * 10, true, false);
break;
}
}
}
}
}
Still need stuff for these. But its a start