Thread: [Hyperion] Stackable arrows on drop

Results 1 to 10 of 10
  1. #1 [Hyperion] Stackable arrows on drop 
    Registered Member
    Riedell's Avatar
    Join Date
    Feb 2008
    Age
    31
    Posts
    403
    Thanks given
    4
    Thanks received
    2
    Rep Power
    152
    Seem to cannot fix this issue. Using 459 hyperion base, has anyone seemed to find the solution to this? I can post methods of where its called.
    ~Riedell
    Reply With Quote  
     

  2. #2  
    Registered Member
    Riedell's Avatar
    Join Date
    Feb 2008
    Age
    31
    Posts
    403
    Thanks given
    4
    Thanks received
    2
    Rep Power
    152
    Still looking for some assistance. New to hyperion.
    ~Riedell
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Nov 2013
    Posts
    270
    Thanks given
    107
    Thanks received
    76
    Rep Power
    0
    I would iterate through your list of ground items to check if there's an existing arrow on that tile. If so just update the count by 1.
    Reply With Quote  
     

  4. #4  
    Banned [Hyperion] Stackable arrows on drop Market Banned


    Join Date
    Jan 2011
    Age
    26
    Posts
    3,112
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    what exactly do you need help with? explain in-depth please
    Reply With Quote  
     

  5. #5  
    Registered Member
    Riedell's Avatar
    Join Date
    Feb 2008
    Age
    31
    Posts
    403
    Thanks given
    4
    Thanks received
    2
    Rep Power
    152
    Basically, when an arrow is shot, it does a simple check to see if the current ground item is stackable. If so, it then checks to see if it exists. Afterwards, it will increase the count, remove the old ground item then replace it with the new item. Right now, the arrows (in this case yes) drop 2 at a time and still trying to resolve this issue.

    Heres the code I wrote up and isnt fully working yet. This is my issue here.

    Code:
    	public void addGroundItem(GroundItem item, boolean showToAll, Player player) {
    		player.getActionSender().sendCreateGroundItem(item);
    		Region region = World.getWorld().getRegionManager().getRegionByLocation(item.getLocation());
    		region.addGroundItem(item);
    		if (item.getItem().getDefinition().isStackable()) {
    			if(groundItemExists(item.getLocation(), item)) {
    				item.getItem().increaseCount(item.getItem().getCount());
    				player.getActionSender().sendDestroyGroundItem(item);
    				player.getActionSender().sendCreateGroundItem(item);
    				return;
    			}
    		}
    		if (showToAll) {
    			World.getWorld().submit(new GroundItemEvent(item, Function.SHOW));
    		}
    		World.getWorld().submit(new GroundItemEvent(item, Function.REMOVE));
    	}
    ~Riedell
    Reply With Quote  
     

  6. #6  
    Registered Member
    Riedell's Avatar
    Join Date
    Feb 2008
    Age
    31
    Posts
    403
    Thanks given
    4
    Thanks received
    2
    Rep Power
    152
    Here's something that looks like it will work, but still is not stacking the arrows on top of each other. Anyone have some input?

    Code:
    	public void addGroundItem(GroundItem item, boolean showToAll, Player player) {
    		player.getActionSender().sendCreateGroundItem(item);
    		Region region = World.getWorld().getRegionManager().getRegionByLocation(item.getLocation());
    		region.addGroundItem(item);
    		if (item.getItem().getDefinition().isStackable()) {
    			for(GroundItem gI : region.getGroundItems()) {
    				if (gI.getLocation().equals(item.getLocation()) && gI.getItem().getId() == item.getItem().getId()) {
    					gI.getItem().increaseCount(gI.getItem().getCount() + item.getItem().getCount());
    					player.getActionSender().sendDestroyGroundItem(item);
    					player.getActionSender().sendCreateGroundItem(item);
    					break;
    				}
    			}
    		}
    		if (showToAll) {
    			World.getWorld().submit(new GroundItemEvent(item, Function.SHOW));
    		}
    		World.getWorld().submit(new GroundItemEvent(item, Function.REMOVE));
    	}
    ~Riedell
    Reply With Quote  
     

  7. #7  
    Registered Member
    Riedell's Avatar
    Join Date
    Feb 2008
    Age
    31
    Posts
    403
    Thanks given
    4
    Thanks received
    2
    Rep Power
    152
    Still having this issue.
    ~Riedell
    Reply With Quote  
     

  8. #8  
    Banned [Hyperion] Stackable arrows on drop Market Banned


    Join Date
    Jan 2011
    Age
    26
    Posts
    3,112
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    i actually did this for my combat base yesterday and got it working fine, I'll post the code once I'm home
    Reply With Quote  
     

  9. #9  
    Registered Member
    Riedell's Avatar
    Join Date
    Feb 2008
    Age
    31
    Posts
    403
    Thanks given
    4
    Thanks received
    2
    Rep Power
    152
    Quote Originally Posted by lare96 View Post
    i actually did this for my combat base yesterday and got it working fine, I'll post the code once I'm home
    I'd like to see how you did it. Please and thank you
    ~Riedell
    Reply With Quote  
     

  10. #10  
    Banned [Hyperion] Stackable arrows on drop Market Banned


    Join Date
    Jan 2011
    Age
    26
    Posts
    3,112
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Quote Originally Posted by Riedell View Post
    I'd like to see how you did it. Please and thank you
    Code:
        /**
         * Registers a new ground item and stacks it on top of any existing ground
         * items with the same id.
         * 
         * @param registerable
         *        the ground item to register and stack if applicable.
         */
        public void registerAndStack(GroundItem registerable) {
            int itemCount = 0;
    
            for (Iterator<GroundItem> iterator = itemList.iterator(); iterator.hasNext();) {
                GroundItem item = iterator.next();
    
                if (item == null) {
                    continue;
                }
    
                if (item.getItem().getId() == registerable.getItem().getId() && item.getPosition().equals(registerable.getPosition()) && item.getPlayer().getUsername().equals(registerable.getPlayer().getUsername())) {
                    itemCount += item.getItem().getAmount();
                    item.fireOnUnregister();
                    iterator.remove();
                }
            }
    
            registerable.getItem().incrementAmountBy(itemCount);
    
            /** Fire the item's registration event. */
            registerable.fireOnRegister();
    
            /** Add the item in the database. */
            itemList.add(registerable);
        }
    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. [Hyperion] Fury arrow drop when shot
    By Mpeg in forum Snippets
    Replies: 3
    Last Post: 02-15-2014, 11:58 AM
  2. How to make stackable arrows on ground
    By Soulevoker in forum Help
    Replies: 3
    Last Post: 02-16-2010, 02:09 AM
  3. Custom Stackables (Arrows)
    By ViperSniper in forum Snippets
    Replies: 9
    Last Post: 06-16-2009, 04:21 AM
  4. Replies: 11
    Last Post: 06-05-2009, 09:01 AM
  5. Help Me On Drop Rates
    By 2richdeens in forum Help
    Replies: 0
    Last Post: 11-02-2008, 01:51 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
  •