Skip to content

Class "EntityNPC"⚓︎

Info

You can get this class by using the following function:

Example Code

local entity = Isaac.GetRoomEntities()[1]:ToNPC()

Class Diagram⚓︎

    classDiagram
    class Entity:::diagramCurrentPage
    class EntityBomb
    class EntityEffect
    class EntityFamiliar
    class EntityKnife
    class EntityLaser
    class EntityNPC
    class EntityPickup
    class EntityPlayer
    class EntityProjectile
    class EntityTear
    Entity <|-- EntityBomb
    Entity <|-- EntityEffect
    Entity <|-- EntityFamiliar
    Entity <|-- EntityKnife
    Entity <|-- EntityLaser
    Entity <|-- EntityNPC
    Entity <|-- EntityPickup
    Entity <|-- EntityPlayer
    Entity <|-- EntityProjectile
    Entity <|-- EntityTear
    link Entity "Entity.html" "Go to page for 'Entity' class"
    link EntityBomb "EntityBomb.html" "Go to page for 'EntityBomb' class"
    link EntityEffect "EntityEffect.html" "Go to page for 'EntityEffect' class"
    link EntityFamiliar "EntityFamiliar.html" "Go to page for 'EntityFamiliar' class"
    link EntityKnife "EntityKnife.html" "Go to page for 'EntityKnife' class"
    link EntityLaser "EntityLaser.html" "Go to page for 'EntityLaser' class"
    link EntityNPC "EntityNPC.html" "Go to page for 'EntityNPC' class"
    link EntityPickup "EntityPickup.html" "Go to page for 'EntityPickup' class"
    link EntityPlayer "EntityPlayer.html" "Go to page for 'EntityPlayer' class"
    link EntityProjectile "EntityProjectile.html" "Go to page for 'EntityProjectile' class"
    link EntityTear "EntityTear.html" "Go to page for 'EntityTear' class"

Functions⚓︎

Anim·Walk·Frame ()⚓︎

void AnimWalkFrame ( string HorizontalAnim, string VerticalAnim, float SpeedThreshold )⚓︎


Calc·Target·Position ()⚓︎

Vector CalcTargetPosition ( float DistanceLimit )⚓︎


Can·Be·Damaged·From·Velocity ()⚓︎

boolean CanBeDamagedFromVelocity ( Vector Velocity )⚓︎


Can·Reroll ()⚓︎

boolean CanReroll ( )⚓︎


Fire·Boss·Projectiles ()⚓︎

EntityProjectile FireBossProjectiles ( int 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)


Fire·Projectiles ()⚓︎

void FireProjectiles ( Vector Pos, Vector Velocity, ProjectilesMode Mode, ProjectileParams Params )⚓︎

ProjectilesMode
  • 0 : single projectile
  • 1 : two projectiles (uses params.Spread)
  • 2 : three projectiles (uses params.Spread)
  • 3 : three projectiles (uses params.Spread, more spread out?)
  • 4 : four projectiles (uses params.Spread)
  • 5 : five projectiles (uses params.Spread)
  • 6 : four projectiles in a + pattern (uses velocity.x as speed)
  • 7 : four projectiles in a x pattern (uses velocity.x as speed)
  • 8 : eight projectiles in a star pattern (uses velocity.x as speed)
  • 9 : N projectiles in a circle (velocity.x = speed, velocity.y = N, params.FireDirectionLimit and params.DotProductLimit to fire in an arc only)

Get·Alive·Enemy·Count ()⚓︎

int GetAliveEnemyCount ( )⚓︎

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


Get·Boss·Color·Idx ()⚓︎

int GetBossColorIdx ( )⚓︎

Notes

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.


Get·Champion·Color·Idx ()⚓︎

int GetChampionColorIdx ( )⚓︎

Notes

A list of Champion colors can be found here : ChampionColorIdx


Get·Player·Target ()⚓︎

Entity GetPlayerTarget ( )⚓︎

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


Is·Boss ()⚓︎

boolean IsBoss ( )⚓︎


Is·Champion ()⚓︎

boolean IsChampion ( )⚓︎


Kill·Unique ()⚓︎

void KillUnique ( )⚓︎

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


Make·Champion ()⚓︎

void MakeChampion ( int Seed, ChampionColor ChampionColorIdx = -1, boolean Init = false )⚓︎

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

ChampionColorIdx: The type of champion to turn this enemy into (-1 results in a random champion type)

Init: Set to true when called while initializing the enemy, false otherwise


Make·Splat ()⚓︎

EntityEffect MakeSplat ( float Size )⚓︎


Morph ()⚓︎

boolean Morph ( EntityType type, int Variant, int SubType, int ChampionColorIdx )⚓︎

Morph the current entity into another one. ChampionColorIdx can be used to turn the entity into a champion. Use -1 in order to not add a champion color. A list of Champion colors can be found here : ChampionColorIdx

Bug

This function can not turn a champion NPC into a regular NPC! for that, use the following code:

1
2
3
4
5
local previousNPC = entity:ToNPC()
-- spawn the same entity at the same location as the old one
Isaac.Spawn(previousNPC.Type, previousNPC.Variant, previousNPC.SubType, previousNPC.Position, previousNPC.Velocity, previousNPC.Parent)
-- remove old entity
previousNPC:Remove()

Example Code

This code turns an entity into a gaper.

1
entity:ToNPC():Morph(EntityType.ENTITY_GAPER, 0, 0, -1)


Play·Sound ()⚓︎

void PlaySound ( SoundEffect ID, float Volume, int FrameDelay, boolean Loop, float Pitch )⚓︎


Query·NPCs·Group ()⚓︎

EntityList QueryNPCsGroup ( int GroupIdx )⚓︎


Query·NPCs·Spawner·Type ()⚓︎

EntityList QueryNPCsSpawnerType ( EntityType SpawnerType, EntityType Type, boolean OnlyEnemies )⚓︎


Query·NPCs·Type ()⚓︎

EntityList QueryNPCsType ( EntityType Type, int Variant )⚓︎


Reset·Path·Finder·Target ()⚓︎

void ResetPathFinderTarget ( )⚓︎


Throw·Spider ()⚓︎

static const EntityNPC ThrowSpider ( Vector Position, Entity Spawner, Vector TargetPos, boolean Big, float YOffset )⚓︎


Variables⚓︎

Can·Shut·Doors⚓︎

boolean CanShutDoors⚓︎


Child·NPC⚓︎

const EntityNPC ChildNPC⚓︎


Entity·Ref⚓︎

Entity EntityRef⚓︎


Group·Idx⚓︎

int GroupIdx⚓︎

Used to identify multichunks groups.


I1⚓︎

int I1⚓︎

General usage int for AI specific actions. The effect and usage is manually defined for each entity. It can also not be used at all for some.

Example: The Frail sets I2 to 1 when entering the second phase.


I2⚓︎

int I2⚓︎

General usage int for AI specific actions. The effect and usage is manually defined for each entity. It can also not be used at all for some.

Example: The Frail sets I2 to 1 when entering the second phase.


Parent·NPC⚓︎

const EntityNPC ParentNPC⚓︎

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


Pathfinder⚓︎

PathFinder Pathfinder⚓︎


Projectile·Cooldown⚓︎

int ProjectileCooldown⚓︎

projectiles can fire again when it reaches 0


Projectile·Delay⚓︎

int ProjectileDelay⚓︎

>0: projectile will be fired in n frames


Scale⚓︎

float Scale⚓︎


State⚓︎

NpcState State⚓︎


State·Frame⚓︎

int StateFrame⚓︎


V1⚓︎

Vector V1⚓︎

General usage Vector for AI specific actions. Initialized to be Vector(0,0). The effect and usage is manually defined for each entity. It can also not be used at all for some.


V2⚓︎

Vector V2⚓︎

General usage Vector for AI specific actions. Initialized to be Vector(0,0). The effect and usage is manually defined for each entity. It can also not be used at all for some.



Last update: April 26, 2024