Modding:Lua/Hooks/Monster

From Starbounder - Starbound Wiki
Jump to: navigation, search

Description

These monster hooks are stubs for global functions that monster scripts can define, which will be called by the C++ engine. Documentation for it was removed from the assets, but an old and outdated (2015) version can be found here: https://pastebin.com/cuAdqBtV

Hooks

init()

Called (once) after the monster is added to the world. Note that the monster's position may not yet be valid

update(dt)

Update loop handler.
Called once every scriptDelta (defined in *.monstertype) ticks

die()

Called when shouldDie has returned true and the monster and is about to be removed from the world

damage(args)

Called after the monster has taken damage.
'args' is a map of info about the damage, structured as:

{
sourceId = <entity id of entity that caused the damage>,
damage = <numeric amount of damage that was taken>,
sourceDamage = <numeric amount of damage that was originally dealt>,
sourceKind = <string kind of damage being applied, as defined in "damageKind" value in a *.projectile config>
}

Note that "sourceDamage" can be higher than "damage" if - for instance - some damage was blocked by a shield.

shouldDie()

Called each update to determine if the monster should die. If not defined in the monster's lua, will default to returning true when the monster's health has been depleted.

Returns boolean - true if the monster can die, false to keep the monster alive


Quick Navigation