Skip to content

NPC Manipulation Functions

ModCS.Npc.SetRect()

ModCS.Npc.SetRect(npc, left, top, right, bottom)
ModCS.Npc.SetRect(npc, rect)

Sets the Rect of npc to a Rect with left, top, right, bottom.

If a rect is specified, set the Rect of npc to that Rect instead.

ModCS.Npc.GetRect()

ModCS.Npc.GetRect(npc)

Returns npc's Rect.

ModCS.Npc.OffsetRect()

ModCS.Npc.OffsetRect(npc, left, top, right, bottom)

Adds left, top, right, bottom to the the left, top, right, bottom values of the Rect of npc.

right and bottom are optional parameters. If they are not specified, left and top will be used in their place instead.

ModCS.Npc.SetHitbox()

ModCS.Npc.SetHitbox(npc, front, top, back, bottom)
ModCS.Npc.SetHitbox(npc, rangerect)

Sets the hitbox of npc to a RangeRect with front, top, back, bottom.

If a rangerect is specified, set the hitbox of npc to that RangeRect instead.

Warning

When editing NPC hitboxes make sure that the front and back values of the hitbox are the same, otherwise you might get weird hitbox behavior.

ModCS.Npc.GetHitbox()

ModCS.Npc.GetHitbox(npc)

Returns the hitbox RangeRect of npc.

ModCS.Npc.SetViewbox()

ModCS.Npc.SetViewbox(npc, front, top, back, bottom)
ModCS.Npc.SetViewbox(npc, rangerect)

Sets the sprite offset of npc to a RangeRect with front, top, back, bottom.

If a rangerect is specified, set the sprite offset of npc to that RangeRect instead.

ModCS.Npc.GetViewbox()

ModCS.Npc.GetViewbox(npc)

Returns the sprite offset RangeRect of npc.

ModCS.Npc.ActCode()

ModCS.Npc.ActCode(npc, npctype)

npctype is an optional parameter. If not specified, it will be set to npc's id.

Runs the action code for NPC Type npctype to npc.

Note

This will run the vanilla act code for npctype. To run any overwritten act functions, run functions from the ModCS.Npc.Act array instead.

ModCS.Npc.IsHit()

ModCS.Npc.IsHit(npc)

Returns true if npc is being hit by a bullet. Returns false otherwise.

ModCS.Npc.Delete()

ModCS.Npc.Delete(npc)

Deletes npc. Same effect as <DNP.

ModCS.Npc.Kill()

ModCS.Npc.Kill(npc)

Kills npc.

ModCS.Npc.KillOnNextFrame()

ModCS.Npc.KillOnNextFrame(npc)

Sets npc for deletion on the next frame.

ModCS.Npc.Move()

ModCS.Npc.Move(npc)

Adds xm and ym of npc to npc's x and y.

ModCS.Npc.Move2()

ModCS.Npc.Move2(npc)

Adds xm2 and ym2 of npc to npc's x and y.

ModCS.Npc.TriggerBox()

ModCS.Npc.TriggerBox(npc, front, top, back, bottom)
ModCS.Npc.TriggerBox(npc, rangerect)

Returns true if the player is in a range of a RangeRect with front, top, back, bottom to npc. Returns false otherwise.

If a rangerect is specified, set the range used will be the one of the RangeRect instead.