Thread: [PI] 99% Dicing

Page 1 of 12 123 11 ... LastLast
Results 1 to 10 of 120
  1. #1 [PI] 99% Dicing 
    Zarpor Owner
    mattsforeal's Avatar
    Join Date
    Oct 2009
    Posts
    250
    Thanks given
    51
    Thanks received
    78
    Rep Power
    66
    I figured I'd release this on here maybe for a little rep, It is almost perfect dicing and I tried to keep the code as neat as possible.

    In player.java add these variables...
    Code:
    public boolean clanDice = false;
    	public long diceDelay;
    	public int diceID = 15084;
    	public int cDice = 0;
    In client.java add to process()

    Code:
    FetchDice();
    Add these two voids.

    Code:
    public void FetchDice()
    	{
    		int rnd;
    		String Message = "";
    		if (cDice == 0 || (System.currentTimeMillis() - diceDelay <= 1000)) {
    			return;
    		}
    		switch (cDice) {
    		//Dice
    			case 15096: rnd = Misc.random(19)+1; Message = ("rolled <col=16711680>"+ rnd +"</col> on a twenty-sided die."); break;
    			case 15094: rnd = Misc.random(11)+1; Message = ("rolled <col=16711680>"+ rnd +"</col> on a twelve-sided die."); break;
    			case 15092: rnd = Misc.random(9)+1; Message = ("rolled <col=16711680>"+ rnd +"</col> on a ten-sided die."); break;
    			case 15090: rnd = Misc.random(7)+1; Message = ("rolled <col=16711680>"+ rnd +"</col> on an eight-sided die."); break;
    			case 15100: rnd = Misc.random(3)+1; Message = ("rolled <col=16711680>"+ rnd +"</col> on a four-sided die."); break;
    			case 15086: rnd = Misc.random(5)+1;	Message = ("rolled <col=16711680>"+ rnd +"</col> on a six-sided die."); break;
    			case 15088: rnd = Misc.random(11)+1; Message = ("rolled <col=16711680>"+ rnd +"</col> on two six-sided dice."); break;
    			case 15098: rnd = Misc.random(99)+1; Message = ("rolled <col=16711680>"+ rnd +"</col> on the percentile dice."); break;
    		}
    		sendMessage("You " + Message);
    			if (clanDice){
    				if (clanId >= 0) {
    					Server.clanChat.messageToClan("Clan Chat channel-mate <col=16711680>"+playerName+"</col> "+Message, clanId);
    				}
    			}
    		cDice = 0;
    	}
    
    	public void useDice(int itemId, boolean clan){
    			if (System.currentTimeMillis() - diceDelay >= 3000) {
    				sendMessage("Rolling...");
    				startAnimation(11900);
    				diceDelay = System.currentTimeMillis();
    				cDice = itemId;
    				clanDice = clan;
    			switch (itemId) {
    				//Gfx's
    				case 15086: gfx0(2072); break;
    				case 15088: gfx0(2074); break;
    				case 15090: gfx0(2071); break;
    				case 15092: gfx0(2070); break;
    				case 15094: gfx0(2073); break;
    				case 15096: gfx0(2068); break;
    				case 15098: gfx0(2075); break;
    				case 15100: gfx0(2069); break;
    			}
    		}
    
    	}
    In clickitem.java

    Code:
    	if (itemId > 15085 && itemId < 15102){
    			c.useDice(itemId, false);
    		}
    		if (itemId == 15084)
    		{//dice bag
    			c.diceID = itemId;
    			c.getDH().sendDialogues(106, 0);
    		}

    In itemassistant.java
    Under "public boolean wearItem(int wearID, int slot) {"

    Code:
    if (wearID > 15085 && wearID < 15102){
    				if (c.clanId >= 0){
    					c.useDice(wearID, true);
    				}else{
    					c.sendMessage("You must be in a clan chat channel to do that.");
    				}
    					return false;
    			}
    In dialoguehandler.java
    Under "switch (dialogue){"

    Code:
    case 106:
    				sendOption5("One 6-sided die", "Two 6-sided dice", "One 4-sided die", "One 8-sided die", "More...");
    				c.dialogueAction = 106;
    				c.teleAction = 0;
    				c.nextChat = 0;
    				break;
    
    			case 107:
    				sendOption5("One 10-sided die", "One 12-sided die", "One 20-sided die", "Two 10-sided dice for 1-100", "Back...");
    				c.dialogueAction = 107;
    				c.teleAction = 0;
    				c.nextChat = 0;
    				break;
    In clickingbuttons.java

    case 9190:

    Code:
    if (c.dialogueAction == 106) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15086, 1);
    						c.sendMessage("You get a six-sided die out of the dice bag.");
    					}
    					c.getPA().closeAllWindows();
    				} else if (c.dialogueAction == 107) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15092, 1);
    						c.sendMessage("You get a ten-sided die out of the dice bag.");
    					}
    					c.getPA().closeAllWindows();
    				}
    case 9191:

    Code:
    if (c.dialogueAction == 106) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15088, 1);
    						c.sendMessage("You get two six-sided dice out of the dice bag.");
    					}
    					c.getPA().closeAllWindows();
    				} else if (c.dialogueAction == 107) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15094, 1);
    						c.sendMessage("You get a twelve-sided die out of the dice bag.");
    					}
    					c.getPA().closeAllWindows();
    				}
    case 9192:

    Code:
    if (c.dialogueAction == 106) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15100, 1);
    						c.sendMessage("You get a four-sided die out of the dice bag.");
    					}
    					c.getPA().closeAllWindows();
    				} else if (c.dialogueAction == 107) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15096, 1);
    						c.sendMessage("You get a twenty-sided die out of the dice bag.");
    				}
    					c.getPA().closeAllWindows();
    				}
    case 9193:

    Code:
    if (c.dialogueAction == 106) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15090, 1);
    						c.sendMessage("You get an eight-sided die out of the dice bag.");
    					}
    					c.getPA().closeAllWindows();
    				} else if (c.dialogueAction == 107) {
    					if(c.getItems().playerHasItem(c.diceID, 1)) {
    						c.getItems().deleteItem(c.diceID, c.getItems().getItemSlot(c.diceID), 1);	
    						c.getItems().addItem(15098, 1);
    						c.sendMessage("You get the percentile dice out of the dice bag.");
    				}
    					c.getPA().closeAllWindows();
    				}
    case 9194:

    Code:
    if (c.dialogueAction == 106) {
    				c.getDH().sendDialogues(107, 0);
    				break;
    				} else if (c.dialogueAction == 107) {
    				c.getDH().sendDialogues(106, 0);
    				break;
    				}
    Thanks to InsidiaX for pointing out what I forgot
    Please say thanks if this helped you, it took me quite a while to perfect this.
    Last edited by Mister Maggot; 08-17-2011 at 06:41 AM.
    [Only registered and activated users can see links. ]

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


  2. #2  
    Registered Member

    Faris's Avatar
    Join Date
    Sep 2008
    Posts
    4,697
    Thanks given
    809
    Thanks received
    1,382
    Rep Power
    2840
    First , Brilliant release, Will use!
    "Know thy self, know thy enemy. A thousand battles, a thousand victories." - Sun Tzu
    GitHub: [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. #3  
    Donator

    James_'s Avatar
    Join Date
    May 2011
    Posts
    353
    Thanks given
    31
    Thanks received
    42
    Rep Power
    119
    Great snippet man ty

    [Only registered and activated users can see links. ]

    Reply With Quote  
     

  4. #4  
    Registered Member

    Faris's Avatar
    Join Date
    Sep 2008
    Posts
    4,697
    Thanks given
    809
    Thanks received
    1,382
    Rep Power
    2840
    Could we have your methods for Display Name btw?
    "Know thy self, know thy enemy. A thousand battles, a thousand victories." - Sun Tzu
    GitHub: [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #5  
    Zarpor Owner
    mattsforeal's Avatar
    Join Date
    Oct 2009
    Posts
    250
    Thanks given
    51
    Thanks received
    78
    Rep Power
    66
    Quote Originally Posted by InsidiaX View Post
    Could we have your methods for Display Name btw?
    Oh my bad, use playerName... That's from my name changing system. I'll fix that...
    Reply With Quote  
     

  6. #6  
    Registered Member Aintaro.'s Avatar
    Join Date
    Sep 2010
    Posts
    998
    Thanks given
    191
    Thanks received
    213
    Rep Power
    37
    you should make a seperated class to keep things clear.

    Other than that, it looks good.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Steve Smith's Avatar
    Join Date
    Dec 2010
    Posts
    2,375
    Thanks given
    504
    Thanks received
    437
    Rep Power
    202
    well seems like you have bested everyone elses dicing releases, very nice
    Reply With Quote  
     

  8. #8  
    Registered Member Aintaro.'s Avatar
    Join Date
    Sep 2010
    Posts
    998
    Thanks given
    191
    Thanks received
    213
    Rep Power
    37
    oh yeah...why do you add fetchDice in process? (not sure how dicing works on runescape)
    Reply With Quote  
     

  9. #9  
    Zarpor Owner
    mattsforeal's Avatar
    Join Date
    Oct 2009
    Posts
    250
    Thanks given
    51
    Thanks received
    78
    Rep Power
    66
    Quote Originally Posted by Aintaro. View Post
    oh yeah...why do you add fetchDice in process? (not sure how dicing works on runescape)
    There is a delay when you roll the dice before you get the result.
    Reply With Quote  
     

  10. #10  
    Registered Member Aintaro.'s Avatar
    Join Date
    Sep 2010
    Posts
    998
    Thanks given
    191
    Thanks received
    213
    Rep Power
    37
    Quote Originally Posted by mattsforeal View Post
    There is a delay when you roll the dice before you get the result.

    Use events rather than process, because your going through that code every 600ms while its not necessary...
    Reply With Quote  
     

Page 1 of 12 12311 ... LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. (PI) Gambling/Dicing.
    By `moh in forum Tutorials
    Replies: 52
    Last Post: 12-20-2012, 03:03 AM
  2. [Pi] 60% Dicing
    By Kickyamom in forum Snippets
    Replies: 21
    Last Post: 08-20-2011, 02:46 AM
  3. Dicing randomizer?
    By op ninja in forum Help
    Replies: 8
    Last Post: 08-01-2011, 04:38 PM
  4. [PI] Clan Dicing
    By Steve Smith in forum Snippets
    Replies: 19
    Last Post: 08-01-2011, 04:44 AM
  5. gfx for dicing?
    By `Michael in forum Requests
    Replies: 2
    Last Post: 07-12-2011, 10:26 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
  •