Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
desertking opened this issue Sep 20, 2022 · 4 comments
Closed

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

desertking opened this issue Sep 20, 2022 · 4 comments
Labels
A-avm1 Area: AVM1 (ActionScript 1 & 2) bug Something isn't working

Comments

@desertking
Copy link

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 desertking added the bug Something isn't working label Sep 20, 2022
@desertking desertking changed the title Penguins Attack TD 3 - Enemies gets shot even if dead. (AS3) Penguins Attack TD 2 - Enemies gets shot even if dead. (AS3) Sep 20, 2022
@adrian17 adrian17 added the A-avm1 Area: AVM1 (ActionScript 1 & 2) label Sep 20, 2022
@adrian17 adrian17 changed the title Penguins Attack TD 2 - Enemies gets shot even if dead. (AS3) Penguins Attack TD 2 - Enemies gets shot even if dead. Sep 20, 2022
@adrian17
Copy link
Collaborator

(changed title, as it's an AS2 game. I imagine it's related to #1513 )

@thomasyang18
Copy link

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
Copy link

thomasyang18 commented Oct 5, 2022

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?

@desertking
Copy link
Author

Been a while. This game seems to work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-avm1 Area: AVM1 (ActionScript 1 & 2) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants