Class Projectile

Methods

projectile:init (projectile_type, source, target, info) Initiates a projectile.
projectile:get_description () Gets the name and description of the projectile
projectile:delete () Deletes a projectile
projectile:refresh_path () Refresh or create the projectile's path
projectile:advance () This code runs every turn a projectile is active.
projectile:update (dt, force_generic) This code runs every tick a projectile is active.
projectile:hits (target, force_generic) Called when a projectile hits something
projectile:get_name (full) Gets the name of the projectile
projectile:get_enchantments () Return a list of all enchantments currently applied to an projectile
projectile:get_hit_conditions () Check what hit conditions a projectile can inflict
projectile:get_damage () Return the damage done by the projectile
projectile:get_enchantment_bonus (bonusType) Returns the total value of the bonuses of a given type provided by enchantments.
projectile:get_extra_damage (target, dmg) Find out how much extra damage an item will deal due to enchantments
projectile:apply_enchantment (enchantment, turns) Apply an enchantment to an projectile


Methods

projectile:init (projectile_type, source, target, info)
Initiates a projectile. Don't call this explicitly, it's called when you create a new projectile with Projectile('projectileID',source,target).

Parameters:

  • projectile_type String. The ID of the projectile you'd like to create
  • source Entity. A table that contains the X and Y coordinates the projectile is starting at. Might be a creature.
  • target Entity. A table that contains the X and Y coordinates the projectile is moving towards. Might be a creature.
  • info Whatever you want to pass to the projectile's new() function

Returns:

    The projectile itself.
projectile:get_description ()
Gets the name and description of the projectile

Returns:

    String. The name and description of the projectile
projectile:delete ()
Deletes a projectile
projectile:refresh_path ()
Refresh or create the projectile's path
projectile:advance ()
This code runs every turn a projectile is active. Called by the advance_turn() code
projectile:update (dt, force_generic)
This code runs every tick a projectile is active. You shouldn't call it explicitly.

Parameters:

  • dt Number The number of seconds since the last tick
  • force_generic Boolean. If set to true, run this code and don't run the projectile's custom update() code.
projectile:hits (target, force_generic)
Called when a projectile hits something

Parameters:

  • target Entity. The thing it hit. Must be a table with an X and Y coordinate, probably a creature.
  • force_generic Boolean. If set to true, run this code and don't run the projectile's custom hits() code.
projectile:get_name (full)
Gets the name of the projectile

Parameters:

  • full Boolean. If true, return just the basic name of the projectile. If false, preface with "a" or "an"

Returns:

    String. The name of the projectile
projectile:get_enchantments ()
Return a list of all enchantments currently applied to an projectile

Returns:

    Table. The list of enchantments
projectile:get_hit_conditions ()
Check what hit conditions a projectile can inflict

Returns:

    Table. The list of hit conditions
projectile:get_damage ()
Return the damage done by the projectile

Returns:

    Number. The damage done
projectile:get_enchantment_bonus (bonusType)
Returns the total value of the bonuses of a given type provided by enchantments.

Parameters:

  • bonusType Text. The bonus type to look at

Returns:

    Number. The bonus
projectile:get_extra_damage (target, dmg)
Find out how much extra damage an item will deal due to enchantments

Parameters:

  • target Entity. The target of the item's attack.
  • dmg Number. The base damage being done to the target

Returns:

    Table. A table with values of the extra damage the item will deal.
projectile:apply_enchantment (enchantment, turns)
Apply an enchantment to an projectile

Parameters:

  • enchantment Text. The enchantment ID
  • turns Number. The number of turns to apply the enchantment, if applicable. Generally only matters for projectiles if it misses and leaves an item behind. Use -1 to force this enchantment to be permanent. Use 0 to force the enchantment to not be applied to the item left behind.
generated by LDoc 1.5.0 Last updated 2025-05-24 09:49:55