Class Creature
java.lang.Object
- All Implemented Interfaces:
Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
ArenaCreature
,AttackableCreature
,DeathMatchCreature
,DomesticAnimal
,ItemChangeGuardCreature
,ItemGuardCreature
,RaidCreature
Server-side representation of a creature.
A creature is defined as an entity which can move with certain speed, has life points (HP) and can die.
Not all creatures have to be hostile, but at the moment the default behavior is to attack the player.
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Modifier and TypeFieldDescriptionThis list of item instances this creature may drop for use in quests.This list of item names this creature may drop Note; per default this list is shared with all creatures of that class.protected LinkedHashMap<String,LinkedList<String>>
List of things this creature should say.Fields inherited from class games.stendhal.server.entity.npc.NPC
pauseDirection, pauseTurns, pauseTurnsRemaining, SOUND_RADIUS
Fields inherited from class games.stendhal.server.entity.RPEntity
atk, ATTR_TITLE, damageReceived, def, level, lv_cap, ratk, statusAttackers, statusList, totalDamageReceived
Fields inherited from class games.stendhal.server.entity.GuidedEntity
baseSpeed, pathnotifier
Fields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
ConstructorDescriptionCreature()
creates a new creature without properties.creates a new CreatureCreature(String clazz, String subclass, String name, int hp, int atk, int ratk, int def, int level, int xp, int width, int height, double baseSpeed, List<DropItem> dropItems, Map<String,String> aiProfiles, LinkedHashMap<String,LinkedList<String>> noises, int respawnTime, String description)
Creates a new creature with the given properties.creates a new Creature -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDropItem(Item item)
adds a specific item to the List of Items that will be dropped on dead with 100 % probability.void
addDropItem(String name, double probability, int amount)
adds a named item to the List of Items that will be dropped on dead if clearDropItemList hasn't been called first, this will change all creatures of this kind.void
addDropItem(String name, double probability, int min, int max)
adds a named item to the List of Items that will be dropped on dead if clearDropItemList hasn't been called first, this will change all creatures of this kind.boolean
attack()
Lets the attacker attack its target.void
clears the list of predefined dropItems and creates an empty list specific to this creature.protected void
dropItemsOn(Corpse corpse)
void
static void
getAIProfile(String key)
returns the value of an ai profile.gets the aiProfile of this creatureGet the fighting strategy used by the creature.int
gets the name of the player who deserves the corpseint
Get the corpse image name to be used for the entity.int
protected Nature
Get the type of the damage this entity inflictsReturns a list of enemies.float
Retrieves total ATK value of held weapons.float
Retrieves total range attack value of held weapon & ammunition.int
Get the maximum distance attack range.getNearestEnemy(double range)
Returns the nearest enemy, which is reachable or otherwise attackable.creates a new instance, using this creature as templateprotected Nature
Get the nature of the damage the entity inflicts in ranged attacks.gets the respan point of this createint
Get the respawn time of the creature.protected double
getSusceptibility(Nature type)
Get a multiplier for a given damage type when this entity is damaged.boolean
void
init()
is called after the Creature is added to the zone.boolean
Checks if the creature has "abnormal" or "rare" profile.boolean
Returns true if this RPEntity is attackable.boolean
isAttackTurn(int turn)
boolean
isBoss()
Check if the entity is a "boss".boolean
isEnemyNear(double range)
boolean
boolean
isRare()
Check if the creature has a rare profile, and thus should not appear in DeathMatch, or the daily quest.boolean
void
logic()
Perform cycle logic.void
Random sound noises.void
makeNoiseChance(int prob, String state)
wrapper around makeNoise to simplify a codevoid
Will notify observers when event will occurred (death).void
This method is called when this entity has been killed (hp == 0).void
registerObjectsForNotification(Observer observer)
sets new observervoid
registerObjectsForNotification(List<Observer> observers)
sets new observervoid
setAIProfiles(Map<String,String> aiProfiles)
sets the aiProfile of this creaturevoid
setAttackStrategy(Map<String,String> aiProfiles)
Set the fighting strategy used by the creature.void
setBusy()
void
void
setDamageTypes(Nature type, Nature rangedType)
Set the damage natures the creature inflicts.void
setDeathSound(String sound)
Sets the sound played at creature's deathvoid
void
setIdle()
void
setMovementSound(String sound)
Set looped sound to be played while creature is walkingvoid
setNoises(LinkedHashMap<String,LinkedList<String>> creatureNoises)
Override noises for changes.void
setRespawned(boolean isRespawned)
void
setRespawnPoint(CreatureRespawnPoint point)
void
setSusceptibilities(Map<Nature,Double> susceptibilities)
Set the susceptibility mapping of a creature.void
Stops the looped soundvoid
unregisterObjectsForNotification(Observer observer)
unset observervoid
unregisterObjectsForNotification(List<Observer> observers)
unset observerMethods inherited from class games.stendhal.server.entity.npc.NPC
checkPause, getIdea, getMovementRange, getPerceptionRange, getSounds, maybeMakeSound, maybeMakeSound, moveRandomly, onFinishedPath, say, setIdea, setMovement, setMovementRange, setPathCompletedPause, setPathCompletedPause, setPerceptionRange, setRandomPathFrom, setSounds, setSounds
Methods inherited from class games.stendhal.server.entity.DressedEntity
getOriginalOutfit, getOutfit, getOutfitColors, isNaked, put, restoreOriginalOutfit, setOutfit, setOutfit, setOutfit, setOutfit, setOutfit, setOutfit, setOutfitColor, setOutfitColor, setOutfitColor, setOutfitColors, setOutfitWithDetail, unsetOutfitColor
Methods inherited from class games.stendhal.server.entity.RPEntity
addAtkXP, addBaseMana, addDefXP, addKarma, addMana, addRatkXP, addStatusAttacker, addXP, applyDefXP, applyDistanceAttackModifiers, canDoRangeAttack, canHit, damage, damageDone, delayedDamage, describe, drop, drop, drop, dropDroppableItem, dropWithInfostring, dropWithInfostring, entityAsOnlinePlayer, entityAsPet, equip, equipOrPutOnGround, equipToInventoryOnly, getAllEquipped, getAllEquippedWithInfostring, getAmmunition, getArmor, getAtk, getAtkXP, getAttackingRPEntities, getAttackRate, getAttackSources, getAttackTarget, getBaseHP, getBaseMana, getBloodClass, getBoots, getCappedAtk, getCappedDef, getCappedRatk, getCloak, getDeathSound, getDef, getDefenseItems, getDefXP, getDescriptionName, getDroppables, getEquippedItemClass, getFirstEquipped, getHelmet, getHP, getItemDef, getKarma, getLanguage, getLegs, getLevel, getLVCap, getMana, getMissileIfNotHoldingOtherWeapon, getName, getNumberOfEquipped, getRangeWeapon, getRatk, getRatkXP, getRing, getsFightXpFrom, getShield, getSlotToEquip, getStatusList, getTitle, getTotalNumberOf, getWeapon, getWeapons, getXP, handleLifesteal, handlePortal, hasArmor, hasBoots, hasCloak, hasHelmet, hasLegs, hasLineOfSight, hasRing, hasShield, hasStatus, heal, heal, heal, incAtkXP, incDefXP, incRatkXP, initHP, isAttacked, isAttacking, isEquipped, isEquipped, isEquippedItemClass, isEquippedItemInSlot, isEquippedWithInfostring, isEquippedWithInfostring, isInvisibleToCreatures, makeCorpse, maybeDropDroppables, onAdded, onDamaged, onDead, onRemoved, rememberAttacker, rewardKillerAnimals, rewardKillers, sendPrivateText, sendPrivateText, setAtk, setAtkInternal, setAtkXP, setBaseHP, setBaseMana, setBlood, setDef, setDefInternal, setDefXP, setHP, setLevel, setLVCap, setMana, setName, setRatk, setRatkInternal, setRatkXP, setRatkXPInternal, setShadowStyle, setTarget, setTitle, setXP, stopAttack, stopAttacking, subXP, update, updateItemAtkDef, updateLevel, useKarma, useKarma, useKarma
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, 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, 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
-
dropsItems
This list of item names this creature may drop Note; per default this list is shared with all creatures of that class. -
dropItemInstances
This list of item instances this creature may drop for use in quests. This is always creature specific. -
noises
List of things this creature should say.
-
-
Constructor Details
-
Creature
creates a new Creature- Parameters:
object
- serialized creature
-
Creature
creates a new Creature- Parameters:
copy
- template to copy
-
Creature
public Creature()creates a new creature without properties. These must be set in the deriving class -
Creature
public Creature(String clazz, String subclass, String name, int hp, int atk, int ratk, int def, int level, int xp, int width, int height, double baseSpeed, List<DropItem> dropItems, Map<String,String> aiProfiles, LinkedHashMap<String,LinkedList<String>> noises, int respawnTime, String description)Creates a new creature with the given properties.Creatures created with this function will share their dropItems with any other creature of that kind. If you want individual dropItems, use clearDropItemList first!
- Parameters:
clazz
- The creature's class, e.g. "golem".subclass
- The creature's subclass, e.g. "wooden_golem".name
- Typically the same as clazz, except for NPCs.hp
- The creature's maximum health points.atk
- The creature's attack strength.ratk
- The creature's ranged attack strength.def
- The creature's attack strength.level
- The creature's level.xp
- The creature's experience.width
- The creature's width, in squares.height
- The creature's height, in squares.baseSpeed
- The normal speed at which the creature moves.dropItems
- List of items that the creature drops on death.aiProfiles
- Creature's behaviours.noises
- . Sound effects used by the client when player is near creature.respawnTime
- How often creature respawns, in turns.description
- String description displayed when player examines creature.
-
-
Method Details
-
getNewInstance
creates a new instance, using this creature as template- Returns:
- a new creature
-
setDeathSound
Sets the sound played at creature's death- Overrides:
setDeathSound
in classRPEntity
- Parameters:
sound
- Name of sound
-
setMovementSound
Set looped sound to be played while creature is walking- Parameters:
sound
- sound effect file name
-
setNoises
Override noises for changes.- Parameters:
creatureNoises
- noises to be used instead of the defaults for the creature
-
registerObjectsForNotification
sets new observer- Parameters:
observer
- - observer, which will get info about creature death.
-
registerObjectsForNotification
sets new observer- Parameters:
observers
- - observers, which will get info about creature death.
-
unregisterObjectsForNotification
unset observer- Parameters:
observer
- - observer to remove.
-
unregisterObjectsForNotification
unset observer- Parameters:
observers
- - observers to remove.
-
notifyRegisteredObjects
public void notifyRegisteredObjects()Will notify observers when event will occurred (death). -
isSpawned
public boolean isSpawned() -
setRespawned
public void setRespawned(boolean isRespawned) -
getAttackTurn
public int getAttackTurn() -
isAttackTurn
public boolean isAttackTurn(int turn) -
generateRPClass
public static void generateRPClass() -
setAIProfiles
sets the aiProfile of this creature- Parameters:
aiProfiles
- aiProfile
-
getAIProfiles
gets the aiProfile of this creature- Returns:
- aiProfile
-
setRespawnPoint
-
getRespawnPoint
gets the respan point of this create- Returns:
- CreatureRespawnPoint
-
getRespawnTime
public int getRespawnTime()Get the respawn time of the creature.- Returns:
- respawn time in turns
-
setCorpse
-
getCorpseName
Description copied from class:RPEntity
Get the corpse image name to be used for the entity. Defaults to a player corpse.- Overrides:
getCorpseName
in classRPEntity
- Returns:
- Identification string for corpse. This is the corpse image shown by the client without the path or file extension.
-
getHarmlessCorpseName
- Overrides:
getHarmlessCorpseName
in classRPEntity
-
getCorpseWidth
public int getCorpseWidth()- Overrides:
getCorpseWidth
in classRPEntity
-
getCorpseHeight
public int getCorpseHeight()- Overrides:
getCorpseHeight
in classRPEntity
-
clearDropItemList
public void clearDropItemList()clears the list of predefined dropItems and creates an empty list specific to this creature. -
addDropItem
adds a named item to the List of Items that will be dropped on dead if clearDropItemList hasn't been called first, this will change all creatures of this kind.- Parameters:
name
-probability
-min
-max
-
-
addDropItem
adds a named item to the List of Items that will be dropped on dead if clearDropItemList hasn't been called first, this will change all creatures of this kind.- Parameters:
name
-probability
-amount
-
-
addDropItem
adds a specific item to the List of Items that will be dropped on dead with 100 % probability. this is always for that specific creature only.- Parameters:
item
-
-
isAttackable
public boolean isAttackable()Returns true if this RPEntity is attackable.- Overrides:
isAttackable
in classNPC
- Returns:
- true if this RPEntity is attackable.
-
onDead
Description copied from class:RPEntity
This method is called when this entity has been killed (hp == 0). -
dropItemsOn
- Overrides:
dropItemsOn
in classNPC
-
getEnemyList
Returns a list of enemies. One of it will be attacked.- Returns:
- list of enemies
-
getNearestEnemy
Returns the nearest enemy, which is reachable or otherwise attackable.- Parameters:
range
- attack radius- Returns:
- chosen enemy or null if no enemy was found.
-
isEnemyNear
public boolean isEnemyNear(double range) -
isBoss
public boolean isBoss()Check if the entity is a "boss". Bosses have higher capacity corpses. -
isRare
public boolean isRare()Check if the creature has a rare profile, and thus should not appear in DeathMatch, or the daily quest.- Returns:
- true if the creature is rare, false otherwise
-
isAbnormal
public boolean isAbnormal()Checks if the creature has "abnormal" or "rare" profile.- Returns:
true
if creature is abnormal or rare.
-
equip
-
getMaxRangeForArcher
public int getMaxRangeForArcher()Description copied from class:RPEntity
Get the maximum distance attack range.- Overrides:
getMaxRangeForArcher
in classRPEntity
- Returns:
- maximum range, or 0 if the entity can't attack from distance
-
getAIProfile
returns the value of an ai profile.- Parameters:
key
- as defined in creatures.xml- Returns:
- value or null if undefined
-
init
public void init()is called after the Creature is added to the zone. -
logic
public void logic()Description copied from class:RPEntity
Perform cycle logic. -
makeNoise
Random sound noises.- Parameters:
state
- - state for noises
-
makeNoiseChance
wrapper around makeNoise to simplify a code- Parameters:
prob
- - 1/chance of make noisestate
- - state for noises
-
stopMovementSound
public void stopMovementSound()Stops the looped sound -
isPlayingMovementSound
public boolean isPlayingMovementSound()- Returns:
- true if looped sound is currently playing
-
hasTargetMoved
public boolean hasTargetMoved() -
setIdle
public void setIdle() -
setBusy
public void setBusy() -
setAttackStrategy
Set the fighting strategy used by the creature.- Parameters:
aiProfiles
- AI profiles to be used when deciding the strategy
-
getAttackStrategy
Get the fighting strategy used by the creature.- Returns:
- strategy
-
setHealer
-
getItemAtk
public float getItemAtk()Description copied from class:RPEntity
Retrieves total ATK value of held weapons.- Overrides:
getItemAtk
in classRPEntity
-
getItemRatk
public float getItemRatk()Description copied from class:RPEntity
Retrieves total range attack value of held weapon & ammunition.- Overrides:
getItemRatk
in classRPEntity
-
setSusceptibilities
Set the susceptibility mapping of a creature. The mapping is not copied.- Parameters:
susceptibilities
- The susceptibilities of the creature
-
getSusceptibility
Description copied from class:RPEntity
Get a multiplier for a given damage type when this entity is damaged.- Overrides:
getSusceptibility
in classRPEntity
- Parameters:
type
- Type of the damage- Returns:
- damage multiplier
-
getDamageType
Description copied from class:RPEntity
Get the type of the damage this entity inflicts- Overrides:
getDamageType
in classRPEntity
- Returns:
- type of damage
-
getRangedDamageType
Description copied from class:RPEntity
Get the nature of the damage the entity inflicts in ranged attacks.- Overrides:
getRangedDamageType
in classRPEntity
- Returns:
- type of damage
-
setDamageTypes
Set the damage natures the creature inflicts.- Parameters:
type
- Damage nature.rangedType
- Damage nature for ranged attacks, ornull
if the creature uses the same type as for the melee.
-
attack
public boolean attack()Description copied from class:RPEntity
Lets the attacker attack its target. -
getCorpseDeserver
gets the name of the player who deserves the corpse- Overrides:
getCorpseDeserver
in classRPEntity
- Returns:
- name of player who deserves the corpse or
null
.
-