StendhalAPI
Jump to navigation
Jump to search
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.
- 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.true
for "the" &false
for "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 ornull
if 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
)true
if the entity is not moving.
- hasDescription()
- Checks if the entity has a description.
- returns: (
bool
)true
if the "description" attribute is set.
- isObstacle(entity)
- Determine if this is an obstacle for another entity.
- entity: The entity to check against.
- returns: (
bool
)true
if 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
)true
if 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
)true
if 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
StendhalRPWorld
that 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>
)
Public static methods:
- generateRPClass()
- Initializes the RPClass for this entity (initialized from games.stendhal.server.core.engine.RPClassGenerator).
ActiveEntity
- Class: games.stendhal.server.entity.ActiveEntity
- Inherits: Entity
Public methods:
- ActiveEntity()
- Default constructor.
- ActiveEntity(object)
- Copy constructor.
- object: (
RPObject
) Object to be copied.
- setSpeed(speed)
- Sets the entity's current movement speed.
- speed: (
double
)
- setDirection(dir)
- Sets the entity's facing direction.
- dir: (
Direction
) Direction to face.
- setIgnoresCollision(ignore)
- Sets whether or not the entity should be able to traverse collision tiles.
- ignore: (
boolean
) Iftrue
sets the "ignore_collision" attribute, otherwise removes it.
- applyMovement()
- getDirection()
- Retrieves the entities current facing direction.
- returns: (
Direction
)
- getSpeed()
- Retrieves the speed at which the entity is currently moving.
- returns: (
double
)
- getStepsTaken()
- Retrieves the number of steps the entity has taken during the current session.
- returns: (
int
)
- getDirectionToward(entity)
- Retrieves the direction from this entity to another.
- entity: (
Entity
) Entity from which to gauge direction. - returns: (
Direction
)
- getDirectionToward(area)
- area: (
Rectangle2D
) - returns: (
Direction
)
- isGhost()
- Checks whether an entity is a ghost (not physically interactive).
- returns: (
boolean
)true
if "ghostmode" attribute is set (players only).
- stop()
- Stops the entity's movement.
- isFacingToward(entity)
- Determines if this entity is facing toward another entity.
- entity: (
Entity
) Target entity. - returns: (
boolean
)true
if facing other entity.
- faceto(x, y)
- Face toward a specific point on the map.
- x: (
int
) Horizontal position of point to face. - y: (
int
) Vertical position of point to face.
- faceToward(entity)
- Face toward a specific entity.
- entity: (
Entity
) Entity to face toward.
- canMoveTo(x, y)
- Predicts if entity can move to a position.
- x: (
int
) Horizontal position of the target point. - y: (
int
) Vertical position of the target point. - returns: (
boolean
)true
if nothing is preventing entity from moving to target point.
- canMoveTo(pos)
- Predicts if entity can move to a position.
- pos: (
Point
) Target point. - returns: (
boolean
)true
if nothing is preventing entity from moving to target point.
- ignoresCollision()
- Checks if the entity can pass through collision tiles.
- returns: (
boolean
)true
if the "ignore_collision" attribute is set.
Public static methods:
- generateRPClass()
- Initializes the RPClass for this entity (initialized from games.stendhal.server.core.engine.RPClassGenerator).
GuidedEntity
- Class: games.stendhal.server.entity.GuidedEntity
- Inherits: ActiveEntity
Public methods:
- GuidedEntity ()
- Default constructor.
- GuidedEntity (object)
- object : (
RPObject
) Object to be copied.
- setBaseSpeed (bs)
- Set entity's normal movement speed.
- bs : (
double
) New normal speed for moving.
- setPath (path, position)
- Set a path for this entity to follow.
- path : (
FixedPath
) Path to follow. - position : (
int
) (optional) The position of the path where the entity should start (this is not the same assetPosition()
).
- setPathAndPosition (path)
- Set path & starting position for entity.
- path : (
FixedPath
) Path to follow.
- setPathPosition (pathPos)
- Sets the entity's position in its path.
- pathPos : (
int
) Position to set.
- retracePath ()
- Causes entity to retrace its path backwards when it reaches the end.
- setCollisionAction (action)
- Set action type to take when entity collides.
- action : (
CollisionAction
) Behavior type after collision.
- getBaseSpeed ()
- Retreives entity's normal movement speed.
- returns: (
double
)
- getPath ()
- Retrieves the entity's current path.
- returns: (
FixedPath
)
- getPathPosition ()
- Retrieves the entity's current position in its path.
- returns: (
int
)
- getGuide ()
- returns: (
EntityGuide
)
- getCollisionAction ()
- returns: (
CollisionAction
)
- hasPath ()
- Checks if the entity has a path set.
- returns: (
boolean
)
- isPathLoop ()
- Checks if the entity's path loops.
- returns: (
boolean
)
- clearPath ()
- Removes the entity's path.
- reroute ()
- Plan a new path to destination.
- followPath ()
- returns: (
boolean
)
- addSuspend (duration, dir, pos...)
- Add a suspension to the entity's path.
- duration : (
in
) - dir : (
Direction
) (optional) - pos... : (
int[]
) - NOTE: this method is experimental.
- removeSuspend (pos...)
- Removes a suspension from path.
- pos... : (
int[]
) - NOTE: this method is experimental.
- onFinishedPath ()
- updateModifedAttributes ()
- atMovementRadius ()
- returns: (
boolean
)
- onOutsideMovementRadius ()
- setRandomMovementRadius (radius, ret)
- radius : (
int
) - ret : (
boolean
) (optional)
RPEntity
- Class: games.stendhal.server.entity.RPEntity (abstract)
- Inherits: GuidedEntity
Public methods:
- RPEntity ()
- Default constructor.
- RPEntity (object)
- Copy constructor.
- object : (
RPObject
) Object to be copied.
- setName (name)
- Sets the entity's name attribute.
- name : (
String
) String to be used as name.
- setLevel (level)
- Sets the entity's level.
- level : (
int
)
- addKarma (karma)
- Adds good or bad karma (players only).
- karma : (
double
) Amount to be added (negative amount represents "bad" karma).
- getLevel ()
- Retrieves the entity's current level.
- returns: (
int
)
- getKarma ()
- Retrieves current karma level.
- returns: (
double
)
- useKarma (scale)
- TODO
- useKarma (negLimit, posLimit[, granularity])
- TODO
- heal ([amount[, tell]])
- TODO
- addMana (mana, tell)
- TODO
- damageDone (defender, attackingWeaponsValue, damageType)
- TODO
- setAtk (atk)
- TODO
- getAtk ()
- TODO
- getCappedAtk ()
- TODO
- setAtkXP (atk)
- TODO
- addAtkXP (xp)
- TODO
- getAtkXP ()
- TODO
- incAtkXP (def)
- TODO
- setDef ()
- TODO
- getDef ()
- TODO
- getCappedDef ()
- TODO
- setDefXP ()
- TODO
- addDefXP (xp)
- TODO
- getDefXP ()
- TODO
- incDefXP ()
- TODO
- setRatk (ratk)
- TODO
- getRatk ()
- TODO
- getCappedRatk ()
- TODO
- setRatkXP (xp)
- TODO
- addRatkXP (xp)
- TODO
- getRatkXP ()
- TODO
- incRatkXP ()
- TODO
- initHP (hp)
- TODO
- setBaseHP (newhp)
- TODO
- getBaseHP ()
- TODO
- setHP (hp)
- TODO
- getHP ()
- TODO
- getLVCap ()
- TODO
- getMana ()
- TODO
- getBaseMana ()
- TODO
- setMana (newMana)
- TODO
- setBaseMana (newBaseMana)
- TODO
- addBaseMana (newBaseMana)
- TODO
- setLVCap (newLVCap)
- TODO
- setXP (newxp)
- TODO
- subXP (newxp)
- TODO
- addXP (newxp)
- TODO
- getXP ()
- TODO
- isAttackable ()
- TODO
- setTarget (target)
- TODO
- stopAttack ()
- TODO
- getsFightXpFrom (enemy)
- TODO
- stopAttacking (attacker)
- TODO
- rememberAttacker (attacker)
- TODO
- setBlood (name)
- TODO
- getBloodClass ()
- TODO
- getDroppables ()
- TODO
- dropDroppableItem (droppable)
- TODO
- maybeDropDroppables (attacker)
- TODO
- onDamaged (attacker, damage)
- TODO
- damage (amount, attacker)
- TODO
- delayedDamage (amount, attackerName)
- TODO
- onDead (killer[, remove])
- TODO
- getCorpseName ()
- TODO
- getHarmlessCorpseName ()
- TODO
- getCorpseWidth ()
- TODO
- getCorpseHeight ()
- TODO
- isInvisibleToCreatures ()
- TODO
- isAttacked ()
- TODO
- getAttackSources ()
- TODO
- returns: (
List<Entity>
)
- getAttackingRPEntities ()
- TODO
- returns: (
List<RPEntity>
)
- isAttacking ()
- TODO
- returns: (
boolean
)
- getAttackTarget ()
- TODO
- returns: (
RPEntity
)
- equipToInventoryOnly (item)
- TODO
- returns: (
boolean
)
- getSlotToEquip (item)
- TODO
- returns: (
RPSlot
)
- equipOrPutOnGround (item)
- TODO
- returns: (
boolean
)
- equip (slotName, item)
- TODO
- returns: (
boolean
)
- isEquipped (condition, amount)
- TODO
- returns: (
boolean
)
- drop (<name> | <item>)
- TODO
- returns: (
boolean
)
- dropWithInfostring (name, infostring[, amount])
- TODO
- returns: (
boolean
)
- isEquipped (name[, amount])
- TODO
- returns: (
boolean
)
- isEquippedWithInfostring (name, infostring[, amount])
- TODO
- returns: (
boolean
)
- getNumberOfEquipped (name)
- TODO
- returns: (
int
)
- getTotalNumberOf (name)
- TODO
- returns: (
int
)
- getFirstEquipped (name)
- TODO
- returns: (
Item
)
- getAllEquipped (name)
- TODO
- returns: (
List<Item>
)
- getAllEquippedWithInfostring (name, infostring)
- TODO
- returns: (
List<Item>
)
- isEquippedItemClass (slot, clazz)
- TODO
- returns: (
boolean
)
- isEquippedItemInSlot (slot, item)
- TODO
- returns: (
boolean
)
- getEquippedItemClass (slot, clazz)
- TODO
- returns: (
Item
)
- getWeapon ()
- TODO
- returns: (
Item
)
- getWeapons ()
- TODO
- returns: (
List<Item>
)
- getRangeWeapon ()
- TODO
- returns: (
Item
)
- getAmmunition ()
- TODO
- returns: (
StackableItem
)
- getMissileIfNotHoldingOtherWeapon ()
- TODO
- returns: (
StackableItem
)
- hasShield ()
- TODO
- returns: (
boolean
)
- getShield ()
- TODO
- returns: (
Item
)
- hasArmor ()
- TODO
- getArmor ()
- TODO
- hasHelmet ()
- TODO
- getHelmet ()
- TODO
- hasLegs ()
- TODO
- getLegs ()
- TODO
- hasBoots ()
- TODO
- getBoots ()
- TODO
- hasCloak ()
- TODO
- getCloak ()
- TODO
- hasRing ()
- TODO
- getRing ()
- TODO
- sendPrivateText (text)
- TODO
- sendPrivateText (type, text)
- TODO
- getItemAtk ()
- TODO
- getItemRatk ()
- TODO
- getItemDef ()
- TODO
- getDefenseItems ()
- TODO
- updateItemAtkDef ()
- TODO
- canDoRangeAttack (target, maxrange)
- TODO
- hasLineOfSight (target)
- TODO
- getMaxRangeForArcher ()
- TODO
- setTitle (title)
- TODO
- logic ()
- TODO
- canHit (defender)
- TODO
- getAtkRate ()
- TODO
- attack ()
- TODO
- handleLifesteal (attacker, attackerWeapons, damage)
- TODO
- getCorpseDeserver ()
- TODO
- getLanguage ()
- TODO
- setDeathSound (sound)
- TODO
- getDeathSound ()
- TODO
- addStatusAttacker (statusAttacker)
- TODO
- getStatusList ()
- TODO
- hasStatus (statusType)
- TODO
- setShadowStyle (st)
- TODO
Static public methods:
- generateRPClass ()
- applyDistanceAttackModifiers (damage, squareDistance, maxrange)
- TODO
DressedEntity
- Class: games.stendhal.server.entity.DressedEntity (abstract)
- Inherits: RPEntity
Public Methods:
- DressedEntity ()
- Default constructor.
- returns: (
DressedEntity
) New instance.
- DressedEntity (object)
- Copy constructor.
- object : (
RPObject
) Object to be copied. - returns: (
DressedEntity
) New instance.
- getOutfit ()
- TODO
- returns: (
Outfit or null
)
- getOriginalOutfit ()
- TODO
- returns: (
Outfit or null
)
- getOutfitColors ()
- TODO
- setOutfit (outfit[, temporary])
- TODO
- setOutfit (layers)
- TODO
- setOutfit (temporary, layers)
- TODO
- setOutfit (strcode[, temporary])
- TODO
- setOutfitWithDetail (outfit, temporary)
- TODO
- setOutfitColor (part, color)
- TODO
- setOutfitColors (parts)
- TODO
- isNaked ()
- TODO
- unsetOutfitColor (part)
- TODO
- restoreOriginalOutfit ()
- TODO
NPC
- Class: games.stendhal.server.entity.npc.NPC (abstract)
- Inherits: DressedEntity
Public Members:
- pauseTurnsRemaining
- Type:
int
Public Methods:
- NPC ()
- Default constructor
- returns: (
NPC
) New instance.
- NPC (object)
- Copy constructor.
- object : (
RPObject
) Object to be copied. - returns: (
NPC
) New instance.
- checkPause ()
- TODO
- getIdea ()
- TODO
- getMovementRange ()
- TODO
- getPerceptionRange ()
- TODO
- getSounds ()
- TODO
- moveRandomly ()
- TODO
- say (text)
- TODO
- setIdea (idea)
- Sets the NPC's idea/thought.
- idea : (
String
) The idea mnemonic, ornull
.
- setMovement (destEntity, min, max, maxPathRadius)
- TODO
- setMovementRange (movementRange)
- TODO
- setPathCompletedPause (pause[, dir])
- TODO
- setPerceptionRange (perceptionRange)
- TODO
- setRandomPathFrom (x, y, distance)
- TODO
- setSounds (sounds)
- TODO
PassiveNPC
- Class: games.stendhal.server.entity.npc.PassiveNPC (abstract)
- Inherits: NPC
Public Methods:
- createPath ()
- Does nothing unless overridden by sub-class.
- reversePath ()
- Changes entity's path to walk in opposite direction.
- setTeleportsFlag (teleports)
- TODO
- teleports : (
boolean
)
- isTeleporter ()
- returns: (
boolean
) teleports
SpeakerNPC
- Class: games.stendhal.server.entity.npc.SpeakerNPC
- Inherits: PassiveNPC
Public Methods:
- SpeakerNPC (name)
- Constructor.
- name : (
String
) Name of the new entity.
- add (state, trigger, condition, nextState, reply, action)
- TODO
- add (state, trigger, condition, nextState, reply, action, label)
- TODO
- add (state, triggerStrings, condition, nextState, reply, action,label)
- TODO
- add (state, triggerStrings, condition, nextState, reply, action)
- TODO
- add (state, triggerStrings, condition, secondary, nextState, reply, action)
- TODO
- add (states, trigger, condition, nextState, reply, action)
- TODO
- add (states, triggerStrings, condition, nextState, reply, action)
- TODO
- add (state, triggerStrings, nextState, reply, action)
- TODO
- add (state, triggerStrings, nextState, reply, action, label)
- TODO
- addEmotion (triggerStrings, npcAction)
- TODO
- addEmotion (trigger, npcAction)
- TODO
- addEmotionReply (playerAction, npcAction)
- TODO
- addGoodbye ()
- TODO
- addGoodbye (text)
- TODO
- addGreeting ()
- Add default greeting.
- addGreeting (text)
- Add greeting text.
- text : (
String
) Message to be displayed.
- addGreeting (text, action)
- TODO
- addHelp (helpDescription)
- TODO
- addInitChatMessage (condition, action)
- condition : (
ChatCondition
) - action : (
ChatAction
)
- addJob (jobDescription)
- TODO
- addMatching (state, trigger, matcher, condition, nextState, reply, action)
- TODO
- addOffer (offerDescription)
- TODO
- addQuest (text)
- TODO
- addReply (trigger, text)
- TODO
- addReply (triggerStrings, text)
- TODO
- addReply (trigger, text, action)
- TODO
- addReply (triggerStrings, text, action)
- TODO
- addReplyOnEmotion (playerAction, reply)
- TODO
- addWaitMessage ()
- TODO
- addWaitMessage (text, action)
- Message when attending another player.
- text : (
String
) Message to be shown. - action : (
ChatAction
)
- del (label)
- Delete transitions that match label.
- label : (
String
) - returns: (
boolean
)
- endConversation ()
- Ends interaction with player & sets to not attending.
- getAlternativeImage ()
- TODO
- getAttending ()
- Retrieves the entity currently talking to the NPC, or null if not attending anyone.
- returns: (
RPEntity
) Entity attended to.
- getEngine ()
- TODO
- getJob ()
- TODO
- returns: (
String
)
- getReply (trigger)
- TODO
- getReply (trigger, state, expressionType)
- TODO
- getTransitions ()
- TODO
- inConversationRange ()
- Checks if an entity is within range to interact.
- returns: (
boolean
)
- isAllowedToActAlone ()
- returns: (
boolean
)
- isTalking ()
- returns: (
boolean
)
- listenTo (player, text)
- TODO
- onRejectedAttackStart (attacker)
- TODO
- preLogic ()
- setAllowToActAlone (allow)
- Allow or disallow the NPC to act without players in its zone.
- allow : (
boolean
)
- setAlternativeImage (alternativeImage)
- TODO
- setAttending (rpendity)
- Sets the entity to whom the NPC is currently listening.
- rpentity : (
RPEntity
) The entity with whom the NPC should be interacting
- setCurrentState (state)
- TODO
- setIdleDirection (dir)
- Sets the direction the entity will face while not interacting with a player.
- dir : (
Direction
) Direction to face.
- setPlayerChatTimeout (playerChatTimeout)
- Sets the time a conversation can be paused before it will be terminated by the NPC.
- playerChatTimeout : (
long
) Time in seconds.
SilentNPC
- Class: games.stendhal.server.entity.npc.SilentNPC
- Inherits: PassiveNPC