• 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] Help: Pokemon attack that hits twice during sun

  • 2
    Posts
    8
    Years
    • Seen Aug 27, 2023
    Hi, i am making a fan game and want to add a special attack for every starter.
    I am already done with most of them, but now i encountered a problem.

    As already stated above i want to make a new attack, called "Solar Whip".
    It should work like this: Under sunshine or harsh sund the attack should hit the target twice. Without sun the attack hits once.

    Unfortunately i don't seem to get it right. Now it works like this: without sunlight it hits once, when the sun is triggered it hits twice and then keeps hitting twice, until you close the game every time you use it.

    Maybe the error is just so obvious, that i don't find it, but here's the code:

    class PokeBattle_Move_507 < PokeBattle_Move
    def pbIsMultiHit
    if [email protected]==PBWeather::SUNNYDAY ||
    [email protected]==PBWeather::HARSHSUN
    def pbIsMultiHit
    return false
    end
    end
    if @battle.pbWeather==PBWeather::SUNNYDAY ||
    @battle.pbWeather==PBWeather::HARSHSUN
    def pbIsMultiHit
    return true
    end
    def pbNumHits(attacker)
    return 2
    end
    end
    end
    end
     
    What you're doing is defining functions inside of functions, which isn't really valid (it does something, but not necessarily what you want it to). Try this instead:

    Code:
    class PokeBattle_Move_507 < PokeBattle_Move
      def pbIsMultiHit
        if @battle.pbWeather==PBWeather::SUNNYDAY || @battle.pbWeather==PBWeather::HARSHSUN
          return true
        end
        return false
      end
    
      def pbNumHits(attacker)
        if @battle.pbWeather==PBWeather::SUNNYDAY || @battle.pbWeather==PBWeather::HARSHSUN
          return 2
        end
        return 1
      end
    end

    Also, I would strongly recommend reading a Ruby tutorial like this one: https://www.pokecommunity.com/threads/410026 to make working with scripts a lot easier.
     
    Thank you very much for the help.
    Worked perfectly.
    That was actually the first time, that i struggled with a new move.
    I already (for example) did one that damages and causes hail, but u don't know, why i struggled with this one.
    Thanks again.
     
    Back
    Top