All Implemented Interfaces:
Killer, Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
ActorNPC, Creature, PassiveNPC, TrainingDummy

public abstract class NPC extends DressedEntity
  • Field Details

    • SOUND_RADIUS

      protected static final int SOUND_RADIUS
      Creature sound radius.
      See Also:
      Constant Field Values
    • pauseTurns

      protected int pauseTurns
      Idling between path cycles
    • pauseTurnsRemaining

      public int pauseTurnsRemaining
    • pauseDirection

      protected Direction pauseDirection
  • Constructor Details

    • NPC

      public NPC(RPObject object)
    • NPC

      public NPC()
  • Method Details

    • generateRPClass

      public static void generateRPClass()
    • setIdea

      public void setIdea(String idea)
      Set the NPC's idea/thought.
      Parameters:
      idea - The idea mnemonic, or null.
    • setSounds

      public void setSounds(List<String> sounds)
      Set the possible sound events.
      Parameters:
      sounds - sound name list
    • setSounds

      public void setSounds(String[] sounds)
      Set the possible sound events.
      Parameters:
      sounds - sound name list
    • getSounds

      protected List<String> getSounds()
      Get the list of possible sound events.
      Returns:
      list of sound names
    • getIdea

      public String getIdea()
      Get the NPC's idea/thought.
      Returns:
      The idea mnemonic, or null.
    • say

      public void say(String text)
    • setMovement

      public void setMovement(Entity destEntity, double min, double max, double maxPathRadius)
      moves to the given entity. When the distance to the destination is between min and max and this entity does not have a path already one is searched and saved.

      Note: When the distance to the destination is less than min the path is removed. Warning: The pathfinder is not asynchronous, so this thread is blocked until a path is found.

      Parameters:
      destEntity - the destination entity
      min - minimum distance to the destination entity
      max - maximum distance to the destination entity
      maxPathRadius - 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:
      isAttackable in class RPEntity
      Returns:
      true if this RPEntity is attackable.
    • dropItemsOn

      protected void dropItemsOn(Corpse corpse)
      Specified by:
      dropItemsOn in class DressedEntity
    • checkPause

      public void checkPause()
      Checks if the NPC should remain stationary or begin walking
    • logic

      public void logic()
      Description copied from class: RPEntity
      Perform cycle logic.
      Specified by:
      logic in class DressedEntity
    • moveRandomly

      public void moveRandomly()
      Give NPC a random path
    • onFinishedPath

      public void onFinishedPath()
      Overrides:
      onFinishedPath in class GuidedEntity
    • 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

      public void setPathCompletedPause(int pause, Direction dir)
    • 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