StendhalAPI: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>AntumDeluge Page for common public Stendhal server API |
imported>AntumDeluge →Entity: add more public methods |
||
| Line 12: | Line 12: | ||
=== Entity === |
=== Entity === |
||
This is the base entity class for all entities in Stendhal. |
|||
* Class: {{StendhalFile|master|src/games/stendhal/server/entity/Entity.java|games.stendhal.server.entity.Entity}} |
* Class: {{StendhalFile|master|src/games/stendhal/server/entity/Entity.java|games.stendhal.server.entity.Entity}} |
||
| Line 17: | Line 19: | ||
* Implements: |
* Implements: |
||
** {{StendhalFile|master|src/games/stendhal/server/entity/Killer.java|games.stendhal.server.entity.Killer}} |
** {{StendhalFile|master|src/games/stendhal/server/entity/Killer.java|games.stendhal.server.entity.Killer}} |
||
This is the base entity class for all entities in Stendhal. |
|||
Public methods: |
Public methods: |
||
| Line 28: | Line 28: | ||
: Copy constructor. |
: Copy constructor. |
||
: '''''object:''''' Object to be copied. |
: '''''object:''''' Object to be copied. |
||
; ''<span style="color:green;">generateRPClass</span>()'' |
|||
: Initializes the RPClass for this entity (initialized from {{StendhalFile|master|src/games/stendhal/server/core/engine/RPClassGenerator.java|games.stendhal.server.core.engine.RPClassGenerator}}). |
|||
; ''<span style="color:green;">setDescription</span>(text)'' |
; ''<span style="color:green;">setDescription</span>(text)'' |
||
: Sets the description text for the entity. |
: Sets the description text for the entity. |
||
: '''''text:''''' String to be used for description. |
: '''''text:''''' String to be used for description. |
||
; ''<span style="color:green;">setEntityClass</span>(clazz)'' |
|||
: Sets the "class" attribute which is used to determine an image to be used as a representation of this entity. |
|||
: '''''clazz:''''' (<code>String</code>) Class name. |
|||
; ''<span style="color:green;">setEntitySubclass</span>(subclazz)'' |
|||
: Sets the "subclass" attribute which is used to determine an image to be used as a representation of this entity. |
|||
: '''''subclazz:''''' (<code>String</code>) Sub-class name. |
|||
; ''<span style="color:green;">setSize</span>(width, height)'' |
|||
: Sets the entity's size. |
|||
: '''''width:''''' (<code>int</code>) |
|||
: '''''height:''''' (<code>int</code>) |
|||
; ''<span style="color:green;">setPosition</span>(x, y)'' |
|||
: Sets the entity's horizontal & vertical position. |
|||
: '''''x:''''' (<code>int</code>) The horizontal position. |
|||
: '''''y:''''' (<code>int</code>) The vertical position. |
|||
; ''<span style="color:green;">setResistance</span>(resistance)'' |
|||
: Sets the resistance this has with other entities. |
|||
: '''''resistance:''''' (<code>int</code>) Amount of resistance to set (0-100). |
|||
; ''<span style="color:green;">setVisibility</span>(visibility)'' |
|||
: Sets the entity's visibility level. |
|||
: '''''visibility:''''' (<code>int</code>) <code>0</code> = completely transparent, <code>100</code> = completely opaque. |
|||
; ''<span style="color:green;">setMenu</span>(menu)'' |
|||
: Sets the context menu to use for the entity. |
|||
: '''''menu:''''' (<code>String</code>) The menu to display in the client in the format: |
|||
<blockquote> |
|||
<pre> |
|||
Display name 1|action1, |
|||
Display name 2|action2 |
|||
</pre> |
|||
</blockquote> |
|||
; ''<span style="color:green;">setCursor</span>(cursor)'' |
|||
: Sets the name of the mouse cursor that should be used for this entity. |
|||
: '''''cursor:''''' (<code>String</code>) |
|||
; ''<span style="color:green;">getTitle</span>()'' |
; ''<span style="color:green;">getTitle</span>()'' |
||
: Retrieves the entity's title/name |
: Retrieves the entity's nicely formatted title/name. |
||
: ''returns:'' (<code> |
: ''returns:'' (<code>String</code>) The entity's formatted name. |
||
; ''<span style="color:green;">getName</span>()'' |
|||
: Retrieves the name of this entity. |
|||
: ''returns:'' (<code>String</code>) The entity's name. |
|||
; ''<span style="color:green;">getDescription</span>()'' |
; ''<span style="color:green;">getDescription</span>()'' |
||
: Retrieves the entity's description text. |
: Retrieves the entity's description text. |
||
: ''returns:'' (<code>string</code>) The entity's description text. |
: ''returns:'' (<code>string</code>) The entity's description text. |
||
; ''<span style="color:green;">getDescriptionName</span>(definite)'' |
|||
: Retrieves the name or something that can be used to identify the entity to the player. |
|||
: '''''definite:''''' (<code>bool</code>) Determines article to be used as prefix. <code>true</code> for "the" & <code>false</code> for "a/an" in case the entity has no name. |
|||
: ''returns:'' (<code>String</code>) Entity name including article. |
|||
; ''<span style="color:green;">getHeight</span>()'' |
|||
: Retrieves the entity's height. |
|||
: ''returns:'' (<code>double</code>) |
|||
; ''<span style="color:green;">getWidth</span>()'' |
|||
: Retrieves the entity's width. |
|||
: ''returns:'' (<code>double</code>) |
|||
; ''<span style="color:green;">getZone</span>()'' |
; ''<span style="color:green;">getZone</span>()'' |
||
| Line 57: | Line 117: | ||
: '''''entity:''''' (optional) If set, returned value is combined resistance. |
: '''''entity:''''' (optional) If set, returned value is combined resistance. |
||
: ''returns:'' (<code>int</code>) Value between 0-100 (0 = no resistance, 100 = non-traversable). |
: ''returns:'' (<code>int</code>) Value between 0-100 (0 = no resistance, 100 = non-traversable). |
||
; ''<span style="color:green;">getAdjacentNodes</span>()'' |
|||
: 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:'' (<code>List<Node></code>) All nodes next to entity. |
|||
; ''<span style="color:green;">getArea</span>()'' |
|||
: Retrieves the area this entity currently occupies. |
|||
: ''returns:'' (<code>Rectangle2D</code>) |
|||
; ''<span style="color:green;">getArea</span>(ex, ey)'' |
|||
: |
|||
: '''''ex:''''' (<code>double</code>) |
|||
: '''''ey:''''' (<code>double</code>) |
|||
: ''returns:'' (<code>Rectangle2D</code>) |
|||
; ''<span style="color:green;">getOrigin</span>()'' |
|||
: Retrieves the initial position of the entity. |
|||
: ''returns:'' (<code>Point</code>) |
|||
; ''<span style="color:green;">getEntitySlot</span>(name)'' |
|||
: Retrieve's a slot identified by <code>name</code>. |
|||
: '''''name:''''' (<code>String</code>) Name of slot. |
|||
: ''returns:'' (<code>EntitySlot</code>) EntitySlot instance or <code>null</code> if the entity does not have such slot. |
|||
; ''<span style="color:green;">getCursor</span>()'' |
|||
: Retrieves the name of the mouse cursor that should be used for this entity. |
|||
: ''returns:'' (<code>String</code>) Cursor name or </code>null</code>. |
|||
; ''<span style="color:green;">stopped</span>()'' |
; ''<span style="color:green;">stopped</span>()'' |
||
| Line 70: | Line 158: | ||
: '''''entity:''''' The entity to check against. |
: '''''entity:''''' The entity to check against. |
||
: ''returns:'' (<code>bool</code>) <code>true</code> if combined resistance is above 95. |
: ''returns:'' (<code>bool</code>) <code>true</code> if combined resistance is above 95. |
||
; ''<span style="color:green;">isInSight</span>(other)'' |
|||
: Checks if another entity is close enough to be detected by this entity. |
|||
: '''''other:''''' (<code>Entity</code>) The entity to gauge distance to. |
|||
: ''returns:'' (<code>boolean</code>) <code>true</code> if near enough. |
|||
; ''<span style="color:green;">squaredDistance</span>(other)'' |
|||
: Retrieves the square distance between this entity & the given one. |
|||
: '''''other:''''' (<code>Entity</code>) The entity to which the distance should be calculated. |
|||
: ''returns:'' (<code>double</code>) Representation of the squared distance. |
|||
; ''<span style="color:green;">squaredDistance</span>(x, y)'' |
|||
: Retrieves the square distance between this entity & a given point. |
|||
: '''''x:''''' (<code>int</code>) The horizontal position to which distance should be calculated. |
|||
: '''''y:''''' (<code>int</code>) The vertical position to which distance should be calculated. |
|||
: ''returns:'' (<code>double</code>) Representation of the squared distance. |
|||
; ''<span style="color:green;">nextTo</span>(entity, step)'' |
|||
: Checks whether the given entity is next to this one. |
|||
: '''''entity:''''' (<code>Entity</code>) The entity to compare distance to. |
|||
: '''''step:''''' (<code>double</code>) (default: ''0.25'') Maximum distance at which is required to determine if next to. |
|||
: ''returns:'' (<code>bool</code>) <code>true</code> if '''''entity''''' is next to this one. |
|||
; ''<span style="color:green;">onAdded</span>(zone)'' |
|||
: Called when this entity is added to a zone. |
|||
: '''''zone:''''' (<code>StendhalRPZone</code>) The zone this was added to. |
|||
; ''<span style="color:green;">onRemoved</span>(zone)'' |
|||
: Called when this entity is being removed from a zone. |
|||
: '''''zone:''''' (<code>StendhalRPZone</code>) The zone this will be removed from. |
|||
; ''<span style="color:green;">notifyWorldAboutChanges</span>()'' |
|||
: Notifies the <code>StendhalRPWorld</code> that this entity's attributes have changed. |
|||
; ''<span style="color:green;">describe</span>()'' |
|||
: Describes then entity (commonly used for when a player "looks" at an entity). |
|||
: ''returns:'' (<code>string</code>) Description from the player's point-of-view. |
|||
; ''<span style="color:green;">slotIterator</span>(slotTypes)'' |
|||
: |
|||
: '''''slotTypes:''''' (<code>Slots</code>) Slot types to include in the iteration. |
|||
: ''returns:'' (<code>Iterator<RPSlot></code>) |
|||
; ''<span style="color:green;">slots</span>(slotTypes)'' |
|||
: |
|||
: '''''slotTypes:''''' (<code>Slots</code>) Slot types to include in the iteration. |
|||
: ''returns:'' (<code>Iterable<RPSlot></code>) |
|||
=== ActiveEntity === |
=== ActiveEntity === |
||