Thread: Redoing Teleport System Again

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Redoing Teleport System Again 
    Banned

    Join Date
    Jun 2012
    Posts
    652
    Thanks given
    233
    Thanks received
    128
    Rep Power
    0
    Some of you may have noticed my Modern Teleports System on the tutorial section from a while back: http://www.rune-server.org/runescape...s-remakes.html

    Well I'm redoing it again to make it even better but I need help. I'm stuck lol.

    Code:
    package server.model.players.content;
       
    import server.Config;
    import server.model.players.Client;
    import server.model.players.*;
    import server.util.Misc;
          
    public class Teleports {
    	
        private static final int
            BLOOD = 565,
            SOUL = 566,
            LAW = 563,
            FIRE = 554,
            WATER = 555,
            AIR = 556,
            EARTH = 557,
            BANANA = 1963;
    
    	//(button, x, y, h , req, exp, rune 1, rune 1 amount, rune 2, rune 2 amount, rune 3, rune 3 amount, rune 4, rune 5 amount, item 1, item 1 amount, type)
    	public static enum teleportData {
    		/* Moderns */
    		MODERNHOME(4161, Config.RESPAWN_X, Config.RESPAWN_Y, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, "modern"),
    		VARROCK(4140, Config.VARROCK_X, Config.VARROCK_Y, 0, 25, 35, AIR, 3, FIRE, 1, LAW, 1, -1, 0, -1, 0, "modern"),
    		LUMBRIDGE(4143, Config.LUMBRIDGE_X, Config.LUMBRIDGE_Y, 0, 31, 41, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "modern"),		
    		FALADOR(4146, Config.FALADOR_X, Config.FALADOR_Y, 0, 37, 48, AIR, 3, WATER, 1, LAW, 1, -1, 0, -1, 0, "modern"), 
    		CAMELOT(4150, Config.CAMELOT_X, Config.CAMELOT_Y, 0, 45, 56, AIR, 5, LAW, 1, -1, 0, -1, 0, -1, 0, "modern"),
    		ARDOUGNE(6004, Config.ARDOUGNE_X, Config.ARDOUGNE_Y, 0, 51, 61, LAW, 2, WATER, 2, -1, 0, -1, 0, -1, 0, "modern"),
    		WATCHTOWER(6005, Config.WATCHTOWER_X, Config.WATCHTOWER_Y, 0, 58, 68, LAW, 2, EARTH, 2, -1, 0, -1, 0, -1, 0, "modern"),
    		TROLLHEIM(29031, Config.TROLLHEIM_X, Config.TROLLHEIM_Y, 0, 61, 68, LAW, 2, FIRE, 2, -1, 0, -1, 0, -1, 0, "modern"),
    		APEATOLL(72038, Config.APEATOLL_X, Config.APEATOLL_Y, 0, 64, 76, FIRE, 2, WATER, 2, LAW, 2, -1, 0, BANANA, 1, "modern"),
    		/* Ancients */
    		ANCIENTHOME(50056 , Config.RESPAWN_X, Config.RESPAWN_Y, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, "ancient"),
    		PADDEWWA(50235, Config.PADDEWWA_X, Config.PADDEWWA_Y, 0, 31, 64, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
    		SENNTISTEN(50245, Config.SENNTISTEN_X, Config.SENNTISTEN_Y, 0, 31, 70, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
    		KHARYLL(50253, Config.KHARYLL_X, Config.KHARYLL_Y, 0, 31, 76, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
    		LASSAR(51005, Config.LASSAR_X, Config.LASSAR_Y, 0, 31, 82, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
    		DAREEYAK(51013, Config.DAREEYAK_X, Config.DAREEYAK_Y, 0, 31, 88, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
    		CARRALLANGAR(51023, Config.CARRALLANGAR_X, Config.CARRALLANGAR_Y, 0, 31, 94, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
    		ANNAKARL(51031, Config.ANNAKARL_X, Config.ANNAKARL_Y, 0, 31, 100, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
    		GHORROCK(51039, Config.GHORROCK_X, Config.GHORROCK_Y, 0, 31, 106, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient");
    		
    		private int button, x, y, h, req, exp, rune1, amount1, rune2, amount2, rune3, amount3, rune4, amount4, item, amount5;
    		private String type;
    		private teleportData(final int button, final int x, final int y, final int h, final int req, final int exp, final int rune1, final int amount1, final int rune2, final int amount2, final int rune3, final int amount3, final int rune4, final int amount4, final int item, final int amount5, final String type) {
    			this.button = button;
    			this.x = x;
    			this.y = y;
    			this.h = h;
    			this.req = req;
    			this.exp = exp;
    			this.rune1 = rune1;
    			this.amount1 = amount1;
    			this.rune2 = rune2;
    			this.amount2 = amount2;
    			this.rune3 = rune3;
    			this.amount3 = amount3;
    			this.rune4 = rune4;
    			this.amount4 = amount4;
    			this.item = item;
    			this.amount5 = amount5;
    			this.type = type;
    		}
    		public int getButton() {
    			return button;
    		}
    		public int getX() {
    			return x;
    		}
    		public int getY() {
    			return y;
    		}
    		public int getH() {
    			return h;
    		}
    		public int getReq() {
    			return req;
    		}
    		public int getExp() {
    			return exp;
    		}
    		public int getR1() {
    			return rune1;
    		}
    		public int getA1() {
    			return amount1;
    		}
    		public int getR2() {
    			return rune2;
    		}
    		public int getA2() {
    			return amount2;
    		}
    		public int getR3() {
    			return rune3;
    		}
    		public int getA3() {
    			return amount3;
    		}
    		public int getR4() {
    			return rune4;
    		}
    		public int getA4() {
    			return amount4;
    		}
    		public int getItem() {
    			return item;
    		}
    		public int getA5() {
    			return amount5;
    		}
    		public String getType() {
    			return type;
    		}
    	}
    	
    	public static boolean isTeleport() {
    		for(final teleportData t : teleportData.values()) {
    			if(t.getType().equals("ancient") || t.getType().equals("modern") || t.getType().equals("lunar")) {
    				return true;
    			}
    		}
    		return false;
    	}
    	
    	public static void handleTeleport(Client c, int actionButtonId, boolean runesReq) {
    		for(final teleportData t : teleportData.values()) {
    			if(t.getReq() > 0) {
    				if(t.getX() > 0 && t.getY() > 0 && t.getH() >= 0) {
    					if(c.playerLevel[6] > t.getReq()) {
    							if(playerHasItem(c, t.getR1(), t.getA1())) { //Need it to check for all runes and see if the need a rune
    							} else {
    								c.sM("You do not have the required runes and or items to cast this spell.");
    								return;
    							}
    					} else {
    						c.sM("You do not have the required magic level to cast this spell.");
    						return;
    					}	
    					startTeleport(c, t.getX()+Misc.random(2), t.getY()+Misc.random(2), t.getH(), t.getType());
    				}
    			}
    		}
        }
    	
        private static boolean playerHasItem(Client c, int itemID, final int amt) {
            itemID++;
            int found = 0;
            for (int i = 0; i < c.playerItems.length; i++) {
                if (c.playerItems[i] == itemID) {
                    if(c.playerItemsN[i] >= amt){
                        return true;
                    } else{ 
                        found++;
                    }
                }
            }
            if(found >= amt) {
                return true;
            }
            return false;
        }
          
        private static int getItemSlot(Client c, final int ItemID) {
            for (int i = 0; i < c.playerItems.length; i++) {
                if(c.playerItems[i] - 1 == ItemID){
                    return i;
                }
            }
            return -1;
        }
    	
    	 public static void startTeleport(Client c, int x, int y, int height, String teleportType) {
    		if(c.duelStatus == 5) { c.sM("You can't teleport during a duel!"); return; }
    		if(c.inWild() && c.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) { 
    			c.sM("You can't teleport above level "+Config.NO_TELEPORT_WILD_LEVEL+" in the wilderness."); return; }
    		if(System.currentTimeMillis() - c.teleBlockDelay < c.teleBlockLength) { c.sM("You are teleblocked and can't teleport."); return; }
    		if(!c.isDead && c.teleTimer == 0 && c.respawnTimer == -6) {
    			if (c.playerIndex > 0 || c.npcIndex > 0)
    				c.getCombat().resetPlayerAttack();
    				c.stopMovement();
    				c.getPA().removeAllWindows();				
    				c.teleX = x;
    				c.teleY = y;
    				c.updateWalkEntities();
    				c.npcIndex = 0;
    				c.playerIndex = 0;
    				c.faceUpdate(0);
    				c.teleHeight = height;
    			if(teleportType.equalsIgnoreCase("modern")) {
    				c.startAnimation(8939);
    				c.teleTimer = 9;
    				c.gfx0(1576);
    				c.teleEndAnimation = 8941;
    			}	 
    			if(teleportType.equalsIgnoreCase("ancient")) {
    				c.startAnimation(9599);
    				c.teleGfx = 0;
    				c.teleTimer = 11;
    				c.teleEndAnimation = 8941;
    				c.gfx0(1681);
    			}
    			if (teleportType.equalsIgnoreCase("lunar")) {
    				c.startAnimation(9606);
    				c.teleGfx = 0;
    				c.teleTimer = 13;
    				c.teleEndAnimation = 9013;
    				c.gfx0(1685);
    			}
    			if (teleportType.equalsIgnoreCase("ring")) {
    				c.startAnimation(9603);
    				c.teleGfx = 0;
    				c.teleTimer = 11;
    				c.gfx0(1684);
    			}
    			if (teleportType.equalsIgnoreCase("teletab")) {
    				c.startAnimation(9597);
    				c.teleGfx = 0;
    				c.teleTimer = 6;
    				c.teleEndAnimation = 9598;
    				c.gfx0(1680);
    			}
    		}
    	}
    }
    I need to add checking for runes and removing of them. As well as adding of xp. In the enum a value of -1 is supposed to be no rune req. How do I check all of them and delete them as required. Also I tested it without the rune req's or anything and it just kept teleporting me to the same place.(Guessing I missed an if statement for a value. Not sure.) Hopefully we can get this done because It's already a really nice system I just need to get everything working.
    Reply With Quote  
     

  2. #2  
    #Flippergang

    Alberto's Avatar
    Join Date
    May 2008
    Posts
    756
    Thanks given
    46
    Thanks received
    40
    Rep Power
    121
    What the hell does this do?

    Code:
       public static boolean isTeleport(Client c) {
            for(final teleportData t : teleportData.values()) {
                if(t.getType().equals("ancient") || t.getType().equals("modern") || t.getType().equals("lunar")) {
                    return true;
                }
            }
            return false;
        }
    Client c <-- never used. And this method is always going to return true. What's the point of it?
    Hopes and Dreams
    Need something programmed and willing to pay?
    Pm me.
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jun 2012
    Posts
    652
    Thanks given
    233
    Thanks received
    128
    Rep Power
    0
    Quote Originally Posted by Alberto View Post
    What the hell does this do?

    Code:
       public static boolean isTeleport(Client c) {
            for(final teleportData t : teleportData.values()) {
                if(t.getType().equals("ancient") || t.getType().equals("modern") || t.getType().equals("lunar")) {
                    return true;
                }
            }
            return false;
        }
    Client c <-- never used. And this method is always going to return true. What's the point of it?
    Code:
    if(Teleports.isTeleport()) {
    			Teleports.handleTeleport(c, actionButtonId);
    		}
    Thanks for pointing that out.

    It checks if it is a teleport I need a better way to do it.
    Reply With Quote  
     

  4. #4  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    this.rune1 = rune1;
    this.amount1 = amount1;
    this.rune2 = rune2;
    this.amount2 = amount2;
    this.rune3 = rune3;
    this.amount3 = amount3;
    this.rune4 = rune4;
    this.amount4 = amount4;


    I'm sure you didn't use all of these for nothing..

    Enable then checkItems for all of them in StartTeleport

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jun 2012
    Posts
    652
    Thanks given
    233
    Thanks received
    128
    Rep Power
    0
    I don't know what to do if the value is -1 for the rune req.
    Reply With Quote  
     

  6. #6  
    #Flippergang

    Alberto's Avatar
    Join Date
    May 2008
    Posts
    756
    Thanks given
    46
    Thanks received
    40
    Rep Power
    121
    if( itemsNeeded != -1) {
    deleteItem blabalbal
    Hopes and Dreams
    Need something programmed and willing to pay?
    Pm me.
    Reply With Quote  
     

  7. #7  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Something like this;


    if (c.playerHasItem(getR1(), getA1()) &&
    c.playerHasItem(getR2(), getA2()) &&
    c.playerHasItem(getR3(), getA3()) &&
    c.playerHasItem(getR3(), getA3()) &&
    c.playerHasItem(getR3(), getA3()) &&
    c.playerHasItem(getR4(), getA4()) &&
    c.playerHasItem(getItem(), getA5()) &&
    getR1() != -1 || getA1() != -1) ||
    getR2() != -1 || getA2() != -1) ||
    getR3() != -1 || getA3() != -1) ||
    getR3() != -1 || getA3() != -1) ||
    getR4() != -1 || getA4() != -1) ||
    getItem() != -1 || getA5() != -1) {

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Dec 2012
    Posts
    56
    Thanks given
    1
    Thanks received
    15
    Rep Power
    36
    Use an array for the runes + the amounts to make things easier
    (new int[] = {555, 1}; ect.)
    Reply With Quote  
     

  9. #9  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Quote Originally Posted by 2chainz View Post
    Use an array for the runes + the amounts to make things easier
    (new int[] = {555, 1}; ect.)
    You name


    Anyways, enums > arrays.

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  10. #10  
    Banned

    Join Date
    Nov 2012
    Posts
    36
    Thanks given
    2
    Thanks received
    11
    Rep Power
    0
    Code:
    package com.rs.model;
    
    import com.rs.model.player.Player;
    
    public class TeleportHandler {
    	
    	private enum Spellbook {
    		MODERNS, ANCIENTS, LUNARS;
    	}
    	
    	private enum Teleport {
    				
    		LUMBRIDGE(3223, 3218, 0, Spellbook.MODERNS);
    		
    		private int x,z,y;
    		private Spellbook spellbook;
    		
    		private Teleport(int x, int y, int z, Spellbook type) {
    			this.x = x;
    			this.y = y;
    			this.z = z;
    			this.spellbook = type;
    		}
    		
    		public int getX() {
    			return this.x;
    		}
    		
    		public int getY() {
    			return this.y;
    		}
    		
    		public int getZ() {
    			return this.z;
    		}
    		
    		public Spellbook getSpellbook() {
    			return this.spellbook;
    		}
    				
    	}
    	
    	public void doTeleport(Player player, String location) {
    		Teleport teleport = Teleport.valueOf(location);
    		Spellbook spellbook = teleport.getSpellbook();
    		if(!spellbook.equals(player.getSpellbook())) {
    			return;//client hack
    		}
    		int anim = -1, gfx = -1;
    		if(spellbook.equals(Spellbook.MODERNS)) {
    			anim = 8939;
    			gfx = 1576;
    		} else if(spellbook.equals(Spellbook.ANCIENTS)){ 
    			anim = 9599;
    			gfx = 0;
    		} else if(spellbook.equals(Spellbook.LUNARS)) { 
    			anim = 9606;
    			gfx = 1685;
    		}
    		if(anim >= 0) {
    			player.doAnimation(anim);
    		}
    		if(gfx >= 0) {
    			player.doGfx(gfx);
    		}
    		int x = teleport.getX();
    		int y = teleport.getY();
    		int z =  teleport.getZ();
    		player.doTeleport(x, y, z);
    	}
    	
    }
    Code:
    TeleportHandler.doTeleport(player, "LUMBRIDGE");
    I just wrote this up now in Eclipse, I haven't tested it yet. However, all that's needed is an item checking system/concept. I hope this helps.

    Also just a tip about enumeration (I learnt this just now as this is my first time doing one), when you call the valueOf() method from the Enum class and if the value is a null the server will throw an exception. You may want to add an exception handler, at your own choice.

    Edit: Here's the type of error the server will throw if you enter and invalid argument: java.lang.IllegalArgumentException.
    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. [DF] Teleport System
    By dead fury in forum Show-off
    Replies: 7
    Last Post: 10-29-2012, 04:51 AM
  2. [PI] Better teleport system
    By OFF YOUR TITS in forum Snippets
    Replies: 16
    Last Post: 10-26-2012, 11:57 PM
  3. pi redoing drops system
    By deans1243 in forum Requests
    Replies: 0
    Last Post: 11-19-2010, 11:15 PM
  4. im redoing my site
    By Clienthax in forum RS 503+ Client & Server
    Replies: 12
    Last Post: 03-22-2009, 11:47 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
  •