Thread: Prayerdrain through events.

Results 1 to 10 of 10
  1. #1 Prayerdrain through events. 
    Registered Member jelleplomp's Avatar
    Join Date
    Oct 2012
    Age
    26
    Posts
    549
    Thanks given
    73
    Thanks received
    6
    Rep Power
    11
    Hello Rune-server,

    I'm currently working on prayerdraining using events, I've implemented this snippet: http://www.rune-server.org/runescape...er-system.html
    but the draining was shitty so i thought why not re-do it. So I've made some ideas:
    • when prayer is activated create an event with the name of the prayer
    • if already activated, stop event with the name of the prayer

    but now I've come across some problems...:
    • when multiple events are started they all drain seperete amounts, this amounts needs to be 1.


    so I figured out why not create one event, add the drain amount before the event is executed. if this method is called += drainamount or -= drainamount.
    if the event is already running the event shouldn't be executed another time. now... the struggles xd,
    i need to check if there is already an event running i can do this with cycleeventcontainer.isrunning() but then both containers should be the same. so i did this:

    Code:
    	public void execute(final Client c, Prayer prayer, String name) {
    		//OUTSIDE LOOP
    		//TODO - if called c.drainrate += number
    		//	   - if already called only add drainrate and not another event
    		//	   - if prayer is deactivated, c.drainrate -= number
    		
    		//LOOP
    		//TODO - call c.drainrate
    		//     - when prayerlevel = 0 stop the event + reset drainrate
    		CycleEventContainer container;
    		CycleEventHandler.addEvent(c, new CycleEvent() {
    			@Override
    			public void isRunning(container) {
    				if(container.isRunning()) {
    					c.sendMessage("RETURNED !");
    					return;
    				}
    			}
    			@Override
    			public void execute(container) {
    				c.sendMessage("NOT RETURNED !");
    				if(c.playerLevel[5] > 0) {
    					if (c.getActivePrayers().contains(prayer)) {
    						c.drainRate += prayer.getDrain() / 20;
    					}
    					if (c.drainRate > 0)
    						c.drainRate /= (1 + (0.035 * c.playerBonus[11]));
    					c.prayerPoint -= c.drainRate;
    					if (c.prayerPoint <= 0) {
    						c.prayerPoint = 1.0 + c.prayerPoint;
    						reducePrayerLevel(c);
    					}
    				} else if(c.playerLevel[5] <= 0) {//prayer lvl = 0
    					noPrayerPoint(c, prayer);
    					container.stop();
    				}
    				
    			}
    		}, 5, name);
    	}
    and it gives me some wierd error :
    Code:
    Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList
    I hope someone can help me,
    thanks in advance
    p.s sorry, my english isn't very good.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Feb 2015
    Posts
    97
    Thanks given
    8
    Thanks received
    0
    Rep Power
    11
    Code:
    if(container.isRunning()) {
    					c.sendMessage("RETURNED !");
    					return;
    				}
    If i recall correctly, this will check for ANY event that is running?


    Simple & better solution is to add an Attachment to the Player so you can identify specific tasks to a player then you could even make a STACKABLE/NON_STACKABLE add-on to the Task system.

    Code example

    Code:
    public void stopNonStackableTasks(Player player) {
    		if (stackable == Stackable.NON_STACKABLE) {
    			for (Iterator<ScheduledTask> it$ = player.getTasks().iterator(); it$.hasNext();) {
    				ScheduledTask task = it$.next();
    				if (task.stackable == Stackable.NON_STACKABLE) {
    					if (task.isRunning()) {
    						task.stop();
    					}
    				}
    			}
    		}
    		player.getTasks().add(this);
    	}
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member jelleplomp's Avatar
    Join Date
    Oct 2012
    Age
    26
    Posts
    549
    Thanks given
    73
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by Azuline View Post
    Code:
    if(container.isRunning()) {
    					c.sendMessage("RETURNED !");
    					return;
    				}
    If i recall correctly, this will check for ANY event that is running?


    Simple & better solution is to add an Attachment to the Player so you can identify specific tasks to a player then you could even make a STACKABLE/NON_STACKABLE add-on to the Task system.

    Code example

    Code:
    public void stopNonStackableTasks(Player player) {
    		if (stackable == Stackable.NON_STACKABLE) {
    			for (Iterator<ScheduledTask> it$ = player.getTasks().iterator(); it$.hasNext();) {
    				ScheduledTask task = it$.next();
    				if (task.stackable == Stackable.NON_STACKABLE) {
    					if (task.isRunning()) {
    						task.stop();
    					}
    				}
    			}
    		}
    		player.getTasks().add(this);
    	}
    im not familiar with the task system, but can i implement this into cycleevent?
    Reply With Quote  
     

  5. #4  
    Registered Member
    Join Date
    Feb 2015
    Posts
    97
    Thanks given
    8
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by jelleplomp View Post
    im not familiar with the task system, but can i implement this into cycleevent?
    You can but it'd take some code modifications
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Registered Member jelleplomp's Avatar
    Join Date
    Oct 2012
    Age
    26
    Posts
    549
    Thanks given
    73
    Thanks received
    6
    Rep Power
    11
    fixed it thanks for help
    Reply With Quote  
     

  8. #6  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Could always use the system I made a while back (Still 3 years newer then the 2011 one lol): http://www.rune-server.org/runescape...ctivation.html

    Doesn't include prayer drain rate but in the thread I also included a link for ways of removing it out of process like the one here: http://www.rune-server.org/runescape...t-process.html
    Reply With Quote  
     

  9. Thankful user:


  10. #7  
    Registered Member jelleplomp's Avatar
    Join Date
    Oct 2012
    Age
    26
    Posts
    549
    Thanks given
    73
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by Zivik View Post
    Could always use the system I made a while back (Still 3 years newer then the 2011 one lol): http://www.rune-server.org/runescape...ctivation.html

    Doesn't include prayer drain rate but in the thread I also included a link for ways of removing it out of process like the one here: http://www.rune-server.org/runescape...t-process.html
    Hello Zivik, since I see you have expierence with arraylists,
    can I ask you something? I've got the prayer drain and everything fixed but I also implemented quickprayers,
    but now i have a problem, the quicks are readed as booleans, and not as an arraylist.... do you have any tips on how to do this?
    Reply With Quote  
     

  11. #8  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Quote Originally Posted by jelleplomp View Post
    Hello Zivik, since I see you have expierence with arraylists,
    can I ask you something? I've got the prayer drain and everything fixed but I also implemented quickprayers,
    but now i have a problem, the quicks are readed as booleans, and not as an arraylist.... do you have any tips on how to do this?
    Show me code
    Reply With Quote  
     

  12. #9  
    Registered Member jelleplomp's Avatar
    Join Date
    Oct 2012
    Age
    26
    Posts
    549
    Thanks given
    73
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by Zivik View Post
    Show me code
    Code:
    public void turnQuicksOn(Client c) {
    		for(Prayer p : Prayer.values()) {
    			for (int i = 0; i < c.quickPrayers.length; i++) {
    				if (c.quickPrayers[i] && !c.getActivePrayers().contains(c.QUICK_PRAYERS_NAME[i])) {
    					Prayer prayer = Prayer.forName(c.QUICK_PRAYERS_NAME[i]);
    					c.sendMessage(""+prayer);
    					Prayers.togglePrayer(c, prayer);
    				}
    				if (!c.quickPrayers[i]) {
    					c.getActivePrayers().remove(p);
    					c.getPA().sendFrame36(p.getClientConfiguration(), 0);
    					c.getPA().requestUpdates();
    				}
    			}
    		}
    	}
    Code:
    public static Prayer forName(String name) {
    			return prayers.get(name);
    		}
    
    private static Map<String, Prayer> prayersString = new HashMap<String, Prayer>();
    
    static {
    			for(Prayer prayer : Prayer.values()) {
    				prayers.put(prayer.id, prayer);
    				prayersString.put(prayer.name, prayer);
    			}
    		}
    but it gives me a null pointer =\...

    the name it gives at the point marked red is the same as the one clicked as quick prayer.
    i think it has something to do with the stuff marked green.

    btw the enum format (
    Code:
    SUPERHUMAN_STRENGTH(new double[] {97180, 13, 87, 2}, "SUPERHUMAN_STRENGTH", STRENGTH_PRAYER)
    )
    Reply With Quote  
     

  13. #10  
    Registered Member jelleplomp's Avatar
    Join Date
    Oct 2012
    Age
    26
    Posts
    549
    Thanks given
    73
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by Zivik View Post
    Show me code
    nvm i just implemented your version it works smooth, tyvm
    (one thing, do you have the enum constructor can't seem to find it.
    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] Spec Restore through Cycle Events [PI]
    By Paradox_ in forum Snippets
    Replies: 13
    Last Post: 07-08-2012, 09:29 AM
  2. Some Random Events
    By Eleclion in forum Tutorials
    Replies: 4
    Last Post: 05-15-2007, 11:38 PM
  3. Guardian Random Events
    By Eleclion in forum Tutorials
    Replies: 3
    Last Post: 05-12-2007, 08:21 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
  •