• 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.
  • 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!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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] V17.2 How do I make this move function work?

  • 67
    Posts
    4
    Years
    • He/Him
    • Seen Nov 16, 2023
    ################################################################################
    # Inflicts Shock if ally or user is Electric
    ################################################################################
    class PokeBattle_Move_231 < PokeBattle_Move
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if pbIsDamaging?
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret
    else
    if pbTypeModifier(type,attacker,opponent)==0
    @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
    return -1
    end
    return -1 if pbTypeImmunityByAbility(pbType(@type,attacker,opponent),attacker,opponent)
    return -1 if !opponent.pbCanShock?(attacker,true,self)
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    opponent.pbShock(attacker)
    return 0
    end
    return -1
    end

    def pbAdditionalEffect(attacker,opponent)
    if attacker.pbHasType?(:ELECTRIC) || attacker.pbPartner.pbHasType?(:ELECTRIC)
    return if opponent.damagestate.substitute
    if opponent.pbCanShock?(attacker,false,self)
    opponent.pbShock(attacker)
    end
    end
    end
    end
     
    What is it that doesn't work for you in this?
     
    What is it that doesn't work for you in this?

    well the moves I want to apply this to end up not doing damage or anything at all just skips a turn and when I get the synergy effect so the user or ally is electric nothing happens
     
    What is it that doesn't work for you in this?

    Wait never mind I fixed that in PBS but I ran into a different problem when using a pokemon that isn't electric nothing happens I need some sort of else statement in pb Additional effect because it does nothing if the pokemon doesn't have the electric type but the move is supposed to work it just won't status
     
    I thought about doing this but I get syntax errors and I don't know why I still have a lot to learn about coding



    def pbAdditionalEffect(attacker,opponent)
    if attacker.pbHasType?(:ELECTRIC) || attacker.pbPartner.pbHasType?(:ELECTRIC)
    return if opponent.damagestate.substitute
    if opponent.pbCanShock?(attacker,false,self)
    opponent.pbShock(attacker)
    end
    end
    end
    elsif !attacker.pbHasType?(:ELECTRIC) || !attacker.pbPartner.pbHasType?(:ELECTRIC)
    return if opponent.damagestate.substitute
    if opponent.pbCanShock?(attacker,false,self)
    !opponent.pbShock(attacker)
    end
    end
    end
    end
     
    I've looked over your code and I think this is everything you want it to do. The syntax error was caused due to you closing the "def pbAdditionalEffect(attacker,opponent)" off with an end and then trying to continue it. :)
    Code:
    def pbAdditionalEffect(attacker,opponent)
      if attacker.pbHasType?(:ELECTRIC) || attacker.pbPartner.pbHasType?(:ELECTRIC)
        return if opponent.damagestate.substitute
        opponent.pbShock(attacker) if opponent.pbCanShock?(attacker,false,self)
      end
    end
     
    I've looked over your code and I think this is everything you want it to do. The syntax error was caused due to you closing the "def pbAdditionalEffect(attacker,opponent)" off with an end and then trying to continue it. :)
    Code:
    def pbAdditionalEffect(attacker,opponent)
      if attacker.pbHasType?(:ELECTRIC) || attacker.pbPartner.pbHasType?(:ELECTRIC)
        return if opponent.damagestate.substitute
        opponent.pbShock(attacker) if opponent.pbCanShock?(attacker,false,self)
      end
    end

    Thanks it worked one last thing do you know how I can make this work? I am trying to make this move inflict toxic if the user or ally is poison but if it is not it will just poison


    ################################################################################
    # Inflicts Toxic if ally or user is Poison else just poisons
    ################################################################################
    class PokeBattle_Move_235 < PokeBattle_Move
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    return super(attacker,opponent,hitnum,alltargets,showanimation) if pbIsDamaging?
    return -1 if !opponent.pbCanPoison?(attacker,true,self)
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    opponent.pbPoison(attacker,nil,true)
    return 0
    end

    def pbAdditionalEffect(attacker,opponent)
    return if opponent.damagestate.substitute
    if opponent.pbCanPoison?(attacker,false,self)
    opponent.pbPoison(attacker,nil,true)
    end
    end
    if attacker.pbHasType?(:POISON) || attacker.pbPartner.pbHasType?(:POISON)
    return if opponent.damagestate.substitute
    opponent.pbPoison(attacker,nil,true) if opponent.pbCanPoison?(attacker,false,self)
    end
    end
     
    Here you go:
    Code:
    def pbAdditionalEffect(attacker,opponent)
      return if opponent.damagestate.substitute
      return if !opponent.pbCanPoison?(attacker,false,self)
      poison = attacker.pbHasType?(:POISON) || attacker.pbPartner.pbHasType?(:POISON)
      posion ? opponent.pbPoison(attacker,nil,true) : opponent.pbPoison(attacker,nil,false)
    end
     
    Here you go:
    Code:
    def pbAdditionalEffect(attacker,opponent)
      return if opponent.damagestate.substitute
      return if !opponent.pbCanPoison?(attacker,false,self)
      poison = attacker.pbHasType?(:POISON) || attacker.pbPartner.pbHasType?(:POISON)
      posion ? opponent.pbPoison(attacker,nil,true) : opponent.pbPoison(attacker,nil,false)
    end

    bro thank you so much
     
    Back
    Top