Class CreatureScript

All Implemented Interfaces:
ScriptInstance

public abstract class CreatureScript extends EntityScript<Creature>
Convenient base class for creature behavior scripts with movement and combat helpers.
  • Constructor Details

    • CreatureScript

      public CreatureScript()
  • Method Details

    • moveTowards

      public void moveTowards(Point2D target)
      Moves the creature towards a target point in the game world.
      Parameters:
      target - The target in map coordinates; null has no effect.
    • moveTowards

      public void moveTowards(IEntity target)
      Moves the creature towards a target entity.
      Parameters:
      target - The target entity; null has no effect.
    • moveInDirection

      public void moveInDirection(Direction direction)
      Moves the creature in a specific compass direction.
      Parameters:
      direction - The direction; null has no effect.
    • moveInAngle

      public void moveInAngle(double angleDegrees)
      Moves the creature at a specific angle in degrees (0 = North, 90 = East, 180 = South, 270 = West).
      Parameters:
      angleDegrees - The movement angle in degrees.
    • isDead

      public boolean isDead()
      Checks if the creature is currently dead.
      Overrides:
      isDead in class EntityScript<Creature>
      Returns:
      true if the attached creature is dead.
    • getHealth

      public int getHealth()
      Returns current health / hitpoints.
      Overrides:
      getHealth in class EntityScript<Creature>
      Returns:
      The current hit points, or zero when detached.
    • getMaxHealth

      public int getMaxHealth()
      Returns maximum health / hitpoints.
      Overrides:
      getMaxHealth in class EntityScript<Creature>
      Returns:
      The maximum hit points, or zero when detached.
    • createAbility

      public ScriptedAbilityBuilder createAbility(String name)
      Begins building a scripted ability executed by this creature.
      Parameters:
      name - The ability name.
      Returns:
      A builder for the new ability.
    • cast

      public AbilityExecution cast(String name)
      Casts an ability registered on this creature by its name.
      Parameters:
      name - The ability name.
      Returns:
      The execution, or null when detached or not castable.
    • getAbility

      public Optional<Ability> getAbility(String name)
      Gets an ability registered on this creature by its name.
      Parameters:
      name - The ability name.
      Returns:
      The ability, or an empty optional.
    • hasAbility

      public boolean hasAbility(String name)
      Checks if this creature has an ability registered with the specified name.
      Parameters:
      name - The ability name.
      Returns:
      true if it is registered.
    • canCast

      public boolean canCast(String name)
      Checks if an ability registered with the specified name can currently be cast.
      Parameters:
      name - The ability name.
      Returns:
      true if it can currently be cast.
    • isOnCooldown

      public boolean isOnCooldown(String name)
      Checks if an ability registered with the specified name is currently on cooldown.
      Parameters:
      name - The ability name.
      Returns:
      true if it is cooling down.
    • enableTopDownMovement

      public KeyboardEntityController<Creature> enableTopDownMovement()
      Configures top-down WASD keyboard movement for this creature and binds its lifecycle to this script.
      Returns:
      The installed movement controller.
    • enableTopDownMovement

      public KeyboardEntityController<Creature> enableTopDownMovement(int up, int down, int left, int right)
      Configures top-down keyboard movement with custom keys for this creature and binds its lifecycle to this script.
      Parameters:
      up - The key code for upward movement.
      down - The key code for downward movement.
      left - The key code for left movement.
      right - The key code for right movement.
      Returns:
      The installed movement controller.
    • enablePlatformingMovement

      public PlatformingMovementController<Creature> enablePlatformingMovement()
      Configures platforming movement (A/D/Space) for this creature and binds its lifecycle to this script.
      Returns:
      The installed movement controller.
    • enablePlatformingMovement

      public PlatformingMovementController<Creature> enablePlatformingMovement(int left, int right, int jump)
      Configures platforming movement with custom keys for this creature and binds its lifecycle to this script.
      Parameters:
      left - The key code for left movement.
      right - The key code for right movement.
      jump - The key code for jumping.
      Returns:
      The installed movement controller.
    • disableMovementController

      public void disableMovementController()
      Disables and removes active movement controllers on this creature.
    • onJump

      protected void onJump() throws Exception
      Called when the platforming movement controller executes a jump action.
      Throws:
      Exception - if handling fails.