Class Entity

Base Class of any moving object, item, enemy, player or otherwise

Info:

  • Author: Ennis Massey,cathery1

Methods

Entity:GetData () Returns a reference to a table that is directly connected to the Entity.
Entity:Update () Completely updates the Entity.
Entity:Render (Offset) Renders the Entity at an offset from the Entities current position on the screen.
Entity:RenderShadowLayer (Offset) Renders the Entity‘s shadow at an offset from the shadow’s current position on the screen if the entity’s animation has a shadow layer.
Entity:PostRender () I’m unsure if it has any effect.
Entity:TakeDamage (Damage, DamageFlags, SourceEntity, DamageCountdown) Sends a Take Damage callback to the specified Entity with the given set of parameters.
Entity:Kill () The entity dies, playing a death animation if it has one, and leaving a blood splat and making a death burst small sound.
Entity:Die () The entity dies, playing a death animation if it has one.
Entity:Remove () The entity stops existing, completely bypassing all death hooks.
Entity:BloodExplode () The entity emits the gib particles as specified in the enities2.xml.
Entity:AddVelocity (Velocity) Adds to the entity’s current velocity.
Entity:MultiplyFriction (MultiplyValue) Multiplies the Entity’s Friciton by the given ammount.
Entity:SetColor (Color, Duration, Priority, Fadeout) Sets the Entity’s Color to the specified color.
Entity:GetColor () Returns the Entity’s current Color.
Entity:SetSpriteFrame (AnimationName, FrameNum) Sets the entity’s sprite to the current frame in the given animation.
Entity:SetSpriteOverlayFrame (AnimationName, FrameNum) Sets the entity’s overlay sprite to the current frame in the given animation.
Entity:SetSize (Size, SizeMulti, NumGridCollisionPoints) Sets the Entity’s size parameters to the given values.
Entity:CollidesWithGrid () Detects if there is a GridEntity the Entity is colliding with, obstructing its path.
Entity:IsEnemy () Detects if the Entity is an enemy (an NPC).
Entity:IsActiveEnemy (IncludeDead) Detects if the Entity is active (not a fireplace or a shopkeeper)


Methods

Entity:GetData ()
Returns a reference to a table that is directly connected to the Entity.

Returns:

    {...} A table, either empty, or with data in it
Entity:Update ()
Completely updates the Entity. (simulates a post update callback for that specific entity)
Entity:Render (Offset)
Renders the Entity at an offset from the Entities current position on the screen.

Parameters:

  • Offset Vector offset from entity to render at
Entity:RenderShadowLayer (Offset)
Renders the Entity‘s shadow at an offset from the shadow’s current position on the screen if the entity’s animation has a shadow layer.

Parameters:

  • Offset Vector offset from shadow to render at

Returns:

    boolean Success returns true if shadow was found, and is being rendered. false otherwise
Entity:PostRender ()
I’m unsure if it has any effect.
Entity:TakeDamage (Damage, DamageFlags, SourceEntity, DamageCountdown)
Sends a Take Damage callback to the specified Entity with the given set of parameters.

Parameters:

  • Damage float the ammount of damage the entity should take. Half a heart for each full unit of damage.
  • DamageFlags integer the damage flags to be passed along with the hit. Each damage flag affects how the entity will take damage. See DamageFlag enum
  • SourceEntity EntityRef the source entity that hits the victim. Convert the entity to an EntityRef first: EntityRef(ent)
  • DamageCountdown integer only works if the flags contain the DamageFlag.DAMAGECOUNTDOWN flag. How many ticks until the next hit containing the DAMAGECOUNTDOWN flag can be received again.

Returns:

    boolean Success returns true if the entity successfully took damage. false otherwise or if it got denied in the callback.
Entity:Kill ()
The entity dies, playing a death animation if it has one, and leaving a blood splat and making a death burst small sound.
Entity:Die ()
The entity dies, playing a death animation if it has one.
Entity:Remove ()
The entity stops existing, completely bypassing all death hooks.
Entity:BloodExplode ()
The entity emits the gib particles as specified in the enities2.xml. this DOES NOT kill the entity.
Entity:AddVelocity (Velocity)
Adds to the entity’s current velocity.

Parameters:

  • Velocity Vector the velocity vector to be added to the current velocity.
Entity:MultiplyFriction (MultiplyValue)
Multiplies the Entity’s Friciton by the given ammount.

Parameters:

  • MultiplyValue float the value by which the Entity’s Friction will be multiplied.
Entity:SetColor (Color, Duration, Priority, Fadeout)
Sets the Entity’s Color to the specified color.

Parameters:

  • Color Color the color to which the entity should be painted to.
  • Duration integer the ammount of game ticks for which the color should last. Infinite if set to 0 or lower.
  • Priority integer which color should be rendered on top of all. The lower the number the higher the priority. Appears to be ignored at 0 or lower duration.
  • Fadeout boolean if set to true, the color will slowly have faded to the original colors by the time the duration timeout is reached.
Entity:GetColor ()
Returns the Entity’s current Color.

Returns:

    KColor Color the entity’s current Color.
Entity:SetSpriteFrame (AnimationName, FrameNum)
Sets the entity’s sprite to the current frame in the given animation. The animation will be paused and considered finished.

Parameters:

  • AnimationName string the animation to get the frame from
  • FrameNum integer the frame to set the animation to
Entity:SetSpriteOverlayFrame (AnimationName, FrameNum)
Sets the entity’s overlay sprite to the current frame in the given animation. The animation will be paused and considered finished.

Parameters:

  • AnimationName string the animation to get the frame from
  • FrameNum integer the frame to set the animation to
Entity:SetSize (Size, SizeMulti, NumGridCollisionPoints)
Sets the Entity’s size parameters to the given values.

Parameters:

  • Size float the entity’s radius at which the entities start colliding with it
  • SizeMulti Vector multiplies the size in both directions by the given X and Y
  • NumGridCollisionPoints integer the ammount of points to split the enemy collision box into for calculations with grid collision. at 4 points becomes a square, at 6 points becomes a hexagon, etc.
Entity:CollidesWithGrid ()
Detects if there is a GridEntity the Entity is colliding with, obstructing its path.

Returns:

    boolean Collide returns true if the Entity is colliding with grid and its path is being obstructed. false otherwise
Entity:IsEnemy ()
Detects if the Entity is an enemy (an NPC). Every entity with a type 10 or above and lower than 1000 is considered an NPC.

Returns:

    boolean IsEnemy returns true if the entity is an enemy. false otherwise
Entity:IsActiveEnemy (IncludeDead)
Detects if the Entity is active (not a fireplace or a shopkeeper)

Parameters:

  • IncludeDead boolean optional - will count dead enemies as active if true

Returns:

    boolean IsActive returns true if the enemy is active, and, if IncludeDead is NOT specified, if the enemy is not dead
generated by LDoc 1.4.6 Last updated 2017-07-17 09:37:29