Package games.stendhal.server.entity.npc
Class NPC
java.lang.Object
- All Implemented Interfaces:
Killer,Cloneable,Iterable<String>,Serializable
- Direct Known Subclasses:
ActorNPC,Creature,PassiveNPC,TrainingDummy
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Directionprotected intIdling between path cyclesintprotected static final intCreature sound radius.Fields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks if the NPC should remain stationary or begin walkingprotected voiddropItemsOn(Corpse corpse) static voidgetIdea()Get the NPC's idea/thought.intQuery the range in which the NPC will search for movement paths.intQuery the range in which the NPC will notice other subjects like players or enemies.Get the list of possible sound events.booleanReturns true if this RPEntity is attackable.voidlogic()Perform cycle logic.protected voidGenerate a sound event with the probability of SOUND_PROBABILITY, if the previous sound event happened long enough ago.protected voidmaybeMakeSound(int probablility) Generate a sound event with the specified probability, if the previous sound event happened long enough ago.voidGive NPC a random pathvoidvoidvoidvoidSet the NPC's idea/thought.voidsetMovement(Entity destEntity, double min, double max, double maxPathRadius) moves to the given entity.voidsetMovementRange(int movementRange) Set the movement range.voidsetPathCompletedPause(int pause) Pause the entity when path is completed.voidsetPathCompletedPause(int pause, Direction dir) voidsetPerceptionRange(int perceptionRange) Set the perception range.voidsetRandomPathFrom(int x, int y, int distance) Set a random destination as a path.voidSet the possible sound events.voidSet the possible sound events.Methods 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, attack, 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, getCorpseDeserver, getCorpseHeight, getCorpseName, getCorpseWidth, getDamageType, getDeathSound, getDef, getDefenseItems, getDefXP, getDescriptionName, getDroppables, getEquippedItemClass, getFirstEquipped, getHarmlessCorpseName, getHelmet, getHP, getItemAtk, getItemDef, getItemRatk, getKarma, getLanguage, getLegs, getLevel, getLVCap, getMana, getMaxRangeForArcher, getMissileIfNotHoldingOtherWeapon, getName, getNumberOfEquipped, getRangedDamageType, getRangeWeapon, getRatk, getRatkXP, getRing, getShield, getSlotToEquip, getStatusList, getSusceptibility, 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, onDead, onRejectedAttackStart, onRemoved, rememberAttacker, rewardKillerAnimals, rewardKillers, sendPrivateText, sendPrivateText, sendPrivateText, sendPrivateText, setAtk, setAtkInternal, setAtkXP, setBaseHP, setBaseMana, setBlood, setDeathSound, 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
-
SOUND_RADIUS
protected static final int SOUND_RADIUSCreature sound radius.- See Also:
-
pauseTurns
protected int pauseTurnsIdling between path cycles -
pauseTurnsRemaining
public int pauseTurnsRemaining -
pauseDirection
-
-
Constructor Details
-
NPC
-
NPC
public NPC()
-
-
Method Details
-
generateRPClass
public static void generateRPClass() -
setIdea
Set the NPC's idea/thought.- Parameters:
idea- The idea mnemonic, ornull.
-
setSounds
Set the possible sound events.- Parameters:
sounds- sound name list
-
setSounds
Set the possible sound events.- Parameters:
sounds- sound name list
-
getSounds
Get the list of possible sound events.- Returns:
- list of sound names
-
getIdea
Get the NPC's idea/thought.- Returns:
- The idea mnemonic, or
null.
-
say
-
say
-
setMovement
moves to the given entity. When the distance to the destination is betweenminandmaxand this entity does not have a path already one is searched and saved.Note: When the distance to the destination is less than
minthe path is removed. Warning: The pathfinder is not asynchronous, so this thread is blocked until a path is found.- Parameters:
destEntity- the destination entitymin- minimum distance to the destination entitymax- maximum distance to the destination entitymaxPathRadius- the maximum radius in which a path is searched
-
setRandomPathFrom
public void setRandomPathFrom(int x, int y, int distance) Set a random destination as a path.- Parameters:
distance- The maximum axis distance to move.x- The origin X coordinate for placement.y- The origin Y coordinate for placement.
-
getPerceptionRange
public int getPerceptionRange()Query the range in which the NPC will notice other subjects like players or enemies.- Returns:
- perception range
-
setPerceptionRange
public void setPerceptionRange(int perceptionRange) Set the perception range.- Parameters:
perceptionRange-
-
getMovementRange
public int getMovementRange()Query the range in which the NPC will search for movement paths.- Returns:
- movement range
-
setMovementRange
public void setMovementRange(int movementRange) Set the movement range.- Parameters:
movementRange-
-
isAttackable
public boolean isAttackable()Returns true if this RPEntity is attackable.- Overrides:
isAttackablein classRPEntity- Returns:
- true if this RPEntity is attackable.
-
dropItemsOn
- Specified by:
dropItemsOnin classDressedEntity
-
checkPause
public void checkPause()Checks if the NPC should remain stationary or begin walking -
logic
public void logic()Description copied from class:RPEntityPerform cycle logic.- Specified by:
logicin classDressedEntity
-
moveRandomly
public void moveRandomly()Give NPC a random path -
onFinishedPath
public void onFinishedPath()- Overrides:
onFinishedPathin classGuidedEntity
-
setPathCompletedPause
public void setPathCompletedPause(int pause) Pause the entity when path is completed. Call setDirection() first to specify which way entity should face during pause.- Parameters:
pause- Number of turns entity should stay paused
-
setPathCompletedPause
-
maybeMakeSound
protected void maybeMakeSound()Generate a sound event with the probability of SOUND_PROBABILITY, if the previous sound event happened long enough ago. -
maybeMakeSound
protected void maybeMakeSound(int probablility) Generate a sound event with the specified probability, if the previous sound event happened long enough ago.- Parameters:
probablility- sound probability
-