Skip to content

Class "EntityNPC"⚓︎

Info

你可以通过以下函数获取此类:

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 )⚓︎

发射一系列弹幕,目标可以是玩家,方向会随机化,或者在瞄准玩家时稍微随机化。可以使用 FallingAccelModifier 使弹幕更快落地。返回最后生成的弹幕指针(例如,当 NumProjectiles=1 时很有用)。


Fire·Projectiles ()⚓︎

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

ProjectilesMode

该参数控制发射弹幕的模式: * 0 : 单发弹幕 * 1 : 双发弹幕(使用 params.Spread) * 2 : 三发弹幕(使用 params.Spread) * 3 : 三发弹幕(使用 params.Spread,分布更广?) * 4 : 四发弹幕(使用 params.Spread) * 5 : 五发弹幕(使用 params.Spread) * 6 : 四发弹幕(使用 velocity.x 作为速度,呈 + 形状) * 7 : 四发弹幕(使用 velocity.x 作为速度,呈 x 形状) * 8 : 八发弹幕(使用 velocity.x 作为速度,呈星形) * 9 : N 发弹幕(使用 velocity.x 作为速度,velocity.y = N,params.FireDirectionLimit 和 params.DotProductLimit 仅在弧形中发射)


Get·Alive·Enemy·Count ()⚓︎

int GetAliveEnemyCount ( )⚓︎

用于将近战敌人重定向到任何敌人以供友方 NPC 使用。


Get·Boss·Color·Idx ()⚓︎

int GetBossColorIdx ( )⚓︎

Notes

这将返回减少 1 的 boss color idx。要获取在 bosscolors.xml 中设置的实际颜色,请在结果上加 1。


Get·Champion·Color·Idx ()⚓︎

ChampionColorIdx GetChampionColorIdx ( )⚓︎

返回 NPC 的精英颜色索引。如果 NPC 不是精英怪,则返回 -1。


Get·Player·Target ()⚓︎

Entity GetPlayerTarget ( )⚓︎

如果没有修饰符(最好的朋友),这将返回玩家


Is·Boss ()⚓︎

boolean IsBoss ( )⚓︎


Is·Champion ()⚓︎

boolean IsChampion ( )⚓︎


Kill·Unique ()⚓︎

void KillUnique ( )⚓︎

对于具有独特死亡动画的实体,例如 Flush! 与粪便敌人。


Make·Champion ()⚓︎

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

强制非精英怪成为精英怪,重置生命值为最大生命值。

ChampionColorIdx: 要将此敌人变为的精英类型(-1 将导致随机精英类型)

Init: 在初始化敌人时调用时设置为 true,否则为 false


Make·Splat ()⚓︎

EntityEffect MakeSplat ( float Size )⚓︎


Morph ()⚓︎

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

修改当前实体为另一个实体。可以使用 ChampionColorIdx 将实体变为精英怪。使用 -1 以不添加精英变体。

精英变体索引的列表可以在这里找到 : ChampionColorIdx

Bug

这个函数无法将精英 NPC 转换为普通 NPC!为此,请使用以下代码:

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⚓︎

通常用于 AI 特定操作的通用用法 int。每个实体的效果和用法是手动定义的。对于某些实体,它也可能根本无法使用。

Example: 脆皮虫进入第二阶段时将 I2 设置为 1。


I2⚓︎

int I2⚓︎

通常用于 AI 特定操作的通用用法 int。每个实体的效果和用法是手动定义的。对于某些实体,它也可能根本无法使用。

Example: 脆皮虫进入第二阶段时将 I2 设置为 1。


Parent·NPC⚓︎

const EntityNPC ParentNPC⚓︎

父实体,用于像 Larry Jr. 这样的多实体 NPC。


Pathfinder⚓︎

PathFinder Pathfinder⚓︎


Projectile·Cooldown⚓︎

int ProjectileCooldown⚓︎

当 projectileCooldown 达到 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⚓︎

通常用于 AI 特定操作的通用用法 Vector。初始化为 Vector(0,0)。每个实体的效果和用法是手动定义的。对于某些实体,它也可能根本无法使用。


V2⚓︎

Vector V2⚓︎

通常用于 AI 特定操作的通用用法 Vector。初始化为 Vector(0,0)。每个实体的效果和用法是手动定义的。对于某些实体,它也可能根本无法使用。



Last update: September 6, 2025