Author Topic: Stunned Worm Behavior  (Read 6971 times)

0 Members and 1 Guest are viewing this topic.

Offline xelnia

  • Administrator
  • Spring Jumper
  • *
  • Posts: 2869
  • Stop using 0.106
    • Twitch
    • Awards
Stunned Worm Behavior
« on: September 08, 2018, 04:32:40 am »
I played around the MAME debugger to see what I could learn about how the worms behave when stunned. This isn't code-level analysis so I can't claim that it's exhaustive or perfect, but all my observations seem to match the behavior described below.

Basically, each worm has a stun timer, and the timer counts down one value every two frames. 0 is included the time.

The upper vine worms on the gold board have the simplest stun behavior. Each spray sets the stun timer to $80, or 128. Since each value gets two frames, including 0, this means the upper vine worms will remain stunned for 258 frames. Every subsequent spray resets the timer to $80, no matter how fast or often they are sprayed, or if they've already been stunned and then un-stunned.

Ground worms are a bit more complicated. As most players know, the more you spray them the longer they remain stunned. There is, of course, a limit to this.

Each spray of a ground worm adds $30 to the timer, and the timer maxes out at $FF. So, with frame-perfect spraying directly underneath a worm it would only take 6 sprays to max out the timer ($30 > $60 > $90 > $C0 > $F0 >$FF). It would actually only take 6 frame-perfect frames to stun them from any position, but the window is a little tighter the further away you are.

The ground worm timer decrements the same way as the vine worms: one value every two frames, with 0 counting for two frames. So each $30 of the timer equates to 98 frames and the maximum timer value of $FF equates to 512 frames.

The crucial part of the ground worm stun cycle is that each spray only adds $30 to the timer, up to $FF; it doesn't matter how long the worm has been stunned or if it has been previously stunned. The longer you wait between sprays the more sprays it will take to reach $FF. In other words, if you get the maximum stun in the first 6 sprays, then wait 511 frames to spray again, it will take another 6 sprays to reach the full stun value again. So, if you delay successive sprays while dealing with other stuff on the board, it will take more and more sprays to reach the full stun value. If you spray twice, then deal with other bugs for too long, it might take another full 6 sprays to reach $FF instead of 4.

Vines Worms (Gold Board)

Frames|Real Time (60 Hz)|Real Time (60.6061 Hz)
Added to Timer (each spray)
258
4.300 seconds
4.257 seconds
Maximum Timer
258
4.300 seconds
4.257 seconds

Ground Worms (All Boards)

Frames|Real Time (60 Hz)|Real Time (60.6061 Hz)
Added to Timer (each spray)
98
1.633 seconds
1.617 seconds
Maximum Timer
512
8.533 seconds
8.448 seconds
"Do not criticize, question, suggest or opine anything about an upcoming CAG event, no matter how constructive or positive your intent may be. You will find nothing but pain and frustration, trust me. Just go, or don't go, and :-X either way!" -ChrisP, 3/29/15
Member for 11 Years snek CK Killscreener IGBY 2016 DKF Team Member IGBY 2015 DKF Team Member IGBY 2014 DKF Team Member DK Killscreener Blogger Twitch Streamer

Online homerwannabee

  • Spring Jumper
  • *
  • Posts: 2232
    • Awards
Re: Stunned Worm Behavior
« Reply #1 on: September 08, 2018, 05:50:22 am »
Very interesting.  I didn't know you had to shoot them that many times to max it out.  I knew it was a few times, but I had no idea it was 6, and probably 7 times because you are probably not going to do frame perfect sprays.  Now some questions.  Is this time the same for all difficulties?   Now what about the worms that climb down?  Does shooting them more than once increase the time for when they come back down again?  Even the gold board has worms that climb down.
"Perception forged in delusion and refined by pain"

-Ross Benzinger

"It's like we are able to play beautiful music out there, but no one can hear the instruments"

-Leon Shepard
Member for 11 Years Former DK3 World Record Holder DK Masters - Rank D DK Killscreener IGBY 2014 DKF Team Member CK Killscreener Submit a score for every DK3 track Blogger Twitch Streamer Former DKJR World Record Holder - MAME DKJR Killscreener DK3 Repetitive Blue Screener

Offline xelnia

  • Administrator
  • Spring Jumper
  • *
  • Posts: 2869
  • Stop using 0.106
    • Twitch
    • Awards
Re: Stunned Worm Behavior
« Reply #2 on: September 08, 2018, 07:13:50 am »
Very interesting.  I didn't know you had to shoot them that many times to max it out.  I knew it was a few times, but I had no idea it was 6, and probably 7 times because you are probably not going to do frame perfect sprays.  Now some questions.  Is this time the same for all difficulties?   Now what about the worms that climb down?  Does shooting them more than once increase the time for when they come back down again?  Even the gold board has worms that climb down.

Difficulty does not appear to affect the timers. The side-vine worms appear to work similarly but with some changes to the timer. If you spray them on the vine, the timer increments like it would if they were on the ground: $30 per spray. Those worms obviously don't pause; they turn around and head off the screen. Once sprayed, the timer starts decrementing, but this time it does so once every 3 frames instead of once every 2 frames. Also, 0 doesn't seem to be "counted" multiple times...once the timer hits 0 they head back towards the ground. But the slower decrementing means each spray delays them by 144 frames, instead of the ground-stun of 98 frames.

If you spray them enough that they leave the screen, it looks like the stun timer value is doubled, and that value becomes a new timer for how long they stay off screen. But this timer decrements once per frame. So, if a worm leaves the screen with $50 left on its stun timer, the wait timer becomes $50*2 = $A0. $A0 = 160, so that worm will stay off screen for 160 frames. I'm not sure exactly how the game does the math (that's a code-level thing), but my observations are within one frame/value of this doubling. Because the wait timer is only one byte, it can only hold up to $FF. If the stun timer is greater than $80 then it looks like it puts the difference between that value and $FF into the stun timer, then sets a flag that basically results in: "after the remainder has decremented, start again at $FF, decrement that AS WELL, then proceed with your regularly scheduled worming."

Say the stun timer is at $CD when the worm leaves the screen. $CD*2 = $19A. $19A can't be stored in one byte. $19A - $FF = $9B. So $9B is put into the wait timer and the byte next to it is set to 1...I'm assuming this is the flag. After $9B decrements to zero, the flag is also reset to 0, and the wait timer starts decrementing again from $FF. When that $FF hits zero, the worm comes back on the screen.
"Do not criticize, question, suggest or opine anything about an upcoming CAG event, no matter how constructive or positive your intent may be. You will find nothing but pain and frustration, trust me. Just go, or don't go, and :-X either way!" -ChrisP, 3/29/15
Member for 11 Years snek CK Killscreener IGBY 2016 DKF Team Member IGBY 2015 DKF Team Member IGBY 2014 DKF Team Member DK Killscreener Blogger Twitch Streamer

Online homerwannabee

  • Spring Jumper
  • *
  • Posts: 2232
    • Awards
Re: Stunned Worm Behavior
« Reply #3 on: September 08, 2018, 07:43:40 am »
So let me see if I understand.  When the worm goes off screen, the timer resets, and so therefore it doesn't matter how many times you shoot the worm because of the reset?
"Perception forged in delusion and refined by pain"

-Ross Benzinger

"It's like we are able to play beautiful music out there, but no one can hear the instruments"

-Leon Shepard
Member for 11 Years Former DK3 World Record Holder DK Masters - Rank D DK Killscreener IGBY 2014 DKF Team Member CK Killscreener Submit a score for every DK3 track Blogger Twitch Streamer Former DKJR World Record Holder - MAME DKJR Killscreener DK3 Repetitive Blue Screener

Offline xelnia

  • Administrator
  • Spring Jumper
  • *
  • Posts: 2869
  • Stop using 0.106
    • Twitch
    • Awards
Re: Stunned Worm Behavior
« Reply #4 on: September 08, 2018, 12:44:49 pm »
So let me see if I understand.  When the worm goes off screen, the timer resets, and so therefore it doesn't matter how many times you shoot the worm because of the reset?

The wait timer will reset when it comes back on screen, and the stun timer will have been set back to 0 by that point as well. But the more times you've sprayed a worm, the higher its stun timer will be (or retreat timer...whatever you want to call it when they turn around and leave). Therefore, the higher the stun/retreat timer is, the longer it will be off screen. The number of frames the worm will stay off screen is exactly 2/3 of however many frames were left on the stun/retreat timer when it left the screen. So if there were 99 frames left on the stun/retreat timer, it will stay off screen for 66 frames. When it comes back on screen, everything is back to 0 and you'll have to spray it as much as possible to regain a longer off screen time.

Position on the vine is important too, obviously. If you spray a worm 6 times when it's almost at the bottom, it won't make it off screen before it turns around. If it's a little higher, you might spray it 6 times, but it might be so far from the edge of the screen that the stun timer counts down to almost nothing just as it leaves the screen. So for maximum off screen time you would want to continuously spray it as it retreats, and you would want it to be far enough from the edge that you can nail it with 6 or 7 sprays before it leaves...so the very last spray maximizes the stun timer, and therefore the wait timer. I'm not sure how viable that is as a strategy, but it would be a way to get the thing off screen for almost 8.5 seconds.

Regardless, you have to start the whole process from scratch as soon as it comes back on screen.
"Do not criticize, question, suggest or opine anything about an upcoming CAG event, no matter how constructive or positive your intent may be. You will find nothing but pain and frustration, trust me. Just go, or don't go, and :-X either way!" -ChrisP, 3/29/15
Member for 11 Years snek CK Killscreener IGBY 2016 DKF Team Member IGBY 2015 DKF Team Member IGBY 2014 DKF Team Member DK Killscreener Blogger Twitch Streamer