Thread: teleport to a droped item

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 teleport to a droped item 
    Donator
    Gladius.'s Avatar
    Join Date
    May 2010
    Posts
    1,160
    Thanks given
    112
    Thanks received
    58
    Rep Power
    11
    can sombody help me with some code i like to have if i drop a item that i can tele to it like on rs the groupgate stone from dungeoneering


    Reply With Quote  
     

  2. #2  
    Donator
    conmenderls's Avatar
    Join Date
    Sep 2014
    Posts
    129
    Thanks given
    15
    Thanks received
    18
    Rep Power
    11
    You could try adding a custom option to it, such as "break" and make it teleport you to specific coordinates.
    Reply With Quote  
     

  3. #3  
    Donator
    Gladius.'s Avatar
    Join Date
    May 2010
    Posts
    1,160
    Thanks given
    112
    Thanks received
    58
    Rep Power
    11
    Quote Originally Posted by Midgars View Post
    You could try adding a custom option to it, such as "break" and make it teleport you to specific coordinates.
    thats not what i ment. when i drop a item on a random x/y coord that i can tele from home to it pick it up then drop it somewhere else and tele to there.
    the item that i drop must be de coords that i tele to


    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Oct 2015
    Posts
    136
    Thanks given
    3
    Thanks received
    7
    Rep Power
    11
    Multiple options, but since this is based on an item only one player can teleport to I'd go with this:
    Save the coords in the player file upon dropping
    Have the teleport wether that be a command, npc or item teleport you to the saved coords.
    Reply With Quote  
     

  5. #5  
    What's a sundial in the shade?

    Lumiere's Avatar
    Join Date
    May 2013
    Age
    27
    Posts
    543
    Thanks given
    224
    Thanks received
    100
    Rep Power
    113
    If you have Ground Items written OO, just have it when the player drops the item, the ground item is saved as a ground item for the player.

    Code:
    private GroundItem personalGatestone;
    
    public final GroundItem getPersonalGatestone() {
            return personalGatestone;
    }
    
    public final Player setPersonalGatestone(final GroundItem gatestone) {
            this.personalGatestone = gatestone;
            return this;
    }
    Then you can call "player.getPersonalGatestone().getPosition()"

    Spoiler for Revy is perfect:
    Reply With Quote  
     

  6. Thankful user:


  7. #6  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Quote Originally Posted by Lumiere View Post
    If you have Ground Items written OO, just have it when the player drops the item, the ground item is saved as a ground item for the player.

    Code:
    private GroundItem personalGatestone;
    
    public final GroundItem getPersonalGatestone() {
            return personalGatestone;
    }
    
    public final Player setPersonalGatestone(final GroundItem gatestone) {
            this.personalGatestone = gatestone;
            return this;
    }
    Then you can call "player.getPersonalGatestone().getPosition()"
    Seems a bit pointless to save the grounditem like that, when all he needs is the position

    If you have a Position or location system you could do it like this:
    Code:
    	private Optional<Position> gatestonePosition = Optional.empty();
    
    	public Optional<Position> getGatestonePosition() {
    		return gatestonePosition;
    	}
    
    	public void setGatestonePosition(Optional<Position> gatestonePosition) {
    		this.gatestonePosition = gatestonePosition;
    	}
    And in Drop packet or where you create ground items:
    Code:
    			if(item.getId() == GATESTONE_ITEM_ID) {
    				player.setGatestonePosition(Optional.of(player.getPosition().copy()));
    			}
    And in pick up:
    Code:
    			if(item.getId() == GATESTONE_ITEM_ID) {
    				player.setGatestonePosition(Optional.empty());
    			}
    When teleporting, have a check similar ot this:

    Code:
    			if(player.getGatestonePosition().isPresent()) {
    				teleportPosition = player.getGatestonePosition().get();
    			}
    If you don't have a position/location system you'll have to use ints for x, y, z, which I don't recommend
    [Today 01:29 AM] RSTrials: Nice 0.97 Win/Loss Ratio luke. That's pretty bad.
    [Today 01:30 AM] Luke132: Ok u fucking moron i forgot i could influence misc.random
    Reply With Quote  
     

  8. Thankful users:


  9. #7  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by Professor Oak View Post
    Seems a bit pointless to save the grounditem like that, when all he needs is the position

    If you have a Position or location system you could do it like this:
    Code:
        private Optional<Position> gatestonePosition = Optional.empty();
    
        public Optional<Position> getGatestonePosition() {
            return gatestonePosition;
        }
    
        public void setGatestonePosition(Optional<Position> gatestonePosition) {
            this.gatestonePosition = gatestonePosition;
        }
    And in Drop packet or where you create ground items:
    Code:
                if(item.getId() == GATESTONE_ITEM_ID) {
                    player.setGatestonePosition(Optional.of(player.getPosition().copy()));
                }
    And in pick up:
    Code:
                if(item.getId() == GATESTONE_ITEM_ID) {
                    player.setGatestonePosition(Optional.empty());
                }
    When teleporting, have a check similar ot this:

    Code:
                if(player.getGatestonePosition().isPresent()) {
                    teleportPosition = player.getGatestonePosition().get();
                }
    If you don't have a position/location system you'll have to use ints for x, y, z, which I don't recommend
    I have to agree, unless the GroundItem is immutable in which case it might be useful to share the information safely. If it's mutable, you might run into some funny stuff.
    Reply With Quote  
     

  10. Thankful users:


  11. #8  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    974
    Thanks given
    688
    Thanks received
    455
    Rep Power
    727
    Quote Originally Posted by Jason View Post
    I have to agree, unless the GroundItem is immutable in which case it might be useful to share the information safely. If it's mutable, you might run into some funny stuff.
    I agree with both of you. But what do you mean about immutability? We won't be even trying to mutate the ground item at all we would just want to gather the position of it.
    Reply With Quote  
     

  12. #9  
    What's a sundial in the shade?

    Lumiere's Avatar
    Join Date
    May 2013
    Age
    27
    Posts
    543
    Thanks given
    224
    Thanks received
    100
    Rep Power
    113
    Yeah, didn't really think of that, just thought of a quick solution for him, but nice.

    Spoiler for Revy is perfect:
    Reply With Quote  
     

  13. #10  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    974
    Thanks given
    688
    Thanks received
    455
    Rep Power
    727
    Quote Originally Posted by Professor Oak View Post
    And in Drop packet or where you create ground items:
    Code:
    			if(item.getId() == GATESTONE_ITEM_ID) {
    				player.setGatestonePosition(Optional.of(player.getPosition().copy()));
    			}
    What is the point of ".copy()" I've seen this so much and I don't understand it lol. player.getPosition() works fine.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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: 41
    Last Post: 07-12-2010, 04:51 AM
  2. Replies: 15
    Last Post: 11-21-2007, 10:52 PM
  3. Teleporting to Random Locations
    By mrgibblet in forum Tutorials
    Replies: 10
    Last Post: 10-23-2007, 04:50 AM
  4. The answer to no 1 iteming...forever.
    By Raid in forum Tutorials
    Replies: 10
    Last Post: 10-19-2007, 04:00 PM
  5. Replies: 8
    Last Post: 07-23-2007, 10:17 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
  •