Class RPEntity

All Implemented Interfaces:
Killer, Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
DressedEntity

public abstract class RPEntity extends GuidedEntity
  • Field Details

    • ATTR_TITLE

      protected static final String ATTR_TITLE
      The title attribute name.
      See Also:
      Constant Field Values
    • atk

      protected int atk
    • def

      protected int def
    • ratk

      protected int ratk
    • lv_cap

      protected int lv_cap
    • level

      protected int level
    • statusAttackers

      protected com.google.common.collect.ImmutableList<StatusAttacker> statusAttackers
      Entity uses a status attack
    • statusList

      protected StatusList statusList
      a list of current statuses
    • damageReceived

      protected CounterMap<Entity> damageReceived
      Maps each attacker to the sum of hitpoint loss it has caused to this RPEntity.
    • totalDamageReceived

      protected int totalDamageReceived
  • Constructor Details

    • RPEntity

      public RPEntity(RPObject object)
    • RPEntity

      public RPEntity()
  • Method Details

    • handlePortal

      protected boolean handlePortal(Portal portal)
      Overrides:
      handlePortal in class ActiveEntity
    • generateRPClass

      public static void generateRPClass()
    • addKarma

      public void addKarma(double karma)
      Give the player some karma (good or bad).
      Parameters:
      karma - An amount of karma to add/subtract.
    • getKarma

      public double getKarma()
      Get the current amount of karma.
      Returns:
      The current amount of karma.
      See Also:
      addKarma(double)
    • useKarma

      public double useKarma(double scale)
      Get some of the player's karma. A positive value indicates good luck/energy. A negative value indicates bad luck/energy. A value of zero should cause no change on an action or outcome.
      Parameters:
      scale - A positive number.
      Returns:
      A number between -scale and scale.
    • useKarma

      public double useKarma(double negLimit, double posLimit)
      Get some of the player's karma. A positive value indicates good luck/energy. A negative value indicates bad luck/energy. A value of zero should cause no change on an action or outcome.
      Parameters:
      negLimit - The lowest negative value returned.
      posLimit - The highest positive value returned.
      Returns:
      A number within negLimit <= 0 <= posLimit.
    • useKarma

      public double useKarma(double negLimit, double posLimit, double granularity)
      Use some of the player's karma. A positive value indicates good luck/energy. A negative value indicates bad luck/energy. A value of zero should cause no change on an action or outcome.
      Parameters:
      negLimit - The lowest negative value returned.
      posLimit - The highest positive value returned.
      granularity - The amount that any extracted karma is a multiple of.
      Returns:
      A number within negLimit <= 0 <= posLimit.
    • heal

      public int heal()
      Heal this entity completely.
      Returns:
      The amount actually healed.
    • heal

      public int heal(int amount)
      Heal this entity.
      Parameters:
      amount - The [maximum] amount to heal by.
      Returns:
      The amount actually healed.
    • heal

      public int heal(int amount, boolean tell)
      Heal this entity.
      Parameters:
      amount - The [maximum] amount to heal by.
      tell - Whether to tell the entity they've been healed.
      Returns:
      The amount actually healed.
    • addMana

      public int addMana(int mana, boolean tell)
      Give mana to the entity.
      Parameters:
      mana - The amount of mana to add/substract.
      tell - Whether to tell the entity that mana has been added.
      Returns:
      Amount of mana actually refilled.
    • update

      public void update()
      Overrides:
      update in class ActiveEntity
    • damageDone

      public int damageDone(RPEntity defender, double attackingWeaponsValue, Nature damageType)
      Is called when this has hit the given defender. Determines how much hitpoints the defender will lose, based on this's ATK experience and weapon(s), the defender's DEF experience and defensive items, and a random generator.
      Parameters:
      defender - The defender.
      attackingWeaponsValue - ATK-value of all attacking weapons/spells
      damageType - nature of damage
      Returns:
      The number of hitpoints that the target should lose. 0 if the attack was completely blocked by the defender.
    • applyDistanceAttackModifiers

      public static int applyDistanceAttackModifiers(int damage, double squareDistance, double maxrange)
      Calculates the damage that will be done in a distance attack (bow and arrows, spear, etc.).
      Parameters:
      damage - The damage that would have been done if there would be no modifiers for distance attacks.
      squareDistance - the distance
      maxrange - maximum attack range
      Returns:
      The damage that will be done with the distance attack.
    • setName

      public void setName(String name)
      Set the entity's name.
      Parameters:
      name - The new name.
    • getName

      public String getName()
      Get the entity's name.
      Specified by:
      getName in interface Killer
      Overrides:
      getName in class Entity
      Returns:
      The entity's name.
    • onAdded

      public void onAdded(StendhalRPZone zone)
      Description copied from class: ActiveEntity
      Called when this object is added to a zone.
      Overrides:
      onAdded in class ActiveEntity
      Parameters:
      zone - The zone this was added to.
    • setLevel

      public void setLevel(int level)
    • getLevel

      public int getLevel()
    • setAtk

      public void setAtk(int atk)
    • setAtkInternal

      protected void setAtkInternal(int atk, boolean notify)
    • getAtk

      public int getAtk()
    • getCappedAtk

      public int getCappedAtk()
      gets the capped atk level, which prevent players from training their atk way beyond what is reasonable for their level
      Returns:
      capped atk
    • setAtkXP

      public void setAtkXP(int atk)
      Set attack XP.
      Parameters:
      atk - the new value
    • addAtkXP

      public void addAtkXP(int xp)
      Adjust entity's ATK XP by specified amount.
      Parameters:
      xp - Amount to add.
    • getAtkXP

      public int getAtkXP()
    • incAtkXP

      public void incAtkXP()
      Increase attack XP by 1.
    • setDef

      public void setDef(int def)
    • setDefInternal

      protected void setDefInternal(int def, boolean notify)
    • getDef

      public int getDef()
    • getCappedDef

      public int getCappedDef()
      gets the capped def level, which prevent players from training their def way beyond what is reasonable for their level
      Returns:
      capped def
    • setDefXP

      public void setDefXP(int defXp)
      Set defense XP.
      Parameters:
      defXp - the new value
    • addDefXP

      public void addDefXP(int xp)
      Adjust entity's DEF XP by specified amount.
      Parameters:
      xp - Amount to add.
    • getDefXP

      public int getDefXP()
    • incDefXP

      public void incDefXP()
      Increase defense XP by 1.
    • setRatk

      public void setRatk(int ratk)
      Set the value of the entity's ranged attack level.
      Parameters:
      ratk - Integer value representing new ranged attack level
    • setRatkInternal

      protected void setRatkInternal(int ratk, boolean notify)
      Set the entity's ranged attack level.
      Parameters:
      ratk - Integer value representing new ranged attack level
      notify - Update stat in real-time
    • getRatk

      public int getRatk()
      Gets the entity's current ranged attack level.
      Returns:
      Integer value of ranged attack level
    • getCappedRatk

      public int getCappedRatk()
      gets the capped ranged attack level which prevents players from training ratk way beyond what is reasonable for their level.
      Returns:
      The maximum value player's ranged attack level can be at current level
    • setRatkXP

      public void setRatkXP(int ratkXP)
      Sets the entity's ranged attack experience.
      Parameters:
      ratkXP - Integer value of the target experience
    • setRatkXPInternal

      protected void setRatkXPInternal(int ratkXP, boolean notify)
      Sets the entity's ranged attack experience.
      Parameters:
      ratkXP - Integer value of the target experience
      notify - Update ranged attack experience in real-time
    • addRatkXP

      public void addRatkXP(int xp)
      Adjust entity's RATK XP by specified amount.
      Parameters:
      xp - Amount to add.
    • getRatkXP

      public int getRatkXP()
      Get's the entity's current ranged attack experience.
      Returns:
      Integer representation of current experience
    • incRatkXP

      public void incRatkXP()
      Increase ranged XP by 1.
    • initHP

      public void initHP(int hp)
      Set the base and current HP.
      Parameters:
      hp - The HP to set.
    • setBaseHP

      public void setBaseHP(int newhp)
      Set the base HP.
      Parameters:
      newhp - The base HP to set.
    • getBaseHP

      public int getBaseHP()
      Get the base HP.
      Returns:
      The current HP.
    • setHP

      public void setHP(int hp)
      Set the HP.
      DO NOT USE THIS UNLESS YOU REALLY KNOW WHAT YOU ARE DOING.
      Use the appropriate damage(), and heal() methods instead.
      Parameters:
      hp - The HP to set.
    • getHP

      public int getHP()
      Get the current HP.
      Returns:
      The current HP.
    • getLVCap

      public int getLVCap()
      Get the lv_cap.
      Returns:
      The current lv_cap.
    • getMana

      public int getMana()
      Gets the mana (magic).
      Returns:
      mana
    • getBaseMana

      public int getBaseMana()
      Gets the base mana (like base_hp).
      Returns:
      base mana
    • setMana

      public void setMana(int newMana)
      Sets the available mana.
      Parameters:
      newMana - new amount of mana
    • setBaseMana

      public void setBaseMana(int newBaseMana)
      Sets the base mana (like base_hp).
      Parameters:
      newBaseMana - new amount of base mana
    • addBaseMana

      public void addBaseMana(int newBaseMana)
      adds to base mana (like addXP).
      Parameters:
      newBaseMana - amount of base mana to be added
    • setLVCap

      public void setLVCap(int newLVCap)
    • setXP

      public final void setXP(int newxp)
    • subXP

      public void subXP(int newxp)
    • addXP

      public void addXP(int newxp)
    • updateLevel

      protected void updateLevel()
      Change the level to match the XP, if needed.
    • getXP

      public int getXP()
    • getSusceptibility

      protected double getSusceptibility(Nature type)
      Get a multiplier for a given damage type when this entity is damaged.
      Parameters:
      type - Type of the damage
      Returns:
      damage multiplier
    • getDamageType

      protected Nature getDamageType()
      Get the type of the damage this entity inflicts
      Returns:
      type of damage
    • getRangedDamageType

      protected Nature getRangedDamageType()
      Get the nature of the damage the entity inflicts in ranged attacks.
      Returns:
      type of damage
    • isAttackable

      public boolean isAttackable()
      Returns:
      true if this RPEntity is attackable.
    • setTarget

      public void setTarget(RPEntity target)
      Modify the entity to order to attack the target entity.
      Parameters:
      target -
    • stopAttack

      public void stopAttack()
      Modify the entity to stop attacking.
    • getsFightXpFrom

      public boolean getsFightXpFrom(RPEntity enemy)
    • stopAttacking

      public void stopAttacking(Entity attacker)
    • rememberAttacker

      public void rememberAttacker(Entity attacker)
    • setBlood

      public final void setBlood(String name)
      sets the blood class
      Parameters:
      name - name of blood class
    • getBloodClass

      public final String getBloodClass()
      gets the name of the blood class
      Returns:
      bloodClass or null
    • getDroppables

      public List<Item> getDroppables()
      return list of all droppable items in entity's hands. currently only considers items in hands. no other part of body currently, there is only one type of droppable item - CaptureTheFlagFlag. need some more general solution
      Returns:
      list of droppable items. returns null if no droppable items found
    • dropDroppableItem

      public void dropDroppableItem(Item droppable)
      Drop specified item from entity's equipment note: seems like this.drop(droppable) should work, but the item just disappears - does not end up on ground. TODO: probably need to refactor this in to the general drop system (maybe fixing some of the other code paths)
      Parameters:
      droppable - item to be dropped
    • maybeDropDroppables

      public String maybeDropDroppables(RPEntity attacker)
      if defender (this entity) is carrying a droppable item, then attacker and defender both roll d20, and if attacker rolls higher, the defender drops the droppable. note that separate rolls are performed for each droppable that the entity is carrying. XXX this does not belong here - should be in some Effect framework returns string - what happened. no effect returns null
      Parameters:
      attacker -
      Returns:
      event description
    • onDamaged

      public void onDamaged(Entity attacker, int damage)
      This method is called when this entity has been attacked by Entity attacker and it has been damaged with damage points.
      Parameters:
      attacker -
      damage -
    • damage

      public int damage(int amount, Killer attacker)
      Apply damage to this entity, and call onDead() if HP reaches 0.
      Parameters:
      amount - The HP to take.
      attacker - The attacking entity.
      Returns:
      The damage actually taken (in case HP was < amount).
    • delayedDamage

      public void delayedDamage(int amount, String attackerName)
      Apply damage to this entity, delaying the damage to happen in a turn notifier. To be used when dying could result in concurrent modification in the zone's entity list, such as sheep starving. Call onDead() if HP reaches 0.
      Parameters:
      amount - The HP to take.
      attackerName - The name of the attacker.
    • entityAsOnlinePlayer

      protected Player entityAsOnlinePlayer(Entity entity)
      For rewarding killers. Get the entity as a Player, if the entity is a Player. If the player has logged out, try to get the corresponding online player.
      Parameters:
      entity - entity to be checked
      Returns:
      online Player corresponding to the entity, or null if the entity is not a Player, or if the equivalent player is not online
    • entityAsPet

      protected Pet entityAsPet(Entity entity)
    • rewardKillers

      protected void rewardKillers(int oldXP)
      Gives XP to every player who has helped killing this RPEntity.
      Parameters:
      oldXP - The XP that this RPEntity had before being killed.
    • rewardKillerAnimals

      protected void rewardKillerAnimals(int oldXP)
    • onDead

      public final void onDead(Killer killer)
      This method is called when the entity has been killed ( hp==0 ).
      Parameters:
      killer - The entity who caused the death
    • onDead

      public void onDead(Killer killer, boolean remove)
      This method is called when this entity has been killed (hp == 0).
      Parameters:
      killer - The entity who caused the death, i.e. who did the last hit.
      remove - true iff this entity should be removed from the world. For almost everything remove is true, but not for the players, who are instead moved to afterlife ("reborn").
    • makeCorpse

      protected Corpse makeCorpse(String killer)
      Make a corpse belonging to this entity
      Parameters:
      killer - Name of the killer
      Returns:
      The corpse of a dead RPEntity
    • getCorpseName

      public String getCorpseName()
      Get the corpse image name to be used for the entity. Defaults to a player corpse.
      Returns:
      Identification string for corpse. This is the corpse image shown by the client without the path or file extension.
    • getHarmlessCorpseName

      public String getHarmlessCorpseName()
    • getCorpseWidth

      public int getCorpseWidth()
    • getCorpseHeight

      public int getCorpseHeight()
    • dropItemsOn

      protected abstract void dropItemsOn(Corpse corpse)
    • isInvisibleToCreatures

      public boolean isInvisibleToCreatures()
      Determine if the entity is invisible to creatures.
      Returns:
      true if invisible.
    • isAttacked

      public boolean isAttacked()
      Return true if this entity is attacked.
      Returns:
      true if no attack sources found
    • getAttackSources

      public List<Entity> getAttackSources()
      Returns the Entities that are attacking this character.
      Returns:
      list of all attacking entities
    • getAttackingRPEntities

      public List<RPEntity> getAttackingRPEntities()
      Returns the RPEntities that are attacking this character.
      Returns:
      list of all attacking RPEntities
    • isAttacking

      public boolean isAttacking()
      Checks whether the attacktarget is null. Sets attacktarget to null if hp of attacktarget <=0;
      Returns:
      true if attacktarget != null and not dead
    • getAttackTarget

      public RPEntity getAttackTarget()
      Return the RPEntity that this entity is attacking.
      Returns:
      the attack target of this
    • equipToInventoryOnly

      public final boolean equipToInventoryOnly(Item item)
      Tries to equip an item in the appropriate slot.
      Parameters:
      item - the item
      Returns:
      true if the item can be equipped, else false
    • getSlotToEquip

      public final RPSlot getSlotToEquip(Item item)
      Gets the slot in which the entity can equip the item, preferring locations where the item can be merged with existing item stacks.
      Parameters:
      item -
      Returns:
      the slot for the item or null if there is no matching slot in the entity
    • equipOrPutOnGround

      public final boolean equipOrPutOnGround(Item item)
      Tries to equip an item in the appropriate slot.
      Parameters:
      item - the item
      Returns:
      true if the item can be equipped, else false
    • equip

      public final boolean equip(String slotName, Item item)
      Tries to equip one unit of an item in the given slot. Note: This doesn't check if it is allowed to put the given item into the given slot, e.g. it is possible to wear your helmet at your feet using this method.
      Parameters:
      slotName - the name of the slot
      item - the item
      Returns:
      true if the item can be equipped, else false
    • drop

      public boolean drop(String name, int amount)
      Removes a specific amount of an item from the RPEntity. The item can either be stackable or non-stackable. The units can be distributed over different slots. If the RPEntity doesn't have enough units of the item, doesn't remove anything.
      Parameters:
      name - The name of the item
      amount - The number of units that should be dropped
      Returns:
      true iff dropping the desired amount was successful.
    • drop

      public boolean drop(String name)
      Removes one unit of an item from the RPEntity. The item can either be stackable or non-stackable. If the RPEntity doesn't have enough the item, doesn't remove anything.
      Parameters:
      name - The name of the item
      Returns:
      true iff dropping the item was successful.
    • drop

      public boolean drop(Item item)
      Removes the given item from the RPEntity. The item can either be stackable or non-stackable. If the RPEntity doesn't have the item, doesn't remove anything.
      Parameters:
      item - the item that should be removed
      Returns:
      true iff dropping the item was successful.
    • dropWithInfostring

      public boolean dropWithInfostring(String name, String infostring, int amount)
      Removes a specific amount of an item with matching info string from the RPEntity. The item can either be stackable or non-stackable. The units can be distributed over different slots. If the RPEntity doesn't have enough units of the item, doesn't remove anything.
      Parameters:
      name - Name of item to remove.
      infostring - Required item info string to match.
      amount - Number of items to remove from entity.
      Returns:
      true if dropping the item(s) was successful.
    • dropWithInfostring

      public boolean dropWithInfostring(String name, String infostring)
      Removes a single item with matching info string from the RPEntity. The item can either be stackable or non-stackable. The units can be distributed over different slots. If the RPEntity doesn't have enough units of the item, doesn't remove anything.
      Parameters:
      name - Name of item to remove.
      infostring - Required item info string to match.
      Returns:
      true if dropping the item(s) was successful.
    • isEquipped

      public boolean isEquipped(String name, int amount)
      Determine if this entity is equipped with a minimum quantity of an item.
      Parameters:
      name - The item name.
      amount - The minimum amount.
      Returns:
      true if the item is equipped with the minimum number.
    • isEquipped

      public boolean isEquipped(String name)
      Determine if this entity is equipped with an item.
      Parameters:
      name - The item name.
      Returns:
      true if the item is equipped.
    • isEquippedWithInfostring

      public boolean isEquippedWithInfostring(String name, String infostring, int amount)
      Checks if entity carry a number of items with specified info string.
      Parameters:
      name - Name of item to check.
      infostring - Info string of item to check.
      amount - Quantity of carried items to check.
      Returns:
      true if entity is carrying at least specified amount of items matching name & infostring.
    • isEquippedWithInfostring

      public boolean isEquippedWithInfostring(String name, String infostring)
      Checks if entity carry a number of items with specified info string.
      Parameters:
      name - Name of item to check.
      infostring - Info string of item to check.
      Returns:
      true if entity is carrying at least one of items matching name & infostring.
    • getNumberOfEquipped

      public int getNumberOfEquipped(String name)
      Gets the number of items of the given name that are carried by the RPEntity. The item can either be stackable or non-stackable.
      Parameters:
      name - The item's name
      Returns:
      The number of carried items
    • getTotalNumberOf

      public int getTotalNumberOf(String name)
      Gets the number of items of the given name including bank. The item can either be stackable or non-stackable.
      Parameters:
      name - The item's name
      Returns:
      The number of carried items
    • getFirstEquipped

      public Item getFirstEquipped(String name)
      Gets an item that is carried by the RPEntity. If the item is stackable, gets all that are on the first stack that is found.
      Parameters:
      name - The item's name
      Returns:
      The item, or a stack of stackable items, or null if nothing was found
    • getAllEquipped

      public List<Item> getAllEquipped(String name)
      Gets an item that is carried by the RPEntity. If the item is stackable, gets all that are on the first stack that is found.
      Parameters:
      name - The item's name
      Returns:
      The item, or a stack of stackable items, or an empty list if nothing was found
    • getAllEquippedWithInfostring

      public List<Item> getAllEquippedWithInfostring(String name, String infostring)
      Retrieves all of an item with matching info string.
      Parameters:
      name - Name of item to match.
      infostring - Info string of item to match.
      Returns:
      List
    • isEquippedItemClass

      public boolean isEquippedItemClass(String slot, String clazz)
      checks if an item of class clazz is equipped in slot slot returns true if it is, else false.
      Parameters:
      slot -
      clazz -
      Returns:
      true if so false otherwise
    • isEquippedItemInSlot

      public boolean isEquippedItemInSlot(String slot, String item)
      checks if an item is equipped in a slot
      Parameters:
      slot -
      item -
      Returns:
      true if so false otherwise
    • getEquippedItemClass

      public Item getEquippedItemClass(String slot, String clazz)
      Finds the first item of class clazz from the slot.
      Parameters:
      slot -
      clazz -
      Returns:
      the item or null if there is no item with the requested clazz.
    • getWeapon

      public Item getWeapon()
      Gets the weapon that this entity is holding in its hands.
      Returns:
      The weapon, or null if this entity is not holding a weapon. If the entity has a weapon in each hand, returns the weapon in its left hand.
    • getWeapons

      public List<Item> getWeapons()
    • getRangeWeapon

      public Item getRangeWeapon()
      Gets the range weapon (bow etc.) that this entity is holding in its hands.
      Returns:
      The range weapon, or null if this entity is not holding a range weapon. If the entity has a range weapon in each hand, returns one in its left hand.
    • getAmmunition

      public StackableItem getAmmunition()
      Gets the stack of ammunition (arrows or similar) that this entity is holding in its hands.
      Returns:
      The ammunition, or null if this entity is not holding ammunition. If the entity has ammunition in each hand, returns the ammunition in its left hand.
    • getMissileIfNotHoldingOtherWeapon

      public StackableItem getMissileIfNotHoldingOtherWeapon()
      Gets the stack of missiles (spears or similar) that this entity is holding in its hands, but only if it is not holding another, non-missile weapon in the other hand. You can only throw missiles while you're not holding another weapon. This restriction is a workaround because of the way attack strength is determined; otherwise, one could increase one's spear attack strength by holding an ice sword in the other hand.
      Returns:
      The missiles, or null if this entity is not holding missiles. If the entity has missiles in each hand, returns the missiles in its left hand.
    • hasShield

      public boolean hasShield()
      Returns:
      true if the entity has an item of class shield equipped.
    • getShield

      public Item getShield()
    • hasArmor

      public boolean hasArmor()
    • getArmor

      public Item getArmor()
    • hasHelmet

      public boolean hasHelmet()
    • getHelmet

      public Item getHelmet()
    • hasLegs

      public boolean hasLegs()
    • getLegs

      public Item getLegs()
    • hasBoots

      public boolean hasBoots()
    • getBoots

      public Item getBoots()
    • hasCloak

      public boolean hasCloak()
    • getCloak

      public Item getCloak()
    • hasRing

      public boolean hasRing()
    • getRing

      public Item getRing()
    • describe

      public String describe()
      Description copied from class: Entity
      Describes the entity (if a players looks at it).
      Overrides:
      describe in class Entity
      Returns:
      description from the players point of view
    • sendPrivateText

      public void sendPrivateText(String text)
      Sends a message that only this RPEntity can read. In this default implementation, this method does nothing; it can be overridden in subclasses.
      Parameters:
      text - The message.
    • sendPrivateText

      public void sendPrivateText(NotificationType type, String text)
      Sends a message that only this player can read.
      Parameters:
      type - NotificationType
      text - the message.
    • getItemAtk

      public float getItemAtk()
      Retrieves total ATK value of held weapons.
    • getItemRatk

      public float getItemRatk()
      Retrieves total range attack value of held weapon & ammunition.
    • getItemDef

      public float getItemDef()
    • getDefenseItems

      public List<Item> getDefenseItems()
      get all items that affect a player's defensive value except the weapon
      Returns:
      a list of all equipped defensive items
    • updateItemAtkDef

      public void updateItemAtkDef()
      Recalculates item based atk and def.
    • canDoRangeAttack

      public boolean canDoRangeAttack(RPEntity target, int maxrange)
      Can this entity do a distance attack on the given target?
      Parameters:
      target -
      maxrange - maximum attack distance
      Returns:
      true if this entity is armed with a distance weapon and if the target is in range.
    • hasLineOfSight

      public boolean hasLineOfSight(Entity target)
      Check if the entity has a line of sight to the the center of another entity. Only static collisions are checked.
      Parameters:
      target - target entity
      Returns:
      true if there are no collisions blocking the line of sight, false otherwise
    • getMaxRangeForArcher

      public int getMaxRangeForArcher()
      Get the maximum distance attack range.
      Returns:
      maximum range, or 0 if the entity can't attack from distance
    • setTitle

      public void setTitle(String title)
      Set the entity's formatted title.
      Parameters:
      title - The title, or null.
    • getDescriptionName

      public String getDescriptionName(boolean definite)
      Returns the name or something that can be used to identify the entity for the player.
      Overrides:
      getDescriptionName in class Entity
      Parameters:
      definite - true for "the", and false for "a/an" in case the entity has no name.
      Returns:
      The description name.
    • getTitle

      public String getTitle()
      Get the nicely formatted entity title/name.
      Overrides:
      getTitle in class Entity
      Returns:
      The title, or null if unknown.
    • logic

      public abstract void logic()
      Perform cycle logic.
    • canHit

      public boolean canHit(RPEntity defender)
      Chooses randomly if this has hit the defender, or if this missed him. Note that, even if this method returns true, the damage done might be 0 (if the defender blocks the attack).
      Parameters:
      defender - The attacked RPEntity.
      Returns:
      true if the attacker has hit the defender (the defender may still block this); false if the attacker has missed the defender.
    • getAttackRate

      public int getAttackRate()
      Returns the attack rate, the lower the better.
      Returns:
      the attack rate
    • attack

      public boolean attack()
      Lets the attacker attack its target.
      Returns:
      true iff the attacker has done damage to the defender.
    • applyDefXP

      protected void applyDefXP(RPEntity entity)
    • handleLifesteal

      public void handleLifesteal(RPEntity attacker, List<Item> attackerWeapons, int damage)
      Calculate lifesteal and update hp of source.
      Parameters:
      attacker - the RPEntity doing the hit
      attackerWeapons - the weapons of the RPEntity doing the hit
      damage - the damage done by this hit.
    • getCorpseDeserver

      public String getCorpseDeserver()
      Gets the name of the player who deserves the corpse.
      Returns:
      name of player who deserves the corpse or null.
    • getLanguage

      public String getLanguage()
      gets the language
      Returns:
      language
    • setDeathSound

      public void setDeathSound(String sound)
      Sets the sound played at entity death
      Parameters:
      sound - Name of sound
    • getDeathSound

      public String getDeathSound()
      Returns:
      Name of sound played at entity death
    • addStatusAttacker

      public void addStatusAttacker(StatusAttacker statusAttacker)
      Add a status attack type to the entity
      Parameters:
      statusAttacker - Status attacker
    • getStatusList

      public StatusList getStatusList()
      gets the status list
      Returns:
      StatusList
    • hasStatus

      public boolean hasStatus(StatusType statusType)
      Find if the entity has a specified status
      Parameters:
      statusType - the status type to check for
      Returns:
      true, if the entity has status; false otherwise
    • onRemoved

      public void onRemoved(StendhalRPZone zone)
      Description copied from class: ActiveEntity
      Called when this object is removed from a zone.
      Overrides:
      onRemoved in class ActiveEntity
      Parameters:
      zone - The zone this was removed from.
    • setShadowStyle

      public void setShadowStyle(String st)
      Sets the attribute to define the shadow that the client should use.
      Parameters:
      st - String name of the shadow to use.