• 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.

Gen VII Scripts (Z-Moves, Abilities and Moves,)

285
Posts
5
Years
  • Age 21
  • Seen Oct 1, 2023
Strength Sap
Code:
################################################################################
# Heals the user for an amount equal to the target's effective Attack stat
# Lowers the target's Attack by 1 stage
################################################################################
class PokeBattle_Move_1B5 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::HealBlock]>0
      bob="heal"
      bob=_INTL("use {1}",name) if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
      @battle.pbDisplay(_INTL("{1} can't {2} because of Heal Block!",attacker.pbThis,bob))
      return -1 if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
    elsif attacker.hp==attacker.totalhp
      @battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
      return -1 if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
    else
      oatk=opponent.attack
      attacker.pbRecoverHP(oatk,true)
      @battle.pbDisplay(_INTL("{1}'s HP was restored.",attacker.pbThis))
    end
    if opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
      opponent.pbReduceStat(PBStats::ATTACK,1,true,true,false,attacker)
    end
    return 0
  end
end

Hi, I was wondering if anyone has working code for Strength Sap, because I'm pretty sure this code is incorrect for the move. All versions of the move I have found make the same mistake this one does. On Bulbapedia, part of the description for the move is "Strength Sap lowers the target's Attack stat by one stage, then restores the user's HP by the same amount as the target's effective Attack stat before Strength Sap was used. The amount of HP restored depends on the Attack stat after applying stat stages." This means that if the target has increases/decreases in attack stat stages, an ability like Huge Power, etc. this will affect the amount healed. The code here (and where I could find it elsewhere) just takes the attack stat of the target instead of taking into consideration these important factors. Since the healing for this move is supposed to get weaker as you keep using it on the same Pokemon due to it decreasing the target's attack stage, this makes the move much more powerful than intended. (I verified that using the move multiple times against the same Pokemon, who successfully receives attack drops, heals the same exact amount each time).
 
3
Posts
10
Years
  • Seen Apr 4, 2024
NEW SCRIPT TO N-LUNARIZER AND N-SOLARIZER (thanks mybusiness to see the problem):
(Now when you have to separate Necrozma, you can use only N-Solarizer, to Solgaleo, and only N-Lunarizer to Lunala).
Spoiler:

I tried out the N-Solarizer and N-Lunarizer script, it says it didn't work, after I exit the party screen and uses the item from my bag, I see the necrozma remaining in it's fused form and the fused Pokémon (Solgaleo/Lunala) appears in my party. So I decided to work on my own items. Here's the code:
Spoiler:


Hope it helps.
 
285
Posts
5
Years
  • Age 21
  • Seen Oct 1, 2023
I tried out the N-Solarizer and N-Lunarizer script, it says it didn't work, after I exit the party screen and uses the item from my bag, I see the necrozma remaining in it's fused form and the fused Pokémon (Solgaleo/Lunala) appears in my party. So I decided to work on my own items. Here's the code:
Spoiler:


Hope it helps.

I was getting the same problem, but your code fixed it. Thanks!
 
7
Posts
3
Years
  • Age 33
  • Seen Jul 22, 2021
Pollen Puff
Code:
################################################################################
# If the target is an ally, heals the target for the amount of damage that would
#     have been dealt.  If target is an opponent, damages them normally.
################################################################################
class PokeBattle_Move_1B3 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.pbPartner != nil
      if attacker.pbPartner == opponent
        damage=pbCalcDamage(attacker,opponent,0,hitnum)
        opponent.pbRecoverHP(damage,true)
        return 0
      end
    end
    return super(attacker,opponent,hitnum,alltargets,showanimation)
  end
end

Floral Healing
Code:
################################################################################
# Heals target by 1/2 of its max HP.
# In Grassy Terrain, heals target by 3/4 of its max HP.
################################################################################
class PokeBattle_Move_1B4 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.effects[PBEffects::HealBlock]>0
      @battle.pbDisplay(_INTL("{1} can't use {2} because of Heal Block!",attacker.pbThis,name))
      return -1
    end
    if opponent.hp==opponent.totalhp
      @battle.pbDisplay(_INTL("{1}'s HP is full!",opponent.pbThis))
      return -1
    end
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    inc=0.5
    inc=0.75 if @battle.field.effects[PBEffects::GrassyTerrain]>0
    opponent.pbRecoverHP(((opponent.totalhp+1)*inc).floor,true)
    @battle.pbDisplay(_INTL("{1}'s HP was restored.",opponent.pbThis))
    return 0
  end
end

Strength Sap
Code:
################################################################################
# Heals the user for an amount equal to the target's effective Attack stat
# Lowers the target's Attack by 1 stage
################################################################################
class PokeBattle_Move_1B5 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::HealBlock]>0
      bob="heal"
      bob=_INTL("use {1}",name) if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
      @battle.pbDisplay(_INTL("{1} can't {2} because of Heal Block!",attacker.pbThis,bob))
      return -1 if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
    elsif attacker.hp==attacker.totalhp
      @battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
      return -1 if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
    else
      oatk=opponent.attack
      attacker.pbRecoverHP(oatk,true)
      @battle.pbDisplay(_INTL("{1}'s HP was restored.",attacker.pbThis))
    end
    if opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
      opponent.pbReduceStat(PBStats::ATTACK,1,true,true,false,attacker)
    end
    return 0
  end
end

Gear Up
Code:
################################################################################
# Gear Up
################################################################################
class PokeBattle_Move_1B6 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.pbPartner
      if attacker.pbPartner.hasWorkingAbility(:PLUS) ||
         attacker.pbPartner.hasWorkingAbility(:MINUS)
        anim=true
        if attacker.pbPartner.pbCanIncreaseStatStage?(PBStats::ATTACK,true)
          attacker.pbPartner.pbIncreaseStat(PBStats::ATTACK,1,true,anim)
          anim=false
        end
        if attacker.pbPartner.pbCanIncreaseStatStage?(PBStats::SPATK,true)
          attacker.pbPartner.pbIncreaseStat(PBStats::SPATK,1,true,anim)
        end
      end
    end
    return 0
  end
end

Speed Swap
Code:
################################################################################
# User and target swap their Speed stats
################################################################################
class PokeBattle_Move_1B7 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    attacker.speed,opponent.speed=opponent.speed,attacker.speed
    @battle.pbDisplay(_INTL("{1} switched their Speed stats!",attacker.pbThis))
    return 0
  end
end

Shore Up
Code:
################################################################################
# Heals user by 1/2 of its max HP.
# In a sandstorm, heals user by 3/4 of its max HP.
################################################################################
class PokeBattle_Move_1A3 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::HealBlock]>0
      @battle.pbDisplay(_INTL("{1} can't use {2} because of Heal Block!",attacker.pbThis,name))
      return -1
    end
    if attacker.hp==attacker.totalhp
      @battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
      return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    inc=0.5
    inc=0.75 if @battle.pbWeather==PBWeather::SANDSTORM
    attacker.pbRecoverHP(((attacker.totalhp+1)*inc).floor,true)
    @battle.pbDisplay(_INTL("{1}'s HP was restored.",attacker.pbThis))
    return 0
  end
end

Spotlight
Code:
################################################################################
# This round, target becomes the target of attacks that have single targets.
################################################################################
class PokeBattle_Move_1A6 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if [email protected]
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    opponent.effects[PBEffects::FollowMe]=true
    if !opponent.pbPartner.isFainted?
      opponent.pbPartner.effects[PBEffects::FollowMe]=false
    end
    @battle.pbDisplay(_INTL("{1} shone a spotlight on {2}!",attacker.pbThis,opponent.pbThis))
    return 0
  end
end

Revelation Dance
Code:
################################################################################
# Move type changes based on user's primary type
################################################################################
class PokeBattle_Move_192 < PokeBattle_Move
  def pbType(type,attacker,opponent)
    return attacker.type1
  end
end
(originally had this one coded a lot more complicated, where it checks to be sure the attacker is Oricorio, then goes by the form's primary type. Turns out it goes by primary type regardless of species.)

Instruct
Code:
################################################################################
# Instructs the target to use the move it last used again.
################################################################################
class PokeBattle_Move_194 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.lastMoveUsed<=0 ||
       (PBMoveData.new(opponent.lastMoveUsed).flags&0x10)==0 # flag e: Copyable by Mirror Move
      @battle.pbDisplay(_INTL("The instruction failed!"))
      return -1
    end
    opponent.pbUseMoveSimple(opponent.lastMoveUsed,-1,opponent.index)
    return 0
  end
end

For some reason after applying "Strength Sap" I keep getting an error message

Spoiler:


I've tried on a clean 17.2 script and the message still pops up. Can anyone tell me how I can fix it?
 
285
Posts
5
Years
  • Age 21
  • Seen Oct 1, 2023
For some reason after applying "Strength Sap" I keep getting an error message

Spoiler:


I've tried on a clean 17.2 script and the message still pops up. Can anyone tell me how I can fix it?

I think the problem is with this line putting true for the attacker: "if opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)". However, note that this version of Strength Sap is bugged because it doesn't take into account stat changes or Big Root when calculating HP restoration. Here it is with these problems fixed (wasn't sure about the formula for stat changes so I just put separate cases for each stat level):
Code:
################################################################################
# Heals the user for an amount equal to the target's effective Attack stat
# Lowers the target's Attack by 1 stage. (Strength Sap)
################################################################################
class PokeBattle_Move_CF13 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::HealBlock]>0
      bob="heal"
      bob=_INTL("use {1}",name) if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
      @battle.pbDisplay(_INTL("{1} can't {2} because of Heal Block!",attacker.pbThis,bob))
      return -1
    elsif attacker.hp==attacker.totalhp
      @battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
      return -1
    else
      oatk=opponent.attack
      case opponent.stages[PBStats::ATTACK]
      when -6
        oatk=(oatk*1/4).floor
      when -5
        oatk=(oatk*2/7).floor
      when -4
        oatk=(oatk*1/3).floor
      when -3
        oatk=(oatk*2/5).floor
      when -2
        oatk=(oatk*1/2).floor
      when -1
        oatk=(oatk*2/3).floor
      when 1
        oatk=(oatk*3/2).floor
      when 2
        oatk=(oatk*2).floor
      when 3
        oatk=(oatk*5/2).floor
      when 4
        oatk=(oatk*3).floor
      when 5
        oatk=(oatk*7/2).floor
      when 6
        oatk=(oatk*4).floor
      end
      oatk=(oatk*1.3).floor if attacker.hasWorkingItem(:BIGROOT)
      attacker.pbRecoverHP(oatk,true)
      @battle.pbDisplay(_INTL("{1}'s HP was restored.",attacker.pbThis))
      if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
        opponent.pbReduceStat(PBStats::ATTACK,1,attacker,false,self)
      end
    end
    return 0
  end
end
 
22
Posts
7
Years
  • Age 34
  • Seen May 15, 2023
Improved Pursuit's code (improved 12/30):
Spoiler:



Wimp Out and Emergency Exit:
Spoiler:


Hyperspace Hole:
Spoiler:

WolfPP
Hi!, I am using your new code for Pursuit and got this error when I try to use U-turn or a move with the same function:

Spoiler:


This is the code in PokeBattle_Battler in line 5692:

Spoiler:


Do you think the error could be due to that line or maybe it has to do with the achievements script that I have installed?
 
Back
Top