ruffle
ruffle copied to clipboard
Penguins Attack TD 2 - Enemies gets shot even if dead.
Describe the bug
Hey,
this game almost works but it has some flaws especially that the dead enemies still get shot. https://www.newgrounds.com/portal/view/534198?emulate=flash
Expected behavior
Die and don't be shot anymore.
Affected platform
Self-hosted version
Operating system
All
Browser
No response
Additional information
No response
(changed title, as it's an AS2 game. I imagine it's related to https://github.com/ruffle-rs/ruffle/issues/1513 )
Hi, currently looking into this. Just wanted to log another minor bug:
- If you spam a bunch of waves and lose on purpose, then play the round again, a ton of them come swarming into the beginning. Wave counter is glitched as well.
This doesn't happen on the normal flash player. Weird.
Okay, here's my theory:
In the killEnemy function, how the game maker decided to delete the enemy is by calling "Array.splice(i,1)" to delete 1 element at the current index. Fair enough. The author, afaik, doesn't do any check to actually delete the enemy - all that ever happens is that it gets spliced out.
However, the tower class has a "target" pointer. So it points back to the dead enemy. So whatever enemy its pointing to gets kept alive because theres a pointer to it, while the rest get freed by the gc. That's why you only get +5 money instead of the whole group (if you use missile towers for example), even though you killed multiple enemies.
Wild theory is that Adobe meant to actually delete the target elements when calling splice instead of just removing the array references to them, but I doubt it. I've never programmed in flash, and the FlashMX thing I'm reading says this:
Method; adds and removes elements from an array. This method modifies the array without
making a copy.
for Array.splice(). Doesn't sound like any of them is "delete the underlying object as well" instead of just removing the references.
Looking more into it.
edit: nvm, the author deletes the movieclip, i'm just blind lol. Still think it's something weird with the tower's target pointer not being reset at all. Maybe removeMC in rust doesn't delete the actor fully?
Been a while. This game seems to work now.