Solved Oricorios'ability script (Dancer)

WolfPP

Discord Wolf#1235
Member
Posts
90
#1
What we have about Dancer ability and works so far (made by mybusiness)
(DO NOT COPY, THIS IS JUST AN FEEDBACK):
In Move script, paste below 'def isBombMove?':
Code:
  def isDanceMove?
    return isConst?(@id,PBMoves,:QUIVERDANCE) ||
           isConst?(@id,PBMoves,:DRAGONDANCE) ||
           isConst?(@id,PBMoves,:FIERYDANCE) ||
           isConst?(@id,PBMoves,:FEATHERDANCE) ||
           isConst?(@id,PBMoves,:PETALDANCE) ||
           isConst?(@id,PBMoves,:SWORDSDANCE) ||
           isConst?(@id,PBMoves,:TEETERDANCE) ||
           isConst?(@id,PBMoves,:LUNARDANCE) ||
           isConst?(@id,PBMoves,:REVELATIONDANCE)
  end

Now, works fine for Status Move (Swords Dance i.e. but I still didn't test for Lunar Dance). Inside Battler script, use CTRL+F to find '# Try to use move against user if there aren't any targets', then, paste:
Code:
      else
        PBDebug.logonerr{
           thismove.pbEffect(user,nil)
        }
        # Dancer using non-damaging move
        if thismove.isDanceMove?
          for s in @battle.pbPriority(true)
            if s!=user && s.hasWorkingAbility(:DANCER) && !s.fainted?
              PBDebug.logonerr{
              thismove.pbEffect(s,nil)
              }
            end
          end
        end
      end
    else
      # We have targets

This is the move's details:
Code:
Whenever another Pokémon uses a dance move, a Pokémon with the Ability Dancer will immediately use that move as well. Using a move through Dancer is a separate action to using the move originally selected. Dancer will not activate for a move copied by another Pokémon with Dancer, but it will activate on an instructed dance move.

Dancer is able to copy a status dance move that has been powered up into its corresponding Z-Move (e.g. Z-Feather Dance), but the Pokémon with Dancer copies the regular version of the move and does not gain the additional Z-Power effect.

Dancer will not activate if the move's animation does not play (assuming battle animations are on): if all of the move's targets are protected from it, the move fails to affect any Pokémon (e.g. Teeter Dance if all of the targets are already confused or have Own Tempo), or all targets are immune (e.g. Electric-type Revelation Dance if the target is Ground-type). Dancer will not activate if the move is stolen by Snatch.

If multiple Pokémon have Dancer when a dance move is used, the slowest Pokémon will move first (Lagging Tail and Full Incense are ignored), even during Trick Room.

If the Pokémon with Dancer is confused, it may hurt itself instead of copying the move, even if it is protected by a move like Protect or Mat Block. If a Pokémon has flinched, this also applies to moves it subsequently tries to copy with Dancer. A Pokémon with Dancer that is locked into a consecutively executed move (such as Petal Dance) or any move by Encore or a held Choice item will still try to copy the move, but will fail unless it is locked into that same dance move; if a Pokémon uses Petal Dance via Dancer while locked into Petal Dance, this usage does not count towards the 2-3 turn duration. If a Pokémon with Dancer is holding an Assault Vest, it can still successfully copy status dance moves.

Lunar Dance is copied after the original user faints. If a Pokémon copies Petal Dance via Dancer, it will not be locked into the move. If Feather Dance is reflected by Magic Bounce or Magic Coat, Dancer will not activate for either the initial usage of the move or its reflected use. If the Pokémon with Dancer is under the effect of Taunt, it will still try to copy a status dance move, but will fail.

Moves used via Dancer can be stolen by Snatch and reflected by Magic Bounce and Magic Coat. Moves used via Dancer are not considered the move used most recently (such as for the purpose of Instruct, Mimic or Mirror Move), but damage dealt by them is considered for the purpose of Mirror Coat and Metal Burst.

In a Double Battle, if an ally uses a single-target dance move on an opponent, then the copied move will target the same opponent when copied by Dancer. Otherwise, a copied single-target dance move will target the user of the dance move.

Also, what we have for it (from Pokémon Reborn):
Battler script, paste below 'def pbUseMoveSimple(moveid,index=-1,target=-1)':
Code:
  def pbDancerMoveCheck(id)
    dancemoves = [17,63,138,170,192,418,420,483,669]
    for i in @battle.battlers
      next if i == self
      for j in dancemoves
        if id == j
          if i.hasWorkingAbility(:DANCER)
            @battle.pbDisplay(_INTL("{1} joined in with the dance!",i.pbThis))
            i.pbUseMoveSimple(id,-1,-1,true)
          end
        end
      end
    end
  end

Now you need add 'danced=false' in bouth defs:
def pbUseMove(choice,specialusage=false,danced=false)
def pbUseMoveSimple(moveid,index=-1,target=-1,danced=false)

Then, use CTRL+F to find '# We have targets' and add above (below 'else'):
Code:
      unless !thismove
        pbDancerMoveCheck(thismove.id) unless danced      
      end      
    else
      # We have targets
      showanimation=true
      alltargets=[]
And now, add the code like I did:
Code:
        # Get the number of hits
        numhits=thismove.pbNumHits(user)        
        # Reset damage state, set Focus Band/Focus Sash to available
        target.damagestate.reset
        # Use move against the current target
        pbProcessMoveAgainstTarget(thismove,user,target,numhits,turneffects,false,alltargets,showanimation)
        showanimation=false
        i+=1
      end
      unless !thismove
        pbDancerMoveCheck(thismove.id) unless danced
      end
    end
    # Pokémon switching caused by Roar, Whirlwind, Circle Throw, Dragon Tail, Red Card

But we still have these bugs to fix:
Code:
*Dancer will not activate for a move copied by another Pokémon with Dancer, but it will activate on an instructed dance move.
For first part, I think 'if k!=user && !k.fainted?' solved it but IDK about the second part.

*Dancer will not activate if the move is stolen by Snatch.
We need to put some '&& !thismove.effects[PBEffects::Snatch]' or something;

*If multiple Pokémon have Dancer when a dance move is used, the slowest Pokémon will move first (Lagging Tail and Full Incense are ignored), even during Trick Room.
IDK if mybusiness made 'for k in @battle.pbPriority(true)' for that case;

*If the Pokémon with Dancer is confused, it may hurt itself instead of copying the move, even if it is protected by a move like Protect or Mat Block. 
We need to put some 'if k.effects[PBEffects::Confusion]>0; pbConfusionDamage' or something;

A Pokémon with Dancer that is locked into a consecutively executed move (such as Petal Dance) or any move by Encore or a held Choice item will still try to copy the move, but will fail unless it is locked into that same dance move; 

if a Pokémon uses Petal Dance via Dancer while locked into Petal Dance, this usage does not count towards the 2-3 turn duration. 

*Lunar Dance is copied after the original user faints.
I will check that later...

*If a Pokémon copies Petal Dance via Dancer, it will not be locked into the move. 
What mybusiness did and Pokémon Reborn has that bug. How can we fix it?

If Feather Dance is reflected by Magic Bounce or Magic Coat, Dancer will not activate for either the initial usage of the move or its reflected use. 

*If the Pokémon with Dancer is under the effect of Taunt, it will still try to copy a status dance move, but will fail.
We need to put some 'if k.effects[PBEffects::Taunt]>0; thismove.pbMoveFailed(user,target)' or something, IDK yet.

Moves used via Dancer can be stolen by Snatch and reflected by Magic Bounce and Magic Coat. Moves used via Dancer are not considered the move used most recently (such as for the purpose of Instruct, Mimic or Mirror Move), but damage dealt by them is considered for the purpose of Mirror Coat and Metal Burst.

In a Double Battle, if an ally uses a single-target dance move on an opponent, then the copied move will target the same opponent when copied by Dancer. Otherwise, a copied single-target dance move will target the user of the dance move.
How can we fix the bugs?
 

WolfPP

Discord Wolf#1235
Member
Posts
90
#2
What I made so far (need script for Feather Dance and Petal Dance:
For "Snatch" situation:
Add a new code for "Snatched" in 'PBEffects' script:
Code:
    Snatched           = XXX #Will be your last number
Now, 'PokeBattle_Battler' script, use CTRL+F to add between the code, the new one:
Code:
    @effects[PBEffects::SmackDown]        = false
    @effects[PBEffects::Snatch]           = false
    @effects[PBEffects::Snatched]         = false
    @effects[PBEffects::SpikyShield]      = false
    @effects[PBEffects::Stockpile]        = 0
Use Ctrl+F to add inside here:
Code:
    # Try to use move against user if there aren't any targets
    if targets.length==0
      user=pbChangeUser(thismove,user)
      if thismove.target==PBTargets::SingleNonUser ||
         thismove.target==PBTargets::RandomOpposing ||
         thismove.target==PBTargets::AllOpposing ||
         thismove.target==PBTargets::AllNonUsers ||
         thismove.target==PBTargets::Partner ||
         thismove.target==PBTargets::UserOrPartner ||
         thismove.target==PBTargets::SingleOpposing ||
         thismove.target==PBTargets::OppositeOpposing
        @battle.pbDisplay(_INTL("But there was no target..."))
      else
        PBDebug.logonerr{
           thismove.pbEffect(user,nil)
        }
        # Dancer using non-damaging move
        if thismove.isDanceMove?
          for s in @battle.pbPriority(true)
            if s!=user && s.hasWorkingAbility(:DANCER) && !s.fainted?
              PBDebug.logonerr{
              thismove.pbEffect(s,nil)
              }
            end
          end
        end
      end
    else
      # We have targets

Inside 'def pbChangeUser(thismove,user)', add 'i.effects[PBEffects::Snatched]=true':
Code:
  def pbChangeUser(thismove,user)
    # Change user to user of Snatch
    if thismove.canSnatch?; priority=@battle.pbPriority
      for i in priority
        if i.effects[PBEffects::Snatch]
          @battle.pbDisplay(_INTL("{1} snatched {2}'s move!",i.pbThis,user.pbThis(true)))
          PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Snatch made it use #{user.pbThis(true)}'s #{thismove.name}")
          i.effects[PBEffects::Snatched]=true
          i.effects[PBEffects::Snatch]=false; target=user; user=i
          # Snatch's PP is reduced if old user has Pressure
          userchoice=@battle.choices[user.index][1]
          if target.hasWorkingAbility(:PRESSURE) && user.pbIsOpposing?(target.index) && userchoice>=0
            pressuremove=user.moves[userchoice]
            pbSetPP(pressuremove,pressuremove.pp-1) if pressuremove.pp>0
          end
          break if USENEWBATTLEMECHANICS
        end
      end
    end
    return user
  end

Same in 'def pbChangeTarget(thismove,userandtarget,targets)':
Code:
    # Change user to user of Snatch
    if thismove.canSnatch?
      for i in priority
        if i.effects[PBEffects::Snatch]
          @battle.pbDisplay(_INTL("{1} Snatched {2}'s move!",i.pbThis,user.pbThis(true)))
          PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Snatch made it use #{user.pbThis(true)}'s #{thismove.name}")
          i.effects[PBEffects::Snatched]=true
          i.effects[PBEffects::Snatch]=false; target=user; user=i
          # Snatch's PP is reduced if old user has Pressure
          userchoice=@battle.choices[user.index][1]
          if target.hasWorkingAbility(:PRESSURE) && user.pbIsOpposing?(target.index) && userchoice>=0
            PBDebug.log("[Ability triggered] #{target.pbThis}'s Pressure (part of Snatch)")
            pressuremove=user.moves[userchoice]
            pbSetPP(pressuremove,pressuremove.pp-1) if pressuremove.pp>0
          end
        end
      end
    end
    if thismove.canMagicCoat?
      if target.effects[PBEffects::MagicCoat]

Then, in 'def pbBeginTurn(choice)' add:
Code:
    @effects[PBEffects::Snatched]=false #
    @effects[PBEffects::Grudge]=false
    # Reset Parental Bond's count
    @effects[PBEffects::ParentalBond]=0
In PokeBattle_Move, paste above 'def doesCallOtherMoves?':
Code:
  def isDanceMove?
    if isConst?(@id,PBMoves,:QUIVERDANCE) || isConst?(@id,PBMoves,:DRAGONDANCE) ||
    isConst?(@id,PBMoves,:FEATHERDANCE)|| isConst?(@id,PBMoves,:SWORDSDANCE) ||
    isConst?(@id,PBMoves,:TEETERDANCE) || isConst?(@id,PBMoves,:LUNARDANCE)
      priority=@battle.pbPriority
      for i in priority
        if i.effects[PBEffects::Snatched]
          return false
        end
      end
      for i in 0...4
        dancer=@battle.battlers[i]; next if dancer==i
        if dancer.effects[PBEffects::Confusion]>0; dancer.damagestate.reset
          confmove=PokeBattle_Confusion.new(@battle,nil); confmove.pbEffect(dancer,dancer)
          if dancer.fainted?; dancer.pbFaint
          else; @battle.pbDisplay(_INTL("It hurt itself in its confusion!")); return false
          end
        end
      end
      for k in @battle.battlers
        if k.effects[PBEffects::Taunt]>0 &&
        (isConst?(@id,PBMoves,:QUIVERDANCE) || isConst?(@id,PBMoves,:DRAGONDANCE) ||
        isConst?(@id,PBMoves,:FEATHERDANCE)|| isConst?(@id,PBMoves,:SWORDSDANCE) ||
        isConst?(@id,PBMoves,:TEETERDANCE) || isConst?(@id,PBMoves,:LUNARDANCE))
          @battle.pbDisplay(_INTL("But it failed!")); return false
        end
        if k.effects[PBEffects::ChoiceBand]>=0 &&
        (k.hasWorkingItem(:CHOICEBAND) || k.hasWorkingItem(:CHOICESPECS) || k.hasWorkingItem(:CHOICESCARF))
          hasmove=false
          for i in 0...4
            if k.moves[i].id==k.effects[PBEffects::ChoiceBand]; hasmove=true; break; end
          end
          if hasmove && thismove.id!=k.effects[PBEffects::ChoiceBand]
            @battle.pbDisplay(_INTL("But it failed!")); return false
          end
        end
        if k.effects[PBEffects::Encore]>0 && k.choices[idxPokemon][1]!=k.effects[PBEffects::EncoreIndex]
          @battle.pbDisplay(_INTL("But it failed!")); return false
        end
      end
      return true
    elsif isConst?(@id,PBMoves,:PETALDANCE) # WIP
      for i in 0...4
        dancer=@battle.battlers[i]; next if dancer==i
        if dancer.effects[PBEffects::Confusion]>0; dancer.damagestate.reset
          confmove=PokeBattle_Confusion.new(@battle,nil); confmove.pbEffect(dancer,dancer)
          if dancer.fainted?; dancer.pbFaint
          else; @battle.pbDisplay(_INTL("It hurt itself in its confusion!")); return false
          end
        end
      end
      turneffects=[]
      turneffects[PBEffects::SpecialUsage]=false
      return true
    elsif isConst?(@id,PBMoves,:REVELATIONDANCE) || isConst?(@id,PBMoves,:FIERYDANCE)
      for i in 0...4
        dancer=@battle.battlers[i]; next if dancer==i
        if dancer.effects[PBEffects::Confusion]>0; dancer.damagestate.reset
          confmove=PokeBattle_Confusion.new(@battle,nil); confmove.pbEffect(dancer,dancer)
          if dancer.fainted?; dancer.pbFaint
          else; @battle.pbDisplay(_INTL("It hurt itself in its confusion!")); return false
          end
        end
      end
      return true
    end
  end

And add 'attr_accessor(:damagestate)' in 'class PokeBattle_Move', like:
Code:
class PokeBattle_Move
  attr_accessor(:id)
  attr_reader(:battle)
  attr_reader(:name)
  attr_reader(:function)
  attr_reader(:basedamage)
  attr_reader(:type)
  attr_reader(:accuracy)
  attr_reader(:addlEffect)
  attr_reader(:target)
  attr_reader(:priority)
  attr_reader(:flags)
  attr_reader(:thismove)
  attr_accessor(:pp)
  attr_accessor(:totalpp)
  attr_accessor(:damagestate) #

Need code if attacker has positive/negative buf=6 or move failed and then, won't trigger the ability because didn't have animation.
Need code for Petal Dance situation (specialusage=false or something. P.S: If dancer uses Petal Dance and DANCER one, won't count its official move)
Need code for slowest Dancer trigger its ability first (ignoring Lagging Tail/Full Incense nor Trick Room)
 
Top