Package games.stendhal.server.entity
Class RPEntity
- All Implemented Interfaces:
Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
DressedEntity
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected static String
The title attribute name.protected CounterMap<Entity>
Maps each attacker to the sum of hitpoint loss it has caused to this RPEntity.protected int
protected int
protected int
protected int
protected com.google.common.collect.ImmutableList<StatusAttacker>
Entity uses a status attackprotected StatusList
a list of current statusesprotected int
Fields inherited from class games.stendhal.server.entity.GuidedEntity
baseSpeed, pathnotifier
Fields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAtkXP(int xp)
Adjust entity's ATK XP by specified amount.void
addBaseMana(int newBaseMana)
adds to base mana (like addXP).void
addDefXP(int xp)
Adjust entity's DEF XP by specified amount.void
addKarma(double karma)
Give the player some karma (good or bad).int
addMana(int mana, boolean tell)
Give mana to the entity.void
addRatkXP(int xp)
Adjust entity's RATK XP by specified amount.void
addStatusAttacker(StatusAttacker statusAttacker)
Add a status attack type to the entityvoid
addXP(int newxp)
protected void
applyDefXP(RPEntity entity)
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.).boolean
attack()
Lets the attacker attack its target.boolean
canDoRangeAttack(RPEntity target, int maxrange)
Can this entity do a distance attack on the given target?boolean
Chooses randomly if this has hit the defender, or if this missed him.int
Apply damage to this entity, and call onDead() if HP reaches 0.int
damageDone(RPEntity defender, double attackingWeaponsValue, Nature damageType)
Is called when this has hit the given defender.void
delayedDamage(int amount, String attackerName)
Apply damage to this entity, delaying the damage to happen in a turn notifier.describe()
Describes the entity (if a players looks at it).boolean
Removes the given item from the RPEntity.boolean
Removes one unit of an item from the RPEntity.boolean
Removes a specific amount of an item from the RPEntity.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.protected abstract void
dropItemsOn(Corpse corpse)
boolean
dropWithInfostring(String name, String infostring)
Removes a single item with matching info string from the RPEntity.boolean
dropWithInfostring(String name, String infostring, int amount)
Removes a specific amount of an item with matching info string from the RPEntity.protected Player
entityAsOnlinePlayer(Entity entity)
For rewarding killers.protected Pet
entityAsPet(Entity entity)
boolean
Tries to equip one unit of an item in the given slot.boolean
equipOrPutOnGround(Item item)
Tries to equip an item in the appropriate slot.boolean
equipToInventoryOnly(Item item)
Tries to equip an item in the appropriate slot.static void
getAllEquipped(String name)
Gets an item that is carried by the RPEntity.getAllEquippedWithInfostring(String name, String infostring)
Retrieves all of an item with matching info string.Gets the stack of ammunition (arrows or similar) that this entity is holding in its hands.getArmor()
int
getAtk()
int
getAtkXP()
Returns the RPEntities that are attacking this character.int
Returns the attack rate, the lower the better.Returns the Entities that are attacking this character.Return the RPEntity that this entity is attacking.int
Get the base HP.int
Gets the base mana (like base_hp).gets the name of the blood classgetBoots()
int
gets the capped atk level, which prevent players from training their atk way beyond what is reasonable for their levelint
gets the capped def level, which prevent players from training their def way beyond what is reasonable for their levelint
gets the capped ranged attack level which prevents players from training ratk way beyond what is reasonable for their level.getCloak()
Gets the name of the player who deserves the corpse.int
Get the corpse image name to be used for the entity.int
protected Nature
Get the type of the damage this entity inflictsint
getDef()
get all items that affect a player's defensive value except the weaponint
getDefXP()
getDescriptionName(boolean definite)
Returns the name or something that can be used to identify the entity for the player.return list of all droppable items in entity's hands.getEquippedItemClass(String slot, String clazz)
Finds the first item of class clazz from the slot.getFirstEquipped(String name)
Gets an item that is carried by the RPEntity.int
getHP()
Get the current HP.float
Retrieves total ATK value of held weapons.float
float
Retrieves total range attack value of held weapon & ammunition.double
getKarma()
Get the current amount of karma.gets the languagegetLegs()
int
getLevel()
int
getLVCap()
Get the lv_cap.int
getMana()
Gets the mana (magic).int
Get the maximum distance attack range.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.getName()
Get the entity's name.int
getNumberOfEquipped(String name)
Gets the number of items of the given name that are carried by the RPEntity.protected Nature
Get the nature of the damage the entity inflicts in ranged attacks.Gets the range weapon (bow etc.) that this entity is holding in its hands.int
getRatk()
Gets the entity's current ranged attack level.int
Get's the entity's current ranged attack experience.getRing()
boolean
getsFightXpFrom(RPEntity enemy)
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.gets the status listprotected double
getSusceptibility(Nature type)
Get a multiplier for a given damage type when this entity is damaged.getTitle()
Get the nicely formatted entity title/name.int
getTotalNumberOf(String name)
Gets the number of items of the given name including bank.Gets the weapon that this entity is holding in its hands.int
getXP()
void
handleLifesteal(RPEntity attacker, List<Item> attackerWeapons, int damage)
Calculate lifesteal and update hp of source.protected boolean
handlePortal(Portal portal)
boolean
hasArmor()
boolean
hasBoots()
boolean
hasCloak()
boolean
boolean
hasLegs()
boolean
hasLineOfSight(Entity target)
Check if the entity has a line of sight to the the center of another entity.boolean
hasRing()
boolean
boolean
hasStatus(StatusType statusType)
Find if the entity has a specified statusint
heal()
Heal this entity completely.int
heal(int amount)
Heal this entity.int
heal(int amount, boolean tell)
Heal this entity.void
incAtkXP()
Increase attack XP by 1.void
incDefXP()
Increase defense XP by 1.void
Increase ranged XP by 1.void
initHP(int hp)
Set the base and current HP.boolean
boolean
Return true if this entity is attacked.boolean
Checks whether the attacktarget is null.boolean
isEquipped(String name)
Determine if this entity is equipped with an item.boolean
isEquipped(String name, int amount)
Determine if this entity is equipped with a minimum quantity of an item.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.boolean
isEquippedItemInSlot(String slot, String item)
checks if an item is equipped in a slotboolean
isEquippedWithInfostring(String name, String infostring)
Checks if entity carry a number of items with specified info string.boolean
isEquippedWithInfostring(String name, String infostring, int amount)
Checks if entity carry a number of items with specified info string.boolean
Determine if the entity is invisible to creatures.abstract void
logic()
Perform cycle logic.protected Corpse
makeCorpse(String killer)
Make a corpse belonging to this entitymaybeDropDroppables(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.void
onAdded(StendhalRPZone zone)
Called when this object is added to a zone.void
This method is called when this entity has been attacked by Entity attacker and it has been damaged with damage points.void
This method is called when the entity has been killed ( hp==0 ).void
This method is called when this entity has been killed (hp == 0).void
onRemoved(StendhalRPZone zone)
Called when this object is removed from a zone.void
rememberAttacker(Entity attacker)
protected void
rewardKillerAnimals(int oldXP)
protected void
rewardKillers(int oldXP)
Gives XP to every player who has helped killing this RPEntity.void
sendPrivateText(NotificationType type, String text)
Sends a message that only this player can read.void
sendPrivateText(String text)
Sends a message that only this RPEntity can read.void
setAtk(int atk)
protected void
setAtkInternal(int atk, boolean notify)
void
setAtkXP(int atk)
Set attack XP.void
setBaseHP(int newhp)
Set the base HP.void
setBaseMana(int newBaseMana)
Sets the base mana (like base_hp).void
sets the blood classvoid
setDeathSound(String sound)
Sets the sound played at entity deathvoid
setDef(int def)
protected void
setDefInternal(int def, boolean notify)
void
setDefXP(int defXp)
Set defense XP.void
setHP(int hp)
Set the HP.void
setLevel(int level)
void
setLVCap(int newLVCap)
void
setMana(int newMana)
Sets the available mana.void
Set the entity's name.void
setRatk(int ratk)
Set the value of the entity's ranged attack level.protected void
setRatkInternal(int ratk, boolean notify)
Set the entity's ranged attack level.void
setRatkXP(int ratkXP)
Sets the entity's ranged attack experience.protected void
setRatkXPInternal(int ratkXP, boolean notify)
Sets the entity's ranged attack experience.void
setShadowStyle(String st)
Sets the attribute to define the shadow that the client should use.void
Modify the entity to order to attack the target entity.void
Set the entity's formatted title.void
setXP(int newxp)
void
Modify the entity to stop attacking.void
stopAttacking(Entity attacker)
void
subXP(int newxp)
void
update()
void
Recalculates item based atk and def.protected void
Change the level to match the XP, if needed.double
useKarma(double scale)
Get some of the player's karma.double
useKarma(double negLimit, double posLimit)
Get some of the player's karma.double
useKarma(double negLimit, double posLimit, double granularity)
Use some of the player's karma.Methods inherited from class games.stendhal.server.entity.GuidedEntity
addSuspend, addSuspend, applyMovement, atMovementRadius, clearPath, followPath, getBaseSpeed, getCollisionAction, getDirectionFromOrigin, getDistanceFromOrigin, getGuide, getPath, getPathPosition, handleObjectCollision, hasPath, isPathLoop, onFinishedPath, onMoved, onNodeReached, onOutsideMovementRadius, removeSuspend, reroute, retracePath, setBaseSpeed, setCollisionAction, setPath, setPath, setPathAndPosition, setPathPosition, setRandomMovementRadius, setRandomMovementRadius, setRetracePath, setUsesRandomPath, stop, updateModifiedAttributes, usesRandomPath
Methods inherited from class games.stendhal.server.entity.ActiveEntity
canMoveTo, canMoveTo, faceto, faceToward, getDirection, getDirectionToward, getDirectionToward, getResistance, getSpeed, getStepsTaken, handleLeaveZone, handleSimpleCollision, ignoresCollision, isFacingToward, isGhost, isMoveCompleted, isZoneChangeAllowed, move, setDirection, setIgnoresCollision, setSpeed, stopped
Methods inherited from class games.stendhal.server.entity.Entity
getAdjacentNodes, getArea, getArea, getCursor, getDescription, getEntitySlot, getHeight, getOrigin, getResistance, getWidth, getX, getY, getZone, hasDescription, isInSight, isObstacle, nextTo, nextTo, notifyWorldAboutChanges, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance
Methods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, toString, unhide, unstore, writeObject, writeObject, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
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
Entity uses a status attack -
statusList
a list of current statuses -
damageReceived
Maps each attacker to the sum of hitpoint loss it has caused to this RPEntity. -
totalDamageReceived
protected int totalDamageReceived
-
-
Constructor Details
-
RPEntity
-
RPEntity
public RPEntity()
-
-
Method Details
-
handlePortal
- Overrides:
handlePortal
in classActiveEntity
-
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 classActiveEntity
-
damageDone
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/spellsdamageType
- 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 distancemaxrange
- maximum attack range- Returns:
- The damage that will be done with the distance attack.
-
setName
Set the entity's name.- Parameters:
name
- The new name.
-
getName
Get the entity's name. -
onAdded
Description copied from class:ActiveEntity
Called when this object is added to a zone.- Overrides:
onAdded
in classActiveEntity
- 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 levelnotify
- 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 experiencenotify
- 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
Get a multiplier for a given damage type when this entity is damaged.- Parameters:
type
- Type of the damage- Returns:
- damage multiplier
-
getDamageType
Get the type of the damage this entity inflicts- Returns:
- type of damage
-
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
Modify the entity to order to attack the target entity.- Parameters:
target
-
-
stopAttack
public void stopAttack()Modify the entity to stop attacking. -
getsFightXpFrom
-
stopAttacking
-
rememberAttacker
-
setBlood
sets the blood class- Parameters:
name
- name of blood class
-
getBloodClass
gets the name of the blood class- Returns:
- bloodClass or
null
-
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
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
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
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
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
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
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
-
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
This method is called when the entity has been killed ( hp==0 ).- Parameters:
killer
- The entity who caused the death
-
onDead
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
Make a corpse belonging to this entity- Parameters:
killer
- Name of the killer- Returns:
- The corpse of a dead RPEntity
-
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
-
getCorpseWidth
public int getCorpseWidth() -
getCorpseHeight
public int getCorpseHeight() -
dropItemsOn
-
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
Returns the Entities that are attacking this character.- Returns:
- list of all attacking entities
-
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
Return the RPEntity that this entity is attacking.- Returns:
- the attack target of this
-
equipToInventoryOnly
Tries to equip an item in the appropriate slot.- Parameters:
item
- the item- Returns:
- true if the item can be equipped, else false
-
getSlotToEquip
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
Tries to equip an item in the appropriate slot.- Parameters:
item
- the item- Returns:
- true if the item can be equipped, else false
-
equip
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 slotitem
- the item- Returns:
- true if the item can be equipped, else false
-
drop
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 itemamount
- The number of units that should be dropped- Returns:
- true iff dropping the desired amount was successful.
-
drop
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
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
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
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
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
Determine if this entity is equipped with an item.- Parameters:
name
- The item name.- Returns:
true
if the item is equipped.
-
isEquippedWithInfostring
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
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
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
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
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
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
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
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
checks if an item is equipped in a slot- Parameters:
slot
-item
-- Returns:
- true if so false otherwise
-
getEquippedItemClass
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
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
-
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
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
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
-
hasArmor
public boolean hasArmor() -
getArmor
-
hasHelmet
public boolean hasHelmet() -
getHelmet
-
hasLegs
public boolean hasLegs() -
getLegs
-
hasBoots
public boolean hasBoots() -
getBoots
-
hasCloak
public boolean hasCloak() -
getCloak
-
hasRing
public boolean hasRing() -
getRing
-
describe
Description copied from class:Entity
Describes the entity (if a players looks at it). -
sendPrivateText
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
Sends a message that only this player can read.- Parameters:
type
- NotificationTypetext
- 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
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
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
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
Set the entity's formatted title.- Parameters:
title
- The title, ornull
.
-
getDescriptionName
Returns the name or something that can be used to identify the entity for the player.- Overrides:
getDescriptionName
in classEntity
- Parameters:
definite
-true
for "the", andfalse
for "a/an" in case the entity has no name.- Returns:
- The description name.
-
getTitle
Get the nicely formatted entity title/name. -
logic
public abstract void logic()Perform cycle logic. -
canHit
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
-
handleLifesteal
Calculate lifesteal and update hp of source.- Parameters:
attacker
- the RPEntity doing the hitattackerWeapons
- the weapons of the RPEntity doing the hitdamage
- the damage done by this hit.
-
getCorpseDeserver
Gets the name of the player who deserves the corpse.- Returns:
- name of player who deserves the corpse or
null
.
-
getLanguage
gets the language- Returns:
- language
-
setDeathSound
Sets the sound played at entity death- Parameters:
sound
- Name of sound
-
getDeathSound
- Returns:
- Name of sound played at entity death
-
addStatusAttacker
Add a status attack type to the entity- Parameters:
statusAttacker
- Status attacker
-
getStatusList
gets the status list- Returns:
- StatusList
-
hasStatus
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
Description copied from class:ActiveEntity
Called when this object is removed from a zone.- Overrides:
onRemoved
in classActiveEntity
- Parameters:
zone
- The zone this was removed from.
-
setShadowStyle
Sets the attribute to define the shadow that the client should use.- Parameters:
st
- String name of the shadow to use.
-