Thread: How does this work?

Results 1 to 6 of 6
  1. #1 How does this work? 
    Registered Member
    Join Date
    Nov 2014
    Posts
    273
    Thanks given
    26
    Thanks received
    8
    Discord
    View profile
    Rep Power
    72
    This is in my fishing.java i know it's not this most effective way of having the fishing class but i need help understanding how this line of code works, when it tries to grab the first fish it only grabs second fish to inventory instead of a chance of first and second fish.

    This is the data it's grabbing:

    Code:
    c.playerSkillProp[10][0] = data[i][6]; // ANIM
    				c.playerSkillProp[10][1] = data[i][4]; // First FISH
    				c.playerSkillProp[10][2] = data[i][5]; // First XP Rate
    				c.playerSkillProp[10][3] = data[i][3]; // BAIT
    				c.playerSkillProp[10][4] = data[i][2]; // First Equipment
    				c.playerSkillProp[10][5] = data[i][7]; // Second FISH
    				c.playerSkillProp[10][6] = data[i][8]; // Second Level
    				c.playerSkillProp[10][8] = data[i][9]; // Second XP Rate
    				c.playerSkillProp[10][9] = Misc.random(1) == 0 ? 7 : 5;
    				c.playerSkillProp[10][10] = data[i][0]; // INDEX
    Trying to understand:
    Code:
    public void execute(CycleEventContainer container) {
    						if (c.playerSkillProp[10][5] > 0) {
    							if (c.playerLevel[c.playerFishing] >= c.playerSkillProp[10][6]) {
    								c.playerSkillProp[10][1] = c.playerSkillProp[10][Misc
    										.random(1) == 0 ? 7 : 5];
    							}
    						}
    Reply With Quote  
     

  2. #2  
    Community Veteran


    arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,833
    Thanks given
    187
    Thanks received
    306
    Discord
    View profile
    Rep Power
    770
    I got a better idea:
    delete the old fishing code and do your own. That way you will understand it.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,187
    Thanks given
    1,124
    Thanks received
    834
    Discord
    View profile
    Rep Power
    1514
    what the hell is this
    Reply With Quote  
     

  4. #4  
    Donator

    Join Date
    Oct 2015
    Posts
    78
    Thanks given
    13
    Thanks received
    6
    Discord
    View profile
    Rep Power
    24
    A monstrosity
    Reply With Quote  
     

  5. #5  
    Registered Member
    bracket's Avatar
    Join Date
    Aug 2009
    Posts
    5,286
    Thanks given
    1,047
    Thanks received
    1,463
    Rep Power
    5000
    Code:
                                    c.playerSkillProp[10][0] = data[i][6]; // ANIM
    				c.playerSkillProp[10][1] = data[i][4]; // First FISH
    				c.playerSkillProp[10][2] = data[i][5]; // First XP Rate
    				c.playerSkillProp[10][3] = data[i][3]; // BAIT
    				c.playerSkillProp[10][4] = data[i][2]; // First Equipment
    				c.playerSkillProp[10][5] = data[i][7]; // Second FISH
    				c.playerSkillProp[10][6] = data[i][8]; // Second Level
    				c.playerSkillProp[10][8] = data[i][9]; // Second XP Rate
    				c.playerSkillProp[10][9] = Misc.random(1) == 0 ? 7 : 5;
    				c.playerSkillProp[10][10] = data[i][0]; // INDEX
    Code:
    c.playerSkillProp[10][1] = c.playerSkillProp[10][Misc.random(1) == 0 ? 7 : 5];
    So you're assigning the playerSkillProp[10][1] here by rolling playerSkillProp[10][random(1)]. If it rolls 0 it will assign index 7, any other roll will assign index 5 (red). As you can see it will only be able to catch the second fish, not the first.

    You should probably get rid of this lol.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Nov 2014
    Posts
    273
    Thanks given
    26
    Thanks received
    8
    Discord
    View profile
    Rep Power
    72
    Quote Originally Posted by bracket View Post
    Code:
                                    c.playerSkillProp[10][0] = data[i][6]; // ANIM
    				c.playerSkillProp[10][1] = data[i][4]; // First FISH
    				c.playerSkillProp[10][2] = data[i][5]; // First XP Rate
    				c.playerSkillProp[10][3] = data[i][3]; // BAIT
    				c.playerSkillProp[10][4] = data[i][2]; // First Equipment
    				c.playerSkillProp[10][5] = data[i][7]; // Second FISH
    				c.playerSkillProp[10][6] = data[i][8]; // Second Level
    				c.playerSkillProp[10][8] = data[i][9]; // Second XP Rate
    				c.playerSkillProp[10][9] = Misc.random(1) == 0 ? 7 : 5;
    				c.playerSkillProp[10][10] = data[i][0]; // INDEX
    Code:
    c.playerSkillProp[10][1] = c.playerSkillProp[10][Misc.random(1) == 0 ? 7 : 5];
    So you're assigning the playerSkillProp[10][1] here by rolling playerSkillProp[10][random(1)]. If it rolls 0 it will assign index 7, any other roll will assign index 5 (red). As you can see it will only be able to catch the second fish, not the first.

    You should probably get rid of this lol.
    Thank you for explaining I was working on an enum based fishing still new to it but this is what i have right now.
    Code:
    public class FishingUpdate {
    	
    	public enum fishingData {
    		// animation, fish, xp rate, bait, equipment 
    		SHRIMP_ANCHOVIE(621, new int[] {317, 321}, new int[] {5, 10}, -1, 303);
    		
    		private int animId, bait, equipment;
    		private int[] fish, xp;
    		
    		fishingData(int anim, int[] fishId, int[] xp, int bait, int equipment) {
    			this.animId = anim;
    			this.fish = fishId;
    			this.xp = xp;
    			this.bait = bait;
    			this.equipment = equipment;
    		}
    
    		public int getAnimId() {
    			return animId;
    		}
    
    		public int getBait() {
    			return bait;
    		}
    
    		public int getEquipment() {
    			return equipment;
    		}
    
    		public int[] getFish() {
    			return fish;
    		}
    
    		public int[] getXp() {
    			return xp;
    		}
    		
    		public static void attemptFishing(int fishId) {
    			
    		}
    	}
    }
    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. Replies: 14
    Last Post: 07-21-2015, 03:59 PM
  2. hi how does this work
    By Thakiller in forum Spam
    Replies: 12
    Last Post: 05-13-2014, 06:05 PM
  3. Replies: 3
    Last Post: 01-15-2012, 09:42 PM
  4. [Rep++] How does this dupe works?
    By Gr1nderscape in forum Help
    Replies: 4
    Last Post: 01-02-2012, 01:22 PM
  5. How does this work??Rep++
    By Mini in forum Help
    Replies: 1
    Last Post: 12-20-2009, 11:22 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
  •