If you get an error saying "bad object", that means the object has already been destroyed, yes, and skeleton archer arrows (and medusa arrows, and trickster rocks) are indeed destroyed before a WallTriggerComponent's onActivate connector triggers. References to destroyed objects can still exist, but any attempt to index them other than indexing their class's methods, pass them to functions that expect an object, or assign keys to them will result in that error.
(In this context, "object" can mean a GameObject, like in this case, or a Component or other class like Champion or Map; they all have this in common).
There are a few workarounds you could use to ensure that the object hasn't been destroyed before sending it to your script. I think the easiest one would be to use this onActivate hook in the definitions of all your WallTriggerComponents:
Code: Select all
onActivate = function(self, entity)
-- Ensure the triggering entity is on the map, preventing already-destroyed objects (fragile ItemComponents, mainly) from triggering connectors.
for e in self.go.map:allEntities() do
if e == entity then
return true
end
end
return false -- Do not trigger connectors
end
(If you know your wall trigger can only be hit by projectiles in a few specific squares - most wall triggers can only be hit by projectiles in their own square unless you are using extreme projectile speeds, extreme time multipliers, or huge projectile colliders - then you can use one or a few entitiesAt() calls instead of allEntities() here, of course, which is faster in some circumstances, but as most dungeons will never have multiple wall triggers being triggered on the same frame, such an optimization is unlikely to be useful.)