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

Fling doesn't check if move is successful before consuming item. #3001

Closed
SarnPoke opened this issue May 13, 2023 · 2 comments · Fixed by #3191
Closed

Fling doesn't check if move is successful before consuming item. #3001

SarnPoke opened this issue May 13, 2023 · 2 comments · Fixed by #3191

Comments

@SarnPoke
Copy link

When using Fling in battle, the item will always be consumed, even if the move isn't actually successfully used. For example, if a Pokémon is asleep and uses Fling, then it will sleep for the turn and the item will have been consumed erroneously. Another consequence of this is that if the Pokémon is not holding an item and uses Fling, the textbox that states how the move has failed will always print even when it's not supposed to.

The problem stems from BattleScript_EffectFling in data/battle_scripts_1.s

BattleScript_EffectFling:
    jumpifcantfling BS_ATTACKER, BattleScript_ButItFailedAtkStringPpReduce
    jumpifstatus3 BS_ATTACKER, STATUS3_EMBARGO, BattleScript_ButItFailedAtkStringPpReduce
    jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MAGIC_ROOM, BattleScript_ButItFailedAtkStringPpReduce
    setlastuseditem BS_ATTACKER
    removeitem BS_ATTACKER
    attackcanceler
    accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
    attackstring
    pause B_WAIT_TIME_SHORT
    printstring STRINGID_PKMNFLUNG
    waitmessage B_WAIT_TIME_SHORT
    ppreduce
    critcalc
    damagecalc
    ...

attackcanceler is used too late here and needs to be moved to the first line like so:

BattleScript_EffectFling:
    attackcanceler
    jumpifcantfling BS_ATTACKER, BattleScript_ButItFailedAtkStringPpReduce
    jumpifstatus3 BS_ATTACKER, STATUS3_EMBARGO, BattleScript_ButItFailedAtkStringPpReduce
    jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MAGIC_ROOM, BattleScript_ButItFailedAtkStringPpReduce
    setlastuseditem BS_ATTACKER
    removeitem BS_ATTACKER
    accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
    attackstring
    pause B_WAIT_TIME_SHORT
    printstring STRINGID_PKMNFLUNG
    waitmessage B_WAIT_TIME_SHORT
    ppreduce
    critcalc
    damagecalc
    ...

That's pretty much it.

@AsparagusEduardo
Copy link
Collaborator

Hmm according to Bulbapedia:

After using Fling, the item is consumed, even if the target was protected by a protection move.

And Smogon:

If there is no target or the target avoids this move by protecting itself, the user's held item is still lost.

This may be the reason why attackcanceler is below removeitem.
I can't find stuff regarding sleep, we need to check this issue in detail.

@SarnPoke
Copy link
Author

SarnPoke commented May 17, 2023

That was likely the intention behind the placement of attackcanceler though in it's current state it doesn't account for status moves and other things that stop the move before it is even fired.

The attackcanceler cmd seems to be responsible for checking both if a move was stopped by Protect and if a move was stopped by a status condition. If Fling is stopped by a status condition, the item should not be consumed, but if it's stopped by Protect it should. Some additional check may be required here.

Edit:
For clarification, status conditions do seem to actually stop the move itself when you have an item to fling, but it does not stop item deletion. And when you DON'T have an item to fling it will always print the failure string instead of properly displaying things like sleep status if present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants