Pure Kaos
Posts : 438 Points : 2147595307 Rank : 1 Join date : 2009-08-09 Age : 30 Location : England, Bristol
| Subject: Codes for castle wars. Thu Nov 05, 2009 6:44 pm | |
| 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 } } } | |
|
Bobibob
Posts : 538 Points : 115764 Rank : 24 Join date : 2009-08-27 Age : 29 Location : uk
| Subject: Re: Codes for castle wars. Fri Nov 06, 2009 3:27 am | |
| my version of deadly clan wars we can test out our clan sword against adrians here its all dangerous ive already posted this on moparscape forums So what does this mini-game include? - 2 Teams - The 2 Teams PK Each other - Not a safe mini-game, since I like to loose items (You can make it safe) - Rewards, You can add more. - Countdown timer untill next match (Yells to all players) - Say Team1 has 2 players, then next to Signup will enter Team2 and so on. - Blocking Team Killing(AKA Can't kill people in same team, Range, Magic, Melee) - After signup you will be teleported into the next match when it begins - Each match continues for 5Minutes. - After death, you will only recieve a SMALL Reward. - The remaining people that has not died after 5minutes, will be given a bigger reward and also teleported outside. - You talk to an NPC to Signup/Resign/Information. - Supports MultiCombat - Displays both Teams Members (Using ArrayList) - Not enough registrations = No Match, but pay fee back. - 10k Signup fee. - If you Resign, the NPC takes 50% of your 10k (5k). - And more, just read code. Let's begin. Step 1: Start of by declaring all this in Client class: Code: public boolean hasGotTeam = false; public int team; public int team1PlayerAmount; public int team2PlayerAmount; public int teamTimer = 600; public int teamParticipant; ArrayList team1Players = new ArrayList(); ArrayList team2Players = new ArrayList(); ArrayList noTeam = new ArrayList(); ArrayList playersMessage1 = new ArrayList(); ArrayList playersMessage2 = new ArrayList(); public ArrayList getPlayerTeam() { if(team == 1) { return team1Players; } if(team == 2) { return team2Players; } return noTeam; } public void getTeamPlayers() { for (Player p : server.playerHandler.players) { if(p != null) { client person = (client)p; if(person.team == 1) { team1Players.add(person.playerName); } if(person.team == 2) { team2Players.add(person.playerName); } } } } public void teamMessage() { getTeamPlayers(); talk("You are now on team: "+team, 513); customCommand("teamdebugmsg"); }
public void getBothTeamPlayers() {
for (Player p : server.playerHandler.players) { if(p != null) { client person = (client)p; if(person.team == 1) { playersMessage1.add(person.playerName); } if(person.team == 2) { playersMessage2.add(person.playerName); } } } }
public void team2Msg() { team = 2; team2PlayerAmount++; team2Players.add(""+playerName); hasGotTeam = true; teamMessage(); } public void team1Msg() { team = 1; team1PlayerAmount++; team1Players.add(""+playerName); hasGotTeam = true; teamMessage(); }
public void randteamMsg() { if(team == 1) { team1PlayerAmount++; team1Players.add(""+playerName); hasGotTeam = true; teamMessage(); } if(team == 2) { team1PlayerAmount++; team1Players.add(""+playerName); hasGotTeam = true; teamMessage(); } }
public static int teams[] = {1, 2}; public static int randomTeam() { return teams[(int)(Math.random()*teams.length)]; }
As stated above, these are just declarations.
Step 2:
Add this in your AttackPlayer Method:
Code:
if(AttackingOn2.team == team && isInWars(absX, absY, 1)==true) { sendStatement("You can not attack players from your own team!"); ResetAttack(); return false; } if(isInWars(absX, absY, 1) && team == 0) { sendStatement("You can not attack if you do not attend!"); ResetAttack(); return false; }
Add this to packet 249:
Code:
if(castOnPlayer.team == team && isInWars(absX, absY, 1)) { sendStatement("You can not attack players in your team!"); ResetAttack(); break; }
if(castOnPlayer.team == 1 || castOnPlayer.team == 2 && team == 0 && isInWars(absX, absY, 1)) { sendStatement("You must participate before attempting to kill someone."); ResetAttack(); break; }
These 2 codes stops TeamMembers from attacking each other.
Step 3:
Add these NPC Dialogues:
Code:
case 150: talk2("Hello there! I am the hoster of this minigame.","Please take a moment to decide:", 513); break; case 151: sendFrame164(2492); sendFrame126("Please Choose", 2493); sendFrame126("Sign Up!", 2494); sendFrame126("Resign", 2495); sendFrame126("Information", 2496); sendFrame126("", 2497); sendFrame126("Nevermind!", 2497); break; case 152: talk2("This minigame consist of 2 teams.","These 2 teams are to fight each other to the death.", 513); break; case 153: talk2("The remaining players alive after 5minutes","will be rewarded.",513); break; case 154: talk2("The signup fee is only 10,000 Gold!","So why not give it a try?", 513); break;
Just some dialogues.
Step 4: Add this to FirstClickNPC:
Code:
if(NPCID == 513) { NpcDialogue = 150; NpcDialogueSend = false; }
And while you're at it, add this to your autospawn:
Code:
spawn = 513 3113 9519 0 0 0 0 0 1
Step 5: Add this to your void/boolean process(), or alternativly, add it to Grahams EventManager.
Code:
if(teamTimer >= 0) { teamTimer -= 1; } switch(teamTimer) { case 480: yell("Team PK Match starts in 4 Minutes!"); break; case 360: yell("Team PK Match starts in 3 Minutes!"); break; case 240: yell("Team PK Match starts in 2 Minutes!"); break; case 120: yell("Team PK Match starts in 1 Minute!"); break; } if(teamTimer == 0) { for (Player p : server.playerHandler.players) { if(p != null) { client teamPlayers = (client)p; if(team1Players == null || team2Players == null) { if(teamPlayers.team == 1 || teamPlayers.team == 2) { teamPlayers.toX = 3111; teamPlayers.toY = 9525; teamPlayers.team = 0; teamPlayers.teamParticipant = 0; teamPlayers.talk2("I'm sorry but there weren't enough","registrations to hold this match.", 513); teamPlayers.addItem(995, 10000); teamPlayers.sM("You recieved your pay fee back."); } } if(teamPlayers.teamParticipant == 1 && teamPlayers.team == 1 || teamPlayers.team == 2 && teamTimer == 1) { teamPlayers.toX = 3111; teamPlayers.toY = 9525; teamPlayers.team = 0; teamPlayers.teamParticipant = 0; teamPlayers.talk2("Congratulations for winning this game!","Here's your reward.", 513); teamPlayers.addItem(995, 100000); teamPlayers.addItem(392, 50); } if(teamPlayers.team == 1) { teamPlayers.triggerTele(3104 + misc.random(3), 9518 + misc.random(3), 0); teamPlayers.teamParticipant = 1; } if(teamPlayers.team == 2) { teamPlayers.triggerTele(3104 + misc.random(3), 9518 + misc.random(3), 0); teamPlayers.teamParticipant = 1; } if(teamPlayers.team == 0) { teamPlayers.sM("A Team PK MiniGame has started. Go signup for next one!"); } } } teamTimer = 300; }
The main things we'll need. Notice the case '240' etc, that's Seconds. Since the process is called every 0.5 seconds (500ms), we have to duplicate our real number. 240 is 2minutes, originally 120 Seconds.
Step 6: Some commands for this:
Code:
if(command.equalsIgnoreCase("timer1") && playerRights >= 3) { teamTimer = 10; } if(command.equalsIgnoreCase("teamdebugmsg")) { getBothTeamPlayers(); sM("Players on team1: "+playersMessage1); sM("Players on team2: "+playersMessage2); playersMessage1.clear(); playersMessage2.clear(); } if(command.equalsIgnoreCase("team")) { sM("Your Team: "+team); }
Step 7: Now we're gonna add the Zones. You'll have to find out where.
Code:
public boolean isInWilderness(int coordX, int coordY, int Type) { if (Type == 1) { if ((coordY >= 3523) && (coordY <= 3967) && (coordX <= 3392) && (coordX >= 2942) || absX >= 3094 && absX <= 3106 && absY >= 9509 && absY <= 9528 || absX >= 3220 && absX <= 3299 && absY >= 3520 && absY <=3548 || absX >= 2250 && absX <= 2296 && absY >= 4676 && absY <=4715) { return true; } } else if (Type == 2) { if ((coordY >= 3512) && (coordY <= 3967) && (coordX <= 3392) && (coordX >= 2942)) { return true; } } return false; } public boolean isInWars(int coordX, int coordY, int Type) { if(Type == 1) { if ((absY >= 9509) && (absY <= 9528) && (absX <= 3106) && (absX >= 3094)) { return true; } } return false; }
Code:
public boolean multiCombat() { if ((absY >= 9509) && (absY <= 9528) && (absX <= 3106) && (absX >= 3094)) { return true; } if((absX >= 3144 && absX <= 3184 && absY >= 3519 && absY <=3656) || (absX >= 3185 && absX <= 3350 && absY >= 3502 && absY <=3900) || (absX >= 2983 && absX <= 3007 && absY >= 3905 && absY <=3917) || (absX >= 3007 && absX <= 3075 && absY >= 3608 && absY <=3713) || (absX >= 2944 && absX <= 2963 && absY >= 3812 && absY <=3827) || (absX >= 3041 && absX <= 3057 && absY >= 3869 && absY <=3883) || (absX >= 3157 && absX <= 3181 && absY >= 3874 && absY <=3895) || (absX >= 2720 && absX <= 2760 && absY >= 5073 && absY <=5114) || (absX >= 2256 && absX <= 2287 && absY >= 4680 && absY <=4711) || (absX >= 2360 && absX <= 2445 && absY >= 5045 && absY <= 5125) || (absX >= 2760 && absX <= 2780 && absY >= 2790 && absY <=2810) || (absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <=2619) || (absX >= 3460 && absX <= 3520 && absY >= 9470 && absY <=9530) || (absX >= 2371 && absX <= 2424 && absY >= 5125 && absY <=5167) || (absX >= 2627 && absX <= 2677 && absY >= 4550 && absY <=4602) || (absX >= 3249 && absX <= 3307 && absY >= 3904 && absY <=3952) || (absX >= 2420 && absX <= 2520 && absY >= 10100 && absY <=10200) || (absX >= 2992 && absX <= 3090 && absY >= 4804 && absY <=4872)) return true; else return false; }
Step 8: You can close Client class now, and open ClickingMost.
Add these: Code:
case 9190: if(c.NpcDialogue == 151) { if(c.playerHasItem(995, 10000)==false) { c.closeAll(); c.talk("The signup fee is 10k coins.", 513); } else if(c.playerHasItem(995, 10000)) { if(c.team1PlayerAmount == c.team2PlayerAmount || c.team2PlayerAmount == c.team1PlayerAmount) { c.closeAll(); c.team = c.randomTeam(); c.randteamMsg(); c.deleteItem(995, 10000); }else if(c.team1PlayerAmount >= c.team2PlayerAmount && c.hasGotTeam == false) { c.closeAll(); c.team2Msg(); c.deleteItem(995, 10000); }else if(c.team2PlayerAmount >= c.team1PlayerAmount && c.hasGotTeam == false) { c.closeAll(); c.team1Msg(); c.deleteItem(995, 10000); } } }
Code:
case 9191: if(c.NpcDialogue == 151) { if(c.team == 0) { c.closeAll(); c.talk("You are not signed up!", 513); } else { c.closeAll(); c.team = 0; c.talk2("Sad to hear you resigned. You will get your money back","But I'm taking 50%!!", 513); c.addItem(995, 5000); } }
Code:
case 9192: if(c.NpcDialogue == 151) { c.NpcDialogue = 152; c.NpcDialogueSend = false; }
Code:
case 9194: if(c.NpcDialogue == 151) { c.closeAll(); }
Step 9: Add this death statement:
Code:
if (deathStage == 2 && System.currentTimeMillis() - deathTimer >= 2500 && !isInPitGame() && !IsInFightCave() && isInWars(absX, absY, 1)) { toX = 3111; toY = 9510; AtkPray = 0; StrPrayer = 0; DefPray = 0; RangePray = 0; MagePray = 0; PrayHeal = false; ProtItem = false; ProtMage = false; ProtRange = false; ProtMelee = false; Redemption = false; Retribution = false; Smite = false; Chivalry = false; Piety = false; isSkulled = false; lastSkull = 0; headIcon = 0; turnpray(); heightLevel = 0; currentHealth = playerLevel[playerHitpoints]; deathStage = 0; resetAnimation(); frame1(); prayOn = false; AntiTeleDelay = 0; EntangleDelay = 0; sM("Oh dear you have died!"); resetOtherAtk(); followID = 0; followID2 = 0; teamParticipant = 0; talk2("Sorry to say, you have been discvalified.","But you gain a small reward for your attendance.", 513); addItem(995, 50000); }
Step 10: There's no step 10 really, just to say that you're done. Go enjoy the new mini-game :3
had mate make a decent vid of it but u need more players to play it http://tinypic.com/player.php?v=11bp8gy&s=4 | |
|
Pure Kaos
Posts : 438 Points : 2147595307 Rank : 1 Join date : 2009-08-09 Age : 30 Location : England, Bristol
| Subject: Re: Codes for castle wars. Sat Nov 07, 2009 4:22 am | |
| Lol i got sent my cords by moparscape admin. :L | |
|
Cr4nk
Posts : 7 Points : 109857 Rank : 0 Join date : 2009-11-11
| Subject: Re: Codes for castle wars. Sat Nov 14, 2009 12:06 pm | |
| Ya but all of this is copy + paste, the owner needs to know how to add castle wars by himself | |
|
ki
Posts : 37 Points : 110512 Rank : 0 Join date : 2009-10-16 Age : 29
| Subject: Re: Codes for castle wars. Sat Nov 14, 2009 1:00 pm | |
| Yes . I think it will be very popular and great. | |
|
Bobibob
Posts : 538 Points : 115764 Rank : 24 Join date : 2009-08-27 Age : 29 Location : uk
| Subject: Re: Codes for castle wars. Sun Nov 15, 2009 4:33 pm | |
| rofl dude im the person who added to the moparscape forums | |
|
Sapphira
Posts : 111 Points : 110576 Rank : 0 Join date : 2009-11-05
| Subject: Re: Codes for castle wars. Sun Nov 15, 2009 8:12 pm | |
| Lewis ur code looks incompleted. | |
|
Sponsored content
| Subject: Re: Codes for castle wars. | |
| |
|