Class RPEntity

All Implemented Interfaces:
IEntity, RPObjectChangeListener
Direct Known Subclasses:
Creature, NPC, Player

public abstract class RPEntity extends ActiveEntity
This class is a link between client graphical objects and server attributes objects.
You need to extend this object in order to add new elements to the game.
  • Field Details

    • PROP_ADMIN_LEVEL

      public static final games.stendhal.client.entity.Property PROP_ADMIN_LEVEL
      Admin Level property.
    • PROP_GHOSTMODE

      public static final games.stendhal.client.entity.Property PROP_GHOSTMODE
      ghostmode property.
    • PROP_GROUP_MEMBERSHIP

      public static final games.stendhal.client.entity.Property PROP_GROUP_MEMBERSHIP
      group membership.
    • PROP_TEXT_INDICATORS

      public static final games.stendhal.client.entity.Property PROP_TEXT_INDICATORS
      Indicator text property. Fired if they are added or removed.
    • PROP_OUTFIT

      public static final games.stendhal.client.entity.Property PROP_OUTFIT
      Outfit property.
    • PROP_TITLE_TYPE

      public static final games.stendhal.client.entity.Property PROP_TITLE_TYPE
      Title Type property.
    • PROP_HP_RATIO

      public static final games.stendhal.client.entity.Property PROP_HP_RATIO
      Hp and max HP property.
    • PROP_HP_DISPLAY

      public static final games.stendhal.client.entity.Property PROP_HP_DISPLAY
      Property for showing and hiding the HP bar.
    • PROP_HEALER

      public static final games.stendhal.client.entity.Property PROP_HEALER
      Healer
    • PROP_MERCHANT

      public static final games.stendhal.client.entity.Property PROP_MERCHANT
      Merchant
    • PROP_CONFUSED

      public static final games.stendhal.client.entity.Property PROP_CONFUSED
      Confused property
    • PROP_EATING

      public static final games.stendhal.client.entity.Property PROP_EATING
      Eating property
    • PROP_POISONED

      public static final games.stendhal.client.entity.Property PROP_POISONED
      Poisoned property
    • PROP_SHOCK

      public static final games.stendhal.client.entity.Property PROP_SHOCK
      Shock property
    • PROP_ZOMBIE

      public static final games.stendhal.client.entity.Property PROP_ZOMBIE
      Zombie property
    • PROP_HEAVY

      public static final games.stendhal.client.entity.Property PROP_HEAVY
      Heavy property
    • PROP_ATTACK

      public static final games.stendhal.client.entity.Property PROP_ATTACK
      Attacking property. (for attack events)
    • OUTFIT_UNSET

      public static final int OUTFIT_UNSET
      The value of an outfit that isn't set.
      See Also:
      Constant Field Values
  • Method Details

    • addTextIndicator

      protected void addTextIndicator(String text, NotificationType type)
      Create/add a text indicator message.
      Parameters:
      text - The text message.
      type - The indicator type.
    • getAdminLevel

      public int getAdminLevel()
      Get the admin level.
      Returns:
      The admin level.
    • getAtk

      public int getAtk()
      Returns:
      Returns the atk.
    • getAtkItem

      public int getAtkItem()
      Returns:
      Returns the atk of items
    • getAtkXP

      public int getAtkXP()
      Returns:
      the attack xp
    • getBaseHP

      public int getBaseHP()
      Returns:
      Returns the base_hp.
    • getBaseMana

      public int getBaseMana()
      Returns:
      Returns the base mana value
    • getDef

      public int getDef()
      Returns:
      Returns the def.
    • getDefItem

      public int getDefItem()
      Returns:
      Returns the def of items
    • getDefXP

      public int getDefXP()
      Returns:
      the defence xp
    • getRatk

      public int getRatk()
      Returns:
      Returns the ratk.
    • getRatkItem

      public int getRatkItem()
      Returns:
      Returns the ratk of items
    • getRatkXP

      public int getRatkXP()
      Returns:
      the ranged xp
    • getHpRatio

      public float getHpRatio()
      Get the ratio of HP to base HP.
      Returns:
      The HP ratio (0.0 - 1.0).
    • getTextIndicators

      public Iterator<TextIndicator> getTextIndicators()
      Get the list of text indicator elements.
      Returns:
      An iterator of text indicators.
    • getMana

      public int getMana()
      Returns:
      Returns the total mana of a player
    • getExtOutfit

      public String getExtOutfit()
      Get the outfit code.
      Returns:
      The outfit code.
    • getOldOutfitCode

      public int getOldOutfitCode()
      Get the old outfit code.
      Returns:
      The outfit code.
    • getOutfit

      @Deprecated public int getOutfit()
      Deprecated.
      Get the outfit code.
      Returns:
      The outfit code.
    • getResolution

      public RPEntity.Resolution getResolution()
      The result of previous attack against this entity.
      Returns:
      attack result
    • getAttackTarget

      public RPEntity getAttackTarget()
      Get the attack target of an entity.
      Returns:
      the target, or null if there is none
    • getTitle

      public String getTitle()
      Get the nicely formatted entity title. This searches the follow attribute order: title, name (w/o underscore), class (w/o underscore), type (w/o underscore).
      Specified by:
      getTitle in interface IEntity
      Overrides:
      getTitle in class Entity
      Returns:
      The title, or null if unknown.
    • getTitleType

      public String getTitleType()
      Get title type.
      Returns:
      The title type, or null if the entity has no special title type
    • getXP

      public int getXP()
      Returns:
      Returns the XP.
    • getAttackers

      public Collection<Entity> getAttackers()
      Returns:
      Returns the entities attacking this entity
    • isAttacking

      public boolean isAttacking(IEntity defender)
      Check if the entity is attacking a specified entity. This is meant to be called from the EDT when drawing entities.
      Parameters:
      defender - the potential target
      Returns:
      true if defender is attacked by this entity, otherwise false
    • isBeingAttacked

      public boolean isBeingAttacked()
      Check if the entity is a target of an attack.
      Returns:
      true if the entity is being attacked, otherwise false
    • isAttackedBy

      public boolean isAttackedBy(IEntity attacker)
      Check if a specific entity is attacking this RPEntity.
      Parameters:
      attacker - potential attacker
      Returns:
      true if attacker is attacking this RPEntity, otherwise false
    • getShownDamageType

      public Nature getShownDamageType()
      Get the damage type of the current strike.
      Returns:
      type of damage, or null if the entity is not striking
    • getShownWeapon

      public String getShownWeapon()
      Get the weapon used in the current attack.
      Returns:
      weapon, or null if not specified
    • isDoingRangedAttack

      public boolean isDoingRangedAttack()
      Check if the currently performed attack is ranged.
      Returns:
      true if the attack is ranged, false otherwise
    • isDefending

      public boolean isDefending()
      Check if the entity is defending against an attack right now. The entity is defending if the last attack happened within 1.2s.
      Returns:
      true if the entity is defending against an attack, false otherwise
    • isEating

      public boolean isEating()
      Check if the entity is eating.
      Returns:
      true if the entity is eating, otherwise false
    • isGhostMode

      public boolean isGhostMode()
      Determine if in full ghostmode.
      Returns:
      true is in full ghostmode.
    • ignoresCollision

      public boolean ignoresCollision()
      Check if the entity can pass through static collisions.
      Returns:
      true if the entity can pass through walls, otherwise false
    • isConfused

      public boolean isConfused()
      Check if the entity is confused or poisoned.
      Returns:
      true if the entity is confused or poisoned, otherwise false
    • hasStatus

      public boolean hasStatus(StatusID status)
      Check if the entity has a certain status.
      Parameters:
      status - status id
      Returns:
      true if the entity has the status, otherwise false.
    • isChoking

      public boolean isChoking()
      Check if the entity is choking.
      Returns:
      true if the entity is choking, otherwise false
    • onAttackPerformed

      public void onAttackPerformed(Nature type, boolean ranged, String weapon)
      When this entity performs an attack.
      Parameters:
      type - attack nature
      ranged - true if it's a ranged attack, otherwise false
      weapon - Weapon used in the attack, or null if not specified
    • onBlocked

      public void onBlocked()
      Called when this entity blocks the attack by attacker.
    • onDamaged

      public void onDamaged(Entity attacker, int damage)
      Called when this entity is damaged by attacker with damage amount.
      Parameters:
      attacker - attacking entity
      damage - amount of damage
    • onHealed

      public void onHealed(int amount)
      Called when the entity gets healed.
      Parameters:
      amount - amount healed
    • onMissed

      public void onMissed()
      Called when an attacker misses this entity.
    • onPrivateListen

      public void onPrivateListen(String texttype, String text)
      Called when entity listen to text from talker.
      Parameters:
      texttype - type of talk (normal private talk, administrator message)
      text - message contents
    • onReachAchievement

      public void onReachAchievement(String achievementTitle, String achievementDescription, String achievementCategory)
      Called when the entity reaches an achievement.
      Parameters:
      achievementTitle - title of the achievement
      achievementDescription - description of the achievement
      achievementCategory - achievement category
    • onTalk

      public void onTalk(String text)
      Called when entity says something.
      Parameters:
      text - message contents
    • getResistance

      public int getResistance()
      Get the resistance this has on other entities (0-100).
      Specified by:
      getResistance in interface IEntity
      Overrides:
      getResistance in class Entity
      Returns:
      The resistance, or 0 if in ghostmode.
    • initialize

      public void initialize(RPObject object)
      Initialize this entity for an object.
      Specified by:
      initialize in interface IEntity
      Overrides:
      initialize in class ActiveEntity
      Parameters:
      object - The object.
      See Also:
      release()
    • release

      public void release()
      Release this entity. This should clean anything that isn't automatically released (such as unregister callbacks, cancel external operations, etc).
      Specified by:
      release in interface IEntity
      Overrides:
      release in class Entity
      See Also:
      initialize(RPObject)
    • update

      public void update(int delta)
      Update cycle.
      Specified by:
      update in interface IEntity
      Overrides:
      update in class ActiveEntity
      Parameters:
      delta - The time (in ms) since last call.
    • onChangedAdded

      public void onChangedAdded(RPObject object, RPObject changes)
      The object added/changed attribute(s).
      Specified by:
      onChangedAdded in interface RPObjectChangeListener
      Overrides:
      onChangedAdded in class Entity
      Parameters:
      object - The base object.
      changes - The changes.
    • onChangedRemoved

      public void onChangedRemoved(RPObject object, RPObject changes)
      The object removed attribute(s).
      Specified by:
      onChangedRemoved in interface RPObjectChangeListener
      Overrides:
      onChangedRemoved in class Entity
      Parameters:
      object - The base object.
      changes - The changes.
    • showTitle

      public boolean showTitle()
      Check if the entity view should show the title.
      Returns:
      true, if the title should be displayed, false if it should be hidden
    • showHPBar

      public boolean showHPBar()
      Check if the entity view should show the HP indicator.
      Returns:
      true, if the HP bar should be displayed, false if it should be hidden
    • castsShadow

      public boolean castsShadow()
      Check if a shadow should be drawn under the entity.
      Returns:
      true if a shadow should be drawn, false if not.
    • getShadowStyle

      public String getShadowStyle()
      Retrieves the name that should be used to override shadow.
      Returns:
      String path to shadow file to use or null.
    • addSounds

      protected void addSounds(String groupName, String categoryName, String... soundNames)
    • onPosition

      protected void onPosition(double x, double y)
      Description copied from class: Entity
      When the entity's position changed.
      Overrides:
      onPosition in class Entity
      Parameters:
      x - The new X coordinate.
      y - The new Y coordinate.
    • playRandomSoundFromCategory

      protected void playRandomSoundFromCategory(String groupName, String categoryName)
    • playRandomSoundFromGroup

      protected void playRandomSoundFromGroup(String groupName, String categoryName, long waitTimeInMilliSec)
    • playSoundFromCategory

      protected void playSoundFromCategory(String groupName, String categoryName)
    • playSoundFromCategory

      protected void playSoundFromCategory(String groupName, String categoryName, int index)