StendhalAPI
this page is a work-in progress
Description
This page is intended to be a description of the common usable methods for adding or altering the world of Stendhal.
Entities
Base Classes
Entity
This is the base entity class for all entities in Stendhal.
- Class: games.stendhal.server.entity.Entity
- Inherits: marauroa.common.game.RPObject
- Implements:
Public methods:
- Entity()
- Default constructor.
- Entity(object)
- Copy constructor.
- object: Object to be copied.
- generateRPClass()
- Initializes the RPClass for this entity (initialized from games.stendhal.server.core.engine.RPClassGenerator).
- setDescription(text)
- Sets the description text for the entity.
- text: String to be used for description.
- setEntityClass(clazz)
- Sets the "class" attribute which is used to determine an image to be used as a representation of this entity.
- clazz: (
String) Class name.
- setEntitySubclass(subclazz)
- Sets the "subclass" attribute which is used to determine an image to be used as a representation of this entity.
- subclazz: (
String) Sub-class name.
- setSize(width, height)
- Sets the entity's size.
- width: (
int) - height: (
int)
- setPosition(x, y)
- Sets the entity's horizontal & vertical position.
- x: (
int) The horizontal position. - y: (
int) The vertical position.
- setResistance(resistance)
- Sets the resistance this has with other entities.
- resistance: (
int) Amount of resistance to set (0-100).
- setVisibility(visibility)
- Sets the entity's visibility level.
- visibility: (
int)0= completely transparent,100= completely opaque.
- setMenu(menu)
- Sets the context menu to use for the entity.
- menu: (
String) The menu to display in the client in the format:
Display name 1|action1, Display name 2|action2
- setCursor(cursor)
- Sets the name of the mouse cursor that should be used for this entity.
- cursor: (
String)
- getTitle()
- Retrieves the entity's nicely formatted title/name.
- returns: (
String) The entity's formatted name.
- getName()
- Retrieves the name of this entity.
- returns: (
String) The entity's name.
- getDescription()
- Retrieves the entity's description text.
- returns: (
string) The entity's description text.
- getDescriptionName(definite)
- Retrieves the name or something that can be used to identify the entity to the player.
- definite: (
bool) Determines article to be used as prefix.truefor "the" &falsefor "a/an" in case the entity has no name. - returns: (
String) Entity name including article.
- getHeight()
- Retrieves the entity's height.
- returns: (
double)
- getWidth()
- Retrieves the entity's width.
- returns: (
double)
- getZone()
- returns: (
StendhalRPZone) The current zone where the entity is located.
- getX()
- returns: (
int) The horizontal coordinate of the entity's position.
- getY()
- returns: (
int) The vertical coordinate of the entity's position.
- getResistance(entity)
- Retrieves the resistance this entity has on other entities.
- entity: (optional) If set, returned value is combined resistance.
- returns: (
int) Value between 0-100 (0 = no resistance, 100 = non-traversable).
- getAdjacentNodes()
- Retrieves horizontal & vertical nodes immediately adjacent to entity's current position.
- NOTE: This does not compensate for the entity's size. It is only meant to determine the positions the entity could potentially move to.
- returns: (
List<Node>) All nodes next to entity.
- getArea()
- Retrieves the area this entity currently occupies.
- returns: (
Rectangle2D)
- getArea(ex, ey)
- ex: (
double) - ey: (
double) - returns: (
Rectangle2D)
- getOrigin()
- Retrieves the initial position of the entity.
- returns: (
Point)
- getEntitySlot(name)
- Retrieve's a slot identified by
name. - name: (
String) Name of slot. - returns: (
EntitySlot) EntitySlot instance ornullif the entity does not have such slot.
- getCursor()
- Retrieves the name of the mouse cursor that should be used for this entity.
- returns: (
String) Cursor name or null.
- stopped()
- returns: (
bool)trueif the entity is not moving.
- hasDescription()
- Checks if the entity has a description.
- returns: (
bool)trueif the "description" attribute is set.
- isObstacle(entity)
- Determine if this is an obstacle for another entity.
- entity: The entity to check against.
- returns: (
bool)trueif combined resistance is above 95.
- isInSight(other)
- Checks if another entity is close enough to be detected by this entity.
- other: (
Entity) The entity to gauge distance to. - returns: (
boolean)trueif near enough.
- squaredDistance(other)
- Retrieves the square distance between this entity & the given one.
- other: (
Entity) The entity to which the distance should be calculated. - returns: (
double) Representation of the squared distance.
- squaredDistance(x, y)
- Retrieves the square distance between this entity & a given point.
- x: (
int) The horizontal position to which distance should be calculated. - y: (
int) The vertical position to which distance should be calculated. - returns: (
double) Representation of the squared distance.
- nextTo(entity, step)
- Checks whether the given entity is next to this one.
- entity: (
Entity) The entity to compare distance to. - step: (
double) (default: 0.25) Maximum distance at which is required to determine if next to. - returns: (
bool)trueif entity is next to this one.
- onAdded(zone)
- Called when this entity is added to a zone.
- zone: (
StendhalRPZone) The zone this was added to.
- onRemoved(zone)
- Called when this entity is being removed from a zone.
- zone: (
StendhalRPZone) The zone this will be removed from.
- notifyWorldAboutChanges()
- Notifies the
StendhalRPWorldthat this entity's attributes have changed.
- describe()
- Describes then entity (commonly used for when a player "looks" at an entity).
- returns: (
string) Description from the player's point-of-view.
- slotIterator(slotTypes)
- slotTypes: (
Slots) Slot types to include in the iteration. - returns: (
Iterator<RPSlot>)
- slots(slotTypes)
- slotTypes: (
Slots) Slot types to include in the iteration. - returns: (
Iterable<RPSlot>)
ActiveEntity
- Class: games.stendhal.server.entity.ActiveEntity
- Inherits: Entity
GuidedEntity
- Class: games.stendhal.server.entity.GuidedEntity
- Inherits: ActiveEntity
RPEntity
- Class: games.stendhal.server.entity.RPEntity
- Inherits: GuidedEntity