Class Creature
java.lang.Object
- All Implemented Interfaces:
Killer,Cloneable,Iterable<String>,Serializable
- Direct Known Subclasses:
ArenaCreature,AttackableCreature,DeathMatchCreature,DomesticAnimal,ItemChangeGuardCreature,ItemGuardCreature,Myling,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
FieldsModifier 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_RADIUSFields inherited from class games.stendhal.server.entity.RPEntity
atk, ATTR_TITLE, damageReceived, def, HIT_CHANCE_MULTIPLIER, level, lv_cap, ratk, statusAttackers, statusList, totalDamageReceivedFields inherited from class games.stendhal.server.entity.CombatEntity
enemiesThatGiveFightXP, RPCLASS_NAMEFields inherited from class games.stendhal.server.entity.GuidedEntity
baseSpeed, pathnotifierFields inherited from class marauroa.common.game.RPObject
INVALID_ID -
Constructor Summary
ConstructorsConstructorDescriptionCreature()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 TypeMethodDescriptionvoidaddDropItem(Item item) adds a specific item to the List of Items that will be dropped on dead with 100 % probability.voidaddDropItem(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.voidaddDropItem(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.booleanattack()Lets the attacker attack its target.voidclears the list of predefined dropItems and creates an empty list specific to this creature.protected voiddropItemsOn(Corpse corpse) voidstatic voidgetAIProfile(String key) returns the value of an ai profile.gets the aiProfile of this creatureGet the fighting strategy used by the creature.intgets the name of the player who deserves the corpseintGet the corpse image name to be used for the entity.intprotected NatureGet the type of the damage this entity inflictsReturns a list of enemies.floatRetrieves total ATK value of held weapons.floatRetrieves total range attack value of held weapon & ammunition.intGet 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 NatureGet the nature of the damage the entity inflicts in ranged attacks.gets the respan point of this createintGet the respawn time of the creature.protected doublegetSusceptibility(Nature type) Get a multiplier for a given damage type when this entity is damaged.booleanvoidinit()is called after the Creature is added to the zone.booleanChecks if the creature has "abnormal" or "rare" profile.booleanReturns true if this RPEntity is attackable.booleanisAttackTurn(int turn) booleanisBoss()Check if the entity is a "boss".booleanisEnemyNear(double range) booleanbooleanisRare()Check if the creature has a rare profile, and thus should not appear in DeathMatch, or the daily quest.booleanvoidlogic()Perform cycle logic.voidRandom sound noises.voidmakeNoiseChance(int prob, String state) wrapper around makeNoise to simplify a codevoidWill notify observers when event will occurred (death).voidThis method is called when this entity has been killed (hp == 0).voidregisterObjectsForNotification(Observer observer) sets new observervoidregisterObjectsForNotification(List<Observer> observers) sets new observerfinal voidsetAIProfiles(Map<String, String> aiProfiles) sets the aiProfile of this creaturevoidsetAttackStrategy(Map<String, String> aiProfiles) Set the fighting strategy used by the creature.voidsetBusy()final voidfinal voidsetDamageTypes(Nature type, Nature rangedType) Set the damage natures the creature inflicts.final voidsetDeathSound(String sound) Sets the sound played at creature's deathvoidvoidsetIdle()final voidsetMovementSound(String sound) Set looped sound to be played while creature is walkingvoidsetNoises(LinkedHashMap<String, LinkedList<String>> creatureNoises) Override noises for changes.voidsetRespawned(boolean isRespawned) voidvoidsetSusceptibilities(Map<Nature, Double> susceptibilities) Set the susceptibility mapping of a creature.voidStops the looped soundvoidunregisterObjectsForNotification(Observer observer) unset observervoidunregisterObjectsForNotification(List<Observer> observers) unset observerMethods inherited from class games.stendhal.server.entity.npc.NPC
checkPause, getIdea, getMovementRange, getPerceptionRange, getSounds, maybeMakeSound, maybeMakeSound, moveRandomly, onFinishedPath, say, say, setIdea, setMovement, setMovementRange, setPathCompletedPause, setPathCompletedPause, setPerceptionRange, setRandomPathFrom, setSounds, setSoundsMethods inherited from class games.stendhal.server.entity.DressedEntity
clearColors, getColorableLayers, getOriginalOutfit, getOutfit, getOutfitColor, getOutfitColors, isNaked, put, restoreOriginalOutfit, setOutfit, setOutfit, setOutfit, setOutfit, setOutfit, setOutfit, setOutfitColor, setOutfitColor, setOutfitColor, setOutfitColors, setOutfitWithDetail, storeOriginalOutfit, unsetOutfitColorMethods inherited from class games.stendhal.server.entity.RPEntity
addAtkXP, addBaseMana, addDefXP, addKarma, addMana, addRatkXP, addStatusAttacker, addXP, applyDistanceAttackModifiers, calculateRiskForCanHit, canDoRangeAttack, canHit, damage, damageDone, damageDone, delayedDamage, describe, drop, drop, drop, dropDroppableItem, dropWithItemdata, dropWithItemdata, entityAsOnlinePlayer, entityAsPet, equip, equipOrPutOnGround, equipToInventoryOnly, getAllEquipped, getAllEquippedWithItemdata, getAllStatusAttackers, 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, 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, isEquippedWithItemdata, isEquippedWithItemdata, isInvisibleToCreatures, makeCorpse, maybeDropDroppables, onAdded, onDamaged, onDead, onRejectedAttackStart, onRemoved, rememberAttacker, rewardKillerAnimals, rewardKillers, sendPrivateText, sendPrivateText, 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, useKarmaMethods inherited from class games.stendhal.server.entity.CombatEntity
getsAtkXpFrom, getsDefXpFrom, recentlyDamagedByMethods 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, usesRandomPathMethods 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, stoppedMethods 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, squaredDistanceMethods 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, writeToJsonMethods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlotsMethods 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, toAttributeStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
setDeathSoundin 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:RPEntityGet the corpse image name to be used for the entity. Defaults to a player corpse.- Overrides:
getCorpseNamein classRPEntity- Returns:
- Identification string for corpse. This is the corpse image shown by the client without the path or file extension.
-
getHarmlessCorpseName
- Overrides:
getHarmlessCorpseNamein classRPEntity
-
getCorpseWidth
public int getCorpseWidth()- Overrides:
getCorpseWidthin classRPEntity
-
getCorpseHeight
public int getCorpseHeight()- Overrides:
getCorpseHeightin 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:
isAttackablein classNPC- Returns:
- true if this RPEntity is attackable.
-
onDead
Description copied from class:RPEntityThis method is called when this entity has been killed (hp == 0). -
dropItemsOn
- Overrides:
dropItemsOnin 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:
trueif creature is abnormal or rare.
-
equip
-
getMaxRangeForArcher
public int getMaxRangeForArcher()Description copied from class:RPEntityGet the maximum distance attack range.- Overrides:
getMaxRangeForArcherin 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:RPEntityPerform 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:RPEntityRetrieves total ATK value of held weapons.- Overrides:
getItemAtkin classRPEntity
-
getItemRatk
public float getItemRatk()Description copied from class:RPEntityRetrieves total range attack value of held weapon & ammunition.- Overrides:
getItemRatkin 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:RPEntityGet a multiplier for a given damage type when this entity is damaged.- Overrides:
getSusceptibilityin classRPEntity- Parameters:
type- Type of the damage- Returns:
- damage multiplier
-
getDamageType
Description copied from class:RPEntityGet the type of the damage this entity inflicts- Overrides:
getDamageTypein classRPEntity- Returns:
- type of damage
-
getRangedDamageType
Description copied from class:RPEntityGet the nature of the damage the entity inflicts in ranged attacks.- Overrides:
getRangedDamageTypein classRPEntity- Returns:
- type of damage
-
setDamageTypes
Set the damage natures the creature inflicts.- Parameters:
type- Damage nature.rangedType- Damage nature for ranged attacks, ornullif the creature uses the same type as for the melee.
-
attack
public boolean attack()Description copied from class:RPEntityLets the attacker attack its target. -
getCorpseDeserver
gets the name of the player who deserves the corpse- Overrides:
getCorpseDeserverin classRPEntity- Returns:
- name of player who deserves the corpse or
null.
-