Thread: [PI] Run Energy Out of Process

Results 1 to 8 of 8
  1. #1 [PI] Run Energy Out of Process 
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    I know most of you pi users use this as your run energy alternative [Only registered and activated users can see links. ]

    which uses process, so i thought id convert it to a task for ya to help you yet again remove something out of process and hopefully help you understand that there are always alternatives than just throwing things in process

    Code:
    package com.divine.fate.main.cycle.event;
    
    import com.divine.fate.main.cycle.CycleEvent;
    import com.divine.fate.main.cycle.CycleEventContainer;
    
    import game.model.entity.players.Player;
    
    public class RunEnergyTask extends CycleEvent {
    	
    	private Player player;
    	
    	public RunEnergyTask(Player player) {
    		this.player = player;
    	}
    
    	@Override
    	public void execute(CycleEventContainer container) {
    		if (player.playerEnergy == 100 || player.playerEnergy > 100) {
    			container.stop();
    		}
    		if (player.playerEnergy < 100 && !player.isRunning()) {
    			if (System.currentTimeMillis() > player.getPA()
    					.getAgilityRunRestore() + player.lastRunRecovery) {
    				player.playerEnergy++;
    				player.lastRunRecovery = System.currentTimeMillis();
    				player.getPA().sendFrame126(player.playerEnergy + "%", 149);
    			}
    		}
    	}
    
    	@Override
    	public void stop() {
    		player.playerEnergy = 100;
    	}
    	
    }
    now just call the task under where you have this declared, runEnergy--;
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Extreme Donator Market Banned Market Banned



    Join Date
    Dec 2010
    Age
    22
    Posts
    6,082
    Thanks given
    1,690
    Thanks received
    1,233
    Rep Power
    1704
    Nice release there.
    Reply With Quote  
     

  4. #3  
    Registered Member
    Karma_K's Avatar
    Join Date
    Nov 2012
    Posts
    4,287
    Thanks given
    152
    Thanks received
    610
    Rep Power
    108
    Forgot, you'll also need to call this in initialize() or whenever the player logs in
    Reply With Quote  
     

  5. #4  
    Donator

    Join Date
    Feb 2013
    Posts
    197
    Thanks given
    100
    Thanks received
    8
    Rep Power
    19
    thanks for the share
    Spoiler for massive sig:




    Reply With Quote  
     

  6. #5  
    Registered Member

    Join Date
    May 2012
    Posts
    253
    Thanks given
    5
    Thanks received
    146
    Rep Power
    122
    You also need to check whether the player has been disconnected or not, otherwise the event will just run. Like so:

    Code:
    		if (player.playerEnergy == 100 || player.playerEnergy > 100 || player.disconnected) {
    			container.stop();
    		}

    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  7. Thankful user:


  8. #6  
    Banned Market Banned Market Banned


    Join Date
    Jan 2011
    Age
    23
    Posts
    3,115
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Quote Originally Posted by Rhubarb View Post
    You also need to check whether the player has been disconnected or not, otherwise the event will just run. Like so:

    Code:
    		if (player.playerEnergy == 100 || player.playerEnergy > 100 || player.disconnected) {
    			container.stop();
    		}
    iirc even pi has support for attaching objects to tasks so checking is not needed, all tasks with the attached player will be stopped automatically when the player logs out

    he doesn't seem to be attaching the player instance though lol
    Reply With Quote  
     

  9. Thankful user:


  10. #7  
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    Quote Originally Posted by lare96 View Post
    iirc even pi has support for attaching objects to tasks so checking is not needed, all tasks with the attached player will be stopped automatically when the player logs out

    he doesn't seem to be attaching the player instance though lol
    I'm not sure what you're meaning by me not attaching the player instance. I am currently calling it as

    CycleEventContainer.getSingleton().addEvent(this, new RunEnergyTask(this), 1);

    The first this is in the field of where you specify the object owner, is it not?
    Reply With Quote  
     

  11. #8  
    Banned Market Banned Market Banned


    Join Date
    Jan 2011
    Age
    23
    Posts
    3,115
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Quote Originally Posted by Our Promise View Post
    I'm not sure what you're meaning by me not attaching the player instance. I am currently calling it as

    CycleEventContainer.getSingleton().addEvent(this, new RunEnergyTask(this), 1);

    The first this is in the field of where you specify the object owner, is it not?
    well I'm not sure how the Object attachments work in PI, but yeah if it's like that then you are attaching the player instance
    Reply With Quote  
     

  12. 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: 4
    Last Post: 07-26-2014, 02:35 AM
  2. [PI] Prayer reducing out of process
    By Our Promise in forum Snippets
    Replies: 9
    Last Post: 07-17-2014, 07:31 AM
  3. Cleaning things out of process[PI]
    By TheLife in forum Snippets
    Replies: 38
    Last Post: 11-16-2012, 09:16 AM
  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
  •