Class StendhalRPZone
java.lang.Object
marauroa.server.game.rp.MarauroaRPZone
games.stendhal.server.core.engine.StendhalRPZone
- Direct Known Subclasses:
AdventureIsland
,Northpole
,Vault
-
Nested Class Summary
Nested classes/interfaces inherited from interface marauroa.common.game.IRPZone
IRPZone.ID
-
Field Summary
Modifier and TypeFieldDescriptioncontains data to if a certain area is walkable.Contains data to verify is someone is in a PK-free area.Fields inherited from class marauroa.server.game.rp.MarauroaRPZone
objects, zoneid
-
Constructor Summary
ConstructorDescriptionStendhalRPZone(String name)
StendhalRPZone(String name, int width, int height)
StendhalRPZone(String name, StendhalRPZone zone)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add(CreatureRespawnPoint point)
Add a creature respawn point to the zone.void
This method adds an object to this zone.void
Adds an object to the ground.void
Adds an object to the ground.void
addCollisionLayer(String name, LayerDefinition collisionLayer)
void
addLayer(String name, LayerDefinition layer)
void
addMovementListener(MovementListener listener)
Register a movement listener for notification.void
addProtectionLayer(String name, LayerDefinition protectionLayer)
void
addTilesets(String name, List<TileSetDefinition> tilesets)
void
addToPlayersAndFriends(RPEntity object)
adds an RPEntity to the playersAndFriends list.void
addZoneEnterExitListener(ZoneEnterExitListener listener)
assignPortalID(Portal portal)
void
Calculate danger level for the zone, and store it in the data layer.boolean
collides(int x, int y)
Checks a single pair of coordinates for collision.boolean
Checks whether the given entity would be able to stand at the given position, or if it would collide with the collision map or with another entity.boolean
Checks whether the given entity would be able to stand at the given position, or if it would collide with the collision map or (if checkObjects is enabled) with another entity.boolean
collides(Rectangle2D shape)
Checks an area for collision.boolean
collidesObjects(Entity entity, Rectangle2D area)
boolean
collidesOnLine(int x1, int y1, int x2, int y2)
Checks if there is a collision on the airline between 2 positions.boolean
Return whether the zone contains one or more animals.boolean
Return whether the zone contains any creature including players and animals.boolean
Return whether the zone contains one or more players.protected void
createEntityAt(String clazz, int type, int x, int y)
Create a map entity as a given coordinate.protected void
createLevelPortalAt(int type, int x, int y)
describe()
static String
void
Forbid teleporting to the entire zone using a scroll.void
disallowIn(int x, int y, int width, int height)
Disallow teleporting to specified area.void
Forbid teleporting from the entire zone using a scroll.void
disallowOut(int x, int y, int width, int height)
Disallow teleporting from specified area.void
Sets the flag whether magic scrolls for teleportation may be uses in this zone.void
disAllowTeleport(int x, int y, int width, int height)
Disallow teleporting to and from a specified area.Gets other zones that should receive certain events such as knocking on door.Gets other zones that should receive certain events such as knocking on door.gets the zone attributesgetBlood(int x, int y)
Get blood (if any) at a specified zone position.getEntitiesAt(double x, double y)
Finds all entities at the given coordinates.getEntitiesAt(double x, double y, Class<T> clazz)
Finds all entities at the given coordinates.getEntityAt(double x, double y)
Finds an Entity at the given coordinates.getFilteredEntities(FilterCriteria<Entity> criteria)
int
int
getLevel()
getName()
Get the zone name.Gets the in game error message if movement of items is disabled in this zone.Gets all players in this zone, as well as friendly entities such as sheep.Gets all players in this zone.getPortal(int x, int y)
Get the portal (if any) at a specified zone position.Get the list of sheep foods in the zone.int
getWidth()
int
getX()
int
getY()
boolean
intersects(Rectangle2D area)
Determine if this zone overlaps an area in global coordinates.boolean
isEmpty()
Return whether the zone is completely empty.boolean
isInProtectionArea(Entity entity)
boolean
boolean
Can moveto (mouse movement using pathfinding) be done on this map?boolean
boolean
isTeleportInAllowed(int x, int y)
Check if teleporting with a scroll to a location is allowed.boolean
isTeleportOutAllowed(int x, int y)
Check if teleporting with a scroll from a location is allowed.boolean
leavesZone(Entity entity, double x, double y)
void
logic()
void
This method notify zone that the object has been modified.void
nextTurn()
This method moves zone from this turn to the next turn.void
notifyBeforeMovement(ActiveEntity entity, int oldX, int oldY, int newX, int newY)
void
notifyEntered(ActiveEntity entity, int newX, int newY)
Notify anything interested in when an entity entered.void
notifyExited(ActiveEntity entity, int oldX, int oldY)
Notify anything interested in when an entity exited.void
notifyMovement(ActiveEntity entity, int oldX, int oldY, int newX, int newY)
Notify anything interested that an entity moved.void
Resend the zone data to players on the zone.void
boolean
placeObjectAtEntryPoint(Entity entity)
void
populate(LayerDefinition objectsLayer)
Populate a zone based on it's map content.void
remove(CreatureRespawnPoint point)
Remove a creature respawn point from the zone.removes object from zone.remove(RPObject.ID id)
Removes the object from zone.void
removeMovementListener(MovementListener listener)
Unregister a movement listener from notification.void
removeZoneEnterExitListener(ZoneEnterExitListener listener)
void
setAssociatedZones(String zones)
Sets other zones that should receive certain events such as knocking on door.void
setAttributes(ZoneAttributes attr)
Set zone attributes that should be passed to the client.void
setEntryPoint(int x, int y)
void
setMoveToAllowed(boolean moveToAllowed)
Sets the flag whether moveto (mouse movement using pathfinding) is possible in this zone.void
setNoItemMoveMessage(String message)
Disabled movement of items in this zone.void
void
setPosition(int level, int x, int y)
void
setPublicAccessible(boolean accessible)
Sets the public accessibility of this zoneboolean
simpleCollides(Entity entity, double x, double y, double w, double h)
toString()
Methods inherited from class marauroa.server.game.rp.MarauroaRPZone
assignRPObjectID, get, getID, getPerception, has, hide, iterator, onFinish, onInit, print, reset, size, storeToDatabase, unhide
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
collisionMap
contains data to if a certain area is walkable. -
protectionMap
Contains data to verify is someone is in a PK-free area.
-
-
Constructor Details
-
StendhalRPZone
-
StendhalRPZone
-
StendhalRPZone
-
-
Method Details
-
getBlood
Get blood (if any) at a specified zone position.- Parameters:
x
- The X coordinate.y
- The Y coordinate.- Returns:
- The blood, or
null
.
-
getNPCList
-
getPortals
-
getPortal
-
getPortal
Get the portal (if any) at a specified zone position.- Parameters:
x
- The X coordinate.y
- The Y coordinate.- Returns:
- The portal, or
null
.
-
getSheepFoodList
Get the list of sheep foods in the zone.- Returns:
- The list of sheep foods.
-
getRespawnPointList
-
add
Add a creature respawn point to the zone.- Parameters:
point
- The respawn point.
-
remove
Remove a creature respawn point from the zone.- Parameters:
point
- The respawn point.
-
getPlantGrowers
-
assignPortalID
-
setEntryPoint
public void setEntryPoint(int x, int y) -
placeObjectAtEntryPoint
-
addLayer
- Throws:
IOException
-
addTilesets
- Throws:
IOException
-
notifyOnlinePlayers
public void notifyOnlinePlayers()Resend the zone data to players on the zone. This is meant for situations where the map data changes. (Weather and lighting changes, and so on). -
setAttributes
Set zone attributes that should be passed to the client.- Parameters:
attr
- attributes
-
addCollisionLayer
- Throws:
IOException
-
addProtectionLayer
- Throws:
IOException
-
setPosition
public void setPosition(int level, int x, int y) -
setPosition
public void setPosition() -
getX
public int getX() -
getY
public int getY() -
getLevel
public int getLevel() -
isInterior
public boolean isInterior() -
intersects
Determine if this zone overlaps an area in global coordinates.- Parameters:
area
- The area (in global coordinate space).- Returns:
true
if the area overlaps.
-
populate
Populate a zone based on it's map content. TODO: This should be moved to the zone loader or something.- Parameters:
objectsLayer
-
-
calculateDangerLevel
public void calculateDangerLevel()Calculate danger level for the zone, and store it in the data layer. -
createEntityAt
Create a map entity as a given coordinate.- Parameters:
clazz
- the clazz of entity we are loading.
It is related to the way entities are stored in tilesets now.type
- integer to represent the type of entity to be created.if the class contains portal type is evaluated as follows:
- 0 , 1 entry point
- 1 zone change
- 5 ,2 , 3 LevelPortal
x
-y
-
-
createLevelPortalAt
protected void createLevelPortalAt(int type, int x, int y) -
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getContents
-
isInProtectionArea
-
leavesZone
-
simpleCollides
-
add
Description copied from class:MarauroaRPZone
This method adds an object to this zone.- Specified by:
add
in interfaceIRPZone
- Overrides:
add
in classMarauroaRPZone
- Parameters:
object
- object to add.
-
add
Adds an object to the ground. The player parameter can be used to create special items that react when they are dropped on the ground by a player.- Parameters:
object
- The object that should be added to the zoneplayer
- The player that dropped the item
-
add
Adds an object to the ground.- Parameters:
object
- The object that should be added to the zoneexpire
- True if the item should expire according to its normal behaviour, false otherwise
-
addToPlayersAndFriends
adds an RPEntity to the playersAndFriends list.- Parameters:
object
- RPEntity
-
remove
Description copied from class:MarauroaRPZone
Removes the object from zone.- Specified by:
remove
in interfaceIRPZone
- Overrides:
remove
in classMarauroaRPZone
- Parameters:
id
- identified of the removed object- Returns:
- the removed object
-
remove
removes object from zone.- Parameters:
object
-- Returns:
- the removed object
-
modify
Description copied from class:MarauroaRPZone
This method notify zone that the object has been modified. You should call it only once per turn, even if inside the turn you modify it several times.- Specified by:
modify
in interfaceIRPZone
- Overrides:
modify
in classMarauroaRPZone
- Parameters:
object
- object to modify.
-
collidesOnLine
public boolean collidesOnLine(int x1, int y1, int x2, int y2)Checks if there is a collision on the airline between 2 positions. Only the collision map will be used.- Parameters:
x1
- x value of position 1y1
- y value of position 1x2
- x value of position 2y2
- y value of position 2- Returns:
- true if there is a collision
-
collides
public boolean collides(int x, int y)Checks a single pair of coordinates for collision.- Parameters:
x
- X-coordinatey
- Y-coordinate- Returns:
true
if collision tile located at coordinates.
-
collides
Checks an area for collision.- Parameters:
shape
- Rectangle area.- Returns:
true
if any collision tiles are found in the area.
-
collides
Checks whether the given entity would be able to stand at the given position, or if it would collide with the collision map or with another entity.- Parameters:
entity
- The entity that would stand on the given positionx
- The x coordinate of the position where the entity would standy
- The y coordinate of the position where the entity would stand- Returns:
- true iff the entity could stand on the given position
-
collides
Checks whether the given entity would be able to stand at the given position, or if it would collide with the collision map or (if checkObjects is enabled) with another entity.- Parameters:
entity
- The entity that would stand on the given positionx
- The x coordinate of the position where the entity would standy
- The y coordinate of the position where the entity would standcheckObjects
- If false, only the collision map will be used.- Returns:
- true iff the entity could stand on the given position
-
collidesObjects
-
getEntityAt
Finds an Entity at the given coordinates.- Parameters:
x
- coordinatey
- coordinate- Returns:
- the first entity found if there are more than one or null if there are none
-
getEntitiesAt
Finds all entities at the given coordinates.- Parameters:
x
- coordinatey
- coordinate- Returns:
- list of entities at (x, y)
-
getEntitiesAt
Finds all entities at the given coordinates.- Parameters:
x
- coordinatey
- coordinate- Returns:
- list of entities at (x, y)
-
getName
Get the zone name. This is the same asgetID().getID()
, only cleaner to use.- Returns:
- The zone name.
-
getHumanReadableName
-
notifyEntered
Notify anything interested in when an entity entered.- Parameters:
entity
- The entity that entered.newX
- The new X coordinate.newY
- The new Y coordinate.
-
notifyExited
Notify anything interested in when an entity exited.- Parameters:
entity
- The entity that moved.oldX
- The old X coordinate.oldY
- The old Y coordinate.
-
notifyMovement
Notify anything interested that an entity moved.- Parameters:
entity
- The entity that moved.oldX
- The old X coordinate.oldY
- The old Y coordinate.newX
- The new X coordinate.newY
- The new Y coordinate.
-
notifyBeforeMovement
-
addZoneEnterExitListener
-
removeZoneEnterExitListener
-
addMovementListener
Register a movement listener for notification. Eventually create a macro-block hash to cut down on listeners to check.- Parameters:
listener
- A movement listener to register.
-
removeMovementListener
Unregister a movement listener from notification.- Parameters:
listener
- A movement listener to unregister.
-
toString
-
getItemsOnGround
- Returns:
- a set of all items that are lying on the ground in this zone.
-
getPlayers
Gets all players in this zone.- Returns:
- A list of all players.
-
getPlayerAndFriends
Gets all players in this zone, as well as friendly entities such as sheep. These are the targets (enemies) for wild creatures such as orcs.- Returns:
- a list of all players and friendly entities
-
isMoveToAllowed
public boolean isMoveToAllowed()Can moveto (mouse movement using pathfinding) be done on this map?- Returns:
- true, if moveto is possible, false otherwise
-
setMoveToAllowed
public void setMoveToAllowed(boolean moveToAllowed)Sets the flag whether moveto (mouse movement using pathfinding) is possible in this zone.- Parameters:
moveToAllowed
- true, if it is possible, false otherwise
-
nextTurn
public void nextTurn()Description copied from class:MarauroaRPZone
This method moves zone from this turn to the next turn. It is called by RPWorld.- Specified by:
nextTurn
in interfaceIRPZone
- Overrides:
nextTurn
in classMarauroaRPZone
-
logic
public void logic() -
isEmpty
public boolean isEmpty()Return whether the zone is completely empty.- Returns:
- true if there are no objects in zone
-
containsPlayer
public boolean containsPlayer()Return whether the zone contains one or more players.- Returns:
- if there are players in zone
-
containsAnimal
public boolean containsAnimal()Return whether the zone contains one or more animals.- Returns:
- true if there are domesticalanimals in zone
-
containsCreature
public boolean containsCreature()Return whether the zone contains any creature including players and animals.- Returns:
- true if there are creatures in zone
-
getFilteredEntities
-
disAllowTeleport
public void disAllowTeleport()Sets the flag whether magic scrolls for teleportation may be uses in this zone. -
disAllowTeleport
public void disAllowTeleport(int x, int y, int width, int height)Disallow teleporting to and from a specified area.- Parameters:
x
- left x coordinatey
- top y coordinatewidth
- width of the areaheight
- height of the area
-
isTeleportInAllowed
public boolean isTeleportInAllowed(int x, int y)Check if teleporting with a scroll to a location is allowed.- Parameters:
x
- x coordinatey
- y coordinate- Returns:
true
iff teleporting is allowed
-
isTeleportOutAllowed
public boolean isTeleportOutAllowed(int x, int y)Check if teleporting with a scroll from a location is allowed.- Parameters:
x
- x coordinatey
- y coordinate- Returns:
true
iff teleporting is allowed
-
disallowIn
public void disallowIn()Forbid teleporting to the entire zone using a scroll. -
disallowIn
public void disallowIn(int x, int y, int width, int height)Disallow teleporting to specified area.- Parameters:
x
- left x coordinatey
- top y coordinatewidth
- width of the areaheight
- height of the area
-
disallowOut
public void disallowOut()Forbid teleporting from the entire zone using a scroll. -
disallowOut
public void disallowOut(int x, int y, int width, int height)Disallow teleporting from specified area.- Parameters:
x
- left x coordinatey
- top y coordinatewidth
- width of the areaheight
- height of the area
-
onRemoved
public void onRemoved() -
isPublicAccessible
public boolean isPublicAccessible()- Returns:
- is this zone accessible by the public
-
setPublicAccessible
public void setPublicAccessible(boolean accessible)Sets the public accessibility of this zone- Parameters:
accessible
-
-
describe
-
describe
-
setNoItemMoveMessage
Disabled movement of items in this zone.- Parameters:
message
- in game error message
-
getNoItemMoveMessage
Gets the in game error message if movement of items is disabled in this zone.- Returns:
- message in game error message or
null
-
getAttributes
gets the zone attributes- Returns:
- zone attributes
-
setAssociatedZones
Sets other zones that should receive certain events such as knocking on door.- Parameters:
zones
- Comma-separated string of zone names.
-
getAssociatedZones
Gets other zones that should receive certain events such as knocking on door. -
getAssociatedZonesList
Gets other zones that should receive certain events such as knocking on door.
-