TeamREPENTOGON / REPENTOGON

Script extender for The Binding of Isaac: Repentance
https://repentogon.com/
GNU General Public License v2.0
215 stars 23 forks source link

Unexpected behaviour when using entity:Kill() while iterating through FindInCapsule/FindInRadius #607

Open Spearkiller opened 3 months ago

Spearkiller commented 3 months ago

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:

Initially I had thought this was just an issue with FindInCapsule, but further testing has left me stumped.

Sylmir commented 3 months ago

Your title mentions FindInRadius in addition to FindInCapsule, but I can't seem to find any references to it in the description of the issue ? Did you do some tests with FindInRadius, or is it a typo in the title of the issue ? (I'm asking because I'm more familar with FindInRadius... Extremely questionable implementation, so what you describe would not surprise me that much if it applied to FindInRadius)

Spearkiller commented 3 months ago

oop, I mustve forgotten to mention it, but yes, I tested using FindInRadius as well.