ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

Penguins Attack TD 2 - Enemies gets shot even if dead.

Open desertking opened this issue 2 years ago • 1 comments

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

desertking avatar Sep 20 '22 11:09 desertking

(changed title, as it's an AS2 game. I imagine it's related to https://github.com/ruffle-rs/ruffle/issues/1513 )

adrian17 avatar Sep 20 '22 13:09 adrian17

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.

thomasyang18 avatar Oct 02 '22 13:10 thomasyang18

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?

thomasyang18 avatar Oct 05 '22 20:10 thomasyang18

Been a while. This game seems to work now.

desertking avatar May 11 '23 06:05 desertking