Thread: [DELTA][DELTA][DELTA]My custom multi-player Godwars[COOLER DEN EVER][DELTA][DELTA]

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 [DELTA][DELTA][DELTA]My custom multi-player Godwars[COOLER DEN EVER][DELTA][DELTA] 
    Mr DilIusion
    Guest
    Sum guy leeched dis from my html and took it. dis is real
    Purpose: To create a timed multi-player minigame, my own version of Godwars
    Difficulty: 6, this may require heavy modification to work on your server, so be sure to back it up.
    Assumed Knowledge: How to copy and paste and how to not flame uselessly
    Server Base: Some old cheezescape
    Classes Modified: GodWar, GodwarWaitingRoom, NPCHandler, client, Location
    Required classes: Must have my Timer and Location classes:
    Timer: [Only registered and activated users can see links. ]
    Location: [Only registered and activated users can see links. ]

    Procedure

    Step 1: We need to create the new classes
    Create a new file called GodWar.java and put the following code in(This can be used/modified for other minigames):
    Code:
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Collections;
    
    /**
     * @author tj007razor
     * Description: Handle the running of godwars games
    **/
    
    public class GodWar
    {
    	// possible rewards from godwars
    	private static final int rewards[] = {995, 995, 995, 366, 366, 366, 995, 995, 995, 995, 366, 366, 366, 995, 1213, 1359, 1113, 1147, 1289, 1432, 1079, 1163, 1333, 1347, 1093, 1185, 1303, 1373, 1127, 1201, 1319, 3101, 4824, 1215, 6739, 3140, 1149, 1249, 1434, 4087, 7461, 4587, 3204, 4585, 1187, 1305, 1377, 4212, 4224, 7158, 4151, 4131, 6609, 1311, 1317, 1313, 2599, 3474, 1213, 1359, 1113, 1147, 1289, 1432, 1079, 1163, 1333, 1347, 1093, 1185, 1303, 1373, 1127, 1201, 1319, 3101, 4824, 1215, 6739, 3140, 1149, 1249, 1434, 4087, 7461, 4587, 3204, 4585, 1187, 1305, 1377, 4212, 4224, 7158, 4151, 4131 /* ADD GODSWORDS/OTHER GODWARS SPECIFIC REWARDS HERE */};
    	
    	// the godwar instance
    	public static GodWar war = new GodWar();
    	
    	private Timer gwTimer; // timer for time left in the war
    	private List<Player> inGame; // list of players currently in the godwar
    	private int kills; // current kills team has recieved
    	private boolean bossesKilled[]; // keeps track of whether the 2 bosses have been killed yet
    	
    	// initialize the GodWar instance variables
    	public GodWar()
    	{
    		gwTimer = new Timer();
    		inGame = Collections.synchronizedList(new LinkedList<Player>());
    		kills = 0;
    		bossesKilled = new boolean[2];
    	}
    	
    	// start game by making the timer active
    	public void startGame()
    	{
    		gwTimer.setTimeToRun(60);
    		gwTimer.setActive(true);
    	}
    	
    	// return the amount of time left in the game
    	public int getTimeLeft()
    	{
    		return gwTimer.getTimeLeft();
    	}
    	
    	// return if the game is active
    	public boolean isActive()
    	{
    		return gwTimer.isActive();
    	}
    	
    	// add a player to the list if there's less than 10 people
    	public boolean addPlayer(Player p)
    	{
    		if (inGame.size() < 10)
    			inGame.add(p);
    		return (inGame.size() < 10);
    	}
    	
    	// check if player is in the godwar
    	public boolean isInGw(Player p)
    	{
    		return inGame.contains(p);
    	}
    	
    	// check if player is in the godwar area
    	public boolean isInGwArea(Player p)
    	{
    		if (p.absY >= 9340 && p.absY <= 9415 && p.absX >= 3195 && p.absX <= 3305)
    			return true;
    		return false;
    	}
    	
    	// kill player in the godwar(remove from list)
    	public void killPlayer(Player p)
    	{
    		// "kill" player but they just teleport away without losing items
    		p.updateRequired = true;
    		p.appearanceUpdateRequired = true;
    		((client)p).resetBar();
    		((client)p).sendMessage("Oh dear, you died and lost the godwar! You can no longer get a reward.");
    		((client)p).teleportTo(Location.HOME);
    		((client)p).DeadStats();
    		((client)p).ResetAttack();
    		((client)p).ResetAttackNPC();
    		((client)p).actionTimer = 0;
    		((client)p).NewHP = ((client)p).getLevelForXP(((client)p).playerXP[3]);
    		((client)p).setSkillLevel(3, ((client)p).getLevelForXP(((client)p).playerXP[3]), ((client)p).playerXP[p.playerHitpoints]);
    		((client)p).playerLevel[3] = ((client)p).getLevelForXP(((client)p).playerXP[3]);
    		inGame.remove(p);
    		((client)p).sendFrame126("", 6569);
    		((client)p).currentHealth = ((client)p).getLevelForXP(((client)p).playerXP[3]);
    		((client)p).hitDiff = 0;	
    		p.updateRequired = true;
    		p.appearanceUpdateRequired = true;
    		
    		// tell players who died
    		synchronized(inGame)
    		{
    			for (int i = 0; i < inGame.size(); i++)
    			{
    				Player p1 = inGame.get(i);
    				
    				if (p != null && p.isActive)
    				{
    					((client)p1).sendMessage("Player "+p.playerName+" has died! There are "+inGame.size()+" players left.");
    				}
    			}
    		}
    	}
    	
    	// adds a kill to the godwar
    	public void addKill()
    	{
    		if (kills < 50) // 50 kill max to prevent people from staying in all day
    		{
    			kills++;
    			gwTimer.setTimeToRun(gwTimer.getTimeLeft() + 10);
    		}
    	}
    	
    	// when the team kills a boss
    	public void bossKill(int index)
    	{
    		if (!bossesKilled[index])
    		{
    			if (kills < 50) // 50 kill max to prevent people from staying in all day
    			{
    				kills++;
    				gwTimer.setTimeToRun(gwTimer.getTimeLeft() + 30);
    			}
    			bossesKilled[index] = true;
    		}
    		if (bossesKilled[0] && bossesKilled[1]) // both bosses killed, players win
    			winGame();
    	}
    	
    	// "process" of the godwar
    	public void process()
    	{
    		if (gwTimer.isActive())
    		{
    			if (gwTimer.stop()) // ran out of time
    			{
    				resetGW();
    				return;
    			}
    			printStatus();
    		}
    	}
    	
    	// players win the game and reset
    	public void winGame()
    	{
    		synchronized(inGame)
    		{
    			// teleport each player in turn and give drop if deemed as needing one
    			for (int i = 0; i < inGame.size(); i++)
    			{
    				Player p = inGame.get(i);
    				
    				if (p != null && p.isActive)
    				{
    					((client)p).teleportTo(Location.HOME);
    					((client)p).sendFrame126("", 6569);
    					((client)p).sendMessage("You have won the Godwar!");
    					((client)p).ancPts += 500;
    					
    					if (kills >= 10)
    					{
    						double dropChance = 1500 * 1/((kills*kills) + 1) + 1;
    						if (server.random.nextInt((int)dropChance) == 0)
    						{
    							int index = server.random.nextInt(rewards.length);
    							if (index <= 13) // coins or bass
    								((client)p).addItem(rewards[index], server.random.nextInt(500));
    							else
    								((client)p).addItem(rewards[index], 1);
    						}
    						else
    							((client)p).sendMessage("...and got nothing!");
    					}
    					else
    						((client)p).sendMessage("...however your team failed to reach the 10 kill threshold and you got nothing.");
    				}
    			}
    		}
    		
    		// reset gw vars
    		gwTimer.setActive(false);
    		inGame = Collections.synchronizedList(new LinkedList<Player>());
    		kills = 0;
    		bossesKilled = new boolean[2];
    	}
    	
    	// reset godwars in preparation for a new game
    	private void resetGW()
    	{
    		synchronized(inGame)
    		{
    			// teleport each player in turn away from godwars
    			for (int i = 0; i < inGame.size(); i++)
    			{
    				Player p = inGame.get(i);
    				
    				if (p != null && p.isActive)
    				{
    					((client)p).sendFrame126("", 6569);
    					((client)p).teleportTo(Location.HOME);
    					((client)p).sendMessage("You have lost the Godwar!");
    				}
    			}
    		}
    		
    		// reset gw vars
    		gwTimer.setActive(false);
    		inGame = Collections.synchronizedList(new LinkedList<Player>());
    		kills = 0;
    		bossesKilled = new boolean[2];
    	}
    	
    		
    	// print the status of the current godwar on each players screen
    	private void printStatus()
    	{
    		synchronized(inGame)
    		{
    			for (int i = 0; i < inGame.size(); i++)
    			{
    				Player p = inGame.get(i);
    				
    				if (p == null || !p.isActive || !isInGwArea(p))
    					inGame.remove(inGame.indexOf(p));
    				else
    				{
    					// print info on time left and player's drop chance to the screen
    					String line = "@[email protected]: ";
    					double dropChance = 1500 * 1/((kills*kills) + 1) + 1;
    					
    					if (kills < 10) // below 10 kill threshold, no drop
    						line += kills+" Time left: "+gwTimer.getTimeLeft()+" seconds : Chance of drop: 0";
    					else if (kills == 50) // max kills, print drop chance
    						line += "@[email protected]@[email protected] Time left: "+gwTimer.getTimeLeft()+" seconds : Chance of drop: 1/"+((int)dropChance);
    					else // x kills, drop chance
    						line += "@[email protected]"+kills+"@[email protected] Time left: "+gwTimer.getTimeLeft()+" seconds : Chance of drop: 1/"+((int)dropChance);
    					
    					((client)p).sendFrame126(line, 6569);
    				}
    			}
    		}
    	}
    }
    Next create a file named GodwarWaitingRoom.java and put the following in:
    Code:
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Collections;
    
    /**
     * @author tj007razor
     * Description: Handle the waiting room for godwars
    **/
    
    public class GodwarWaitingRoom
    {
    	// the godwar instance
    	public static GodwarWaitingRoom waiting = new GodwarWaitingRoom();
    	
    	// timer for game to start
    	private static Timer waitTimer;
    	
    	// list of players currently in the waiting room
    	private List<Player> inWait;
    	
    	// initialize the GodWar instance variables
    	public GodwarWaitingRoom()
    	{
    		waitTimer = new Timer();
    		inWait = Collections.synchronizedList(new LinkedList<Player>());
    	}
    	
    	// add a player to the list if there's less than 10 people
    	public void addPlayer(Player p)
    	{
    		if (inWait.contains(p))
    			((client)p).sendMessage("You are already in the waiting room!");
    		else
    		{
    			Location newLoc = new Location(Location.GW_WAIT.getXCoord()+server.random.nextInt(5), Location.GW_WAIT.getYCoord()+server.random.nextInt(5), Location.GW_WAIT.getHeight());
    			((client)p).teleportTo(newLoc);
    			((client)p).sendMessage("Please wait for the next game to start!");
    			
    			// show info on the game
    			String info[] = 
    			{
    				"-5 players needed, up to 10 can go in",
    				"-Probability of drop is based on kills",
    				"---10 kills min for drop",
    				"---50 kills max",
    				"-Kill both bosses in center to win",
    				"-Kills gain you 10 seconds of time",
    				"-You do NOT lose items in the war."
    			};
    			((client)p).showMenu("@[email protected] info", info);
    			inWait.add(p);
    		}
    	}
    	
    	// check if player is in the waiting room
    	public boolean isInWait(Player p)
    	{
    		return inWait.contains(p);
    	}
    	
    	// check if player is in the godwar area
    	private boolean isInWaitArea(Player p)
    	{
    		if (p.absY >= 9360 && p.absY <= 9394 && p.absX >= 3306 && p.absX <= 3326)
    			return true;
    		return false;
    	}
    	
    	//remove player if they leave the room
    	private void checkWaitArea(Player p)
    	{
    		if (!isInWaitArea(p))
    		{
    			((client)p).sendMessage("You have been removed from the waiting room.");
    			inWait.remove(inWait.indexOf(p));
    			((client)p).sendFrame126("", 6569);
    		}
    	}
    	
    	// "process" of the waiting room
    	public void process()
    	{
    		printStatus();
    		if (!GodWar.war.isActive())
    		{
    			// with enough players and no game going on, activate 20 second buffer for next game
    			if (inWait.size() >= 5 && !waitTimer.isActive())
    			{
    				waitTimer.setTimeToRun(20);
    				waitTimer.setActive(true);
    			}
    			
    			// 20 seconds is up, start the game
    			else if (waitTimer.isActive() && waitTimer.stop())
    			{
    				startGodwar();
    				waitTimer.setActive(false);
    			}
    		}
    	}
    	
    	// add players and start godwar game
    	private void startGodwar()
    	{
    		GodWar.war.startGame();
    		synchronized(inWait)
    		{
    			for (int i = 0; i < inWait.size(); i++)
    			{
    				Player p = inWait.get(i);
    				
    				if (!(p == null) && p.isActive)
    				{
    					if (!GodWar.war.addPlayer(p))
    						((client)p).sendMessage("Godwars is full. You will be added next game.");
    					else
    					{
    						((client)p).sendMessage("You have entered the Godwar!");
    						((client)p).teleportTo(Location.GODWAR);
    						inWait.set(inWait.indexOf(p), null);
    					}
    				}
    			}
    		}
    	}
    	
    		
    	// print the status of the current godwar on each players screen
    	private void printStatus()
    	{
    		synchronized(inWait)
    		{
    			for (int i = 0; i < inWait.size(); i++)
    			{
    				Player p = inWait.get(i);
    				
    				if (p == null || !p.isActive)
    					inWait.remove(inWait.indexOf(p));
    				else
    				{
    					checkWaitArea(p);
    					if (waitTimer.isActive() && !waitTimer.stop())
    					{
    						((client)p).sendFrame126("@[email protected] game starts in: "+waitTimer.getTimeLeft()+" seconds. Players: " + inWait.size() + "/10", 6569);
    					}
    					else
    					{
    						if (inWait.size() < 5)
    						{
    							if (GodWar.war.isActive())
    								((client)p).sendFrame126("@[email protected] more players...(Have "+inWait.size()+", need 5) Game ends in: " + GodWar.war.getTimeLeft() + " seconds", 6569);
    							else
    								((client)p).sendFrame126("@[email protected] more players...(Have "+inWait.size()+", need 5)", 6569);
    						}
    						else
    							((client)p).sendFrame126("@[email protected] game ends in: " + GodWar.war.getTimeLeft() + " seconds", 6569);
    					}
    				}
    			}
    		}
    	}
    }
    Step 2: Now we need to add the NPCs adding to kill-count, I used Fire Giants
    In NPCHandler.java find the public void MonsterDropItem method and add:


    Step 3: Now we modify the client class
    In client.java add this command:
    Code:
    	if (command.equalsIgnoreCase("gw") || command.equalsIgnoreCase("godwars")) {
    		GodwarWaitingRoom.waiting.addPlayer(this);
        }
    and in your process method, add the following:
    Code:
    		// kick players to home when in godwars but no the game running or add them to the game
    		if (GodWar.war.isInGwArea(this) && !GodWar.war.isInGw(this))
    		{
    			if (!GodWar.war.isActive())
    			{
    				teleportTo(Location.HOME);
    				sendMessage("You are not part of the Godwar");
    			}
    			else if (GodWar.war.isActive() && GodWar.war.addPlayer(this))
    			{
    				sendMessage("You joined the Godwar effort!");
    			}
    			else
    			{
    				teleportTo(Location.HOME);
    				sendMessage("You are not part of the Godwar");
    			}
    		}
    Now find ApplyDead(); and change it to
    Code:
    			if (GodWar.war.isInGw(this))
    			{
    				GodWar.war.killPlayer(this);
    			}
    			else
    				ApplyDead();
    You will also need this method:
    Code:
    	// tj007razor: print an array of text lines onto a menu
    	public void showMenu(String title, String[] text) {
    		clearQuestInterface();
    		sendQuest(title, 8144);
    		
    		for(int i = 8147; i < 8147+text.length; i++) {
    			sendQuest(text[i-8147], i);
    		}
    		sendQuestSomething(8143);
    		showInterface(8134);
    		flushOutStream();
    	}
    Step 4: Now we add the spawns
    In autospawn.cfg, add the following:
    Code:
    spawn = BOSS ID1 HERE	3249	9367	0	0	0	0	0	1	Godwars boss 1
    spawn = 1585	3274	9357	0	0	0	0	0	1	God fire giant
    spawn = 1585	3275	9379	0	0	0	0	0	1	God fire giant
    spawn = 1585	3262	9399	0	0	0	0	0	1	God fire giant
    spawn = 1585	3260	9376	0	0	0	0	0	1	God fire giant
    spawn = 1585	3250	9348	0	0	0	0	0	1	God fire giant
    spawn = 1585	3238	9366	0	0	0	0	0	1	God fire giant
    spawn = 1585	3273	9389	0	0	0	0	0	1	God fire giant
    spawn = 1585	3258	9388	0	0	0	0	0	1	God fire giant
    spawn = 1585	3245	9349	0	0	0	0	0	1	God fire giant
    spawn = 1585	3234	9363	0	0	0	0	0	1	God fire giant
    spawn = 1585	3284	9356	0	0	0	0	0	1	God fire giant
    spawn = 1585	3256	9392	0	0	0	0	0	1	God fire giant
    spawn = 1585	3290	9365	0	0	0	0	0	1	God fire giant
    spawn = 1585	3235	9359	0	0	0	0	0	1	God fire giant
    spawn = 1585	3228	9355	0	0	0	0	0	1	God fire giant
    spawn = 1585	3231	9368	0	0	0	0	0	1	God fire giant
    spawn = 1585	3235	9371	0	0	0	0	0	1	God fire giant
    spawn = 1585	3249	9400	0	0	0	0	0	1	God fire giant
    spawn = 1585	3235	9401	0	0	0	0	0	1	God fire giant
    spawn = 1585	3239	9384	0	0	0	0	0	1	God fire giant
    spawn = 1585	3261	9364	0	0	0	0	0	1	God fire giant
    spawn = 1585	3260	9366	0	0	0	0	0	1	God fire giant
    spawn = 1585	3256	9351	0	0	0	0	0	1	God fire giant
    spawn = 1585	3245	9360	0	0	0	0	0	1	God fire giant
    spawn = 1585	3245	9368	0	0	0	0	0	1	God fire giant
    spawn = 1585	3245	9365	0	0	0	0	0	1	God fire giant
    spawn = BOSS ID2 HERE	3249	9359	0	0	0	0	0	1	Godwars boss 2
    Step 5: Finally we add the Locations
    In Location.java, add these constants:
    Code:
    	public static final Location GW_WAIT = new Location(3315, 9376, 0); // Godwars waiting room Location
    	public static final Location GODWAR = new Location(3302, 9373, 0); // Godwars Location

    Credits: Me

    Video: [Only registered and activated users can see links. ]

    Picture:


    You need to add godswords and such to the rewards array and you need to put the ID for the godwars bosses in yourself.
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Sep 2009
    Posts
    1,723
    Thanks given
    45
    Thanks received
    81
    Rep Power
    269
    Leeched


    Web Hosting | VPS | CDN | DDoS Protected Solutions
    Reply With Quote  
     

  3. #3  
    Mr DilIusion
    Guest
    no he leeched me an he took my php files toget it so you leeched it not me.
    Reply With Quote  
     

  4. #4  
    Mr DilIusion
    Guest
    and then he went to play on my computer he fried my monitor pixels
    Reply With Quote  
     

  5. #5  
    Registered Member

    Join Date
    Sep 2009
    Posts
    1,723
    Thanks given
    45
    Thanks received
    81
    Rep Power
    269
    Mr Dillusion is Online
    Registered Member





    Posts: 550
    Thanks: 0
    Thanked 4 Times in 3 Posts
    Join Date: Nov 2008
    Age: 18
    Rep Power: 174


    and
    Mr DilIusion is Online
    Registered Member



    Posts: 10
    Thanks: 0
    Thanked 0 Times in 0 Posts
    Join Date: Dec 2009
    Rep Power: 1

    fail much


    Web Hosting | VPS | CDN | DDoS Protected Solutions
    Reply With Quote  
     

  6. #6  
    winlose
    Guest
    Mr DilIusion, you FAIL. stop trying to credit yourself for others work, and stop making lame excuses.put credits where they belong. and by credits i mean the real person who you stole this from.and by "real" you have no posts compaired to him.
    Reply With Quote  
     

  7. #7  
    sup3rman
    Guest
    leeched?
    Reply With Quote  
     

  8. #8  
    🛠️ Actually Knows Programming 🛠️
    Puremin0rez's Avatar
    Join Date
    May 2008
    Age
    27
    Posts
    137
    Thanks given
    14
    Thanks received
    26
    Rep Power
    33
    I love how you left the @author Tj007razor in there.

    .... not to mention your impersonating the real Mr. Dillusion.
    - With Love, Puremin0rez 💝
    Reply With Quote  
     

  9. #9  
    Totally Pro

    Fubergen's Avatar
    Join Date
    Nov 2007
    Age
    28
    Posts
    1,026
    Thanks given
    24
    Thanks received
    14
    Rep Power
    310
    100% leeched off tj007razor's tutorial. + you need to convert it to make work with delta. This tutorial wont work in delta without doing converts ....



    advertising without affiliate is rude
    Reply With Quote  
     

  10. #10  
    Registered Member Sheddy's Avatar
    Join Date
    Jul 2009
    Age
    28
    Posts
    1,041
    Thanks given
    52
    Thanks received
    87
    Rep Power
    52
    Sum guy leeched dis from my html and took it. dis is real
    Lol at this. Learn grammar and if your the some guy then yes you did leech from tj007razor's post. Think...if his post is older then yours how did he leech? Lol.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •