• 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.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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] More Ability Help

  • 158
    Posts
    6
    Years
    Hi! I'm stuck with another ability.

    It's called Echo Shield and it bounces back damage from Sound-based moves (except for Growl because it doesn't do any damage). I was thinking of copying the code for Rough Skin but I decided that it may be too difficult.

    Can someone help me please?
     
    You can start by checking the "i.pbRecoverHP ((i.totalhp / 16) .floor, true)" example commands in PokeBattle_Battle and create specific conditions for this ability.
     
    Using CTRL SHIFT F to open searching tool and read how that code works.
     
    Ok, I'll show you one of my methods to created a special situation in my project, but don't use exactly, it is only for you to have a basis of how to create.
    Spoiler:

    I hope I have helped, because my knowledge is also limited.
     
    Last edited:
    Ok, I'll show you one of my methods to created a special situation in my project, but don't use exactly, it is only for you to have a basis of how to create.
    Spoiler:

    I hope I have helped, because my knowledge is also limited.

    Okay but I want it so that the damage from the Sound-based move is bounced back at the attacker. It's like Counter, and so the Sound-based move's damage will be the same damage (or double) that is bounced back (if the attacker hits a Pokemon with Echo Shield with a Sound-based move eg Hyper Voice, the attacker will get hurt as well by the damage reflected back).
     
    Alright, let's do this!
    So starting from the top, you want an ability that's like Rough Skin, but for sound moves instead of contact moves.

    So, to start, let's take a look at the Rough Skin code

    Code:
            if (target.hasWorkingAbility(:ROUGHSKIN,true) ||
               target.hasWorkingAbility(:IRONBARBS,true)) && !user.fainted?
              if !user.hasWorkingAbility(:MAGICGUARD)
                PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
                @battle.scene.pbDamageAnimation(user,0)
                user.pbReduceHP((user.totalhp/8).floor)
                @battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
                   PBAbilities.getName(target.ability),user.pbThis(true)))
              end
            end

    Now we want to reflect the damage already taken. (You didn't say anything about it but I also made Soundproof pokemon immune to this effect because it's an echo.)
    Code:
            if target.hasWorkingAbility(:ECHOSHIELD,true) && !user.fainted? && move.isSoundBased?
              if !user.hasWorkingAbility(:MAGICGUARD) && !user.hasWorkingAbility(:SOUNDPROOF)
                PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
                @battle.scene.pbDamageAnimation(user,0)
                user.pbReduceHP(damage)
                @battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
                   PBAbilities.getName(target.ability),user.pbThis(true)))
              end
            end
    But, we can't just put this code under Rough Skin, because the if block it's sitting in is for contact moves only. We can instead place it under ANGERPOINT because Anger Point is in the block that's just for moves that dealt damage, no contact necessary. (So below line 1477 should be good in a clean project.)
     
    Last edited:
    Honestly to create custom skills I advise you to look at everything that is already done in essentials to learn how the codes work, so if you can not build a good structure you have total freedom to ask for help in the forums. Do not just rely on help, because not always someone will be able to solve a problem or situation that you want, I hope this does not happen. And as Vendily commented here, the code she created must work the way you asked.
     
    Honestly to create custom skills I advise you to look at everything that is already done in essentials to learn how the codes work, so if you can not build a good structure you have total freedom to ask for help in the forums. Do not just rely on help, because not always someone will be able to solve a problem or situation that you want, I hope this does not happen. And as Vendily commented here, the code she created must work the way you asked.

    Okay!
     
    Alright, let's do this!
    So starting from the top, you want an ability that's like Rough Skin, but for sound moves instead of contact moves.

    So, to start, let's take a look at the Rough Skin code

    Code:
            if (target.hasWorkingAbility(:ROUGHSKIN,true) ||
               target.hasWorkingAbility(:IRONBARBS,true)) && !user.fainted?
              if !user.hasWorkingAbility(:MAGICGUARD)
                PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
                @battle.scene.pbDamageAnimation(user,0)
                user.pbReduceHP((user.totalhp/8).floor)
                @battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
                   PBAbilities.getName(target.ability),user.pbThis(true)))
              end
            end

    Now we want to reflect the damage already taken. (You didn't say anything about it but I also made Soundproof pokemon immune to this effect because it's an echo.)
    Code:
            if target.hasWorkingAbility(:ECHOSHIELD,true) && !user.fainted? && move.isSoundBased?
              if !user.hasWorkingAbility(:MAGICGUARD) && !user.hasWorkingAbility(:SOUNDPROOF)
                PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
                @battle.scene.pbDamageAnimation(user,0)
                user.pbReduceHP(damage)
                @battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
                   PBAbilities.getName(target.ability),user.pbThis(true)))
              end
            end
    But, we can't just put this code under Rough Skin, because the if block it's sitting in is for contact moves only. We can instead place it under ANGERPOINT because Anger Point is in the block that's just for moves that dealt damage, no contact necessary. (So below line 1477 should be good in a clean project.)

    Thanks! I'll try that!
     
    Alright, let's do this!
    So starting from the top, you want an ability that's like Rough Skin, but for sound moves instead of contact moves.

    So, to start, let's take a look at the Rough Skin code

    Code:
            if (target.hasWorkingAbility(:ROUGHSKIN,true) ||
               target.hasWorkingAbility(:IRONBARBS,true)) && !user.fainted?
              if !user.hasWorkingAbility(:MAGICGUARD)
                PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
                @battle.scene.pbDamageAnimation(user,0)
                user.pbReduceHP((user.totalhp/8).floor)
                @battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
                   PBAbilities.getName(target.ability),user.pbThis(true)))
              end
            end

    Now we want to reflect the damage already taken. (You didn't say anything about it but I also made Soundproof pokemon immune to this effect because it's an echo.)
    Code:
            if target.hasWorkingAbility(:ECHOSHIELD,true) && !user.fainted? && move.isSoundBased?
              if !user.hasWorkingAbility(:MAGICGUARD) && !user.hasWorkingAbility(:SOUNDPROOF)
                PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
                @battle.scene.pbDamageAnimation(user,0)
                user.pbReduceHP(damage)
                @battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
                   PBAbilities.getName(target.ability),user.pbThis(true)))
              end
            end
    But, we can't just put this code under Rough Skin, because the if block it's sitting in is for contact moves only. We can instead place it under ANGERPOINT because Anger Point is in the block that's just for moves that dealt damage, no contact necessary. (So below line 1477 should be good in a clean project.)

    It works! Thank you! :D
     
    Back
    Top