castlewars code

Go down

castlewars code

Post  cows1471 on Wed Jan 14, 2009 2:01 pm

yo if anyone wants the clanwars code its this!

What a Face

Difficulty: 3/10,should be easy

Files editederver.java, Client.java, Castlewars.java(new file)

Tested on: My source, should work on all

Took me about a week to get this fully working if you read this POST or i remove
Back up your files just incase
Was originally posted on silabsoft By ME
Step One:
open up server.java and declare this
Code:


CODE
public void castleWars() {
if(Castlewars.gameTime == 0) {
zammyscore = 0;
sarascore = 0;
}
if(Castlewars.waitTime == 0) {
cwarssaramax = 0;
cwarszammymax = 0;
}
}

Step Two:
search for public static server clientHandler = null;
and place this above it
Code:

public static int cwarszammymax = 0;
public static int cwarssaramax = 0;
public static int zammyscore = 0;
public static int sarascore = 0;
public static Castlewars Castlewars = null;

Step Three:
Search for objectHandler = new ObjectHandler();
under it add this
Code:

Castlewars = new Castlewars();

Then close and save server.java
Step Four
create a file called Castlewars.java and add this to it
Code:

public class Castlewars {
int sarascore = server.sarascore;
int zammyscore = server.zammyscore;
int cwarssaramax = server.cwarssaramax;
int cwarszammymax = server.cwarszammymax;
public static int waitTime = -1;
public static int gameTime = -1;
public int Time = 1200; //120 = 1 minute
public int Time2 = 1320; // 11 minutes
public void process() {
if(gameTime >= 0) {
gameTime -= 1;
}
if(waitTime >= 0) {
waitTime -= 1;
}
if(waitTime == -1)
{
sarascore = 0; //resets scores
zammyscore = 0;
cwarssaramax = 0;//resets max players to 0.
cwarszammymax = 0;
gameTime = Time; //starts the game (10 minutes)
waitTime = Time2;
PlayerHandler.messageToAll = ("A new Caslte wars game has started"); //Messages everyone
}
if(gameTime == 0)
{

PlayerHandler.messageToAll = ("A Castle wars game has ended. Get to the wating rooms!");//Messages everyone
}
}
}
save and close

Step Five:
open client.java and declare this
Code:

public boolean Sara = false;
public boolean Zammy = false;
public boolean hasFlag = false;

Step Six:
search for public boolean nonWild()
and after the last } put this
Code:

public boolean castlewarswait() {
if((absX >=2410 && absX <=2434 && absY >=9511 && absY <=9536) || (absX >=2367 && absX <=2393 && absY >=9480 && absY <=9497))
return true;
else
return false;
}
public boolean castlewarsgame() {
if(absX >= 2359 && absX <= 2432 && absY >= 3069 && absY <= 3134)
return true;
else
return false;
}

Step Seven:
search for public void NewObjects() add this to it
Code:

makeGlobalObject(2381, 3122, 4903, 0, 10);//CastleWars Flag Stand (Zamorak flag)-(./.Z.A/./C./H)
makeGlobalObject(2418, 3085, 4902, 0, 10);//CastleWars Flag Stand (Saradomin flag)-(/Z.A/./C./H)

Step Eight:
then search for
//QUEST_1 OBJECTS
under that put
Code:

case 4903:
if(Sara == true)
{
deletethatobject(2381, 3122);
makeGlobalObject(2381, 3122, 4378, 0, 10);//CastleWars Flag Stand empty(Zamorak flag)-(./.Z.A/./C./H)
remove(playerEquipment[playerWeapon] , playerWeapon);
addItem(playerEquipment[playerWeapon] = 4039,0);
deleteItem(4039, getItemSlot(4039), 1);
hasFlag = true;
}
else if(Zammy == true && playerEquipment[playerWeapon] == 4037)
{
remove(playerEquipment[playerWeapon] , playerWeapon);
deleteItem(4037, getItemSlot(4037), 1);
server.zammyscore += 1;
deletethatobject(2418, 3085);
makeGlobalObject(2418, 3085, 4902, 0, 10);//CastleWars Flag Stand (sara flag)-(/Z.A/./C./H)
Zammy = true;
hasFlag = false;
}
break;
case 4902:
if(Zammy == true)
{
deletethatobject(2418, 3085);
makeGlobalObject(2418, 3085, 4377, 0, 10);//CastleWars Flag Stand empty(Saradomin flag)-(/Z.A/./C./H)
remove(playerEquipment[playerWeapon] , playerWeapon);
addItem(playerEquipment[playerWeapon] = 4037,0);
deleteItem(4037, getItemSlot(4037), 1);
hasFlag = true;
}
else if(Sara == true && playerEquipment[playerWeapon] == 4039)
{
remove(playerEquipment[playerWeapon] , playerWeapon);
deleteItem(4039, getItemSlot(4039), 1);
server.sarascore += 1;
deletethatobject(2381, 3122);
makeGlobalObject(2381, 3122, 4903, 0, 10);//CastleWars Flag Stand (Zamorak flag)-(./.Z.A/./C./H)
Sara = true;
hasFlag = false;
}
break;
case 4377:
if(Sara == true && playerEquipment[playerWeapon] == 4039)
{
remove(playerEquipment[playerWeapon] , playerWeapon);
deleteItem(4039, getItemSlot(4039), 1);
server.sarascore += 1;
deletethatobject(2381, 3122);
makeGlobalObject(2381, 3122, 4903, 0, 10);//CastleWars Flag Stand (Zamorak flag)-(./.Z.A/./C./H)
Sara = true;
hasFlag = false;
}
break;
case 4378:
if(Zammy == true && playerEquipment[playerWeapon] == 4037)
{
remove(playerEquipment[playerWeapon] , playerWeapon);
deleteItem(4037, getItemSlot(4037), 1);
server.zammyscore += 1;
deletethatobject(2418, 3085);
makeGlobalObject(2418, 3085, 4902, 0, 10);//CastleWars Flag Stand (sara flag)-(/Z.A/./C./H)
Zammy = true;
hasFlag = false;
}
break;
case 4900:
if(Sara == true) {
ReplaceObject2(objectX, objectY, 6951, -1, 10);
deletethatobject(2418, 3085);
makeGlobalObject(2418, 3085, 4902, 0, 10);//CastleWars Flag Stand (sara flag)-(/Z.A/./C.//H)
}
if(Zammy == true) {
ReplaceObject2(objectX, objectY, 6951, -1, 10);
remove(playerEquipment[playerWeapon] , playerWeapon);
addItem(playerEquipment[playerWeapon] = 4037,0);
deleteItem(4037, getItemSlot(4037), 1);
hasFlag = true;
}
break;
case 4901:
if(Zammy == true) {
ReplaceObject2(objectX, objectY, 6951, -1, 10);
deletethatobject(2381, 3122);
makeGlobalObject(2381, 3122, 4903, 0, 10);//CastleWars Flag Stand (Zammy flag)-(/Z.A/./C.//H)
}
if(Sara == true) {
ReplaceObject2(objectX, objectY, 6951, -1, 10);
remove(playerEquipment[playerWeapon] , playerWeapon);
addItem(playerEquipment[playerWeapon] = 4039,0);
deleteItem(4039, getItemSlot(4039), 1);
hasFlag = true;
}
break;

Step Nine:
then search for //portals
then put this under it
Code:

case 4387: // Saradomin Portal enter
if(Castlewars.waitTime < 0)
{
sendMessage("Game is already in play!");
}
else
{
if(server.cwarssaramax > server.cwarszammymax)
{
sendMessage("This team is full.");
}
else
{
if(Zammy == true)
{
sendMessage("Type ::resetteam to be able to go in here.");
}
else
{
addItem(playerEquipment[playerCape] = 4041,0);
addItem(playerEquipment[playerHat] = 4513,0);
deleteItem(4041, GetItemSlot(4041), 5);
deleteItem(4513, GetItemSlot(4513), 5);
Sara = true;
server.cwarssaramax += 1;
teleportToX = 2379+misc.random(4);
teleportToY = 9488+misc.random(4);
}
}
}
break;

case 4389: // Saradomin Portal leave
remove(playerEquipment[playerCape], playerCape);
remove(playerEquipment[playerHat], playerHat);
deleteItem(4041, GetItemSlot(4041), 5);
deleteItem(4513, GetItemSlot(4513), 5);
Sara = false;
server.cwarssaramax -= 1;
teleportToX = 2441+misc.random(4);
teleportToY = 3089+misc.random(4);
break;

case 4388: // Zamorak Portal enter
if(Castlewars.waitTime < 0)
{
sendMessage("Game is already in play!");
}
else
{
if(Sara == true)
{
sendMessage("Type ::resetteam to be able to go in here.");
}
else
{
if(server.cwarszammymax > server.cwarssaramax)
{
sendMessage("This team is full.");
}
else
{
addItem(playerEquipment[playerCape] = 4042,0);
addItem(playerEquipment[playerHat] = 4513,0);
deleteItem(4042, GetItemSlot(4042), 5);
deleteItem(4515, GetItemSlot(4515), 5);
Zammy = true;
server.cwarszammymax += 1;
teleportToX = 2421+misc.random(2);
teleportToY = 9523+misc.random(2);
}
}
}
break;

case 4390: // Zamorak Portal leave
remove(playerEquipment[playerCape], playerCape);
remove(playerEquipment[playerHat], playerCape);
deleteItem(4041, GetItemSlot(4042), 5);
deleteItem(4513, GetItemSlot(4515), 5);
Zammy = false;
server.cwarszammymax -= 1;
teleportToX = 2441+misc.random(4);
teleportToY = 3089+misc.random(4);
break;

Step Ten:
then search for public void process() and put this under it
Code:

if(Sara == true && castlewarsgame() == true) {
if(playerEquipment[playerCape] == 4041) {
}
else
{
addItem(playerEquipment[playerCape] = 4041,0);
addItem(playerEquipment[playerHat] = 4513,0);
deleteItem(4041, GetItemSlot(4041), 21);
deleteItem(4513, GetItemSlot(4513), 21);
}
}
if(Sara == true && castlewarsgame() == true) {
if(playerEquipment[playerHat] == 4513) {
}
else
{
addItem(playerEquipment[playerCape] = 4041,0);
addItem(playerEquipment[playerHat] = 4513,0);
deleteItem(4041, GetItemSlot(4041), 21);
deleteItem(4513, GetItemSlot(4513), 21);
}
}

if(Zammy == true && castlewarsgame() == true) {
if(playerEquipment[playerCape] == 4042) {
}
else
{
addItem(playerEquipment[playerCape] = 4042,0);
addItem(playerEquipment[playerHat] = 4515,0);
deleteItem(4041, GetItemSlot(4042), 21);
deleteItem(4513, GetItemSlot(4515), 21);
}
}
if(Zammy == true && castlewarsgame() == true) {
if(playerEquipment[playerHat] == 4515) {
}
else
{
addItem(playerEquipment[playerCape] = 4042,0);
addItem(playerEquipment[playerHat] = 4515,0);
deleteItem(4041, GetItemSlot(4042), 21);
deleteItem(4513, GetItemSlot(4515), 21);
}
}

if(hasFlag == true) {
if(Sara == true) {
if(playerEquipment[playerWeapon] == 4039) {
}
else
{
deleteItem(4039, getItemSlot(4039), 28);//makes sure there is no bugs or glitches
makeGlobalObject(absX, absY, 4901, 0, 10);//CastleWars Flag no stand(Zamorak Flag) - zach
hasFlag = false;
}
}

if(Zammy == true) {
if(playerEquipment[playerWeapon] == 4037) {
}
else
{
deleteItem(4037, getItemSlot(4037), 28);//makes sure there is no bugs or glitches
makeGlobalObject(absX, absY, 4900, 0, 10);//CastleWars Flag no stand(Zamorak Flag) - zach
hasFlag = false;
}
}
}
int waitTime = Castlewars.waitTime;
int gameTime = Castlewars.gameTime;
int sarascore = server.sarascore;
int zammyscore = server.zammyscore;
int cwarssaramax = server.cwarssaramax;
int cwarszammymax = server.cwarszammymax;
if(castlewarsgame() == true)
{
sendFrame126(" @whi@Time Left: @gre@ " + gameTime, 6570);
sendFrame126("@cya@ Sara:@whi@ " + sarascore, 6570);
sendFrame126("@red@Zamorak:@whi@ " + zammyscore, 6572);
setInterfaceWalkable(6673);//6673
updateRequired = true;
appearanceUpdateRequired = true;
}
if(castlewarswait() == true)
{

sendFrame126(" @whi@Time left till Game Starts@gre@ ", 6570);
if(waitTime <= 1320 && waitTime >= 1200)
{
sendFrame126("@gre@ 11 minutes", 6572);
}
if(waitTime <= 1200 && waitTime >= 1080 )
{
sendFrame126("@gre@ 10 minutes", 6572);
appearanceUpdateRequired = true;
}
if(waitTime <= 1080 && waitTime >= 960 )
{
sendFrame126("@gre@ 9 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 960 && waitTime >= 840 )
{
sendFrame126("@gre@ 8 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 840 && waitTime >= 720)
{
sendFrame126("@gre@ 7 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 720 && waitTime >= 600)
{
sendFrame126("@gre@ 6 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 600 && waitTime >= 480)
{
sendFrame126("@gre@ 5 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 480 && waitTime >= 360)
{
sendFrame126("@gre@ 4 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 360 && waitTime >= 240)
{
sendFrame126("@gre@ 3 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 240 && waitTime >= 120)
{
sendFrame126("@gre@ 2 minutes", 6572);

appearanceUpdateRequired = true;
}
if(waitTime <= 120 && waitTime >= 0)
{
sendFrame126("@gre@ 1 minute", 6572);

appearanceUpdateRequired = true;
}
sendFrame126(" @red@", 6664);
setInterfaceWalkable(6673);//6673
}

if(waitTime == 0 && (absX >=2367 && absX <=2393 && absY >=9480 && absY <=9497)) //this says if the player is in the waiting room and the waitTime is 0, then it will tele them into the game field.
{
teleportToX = 2425+misc.random(3);//sara side
teleportToY = 3079+misc.random(1);
cwarssaramax = 0;
}
if(waitTime == 0 && (absX >=2410 && absX <=2434 && absY >=9511 && absY <=9536)) //this says if the player is in the waiting room and the waitTime is -1, then it will tele them into the game field.
{
teleportToX = 2374+misc.random(Cool;//zammy side
teleportToY = 3127+misc.random(Cool;
cwarszammymax = 0;
}
if(gameTime == 0 && (absX >= 2359 && absX <= 2432 && absY >= 3069 && absY <= 3134)) //this checks if the gametime is done and the player is in the game field, if he/she is, then it will teleport them back to the lobby.
{
teleportToX = 2440+misc.random(4);//teleports to castlewars lobby(where portals are)
teleportToY = 3090+misc.random(4);
hasFlag = false;
remove(playerEquipment[playerWeapon], playerWeapon);
deleteItem(4037, getItemSlot(4037), 3);
deleteItem(4039, getItemSlot(4039), 3);
if(sarascore > zammyscore && Sara == true)
{
addItem(995, 10000000);
Sara = false;
zammyscore = 0;
sarascore = 0;
}
if(sarascore < zammyscore && Zammy == true)
{
addItem(995, 10000000);
Zammy = false;
zammyscore = 0;
sarascore = 0;
}
if(sarascore > zammyscore && Zammy == true)
{
Zammy = false;
zammyscore = 0;
sarascore = 0;
}
if(sarascore < zammyscore && Sara == true)
{
Sara = false;
zammyscore = 0;
sarascore = 0;
}
}

Step 11:
then search for //if killed apply dead
and place this under it
Code:

if ((absX >= 2359 && absX <= 2432 && absY >= 3069 && absY <= 3134 && IsDead == true && NewHP <= 1)) {
if(Sara == true) {
IsDead = false;
playerLevel[3] = getLevelForXP(playerXP[3]);
currentHealth = playerLevel[3];
NewHP = playerLevel[3];
refreshSkills();
updateRequired = true;
appearanceUpdateRequired = true;
teleportToX = 2427;
teleportToY = 3074;
sendMessage("you died in castlewars");
}
else if(Zammy == true) {
IsDead = false;
playerLevel[3] = getLevelForXP(playerXP[3]);
currentHealth = playerLevel[3];
NewHP = playerLevel[3];
refreshSkills();
updateRequired = true;
appearanceUpdateRequired = true;
teleportToX = 2372;
teleportToY = 3131;
sendMessage("you died in castlewars");

}
}

Step 12:
then search for // Log out
and place this above the last }
Code:

if (castlewarsgame() ==true)
{
teleportToX = 2441;
teleportToY = 3089;
Sara = false;
Zammy = false;
logout();
savefile = true;
}
if (castlewarswait() ==true)
{
teleportToX = 2441;
teleportToY = 3089;
Sara = false;
Zammy = false;
logout();
savefile = true;
}
avatar
cows1471
GOD!
GOD!

Number of posts : 137
Reputation : 1
Registration date : 2009-01-13

View user profile http://billscape.inmyclan.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum