TeamREPENTOGON / TeamREPENTOGON/REPENTOGON
Unexpected behaviour when using entity:Kill() while iterating through FindInCapsule/FindInRadius
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 345
- Forks
- 51
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 4
Description
I'm making a familiar (Which, in this situation, is technically a bomb due to complications regarding TryThrow not working on familiars, but that's besides the point but feel it worth mentioning just in case that plays a part in the issue) that when thrown, destroys any projectiles that it collides with. I have been doing this with
for k, v in pairs(Isaac.FindInCapsule(bomb:GetCollisionCapsule(), EntityPartition.BULLET)) do
v:Kill()
end
A note that this is done in a MC_PRE_BOMB_UPDATE callback. POST_BOMB_COLLISION does not fire in this circumstance.
When testing, I found that, inexplicably, enemies would randomly die when hit by my familiar/bomb.
After some further experimentation, I found that removing the v:Kill() call stopped this from happening.
Some other things I have tested/noticed:
- Sometimes, entities outside of the collision capsule would be killed instead.
- Doing
print(v.Type)always printed "9" into the console (EntityType.ENTITY_PROJECTILE) - Changing it to
if v:ToProjectile() then v:Kill() endhad no effect and npcs would continue to randomly die as before. - Using FindInRadius also demonstrated strange behaviour.
- Changing it to
Remove()works as expected. - Creating a table, copying all the entities to be killed into that table, and then doing a second iteration through that, also checking
if v:ToProjectile() thendid not stop non-projectiles being killed.
Initially I had thought this was just an issue with FindInCapsule, but further testing has left me stumped.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the report in an MC_PRE_BOMB_UPDATE callback with FindInCapsule and FindInRadius, comparing Kill() with Remove(). Then trace the bindings or entry points for FindInCapsule, FindInRadius, Entity:Kill(), and Entity:Remove() in the C++ code. Done means only the entities returned by the query are affected, with projectile filtering behaving consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- game-dev, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100