Binding of Isaac - Afterbirth+ Lua Reference/Guide
EntityNPC Class Reference
Inheritance diagram for EntityNPC:
Entity

Public Member Functions

boolean Morph (EntityType, integer Variant, integer SubType, integer ChampionColorIdx)
 
 KillUnique ()
 For entities with unique death animation, like Flush! vs poop enemies. More...
 
boolean IsBoss ()
 
EntityGetPlayerTarget ()
 if there are no modifiers (best friend) this will return the player More...
 
Vector CalcTargetPosition (float DistanceLimit)
 
integer GetBossColorIdx ()
 
integer GetChampionColorIdx ()
 
 ResetPathFinderTarget ()
 
boolean CanBeDamagedFromVelocity (Vector Velocity)
 
boolean CanReroll ()
 
boolean IsChampion ()
 
 MakeChampion (integer Seed)
 Forces a non champion to become a champion, resets hp to max hp. More...
 
 PlaySound (SoundEffect ID, float Volume, integer FrameDelay, boolean Loop, float Pitch)
 
EntityEffectMakeSplat (float Size)
 
integer GetAliveEnemyCount ()
 Used to redirect close door enemies to any enemies for friendly npcs. More...
 
 FireProjectiles (Vector Pos, Vector Velocity, ProjectilesMode Mode, ProjectileParams Params)
 
EntityProjectileFireBossProjectiles (integer NumProjectiles, Vector TargetPos, float TrajectoryModifier, ProjectileParams Params)
 
 AnimWalkFrame (string HorizontalAnim, string VerticalAnim, float SpeedThreshold)
 
EntityList QueryNPCsType (EntityType Type, integer Variant)
 
EntityList QueryNPCsSpawnerType (EntityType SpawnerType, EntityType Type, boolean OnlyEnemies)
 
EntityList QueryNPCsGroup (integer GroupIdx)
 
- Public Member Functions inherited from Entity
table GetData ()
 
 Update ()
 
 Render (Vector Offset)
 
boolean RenderShadowLayer (Vector Offset)
 
 PostRender ()
 
boolean TakeDamage (float Damage, integer Flags, EntityRef Source, integer DamageCountdown)
 
boolean HasMortalDamage ()
 
 Kill ()
 Kills the entity and makes a blood splat or gibs. More...
 
 Die ()
 
 Remove ()
 
 BloodExplode ()
 Explodes with gibs and blood. More...
 
 AddVelocity (Vector Velocity)
 
 MultiplyFriction (float Value)
 
 SetColor (Color Color, integer Duration, integer Priority, boolean Fadeout, boolean Share)
 
const ColorGetColor ()
 
 SetSpriteFrame (string AnimationName, integer FrameNum)
 
 SetSpriteOverlayFrame (string AnimationName, integer FrameNum)
 
 SetSize (float Size, Vector SizeMulti, integer NumGridCollisionPoints)
 
boolean CollidesWithGrid ()
 
boolean IsEnemy ()
 return true for NPCs that are not controlled by the player More...
 
boolean IsActiveEnemy (boolean includeDead)
 return true for non background NPCs (ex: every enemy except fire and shopkeepers) More...
 
boolean IsVulnerableEnemy ()
 return true for enemies that can be damaged More...
 
boolean IsFlying ()
 
 AddEntityFlags (integer Flags)
 
 ClearEntityFlags (integer Flags)
 
integer GetEntityFlags ()
 
boolean HasEntityFlags (integer Flags)
 
boolean HasFullHealth ()
 
 AddHealth (float HitPoints)
 
 AddPoison (EntityRef Source, integer Duration, float Damage)
 
 AddFreeze (EntityRef Source, integer Duration)
 
 AddSlowing (EntityRef Source, integer Duration, float SlowValue, Color SlowColor)
 Makes the friction higher. More...
 
 AddCharmed (integer Duration)
 
 AddConfusion (EntityRef Source, integer Duration, boolean IgnoreBosses)
 
 AddMidasFreeze (EntityRef Source, integer Duration)
 
 AddFear (EntityRef Source, integer Duration)
 
 AddBurn (EntityRef Source, integer Duration, float Damage)
 
 AddShrink (EntityRef Source, integer Duration)
 
 RemoveStatusEffects ()
 
boolean Exists ()
 
boolean IsDead ()
 
boolean IsVisible ()
 
boolean IsInvincible ()
 
boolean CanShutDoors ()
 enemies keep the doors shut More...
 
boolean IsBoss ()
 bosses display health bar More...
 
BossId GetBossID ()
 
EntityGetLastParent ()
 
EntityGetLastChild ()
 
boolean HasCommonParentWithEntity (Entity Other)
 
boolean IsFrame (integer Frame, integer Offset)
 true every X frames More...
 
RNGGetDropRNG ()
 
SpriteGetSprite ()
 
EntityPlayer ToPlayer ()
 
EntityEffect ToEffect ()
 
EntityNPC ToNPC ()
 
EntityPickup ToPickup ()
 
EntityFamiliar ToFamiliar ()
 
EntityBomb ToBomb ()
 
EntityKnife ToKnife ()
 
EntityLaser ToLaser ()
 
EntityTear ToTear ()
 
EntityProjectile ToProjectile ()
 

Static Public Member Functions

static ThrowSpider (Vector Position, Entity Spawner, Vector TargetPos, boolean Big, float YOffset)
 

Public Attributes

boolean CanShutDoors
 
float Scale
 
const EntityNPCParentNPC
 parent entity, for multi-entity NPCs like Larry Jr. More...
 
const EntityNPCChildNPC
 
EntityEntityRef
 
integer StateFrame
 
PathFinder Pathfinder
 
integer State
 
integer ProjectileCooldown
 
integer ProjectileDelay
 >0: projectile will be fired in n frames More...
 
Vector V1
 general usage for ai_* functions, initialized to (0,0) More...
 
Vector V2
 like m_V1, in case we need two of those More...
 
integer I1
 general usage ints for ai_ More...
 
integer I2
 same as m_I1 More...
 
integer GroupIdx
 Used to identify multichunks groups. More...
 
- Public Attributes inherited from Entity
float Friction
 loaded from entity config More...
 
Vector Position
 
Vector Velocity
 
const EntityType Type
 
integer Variant
 void SetType(eEntityType Type); More...
 
integer SubType
 
EntityType SpawnerType
 
integer SpawnerVariant
 
const ColorSplatColor
 
boolean Visible
 
const VectorPositionOffset
 
integer RenderZOffset
 
boolean FlipX
 
const VectorSpriteOffset
 
const VectorSpriteScale
 
float SpriteRotation
 
Vector SizeMulti
 
float Mass
 
float MaxHitPoints
 
float HitPoints
 
const integer Index
 
const VectorTargetPosition
 
GridCollisionClass GridCollisionClass
 
EntityCollisionClass EntityCollisionClass
 
float CollisionDamage
 
const integer SpawnGridIndex
 
EntityParent
 
EntityChild
 
EntityTarget
 
EntitySpawnerEntity
 
const integer FrameCount
 
const integer InitSeed
 
const integer DropSeed
 
float DepthOffset
 

Member Function Documentation

◆ AnimWalkFrame()

EntityNPC::AnimWalkFrame ( string  HorizontalAnim,
string  VerticalAnim,
float  SpeedThreshold 
)

◆ CalcTargetPosition()

Vector EntityNPC::CalcTargetPosition ( float  DistanceLimit)

◆ CanBeDamagedFromVelocity()

boolean EntityNPC::CanBeDamagedFromVelocity ( Vector  Velocity)

◆ CanReroll()

boolean EntityNPC::CanReroll ( )

◆ FireBossProjectiles()

EntityProjectile& EntityNPC::FireBossProjectiles ( integer  NumProjectiles,
Vector  TargetPos,
float  TrajectoryModifier,
ProjectileParams  Params 
)

fire a number of projectiles, optionally targeting the player direction is randomized, or slightly randomized when targeting the player FallingAccelModifier can be used to make projectiles fall faster to the ground returns a pointer to the projectile spawned last (useful e.g. when NumProjectiles=1)

◆ FireProjectiles()

EntityNPC::FireProjectiles ( Vector  Pos,
Vector  Velocity,
ProjectilesMode  Mode,
ProjectileParams  Params 
)

◆ GetAliveEnemyCount()

integer EntityNPC::GetAliveEnemyCount ( )

Used to redirect close door enemies to any enemies for friendly npcs.

◆ GetBossColorIdx()

integer EntityNPC::GetBossColorIdx ( )

This will return the boss color idx reduced by 1. To get the actual color as set in bosscolors.xml, add +1 to the result.

◆ GetChampionColorIdx()

integer EntityNPC::GetChampionColorIdx ( )

A list of Champion colors can be found here : ChampionColorIdx

◆ GetPlayerTarget()

Entity& EntityNPC::GetPlayerTarget ( )

if there are no modifiers (best friend) this will return the player

◆ IsBoss()

boolean EntityNPC::IsBoss ( )

◆ IsChampion()

boolean EntityNPC::IsChampion ( )

◆ KillUnique()

EntityNPC::KillUnique ( )

For entities with unique death animation, like Flush! vs poop enemies.

◆ MakeChampion()

EntityNPC::MakeChampion ( integer  Seed)

Forces a non champion to become a champion, resets hp to max hp.

Hard to use because there are millions of possible seeds to input here.
Use Morph() to change the champion Color instead!

◆ MakeSplat()

EntityEffect& EntityNPC::MakeSplat ( float  Size)

◆ Morph()

boolean EntityNPC::Morph ( EntityType  ,
integer  Variant,
integer  SubType,
integer  ChampionColorIdx 
)

Morph the current entity into another one.

ChampionColorIdx can be used to turn the entity into a champion. Use -1 to turn it into a regular entity.

A list of Champion colors can be found here : ChampionColorIdx

This code turns an entity into a gaper.
entity:ToNPC():Morph(EntityType.ENTITY_GAPER , 0, 0,-1)

◆ PlaySound()

EntityNPC::PlaySound ( SoundEffect  ID,
float  Volume,
integer  FrameDelay,
boolean  Loop,
float  Pitch 
)

◆ QueryNPCsGroup()

EntityList EntityNPC::QueryNPCsGroup ( integer  GroupIdx)

◆ QueryNPCsSpawnerType()

EntityList EntityNPC::QueryNPCsSpawnerType ( EntityType  SpawnerType,
EntityType  Type,
boolean  OnlyEnemies 
)

◆ QueryNPCsType()

EntityList EntityNPC::QueryNPCsType ( EntityType  Type,
integer  Variant 
)

◆ ResetPathFinderTarget()

EntityNPC::ResetPathFinderTarget ( )

◆ ThrowSpider()

static EntityNPC::ThrowSpider ( Vector  Position,
Entity  Spawner,
Vector  TargetPos,
boolean  Big,
float  YOffset 
)
static

Member Data Documentation

◆ CanShutDoors

boolean EntityNPC::CanShutDoors

◆ ChildNPC

const EntityNPC& EntityNPC::ChildNPC

◆ EntityRef

Entity& EntityNPC::EntityRef

◆ GroupIdx

integer EntityNPC::GroupIdx

Used to identify multichunks groups.

◆ I1

integer EntityNPC::I1

general usage ints for ai_

◆ I2

integer EntityNPC::I2

same as m_I1

◆ ParentNPC

const EntityNPC& EntityNPC::ParentNPC

parent entity, for multi-entity NPCs like Larry Jr.

◆ Pathfinder

PathFinder EntityNPC::Pathfinder

◆ ProjectileCooldown

integer EntityNPC::ProjectileCooldown

projectiles can fire again when it reaches 0

◆ ProjectileDelay

integer EntityNPC::ProjectileDelay

>0: projectile will be fired in n frames

◆ Scale

float EntityNPC::Scale

◆ State

integer EntityNPC::State

◆ StateFrame

integer EntityNPC::StateFrame

◆ V1

Vector EntityNPC::V1

general usage for ai_* functions, initialized to (0,0)

◆ V2

Vector EntityNPC::V2

like m_V1, in case we need two of those