Thread: Pest Control bug?

Results 1 to 6 of 6
  1. #1 Pest Control bug? 
    Banned

    Join Date
    Jun 2013
    Posts
    938
    Thanks given
    462
    Thanks received
    171
    Rep Power
    0
    ok i was just checking out pest control when i came across this bug, when you finish pest control it just does this

    also the portals move and attack back and at the end they do dying emote
    pestcontrol.java
    Code:
    package server.model.minigames;
    
    import server.model.npcs.NPCHandler;
    import server.model.players.Client;
    import server.model.players.PlayerHandler;
    import server.Server;
    import java.util.HashMap;
    import java.util.Iterator;
    import server.util.Misc;
    
    /**
     * @author Harlan
     * Credits to Sanity
     */
    
    public class PestControl {
    
    	/**
    	 * how long the game is going for
    	 */
    	private final int GAME_TIMER = 200;
    	/**
    	 * how long before were put into the game from lobby
    	 */
    	private final int WAIT_TIMER = 60;
    	/**
    	 * How many players we need to start a game
    	 */
    	private final int PLAYERS_REQUIRED = 1;
    	/**
    	 * How many points a player should receive each game
    	 */
    	private final int POINT_REWARD = 8;
    	/**
    	 * How much health should the knight have
    	 */
    	private final int KNIGHTS_HEALTH = 200;
    	/**
    	 * Hashmap for the players in lobby
    	 */
    	private static HashMap<Client, Integer> waitingBoat = new HashMap<Client, Integer>();
    	/**
    	 * hashmap for the players in game
    	 */
    	private static HashMap<Client, Integer> gamePlayers = new HashMap<Client, Integer>();
    
    	private int gameTimer = -1;
    	private int waitTimer = 60;
    	public boolean gameStarted = false;
    
    	/**
    	 * Array used for storing the portals health
    	 */
    	public static int[] portalHealth = {
    		2000,
    		2000,
    		2000,
    		2000
    	};
    	/**
    	 * array used for storing the npcs used in the minigame
    	 * @order npcId, xSpawn, ySpawn, health
    	 */
    	private int[][] pcNPCData = {
    			{6142,2628,2591}, //portal
    			{6143,2680,2588}, //portal
    			{6144, 2669,2570}, //portal
    			{6145, 2645,2569}, //portal
    			{3782,2656,2592} //knight
    	};
    	/**
    	 * Process of the minigame handles game start / end
    	 */
    	public void process() {
    		try {
    			setInterface();
    			/**
    			 * handling the wait time in lobby, if timer is done then attempt to start game
    			 */
    			if (waitTimer > 0)
    				waitTimer--;
    			else if (waitTimer == 0)
    				startGame();
    			if (gameStarted && playersInGame() < 1)
    				endGame(false);
    			/**
    			 * if the game has started handle in game aspects
    			 */
    			if (gameTimer > 0 && gameStarted) {
    				gameTimer--;
    				setInterface();
    				if (allPortalsDead())
    					endGame(true);
    			} else if (gameTimer <= 0 && gameStarted)
    				endGame(false);
    		} catch (RuntimeException e) {
    			System.out.println("Failed to set process");
    			e.printStackTrace();
    		}
    	}
    	/**
    	 * Method we use for removing a player from the pc game
    	 * @param player
    	 */
    	public static void removePlayerGame(Client player) {
    		if (gamePlayers.containsKey(player)) {
    			player.getPA().movePlayer(2657, 2639, 0);
    			gamePlayers.remove(player);
    		}
    	}
    
    	/**
    	 * Setting the interfaces for the waiting lobby
    	 */
    
    
    	/**
    	 * Setting the interface for in game players
    	 */
    	private void setInterface() {
    				for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcBoat()) {
    					Client c = (Client) Server.playerHandler.players[j];
    					c.getPA().sendFrame126("Next Departure: "+waitTimer+"", 21006);
    					c.getPA().sendFrame126("Players Ready: "+playersInBoat()+"", 21007);
    					c.getPA().sendFrame126("(Need 3 to 25 players)", 21008);
    					c.getPA().sendFrame126("Pest Control Points: "+c.pcPoints+"", 21009);
    					c.getPA().sendFrame126("Next Departure: "+waitTimer+"", 21120);
    					c.getPA().sendFrame126("Players Ready: "+playersInBoat()+"", 21121);
    					c.getPA().sendFrame126("(Need 3 to 25 players)", 21122);
    					c.getPA().sendFrame126("Pest Control Points: "+c.pcPoints+"", 21123);
    				}
     				if (Server.playerHandler.players[j].inPcGame()) {
    					Client c = (Client) Server.playerHandler.players[j];
    					for (j = 0; j < Server.npcHandler.npcs.length; j++) {
    						if (Server.npcHandler.npcs[j] != null) {
    							if (Server.npcHandler.npcs[j].npcType == 6142 && Server.npcHandler.npcs[j].isDead)
    								c.getPA().sendFrame126("0", 21111);
    							else if (Server.npcHandler.npcs[j].npcType == 6142)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP/10 + "", 21111);
    							if (Server.npcHandler.npcs[j].npcType == 6143&& Server.npcHandler.npcs[j].isDead)
    								c.getPA().sendFrame126("0", 21112);
    							else if (Server.npcHandler.npcs[j].npcType == 6143)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP/10 + "", 21112);
    							if (Server.npcHandler.npcs[j].npcType == 6144&& Server.npcHandler.npcs[j].isDead)
    								c.getPA().sendFrame126("0", 21113);
    							else if (Server.npcHandler.npcs[j].npcType == 6144)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP/10 + "", 21113);
    							if (Server.npcHandler.npcs[j].npcType == 6145&& Server.npcHandler.npcs[j].isDead)
    								c.getPA().sendFrame126("0", 21114);
    							else if (Server.npcHandler.npcs[j].npcType == 6145)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP/10 + "", 21114);
    						}
    					}
    					c.getPA().sendFrame126("0", 21115);
    						if (c.pcDamage < 10) {
    c.getPA().sendFrame126("@red@"+c.pcDamage+".", 21116);
    	} else {
    c.getPA().sendFrame126("@gre@"+c.pcDamage+".", 21116);
    }
    					c.getPA().sendFrame126("Time remaining: "+gameTimer+"", 21117);
    				}
    			}
    		}
    	}
    	/***
    	 * Moving players to arena if there's enough players
    	 */
    	private void startGame() {
    		//if we dont have
    		if (playersInBoat() < PLAYERS_REQUIRED) {
    			waitTimer = WAIT_TIMER;
    			return;
    		}
    		for (int i = 0; i < portalHealth.length; i++)
    			portalHealth[i] = 2000;
    		gameTimer = GAME_TIMER;
    		waitTimer = -1;
    		spawnNpcs();
    		gameStarted = true;
    		Iterator<Client> iterator = waitingBoat.keySet().iterator();
    		while (iterator.hasNext()) {
    			Client player = iterator.next();
    			if (player == null) {
    				continue;
    			}
    			/*if(!player.PC_BOAT.containsPlayer(player) && waitingBoat.containsKey(player)) {
    				waitingBoat.remove(player);
    			}*/
    
    			player.getPA().movePlayer(2656+Misc.random3(3),2614-Misc.random3(4),0);
    			gamePlayers.put(player, 1);
    			player.sendMessage("@red@The Pest Control Game has begun!");
    		}
    		waitingBoat.clear();
    	}
    
    	/**
    	 * Checks how many players are in the waiting lobby
    	 * @return players waiting
    	 */
    	private int playersInBoat() {
    		int players = 0;
    		Iterator<Client> iterator = waitingBoat.keySet().iterator();
    		while (iterator.hasNext()) {
    			Client player = iterator.next();
    			if (player != null) {
    				players++;
    			}
    		}
    		return players;
    	}
    	/**
    	 * Checks how many players are in the game
    	 * @return players in the game
    	 */
    	private int playersInGame() {
    		int players = 0;
    		Iterator<Client> inGamePlayers = gamePlayers.keySet().iterator();
    		while (inGamePlayers.hasNext()) {
    			Client player = inGamePlayers.next();
    			if (player != null) {
    				players++;
    			}
    		}
    		return players;
    	}
    	/**
    	 * Ends the game
    	 * @param won
    	 */
    	
    	public void endGame(boolean won) {
    		gameTimer = -1;
    		waitTimer = WAIT_TIMER;
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcGame()) {
    					Client c = (Client)Server.playerHandler.players[j];
    					c.getPA().movePlayer(2657, 2639, 0);
    					if (won && c.pcDamage > 10) {
    						c.sendMessage("You have won the pest control game and have been awarded 4 pest control points.");
    						c.pcPoints += 4;
    						c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
    						c.playerLevel[5] = c.getLevelForXP(c.playerXP[5]);
    						c.specAmount = 10;
    						c.getItems().addItem(995, c.combatLevel * 50);
    						c.getPA().refreshSkill(3);
    						c.getPA().refreshSkill(5);
    					} else if (won) {
    						c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
    						c.playerLevel[5] = c.getLevelForXP(c.playerXP[5]);
    						c.specAmount = 10;
    						c.sendMessage("The void knights notice your lack of zeal.");
    						c.getPA().refreshSkill(3);
    						c.getPA().refreshSkill(5);
    					} else {
    						c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
    						c.playerLevel[5] = c.getLevelForXP(c.playerXP[5]);
    						c.specAmount = 10;
    						c.sendMessage("You failed to kill all the portals in 5 minutes and have not been awarded any points.");
    						c.getPA().refreshSkill(3);
    						c.getPA().refreshSkill(5);
    					}
    					c.pcDamage = 0;
    					c.getItems().addSpecialBar(c.playerEquipment[c.playerWeapon]);
    					c.getCombat().resetPrayers();
    				}			
    			}		
    		}
    
    		for (int j = 0; j < Server.npcHandler.npcs.length; j++) {
    			if (Server.npcHandler.npcs[j] != null) {
    				if (Server.npcHandler.npcs[j].npcType >= 6142 && Server.npcHandler.npcs[j].npcType <= 6145)
    					Server.npcHandler.npcs[j] = null;
    			}			
    		}
    	}
    
    	/**
    	 * Resets the game variables and map
    	 */
    	private void cleanUp() {
    		gameTimer = -1;
    		waitTimer = WAIT_TIMER;
    		gameStarted = false;
    		gamePlayers.clear();
    		/*
    		 * Removes the npcs from the game if any left over for whatever reason
    		 */
    		for (int i = 0; i < pcNPCData.length; i++){
    			for (int j = 0; j < NPCHandler.npcs.length; j++) {
    				if (NPCHandler.npcs[j] != null) {
    					if (NPCHandler.npcs[j].npcType == pcNPCData[i][0])
    						NPCHandler.npcs[j] = null;
    				}
    			}
    		}
    	}
    	/**
    	 * Cleans the player of any damage, loss they may of received
    	 */
    	private void cleanUpPlayer(Client player){
    		player.poisonDamage = 0;
    		player.getCombat().resetPrayers();
    		for (int i = 0; i < 24; i++) {
    			player.playerLevel[i] = player.getPA().getLevelForXP(player.playerXP[i]);
    			player.getPA().refreshSkill(i);
    		}
    		player.specAmount = 10;
    		player.pcDamage = 0;
    		player.getItems().addSpecialBar(player.playerEquipment[player.playerWeapon]);
    	}
    	/**
    	 * Checks if the portals are dead
    	 * @return players dead
    	 */
    	 public boolean allPortalsDead() {
    		int count = 0;
    		for (int j = 0; j < Server.npcHandler.npcs.length; j++) {
    			if (Server.npcHandler.npcs[j] != null) {
    				if (Server.npcHandler.npcs[j].npcType >= 6142 && Server.npcHandler.npcs[j].npcType <= 6145)
    					if (Server.npcHandler.npcs[j].isDead)
    						count++;
    			}			
    		}
    		return count >= 4;	
    	}
    /*	private boolean allPortalsDead() {
    		int count = 0;
    		for (int i = 0; i < portalHealth.length; i++) {
    			if (portalHealth[i] <= 0)
    				count++;
    		}
    		return count >= 4;
    	}
    */
    	/**
    	 * Moves a player out of the waiting boat
    	 * @param c
    	 */
    	public static void leaveWaitingBoat(Client c) {
    		if (waitingBoat.containsKey(c)) {
    			waitingBoat.remove(c);
    			c.getPA().movePlayer(2657,2639,0);
    		}
    	}
    
    	/**
    	 * Moves a player into the hash and into the lobby
    	 * @param player
    	 */
    	public static void addToWaitRoom(Client player) {
    		if (player != null) {
    			waitingBoat.put(player, 1);
    			player.sendMessage("You have joined the Pest Control boat.");
    			//player.getPA().walkableInterface(21119);
    			player.getPA().movePlayer(2661,2639,0);
    		}
    	}
    
    	/**
    	 * Checks if a player is in the game
    	 * @param player
    	 * @return
    	 */
    	public static boolean isInGame(Client player) {
    		return gamePlayers.containsKey(player);
    	}
    	/**
    	 * Checks if a player is in the pc boat (lobby)
    	 * @param player
    	 * @return
    	 */
    	public static boolean isInPcBoat(Client player) {
    		return waitingBoat.containsKey(player);
    	}
    
    	public static boolean npcIsPortal(int type) {
    		for (int i = 6142; i < 6146; i++) {
    			if (type == i)
    				return true;
    		}
    		return false;
    	}
    
    	private void spawnNpcs() {
    		for (int i = 0; i < pcNPCData.length; i++) {
    			NPCHandler.spawnNewNPC(pcNPCData[i][0],pcNPCData[i][1],pcNPCData[i][2],0,0,2000,0,0, 100, false);
    		}
    	}
    }
    and this is the error i get in cmd
    Code:
    [19/06/13 22:47]: java.lang.NullPointerException
    [19/06/13 22:47]:       at server.model.players.CombatAssistant.appendHit(Combat
    Assistant.java:1028)
    [19/06/13 22:47]:       at server.model.players.Client.process(Client.java:790)
    [19/06/13 22:47]:       at server.model.players.PlayerHandler.process(PlayerHand
    ler.java:138)
    [19/06/13 22:47]:       at server.Server.main(Server.java:160)
    this is line 160 of server.java
    Code:
    playerHandler.process();
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jun 2013
    Posts
    938
    Thanks given
    462
    Thanks received
    171
    Rep Power
    0
    bump
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2012
    Posts
    307
    Thanks given
    63
    Thanks received
    36
    Rep Power
    9
    Try to make the portals an object
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Jun 2013
    Posts
    938
    Thanks given
    462
    Thanks received
    171
    Rep Power
    0
    Quote Originally Posted by Fire Cape View Post
    PM me your password and I will assign you an official helper.
    huh? why would i want to give you my pass
    Reply With Quote  
     

  5. #5  
    Extreme Donator

    Join Date
    Jul 2011
    Posts
    546
    Thanks given
    31
    Thanks received
    18
    Rep Power
    39
    Quote Originally Posted by Fire Cape View Post
    PM me your password and I will assign you an official helper.
    Lol...

    This is actually a very simple fix. There are MANY guides on how to make npc's not attack back and how to make them not move. *they wouldnt move anyways if they didnt attack*
    Reply With Quote  
     

  6. #6  
    Donator
    Darkness's Avatar
    Join Date
    Nov 2012
    Age
    26
    Posts
    876
    Thanks given
    121
    Thanks received
    75
    Rep Power
    47
    Attached image
    Reply With Quote  
     


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. [PI] Pest Control Portals Bug
    By Zelix in forum Help
    Replies: 12
    Last Post: 07-27-2011, 09:34 PM
  2. [PI] Pest control bug
    By Zelix in forum Help
    Replies: 2
    Last Post: 06-11-2011, 07:13 PM
  3. DSPK Pest Control Bug
    By Ftw^ in forum Help
    Replies: 1
    Last Post: 03-15-2011, 03:25 PM
  4. PestCScape (Full pest control) Release
    By Sam Server in forum Downloads
    Replies: 87
    Last Post: 11-29-2010, 09:13 AM
  5. Full pest control Release
    By Sam Server in forum Tutorials
    Replies: 68
    Last Post: 08-13-2007, 08:53 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •