Jump to content
  • 0
Sign in to follow this  
drakthuro

718 Castlewars, Should work but doesn't as intented.

Question

Hi there, Now i got something complicated. My castlewars.

I got all the controlers, They should work but they don't.

When the castlewars game starts. Then the first thing wich is not possible that's setting up the barricades.
With every barricade set down, you get an instant message of

---- you cannot set up your barricade here!-----

the second thing that does not work is. Capturing more then two flags.
Once one team captured 2 flag's, take as example saradomin scores the zamorak flag twice.
Then the third flag won't show up. This is the same for the other team. If saradomin Captures two flags, then it won't show up.

I'm really out of idea's, i have no idea why it does not work. Everything is imported, I got a barricade controler, I got the castlewars,Castlewarsplaying,Castlewars waiting. The tickets work if its a tie. Etc. Here are the files.

All help is appreciated... Thanks.



Castlewars :
[CODE]package com.rs.game.minigames;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.TimerTask;

import com.rs.cores.CoresManager;
import com.rs.game.World;
import com.rs.game.WorldObject;
import com.rs.game.WorldTile;
import com.rs.game.item.Item;
import com.rs.game.npc.others.CastleWarBarricade;
import com.rs.game.player.Equipment;
import com.rs.game.player.Player;
import com.rs.game.player.content.Foods.Food;
import com.rs.game.player.controlers.castlewars.CastleWarsPlaying;
import com.rs.game.player.dialogues.CastleWarsScoreboard;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;

public final class CastleWars {
public static final int CW_TICKET = 4067;
public static final int SARADOMIN = 0;
public static final int ZAMORAK = 1;
private static final int GUTHIX = 2;
[MENTION=19271]supp[/MENTION]ressWarnings("unchecked")
private static final List<Player>[] waiting = new List[2];
[MENTION=19271]supp[/MENTION]ressWarnings("unchecked")
private static final List<Player>[] playing = new List[2];
private static int[] seasonWins = new int[2];
public static final WorldTile LOBBY = new WorldTile(3603, 3365, 0),
SARA_WAITING = new WorldTile(2381, 9489, 0),
ZAMO_WAITING = new WorldTile(2421, 9523, 0),
SARA_BASE = new WorldTile(2426, 3076, 1),
ZAMO_BASE = new WorldTile(2373, 3131, 1);

private static PlayingGame playingGame;

static {
init();
}

public static void init() {
for (int i = 0; i < waiting.length; i++)
waiting[i] = Collections.synchronizedList(new LinkedList<Player>());
for (int i = 0; i < playing.length; i++)
playing[i] = Collections.synchronizedList(new LinkedList<Player>());
}

public static void viewScoreBoard(Player player) {
player.getInterfaceManager().sendChatBoxInterface(55);
player.getPackets().sendIComponentText(55, 1,
"Saradomin: " + seasonWins[SARADOMIN]);
player.getPackets().sendIComponentText(55, 2,
"Zamorak: " + seasonWins[ZAMORAK]);
}

public static int getPowerfullestTeam() {
int zamorak = waiting[ZAMORAK].size() + playing[ZAMORAK].size();
int saradomin = waiting[SARADOMIN].size() + playing[SARADOMIN].size();
if (saradomin == zamorak)
return GUTHIX;
if (zamorak > saradomin)
return ZAMORAK;
return SARADOMIN;
}

public static void joinPortal(Player player, int team) {
if (player.getEquipment().getHatId() != -1
|| player.getEquipment().getCapeId() != -1) {
player.getPackets().sendGameMessage(
"You cannot wear hats, capes or helms in the arena.");
return;
}
for (Item item : player.getInventory().getItems().getItems()) {
if (item == null)
continue;
if (Food.forId(item.getId()) != null) {
player.getPackets().sendGameMessage("You cannot bring food into the arena.");
return;
}
}
int powerfullestTeam = getPowerfullestTeam();
if (team == GUTHIX) {
team = powerfullestTeam == ZAMORAK ? SARADOMIN : ZAMORAK;
} else if (team == powerfullestTeam) {
if (team == ZAMORAK)
player.getPackets()
.sendGameMessage(
"The Zamorak team is powerful enough already! Guthix demands balance - join the Saradomin team instead!");
else if (team == SARADOMIN)
player.getPackets()
.sendGameMessage(
"The Saradomin team is powerful enough already! Guthix demands balance - join the Zamorak team instead!");
return;
}
player.lock(2);
waiting[team].add(player);
setCape(player, new Item(team == ZAMORAK ? 4042 : 4041));
setHood(player, new Item(team == ZAMORAK ? 4515 : 4513));
player.getControlerManager().startControler("CastleWarsWaiting", team);
player.setNextWorldTile(new WorldTile(team == ZAMORAK ? ZAMO_WAITING
: SARA_WAITING, 1));
player.getMusicsManager().playMusic(318); // temp testing else 5
if (playingGame == null && waiting[team].size() >= 1) // at least
// 9players to
// start
createPlayingGame();
else
refreshTimeLeft(player);
// You cannot take non-combat items into the arena
}

public static void setHood(Player player, Item hood) {
player.getEquipment().getItems().set(Equipment.SLOT_HAT, hood);
player.getEquipment().refresh(Equipment.SLOT_HAT);
player.getAppearence().generateAppearenceData();
}

public static void setCape(Player player, Item cape) {
player.getEquipment().getItems().set(Equipment.SLOT_CAPE, cape);
player.getEquipment().refresh(Equipment.SLOT_CAPE);
player.getAppearence().generateAppearenceData();
}

public static void setWeapon(Player player, Item weapon) {
player.getEquipment().getItems().set(Equipment.SLOT_WEAPON, weapon);
player.getEquipment().refresh(Equipment.SLOT_WEAPON);
player.getAppearence().generateAppearenceData();
}

public static void createPlayingGame() {
playingGame = new PlayingGame();
CoresManager.fastExecutor
.scheduleAtFixedRate(playingGame, 60000, 60000);
refreshAllPlayersTime();
}

public static void destroyPlayingGame() {
playingGame.cancel();
playingGame = null;
refreshAllPlayersTime();
leavePlayersSafely();
}

public static void leavePlayersSafely() {
leavePlayersSafely(-1);
}

public static void leavePlayersSafely(final int winner) {
for (int i = 0; i < playing.length; i++) {
for (final Player player : playing[i]) {
player.lock(7);
player.stopAll();
}
}
WorldTasksManager.schedule(new WorldTask() {
[MENTION=15855]Over[/MENTION]ride
public void run() {
for (int i = 0; i < playing.length; i++)
for (Player player : playing[i]
.toArray(new Player[playing[i].size()])) {
forceRemovePlayingPlayer(player);
if (winner != -1) {
if (winner == -2) {
player.getPackets()
.sendGameMessage("You draw.");
player.getInventory().addItem(CW_TICKET, 1);
} else if (winner == i) {
player.getPackets().sendGameMessage("You won.");
player.getInventory().addItem(CW_TICKET, 2);
} else
player.getPackets()
.sendGameMessage("You lost.");
}
}
}
}, 6);
}

// unused
public static void forceRemoveWaitingPlayer(Player player) {
player.getControlerManager().forceStop();
}

public static void removeWaitingPlayer(Player player, int team) {
waiting[team].remove(player);
setCape(player, null);
setHood(player, null);
player.setNextWorldTile(new WorldTile(LOBBY, 2));
if (playingGame != null && waiting[team].size() == 0
&& playing[team].size() == 0)
destroyPlayingGame(); // cancels if 0 players playing/waiting on any
// of the tea
}

public static void refreshTimeLeft(Player player) {
player.getPackets()
.sendConfig(
380,
playingGame == null ? 0
: playingGame.minutesLeft
- (player.getControlerManager()
.getControler() instanceof CastleWarsPlaying ? 5
: 0));
}

public static void startGame() {
for (int i = 0; i < waiting.length; i++) {
for (Player player : waiting[i].toArray(new Player[waiting[i]
.size()])) {
joinPlayingGame(player, i);
}
}
}

public static void forceRemovePlayingPlayer(Player player) {
player.getControlerManager().forceStop();
}

public static void removePlayingPlayer(Player player, int team) {
playing[team].remove(player);
player.reset();
player.setCanPvp(false);
// remove the items
setCape(player, null);
setHood(player, null);
int weaponId = player.getEquipment().getWeaponId();
if (weaponId == 4037 || weaponId == 4039) {
CastleWars.setWeapon(player, null);
CastleWars.dropFlag(player.getLastWorldTile(),
weaponId == 4037 ? CastleWars.SARADOMIN
: CastleWars.ZAMORAK);
}
player.closeInterfaces();
player.getInventory().deleteItem(4049, Integer.MAX_VALUE); // bandages
player.getInventory().deleteItem(4053, Integer.MAX_VALUE); // barricades

player.getHintIconsManager().removeUnsavedHintIcon();
player.getMusicsManager().reset();
player.setNextWorldTile(new WorldTile(LOBBY, 2));
if (playingGame != null && waiting[team].size() == 0
&& playing[team].size() == 0)
destroyPlayingGame(); // cancels if 0 players playing/waiting on any
// of the tea
}

public static void joinPlayingGame(Player player, int team) {
playingGame.refresh(player);
waiting[team].remove(player);
player.getControlerManager().removeControlerWithoutCheck();
player.getPackets().closeInterface(player.getInterfaceManager().hasRezizableScreen() ? 34 : 0);
playing[team].add(player);
player.setCanPvp(true);
player.getControlerManager().startControler("CastleWarsPlaying", team);
player.setNextWorldTile(new WorldTile(team == ZAMORAK ? ZAMO_BASE
: SARA_BASE, 1));
}

public static void endGame(int winner) {
if (winner != -2)
seasonWins[winner]++;
leavePlayersSafely(winner);
}

public static void refreshAllPlayersTime() {
for (int i = 0; i < waiting.length; i++)
for (Player player : waiting[i])
refreshTimeLeft(player);
for (int i = 0; i < playing.length; i++)
for (Player player : playing[i]) {
player.getMusicsManager().playMusic(i == ZAMORAK ? 845 : 314);
refreshTimeLeft(player);
}
}

public static void refreshAllPlayersPlaying() {
for (int i = 0; i < playing.length; i++)
for (Player player : playing[i])
playingGame.refresh(player);
}

public static void addHintIcon(int team, Player target) {
for (Player player : playing[team]) {
player.getHintIconsManager().addHintIcon(target, 0, -1, false);
}
}

public static void removeHintIcon(int team) {
for (Player player : playing[team]) {
player.getHintIconsManager().removeUnsavedHintIcon();
}
}

public static void addScore(Player player, int team, int flagTeam) {
if (playingGame == null)
return;
playingGame.addScore(player, team, flagTeam);
}

public static void takeFlag(Player player, int team, int flagTeam,
WorldObject object, boolean droped) {
if (playingGame == null)
return;
playingGame.takeFlag(player, team, flagTeam, object, droped);
}

public static void dropFlag(WorldTile tile, int flagTeam) {
if (playingGame == null)
return;
playingGame.dropFlag(tile, flagTeam);
}

public static void removeBarricade(int team, CastleWarBarricade npc) {
if (playingGame == null)
return;
playingGame.removeBarricade(team, npc);
}

public static void addBarricade(int team, Player player) {
if (playingGame == null)
return;
playingGame.addBarricade(team, player);
}

public static boolean isBarricadeAt(WorldTile tile) {
if (playingGame == null)
return false;
return playingGame.isBarricadeAt(tile);
}

private static class PlayingGame extends TimerTask {

private static final int SAFE = 0, TAKEN = 1, DROPPED = 2;
private int minutesLeft;
private int[] score;
private int[] flagStatus;
private int[] barricadesCount;
private final LinkedList<WorldObject> spawnedObjects = new LinkedList<WorldObject>();
private final LinkedList<CastleWarBarricade> barricades = new LinkedList<CastleWarBarricade>();

public PlayingGame() {
reset();
}

public void reset() {
minutesLeft = 1; // temp testing else 5
score = new int[2];
flagStatus = new int[2];
barricadesCount = new int[2];
for (WorldObject object : spawnedObjects)
World.destroySpawnedObject(object, object.getId() == 4377
|| object.getId() == 4378 ? false : true);
spawnedObjects.clear();
for (CastleWarBarricade npc : barricades)
npc.finish();
barricades.clear();
}

public boolean isBarricadeAt(WorldTile tile) {
for (Iterator<CastleWarBarricade> it = barricades.iterator(); it
.hasNext();) {
CastleWarBarricade npc = it.next();
if (npc.isDead() || npc.hasFinished()) {
it.remove();
continue;
}
if (npc.getX() == tile.getX() && npc.getY() == tile.getY()
&& tile.getPlane() == tile.getPlane())
return true;
}
return false;
}

public void addBarricade(int team, Player player) {
if (barricadesCount[team] >= 10) {
player.getPackets()
.sendGameMessage(
"Each team in the activity can have a maximum of 10 barricades set up.");
return;
}
player.getInventory().deleteItem(new Item(4053, 1));
barricadesCount[team]++;
barricades.add(new CastleWarBarricade(team, new WorldTile(player)));
}

public void removeBarricade(int team, CastleWarBarricade npc) {
barricadesCount[team]--;
barricades.remove(npc);
}

public void takeFlag(Player player, int team, int flagTeam,
WorldObject object, boolean droped) {
if (!droped && team == flagTeam)
return;
if (droped && flagStatus[flagTeam] != DROPPED)
return;
else if (!droped && flagStatus[flagTeam] != SAFE)
return;

if (flagTeam != team
&& (player.getEquipment().getWeaponId() != -1 || player
.getEquipment().getShieldId() != -1)) {
// TODO no space message
player.getPackets()
.sendGameMessage(
"You can't take flag while wearing something in your hands.");
return;
}
if (!droped) {
WorldObject flagStand = new WorldObject(
flagTeam == SARADOMIN ? 4377 : 4378, object.getType(),
object.getRotation(), object.getX(), object.getY(),
object.getPlane());
spawnedObjects.add(flagStand);
World.spawnObject(flagStand, false);
} else {
spawnedObjects.remove(object);
World.destroySpawnedObject(object, true);
if (flagTeam == team) {
makeSafe(flagTeam);
return;
}
}
addHintIcon(flagTeam, player);
flagStatus[flagTeam] = TAKEN;
setWeapon(player, new Item(flagTeam == SARADOMIN ? 4037 : 4039, 1));
refreshAllPlayersPlaying();
}

public void addScore(Player player, int team, int flagTeam) {
setWeapon(player, null);
score[team] += 1;
makeSafe(flagTeam);
}

private void makeSafe(int flagTeam) {
WorldObject flagStand = null;
for (WorldObject object : spawnedObjects) {
if (object.getId() == (flagTeam == SARADOMIN ? 4377 : 4378)) {
flagStand = object;
break;
}
}
if (flagStand == null)
return;
World.destroySpawnedObject(flagStand, false);
flagStatus[flagTeam] = SAFE;
refreshAllPlayersPlaying();
}

public void dropFlag(WorldTile tile, int flagTeam) {
removeHintIcon(flagTeam);
WorldObject flagDroped = new WorldObject(
flagTeam == SARADOMIN ? 4900 : 4901, 10, 0, tile.getX(),
tile.getY(), tile.getPlane());
spawnedObjects.add(flagDroped);
World.spawnObject(flagDroped, true);
flagStatus[flagTeam] = DROPPED;
refreshAllPlayersPlaying();
}

public void refresh(Player player) {
player.getPackets().sendConfigByFile(143, flagStatus[SARADOMIN]);
player.getPackets().sendConfigByFile(145, score[SARADOMIN]);
player.getPackets().sendConfigByFile(153, flagStatus[ZAMORAK]);
player.getPackets().sendConfigByFile(155, score[ZAMORAK]);
}

[MENTION=15855]Over[/MENTION]ride
public void run() {
minutesLeft--;
if (minutesLeft == 5) {
endGame(score[SARADOMIN] == score[ZAMORAK] ? -2
: score[SARADOMIN] > score[ZAMORAK] ? SARADOMIN
: ZAMORAK);
reset();
} else if (minutesLeft == 0) {
minutesLeft = 25;
startGame();
} else if (minutesLeft > 6) // adds ppl waiting on lobby
startGame();
refreshAllPlayersTime();
}
}

public static void handleInterfaces(Player player, int interfaceId,
int componentId) {
if (interfaceId == 55) {
if (componentId == 9)
player.closeInterfaces();
}
}

public static boolean handleObjects(Player player, int objectId) {
if (objectId == 4484) { // scoreboard
player.getDialogueManager().startDialogue(
new CastleWarsScoreboard());
return true;
}
if (objectId == 4388) {
joinPortal(player, ZAMORAK);
return true;
}
if (objectId == 4408) {
joinPortal(player, GUTHIX);
return true;
}
//if (objectId == 4387) {
if (objectId == 2465) {
joinPortal(player, SARADOMIN);
return true;
}
return false;
}

public static List<Player>[] getPlaying() {
return playing;
}
}
[/CODE]



Castlewars playing
[CODE]package com.rs.game.player.controlers.castlewars;

import java.util.List;

import com.rs.game.Animation;
import com.rs.game.Entity;
import com.rs.game.Hit;
import com.rs.game.Hit.HitLook;
import com.rs.game.World;
import com.rs.game.WorldObject;
import com.rs.game.WorldTile;
import com.rs.game.item.Item;
import com.rs.game.minigames.CastleWars;
import com.rs.game.npc.NPC;
import com.rs.game.npc.others.CastleWarBarricade;
import com.rs.game.player.Equipment;
import com.rs.game.player.Inventory;
import com.rs.game.player.Player;
import com.rs.game.player.controlers.Controler;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.utils.Utils;

public class CastleWarsPlaying extends Controler {

private int team;

[MENTION=15855]Over[/MENTION]ride
public void start() {
team = (int) getArguments()[0];
sendInterfaces();
}

[MENTION=15855]Over[/MENTION]ride
public boolean canMove(int dir) {
WorldTile toTile = new WorldTile(player.getX()
+ Utils.DIRECTION_DELTA_X[dir], player.getY()
+ Utils.DIRECTION_DELTA_Y[dir], player.getPlane());
return !CastleWars.isBarricadeAt(toTile);
}

[MENTION=15855]Over[/MENTION]ride
public boolean processNPCClick2(NPC n) {
if (n.getId() == 1532 && n instanceof CastleWarBarricade) {
if (!player.getInventory().containsItem(590, 1)) {
player.getPackets().sendGameMessage(
"You do not have the required items to light this.");
return false;
}
CastleWarBarricade barricade = (CastleWarBarricade) n;
barricade.litFire();
return false;
}
return true;
}

/*
* return process normaly
*/
[MENTION=15855]Over[/MENTION]ride
public boolean processButtonClick(int interfaceId, int componentId,
int slotId, int packetId) {
if (interfaceId == 387) {
if (componentId == 9 || componentId == 6) {
player.getPackets().sendGameMessage(
"You can't remove your team's colours.");
return false;
}
if (componentId == 15) {
int weaponId = player.getEquipment().getWeaponId();
if (weaponId == 4037 || weaponId == 4039) {
player.getPackets().sendGameMessage(
"You can't remove enemy's flag.");
return false;
}
}
} else if (interfaceId == Inventory.INVENTORY_INTERFACE) {
Item item = player.getInventory().getItem(slotId);
if (item != null) {
if (item.getId() == 4053) {
if (player.getX() == 2422 && player.getY() == 3076 || player.getX() == 2426 && player.getY() == 3080 || player.getX() == 2423 && player.getY() == 3076 || player.getX() == 2426 && player.getY() == 3081 || player.getX() == 2373 && player.getY() == 3127 || player.getX() == 2373 && player.getY() == 3126 || player.getX() == 2376 && player.getY() == 3131 || player.getX() == 2377 && player.getY() == 3131 || !CastleWars.isBarricadeAt(player)) {
player.getPackets().sendGameMessage("You cannot place a barracade here!");
return false;
}
CastleWars.addBarricade(team, player);
return false;
} else if (item.getId() == 4049 || item.getId() == 4050
|| item.getId() == 12853 || item.getId() == 14640
|| item.getId() == 14648) {
doBandageEffect(item);
return false;
}
}
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean canDropItem(Item item) {
if (item.getDefinitions().getName().toLowerCase().contains("flag")) {
player.getPackets().sendGameMessage("You cannot just drop the flag!");
return false;
}
return true;
}

private void doBandageEffect(Item item) {
int gloves = player.getEquipment().getGlovesId();
player.heal((int) (player.getMaxHitpoints() * (gloves >= 11079
&& gloves <= 11084 ? 0.15 : 0.10)));
int restoredEnergy = (int) (player.getRunEnergy() * 1.3);
player.setRunEnergy(restoredEnergy > 100 ? 100 : restoredEnergy);
player.getInventory().deleteItem(item);
}

[MENTION=15855]Over[/MENTION]ride
public boolean canEquip(int slotId, int itemId) {
if (slotId == Equipment.SLOT_CAPE || slotId == Equipment.SLOT_HAT) {
player.getPackets().sendGameMessage(
"You can't remove your team's colours.");
return false;
}
if (slotId == Equipment.SLOT_WEAPON || slotId == Equipment.SLOT_SHIELD) {
int weaponId = player.getEquipment().getWeaponId();
if (weaponId == 4037 || weaponId == 4039) {
player.getPackets().sendGameMessage(
"You can't remove enemy's flag.");
return false;
}
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean canAttack(Entity target) {
if (target instanceof Player) {
if (canHit(target))
return true;
player.getPackets().sendGameMessage("You can't attack your team.");
return false;
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processItemOnNPC(NPC npc, Item item) {
if (npc.getId() == 1532 && npc instanceof CastleWarBarricade) {
CastleWarBarricade barricade = (CastleWarBarricade) npc;
if (item.getId() == 590) {
barricade.litFire();
return false;
} else if (item.getId() == 4045) {
player.getInventory().deleteItem(item);
barricade.explode();
return false;
}
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean canHit(Entity target) {
if (target instanceof NPC)
return true;
Player p2 = (Player) target;
if (p2.getEquipment().getCapeId() == player.getEquipment().getCapeId())
return false;
return true;
}

// You can't leave just like that!

public void leave() {
player.getPackets().closeInterface(
player.getInterfaceManager().hasRezizableScreen() ? 11 : 0);
CastleWars.removePlayingPlayer(player, team);
}

[MENTION=15855]Over[/MENTION]ride
public void sendInterfaces() {
player.getInterfaceManager().sendTab(
player.getInterfaceManager().hasRezizableScreen() ? 11 : 0, 58);
}

[MENTION=15855]Over[/MENTION]ride
public boolean sendDeath() {
WorldTasksManager.schedule(new WorldTask() {
int loop;

[MENTION=15855]Over[/MENTION]ride
public void run() {
if (loop == 0) {
player.setNextAnimation(new Animation(836));
} else if (loop == 1) {
player.getPackets().sendGameMessage(
"Oh dear, you have died.");
} else if (loop == 3) {
int weaponId = player.getEquipment().getWeaponId();
if (weaponId == 4037 || weaponId == 4039) {
CastleWars.setWeapon(player, null);
CastleWars.dropFlag(player,
weaponId == 4037 ? CastleWars.SARADOMIN
: CastleWars.ZAMORAK);
} else {
Player killer = player
.getMostDamageReceivedSourcePlayer();
if (killer != null)
killer.increaseKillCount(player);
}

player.reset();
player.setNextWorldTile(new WorldTile(
team == CastleWars.ZAMORAK ? CastleWars.ZAMO_BASE
: CastleWars.SARA_BASE, 1));
player.setNextAnimation(new Animation(-1));
} else if (loop == 4) {
player.getPackets().sendMusicEffect(90);
stop();
}
loop++;
}
}, 0, 1);
return false;
}

[MENTION=15855]Over[/MENTION]ride
public boolean logout() {
player.setLocation(new WorldTile(CastleWars.LOBBY, 2));
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processMagicTeleport(WorldTile toTile) {
player.getDialogueManager().startDialogue("SimpleMessage",
"You can't leave just like that!");
return false;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processItemTeleport(WorldTile toTile) {
player.getDialogueManager().startDialogue("SimpleMessage",
"You can't leave just like that!");
return false;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processObjectTeleport(WorldTile toTile) {
player.getDialogueManager().startDialogue("SimpleMessage",
"You can't leave just like that!");
return false;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processObjectClick1(WorldObject object) {
int id = object.getId();
if (id == 4406 || id == 4407) {
removeControler();
leave();
return false;
} else if ((id == 4469 && team == CastleWars.SARADOMIN)
|| (id == 4470 && team == CastleWars.ZAMORAK)) {
passBarrier(object);
return false;
} else if (id == 4377 || id == 4378) { // no flag anymore
if (id == 4377 && team == CastleWars.SARADOMIN) {
if (player.getEquipment().getWeaponId() == 4039) {
CastleWars.addScore(player, team, CastleWars.ZAMORAK);
return false;
}
} else if (id == 4378 && team == CastleWars.ZAMORAK) {
if (player.getEquipment().getWeaponId() == 4037) {
CastleWars.addScore(player, team, CastleWars.SARADOMIN);
return false;
}
}
player.getPackets().sendGameMessage(
"You need to bring a flag back here!");
return false;
} else if (id == 4902 || id == 4903) { // take flag
if (id == 4902 && team == CastleWars.SARADOMIN) {
if (player.getEquipment().getWeaponId() == 4039) {
CastleWars.addScore(player, team, CastleWars.ZAMORAK);
return false;
}
player.getPackets().sendGameMessage(
"Saradomin won't let you take his flag!");
} else if (id == 4903 && team == CastleWars.ZAMORAK) {
if (player.getEquipment().getWeaponId() == 4037) {
CastleWars.addScore(player, team, CastleWars.SARADOMIN);
return false;
}
player.getPackets().sendGameMessage(
"Zamorak won't let you take his flag!");
} else {
// take flag
CastleWars.takeFlag(player, team,
id == 4902 ? CastleWars.SARADOMIN : CastleWars.ZAMORAK,
object, false);
}
return false;
} else if (id == 4900 || id == 4901) { // take dropped flag
CastleWars.takeFlag(player, team, id == 4900 ? CastleWars.SARADOMIN
: CastleWars.ZAMORAK, object, true);
return false;
} else if (id == 36579 || id == 36586) {
player.getInventory().addItem(new Item(4049));
return false;
} else if (id == 36575 || id == 36582) {
player.getInventory().addItem(new Item(4053));
return false;
} else if (id == 36577 || id == 36584) {
player.getInventory().addItem(new Item(4045));
return false;
// under earth from basess
} else if (id == 4411) {// stepping stone
if (object.getX() == player.getX()
&& object.getY() == player.getY())
return false;
player.lock(2);
player.setNextAnimation(new Animation(741));
player.addWalkSteps(object.getX(), object.getY(), -1, false);
} else if (id == 36693) {
player.useStairs(827, new WorldTile(2430, 9483, 0), 1, 2);
return false;
} else if (id == 36694) {
player.useStairs(827, new WorldTile(2369, 9524, 0), 1, 2);
return false;
} else if (id == 36645) {
player.useStairs(828, new WorldTile(2430, 3081, 0), 1, 2);
return false;
} else if (id == 36646) {
player.useStairs(828, new WorldTile(2369, 3126, 0), 1, 2);
return false;
} else if (id == 4415) {
if (object.getX() == 2417 && object.getY() == 3075
&& object.getPlane() == 1)
player.useStairs(-1, new WorldTile(2417, 3078, 0), 0, 1);
else if (object.getX() == 2419 && object.getY() == 3080
&& object.getPlane() == 1)
player.useStairs(-1, new WorldTile(2419, 3077, 0), 0, 1);
else if (object.getX() == 2430 && object.getY() == 3081
&& object.getPlane() == 2)
player.useStairs(-1, new WorldTile(2427, 3081, 1), 0, 1);
else if (object.getX() == 2425 && object.getY() == 3074
&& object.getPlane() == 3)
player.useStairs(-1, new WorldTile(2425, 3077, 2), 0, 1);
else if (object.getX() == 2380 && object.getY() == 3127
&& object.getPlane() == 1)
player.useStairs(-1, new WorldTile(2380, 3130, 0), 0, 1);
else if (object.getX() == 2382 && object.getY() == 3132
&& object.getPlane() == 1)
player.useStairs(-1, new WorldTile(2382, 3129, 0), 0, 1);
else if (object.getX() == 2369 && object.getY() == 3126
&& object.getPlane() == 2)
player.useStairs(-1, new WorldTile(2372, 3126, 1), 0, 1);
else if (object.getX() == 2374 && object.getY() == 3133
&& object.getPlane() == 3)
player.useStairs(-1, new WorldTile(2374, 3130, 2), 0, 1);
return false;
} else if (id == 36481) {
player.useStairs(-1, new WorldTile(2417, 3075, 0), 0, 1);
return false;
} else if (id == 36495 && object.getPlane() == 0) {
player.useStairs(-1, new WorldTile(2420, 3080, 1), 0, 1);
return false;
} else if (id == 36480 && object.getPlane() == 1) {
player.useStairs(-1, new WorldTile(2430, 3080, 2), 0, 1);
return false;
} else if (id == 36484 && object.getPlane() == 2) {
player.useStairs(-1, new WorldTile(2426, 3074, 3), 0, 1);
return false;
} else if (id == 36532 && object.getPlane() == 0) {
player.useStairs(-1, new WorldTile(2379, 3127, 1), 0, 1);
return false;
} else if (id == 36540) {
player.useStairs(-1, new WorldTile(2383, 3132, 0), 0, 1);
return false;
} else if (id == 36521 && object.getPlane() == 1) {
player.useStairs(-1, new WorldTile(2369, 3127, 2), 0, 1);
return false;
} else if (id == 36523 && object.getPlane() == 2) {
player.useStairs(-1, new WorldTile(2373, 3133, 3), 0, 1);
return false;
} else if (id == 36644) {
if (object.getY() == 9508)
player.useStairs(828, new WorldTile(2400, 3106, 0), 1, 2);
else if (object.getY() == 9499)
player.useStairs(828, new WorldTile(2399, 3100, 0), 1, 2);
player.setFreezeDelay(0);
player.setFrozeBlocked(0);
return false;
} else if (id == 36691) {
if (object.getY() == 3099)
player.useStairs(827, new WorldTile(2399, 9500, 0), 1, 2);
else if (object.getY() == 3108)
player.useStairs(827, new WorldTile(2400, 9507, 0), 1, 2);
player.setFreezeDelay(0);
player.setFrozeBlocked(0);
return false;
}/*
* else if (id == 4438) player.getActionManager().setSkill(new
* Mining(object, RockDefinitions.SMALLER_ROCKS)); else if (id == 4437)
* player.getActionManager().setSkill(new Mining(object,
* RockDefinitions.ROCKS ));
*/
else if (id == 4448) {
for (List<Player> players : CastleWars.getPlaying()) {
for (Player player : players) {
if (player.withinDistance(object, 1))
player.applyHit(new Hit(player, player.getHitpoints(),
HitLook.REGULAR_DAMAGE));
}
}
World.spawnObject(
new WorldObject(4437, object.getType(), object
.getRotation(), object.getX(), object.getY(),
object.getPlane()), true);
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processObjectClick2(WorldObject object) {
int id = object.getId();
if (id == 36579 || id == 36586) {
player.getInventory().addItem(new Item(4049, 5));
return false;
} else if (id == 36575 || id == 36582) {
player.getInventory().addItem(new Item(4053, 5));
return false;
} else if (id == 36577 || id == 36584) {
player.getInventory().addItem(new Item(4045, 5));
return false;
}
return true;
}

public void passBarrier(WorldObject object) {
if (object.getRotation() == 0 || object.getRotation() == 2) {
if (player.getY() != object.getY())
return;
player.lock(2);
player.addWalkSteps(object.getX() == player.getX() ? object.getX()
+ (object.getRotation() == 0 ? -1 : +1) : object.getX(),
object.getY(), -1, false);
} else if (object.getRotation() == 1 || object.getRotation() == 3) {
if (player.getX() != object.getX())
return;
player.lock(2);
player.addWalkSteps(
object.getX(),
object.getY() == player.getY() ? object.getY()
+ (object.getRotation() == 3 ? -1 : +1) : object
.getY(), -1, false);
}
}

[MENTION=15855]Over[/MENTION]ride
public void magicTeleported(int type) {
removeControler();
leave();
}

[MENTION=15855]Over[/MENTION]ride
public void forceClose() {
leave();
}
}
[/CODE]



Castlewars Waiting

[CODE]package com.rs.game.player.controlers.castlewars;

import com.rs.game.WorldObject;
import com.rs.game.WorldTile;
import com.rs.game.minigames.CastleWars;
import com.rs.game.player.Equipment;
import com.rs.game.player.controlers.Controler;

public class CastleWarsWaiting extends Controler {

private int team;

[MENTION=15855]Over[/MENTION]ride
public void start() {
team = (int) getArguments()[0];
sendInterfaces();
}

// You can't leave just like that!

public void leave() {
player.getPackets().closeInterface(
player.getInterfaceManager().hasRezizableScreen() ? 34 : 0);
CastleWars.removeWaitingPlayer(player, team);
}

[MENTION=15855]Over[/MENTION]ride
public void sendInterfaces() {
player.getInterfaceManager().sendTab(
player.getInterfaceManager().hasRezizableScreen() ? 34 : 0, 57);
}

[MENTION=15855]Over[/MENTION]ride
public boolean processButtonClick(int interfaceId, int componentId,
int slotId, int packetId) {
if (interfaceId == 387) {
if (componentId == 9 || componentId == 6) {
player.getPackets().sendGameMessage(
"You can't remove your team's colours.");
return false;
}
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean canEquip(int slotId, int itemId) {
if (slotId == Equipment.SLOT_CAPE || slotId == Equipment.SLOT_HAT) {
player.getPackets().sendGameMessage(
"You can't remove your team's colours.");
return false;
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean sendDeath() {
removeControler();
leave();
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean logout() {
player.setLocation(new WorldTile(CastleWars.LOBBY, 2));
return true;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processMagicTeleport(WorldTile toTile) {
player.getDialogueManager().startDialogue("SimpleMessage",
"You can't leave just like that!");
return false;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processItemTeleport(WorldTile toTile) {
player.getDialogueManager().startDialogue("SimpleMessage",
"You can't leave just like that!");
return false;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processObjectTeleport(WorldTile toTile) {
player.getDialogueManager().startDialogue("SimpleMessage",
"You can't leave just like that!");
return false;
}

[MENTION=15855]Over[/MENTION]ride
public boolean processObjectClick1(WorldObject object) {
int id = object.getId();
if (id == 2469 || id == 4390) {
removeControler();
leave();
return false;
}
return true;
}

[MENTION=15855]Over[/MENTION]ride
public void magicTeleported(int type) {
removeControler();
leave();
}

[MENTION=15855]Over[/MENTION]ride
public void forceClose() {
leave();
}
}
[/CODE]




Barricade Combat
[CODE]package com.rs.game.npc.combat.impl;

import com.rs.game.Entity;
import com.rs.game.npc.NPC;
import com.rs.game.npc.combat.CombatScript;

public class BarricadeCombat extends CombatScript {

[MENTION=15855]Over[/MENTION]ride
public Object[] getKeys() {
// TODO Auto-generated method stub
return new Object[] { "Barricade" };
}

/*
* empty
*/
[MENTION=15855]Over[/MENTION]ride
public int attack(NPC npc, Entity target) {
return 0;
}

}
[/CODE]

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0
[CODE]
if (player.getX() == 2422 && player.getY() == 3076 || player.getX() == 2426 && player.getY() == 3080 || player.getX() == 2423 && player.getY() == 3076 || player.getX() == 2426 && player.getY() == 3081 || player.getX() == 2373 && player.getY() == 3127 || player.getX() == 2373 && player.getY() == 3126 || player.getX() == 2376 && player.getY() == 3131 || player.getX() == 2377 && player.getY() == 3131 || !CastleWars.isBarricadeAt(player)) {
player.getPackets().sendGameMessage("You cannot place a barracade here!");
return false;

[/CODE]

That's where you first issue lies, you probably need to re-do the spots where you can/can't add them. I would also suggest making world.java or another class handling it, just looks messy.


For your flag respawns

[CODE]
public void addScore(Player player, int team, int flagTeam) {
setWeapon(player, null);
score[team] += 1;
makeSafe(flagTeam);
}
[/CODE]

Just look at how your flags are being handled, and when they respawn. I'm sure it's something with makesafe

Share this post


Link to post
Share on other sites
  • 0
o wauw, the first time i changed the coords it didn't work. even if i completely removed them. But i added them again and organized just in castlewars again. Looks better now and barricades work.

I tried playing around now with the makesafe flagteam. I think you were right but i can't get it to work.

How it go's now is. after the zamorak team captured 2 flags. then the third flag cannot be taken, You can see it but you cant take it.

This is till now the only problem that persist.

Share this post


Link to post
Share on other sites
  • 0
Im having the same problem is there anway to fix it please? Once one team captured 2 flag's, take as example saradomin scores the zamorak flag twice.
Then the third flag won't show up. This is the same for the other team. If saradomin Captures two flags, then it won't show up.

Share this post


Link to post
Share on other sites
  • 0
[quote name='blackhacker']Im having the same problem is there anway to fix it please? Once one team captured 2 flag's, take as example saradomin scores the zamorak flag twice.
Then the third flag won't show up. This is the same for the other team. If saradomin Captures two flags, then it won't show up.[/QUOTE]

Do you receive any errors in the cmd when clicking it for a third time?

Share this post


Link to post
Share on other sites
  • 0
nope, there are no errors shown when the you try to take the third flag.
The game does not end as well. Even after spawnen more flags and just capturing you can go over 20 points.

Share this post


Link to post
Share on other sites
  • 0
[quote name='drakthuro']nope, there are no errors shown when the you try to take the third flag.
The game does not end as well. Even after spawnen more flags and just capturing you can go over 20 points.[/QUOTE]

I'm really confused by this and kind of interested. I think I might download a 718 and look further into it.

Share this post


Link to post
Share on other sites
  • 0
would be lovely falconpunch.

it's not the cache nor the client, i Tried different caches and clients but the problem persists.
Barricades are fixed since it was easy to fix it :3 since you told me how.

Anyways, I'm eager to get it fixed, so can't wait ;)

Share this post


Link to post
Share on other sites
  • 0
[CODE]public void reset() {
minutesLeft = 1;
score = new int[999];
flagStatus = new int[999];
barricadesCount = new int[999];
for (WorldObject object : spawnedObjects)
World.destroySpawnedObject(object, object.getId() == 4377
|| object.getId() == 4378 ? false : true);
spawnedObjects.clear();
for (CastleWarBarricade npc : barricades)
npc.finish();
barricades.clear();
}[/CODE]

Share this post


Link to post
Share on other sites
  • 0
'bevy, what's that for? the ints changed to 999?

Share this post


Link to post
Share on other sites
  • 0
[quote name='drakthuro']'bevy, what's that for? the ints changed to 999?[/QUOTE]

I'm now on a 718. I'm about to try and figure out the problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×