Thread: [PI] Better Mining w/ Cycle Events [PI]

Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1 [PI] Better Mining w/ Cycle Events [PI] 
    Banned
    Join Date
    Oct 2011
    Posts
    861
    Thanks given
    371
    Thanks received
    214
    Rep Power
    0
    Purpose: Better mining without the use of process.
    Difficulty: 1/10
    Classes modified: Mining.java, Client.java, possibly Player.java, and possibly adding CycleEvents

    Note: you need Null++'s modified cycle based event manager for this if you don't already have it you can add it by clicking [Only registered and activated users can see links. ].

    This is just PI mining with some modifications that consist of removal of process, some bug fixes, and some enhanced timers.

    So replace your Mining.java with mine.
    Spoiler for class:
    Code:
    package server.model.players.skills;
    
    import server.model.players.*;
    import server.util.Misc;
    import server.event.*;
    import server.Config;
    
    /**
    * @Author Sanity
    */
    
    public class Mining {
    	
    	Client c;
    	
    	private final int VALID_PICK[] = {1265,1267,1269,1273,1271,1275};
    	private final int[] PICK_REQS = {1,1,6,6,21,31,41,61};
    	private final int[] RANDOM_GEMS = {1623,1621,1619,1617,1631};
    	private int oreType;
    	private int exp;
    	private int levelReq;
    	private int pickType;
    	private int EMOTE() {
    		switch (c.playerEquipment[c.playerWeapon]) {
    			case 1275://Rune Pickaxe
    				return 624;
    			case 1271://Adamant Pickaxe
    				return 628;
    			case 1273://Mithril Pickaxe
    				return 629;
    			case 1269://Steel Pickaxe
    				return 627;
    			case 1267://Iron Pickaxe
    				return 626;
    			case 1265://Bronze Pickaxe
    				return 625;
    		}
    		return 625;
    	}
    	
    	public Mining(Client c) {
    		this.c = c;
    	}
    	
    	public void startMining(int oreType, int levelReq, int exp) {
    		c.turnPlayerTo(c.objectX, c.objectY);
    		if (goodPick() > 0) {
    			if (c.playerLevel[c.playerMining] >= levelReq) {
    				this.oreType = oreType;
    				this.exp = exp;
    				this.levelReq = levelReq;
    				this.pickType = goodPick();
    				c.sendMessage("You swing your pick at the rock.");
    				c.miningTimer = getMiningTimer();
    				if (!miningEvent) {
    					miningEvent(c);
    				}
    				c.startAnimation(EMOTE());
    			} else {
    				resetMining();
    				c.sendMessage("You need a mining level of " + levelReq + " to mine this rock.");
    				c.startAnimation(65535);
    			}		
    		} else {
    			resetMining();
    			c.sendMessage("You need a pickaxe to mine this rock.");
    			c.startAnimation(65535);
    			c.getPA().resetVariables();
    		}
    	}
    	
    	public void mineOre() {
    	final int randomNumber = 17;
    		if (c.getItems().addItem(oreType,1) && Misc.random(60) != randomNumber) {
    			c.miningTimer = getMiningTimer();
    			c.startAnimation(EMOTE());
    			c.sendMessage("You manage to mine some ore.");
    			c.getPA().addSkillXP(exp * Config.MINING_EXPERIENCE, c.playerMining);
    			c.getPA().refreshSkill(c.playerMining);
    		} else if (Misc.random(60) == randomNumber) {
    			c.getItems().addItem(RANDOM_GEMS[(int)(RANDOM_GEMS.length * Math.random())], 1);
    			c.getPA().addSkillXP(100 * Config.MINING_EXPERIENCE, c.playerMining);
    			c.sendMessage("You find a gem!");
    			resetMining();
    		} else {
    			resetMining();
    			c.getPA().resetVariables();
    			c.startAnimation(65535);
    		}
    	}
    	
    	public void resetMining() {
    		this.oreType = -1;
    		this.exp = -1;
    		this.levelReq = -1;
    		this.pickType = -1;
    		c.miningTimer = -1;
    	}
    	
    	public int goodPick() {
    		for (int j = VALID_PICK.length - 1; j >= 0; j--) {
    			if (c.playerEquipment[c.playerWeapon] == VALID_PICK[j]) {
    				if (c.playerLevel[c.playerMining] >= PICK_REQS[j])
    					return VALID_PICK[j];
    			}		
    		}
    		for (int i = 0; i < c.playerItems.length; i++) {
    			for (int j = VALID_PICK.length - 1; j >= 0; j--) {
    				if (c.playerItems[i] == VALID_PICK[j] + 1) {
    					if (c.playerLevel[c.playerMining] >= PICK_REQS[j])
    						return VALID_PICK[j];
    				}
    			}		
    		}
    		return - 1;
    	}
    	
    	private int oreModifier() {
    		switch (c.mining[0]) {
    			case 451://Runite Ore
    				return 15;
    			case 449://Adamantite Ore
    				return 8;
    			case 447://Mithril
    				return 6;
    			case 444://Gold
    				return 6;
    			case 453://Coal
    				return 5;
    			case 442://Silver
    				return 4;
    			case 440://Iron
    				return 3;
    			case 436://Copper
    			case 428://Tin		
    			case 434://Clay
    				return 1;
    		}
    		return 1;
    	}
    	
    	public int getMiningTimer() {
    		int time = Misc.random(5);
    		return time + Misc.random(oreModifier());
    	}
    	
    	public boolean miningEvent = false;
    	public void miningEvent(final Client c) {
    		if (miningEvent)
    			return;
    		miningEvent = true;
    		CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    			@Override
    			public void execute(CycleEventContainer container) {
    				if (miningEvent && c.miningTimer == 4 || c.miningTimer == 8 || c.miningTimer == 12 || c.miningTimer == 16 || c.miningTimer == 20) {
    					c.startAnimation(EMOTE());
    				}
    				if(c.miningTimer > 0) {
    					c.miningTimer--;
    				}
    				if (c.getItems().freeSlots() < 1 || c.mining[0] == 0 || c.mining[1] == 0 || c.mining[2] == 0) {
    					container.stop();
    				}
    				if (c.miningTimer == 0 && c.mining[0] > 0) {
    					c.miningTimer = getMiningTimer();
    					mineOre();
    					
    				}
    				
    			}
    			@Override
    			public void stop() {
    				miningEvent = false;
    				resetMining();
    				c.startAnimation(65535);
    			}
    		}, 1);
    	}
    }


    and in Client.java under:
    Code:
    public void process() {
    find
    Code:
    if (miningTimer > 0 && mining[0] > 0) {
    			miningTimer--;
    		} else if (miningTimer == 0 && mining[0] > 0) {
    			getMining().mineOre();
    		} else
    and delete it.

    I will be happy to help with any errors, or bugs that may occur, remember I'm learning just like you are. I know this is nothing special but it is better than having processed skilling.

    kthxbai
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Banned
    Join Date
    Sep 2011
    Posts
    261
    Thanks given
    62
    Thanks received
    41
    Rep Power
    0
    This works with RiotScape 2.0?
    Reply With Quote  
     

  4. #3  
    Banned
    Join Date
    Oct 2011
    Posts
    861
    Thanks given
    371
    Thanks received
    214
    Rep Power
    0
    Probably, you could always try it.
    Reply With Quote  
     

  5. #4  
    Banned
    Join Date
    Sep 2011
    Posts
    261
    Thanks given
    62
    Thanks received
    41
    Rep Power
    0
    Okies.
    I liked Russian's server and was gonna have him send me a fr33 copy lol

    I think his is Riotscape 2.0 so I'll give it a go once he responds.
    Reply With Quote  
     

  6. #5  
    Spread Love

    Dhruv's Avatar
    Join Date
    Feb 2012
    Age
    25
    Posts
    1,014
    Thanks given
    156
    Thanks received
    166
    Rep Power
    215
    How can i stop it from showing the countdown ingame? And thanks for this.
    Reply With Quote  
     

  7. #6  
    Registered Member Market Banned Market Banned


    Join Date
    Feb 2010
    Age
    25
    Posts
    3,068
    Thanks given
    913
    Thanks received
    349
    Rep Power
    385
    Nice Job, Looks good
    Reply With Quote  
     

  8. Thankful user:


  9. #7  
    Banned
    Join Date
    Oct 2011
    Posts
    861
    Thanks given
    371
    Thanks received
    214
    Rep Power
    0
    Quote Originally Posted by Purple™ View Post
    How can i stop it from showing the countdown ingame? And thanks for this.
    Just re-copy and paste mining.java, I just remember that and fixed it! thanks for asking!
    Reply With Quote  
     

  10. #8  
    Spread Love

    Dhruv's Avatar
    Join Date
    Feb 2012
    Age
    25
    Posts
    1,014
    Thanks given
    156
    Thanks received
    166
    Rep Power
    215
    Thanks bro.
    Reply With Quote  
     

  11. #9  
    Registered Member
    Freezia's Avatar
    Join Date
    Feb 2011
    Posts
    5,869
    Thanks given
    1,145
    Thanks received
    757
    Rep Power
    1309
    Okay might come out as a noob but I keep getting this I have this event system added into my server it was added by some guy I paid to do my woodcutting... so I never use it.

    src\server\model\players\skills\Mining.java:152: cannot find symbol
    symbol : class CycleEvent
    location: class server.model.players.skills.Mining
    CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    ^
    src\server\model\players\skills\Mining.java:152: cannot find symbol
    symbol : variable CycleEventHandler
    location: class server.model.players.skills.Mining
    CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    ^

    Help is appreciated.


    Click above to get the cheapest WEB HOSTING options! We also provide VIRTUAL PRIVATE SERVERS (VPS)! Now equipped with DDOS Protection.


    Reply With Quote  
     

  12. #10  
    Super Donator

    Batukka's Avatar
    Join Date
    Oct 2011
    Posts
    2,437
    Thanks given
    86
    Thanks received
    342
    Rep Power
    496
    Quote Originally Posted by Freezia View Post
    Okay might come out as a noob but I keep getting this I have this event system added into my server it was added by some guy I paid to do my woodcutting... so I never use it.

    src\server\model\players\skills\Mining.java:152: cannot find symbol
    symbol : class CycleEvent
    location: class server.model.players.skills.Mining
    CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    ^
    src\server\model\players\skills\Mining.java:152: cannot find symbol
    symbol : variable CycleEventHandler
    location: class server.model.players.skills.Mining
    CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    ^

    Help is appreciated.
    You need import cycleevent or you're missing it.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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] Better Woodcutting w/ Cycle Events [PI]
    By Paradox_ in forum Snippets
    Replies: 15
    Last Post: 02-20-2014, 05:58 PM
  2. Cycle based events handler
    By Spooky in forum Tutorials
    Replies: 36
    Last Post: 10-13-2012, 12:58 PM
  3. [PI] Spec Restore through Cycle Events [PI]
    By Paradox_ in forum Snippets
    Replies: 13
    Last Post: 07-08-2012, 09:29 AM
  4. Help w/ Cycle Events
    By L__A in forum Help
    Replies: 3
    Last Post: 06-08-2012, 12:49 AM
  5. Missing a method (Cycle Events).
    By Organic in forum Help
    Replies: 4
    Last Post: 02-11-2011, 10:30 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
  •