Thread: Ranging

Results 1 to 5 of 5
  1. #1 Ranging 
    Registered Member
    Stimulant's Avatar
    Join Date
    Jan 2013
    Age
    27
    Posts
    1,457
    Thanks given
    248
    Thanks received
    187
    Rep Power
    578
    Hi, I'm currently redoing some part of combat but I'm stuck, for some reason it doesn't read all the arrows in the int[] so the bow can only use the first arrow (882 in this case), even tho when I print "System.out.println(data.getAmmo().length);" it says 2 (so it reads all of them). I've put in red what I think causes the problem.

    Enum:

    Code:
    TRAINING_BOW(9705, new int[] { 882, 9706 });
    
    private int weaponId;
    		private int[] ammoId;
    		
    		private Weapons(int weaponId, int[] ammoId) {
    			this.weaponId = weaponId;
    			this.ammoId = ammoId;
    		}
    		
    		public int getWeaponId() {
    			return weaponId;
    		}
    		
    		public int[] getAmmo() {
    			return ammoId;
    		}
    	}
    Method:

    Code:
    public static int isRanging(Player player) {
    		int weaponId = player.getEquipment().getWeaponId();
    		if (weaponId == -1) {
    			return 0;
    		}
    		String itemName = ItemDefinitions.getItemDefinitions(weaponId).getName();
    		if (itemName != null) {
    			if (itemName.contains("knife") || itemName.contains("dart") || itemName.contains("javelin") || itemName.contains("thrownaxe") || itemName.contains("throwing axe") || itemName.contains("crystal bow") || itemName.equalsIgnoreCase("zaryte bow") || itemName.contains("chinchompa") || itemName.contains("Bolas")) {
    				return 2;
    			}
    		}
    		for (Weapons data : Weapons.values()) {
    			for (int i = 0; i < data.getAmmo().length; i++) {
    				System.out.println(data.getAmmo()[i]);
    				
    				if (player.getEquipment().getAmmoId() == -1) {
    					return 3;
    				}
    				if (player.getEquipment().getAmmoId() == data.getAmmo()[i]) {
    					return 2;
    				}
    				if (player.getEquipment().getWeaponId() == data.getWeaponId()) {
    					return 1;
    				}
    			}
    		}
    		return 0;
    	}
    - Thanks.
    Reply With Quote  
     

  2. #2  
    Banned Ranging Market Banned


    Join Date
    Feb 2018
    Posts
    824
    Thanks given
    9
    Thanks received
    236
    Rep Power
    0
    So the issue is it will fire 1 arrow, then throws an error and stops shooting?
    Reply With Quote  
     

  3. #3  
    Registered Member
    Stimulant's Avatar
    Join Date
    Jan 2013
    Age
    27
    Posts
    1,457
    Thanks given
    248
    Thanks received
    187
    Rep Power
    578
    Quote Originally Posted by Kharyrll. View Post
    So the issue is it will fire 1 arrow, then throws an error and stops shooting?
    No, the bow will be only able to shoot the first arrow in the int[] which is 882, when equipping the other one it will says that my bow is not enough powerful to shoot it.
    Reply With Quote  
     

  4. #4  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Move this part:

    Code:
    				if (player.getEquipment().getWeaponId() == data.getWeaponId()) {
    					return 1;
    				}
    After the 2nd loop:

    Code:
    for (Weapons data : Weapons.values()) {
    			for (int i = 0; i < data.getAmmo().length; i++) {
    				System.out.println(data.getAmmo()[i]);
    				
    				if (player.getEquipment().getAmmoId() == -1) {
    					return 3;
    				}
    				if (player.getEquipment().getAmmoId() == data.getAmmo()[i]) {
    					return 2;
    				}
    			}
    if (player.getEquipment().getWeaponId() == data.getWeaponId()) {
    					return 1;
    				}
    		}
    Project thread
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Registered Member
    Stimulant's Avatar
    Join Date
    Jan 2013
    Age
    27
    Posts
    1,457
    Thanks given
    248
    Thanks received
    187
    Rep Power
    578
    Quote Originally Posted by clem585 View Post
    Move this part:

    Code:
    				if (player.getEquipment().getWeaponId() == data.getWeaponId()) {
    					return 1;
    				}
    After the 2nd loop:

    Code:
    for (Weapons data : Weapons.values()) {
    			for (int i = 0; i < data.getAmmo().length; i++) {
    				System.out.println(data.getAmmo()[i]);
    				
    				if (player.getEquipment().getAmmoId() == -1) {
    					return 3;
    				}
    				if (player.getEquipment().getAmmoId() == data.getAmmo()[i]) {
    					return 2;
    				}
    			}
    if (player.getEquipment().getWeaponId() == data.getWeaponId()) {
    					return 1;
    				}
    		}
    Lmao, thanks it worked.
    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: 2
    Last Post: 05-20-2007, 06:09 AM
  2. [tut]90% Ranging (Missing a few gfx ids)..
    By Santa Clause in forum Tutorials
    Replies: 16
    Last Post: 05-06-2007, 12:04 PM
  3. Cooking - On Range and Fire!
    By Santa Noobie in forum Tutorials
    Replies: 5
    Last Post: 05-04-2007, 04:43 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
  •