Thread: Prayer drain

Results 1 to 2 of 2
  1. #1 Prayer drain 
    Donator

    Join Date
    Nov 2012
    Posts
    790
    Thanks given
    47
    Thanks received
    42
    Rep Power
    12
    When i run out of prayer points it throws this error, I recently added Rigour and Augury.

    Code:
    [12/11/17 22:57]: java.lang.ArrayIndexOutOfBoundsException: 28
    [12/11/17 22:57]: 	at server.model.players.CombatAssistant.resetPrayers(CombatAssistant.java:2503)
    [12/11/17 22:57]: 	at server.model.players.CombatAssistant.reducePrayerLevel(CombatAssistant.java:2494)
    [12/11/17 22:57]: 	at server.model.players.CombatAssistant.handlePrayerDrain(CombatAssistant.java:2483)
    [12/11/17 22:57]: 	at server.model.players.Client.process(Client.java:772)
    [12/11/17 22:57]: 	at server.model.players.PlayerHandler.process(PlayerHandler.java:145)
    [12/11/17 22:57]: 	at server.Server.main(Server.java:161)
    (CombatAssistant.java:2503)
    Code:
    public void resetPrayers() {
    		for(int i = 0; i < c.prayerActive.length; i++) {
    			c.prayerActive[i] = false;
    			c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
    		}
    		c.headIcon = -1;
    		c.getPA().requestUpdates();
    	}
    (CombatAssistant.java:2494)
    Code:
    	public void reducePrayerLevel() {
    		if(c.playerLevel[5] - 1 > 0) {
    			c.playerLevel[5] -= 1;
    		} else {
    			c.sendMessage("You have run out of prayer points!");
    			c.playerLevel[5] = 0;
    			resetPrayers();
    			c.prayerId = -1;	
    		}
    		c.getPA().refreshSkill(5);
    	}
    Code:
        public void handlePrayerDrain() {
    		c.usingPrayer = false;
    		double toRemove = 0.0;
    		for (int j = 0; j < prayerData.length; j++) {
    			if (c.prayerActive[j]) {
    				toRemove += prayerData[j]/20;
    				c.usingPrayer = true;
    			}
    		}
    		if (toRemove > 0) {
    			toRemove /= (1 + (0.035 * c.playerBonus[11]));		
    		}
    		c.prayerPoint -= toRemove;
    		if (c.prayerPoint <= 0) {
    			c.prayerPoint = 1.0 + c.prayerPoint;
    			reducePrayerLevel();
    		}
    	
    	}
    (Client.java:772)
    Code:
    		getCombat().handlePrayerDrain();
    (PlayerHandler.java:145)
    Code:
    					players[i].process();
    (Server.java:161)
    Code:
    				playerHandler.process();
    Player.java
    Code:
    public int prayerId = -1;
    	public int headIcon = -1;
    	public int bountyIcon = 0;
    	public long stopPrayerDelay, prayerDelay;
    	public boolean usingPrayer;
    	 public final int[] PRAYER_DRAIN_RATE = {
    		        500, 500, 500, 500, 500, 500, 500,
    		        500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
    		        500, 500, 500, 500, 500, 500, 500, 500
    		    };
    		    public final int[] PRAYER_LEVEL_REQUIRED = {
    		        1, 4, 7, 8, 9, 10, 13, 16, 19,
    		        22, 25, 26, 27, 28, 31, 34, 37, 40, 43, 44, 45, 46, 49, 52, 60, 70, 75, 75
    		    };
    		    public final int[] PRAYER = {
    		        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
    		        14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27
    		    };
    		    public final String[] PRAYER_NAME = {
    		        "Thick Skin", "Burst of Strength",
    		            "Clarity of Thought", "Sharp Eye", "Mystic Will", "Rock Skin",
    		            "Superhuman Strength", "Improved Reflexes", "Rapid Restore",
    		            "Rapid Heal", "Protect Item", "Hawk Eye", "Mystic Lore",
    		            "Steel Skin", "Ultimate Strength", "Incredible Reflexes",
    		            "Protect from Magic", "Protect from Missiles",
    		            "Protect from Melee", "Eagle Eye", "Mystic Might", "Retribution",
    		            "Redemption", "Smite", "Chivalry", "Piety", "Rigour", "Augury"
    		    };
    		    public final int[] PRAYER_GLOW = {
    		        83, 84, 85, 601, 602, 86, 87, 88, 89,
    		        90, 91, 603, 604, 92, 93, 94, 95, 96, 97, 605, 606, 98, 99, 100,
    		        607, 608, 101, 102
    		    };
    		    public final int[] PRAYER_HEAD_ICONS = {
    		        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 0, -1, -1, 3, 5, 4, -1, -1, -1, -1, -1, -1
    		    };
    		    // {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,1,4,6,5};
    
    		    public boolean[] prayerActive = {
    		        false, false, false, false, false, false,
    		        false, false, false, false, false, false, false, false, false,
    		        false, false, false, false, false, false, false, false, false,
    		        false, false,
    		        false, false, false, false
    		    };
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Oct 2017
    Posts
    15
    Thanks given
    0
    Thanks received
    2
    Rep Power
    11
    Code:
    public void resetPrayers() {
    		for(int i = 0; i < c.prayerActive.length; i++) {
    			c.prayerActive[i] = false;
    			c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
    		}
    		c.headIcon = -1;
    		c.getPA().requestUpdates();
    	}
    That code is wrong because you are trying to loop over to arrays with different lengths so you are getting an 'ArrayIndexOutOfBoundsException', to fix this just do two loops, one for each array:

    Code:
    public void resetPrayers() {
    		for(int i = 0; i < c.prayerActive.length; i++) {
    			c.prayerActive[i] = false;
    		}
                    for(int j = 0; j < c.PRAYER_GLOW.length; j++){
                            c.getPA().sendFrame36(c.PRAYER_GLOW[j], 0);
                    }
    		c.headIcon = -1;
    		c.getPA().requestUpdates();
    	}
    Should work..
    Reply With Quote  
     

  3. Thankful user:



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. [Hyperion] Prayer Draining
    By PSNB in forum Help
    Replies: 0
    Last Post: 04-15-2010, 06:07 AM
  2. The Correct Prayer draining
    By Profesor Oak in forum Informative Threads
    Replies: 32
    Last Post: 04-04-2010, 09:57 PM
  3. Project Czar - Remove Prayer Draining Tutorial
    By Pheonix in forum Tutorials
    Replies: 10
    Last Post: 08-30-2009, 07:47 AM
  4. [delta] Prayer draining.
    By lemby pk in forum Help
    Replies: 0
    Last Post: 03-14-2009, 11:16 PM
  5. npc effects: healing, prayer drain, etc
    By WH:II:DOW in forum Tutorials
    Replies: 12
    Last Post: 07-23-2008, 02:42 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
  •