Class CreatureScript
java.lang.Object
de.gurkenlabs.litiengine.scripting.AbstractScript<Creature>
de.gurkenlabs.litiengine.scripting.EntityScript<Creature>
de.gurkenlabs.litiengine.scripting.CreatureScript
- All Implemented Interfaces:
ScriptInstance
Convenient base class for creature behavior scripts with movement and combat helpers.
-
Field Summary
Fields inherited from class AbstractScript
globals -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if an ability registered with the specified name can currently be cast.Casts an ability registered on this creature by its name.createAbility(String name) Begins building a scripted ability executed by this creature.voidDisables and removes active movement controllers on this creature.Configures platforming movement (A/D/Space) for this creature and binds its lifecycle to this script.enablePlatformingMovement(int left, int right, int jump) Configures platforming movement with custom keys for this creature and binds its lifecycle to this script.Configures top-down WASD keyboard movement for this creature and binds its lifecycle to this script.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.getAbility(String name) Gets an ability registered on this creature by its name.intReturns current health / hitpoints.intReturns maximum health / hitpoints.booleanhasAbility(String name) Checks if this creature has an ability registered with the specified name.booleanisDead()Checks if the creature is currently dead.booleanisOnCooldown(String name) Checks if an ability registered with the specified name is currently on cooldown.voidmoveInAngle(double angleDegrees) Moves the creature at a specific angle in degrees (0 = North, 90 = East, 180 = South, 270 = West).voidmoveInDirection(Direction direction) Moves the creature in a specific compass direction.voidmoveTowards(IEntity target) Moves the creature towards a target entity.voidmoveTowards(Point2D target) Moves the creature towards a target point in the game world.protected voidonJump()Called when the platforming movement controller executes a jump action.Methods inherited from class EntityScript
attached, detached, die, onAction, onCollision, onCollision, onDeath, onDeath, onHit, onHit, onInteract, onLoaded, onMessage, onMessage, onUnloaded, remove, resurrect, sendMessage, sendMessageMethods inherited from class AbstractScript
attach, camera, context, detach, environment, globals, host, input, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheel, onRender, render, spawn, spawn, spawn, spawn, spawnCreature, spawnCreature, spawner, spawnProp, spawnProp, uiMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ScriptInstance
update
-
Constructor Details
-
CreatureScript
public CreatureScript()
-
-
Method Details
-
moveTowards
Moves the creature towards a target point in the game world.- Parameters:
target- The target in map coordinates;nullhas no effect.
-
moveTowards
Moves the creature towards a target entity.- Parameters:
target- The target entity;nullhas no effect.
-
moveInDirection
Moves the creature in a specific compass direction.- Parameters:
direction- The direction;nullhas 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:
isDeadin classEntityScript<Creature>- Returns:
trueif the attached creature is dead.
-
getHealth
public int getHealth()Returns current health / hitpoints.- Overrides:
getHealthin classEntityScript<Creature>- Returns:
- The current hit points, or zero when detached.
-
getMaxHealth
public int getMaxHealth()Returns maximum health / hitpoints.- Overrides:
getMaxHealthin classEntityScript<Creature>- Returns:
- The maximum hit points, or zero when detached.
-
createAbility
Begins building a scripted ability executed by this creature.- Parameters:
name- The ability name.- Returns:
- A builder for the new ability.
-
cast
Casts an ability registered on this creature by its name.- Parameters:
name- The ability name.- Returns:
- The execution, or
nullwhen detached or not castable.
-
getAbility
-
hasAbility
Checks if this creature has an ability registered with the specified name.- Parameters:
name- The ability name.- Returns:
trueif it is registered.
-
canCast
Checks if an ability registered with the specified name can currently be cast.- Parameters:
name- The ability name.- Returns:
trueif it can currently be cast.
-
isOnCooldown
Checks if an ability registered with the specified name is currently on cooldown.- Parameters:
name- The ability name.- Returns:
trueif it is cooling down.
-
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
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
-