• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • 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] Bug with the script for Knock Off?

I don't know if this is a bug or just a problem with my Essentials, but the move Knock Off doesn't seem to be getting a boost when used against a Pokemon with an item. After lots of testing, the move always did the same amount of damage no matter if an item was held or not. Here's the script for Knock Off, is there something wrong here? I'm pretty sure this is just the original, unedited script from Vanilla Essentials.

Code:
################################################################################
# Target drops its item. It regains the item at the end of the battle. (Knock Off)
# If target has a losable item, damage is multiplied by 1.5.
################################################################################
class PokeBattle_Move_0F0 < PokeBattle_Move
  def pbEffectAfterHit(attacker,opponent,turneffects)
    if !attacker.fainted? && !opponent.fainted? && opponent.item!=0 &&
       opponent.damagestate.calcdamage>0 && !opponent.damagestate.substitute
      if !attacker.hasMoldBreaker && opponent.hasWorkingAbility(:STICKYHOLD)
        abilityname=PBAbilities.getName(opponent.ability)
        @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",opponent.pbThis,abilityname,@name))
      elsif [email protected](opponent,opponent.item)
        itemname=PBItems.getName(opponent.item)
        opponent.item=0
        opponent.effects[PBEffects::ChoiceBand]=-1
        opponent.effects[PBEffects::Unburden]=true
        @battle.pbDisplay(_INTL("{1} dropped its {2}!",opponent.pbThis,itemname))
      end   
  end
end
  def pbModifyDamage(damagemult,attacker,opponent)
    if USENEWBATTLEMECHANICS &&
       [email protected](opponent,opponent.item)
       # Still boosts damage even if opponent has Sticky Hold
      return (damagemult*1.5).round
    end
    return damagemult
  end
end

I tried playing around with the damage multiplier part of the code, but nothing I did worked. Knock Off is listed in the correct move class of 0F0, Sticky Hold wasn't in play, and my Pokemon just held a Berry while the opponent did Knock Off. The Berry would be knocked off, but the move wasn't any more powerful.

Any ideas are appreciated. Thanks!
 
I don't know if this is a bug or just a problem with my Essentials, but the move Knock Off doesn't seem to be getting a boost when used against a Pokemon with an item. After lots of testing, the move always did the same amount of damage no matter if an item was held or not. Here's the script for Knock Off, is there something wrong here? I'm pretty sure this is just the original, unedited script from Vanilla Essentials.

Code:
################################################################################
# Target drops its item. It regains the item at the end of the battle. (Knock Off)
# If target has a losable item, damage is multiplied by 1.5.
################################################################################
class PokeBattle_Move_0F0 < PokeBattle_Move
  def pbEffectAfterHit(attacker,opponent,turneffects)
    if !attacker.fainted? && !opponent.fainted? && opponent.item!=0 &&
       opponent.damagestate.calcdamage>0 && !opponent.damagestate.substitute
      if !attacker.hasMoldBreaker && opponent.hasWorkingAbility(:STICKYHOLD)
        abilityname=PBAbilities.getName(opponent.ability)
        @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",opponent.pbThis,abilityname,@name))
      elsif [email protected](opponent,opponent.item)
        itemname=PBItems.getName(opponent.item)
        opponent.item=0
        opponent.effects[PBEffects::ChoiceBand]=-1
        opponent.effects[PBEffects::Unburden]=true
        @battle.pbDisplay(_INTL("{1} dropped its {2}!",opponent.pbThis,itemname))
      end   
  end
end
  def pbModifyDamage(damagemult,attacker,opponent)
    if USENEWBATTLEMECHANICS &&
       [email protected](opponent,opponent.item)
       # Still boosts damage even if opponent has Sticky Hold
      return (damagemult*1.5).round
    end
    return damagemult
  end
end

I tried playing around with the damage multiplier part of the code, but nothing I did worked. Knock Off is listed in the correct move class of 0F0, Sticky Hold wasn't in play, and my Pokemon just held a Berry while the opponent did Knock Off. The Berry would be knocked off, but the move wasn't any more powerful.

Any ideas are appreciated. Thanks!

The code doesn't actually seem to check that the item was knocked off, and a berry shouldn't be an unlosable item, so the only thing I can think of is that you might have USENEWBATTLEMECHANICS set to false?
 
The code doesn't actually seem to check that the item was knocked off, and a berry shouldn't be an unlosable item, so the only thing I can think of is that you might have USENEWBATTLEMECHANICS set to false?

Nope, USENEWBATTLEMECHANICS is set to true. It's weird! I'm going to experiment some more and see if I can get an alternate code to work.
 
FIXED!

Okay, after a bit of tweaking the original script, I got a fully-functioning code for Knock Off. This accounts for Sticky Hold, holding unlosable items like Mega Stones, and for unlocking you from the effects of Choice items. Damage increases at the appropriate times. Here's the modified code:

Code:
################################################################################
# Target drops its item. It regains the item at the end of the battle. (Knock Off)
# If target has a losable item, damage is multiplied by 1.5.
################################################################################
class PokeBattle_Move_0F0 < PokeBattle_Move
  def pbEffectAfterHit(attacker,opponent,turneffects)
    if !attacker.fainted? && !opponent.fainted? && opponent.item!=0 &&
       opponent.damagestate.calcdamage>0 && !opponent.damagestate.substitute
      if [email protected](opponent,opponent.item) && !opponent.hasWorkingAbility(:STICKYHOLD)
        itemname=PBItems.getName(opponent.item)
        opponent.item=0
        opponent.effects[PBEffects::ChoiceBand]=-1
        opponent.effects[PBEffects::Unburden]=true
        @battle.pbDisplay(_INTL("{1} dropped its {2}!",opponent.pbThis,itemname))
      elsif !attacker.hasMoldBreaker && opponent.hasWorkingAbility(:STICKYHOLD)
        abilityname=PBAbilities.getName(opponent.ability)
        @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",opponent.pbThis,abilityname,@name))
      end   
    end
  end
  def pbModifyDamage(damagemult,attacker,opponent)
    if USENEWBATTLEMECHANICS && opponent.item!=0 && [email protected](opponent,opponent.item)
       # Still boosts damage even if opponent has Sticky Hold
      return (damagemult*1.5).round
    end
    return damagemult
  end
end

EDIT: Fixed with Maruno's suggestion! I didn't realize Knock Off wouldn't get the damage boost when used on unlosable items. The code is updated to remedy this.
 
Last edited:
The one downside with your "fix" is that Knock Off is not supposed to get a damage boost if the item is unlosable (e.g. is a usable Mega Stone or a Giratina with a Griseous Orb, etc.). Check Bulbapedia.
 
Back
Top