ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

Champion Archer bow not working after first level

Open FynnFreyer opened this issue 3 years ago • 4 comments

Describe the bug

Steps to reproduce

  1. Load the game
  2. Finish the first level
  3. Try to shoot an arrow in the second level
  4. It doesn't shoot an arrow

SWF file

Champion Archer

Visual problems

None

Expected behavior

When you finish the first level, you can still use your bow afterwards.

Affected platform

Desktop app and browser demo

Operating system

Ubuntu 20.04

Browser

Firefox 96.0 (64-bit) on Ubuntu

Additional information

I did test this in the online demo and with the desktop app (linux-x86_64)

FynnFreyer avatar Jan 24 '22 19:01 FynnFreyer

Thanks for the report.

The issue is around these lines in \DefineSprite (157)\frame 1\PlaceObject2 (134) Depth: 5 (arms)\onClipEvent(load):

onClipEvent(load){
   if(_root.setListen != true)
   {
      click = new Object();
      click.onMouseDown = function()
      {
         trace(this._currentframe);
         trace(_currentframe);
         if(_currentframe == 1)
         {
            // code to shoot an arrow...
         }
...

_currentframe always holds a value of 1 in Flash Player, but on Ruffle the value changes to 3 when reaching the second level.

It appears the game was partially working in nightly-2021-10-13 and the older releases (it's possible to shoot arrows in the second level but there are other issues related to #5492), so it seems like the commit e9fbed7be0d33e47fe5cc522fc468ebbdfc4a2bf (PR #5465) introduced a regression.

@Herschel, maybe you have an idea of what's going on here?

Toad06 avatar Jan 24 '22 22:01 Toad06

Yes, when you e.g. play on addictinggames.com (nightly 2021-04-04) there is another issue with the bow (position doesn't update anymore). Just as an example of it 'working' in an older release.

Addictinggames is where I initially found this project btw, but I thought just mentioning my test with the newest nightly version might be better for clarity.

PS: Even though this might not be the right place, thanks a lot for putting work into this. I have many fond memories of old flash games, and this project helps keeping those available!

FynnFreyer avatar Jan 25 '22 12:01 FynnFreyer

5$ bounty: https://app.bountysource.com/issues/110151502-champion-archer-bow-not-working-after-first-level

Edit: While the bounty still stands, I do regret making it, per this blog post

dginovker avatar Jul 28 '22 05:07 dginovker

Thanks for the report.

The issue is around these lines in \DefineSprite (157)\frame 1\PlaceObject2 (134) Depth: 5 (arms)\onClipEvent(load):

onClipEvent(load){
   if(_root.setListen != true)
   {
      click = new Object();
      click.onMouseDown = function()
      {
         trace(this._currentframe);
         trace(_currentframe);
         if(_currentframe == 1)
         {
            // code to shoot an arrow...
         }
...

_currentframe always holds a value of 1 in Flash Player, but on Ruffle the value changes to 3 when reaching the second level.

It’s not so much that it stays at 3, but rather it stays at the last frame of the animation at the time of you releasing the primary mouse button when ending the level (you’ll notice that you begin to shoot as you press “Continue” if you hold the button).

If you again recall the ghost arrows being shot in the old nightlies that you mentioned, that is the reason why.

ernestask avatar Jul 31 '22 07:07 ernestask

On latest nightly, the issue is no longer that _currentframe is incorrect, but rather that _parent, referenced inside the code to shoot an arrow is set incorrectly. This happens because _root.warriors.champ gets removed when opening the shop window, and when the shop window is closed and a new level started, a new champ is created and added to the same path. However, the Avm1Function.base_clip of the set onMouseDown function still references the old champ, which is avm1_removed. It seems that Avm1Function.base_clip needs to be a string path, which will be resolved every time a function is executed. This ties in with #9447/#5492.

This is also probably what was behind the issues in earlier versions before the regression.

Lord-McSweeney avatar Dec 31 '23 05:12 Lord-McSweeney