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

In turn-based battles, non-blocking attacks delayed by X attacks will delay up to X turns #1118

Closed
rversteegen opened this issue Apr 24, 2020 · 2 comments
Labels
attacks bug Yeah... that's broken rel: fufluns Present in fufluns 2020-01-12

Comments

@rversteegen
Copy link
Contributor

The "Delay/Advance attack by X attacks" setting (turn-based battles only) is meant to change the order in which attacks happen during a single turn, but it seems to cause a delay by that many turns instead if combined with a turn delay

Feenick: another attack delay-related bug: it seems that attacks delayed by attacks can go off into another turn [as opposed to being guaranteed to be at the end of the turn, as I was intending to use the function]
tmc: is the "Delay doesn't block further actions" bit on? is the attack part of a chain?
Feenick: Yeah, both of those are the case
tmc: is it the start of the chain? end? does the rest of the chain have any delays? I think I'd have to see the .rpg
Feenick: It's a one-turn delay with an additional 1-attack delay. It's the second in a chain

Here's a testcase Feenick sent me; the hero's attack chains to an attack with a delay of 1 turn and 4 attacks: delaytest.zip
You can see the attacks build up in the queue.

Incidentally this "Delay/advance attack" setting is so confusingly named that I was initially very confused, and then really struggled to refer to it while writing this bug.

@rversteegen rversteegen added bug Yeah... that's broken attacks rel: nightlies Present in nightly builds (after a release, replace with the release tag) labels Apr 24, 2020
@rversteegen
Copy link
Contributor Author

rversteegen commented Apr 25, 2020

I've found that the cause of the bug is here in pending_attacks_for_this_turn:

 'Check for queued attacks
 FOR i as integer = 0 TO UBOUND(atkq)
  WITH atkq(i)
   'Ignore unused atkq() slots, attacks with a turn delay, and stunned attackers
   IF atkq_attack_active(atkq(i), bslot()) THEN
    '--only blocking queued attacks are considered part of the current
    ' turn (although it is always perfectly possible for a nonblocking
    ' attack to happen in the current turn)
    ' FIXME: Why?! This doesn't look correct - won't it cause us to the next
    ' round even if there are attacks left?
    IF .blocking THEN RETURN YES
   END IF
  END WITH
 NEXT i

 RETURN NO

Replacing IF .blocking THEN RETURN YES with RETURN YES fixes the problem.
So the bug doesn't happen if the attack is blocking. However there's no way I'm making that change right before release.

I added that FIXME comment a year and a half ago but because the comment above it so confidently claimed that this was correct I didn't want to change it.

Also in r10640 (d82875b) I added a comment about attacks (in turn-based mode) getting "shunted" to the next round even if they don't have a turn delay, and fixed another resulting bug. I'm pretty sure I was referring to this behaviour. That fix might need revisiting too.

@rversteegen rversteegen changed the title Delaying by X attacks delays by X turns instead when there's also a turn delay In turn-based battles delaying by X attacks can delay by up to X turns May 10, 2020
@rversteegen rversteegen changed the title In turn-based battles delaying by X attacks can delay by up to X turns In turn-based battles, non-blocking attacks delayed by X attacks will delay up to X turns May 10, 2020
@rversteegen rversteegen added rel: fufluns Present in fufluns 2020-01-12 and removed rel: nightlies Present in nightly builds (after a release, replace with the release tag) labels May 10, 2020
@rversteegen
Copy link
Contributor Author

Fixed r11813 (82a636c)
The testcase Feenick provided has an attack with a delay of 1 turn and 4 attacks, but the bug happens if the turn delay is zero too. Therefore I think lots of games encounter/rely on this bug, so I've added a "Non-turn attack delays can also cause turn delays" backcompat bit to get the old behaviour.

rversteegen added a commit that referenced this issue May 10, 2020
…elay up to X turns

Added "Non-turn attack delays can also cause turn delays" backcompat bit

git-svn-id: https://rpg.hamsterrepublic.com/source/wip@11813 7d344553-34f0-0310-a9b1-970ce8f1c3a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attacks bug Yeah... that's broken rel: fufluns Present in fufluns 2020-01-12
Projects
None yet
Development

No branches or pull requests

1 participant