Thread: [Any Revision] Area System ;)

Page 1 of 8 123 ... LastLast
Results 1 to 10 of 71
  1. #1 [Any Revision] Area System ;) 
    Banned

    Join Date
    Oct 2011
    Age
    27
    Posts
    2,566
    Thanks given
    1,027
    Thanks received
    1,168
    Rep Power
    0
    Seen a few of these so decided to release this.

    What you are adding:
    This system basically groups a certain number of coordinates and gives it a name (makes an area).

    e.g. It would draw a shape or a group of shapes around a certain area like Wizards Tower (see below) and all the tiles inside that shape are now part of that area. A single shape is used for wizards tower but for areas like Lumbridge you'd use a polygon to mark the Lumbridge area, then a rectangle to mark the chest room down the kitchen and both these groups of tiles will be part of an 'area' called Lumbridge.

    Here's a picture of what you're adding, and how it works:




    Code:
    package org.fb.game.world.area;
    
    import java.util.LinkedList;
    import java.util.List;
    
    import org.fb.game.entity.character.player.Player;
    
    public abstract class Area {
    
    	private List<Player> players = new LinkedList<Player>();
    
    	public abstract Area update();
    
    	public abstract String name();
    
    	public abstract Shape[] shapes();
    
    	public abstract boolean member();
    
    	public abstract Environment environment();
    
    	public List<Player> players() {
    		return players;
    	}
    
    	public enum Environment {
    		NORMAL,
    		DESERT,
    		GODWARS;
    	}
    
    }
    Code:
    package org.frostblades.game.world.area;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import org.frostblades.GameServer;
    import org.frostblades.engine.GameEngine;
    import org.frostblades.engine.task.Task;
    import org.frostblades.game.Location;
    import org.frostblades.game.entity.character.player.Player;
    import org.frostblades.game.world.area.impl.Alkharid;
    import org.frostblades.game.world.area.impl.Falador;
    import org.frostblades.game.world.area.impl.Lumbridge;
    import org.frostblades.game.world.area.impl.Varrock;
    import org.frostblades.utils.Utils;
    
    public class AreaManager {
    
    	private static List<Area> areas;
    
    	public static void init() {
    		try {
    			areas(new ArrayList<Area>());
    			areas().add(new Varrock());
    			areas().add(new Falador());
    			areas().add(new Lumbridge());
    			areas().add(new Alkharid());
    		} catch (Exception e) {
    			GameServer.get().logger().error(e);
    		}
    	}
    
    	public static Area get(final Location location) {
    		try {
    			Area current = null;
    			boolean found = false;
    			for (Area area : areas()) {
    
    				for (Shape shape : area.shapes()) {
    
    					if (shape.inside(location)) {
    						current = area;
    						found = true;
    						break;
    					}
    
    				}
    
    				if (!found)
    					continue;
    
    				return current;
    			}
    		} catch (Exception e) {
    			GameServer.get().logger().error(e);
    		}
    		return null;
    	}
    
    	public static void update(final Player player, final Area area) {
    		if (player.getBoneDelay() > Utils.currentTimeMillis())
    			return;
    		player.packets().sendIComponentText(1073, 10, "<col=ffffff>You have reached");
    		player.packets().sendIComponentText(1073, 11, "<col=ffcff00>" + area.name());
    		player.interfaceManager().sendTab(player.interfaceManager().hasRezizableScreen() ? 1 : 11, 1073);
    		GameEngine.get().addTask(new Task(3) {
    			@Override
    			public void execute() {
    				player.packets().closeInterface(player.interfaceManager().hasRezizableScreen() ? 1 : 11);
    				stop();
    			}
    		});
    	}
    
    	public static List<Area> areas() {
    		return areas;
    	}
    
    	public static void areas(List<Area> list) {
    		areas = list;
    	}
    
    }
    Code:
    package org.frostblades.game.world.area;
    
    import org.frostblades.game.Location;
    
    public abstract class Shape {
    
    	private Location[] areas;
    	private ShapeType type;
    
    	public abstract boolean inside(Location location);
    	
    	public Location[] areas() {
    		return areas;
    	}
    
    	public Shape areas(Location[] areas) {
    		this.areas = areas;
    		return this;
    	}
    
    	public ShapeType type() {
    		return type;
    	}
    
    	public Shape type(ShapeType type) {
    		this.type = type;
    		return this;
    	}
    
    	public enum ShapeType {
    		RECTANGLE, POLYGON;
    	}
    
    }
    Code:
    package org.frostblades.game.world.area.shapes;
    
    import org.frostblades.game.Location;
    import org.frostblades.game.world.area.Shape;
    
    public class Rectangle extends Shape {
    
    	public Rectangle(Location northEast, Location southWest) {
    		areas(new Location[] { northEast, southWest }).type(ShapeType.RECTANGLE);
    	}
    
    	@Override
    	public boolean inside(Location location) {
    
    		if (areas()[0].x() < location.x() || areas()[1].x() > location.x())
    			return false;
    
    		if (areas()[0].y() < location.y() || areas()[1].y() > location.y())
    			return false;
    
    		return true;
    	}
    
    }
    Code:
    package org.frostblades.game.world.area.shapes;
    
    import org.frostblades.game.Location;
    import org.frostblades.game.world.area.Shape;
    
    public class Polygon extends Shape {
    
    	private int sides;
    	private int[][] points;
    
    	public Polygon(Location[] points) {
    		sides(points.length).areas(points).type(ShapeType.POLYGON);
    
    		points(new int[sides][2]);
    
    		for (int i = 0; i < sides; i++) {
    			points()[i][0] = points[i].x();
    			points()[i][1] = points[i].y();
    		}
    
    	}
    
    	@Override
    	public boolean inside(Location location) {
    		boolean inside = false;
    		int y = location.y(), x = location.x();
    
    		for (int i = 0, j = sides() - 1; i < sides(); j = i++) {
    			if ((points()[i][1] < y && points()[j][1] >= y) || (points()[j][1] < y && points()[i][1] >= y)) {
    				if (points()[i][0] + (y - points()[i][1]) / (points()[j][1] - points()[i][1]) * (points()[j][0] - points()[i][0]) < x) {
    					inside = !inside;
    				}
    			}
    		}
    
    		return inside;
    	}
    
    	public int sides() {
    		return sides;
    	}
    
    	public Shape sides(int sides) {
    		this.sides = sides;
    		return this;
    	}
    
    	public int[][] points() {
    		return points;
    	}
    
    	public Shape points(int[][] points) {
    		this.points = points;
    		return this;
    	}
    
    }
    Here's some pre-marked shapes for you to test.

    https://mega.co.nz/#!DMBVnD5D!FKL1Ei...iuGD49f-0Sfvq0

    Uses:
    Quote Originally Posted by Vip3r View Post




    The red areas are where the desert heat can get you, the blue areas are parts where the heat doesn't effect you. With this system you can easily create this, with your system you have a square region. How the **** do you create this with your system...?
    Quote Originally Posted by Vip3r View Post
    It's a shape array. You can have more than one shape, e.g. if you wanted to make a pvp world you can make one Area called 'safe' where you would have multiple 'shapes' which all contribute to this one area.



    You would set the environment to 'safe' and add its effect there.
    Reply With Quote  
     


  2. #2  
    The Massive Eater
    shut's Avatar
    Join Date
    Apr 2012
    Age
    29
    Posts
    396
    Thanks given
    37
    Thanks received
    14
    Rep Power
    6
    so this is means u can actually can create a island or something like that?


    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Would be nice for lower revisions but higher would look bad, good job anyways.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Thanks. Might put something like this to use.
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Oct 2011
    Age
    27
    Posts
    2,566
    Thanks given
    1,027
    Thanks received
    1,168
    Rep Power
    0
    Quote Originally Posted by shut View Post
    so this is means u can actually can create a island or something like that?
    It's for marking, not creating. You can mark a shape and give it a name thus becomes an area.

    Quote Originally Posted by Teek View Post
    Would be nice for lower revisions but higher would look bad, good job anyways.
    It's not about the look, you can mark an area and call it Desert then initialise an environment called 'DESERT' where the process would drain health every few mins unless they have waterskins. I just added the 'you have reached' so player can know what area they are in.
    Last edited by Streetwave; 06-24-2014 at 09:01 PM.
    Reply With Quote  
     

  6. Thankful user:


  7. #6  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Quote Originally Posted by Vip3r View Post
    It's not about the look, you can mark an area and call it Desert then initialise an environment called 'DESERT' where the process would drain health every few mins unless they have waterskins. I just added the 'you have reached' so player can know what area they are in.
    That's it?.. well that's stupid, you could just get the coords of the desert x / y in a square and do it that way, it would be so much easier.. lol
    Reply With Quote  
     

  8. #7  
    Banned

    Join Date
    Oct 2011
    Age
    27
    Posts
    2,566
    Thanks given
    1,027
    Thanks received
    1,168
    Rep Power
    0
    Quote Originally Posted by Teek View Post
    That's it?.. well that's stupid, you could just get the coords of the desert x / y in a square and do it that way, it would be so much easier.. lol




    The red areas are where the desert heat can get you, the blue areas are parts where the heat doesn't effect you. With this system you can easily create this, with your system you have a square region. How the **** do you create this with your system...?
    Reply With Quote  
     

  9. Thankful users:


  10. #8  
    592
    Jawvuh's Avatar
    Join Date
    Dec 2012
    Posts
    333
    Thanks given
    150
    Thanks received
    53
    Rep Power
    0
    dude......activate windows
    Attached image
    Reply With Quote  
     

  11. #9  
    Banned

    Join Date
    Oct 2011
    Age
    27
    Posts
    2,566
    Thanks given
    1,027
    Thanks received
    1,168
    Rep Power
    0
    Quote Originally Posted by Javahh View Post
    dude......activate windows
    n3v0r

    maybe

    okay lol
    Reply With Quote  
     

  12. #10  
    592
    Jawvuh's Avatar
    Join Date
    Dec 2012
    Posts
    333
    Thanks given
    150
    Thanks received
    53
    Rep Power
    0
    Quote Originally Posted by Vip3r View Post
    n3v0r

    maybe

    okay lol
    its okay i havnt activated my windows 8 either
    Attached image
    Reply With Quote  
     

Page 1 of 8 123 ... 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. [Any Revision] Area System
    By Heisenberg_ in forum Snippets
    Replies: 9
    Last Post: 08-03-2014, 03:25 AM
  2. Making client ip change[any revision]
    By mgi125 in forum Tutorials
    Replies: 5
    Last Post: 07-21-2010, 05:01 AM
  3. any revision 525++
    By Teemuzz in forum Requests
    Replies: 2
    Last Post: 03-23-2010, 04:10 PM
  4. Replies: 7
    Last Post: 02-26-2010, 07:35 PM
  5. any revision, KBD and gwds bosses... rs2hd..
    By Dynamite in forum Snippets
    Replies: 5
    Last Post: 12-24-2009, 07:00 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •