• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Forcing two-turn moves to end early?

  • 220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    It's a move that's supposed to stop moves like solar beam and razor wind early (possible dig, sky attack and the likes too), but my rudimentary attempt just results in "but it failed" for each pokemon it's used on.

    Code:
    class Pokebattle_Move_216 < PokeBattle_Move
      def pbEffect(opponent)
        return opponent.effects[PBEffects::TwoTurnAttack]==0
      end
    end
     
  • 188
    Posts
    9
    Years
    • Seen May 16, 2024
    You'll have to create and initialise a new effect in PBEffects and PokeBattle_Battler for this to work. The effect will have a boolean (true/false) value. I'll call it Interrupted, but you can use just about any name. In PokeBattle Move add this code:
    Code:
      def pbDisplayUseMessage(attacker)
      # Return values:
      # -1 if the attack should exit as a failure
      # 1 if the attack should exit as a success
      # 0 if the attack should proceed its effect
      # 2 if Bide is storing energy
        [COLOR=Red]if attacker.effects[PBEffects::Interrupted]
          @battle.pbDisplayBrief(_INTL("{1}'s move was interrupted!",attacker.pbThis))
          [/COLOR][COLOR=Red][COLOR=Red]attacker.effects[PBEffects::Interrupted]=false[/COLOR]
          return -1
        end
    [/COLOR]    @battle.pbDisplayBrief(_INTL("{1} used\r\n{2}!",attacker.pbThis,name))
        return 0
      end
    In PokeBattle_MoveEffects change your initial code to this:
    Code:
    class PokeBattle_Move_216 < PokeBattle_Move
      [COLOR=Red]def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        ret=super(attacker,opponent,hitnum,alltargets,showanimation)
        [COLOR=Green]# if the opponent is charging a two-turn attack[/COLOR]
        if opponent.effects[PBEffects::TwoTurnAttack]>0
          opponent.effects[PBEffects::TwoTurnAttack]=0 [/COLOR][COLOR=Red][COLOR=Red][COLOR=Green]# cancel the two-turn attack[/COLOR][/COLOR]
          opponent.effects[PBEffects::Interrupted]=true
        end
        return (@basedamage>0) ? ret : 0
     [COLOR=Black] end
    end
    This move would only interrupt the two-turn attack if the opponent has started charging it before use.
    [/COLOR][/COLOR]
     
  • 220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    Thanks!

    EDIT: So it only works if it outspeeds the opponent before it finishes using them move?
    Because it doesn't work if the pokemon uses a move, then the pokemon using this move uses this move in the same turn.
     
    Last edited:
  • 188
    Posts
    9
    Years
    • Seen May 16, 2024
    Here's how it would work:
    • The opponent is faster and starts charging a two-turn attack. The attacker uses move 0x216 and the opponent would be interrupted, therefore unable to attack next turn.
    • The attacker is faster and tries to use 0x216 before the opponent starts charging its two-turn attack. The move will act like a regular damaging move (or fail if the move is a status move—a few changes to the code will be needed for that to happen)
    • The attacker is faster and uses 0x216 before the opponent executes the two-turn attack (after charging it in the previous turn). The opponent will be interrupted and therefore be unable to execute the move.
    There are cases where the attack order would change during the duration of the two-turn move, but those are unlikely to occur. They are:
    • The opponent charges up a two-turn attack before the attacker uses its move. Next turn, the attacker uses a move higher in speed priority (e.g. Protect) and would therefore use its move before the two-turn move is executed.
    • The opponent charges its two-turn move after the attacker has moved and in the next turn, the opponent executes its move before the attacker can move. This can occur if the Speed stats are equal and both battlers use moves that are equal in speed priority.
     
  • 220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    This is what I've got (it's for a status move). Unfortunately it just reports "but it failed" for each pokemon. Maybe there's a failsafe in TwoTurnAttack?
    Code:
    class Pokebattle_Move_216 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        ret=super(attacker,opponent,hitnum,alltargets,showanimation)
        # if the opponent is charging a two-turn attack
        if opponent.effects[PBEffects::TwoTurnAttack]>0
          opponent.effects[PBEffects::TwoTurnAttack]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
        end
    #    return (@basedamage>0) ? ret : 0
      end
    end
     
  • 188
    Posts
    9
    Years
    • Seen May 16, 2024
    Here's the fix now that I know it's for a status move:
    Code:
    class Pokebattle_Move_216 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        # if the opponent is charging a two-turn attack
        if opponent.effects[PBEffects::TwoTurnAttack]>0
          opponent.effects[PBEffects::TwoTurnAttack]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
          return 0
        else
          @battle.pbDisplay("But it failed!")
          return -1
        end
      end
    end
     
  • 220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    It now ends the move early, but not in a failure. I tried changing this:
    Code:
        if attacker.effects[PBEffects::Interrupted][color=red]=True[/color]
          @battle.pbDisplayBrief(_INTL("{1}'s move was interrupted!",attacker.pbThis))
          attacker.effects[PBEffects::Interrupted]=false
          return -1
        end
    But then it says every move was interrupted.

    Also it doesn't seem to work at all as a priority move.

    EDIT: I may just give up on this move entirely, its so frustrating. I tried changing the report from "But it failed!" to "{1} was unaffected!" on a whim, and it's not even reaching that far before saying "But it failed!"
     
    Last edited:
  • 824
    Posts
    9
    Years
    You want to replace the single equals sign of the first line in your previous post to a double equals sign. So it reads like this:
    Code:
        if attacker.effects[PBEffects::Interrupted]==true

    Alternatively, you can completely remove the comparison to a true value, and make it read like so:
    Code:
        if attacker.effects[PBEffects::Interrupted]

    The way you have it now, it sets the Interrupted status to true, instead of checking if it's true.
     
  • 220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    This is what I currently have (that just returns "but it failed" all the time):
    Code:
    class Pokebattle_Move_216 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        # if the opponent is charging a two-turn attack
        if opponent.effects[PBEffects::TwoTurnAttack]>0
          opponent.effects[PBEffects::TwoTurnAttack]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
          return 0
        elsif opponent.effects[PBEffects::Outrage]>0
          opponent.effects[PBEffects::Outrage]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
          return 0
        elsif opponent.effects[PBEffects::Uproar]>0
          opponent.effects[PBEffects::Uproar]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
          return 0
        else
          @battle.pbDisplay(_INTL("{1} was unaffected!".opponent.pbThis))
          return -1
        end
      end
    end

    Code:
      def pbDisplayUseMessage(attacker)
      # Return values:
      # -1 if the attack should exit as a failure
      # 1 if the attack should exit as a success
      # 0 if the attack should proceed its effect
      # 2 if Bide is storing energy
        if attacker.effects[PBEffects::Interrupted]
          @battle.pbDisplayBrief(_INTL("{1}'s move was interrupted!",attacker.pbThis))
          attacker.effects[PBEffects::Interrupted]=false
          return -1
        end
        @battle.pbDisplayBrief(_INTL("{1} used\r\n{2}!",attacker.pbThis,name))
        return 0
      end

    Code:
    604,SOOTHESONG,Soothe Song,216,0,NORMAL,Status,0,30,0,08,1,bek,"A sweet song plays to calm even the most focused, frenzied spirits."
     

    jdprager

    OH MY GOD I FREAKING LOVE HYDREIGON
  • 19
    Posts
    7
    Years
    This is what I currently have (that just returns "but it failed" all the time):
    Code:
    class Pokebattle_Move_216 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        # if the opponent is charging a two-turn attack
        if opponent.effects[PBEffects::TwoTurnAttack]>0
          opponent.effects[PBEffects::TwoTurnAttack]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
          return 0
        elsif opponent.effects[PBEffects::Outrage]>0
          opponent.effects[PBEffects::Outrage]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
          return 0
        elsif opponent.effects[PBEffects::Uproar]>0
          opponent.effects[PBEffects::Uproar]=0 # cancel the two-turn attack
          opponent.effects[PBEffects::Interrupted]=true
          return 0
        else
          @battle.pbDisplay(_INTL("{1} was unaffected!".opponent.pbThis))
          return -1
        end
      end
    end

    Code:
      def pbDisplayUseMessage(attacker)
      # Return values:
      # -1 if the attack should exit as a failure
      # 1 if the attack should exit as a success
      # 0 if the attack should proceed its effect
      # 2 if Bide is storing energy
        if attacker.effects[PBEffects::Interrupted]
          @battle.pbDisplayBrief(_INTL("{1}'s move was interrupted!",attacker.pbThis))
          attacker.effects[PBEffects::Interrupted]=false
          return -1
        end
        @battle.pbDisplayBrief(_INTL("{1} used\r\n{2}!",attacker.pbThis,name))
        return 0
      end

    Code:
    604,SOOTHESONG,Soothe Song,216,0,NORMAL,Status,0,30,0,08,1,bek,"A sweet song plays to calm even the most focused, frenzied spirits."
    "cancel the two-turn attack" doesn't seem like a valid flag. (nevermind thats not a flag) Also, outrage and uproar aren't considered two-turn attacks by the game, partially because neither has a definite chance of only lasting two turns, and partially because they don't charge themselves, they repeat the move. You probably need to add additional code to the Interrupted itself to affect these two. Also Petal Blizzard, it is grass type outrage. I'd consider changing the flag for these specific moves to if the move, Interruption, was USED before a 2nd+ turn of Outrage, Uproar, etc. as opposed to the effect itself, which wouldn't affect these moves.
     
    Last edited:
  • 220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    "cancel the two-turn attack" doesn't seem like a valid flag. Also, outrage and uproar aren't considered two-turn attacks by the game, partially because neither has a definite chance of only lasting two turns, and partially because they don't charge themselves, they repeat the move. You probably need to add additional code to the Interrupted itself to affect these two. Also Petal Blizzard, it is grass type outrage

    Good thing it's not a flag then, and that that's only a comment, eh? :P
     
    Last edited:

    jdprager

    OH MY GOD I FREAKING LOVE HYDREIGON
  • 19
    Posts
    7
    Years
    Good thing it's not a flag then, and that that's only a comment, eh? :P

    Yeah you're right, I just realized that. I didn't notice the # earlier. The flag of the effect on those moves seems to be the problem, but it should be fixed if the game checks the use of the move itself. No promises though.
     
    Back
    Top