Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropped GroundItems are never made globally visible #352

Open
tlf30 opened this issue Sep 13, 2017 · 12 comments
Open

Dropped GroundItems are never made globally visible #352

tlf30 opened this issue Sep 13, 2017 · 12 comments
Labels
bug Incorrect or broken functionality documentation high priority Should be fixed as soon as feasible

Comments

@tlf30
Copy link
Contributor

tlf30 commented Sep 13, 2017

Hello,
So I was doing some tests.
Performing

val g = GroundItem.dropped(...)
player.world.spawn(g)

Does not show anything in the world
But doing

val g = GroundItem.create(...)
player.world.spawn(g)

Does show the items in the world.

I think this is an issue, or are we only supposed to run GroundItem.create when we want an item to be visible?

@Major- Major- added the bug Incorrect or broken functionality label Sep 14, 2017
@garyttierney garyttierney added documentation and removed bug Incorrect or broken functionality labels Sep 16, 2017
@garyttierney
Copy link
Contributor

@Major- we discussed this on IRC before and the conclusion was that it is intended behaviour. Is that right? I think that needs documented.

@tlf30
Copy link
Contributor Author

tlf30 commented Sep 16, 2017

If this is intended functionality, what would be a use case for GroundItem.dropped? When a user drops an item, should that use GroundItem.create? I guess I am confused because of what the javadocs state.

/**
* Creates a new GroundItem.
*
* @param world The {@link World} containing the GroundItem.
* @param position The {@link Position} of the Item.
* @param item The Item displayed on the ground.
* @return The GroundItem.
*/
public static GroundItem create(World world, Position position, Item item) {
return new GroundItem(world, position, item, -1);
}
/**
* Creates a new dropped GroundItem.
*
* @param world The {@link World} containing the GroundItem.
* @param position The {@link Position} of the Item.
* @param item The Item displayed on the ground.
* @param owner The the {@link Player} who dropped this GroundItem.
* @return The GroundItem.
*/
public static GroundItem dropped(World world, Position position, Item item, Player owner) {
return new GroundItem(world, position, item, owner.getIndex());
}

The only difference that I can tell between the two is that dropped assigns an owner. Should the item be visible to the owner when dropped?

@garyttierney
Copy link
Contributor

<Major_RS> first one (create): send only to the player who dropped it at the time they drop it. second one (dropped): send to everyone, the client of the player who dropped it filters it out so it doesnt show twice

@Major-
Copy link
Member

Major- commented Sep 16, 2017

Oh yeah nvm this is intended, the method names aren't very useful though. Maybe we should move GroundItem#dropped to Player#drop?

@tlf30
Copy link
Contributor Author

tlf30 commented Sep 16, 2017

Understood, so when an item is dropped, then both need to get called? How does create know which player dropped the item?

@Major-
Copy link
Member

Major- commented Sep 16, 2017

GroundItem.dropped is for ground items that should only be visible to a specific player when first spawned (like when a player drops an item, or kills a monster that drops items). In these situations the dropped item is only visible to the owner (player) for 60 seconds; after that it becomes visible to everyone else.
GroundItem.dropped actually means "display this item for every player but the owner".

Use GroundItem.create if you want an item that is globally visible from the moment it's spawned, like for items that respawn endlessly (e.g. the mind rune in lumbridge castle), or balloons in the party room.

@tlf30
Copy link
Contributor Author

tlf30 commented Sep 16, 2017

OK, That makes sense. Thank you!
EDIT: Those would be great descriptions for the javadocs

@tlf30
Copy link
Contributor Author

tlf30 commented Sep 16, 2017

So this is the test I wrote

import org.apollo.game.action.Action
import org.apollo.game.message.impl.InventoryItemMessage
import org.apollo.game.model.Item
import org.apollo.game.model.entity.Entity
import org.apollo.game.model.entity.EntityType
import org.apollo.game.model.entity.GroundItem
import org.apollo.game.model.entity.Player

class DropItemAction(val player: Player, val item: Int): Action<Player>(0, true, player) {
    override fun execute() {
        val region = player.world.regionRepository.fromPosition(player.position)
        if (region.getEntities<Entity>(player.position, EntityType.DYNAMIC_OBJECT, EntityType.STATIC_OBJECT).isEmpty()) {
            val amount = player.inventory.getAmount(item)
            System.out.println(amount)
            player.inventory.remove(item, amount)
            val groundItem = GroundItem.dropped(player.world, player.position, Item(item, amount), player)
            player.world.spawn(groundItem)
        } else {
            player.sendMessage("You cannot drop this here.")
        }
        stop()
    }

}

on {InventoryItemMessage::class}
        .where {option == 5 && interfaceId == 3214}
        .then {
            it.startAction(DropItemAction(it, id))
            terminate()
        }

When I drop an item I cannot see it, but other clients can immediately. After 60 seconds there is still no change.

If I change it to use GroundItem.create then the item shows on all clients immediately.

@Major-
Copy link
Member

Major- commented Sep 16, 2017

Yeah looks like nobody ever got round to writing a Task that replaces the private dropped items with public ones

@Major- Major- changed the title GroundItem.dropped not visible, but GroundItem.create are Dropped GroundItems are never made globally visible Sep 16, 2017
@Major- Major- added bug Incorrect or broken functionality high priority Should be fixed as soon as feasible labels Sep 16, 2017
@Major-
Copy link
Member

Major- commented Sep 16, 2017

So we need some sort of management for dropping/spawning grounditems basically

(edit: Oops deleting that comment was an accident, sorry)

@apollo-rsps apollo-rsps deleted a comment from tlf30 Sep 16, 2017
@tlf30
Copy link
Contributor Author

tlf30 commented Sep 16, 2017

No worries!

@Major-
Copy link
Member

Major- commented Sep 24, 2017

Blocking #349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect or broken functionality documentation high priority Should be fixed as soon as feasible
Projects
None yet
Development

No branches or pull requests

3 participants