Craig╭∩╮(︶︿︶)╭∩╮ Designer
Posts : 97 Points : 118 Reputation : 0 Join date : 2013-04-08 Age : 108 Location : Under your bed
| Subject: Re: News! We found Castle Wars:) Sat Apr 13, 2013 9:44 pm | |
| k - Code:
-
Server.java where you initiate the other processes replace your castle wars one with this
Code: CastleWars.process(); import
Code: import server.model.minigames.*; should already be there tho
My castlewars.java
Code: package server.model.minigames;
import java.util.HashMap; import java.util.Iterator; import server.model.players.Client; import server.util.Misc;
/** * @Author Sanity for base * @Edited by Satan666 */ public class CastleWars {
/* * Game timers. */ private static final int GAME_TIMER = 200; //1500 * 600 = 900000ms = 15 minutes private static final int GAME_START_TIMER = 30; /* * Hashmap for the waitingroom players */ private static HashMap<Client, Integer> waitingRoom = new HashMap<Client, Integer>(); /* * hashmap for the gameRoom players */ private static HashMap<Client, Integer> gameRoom = new HashMap<Client, Integer>(); /* * The coordinates for the waitingRoom both sara/zammy */ private static final int[][] WAIT_ROOM = { {2377, 9485}, //sara {2421, 9524} //zammy }; /* * The coordinates for the gameRoom both sara/zammy */ private static final int[][] GAME_ROOM = { {2426, 3076}, //sara {2372, 3131} //zammy }; private static final int[][] FLAG_STANDS = { {2429, 3074}, //sara {X-Coord, Y-Coord) {2370, 3133} //zammy }; /* * Scores for saradomin and zamorak! */ private static int[] scores = {0, 0}; /* * Booleans to check if a team's flag is safe */ private static int zammyFlag = 0; private static int saraFlag = 0; /* * Zamorak and saradomin banner/capes item ID's */ public static final int SARA_BANNER = 4037; public static final int ZAMMY_BANNER = 4039; public static final int SARA_CAPE = 4041; public static final int ZAMMY_CAPE = 4042; /* * */ private static int properTimer = 0; private static int timeRemaining = -1; private static int gameStartTimer = GAME_START_TIMER; private static boolean gameStarted = false;
/** * Method we use to add someone to the waitinroom in a different method, this will filter out some error messages * @param player the player that wants to join * @param team the team! */ public static void addToWaitRoom(Client player, int team) { if (player == null) { return; } else if (gameStarted == true) { player.sendMessage("There's already a Castle Wars going. Please wait a few minutes before trying again."); return; } else if (player.playerEquipment[Client.playerHat] > 0 || player.playerEquipment[Client.playerCape] > 0) { player.sendMessage("You may not wear capes or helmets inside of castle wars."); return; } toWaitingRoom(player, team); }
/** * Method we use to transfer to player from the outside to the waitingroom (: * @param player the player that wants to join * @param team team he wants to be in - team = 1 (saradomin), team = 2 (zamorak), team = 3 (random) */ public static void toWaitingRoom(Client player, int team) { if (team == 1) { if (getSaraPlayers() > getZammyPlayers() && getSaraPlayers() > 0) { player.sendMessage("The saradomin team is full, try again later!"); return; } if (getZammyPlayers() >= getSaraPlayers() || getSaraPlayers() == 0) { player.sendMessage("You have been added to the @red@Saradomin@bla@ team."); player.sendMessage("Next Game Begins In:@red@ " + ((gameStartTimer * 3) + (timeRemaining * 3)) + " @bla@seconds."); addCapes(player, SARA_CAPE); waitingRoom.put(player, team); player.getPA().movePlayer(WAIT_ROOM[team - 1][0] + Misc.random(5), WAIT_ROOM[team - 1][1] + Misc.random(5), 0); } } else if (team == 2) { if (getZammyPlayers() > getSaraPlayers() && getZammyPlayers() > 0) { player.sendMessage("The zamorak team is full, try again later!"); return; } if (getZammyPlayers() <= getSaraPlayers() || getZammyPlayers() == 0) { player.sendMessage("[@red@RANDOM TEAM@bla@] You have been added to the @red@Zamorak@bla@ team."); player.sendMessage("Next Game Begins In:@red@ " + ((gameStartTimer * 3) + (timeRemaining * 3)) + " @bla@seconds."); addCapes(player, ZAMMY_CAPE); waitingRoom.put(player, team); player.getPA().movePlayer(WAIT_ROOM[team - 1][0] + Misc.random(5), WAIT_ROOM[team - 1][1] + Misc.random(5), 0); } } else if (team == 3) { toWaitingRoom(player, getZammyPlayers() > getSaraPlayers() ? 1 : 2); return; } }
/** * Method to add score to scoring team * @param player the player who scored * @param banner banner id! */ public static void returnFlag(Client player, int wearItem) { if (player == null) { return; } if (wearItem != SARA_BANNER && wearItem != ZAMMY_BANNER) { return; } int team = gameRoom.get(player); int objectId = -1; int objectTeam = -1; switch (team) { case 1: if (wearItem == SARA_BANNER) { setSaraFlag(0); objectId = 4902; objectTeam = 0; player.sendMessage("returned the sara flag!"); } else { objectId = 4903; objectTeam = 1; setZammyFlag(0); scores[0]++; //upping the score of a team; team 0 = sara, team 1 = zammy player.sendMessage("The team of Saradomin scores 1 point!"); } break; case 2: if (wearItem == ZAMMY_BANNER) { setZammyFlag(0); objectId = 4903; objectTeam = 1; player.sendMessage("returned the zammy flag!"); } else { objectId = 4902; objectTeam = 0; setSaraFlag(0); scores[1]++; //upping the score of a team; team 0 = sara, team 1 = zammy player.sendMessage("The team of Zamorak scores 1 point!"); zammyFlag = 0; } break; } changeFlagObject(objectId, objectTeam); player.getPA().createPlayerHints(10, -1); player.playerEquipment[Client.playerWeapon] = -1; player.playerEquipmentN[Client.playerWeapon] = 0; player.getItems().updateSlot(3); player.appearanceUpdateRequired = true; player.updateRequired = true; player.getItems().resetItems(3214); }
/** * Method that will capture a flag when being taken by the enemy team! * @param player the player who returned the flag * @param team */ public static void captureFlag(Client player) { if (player.playerEquipment[Client.playerWeapon] > 0) { player.sendMessage("Please remove your weapon before attempting to get the flag again!"); return; } int team = gameRoom.get(player); if (team == 2 && saraFlag == 0) { //sara flag setSaraFlag(1); addFlag(player, SARA_BANNER); createHintIcon(player, 1); changeFlagObject(4377, 0); } if (team == 1 && zammyFlag == 0) { setZammyFlag(1); addFlag(player, ZAMMY_BANNER); createHintIcon(player, 2); changeFlagObject(4378, 1); } }
/** * Method that will add the flag to a player's weapon slot * @param player the player who's getting the flag * @param flagId the banner id. */ public static void addFlag(Client player, int flagId) { player.playerEquipment[Client.playerWeapon] = flagId; player.playerEquipmentN[Client.playerWeapon] = 1; player.getItems().updateSlot(Client.playerWeapon); player.appearanceUpdateRequired = true; player.updateRequired = true; }
/** * Method we use to handle the flag dropping * @param player the player who dropped the flag/died * @param flagId the flag item ID */ public static void dropFlag(Client player, int flagId) { int object = -1; switch (flagId) { case SARA_BANNER: //sara setSaraFlag(2); object = 4900; createFlagHintIcon(player.getX(), player.getY()); break; case ZAMMY_BANNER: //zammy setZammyFlag(2); object = 4901; createFlagHintIcon(player.getX(), player.getY()); break; } Iterator iterator = gameRoom.keySet().iterator(); while (iterator.hasNext()) { Client teamPlayer = (Client) iterator.next(); teamPlayer.getPA().object(object, player.getX(), player.getY(), 0, 10); } }
/** * Method we use to pickup the flag when it was dropped/lost * @param Player the player who's picking it up * @param objectId the flag object id. */ public static void pickupFlag(Client player) { switch (player.objectId) { case 4900: //sara setSaraFlag(1); addFlag(player, 4037); break; case 4901: //zammy setZammyFlag(1); addFlag(player, 4039); break; } createHintIcon(player, (gameRoom.get(player) == 1) ? 2 : 1); Iterator iterator = gameRoom.keySet().iterator(); while (iterator.hasNext()) { Client teamPlayer = (Client) iterator.next(); teamPlayer.getPA().createObjectHints(player.objectX, player.objectY, 170, -1); teamPlayer.getPA().object(-1, player.objectX, player.objectY, 0, 10); } return; }
/** * Hint icons appear to your team when a enemy steals flag * @param player the player who took the flag * @param t team of the opponent team. (: */ public static void createHintIcon(Client player, int t) { Iterator iterator = gameRoom.keySet().iterator(); while (iterator.hasNext()) { Client teamPlayer = (Client) iterator.next(); System.out.println(teamPlayer.playerName + " => Team => " + gameRoom.get(teamPlayer)); System.out.println("desired team = " + t); teamPlayer.getPA().createPlayerHints(10, -1); if (gameRoom.get(teamPlayer) == t) { System.out.println("created hint icons for playername " + teamPlayer.playerName + " and team number: " + t); teamPlayer.getPA().createPlayerHints(10, player.playerId); teamPlayer.getPA().requestUpdates(); } } }
/** * Hint icons appear to your team when a enemy steals flag * @param player the player who took the flag * @param t team of the opponent team. (: */ public static void createFlagHintIcon(int x, int y) { Iterator iterator = gameRoom.keySet().iterator(); while (iterator.hasNext()) { Client teamPlayer = (Client) iterator.next(); teamPlayer.getPA().createObjectHints(x, y, 170, 2); } }
/** * This method is used to get the teamNumber of a certain player * @param player * @return */ public static int getTeamNumber(Client player) { if (player == null) { return -1; } if (gameRoom.containsKey(player)) { return gameRoom.get(player); } return -1; }
/** * The leaving method will be used on click object or log out * @param player player who wants to leave */ public static void leaveWaitingRoom(Client player) { if (player == null) { System.out.println("player is null"); return; } if (waitingRoom.containsKey(player)) { waitingRoom.remove(player); player.getPA().createPlayerHints(10, -1); player.sendMessage("You left your team!"); deleteGameItems(player); player.getPA().movePlayer(2439 + Misc.random(4), 3085 + Misc.random(5), 0); return; } player.getPA().movePlayer(2439 + Misc.random(4), 3085 + Misc.random(5), 0); System.out.println("Waiting room map does not contain " + player.playerName); }
public static void process() { if (properTimer > 0) { properTimer--; return; } else { properTimer = 4; } if (gameStartTimer > 0) { gameStartTimer--; updatePlayers(); } else if (gameStartTimer == 0) { startGame(); } if (timeRemaining > 0) { timeRemaining--; updateInGamePlayers(); } else if (timeRemaining == 0) { endGame(); } }
/** * Method we use to update the player's interface in the waiting room */ public static void updatePlayers() { Iterator iterator = waitingRoom.keySet().iterator(); while (iterator.hasNext()) { Client player = (Client) iterator.next(); if (player != null) { player.getPA().sendFrame126("Next Game Begins In:@red@ " + ((gameStartTimer * 3) + (timeRemaining * 3)) + " @whi@seconds.", 6570); player.getPA().sendFrame126("Zamorak Players: @red@" + getZammyPlayers() + "@whi@.", 6572); player.getPA().sendFrame126("Saradomin Players: @red@" + getSaraPlayers() + "@whi@.", 6664); player.getPA().walkableInterface(6673); } } }
/** * Method we use the update the player's interface in the game room */ public static void updateInGamePlayers() { if (getSaraPlayers() > 0 && getZammyPlayers() > 0) { Iterator iterator = gameRoom.keySet().iterator(); while (iterator.hasNext()) { Client player = (Client) iterator.next(); int config; if (player == null) { continue; } player.getPA().walkableInterface(11146); player.getPA().sendFrame126("Zamorak = " + scores[1], 11147); player.getPA().sendFrame126(scores[0] + " = Saradomin", 11148); player.getPA().sendFrame126(timeRemaining * 3 + " secs", 11155); config = (2097152 * saraFlag); player.getPA().sendFrame87(378, config); config = (2097152 * zammyFlag); //flags 0 = safe 1 = taken 2 = dropped player.getPA().sendFrame87(377, config); } } }
/* * Method that will start the game when there's enough players. */ public static void startGame() { if (getSaraPlayers() < 1 || getZammyPlayers() < 1) { gameStartTimer = GAME_START_TIMER; return; } gameStartTimer = -1; System.out.println("Starting Castle Wars game."); gameStarted = true; timeRemaining = GAME_TIMER / 2; Iterator iterator = waitingRoom.keySet().iterator(); while (iterator.hasNext()) { Client player = (Client) iterator.next(); int team = waitingRoom.get(player); if (player == null) { continue; } player.getPA().walkableInterface(-1); player.getPA().movePlayer(GAME_ROOM[team - 1][0] + Misc.random(3), GAME_ROOM[team - 1][1] - Misc.random(3), 1); player.getPA().movePlayer(GAME_ROOM[team - 1][0] + Misc.random(3), GAME_ROOM[team - 1][1] - Misc.random(3), 1); gameRoom.put(player, team); } waitingRoom.clear(); }
/* * Method we use to end an ongoing cw game. */ public static void endGame() { Iterator iterator = gameRoom.keySet().iterator(); while (iterator.hasNext()) { Client player = (Client) iterator.next(); int team = gameRoom.get(player); if (player == null) { continue; } player.cwGames++; player.getPA().movePlayer(2440 + Misc.random(3), 3089 - Misc.random(3), 0); player.sendMessage("[@red@CASTLE WARS@bla@] The Castle Wars Game has ended!"); player.sendMessage("[@red@CASTLE WARS@bla@] Kills: @red@ " + player.cwKills + " @bla@Deaths:@red@ " + player.cwDeaths + "@bla@ Games Played: @red@" + player.cwGames + "@bla@."); player.getPA().createPlayerHints(10, -1); deleteGameItems(player); if (scores[0] == scores[1]) { player.getItems().addItem(4067, 30); player.sendMessage("Tie game! You gain 30 CastleWars tickets!"); } else if (team == 1) { if (scores[0] > scores[1]) { player.getItems().addItem(4067, 50); player.sendMessage("You won the CastleWars Game. You received 50 CastleWars Tickets!"); } else if (scores[0] < scores[1]) { player.getItems().addItem(4067, 20); player.sendMessage("You lost the CastleWars Game. You received 20 CastleWars Tickets!"); } } else if (team == 2) { if (scores[1] > scores[0]) { player.getItems().addItem(4067, 50); player.sendMessage("You won the CastleWars Game. You received 50 CastleWars Tickets!"); } else if (scores[1] < scores[0]) { player.getItems().addItem(4067, 20); player.sendMessage("You lost the CastleWars Game. You received 20 CastleWars Tickets!"); } } } resetGame(); }
/** * reset the game variables */ public static void resetGame() { changeFlagObject(4902, 0); changeFlagObject(4903, 1); setSaraFlag(0); setZammyFlag(0); timeRemaining = -1; System.out.println("Ending Castle Wars game."); gameStartTimer = GAME_START_TIMER; gameStarted = false; gameRoom.clear(); }
/** * Method we use to remove a player from the game * @param player the player we want to be removed */ public static void removePlayerFromCw(Client player) { if (player == null) { System.out.println("Error removing player from castle wars [REASON = null]"); return; } if (gameRoom.containsKey(player)) { /* * Logging/leaving with flag */ if (player.getItems().playerHasEquipped(SARA_BANNER)) { player.getItems().removeItem(player.playerEquipment[3], 3); setSaraFlag(0); //safe flag } else if (player.getItems().playerHasEquipped(ZAMMY_BANNER)) { player.getItems().removeItem(player.playerEquipment[3], 3); setZammyFlag(0); //safe flag } deleteGameItems(player); player.getPA().movePlayer(2440, 3089, 0); System.out.println("Deleting playername test: " + player.playerName); player.sendMessage("[@red@CASTLE WARS@bla@] The Casle Wars Game has ended for you!"); player.sendMessage("[@red@CASTLE WARS@bla@] Kills: @red@ " + player.cwKills + " @bla@Deaths:@red@ " + player.cwDeaths + "@bla@."); player.getPA().createPlayerHints(10, -1); gameRoom.remove(player); } if (getZammyPlayers() <= 0 || getSaraPlayers() <= 0) { endGame(); } }
/** * Will add a cape to a player's equip * @param player the player * @param capeId the capeId */ public static void addCapes(Client player, int capeId) { player.playerEquipment[Client.playerCape] = capeId; player.playerEquipmentN[Client.playerCape] = 1; player.getItems().updateSlot(Client.playerCape); player.appearanceUpdateRequired = true; player.updateRequired = true; }
/** * This method will delete all items received in game. Easy to add items to the array. (: * @param player the player who want the game items deleted from. */ public static void deleteGameItems(Client player) { switch (player.playerEquipment[3]) { case 4037: case 4039: player.getItems().removeItem(player.playerEquipment[3], 3); System.out.println("removed weapon:" + player.playerEquipment[3]); break; } switch (player.playerEquipment[1]) { case 4042: case 4041: player.getItems().removeItem(player.playerEquipment[1], 1); System.out.println("removed cape:" + player.playerEquipment[1]); break; } int[] items = {4049, 1265, 4045, 4053, 4042, 4041, 4037, 4039}; for (int i = 0; i < items.length; i++) { if (player.getItems().playerHasItem(items[i])) { player.getItems().deleteItem2(items[i], player.getItems().getItemAmount(items[i])); } } }
/** * Methode we use to get the zamorak players * @return the amount of players in the zamorakian team! */ public static int getZammyPlayers() { int players = 0; Iterator iterator = (!waitingRoom.isEmpty()) ? waitingRoom.values().iterator() : gameRoom.values().iterator(); while (iterator.hasNext()) { if ((Integer) iterator.next() == 2) { players++; } } return players; }
/** * Method we use to get the saradomin players! * @return the amount of players in the saradomin team! */ public static int getSaraPlayers() { int players = 0; Iterator iterator = (!waitingRoom.isEmpty()) ? waitingRoom.values().iterator() : gameRoom.values().iterator(); while (iterator.hasNext()) { if ((Integer) iterator.next() == 1) { players++; } } return players; }
/** * Method we use for checking if the player is in the gameRoom * @param player player who will be checking * @return */ public static boolean isInCw(Client player) { return gameRoom.containsKey(player); }
/** * Method we use for checking if the player is in the waitingRoom * @param player player who will be checking * @return */ public static boolean isInCwWait(Client player) { return waitingRoom.containsKey(player); }
/** * Method to make sara flag change status 0 = safe, 1 = taken, 2 = dropped * @param status */ public static void setSaraFlag(int status) { saraFlag = status; }
/** * Method to make zammy flag change status 0 = safe, 1 = taken, 2 = dropped * @param status */ public static void setZammyFlag(int status) { zammyFlag = status; }
/** * Method we use for the changing the object of the flag stands when capturing/returning flag * @param objectId the object * @param team the team of the player */ public static void changeFlagObject(int objectId, int team) { Iterator iterator = gameRoom.keySet().iterator(); while (iterator.hasNext()) { Client teamPlayer = (Client) iterator.next(); teamPlayer.getPA().object(objectId, FLAG_STANDS[team][0], FLAG_STANDS[team][1], 0, 10); } } } OK now castlewarsObject.java replace your whole class with this
Code: package server.model.minigames;
import server.model.players.Client;
public class CastleWarObjects {
public static void handleObject(Client c, int id, int x, int y) { if (!CastleWars.isInCw(c)) { c.sendMessage("You gotta be in castle wars before you can use these objects"); return; } switch (id) { case 4469: if (CastleWars.getTeamNumber(c) == 2) { c.sendMessage("You are not allowed in the other teams spawn point."); break; } if (x == 2426) { if (c.getY() == 3080) { c.getPA().movePlayer(2426, 3081, c.heightLevel); } else if (c.getY() == 3081) { c.getPA().movePlayer(2426, 3080, c.heightLevel); } } else if (x == 2422) { if (c.getX() == 2422) { c.getPA().movePlayer(2423, 3076, c.heightLevel); } else if (c.getX() == 2423) { c.getPA().movePlayer(2422, 3076, c.heightLevel); } } break; case 4470: if (CastleWars.getTeamNumber(c) == 1) { c.sendMessage("You are not allowed in the other teams spawn point."); break; } if (x == 2373 && y == 3126) { if (c.getY() == 3126) { c.getPA().movePlayer(2373, 3127, 1); } else if (c.getY() == 3127) { c.getPA().movePlayer(2373, 3126, 1); } } else if (x == 2377 && y == 3131) { if (c.getX() == 2376) { c.getPA().movePlayer(2377, 3131, 1); } else if (c.getX() == 2377) { c.getPA().movePlayer(2376, 3131, 1); } } break; case 4417: if (x == 2428 && y == 3081 && c.heightLevel == 1) { c.getPA().movePlayer(2430, 3080, 2); } if (x == 2425 && y == 3074 && c.heightLevel == 2) { c.getPA().movePlayer(2426, 3074, 3); } if (x == 2419 && y == 3078 && c.heightLevel == 0) { c.getPA().movePlayer(2420, 3080, 1); } break; case 4415: if (x == 2419 && y == 3080 && c.heightLevel == 1) { c.getPA().movePlayer(2419, 3077, 0); } if (x == 2430 && y == 3081 && c.heightLevel == 2) { c.getPA().movePlayer(2427, 3081, 1); } if (x == 2425 && y == 3074 && c.heightLevel == 3) { c.getPA().movePlayer(2425, 3077, 2); } if (x == 2374 && y == 3133 && c.heightLevel == 3) { c.getPA().movePlayer(2374, 3130, 2); } if (x == 2369 && y == 3126 && c.heightLevel == 2) { c.getPA().movePlayer(2372, 3126, 1); } if (x == 2380 && y == 3127 && c.heightLevel == 1) { c.getPA().movePlayer(2380, 3130, 0); } break; case 4411: if (x == 2421 && y == 3073 && c.heightLevel == 1) { c.getPA().movePlayer(c.getX(), c.getY(), 0); } break; case 4419: if (x == 2417 && y == 3074 && c.heightLevel == 0) { c.getPA().movePlayer(2416, 3074, 0); } if (x == 2417 && y == 3074 && c.heightLevel == 1) { c.getPA().movePlayer(2417, 3073, 0); } break; case 4911: if (x == 2421 && y == 3073 && c.heightLevel == 1) { c.getPA().movePlayer(2421, 3074, 0); } if (x == 2378 && y == 3134 && c.heightLevel == 1) { c.getPA().movePlayer(2378, 3133, 0); } break; case 1747: if (x == 2421 && y == 3073 && c.heightLevel == 0) { c.getPA().movePlayer(2421, 3074, 1); } if (x == 2378 && y == 3134 && c.heightLevel == 0) { c.getPA().movePlayer(2378, 3133, 1); } break; case 4912: if (x == 2430 && y == 3082 && c.heightLevel == 0) { c.getPA().movePlayer(c.getX(), c.getY() + 6400, 0); } if (x == 2369 && y == 3125 && c.heightLevel == 0) { c.getPA().movePlayer(c.getX(), c.getY() + 6400, 0); } break; case 1757: if (x == 2430 && y == 9482) { c.getPA().movePlayer(2430, 3081, 0); } else { c.getPA().movePlayer(2369, 3126, 0); } break;
case 4418: if (x == 2380 && y == 3127 && c.heightLevel == 0) { c.getPA().movePlayer(2379, 3127, 1); } if (x == 2369 && y == 3126 && c.heightLevel == 1) { c.getPA().movePlayer(2369, 3127, 2); } if (x == 2374 && y == 3131 && c.heightLevel == 2) { c.getPA().movePlayer(2373, 3133, 3); } break; case 4420: if (x == 2382 && y == 3131 && c.heightLevel == 0) { if (c.getX() >= 2383 && c.getX() <= 2385) { c.getPA().movePlayer(2382, 3130, 0); } else { c.getPA().movePlayer(2383, 3133, 0); } } break; case 4437: if (x == 2400 && y == 9512) { c.getPA().movePlayer(2400, 9514, 0); } else if (x == 2391 && y == 9501) { c.getPA().movePlayer(2393, 9502, 0); } else if (x == 2409 && y == 9503) { c.getPA().movePlayer(2411, 9503, 0); } else if (x == 2401 && y == 9494) { c.getPA().movePlayer(2401, 9493, 0); } break; case 1568: if (x == 2399 && y == 3099) { c.getPA().movePlayer(2399, 9500, 0); } else { c.getPA().movePlayer(2400, 9507, 0); } case 6281: c.getPA().movePlayer(2370, 3132, 2); break; case 4472: c.getPA().movePlayer(2370, 3132, 1); break; case 6280: c.getPA().movePlayer(2429, 3075, 2); break; case 4471: c.getPA().movePlayer(2429, 3075, 1); break; case 4406: CastleWars.removePlayerFromCw(c); break; case 4407: CastleWars.removePlayerFromCw(c); break; case 4458: c.startAnimation(881); c.getItems().addItem(4049, 1); c.sendMessage("You get some bandages"); break; case 4902: //sara flag case 4377: switch (CastleWars.getTeamNumber(c)) { case 1: CastleWars.returnFlag(c, c.playerEquipment[c.playerWeapon]); break; case 2: CastleWars.captureFlag(c); break; } break; case 4903: //zammy flag case 4378: switch (CastleWars.getTeamNumber(c)) { case 1: CastleWars.captureFlag(c); break; case 2: CastleWars.returnFlag(c, c.playerEquipment[c.playerWeapon]); break; } break; case 4461: //barricades c.sendMessage("You get a barricade!"); c.getItems().addItem(4053, 1); break; case 4463: // explosive potion! c.sendMessage("You get an explosive potion!"); c.getItems().addItem(4045, 1); break; case 4464: //pickaxe table c.sendMessage("You get a bronzen pickaxe for mining."); c.getItems().addItem(1265, 1); break; case 4900: case 4901: CastleWars.pickupFlag(c); default: break;
} } } Client.java
in the destruct method add
Code: if (CastleWars.isInCwWait(this)) { CastleWars.leaveWaitingRoom(this); } if (CastleWars.isInCw(this)) { CastleWars.removePlayerFromCw(this); } Import:
Code: import server.model.minigames.CastleWars; CombatAssistant.java the checkReqs() method
Code: if (CastleWars.isInCw(c)) { return true; } Import:
Code: import server.model.minigames.CastleWars; player.java add this ints
Code: cwKills, cwDeaths, cwGames, PlayerAssistant.java
under the applyDeath add
Code: int weapon = c.playerEquipment[c.playerWeapon]; and then you add this where the player dies and you give pkp or w.e
Code: if (weapon == CastleWars.SARA_BANNER || weapon == CastleWars.ZAMMY_BANNER) { c.getItems().removeItem(weapon, 3); c.getItems().deleteItem2(weapon, 1); CastleWars.dropFlag(c, weapon); } under
Code: if (c.duelStatus <= 4) { add
Code: if (CastleWars.isInCw(c)) { c.cwDeaths += 1; o.cwKills += 1; } to make it not lose items in castlewars in giveLife() you should modify a line so it looks something like this
Code: if (!CastleWars.isInCw(c) && !c.inPits && !c.inFightCaves() && !c.isInFunPk() && !c.isInPk()) { under
Code: else if (c.pitsStatus == 1) { movePlayer(2399, 5173, 0); }
Code: else if (CastleWars.isInCw(c)) { if (CastleWars.getTeamNumber(c) == 1) { c.getPA().movePlayer(2426 + Misc.random(3), 3076 - Misc.random(3), 1); } else { c.getPA().movePlayer(2373 + Misc.random(3), 3131 - Misc.random(3), 1); } } in the teleport methods add this
Code: if (CastleWars.isInCw(c)) { c.sendMessage("You cannot tele from a Castle Wars Game!"); return; } methods like startTeleport startMovement etc...
PlayerSave.java
loadgame method
Code: else if (token.equals("cw-games")) { p.cwGames = Integer.parseInt(token2); } playerSave
Code: characterfile.write("cw-games = ", 0, 11); characterfile.write(Integer.toString(p.cwGames), 0, Integer.toString(p.cwGames).length()); characterfile.newLine(); ClickObject.java
Code: /* * CastleWars */ case 4387: CastleWars.addToWaitRoom(c, 1); //saradomin break; case 4388: CastleWars.addToWaitRoom(c, 2); // zamorak break; case 4408: CastleWars.addToWaitRoom(c, 3); //guthix break; case 4389: //sara case 4390: //zammy waiting room portal CastleWars.leaveWaitingRoom(c); break; ActionHandler.java
Code: case 4411: case 4415: case 4417: case 4418: case 4419: case 4420: case 4469: case 4470: case 4911: case 4912: case 1747: case 1757: case 4437: case 6281: case 6280: case 4472: case 4471: case 4406: case 4407: case 4458: case 4902: case 4903: case 4900: case 4901: case 4461: case 4463: case 4464: case 4377: case 4378: CastleWarObjects.handleObject(c, objectType, obX, obY); case 1568: if (obX == 3097 && obY == 3468) { c.getPA().movePlayer(3097, 9868, 0); } else { CastleWarObjects.handleObject(c, obY, obY, obY); } break; import:
Code: import server.model.minigames.CastleWarObjects; ItemAssistant.java
in the wearItem(int wearID, int slot) method
add this in it
Code: /* * Castle wars */ if (CastleWars.isInCw(c) || CastleWars.isInCwWait(c)) { if (targetSlot == 1 || targetSlot == 0) { c.sendMessage("You can't wear your own capes or hats in a Castle Wars Game!"); return false; } } under
Code: if (slot >= 0 && wearID >= 0) { int toEquip = c.playerItems[slot]; int toEquipN = c.playerItemsN[slot]; int toRemove = c.playerEquipment[targetSlot]; int toRemoveN = c.playerEquipmentN[targetSlot]; add
Code: /* * Castle wars */ if (CastleWars.SARA_BANNER == toRemove || CastleWars.ZAMMY_BANNER == toRemove) { CastleWars.dropFlag(c, toRemove); } RemoveItem
above
Code: if (addItem(c.playerEquipment[slot], c.playerEquipmentN[slot])) { add
Code: if ((c.playerEquipment[slot] == CastleWars.SARA_CAPE || c.playerEquipment[slot] == CastleWars.ZAMMY_CAPE) && (CastleWars.isInCw(c) || CastleWars.isInCwWait(c))) { c.sendMessage("You cannot unequip your castle wars cape during a game!"); return; } under the
Code: if (addItem(c.playerEquipment[slot], c.playerEquipmentN[slot])) { add this
Code: if (c.playerEquipment[slot] == CastleWars.SARA_BANNER || c.playerEquipment[slot] == CastleWars.ZAMMY_BANNER) { CastleWars.dropFlag(c, c.playerEquipment[slot]); c.getItems().deleteItem2(c.playerEquipment[slot], 1); } add this method
Code: public boolean playerHasEquipped(int itemID) { itemID++; for (int i = 0; i < c.playerEquipment.length; i++) { if (c.playerEquipment[i] == itemID) { return true; } } return false; } Fixing flickering interfaces: in CLIENT.java process()
Code: else if (CastleWars.isInCw(this)) { getPA().showOption(3, 0, "Attack", 1); } else if (!CastleWars.isInCwWait(this)) { getPA().sendFrame99(0); getPA().walkableInterface(-1); getPA().showOption(3, 0, "Null", 1); }
Last edited by Isaac on Sun Apr 14, 2013 4:04 pm; edited 1 time in total (Reason for editing : Is it so hard to use code tags?) | |
|