• 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] Help for "Shaman Shield" ability

HeroesFightingFear

"The Champion of Alon"
99
Posts
4
Years
  • I want to make an ability that works as a Wonder Guard-like ability, but with the extra requirement of having at least one Ghost-type in the team with the ability's holder. If anyone can help, that'd be great, cause I can't wrap my head around how to do it.
     
    285
    Posts
    5
    Years
    • Seen Oct 1, 2023
    You can use this check to see if a Pokemon in the party has Ghost-type (I haven't tested this, but took it from something similar). You'll need to replace "user" in the first line with whoever the battler is that has the ability. This will exclude fainted Pokemon and the active Pokemon, but it's an easy fix if you want it to include them:
    Code:
        [email protected](user.index)
        partyGhost=false
        for i in 0...party.length
          next if attacker.pokemonIndex==i
          if party[i] && !party[i].egg? && party[i].hp>0 && party[i].hasType?(:GHOST)
            partyGhost=true
            break
          end
        end
    You can use the variable partyGhost for seeing if there's a ghost Pokemon in the party (true if there is, false otherwise). I'm not sure what you mean by "with the ability's holder", but you could add that check in "if party && !party.egg? && party.hp>0 && party.hasType?(:GHOST)"
     

    HeroesFightingFear

    "The Champion of Alon"
    99
    Posts
    4
    Years
  • You can use this check to see if a Pokemon in the party has Ghost-type (I haven't tested this, but took it from something similar). You'll need to replace "user" in the first line with whoever the battler is that has the ability. This will exclude fainted Pokemon and the active Pokemon, but it's an easy fix if you want it to include them:
    Code:
        [email protected](user.index)
        partyGhost=false
        for i in 0...party.length
          next if attacker.pokemonIndex==i
          if party[i] && !party[i].egg? && party[i].hp>0 && party[i].hasType?(:GHOST)
            partyGhost=true
            break
          end
        end
    You can use the variable partyGhost for seeing if there's a ghost Pokemon in the party (true if there is, false otherwise). I'm not sure what you mean by "with the ability's holder", but you could add that check in "if party && !party.egg? && party.hp>0 && party.hasType?(:GHOST)"


    I think I figured it out.
    I made a new section for the partyGhost variable
    Code:
    def pbPartyGhostCheck
      [email protected](:ABSOL.index)
        partyGhost=false
        for i in 0...party.length
          next if attacker.pokemonIndex==i
          if party[i] && !party[i].egg? && party[i].hp>0 && party[i].hasType?(:GHOST)
            partyGhost=true
            break
          end
        end

    And had Shaman Shield run off of the partyGhost=true in addition to other Wonder Guard traits
    Code:
    if !user.hasMoldBreaker && target.hasWorkingAbility(:SHAMANSHIELD) &&
             type>=0 && typemod<=8 && partyGhost=true
            @battle.pbDisplay(_INTL("{1} avoided damage with Shaman Shield!",target.pbThis))
            PBDebug.log("[Ability triggered] #{target.pbThis}'s Shaman Shield")
            return false 
          end

    If I need to fix anything, tell me.
     
    285
    Posts
    5
    Years
    • Seen Oct 1, 2023
    I think I figured it out.
    I made a new section for the partyGhost variable
    Code:
    def pbPartyGhostCheck
      [email protected](:ABSOL.index)
        partyGhost=false
        for i in 0...party.length
          next if attacker.pokemonIndex==i
          if party[i] && !party[i].egg? && party[i].hp>0 && party[i].hasType?(:GHOST)
            partyGhost=true
            break
          end
        end

    And had Shaman Shield run off of the partyGhost=true in addition to other Wonder Guard traits
    Code:
    if !user.hasMoldBreaker && target.hasWorkingAbility(:SHAMANSHIELD) &&
             type>=0 && typemod<=8 && partyGhost=true
            @battle.pbDisplay(_INTL("{1} avoided damage with Shaman Shield!",target.pbThis))
            PBDebug.log("[Ability triggered] #{target.pbThis}'s Shaman Shield")
            return false 
          end

    If I need to fix anything, tell me.

    I don't think that's going to work. You don't need a new method for this, as it would prevent you from using the partyGhost variable. Just put the code right above the ability's code. Also, instead of "[email protected](:ABSOL.index)", it should be "[email protected](target.index)". This is what I notice from taking a quick look at it, but you'd have to test it out.
     
    233
    Posts
    5
    Years
    • Seen Oct 9, 2023
    In addition to what silverlime said above, you have to replace "partyGhost=true" with "partyGhost==true".
     
    Back
    Top