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

Problems with Electricman 2 #9594

Open
n0samu opened this issue Feb 16, 2023 · 6 comments
Open

Problems with Electricman 2 #9594

n0samu opened this issue Feb 16, 2023 · 6 comments
Labels
A-avm1 Area: AVM1 (ActionScript 1 & 2) bug Something isn't working timeline Issues relating to timeline animation

Comments

@n0samu
Copy link
Member

n0samu commented Feb 16, 2023

With the panic in #4932 soon to be fixed by #9447, I figured now is a good time to list the remaining issues with Electricman 2. This issue describes the state of the game with the current code in #9447 (at the time of writing).

The first noticeable issue with the game is the one described in #6261. Rapidly clicking the level buttons does work, at least for me.

Compared to the original Electricman 2, Electricman 2 HS is far more playable in Ruffle. That's because Electricman 2 HS allows you to skip the tutorial, which is the part of the game that is most buggy in Ruffle.

If you try to play through the tutorial, all of the lessons after the first "defeat the hologram" exercise will be skipped, but the enemies from the skipped exercises will still be spawned - into the menu! And when you start the first level, you have to fight the enemies that were supposed to be in the tutorial, too. Those enemies start attacking you even before the level countdown finishes.

electricman_tutorial.mp4

If you skip the tutorial in Electricman 2 HS, the game works much better at first. But it's possible to trigger a very similar bug by leaving a match in the middle, then starting a different match:

electricman_leavematch.mp4

If you skip the tutorial, the first 4 matches should work fine as long as you don't quit out of any of them. However, match 5 (the first match of round 2) will be impossible to complete because the game will not recognize when you have defeated all of the enemies.

When problems are occurring or about to occur, one or both of these warnings always seems to be spammed:
WARN run_frame: ruffle_core::avm1::activation: SetProperty: Invalid target
WARN run_frame: ruffle_core::avm1::globals::movie_clip: MovieClip.swapDepths: Invalid target

@n0samu n0samu added bug Something isn't working timeline Issues relating to timeline animation A-avm1 Area: AVM1 (ActionScript 1 & 2) labels Feb 16, 2023
@n0samu
Copy link
Member Author

n0samu commented Feb 16, 2023

Copying #4932 (comment) for greater visibility:

@Aaron1011 has a branch that might help understand the issues with this game: https://github.com/Aaron1011/ruffle/tree/rewind_depth
Here are his messages on Discord explaining the issue:

It looks like you get avm1 to get the same clip at two different depths, by using 'swapDepths' and then rewinding
The rewind is not to the frame where the timeline object is added - it's just to a slightly earlier frame where nothing happens
ok, it looks like === is just doing something odd - calling getDepth on each object returns different values, as expected
So, https://www.kirupa.com/developer/actionscript/depths2.htm seems correct (as far as I've tested) - a rewind in avm1 wipes out the timeline, and forcibly overwrites anything at the timeline depth for every frame from frame 1 to your target frame
plus some weirdness where === doesn't seem to do pointer equality for MovieClip
and Electricman2 actually depends on this behavior
It tries and fails to remove a clip with a negative depth, but then that clip ends up getting overwriten due to a subsequent rewind
Because of the way it uses swapDepths, subsequent enemies end up with positive depths - this only happens when you kill the first tutorial enemy
So I suspect the author was completely unaware of this behavior, and it just happened to work for an entirely unrelated reason

And later conversation between Aaron and kmeisthax:

Aaron:

The test I linked shows that === evaluates to true
But they behave like two different objects
you can call getDepth on them and it returns different values
My guess is that === is actually checking some hidden properties (movie clip symbol ID or something)
which looks like an object identity check in all other situations

kmeisthax:

the instance number, perhaps?

Aaron:

Yeah, maybe

kmeisthax:

hmm... so instead of if !child.placed_by_script() in run_goto we need if depth < AVM1_DEPTH_BIAS or whatever we call it

Aaron:

we also need logic to remove other objects with depth < AVM1_DEPTH_BIAS

Since then, Aaron has added a test in #9583 to demonstrate the rewind issue.

@sombraguerrero
Copy link
Contributor

It is not always the case that the [previous] panic or the non-ending stage problem occurs at the same fights reproducibly. It tends to vary based on the sequence in which you play.

As a matter of record, I will note that one behavior that was also fixed with these changes is that when you are defeated, it is now a proper defeat. Prior (when the panic was still happening), if you were defeated, it was still responded to with a victory and you were allowed to continue.

@ZaydTheCoder
Copy link

This issue is not fixed? I am confused.

@Sapo-san
Copy link

just checked, still not fixed :/

@sombraguerrero
Copy link
Contributor

We don't claim this issue is fixed. Aspects of it have made progress, which is what the previous discussion is, but the issue is still open as there is still work to do on it. It may not seem like it from a user perspective, but the way this game is written is extremely convoluted and difficult to solve for.

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 timeline Issues relating to timeline animation
Projects
None yet
Development

No branches or pull requests

4 participants