Thread: LocationCrystal

Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1 LocationCrystal 
    *breaks walking*

    Cody_'s Avatar
    Join Date
    Dec 2010
    Posts
    717
    Thanks given
    198
    Thanks received
    189
    Discord
    View profile
    Rep Power
    267
    This is a very much improved LocationCrystal, similar to the other ones released that save a location, and you can teleport back to it later.

    This has the ability to save up to 3 locations, give each of them whatever name you would like (up to 12 chars), and teleport to any of them at any time.

    Once a location is saved, you can delete it, teleport to it, or rename it.
    And from the main menu, you can delete all saved teleports, or save a new teleport.

    Doesn't work in controllers, you'll have to add more checks though.






    Code:
    package com.rs.game.player.content;
    
    import java.io.Serializable;
    
    import com.rs.game.WorldTile;
    import com.rs.game.player.Player;
    import com.rs.game.player.dialogues.Dialogue;
    
    /**
     * 
     * @author Cody
     *
     */
    
    public class LocationCrystal implements Serializable {
    	
    	private static final long serialVersionUID = -3788650257010921632L;
    	private Player player;
    	private transient WorldTile tile;
    	private Location[] locations;
    	
    	public LocationCrystal(Player player) {
    		this.player = player;
    		locations = new Location[3];
    		for(int i = 0; i < locations.length; i++)
    			locations[i] = new Location("Empty", null);
    	}
    	
    	public void handleClick() {
    		if(locations == null) {
    			locations = new Location[3];
    			for(int i = 0; i < locations.length; i++)
    				locations[i] = new Location("Empty", null);
    		}
    		player.getDialogueManager().startDialogue(new Dialogue() {
    			
    			private int index;
    
    			@Override
    			public void start() {
    				if(player.getControllerManager().getControler() != null) {
    					player.getPackets().sendGameMessage("You're too busy to do this.");
    					end();
    					return;
    				}
    				sendOptionsDialogue("Select an Option", "View saved locations", "Save new location", "Delete all saved locations", "Nothing");
    			}
    
    			@Override
    			public void run(int interfaceId, int componentId) {
    				if(stage == -1) {
    					if(componentId == OPTION_1) {
    						String[] names = new String[4];
    						for(int i = 0; i < locations.length; i++)
    							names[i] = locations[i].getName();
    						names[3] = "Nothing";
    						sendOptionsDialogue("Select an Option", names);
    						stage = 0;
    					} else if(componentId == OPTION_2) {
    						index = -1;
    						for(int i = 0; i < locations.length; i++) {
    							if(locations[i].getName().toLowerCase().equals("empty"))
    								index = i;
    						}
    						if(index == -1) {
    							sendDialogue("You have no empty locations left. You must delete one before you can save another.");
    							stage = 1;
    							return;
    						}
    						tile = new WorldTile(player.getX(), player.getY(), player.getPlane());
    						player.getTemporaryAttributtes().put("LocationCrystal", index);
    						player.getPackets().sendInputNameScript("Enter location name");
    						stage = 2;
    					} else if(componentId == OPTION_3) {
    						sendOptionsDialogue("Are you sure?", "Yes", "No");
    						stage = 3;
    					} else
    						end();
    				} else if(stage == 0) {
    					index = 0;
    					if(componentId == OPTION_1)
    						index = 0;
    					else if(componentId == OPTION_2)
    						index = 1;
    					else if(componentId == OPTION_3)
    						index = 2;
    					else {
    						end();
    						return;
    					}
    					Location location = locations[index];
    					if(location.getName().toLowerCase().equals("empty")) {
    						sendOptionsDialogue("Select an Option", "Save new location", "Nothing");
    						stage = 4;
    					} else {
    						sendOptionsDialogue("Select an Option", "Teleport to location", "Delete location", "Rename", "Nothing");
    						stage = 5;
    					}
    				} else if(stage == 1) {
    					end();
    				} else if(stage == 2) {
    					end();
    				} else if(stage == 3) {
    					if(componentId == OPTION_1) {
    						locations = new Location[3];
    						for(int i = 0; i < locations.length; i++)
    							locations[i] = new Location("Empty", null);
    					}
    					end();
    				} else if(stage == 4) {
    					if(componentId == OPTION_1) {
    						tile = new WorldTile(player.getX(), player.getY(), player.getPlane());
    						player.getTemporaryAttributtes().put("LocationCrystal", index);
    						player.getPackets().sendInputNameScript("Enter location name");
    						stage = 2;
    					} else
    						end();
    				} else if(stage == 5) {
    					Location location = locations[index];
    					if(componentId == OPTION_1)
    						Magic.sendNormalTeleportSpell(player, 0, 0, location.getTile());
    					else if(componentId == OPTION_2) {
    						sendOptionsDialogue("Are you sure?", "Yes", "No");
    						stage = 6;
    					} else if(componentId == OPTION_3) {
    						player.getTemporaryAttributtes().put("LocationCrystal", index);
    						player.getPackets().sendInputNameScript("Enter new name");
    						stage = 2;
    					} else
    						end();
    				} else if(stage == 6) {
    					if(componentId == OPTION_1)
    						locations[index] = new Location("Empty", null);
    					end();
    				}
    			}
    
    			@Override
    			public void finish() {
    				player.getInterfaceManager().closeChatBoxInterface();
    			}
    			
    		});
    	}
    	
    	public void saveLocation(String name, int index) {
    		locations[index] = new Location(name, tile);
    		player.getDialogueManager().finishDialogue();
    		player.getPackets().sendGameMessage("Your location has been saved.");
    	}
    	
    	public class Location implements Serializable {
    
    		private static final long serialVersionUID = -1921478357927613366L;
    		
    		private String name;
    		private WorldTile tile;
    		
    		public Location(String name, WorldTile tile) {
    			this.name = name;
    			this.tile = tile;
    		}
    		
    		public String getName() {
    			return name;
    		}
    		
    		public WorldTile getTile() {
    			return tile;
    		}
    	}
    
    }
    In WorldPacketsDecoder, under the ENTER_NAME_PACKET:

    Code:
    } else if(player.getTemporaryAttributtes().get("LocationCrystal") != null) {
    				int index = (Integer) player.getTemporaryAttributtes().remove("LocationCrystal");
    				player.getLocationCrystal().saveLocation(value, index);
    				return;
    			}
    In the player class, just do:

    Code:
    private LocationCrystal crystal;
    Inside the init() method, and inside the player constructors, add:

    Code:
    if(crystal == null) crystal = new LocationCrystal(this);
    also add:

    Code:
    public LocationCrystal getLocationCrystal() {
    return crystal;
    }
    (Sorry for conventions, writing this right on rune-server new thread thing)

    finally, in an item click, or however you're making this:

    Code:
    player.getLocationCrystal().handleClick();
    and bam.

    Any errors you get, unless an error in MY code, you can figure out yourself.
    Reply With Quote  
     

  2. #2  
    Registered Member Jem Finch's Avatar
    Join Date
    Dec 2013
    Posts
    104
    Thanks given
    6
    Thanks received
    0
    Rep Power
    11
    nice
    proof of ownership (Kyle_Friz) - 8/17/17
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Jun 2012
    Posts
    320
    Thanks given
    51
    Thanks received
    19
    Rep Power
    0
    Good work dude
    Reply With Quote  
     

  4. #4  
    Registered Member PavSwag's Avatar
    Join Date
    Jul 2012
    Posts
    1,079
    Thanks given
    310
    Thanks received
    98
    Rep Power
    57
    Is that a custom made area? Never seen it before..
    changing osrs forever
    Reply With Quote  
     

  5. #5  
    Exoria
    Aksel's Avatar
    Join Date
    Jan 2012
    Age
    25
    Posts
    1,449
    Thanks given
    238
    Thanks received
    498
    Rep Power
    56
    this is actually kinda neat.
    Reply With Quote  
     

  6. #6  
    Member Market Banned Market Banned
    MaxXi's Avatar
    Join Date
    Jun 2012
    Posts
    765
    Thanks given
    43
    Thanks received
    105
    Rep Power
    12
    Nice looks good.
    Reply With Quote  
     

  7. #7  
    ♢♢♢♢♢♢

    Con Artist's Avatar
    Join Date
    Jan 2012
    Posts
    1,354
    Thanks given
    665
    Thanks received
    307
    Rep Power
    386
    Quote Originally Posted by PavSwag View Post
    Is that a custom made area? Never seen it before..
    its area from some quest, its avaible on 317 coords


    and this is looking good


    widdy widdy


    /|\
    / \

    Reply With Quote  
     

  8. #8  
    Banned
    Join Date
    Nov 2012
    Posts
    122
    Thanks given
    17
    Thanks received
    11
    Rep Power
    0
    Code:
          if(player.getControllerManager().getControler() != null) {
                        player.getPackets().sendGameMessage("You're too busy to do this.");
                        end();
                        return;
                    }
    Finally someone with a good mind.
    Reply With Quote  
     

  9. #9  
    (づ。◕‿‿◕。)づ
    macalroy's Avatar
    Join Date
    Jun 2011
    Posts
    1,123
    Thanks given
    717
    Thanks received
    297
    Rep Power
    12
    Quote Originally Posted by Ozie View Post
    Code:
          if(player.getControllerManager().getControler() != null) {
                        player.getPackets().sendGameMessage("You're too busy to do this.");
                        end();
                        return;
                    }
    Finally someone with a good mind.
    What are you even talking about? That's simple shit.

    Reply With Quote  
     

  10. #10  
    Banned
    Join Date
    Nov 2012
    Posts
    122
    Thanks given
    17
    Thanks received
    11
    Rep Power
    0
    Quote Originally Posted by Orient View Post
    What are you even talking about? That's simple shit.
    Its because people wants their players to get stuck in Dynamic regions etc.
    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

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