Thread: [PI] Prayer reducing out of process

Results 1 to 5 of 5
  1. #1 [PI] Prayer reducing out of process 
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    Code:
    	public double getDrainRate() {
    		double toRemove = 0.0;
    		for(int i = 0; i < c.PRAYER_DRAIN_RATE.length; i++) {
    			if(c.prayerActive[i]) { 
    				toRemove += c.PRAYER_DRAIN_RATE[i]/10;
    			}
    		}
    		if (toRemove > 0) {
    			toRemove /= (1 + (0.035 * c.playerBonus[11]));		
    		}
    		return toRemove;
    	}
    
    	public boolean hasPrayerActive() {
    		for (int i = 0; i < 18; i++) {
    			if(c.prayerActive[i])
    				return true;
    		}
    		return false;
    	}
    	
    	public int getPrayerDelay() {
    		c.usingPrayer = false;
    		int delay = 4000;	
    		for(int i = 0; i < c.prayerActive.length; i++) {
    			if(c.prayerActive[i] == true) {
    				c.usingPrayer = true;
    				delay -= c.PRAYER_DRAIN_RATE[i];
    			}
    		}
    		delay += c.playerBonus[11]*500;
    		return delay;
    	}
    Code:
    package rs2.main.cycle.event.impl;
    
    import rs2.main.cycle.event.CycleEvent;
    import rs2.main.cycle.event.CycleEventContainer;
    import rs2.main.model.entity.players.Client;
    
    /**
     * The task to reduce prayer points for prayer activation
     * @author Final Project
     *
     */
    public class ReducePrayerEvent extends CycleEvent {
    	
    	/**
    	 * Creates an instance of the client
    	 */
    	private Client client;
    	
    	/**
    	 * Constructs the class for the client
    	 * @param client
    	 * 			the client
    	 */
    	public ReducePrayerEvent(Client client) {
    		this.client = client;
    	}
    
    	@Override
    	public void execute(CycleEventContainer container) {
    		/*comment this out, just something i used to get the drain rates*/
    		client.sendMessage(""+client.getCombat().getDrainRate());
    		/*checks if player has no prayer points or has gone down to the negatives or if they have no prayers activated*/
    		if (client.playerLevel[5] == 0 
    				|| client.playerLevel[5] < 0 
    				|| !client.getCombat().hasPrayerActive()) {
    			container.stop();
    			return;
    		}
    		/*the prayer delay of when to drain the prayer point, needs to be more accurate as i kinda just did whatever*/
    		if(System.currentTimeMillis() - client.prayerDelay >  client.getCombat().getPrayerDelay() 
    				&& client.usingPrayer) {	
    			client.prayerDelay = System.currentTimeMillis();
    			/*checks if the client has more than 0 prayer points then starts the draining process*/
    			if (client.playerLevel[5] > 0) {
    				client.playerLevel[5] = (int) (client.playerLevel[5] - client.getCombat().getDrainRate());
    				client.getSkills().refreshSkill(5);
    			}
    		}
    	}
    
    	@Override
    	public void stop() {
    		if (client.playerLevel[5] < 0) {
    			client.playerLevel[5] = 0;
    			client.getSkills().refreshSkill(5);
    		}
    		client.getCombat().resetPrayers();
    	}
    	
    	
    	
    }
    now call the task in your activateprayer method after the switch or wherever you want after that, scratch not, not just anywhere lol.
    i used this guide as a reference for the formula, [Only registered and activated users can see links. ] but i kinda didnt wanna do the math so you guys are welcomed to do that yourself.

    edit: just noticed that i did something stupid, oh well
    Reply With Quote  
     

  2. #2  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    25
    Posts
    4,432
    Thanks given
    892
    Thanks received
    1,525
    Rep Power
    3228
    Good job. Will be useful for a lot of people who want to clean out there process.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Dec 2010
    Posts
    354
    Thanks given
    17
    Thanks received
    61
    Rep Power
    47
    Just make a tutorial about how to reduce the process method with events instead of making a snippet for every single one.
    Reply With Quote  
     

  5. #4  
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    Quote Originally Posted by dan0194 View Post
    Just make a tutorial about how to reduce the process method with events instead of making a snippet for every single one.
    lol. pretty sure theres several threads explaining how the task system works already
    Reply With Quote  
     

  6. #5  
    Registered Member
    Join Date
    Dec 2010
    Posts
    354
    Thanks given
    17
    Thanks received
    61
    Rep Power
    47
    Quote Originally Posted by Our Promise View Post
    lol. pretty sure theres several threads explaining how the task system works already
    true dat. there is real no reason for these people should just be doing it by themselves or not using terrible wL sources.
    Reply With Quote  
     

  7. 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. [PI] Prayer reducing out of process
    By Our Promise in forum Snippets
    Replies: 9
    Last Post: 07-17-2014, 07:31 AM
  2. Cleaning things out of process[PI]
    By TheLife in forum Snippets
    Replies: 38
    Last Post: 11-16-2012, 09:16 AM
  3. [PI] Hair comming out of Helmet o.0
    By wapie in forum Help
    Replies: 2
    Last Post: 07-07-2011, 05:10 PM
  4. [PI]Spawn npc out of a chest on click
    By Thedreamer in forum Help
    Replies: 7
    Last Post: 03-27-2011, 02:37 AM
  5. Replies: 12
    Last Post: 11-12-2010, 10:17 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
  •