Thread: Help sending items to floor on death

Results 1 to 4 of 4
  1. #1 Help sending items to floor on death 
    Registered Member
    Join Date
    Jul 2015
    Posts
    2
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    So i don't know to edit the title but i figured it out, this stupid method was removing the ground items when i loaded the map from my a teleport.

    Code:
    public void refreshSpawnedItems() {
    		for (int regionId : getMapRegionsIds()) {
    			List<FloorItem> floorItems = World.getRegion(regionId).getFloorItems();
    			if (floorItems == null)
    				continue;
    			for (FloorItem item : floorItems) {
    				sendMessage("test1");
    				if ((item.isInvisible() || item.isGrave()) && this != item.getOwner() || item.getTile().getPlane() != getPlane())
    					continue;
    				//getPackets().sendRemoveGroundItem(item); debugging as an awful thing (commenting this line out fixed it)
    				getPackets().sendGroundItem(item);
    			}
    		}
    	}




    So whenever one of my players dies, if their inventory contain's more than one of an item that isn't stack-able say like dragon scim for example, only one of the item will drop on the floor, but if they player is in the same region as the re spawn location is set to, all of the items will appear on the floor. Any help would be much appreciated. If the player only has one of the item everything works perfectly as well as if the item is stack-able all of the stack will be on the floor on the death tile.

    sendItemsOnDeath Method
    Code:
    public void sendItemsOnDeath(Player killer) {
    		//if (rights == 2)
    		//	return;
    		WorldTile tile = new WorldTile(getX(), getY(), getPlane());
    		charges.die();
    		auraManager.removeAura();
    		CopyOnWriteArrayList<Item> containedItems = new CopyOnWriteArrayList<Item>();
    		for (int i = 0; i < 14; i++) {
    			if (equipment.getItem(i) != null
    					&& equipment.getItem(i).getId() != -1
    					&& equipment.getItem(i).getAmount() != -1)
    				containedItems.add(new Item(equipment.getItem(i).getId(),
    						equipment.getItem(i).getAmount()));
    		}
    		for (int i = 0; i < 28; i++) {
    			if (inventory.getItem(i) != null
    					&& inventory.getItem(i).getId() != -1
    					&& inventory.getItem(i).getAmount() != -1)
    				containedItems.add(new Item(getInventory().getItem(i).getId(),
    						getInventory().getItem(i).getAmount()));
    		}
    		if (containedItems.isEmpty())
    			return;
    		int keptAmount = 0;
    		if(!(controlerManager.getControler() instanceof CrucibleControler)) {
    			keptAmount = hasSkull() ? 0 : 3;
    			if (prayer.usingPrayer(0, 10) || prayer.usingPrayer(1, 0))
    				keptAmount++;
    		}
    		
    		CopyOnWriteArrayList<Item> keptItems = new CopyOnWriteArrayList<Item>();
    		Item lastItem = new Item(1, 1);
    		for (int i = 0; i < keptAmount; i++) {
    			for (Item item : containedItems) {
    				int price = item.getDefinitions().getValue();
    				if (price >= lastItem.getDefinitions().getValue()) {
    					lastItem = item;
    				}
    			}
    			keptItems.add(lastItem);
    			containedItems.remove(lastItem);
    			lastItem = new Item(1, 1);
    		}
    		inventory.reset();
    		equipment.reset();
    		for (Item item : keptItems) {
    			getInventory().addItem(item);
    		}
    		for (Item item : containedItems) {
    			FloorItemManager.addGroundItem(item, tile, killer == null ? this : killer, false, 20, true, 30);
    		}
    	}
    addGround Item
    Code:
    	public static final void addGroundItem(final Item item, final WorldTile tile, final Player owner, final boolean underGrave, long hiddenTime, boolean invisible, final int publicTime) {
    		final FloorItem floorItem = new FloorItem(item, tile, owner, owner == null ? false : underGrave, invisible);
    		final Region region = World.getRegion(tile.getRegionId());
    		region.forceGetFloorItems().add(floorItem);
    		
    		if (invisible && hiddenTime != -1) {
    			if (owner != null)
    				owner.getPackets().sendGroundItem(floorItem);
    			
    			FloorItemTask task = new FloorItemTask(floorItem, tile, region, owner, underGrave, publicTime);
    			GameEngine.get().slowExecutor().schedule(task, hiddenTime, TimeUnit.SECONDS);
    			return;
    		}
    		
    		int regionId = tile.getRegionId();
    		
    		for (Player player : World.getPlayers()) {
    			if (player == null || !player.hasStarted() || player.hasFinished() || player.getPlane() != tile.getPlane() || !player.getMapRegionsIds().contains(regionId))
    				continue;
    			player.getPackets().sendGroundItem(floorItem);
    		}
    		
    		removeGroundItem(floorItem, publicTime);
    	}
    Last edited by TrickyLicky; 08-03-2015 at 02:57 AM. Reason: fixed
    Reply With Quote  
     

  2. #2  
    Super Donator

    StanDev's Avatar
    Join Date
    Apr 2014
    Posts
    660
    Thanks given
    82
    Thanks received
    255
    Rep Power
    592
    So when you die in lumby and have 2 dscims, bot will be dropped and when you die in edge with 2 dscim only 1 shows up?
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jul 2015
    Posts
    2
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by icebrick View Post
    So when you die in lumby and have 2 dscims, bot will be dropped and when you die in edge with 2 dscim only 1 shows up?
    yes, but only for the owner of the items. After the hiddenTimer expires all of the d scims will apear for every single player except the owner. The owner will only ever have 1 d scim on his death tile.

    - - - Updated - - -

    I have come to the conclussion that it has nothing to do with the player dying at all. If a player drops 5 rocktail from his inventory, teleports away, then teleports back, he will only see 1 rocktail on the ground where he dropped 5. Feel free to leave me any suggestions as i now try to solve this problem. Thanks
    Reply With Quote  
     

  4. #4  
    Super Donator

    StanDev's Avatar
    Join Date
    Apr 2014
    Posts
    660
    Thanks given
    82
    Thanks received
    255
    Rep Power
    592
    Quote Originally Posted by TrickyLicky View Post
    yes, but only for the owner of the items. After the hiddenTimer expires all of the d scims will apear for every single player except the owner. The owner will only ever have 1 d scim on his death tile.

    - - - Updated - - -

    I have come to the conclussion that it has nothing to do with the player dying at all. If a player drops 5 rocktail from his inventory, teleports away, then teleports back, he will only see 1 rocktail on the ground where he dropped 5. Feel free to leave me any suggestions as i now try to solve this problem. Thanks
    That's really weird, well especially the part that other players could see the 5 rocktails, maybe try removing the final modifier from flooritem but I won't really see how that'll work... Maybe try compare ur addgrounditem method with a diff source.
    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: 17
    Last Post: 02-24-2014, 10:08 PM
  2. Replies: 4
    Last Post: 08-14-2013, 09:21 PM
  3. Need some help [PI] Item's kept on death.
    By Bluntarifick in forum Help
    Replies: 4
    Last Post: 01-09-2013, 07:48 PM
  4. need help items wont keep on death
    By d1sturbed in forum Help
    Replies: 1
    Last Post: 09-27-2009, 05:37 AM
  5. Replies: 3
    Last Post: 07-16-2009, 03:38 AM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •