Jump to content

milf hunter

Member
  • Content count

    778
  • Joined

  • Last visited

About milf hunter

  • Rank
    Adamant Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. [quote name='falconpunch']not bad :P[/QUOTE] thanks, but i'm going to update it to where you can make areas into polygons (any number of sides) instead of just a rectangle or square
  2. [SIZE=3]I got bored and decided to write a system for areas. This will work for any revision, although you may have to change around the imports and packages a little bit. Purpose of this snippet? This basically lets you create custom areas that can be used for minigames, pvp zones, multi zones, boss areas, donator zones, etc or for map effects such as being in the desert makes you lose hp and "die of thirst" and so on and so forth (Can't think of anything else off the top of my head) But yeah, without further ado: Create a new class in whatever directory and put this in it: [CODE]package org.afflatus.game.world.map.location; import java.awt.Point; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import org.afflatus.game.player.Player; /** * Made by: K-Shan */ public class Area { /** * Name of the area */ private String name; /** * Represent the most southern, western point. */ private Point southWest; /** * Represents the most northern, eastern point */ private Point northEast; /** * Represents the map height */ private byte z; /** * is the area a multi zone? */ private boolean multi; /** * Can you teleport to this area? */ private boolean teleportable; /** * Is this a pvp zone? */ private boolean pvp; /** * Area * @param southWest * @param northEast * @param z */ public Area(Point southWest, Point northEast, byte z) { this.southWest = southWest; this.northEast = northEast; this.z = z; } /** * Area * @param southWest * @param northEast * @param z * @param name * @param multi * @param tele * @param pvp */ public Area(Point southWest, Point northEast, byte z, String name, boolean multi, boolean tele, boolean pvp) { this.name = name; this.southWest = southWest; this.northEast = northEast; this.z = z; this.multi = multi; this.teleportable = tele; this.pvp = pvp; } /** * Area * @param point * @param bounds */ public Area(Point point, double bounds) { this.northEast = getNE(point, bounds, bounds); this.southWest = getSW(point, bounds, bounds); this.z = 0; this.name = "Default Location"; } /** * Area * @param point * @param xBounds * @param yBounds */ public Area(Point point, double xBounds, double yBounds) { this.northEast = getNE(point, xBounds, yBounds); this.southWest = getSW(point, xBounds, yBounds); this.z = 0; this.name = "Default Location"; } /** * default vars for an area. */ public Area() { name = ""; southWest = null; northEast = null; pvp = false; multi = false; teleportable = true; z = -1; } /** * Loops through a .txt file and finds the areaName that corresponds with the param "name" * @param name * @return */ public static Area get(String name) { Area area = null; try { BufferedReader r = new BufferedReader(new FileReader(new File("data/areas.txt"))); while (true) { String line = r.readLine(); boolean ignore = false; if (line == null) break; if (line.startsWith("//") || line.equals("")) continue; if (line.contains("/*")) continue; ignore = true; if (line.contains("*/")) if (ignore == true) continue; ignore = false; String[] splitLine = line.split(" - "); String areaName = splitLine[0]; String newLine = splitLine[1]; String[] splitLinev2 = newLine.split(", "); int southWestX = Integer.parseInt(splitLinev2[0]); int southWestY = Integer.parseInt(splitLinev2[1]); int northEastX = Integer.parseInt(splitLinev2[2]); int northEastY = Integer.parseInt(splitLinev2[3]); byte z = Byte.parseByte(splitLinev2[4]); boolean multi = Boolean.parseBoolean(splitLinev2[5]); boolean teleportable = Boolean.parseBoolean(splitLinev2[6]); boolean pvp = Boolean.parseBoolean(splitLinev2[7]); if(areaName.equalsIgnoreCase(name)) area = new Area(new Point(southWestX, southWestY), new Point(northEastX, northEastY), z, areaName, multi, teleportable, pvp); } r.close(); } catch(Throwable e) { e.printStackTrace(); } return area; } /** * Is the player in a certain area? * @param player * @param area * @return */ public static boolean inArea(Player player, Area area) { return player.getX() >= area.southWest().getX() && player.getX() <= area.northEast().getX() && player.getY() >= area.southWest().getY() && player.getY() <= area.northEast().getY(); } /** * Length of the area. * @return */ public short length() { return (short) (northEast.getX() - southWest.getX()); } /** * returns the width of the area. * @return */ public short width() { return (short) (northEast.getY() - southWest.getY()); } /** * Returns the center of the area. * @return */ public Location center() { return new Location(southWest.x + (Math.round(length() / 2)), southWest.y + (Math.round(width() / 2)), z); } /** * Gets the northeastern point. * @param point * @param xBounds * @param yBounds * @return */ public Point getNE(Point point, double xBounds, double yBounds) { Point p = new Point(); p.setLocation(point.x + xBounds, point.y + yBounds); return p; } /** * Gets the southwestern point * @param point * @param xBounds * @param yBounds * @return */ public Point getSW(Point point, double xBounds, double yBounds) { Point p = new Point(); p.setLocation(point.x - xBounds, point.y - yBounds); return p; } /** * Returns northeast point. * @return */ public Point northEast() { return northEast; } /** * Returns southwest point. * @return */ public Point southWest() { return southWest; } /** * Returns if the area is multi or not. * @return */ public boolean isMulti() { return multi; } /** * Can you tele to this area? * @return */ public boolean isTeleportable() { return teleportable; } /** * Is this a pvp area? * @return */ public boolean isPvp() { return pvp; } /** * The name of the area * @return */ public String name() { return name; } } [/CODE] Great job, now you're done! If you want to test the effectiveness of this, follow these extra steps: [SPOILER="Testing The Area System"] Go to your data folder and create a new .txt document called areas.txt and add this inside of it: [CODE] // name - southwest X, southwest Y, northeast x, northeast y, z, multi, teleportable, ispvp? Dungeoneering Test - 3460, 3725, 3471, 3737, 0, false, true, false [/CODE] Now, go to your commands.jerba and add this command to test effectiveness: [CODE] case "m": Area area = Area.get("Dungeoneering Test"); player.getActionSender().sendMessage("Name : "+area.name()+", Teleable ? "+area.isTeleportable() +" NE: "+area.northEast().x+", "+area.northEast().y+" - SW: "+area.southWest().x +", "+area.southWest().y); if(Area.inArea(player, area)) player.sm("In dungeoneering lobby."); else player.sm("Not in dungeoneering lobby."); return true; [/CODE] [/SPOILER] And that's all! Creds: me. If you have any questions, i'd be happy to help. [/SIZE]
  3. Thx for this!!!!! I badly needed ty!! Rep++
  4. [quote name='toysoilder']Great release, but it won't read the cache? even when I have it in my C: drive[/QUOTE] It's supposed to go in your user folder
  5. [quote name='xRealityx']looks horrible[/QUOTE] Thanks, your name does too :)
  6. [quote name='m7md1']Add me "Mr-m7md1" , I want to ask some questions.[/QUOTE] Can't add atm, try adding my Skype. [quote name='DesireRSPS']Nice work, tut island looks sick. GL with sales.[/QUOTE] Thanks [quote name='blik97']wondering if u had a nice server source base. one that would run cleanly and able to host alot of people. 562 prefereably[/QUOTE] Have what you're looking for, add my skype [quote name='officiallulzs3c']Shh and get back to dicing on fatality ;)[/QUOTE] I have no idea what you're talking about but ok
  7. [quote name='issler']I want a map editor for rune evo 3.0[/QUOTE] Ask harry from r-s lol Bump
  8. [quote name='shershah']Add me: shershah fedrik[/QUOTE] There's spaces in skype names? o.o lol but bump
  9. [quote name='Markle']Hey, add my Skype. Webmaster.Joey[/QUOTE] added you
×