Thread: Free For All Minigame

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 Free For All Minigame 
    Banned

    Join Date
    Dec 2014
    Posts
    281
    Thanks given
    200
    Thanks received
    116
    Rep Power
    0
    So I wrote this minigame up for RuneUnity back when I was still a developer on it, and then one of the owners/devs decided to sell it to other servers without my permission. It ended up getting leaked so might as well release it.


    Btw the code is shit as it was written for ruse's minigame system. This whole server was half-assed and the only thing at mind was trying to get everything done soon. Would not recommend using it unless you plan on editing it heavily, but it works.
    Code:
    package com.arlania.world.content.minigames.impl;
    
    import com.arlania.GameSettings;
    import com.arlania.model.Flag;
    import com.arlania.model.Item;
    import com.arlania.model.MagicSpellbook;
    import com.arlania.model.Position;
    import com.arlania.model.Prayerbook;
    import com.arlania.model.Skill;
    import com.arlania.model.container.impl.Equipment;
    import com.arlania.net.packet.impl.EquipPacketListener;
    import com.arlania.util.Misc;
    import com.arlania.world.World;
    import com.arlania.world.content.BonusManager;
    import com.arlania.world.content.skill.SkillManager;
    import com.arlania.world.content.skill.SkillManager.Skills;
    import com.arlania.world.entity.impl.player.Player;
    import java.util.HashMap;
    import java.util.Map;
    
    /**
     * 
     * @author _Lev518
     *
     */
    
    public class FreeForAll {
    	public static int TOTAL_PLAYERS = 0;
    	private static int PLAYERS_IN_LOBBY = 0;
    
    	/**
    	 * @note Stores player and State
    	 */
    	public static Map<Player, String> playerMap = new HashMap<Player, String>();
    	public static Map<Player, String> playersInGame = new HashMap<Player, String>();
    	public static final String PLAYING = "PLAYING";
    	public static final String WAITING = "WAITING";
    	public String type = "";
    	public static boolean pure = false;
    	public int[][] pureInv = new int[][] { { Equipment.HEAD_SLOT, 1153 }, { Equipment.CAPE_SLOT, 10499 },
    			{ Equipment.AMULET_SLOT, 1725 }, { Equipment.WEAPON_SLOT, 4587 }, { Equipment.BODY_SLOT, 1129 },
    			{ Equipment.SHIELD_SLOT, 1540 }, { Equipment.LEG_SLOT, 2497 }, { Equipment.HANDS_SLOT, 7459 },
    			{ Equipment.FEET_SLOT, 3105 }, { Equipment.RING_SLOT, 2550 }, { Equipment.AMMUNITION_SLOT, 9244 } };
    	public static boolean brid = false;
    	public static boolean dharok = false;
    	private static boolean gameRunning = false;
    	private static boolean eventRunning = false;
    	private static int waitTimer = 150;
    	public static int[][] coordinates = { { 2265, 4684, 4 }, { 2261, 4699, 4 }, { 2282, 4706, 4 }, { 2282, 4689, 4 } };
    
    	public static String getState(Player player) {
    		return playerMap.get(player);
    	}
    
    	public static void saveOldStats(Player player) {
    		Skills currentSkills = player.getSkillManager().getSkills();
    		player.oldSkillLevels = currentSkills.level;
    		player.oldSkillXP = currentSkills.experience;
    		player.oldSkillMaxLevels = currentSkills.maxLevel;
    	}
    
    	public static void startGame() {
    		for (Player player : playerMap.keySet()) {
    			eventRunning = false;
    			gameRunning = true;
    			player.getPA().closeAllWindows();
    			saveOldStats(player);
    			player.getSkillManager().newSkillManager();
    			updateSkills(player);
    			if (pure) {
    				player.getSkillManager().setMaxLevel(Skill.ATTACK, 40).setMaxLevel(Skill.STRENGTH, 99)
    						.setMaxLevel(Skill.RANGED, 99).setMaxLevel(Skill.MAGIC, 99)
    						.setMaxLevel(Skill.CONSTITUTION, 990);
    				for (Skill skill : Skill.values()) {
    					player.getSkillManager().setCurrentLevel(skill, player.getSkillManager().getMaxLevel(skill))
    							.setExperience(skill,
    									SkillManager.getExperienceForLevel(player.getSkillManager().getMaxLevel(skill)));
    				}
    				player.getInventory().add(1319, 1);
    				player.getInventory().add(2440, 1);
    				player.getInventory().add(2444, 1);
    				player.getInventory().add(379, 25);
    				player.getEquipment().set(Equipment.HEAD_SLOT, new Item(1169, 1));
    				player.getEquipment().set(Equipment.AMMUNITION_SLOT, new Item(890, 1000));
    				player.getEquipment().set(Equipment.CAPE_SLOT, new Item(15345, 1));
    				player.getEquipment().set(Equipment.AMULET_SLOT, new Item(1725, 1));
    				player.getEquipment().set(Equipment.WEAPON_SLOT, new Item(853, 1));
    				player.getEquipment().set(Equipment.BODY_SLOT, new Item(1129, 1));
    				player.getEquipment().set(Equipment.LEG_SLOT, new Item(1099, 1));
    				player.getEquipment().set(Equipment.HANDS_SLOT, new Item(1065, 1));
    				player.getEquipment().set(Equipment.FEET_SLOT, new Item(1061, 1));
    				player.setPrayerbook(Prayerbook.NORMAL);
    				player.getEquipment().refreshItems();
    				player.getUpdateFlag().flag(Flag.APPEARANCE);
    				EquipPacketListener.resetWeapon(player);
    				BonusManager.update(player);
    			} else if (brid) {
    				player.getSkillManager().setMaxLevel(Skill.ATTACK, 99).setMaxLevel(Skill.STRENGTH, 99)
    						.setMaxLevel(Skill.RANGED, 99).setMaxLevel(Skill.MAGIC, 99).setMaxLevel(Skill.DEFENCE, 99)
    						.setMaxLevel(Skill.PRAYER, 990).setMaxLevel(Skill.CONSTITUTION, 990);
    				for (Skill skill : Skill.values()) {
    					player.getSkillManager().setCurrentLevel(skill, player.getSkillManager().getMaxLevel(skill))
    							.setExperience(skill,
    									SkillManager.getExperienceForLevel(player.getSkillManager().getMaxLevel(skill)));
    				}
    				player.getInventory().add(4151, 1);
    				player.getInventory().add(4722, 1);
    				player.getInventory().add(19111, 1);
    				player.getInventory().add(14484, 1);
    				player.getInventory().add(10551, 1);
    				player.getInventory().add(11732, 1);
    				player.getInventory().add(13262, 1);
    				player.getInventory().add(4736, 1);
    				player.getInventory().add(2436, 1);
    				player.getInventory().add(2440, 1);
    				player.getInventory().add(3024, 2);
    				player.getInventory().add(385, 13);
    				player.getInventory().add(560, 20000);
    				player.getInventory().add(565, 20000);
    				player.getInventory().add(555, 20000);
    				player.getEquipment().set(Equipment.HEAD_SLOT, new Item(10828, 1));
    				player.getEquipment().set(Equipment.CAPE_SLOT, new Item(10636, 1));
    				player.getEquipment().set(Equipment.AMULET_SLOT, new Item(6585, 1));
    				player.getEquipment().set(Equipment.WEAPON_SLOT, new Item(15486, 1));
    				player.getEquipment().set(Equipment.BODY_SLOT, new Item(4712, 1));
    				player.getEquipment().set(Equipment.LEG_SLOT, new Item(4714, 1));
    				player.getEquipment().set(Equipment.SHIELD_SLOT, new Item(6889, 1));
    				player.getEquipment().set(Equipment.HANDS_SLOT, new Item(7462, 1));
    				player.getEquipment().set(Equipment.FEET_SLOT, new Item(6920, 1));
    				player.getEquipment().set(Equipment.RING_SLOT, new Item(2550, 1));
    				player.setSpellbook(MagicSpellbook.ANCIENT);
    				player.setPrayerbook(Prayerbook.NORMAL);
    				player.getPacketSender().sendTabInterface(GameSettings.MAGIC_TAB,
    						player.getSpellbook().getInterfaceId());
    				player.getEquipment().refreshItems();
    				player.getUpdateFlag().flag(Flag.APPEARANCE);
    				EquipPacketListener.resetWeapon(player);
    				BonusManager.update(player);
    			} else if (dharok) {
    				player.getSkillManager().setMaxLevel(Skill.ATTACK, 99).setMaxLevel(Skill.STRENGTH, 99)
    						.setMaxLevel(Skill.RANGED, 99).setMaxLevel(Skill.MAGIC, 99).setMaxLevel(Skill.DEFENCE, 99)
    						.setMaxLevel(Skill.PRAYER, 990).setMaxLevel(Skill.CONSTITUTION, 990);
    				for (Skill skill : Skill.values()) {
    					player.getSkillManager().setCurrentLevel(skill, player.getSkillManager().getMaxLevel(skill))
    							.setExperience(skill,
    									SkillManager.getExperienceForLevel(player.getSkillManager().getMaxLevel(skill)));
    				}
    				player.getInventory().add(14484, 1);
    				player.getInventory().add(2436, 1);
    				player.getInventory().add(2440, 1);
    				player.getInventory().add(6685, 1);
    				player.getInventory().add(4718, 1);
    				player.getInventory().add(3024, 2);
    				player.getInventory().add(6685, 1);
    				player.getInventory().add(385, 17);
    				player.getInventory().add(560, 20000);
    				player.getInventory().add(9075, 20000);
    				player.getInventory().add(557, 20000);
    				player.getEquipment().set(Equipment.HEAD_SLOT, new Item(4716, 1));
    				player.getEquipment().set(Equipment.CAPE_SLOT, new Item(19111, 1));
    				player.getEquipment().set(Equipment.AMULET_SLOT, new Item(6585, 1));
    				player.getEquipment().set(Equipment.WEAPON_SLOT, new Item(4151, 1));
    				player.getEquipment().set(Equipment.BODY_SLOT, new Item(4720, 1));
    				player.getEquipment().set(Equipment.LEG_SLOT, new Item(4722, 1));
    				player.getEquipment().set(Equipment.SHIELD_SLOT, new Item(13262, 1));
    				player.getEquipment().set(Equipment.HANDS_SLOT, new Item(7462, 1));
    				player.getEquipment().set(Equipment.FEET_SLOT, new Item(11732, 1));
    				player.getEquipment().set(Equipment.RING_SLOT, new Item(6737, 1));
    				player.setSpellbook(MagicSpellbook.LUNAR);
    				player.setPrayerbook(Prayerbook.NORMAL);
    				player.getPacketSender().sendTabInterface(GameSettings.PRAYER_TAB,
    						player.getPrayerbook().getInterfaceId());
    				player.getPacketSender().sendTabInterface(GameSettings.MAGIC_TAB,
    						player.getSpellbook().getInterfaceId());
    				player.getEquipment().refreshItems();
    				player.getUpdateFlag().flag(Flag.APPEARANCE);
    				EquipPacketListener.resetWeapon(player);
    				BonusManager.update(player);
    			}
    			movePlayerToArena(player);
    			player.inFFALobby = false;
    			player.inFFA = true;
    			player.getPacketSender().sendInteractionOption("Attack", 2, true);
    			waitTimer = 100;
    		}
    	}
    
    	public static void removePlayer(Player c) {
    		playerMap.remove(c);
    	}
    
    	public static boolean checkEndGame() {
    		if (gameRunning) {
    
    			if (playerMap.size() <= 1) {
    				return true;
    			}
    		}
    		return false;
    	}
    
    	public static void sequence() {
    		if (gameRunning) {
    
    			if (checkEndGame()) {
    				endGame();
    				return;
    			}
    			return;
    		}
    
    		if (!eventRunning)
    			return;
    
    		if (waitTimer > 0) {
    			waitTimer--;
    			if (waitTimer % 100 == 0 && waitTimer > 0)
    				World.sendMessage("@or2@[FFA] " + waitTimer + " seconds until FFA starts!" + " Join now @ ::ffa");
    		}
    		updateGameInterface();
    		if (waitTimer <= 0) {
    			if (!gameRunning)
    				startGame();
    		}
    	}
    
    	private static void updateGameInterface() {
    		for (Player p : playerMap.keySet()) {
    			if (p == null)
    				continue;
    
    			String state = getState(p);
    			if (state != null && state.equals(WAITING)) {
    				p.getPacketSender().sendString(21006, "Time till start: " + waitTimer + "");
    				p.getPacketSender().sendString(21007, "Players Ready: " + PLAYERS_IN_LOBBY + "");
    				p.getPacketSender().sendString(21009, "");
    			}
    		}
    	}
    
    	public static boolean checkItems(Player c) {
    		if (c.getInventory().getFreeSlots() != 28) {
    			return false;
    		}
    		for (int i = 0; i < 14; i++) {
    			if (c.getEquipment().get(i).getId() > 0)
    				return false;
    		}
    		return true;
    	}
    
    	public static void startEvent(String type) {
    		pure = false;
    		brid = false;
    		dharok = false;
    		if (!eventRunning) {
    			World.sendMessage("@or2@[FFA] A " + type + " FFA event has been started! Type ::ffa to join!");
    			if (type == "pure") {
    				pure = true;
    			} else if (type == "brid") {
    				brid = true;
    
    			} else {
    				dharok = true;
    			}
    			eventRunning = true;
    		}
    	}
    
    	private static void movePlayerToArena(Player p) {
    		int random = Misc.random(3);
    		p.moveTo(new Position(coordinates[random][0], coordinates[random][1], coordinates[random][2]));
    		PLAYERS_IN_LOBBY--;
    	}
    
    	public static void enterLobby(Player c) {
    		if (!eventRunning) {
    			c.sendMessage("There is no game available right now!");
    			return;
    		}
    		if (c.getSummoning().getSpawnTask() != null) {
    			c.sendMessage("You can not join ffa with a pet!");
    			return;
    		}
    		if (getState(c) == null) {
    			if (checkItems(c)) {
    				c.getPA().closeAllWindows();
    				playerMap.put(c, WAITING);
    				TOTAL_PLAYERS++;
    				PLAYERS_IN_LOBBY++;
    				c.inFFALobby = true;
    				c.moveTo(new Position(2223, 3799, 0));
    				c.sendMessage("Welcome to FFA!");
    			} else {
    				c.sendMessage("Bank all your items to play FFA!");
    			}
    		}
    	}
    
    	public static void updateSkills(Player player) {
    		for (Skill skill : Skill.values())
    			player.getSkillManager().updateSkill(skill);
    	}
    
    	public static void endGame() {
    		eventRunning = false;
    		gameRunning = false;
    		pure = false;
    		brid = false;
    		dharok = false;
    		for (Player p : playerMap.keySet()) {
    			p.sendMessage("You have won the game! PM a admin or owner for your reward!");
    			World.sendMessage(
    					"@or2@[FFA] @blu@" + Misc.formatPlayerName(p.getUsername()) + " @or2@has just won the FFA game!");
    			leaveGame(p);
    		}
    		playerMap.clear();
    	}
    
    	public static void leaveGame(Player c) {
    		c.getInventory().deleteAll();
    		c.getEquipment().deleteAll();
    		playerMap.remove(c);
    		c.getSkillManager().getSkills().level = c.oldSkillLevels;
    		c.getSkillManager().getSkills().experience = c.oldSkillXP;
    		c.getSkillManager().getSkills().maxLevel = c.oldSkillMaxLevels;
    		c.getUpdateFlag().flag(Flag.ANIMATION);
    		c.getEquipment().refreshItems();
    		updateSkills(c);
    		c.moveTo(GameSettings.DEFAULT_POSITION.copy());
    		c.inFFA = false;
    		c.getPacketSender().sendInteractionOption("null", 2, true);
    		c.sendMessage("Thank you for participating in FFA!");
    	}
    }
    Here's a video of Sprad showcasing the FFA (FFA showcasing starts around 45 seconds)



    P.S: Not the best way to do it but it works.

    Credits:
    Me
    Reply With Quote  
     

  2. #2  
    love

    scoob's Avatar
    Join Date
    Oct 2015
    Age
    25
    Posts
    1,642
    Thanks given
    367
    Thanks received
    640
    Rep Power
    1559
    ❤ Sad it got leaked doe
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Feb 2017
    Posts
    34
    Thanks given
    10
    Thanks received
    11
    Rep Power
    26
    +1 -
    Reply With Quote  
     

  4. #4  
    Community Veteran

    Dexter Morgan's Avatar
    Join Date
    Nov 2008
    Age
    28
    Posts
    4,415
    Thanks given
    1,181
    Thanks received
    756
    Rep Power
    3098
    Consider abstraction, Immutable sets, final state, documenting your code, loops
    Reply With Quote  
     

  5. Thankful users:


  6. #5  
    Unfortunately we’re all human. Except me


    Join Date
    Aug 2011
    Posts
    926
    Thanks given
    539
    Thanks received
    439
    Rep Power
    601
    Arent you the one who leaked it? lol
    Reply With Quote  
     

  7. #6  
    Server Developer
    Argyros's Avatar
    Join Date
    Apr 2011
    Posts
    498
    Thanks given
    25
    Thanks received
    31
    Rep Power
    23
    Isn't this basically riot wars? lol.
    Reply With Quote  
     

  8. #7  
    Banned

    Join Date
    Dec 2014
    Posts
    281
    Thanks given
    200
    Thanks received
    116
    Rep Power
    0
    Quote Originally Posted by LukaFurlan View Post
    Arent you the one who leaked it? lol
    No. It was either Khalil or Harryl and both of them are denying it. It was most likely Harryl. Once I saw that it was leaked I released it on here.
    Reply With Quote  
     

  9. #8  
    What is a Java?

    Leon.'s Avatar
    Join Date
    Oct 2013
    Posts
    1,919
    Thanks given
    173
    Thanks received
    802
    Rep Power
    5000
    I dont understand why you would care about someone releasing this...
    This shouldn't take too long to code, and it's all over the place, lol.

    Attached image
    Attached image

    Reply With Quote  
     

  10. #9  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    975
    Thanks given
    688
    Thanks received
    455
    Rep Power
    727
    Code:
    	public static void updateSkills(Player player) {
    		player.getSkillManager().updateSkill(Skill.ATTACK)  ;
    		player.getSkillManager().updateSkill(Skill.AGILITY  );
    		player.getSkillManager().updateSkill(Skill.CONSTIT  UTION);
    		player.getSkillManager().updateSkill(Skill.CONSTRU  CTION);
    		player.getSkillManager().updateSkill(Skill.COOKING  );
    		player.getSkillManager().updateSkill(Skill.CRAFTIN  G);
    		player.getSkillManager().updateSkill(Skill.DEFENCE  );
    		player.getSkillManager().updateSkill(Skill.DUNGEON  EERING);
    		player.getSkillManager().updateSkill(Skill.FARMING  );
    		player.getSkillManager().updateSkill(Skill.FIREMAK  ING);
    		player.getSkillManager().updateSkill(Skill.FISHING  );
    		player.getSkillManager().updateSkill(Skill.FLETCHI  NG);
    		player.getSkillManager().updateSkill(Skill.HERBLOR  E);
    		player.getSkillManager().updateSkill(Skill.HUNTER)  ;
    		player.getSkillManager().updateSkill(Skill.MAGIC);
    		player.getSkillManager().updateSkill(Skill.MINING)  ;
    		player.getSkillManager().updateSkill(Skill.PRAYER)  ;
    		player.getSkillManager().updateSkill(Skill.RANGED)  ;
    		player.getSkillManager().updateSkill(Skill.RUNECRA  FTING);
    		player.getSkillManager().updateSkill(Skill.SLAYER)  ;
    		player.getSkillManager().updateSkill(Skill.SMITHIN  G);
    		player.getSkillManager().updateSkill(Skill.STRENGT  H);
    		player.getSkillManager().updateSkill(Skill.SUMMONI  NG);
    		player.getSkillManager().updateSkill(Skill.THIEVIN  G);
    		player.getSkillManager().updateSkill(Skill.WOODCUT  TING);
    	}
    omg haha
    Reply With Quote  
     

  11. Thankful users:


  12. #10  
    Banned

    Join Date
    Dec 2014
    Posts
    281
    Thanks given
    200
    Thanks received
    116
    Rep Power
    0
    Quote Originally Posted by Andys1814 View Post
    Code:
    	public static void updateSkills(Player player) {
    		player.getSkillManager().updateSkill(Skill.ATTACK)  ;
    		player.getSkillManager().updateSkill(Skill.AGILITY  );
    		player.getSkillManager().updateSkill(Skill.CONSTIT  UTION);
    		player.getSkillManager().updateSkill(Skill.CONSTRU  CTION);
    		player.getSkillManager().updateSkill(Skill.COOKING  );
    		player.getSkillManager().updateSkill(Skill.CRAFTIN  G);
    		player.getSkillManager().updateSkill(Skill.DEFENCE  );
    		player.getSkillManager().updateSkill(Skill.DUNGEON  EERING);
    		player.getSkillManager().updateSkill(Skill.FARMING  );
    		player.getSkillManager().updateSkill(Skill.FIREMAK  ING);
    		player.getSkillManager().updateSkill(Skill.FISHING  );
    		player.getSkillManager().updateSkill(Skill.FLETCHI  NG);
    		player.getSkillManager().updateSkill(Skill.HERBLOR  E);
    		player.getSkillManager().updateSkill(Skill.HUNTER)  ;
    		player.getSkillManager().updateSkill(Skill.MAGIC);
    		player.getSkillManager().updateSkill(Skill.MINING)  ;
    		player.getSkillManager().updateSkill(Skill.PRAYER)  ;
    		player.getSkillManager().updateSkill(Skill.RANGED)  ;
    		player.getSkillManager().updateSkill(Skill.RUNECRA  FTING);
    		player.getSkillManager().updateSkill(Skill.SLAYER)  ;
    		player.getSkillManager().updateSkill(Skill.SMITHIN  G);
    		player.getSkillManager().updateSkill(Skill.STRENGT  H);
    		player.getSkillManager().updateSkill(Skill.SUMMONI  NG);
    		player.getSkillManager().updateSkill(Skill.THIEVIN  G);
    		player.getSkillManager().updateSkill(Skill.WOODCUT  TING);
    	}
    omg haha
    This was written extremely poorly Only releasing because I don't want people making money off my work no matter how shit it is lol.

    Quote Originally Posted by Leon. View Post
    I dont understand why you would care about someone releasing this...
    This shouldn't take too long to code, and it's all over the place, lol.
    Yeah the entire server was half assed. The issue wasn't that someone released it the issue was that they were selling it and making money off it.
    Reply With Quote  
     

  13. Thankful users:


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

Similar Threads

  1. Basic Free For All Minigame[PI]
    By Aleksandr in forum Snippets
    Replies: 14
    Last Post: 05-12-2014, 02:02 PM
  2. RuneLive [Free for all spawn]
    By Affliction in forum Advertise
    Replies: 12
    Last Post: 03-04-2011, 12:03 PM
  3. How to make a ''free for all'' area
    By OFF YOUR TITS in forum Help
    Replies: 5
    Last Post: 04-22-2010, 05:58 PM
  4. Clanwars[Free for all][525]
    By Xx Jc xX in forum Help
    Replies: 1
    Last Post: 11-04-2009, 03:26 AM
  5. clan wars free for all
    By doobie in forum Requests
    Replies: 7
    Last Post: 07-17-2009, 02:46 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •