• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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] Random Weather Move

  • 155
    Posts
    10
    Years
    • Seen Jun 11, 2021
    I'm trying to create a move that causes a random weather effect whenever it's used. However, when I try to use it in battle, it just skips the move completely.
    Code:
    class PokeBattle_Move_178 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        case @battle.weather
        when PBWeather::HEAVYRAIN
          @battle.pbDisplay(_INTL("There is no relief from this heavy rain!"))
          return -1
        when PBWeather::HARSHSUN
          @battle.pbDisplay(_INTL("The extremely harsh sunlight was not lessened at all!"))
          return -1
        when PBWeather::STRONGWINDS
          @battle.pbDisplay(_INTL("The mysterious air current blows on regardless!"))
          return -1
        [email protected](4)
      end
      
        case rnd
        when 0
          if PBWeather::RAINDANCE
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::RAINDANCE
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:DAMPROCK)
          @battle.pbCommonAnimation("Rain",nil,nil)
          @battle.pbDisplay(_INTL("It started to rain!"))
          return 0
        when 1
          if PBWeather::SUNNYDAY
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::SUNNYDAY
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:HEATROCK)
          @battle.pbCommonAnimation("Sunny",nil,nil)
          @battle.pbDisplay(_INTL("The sunlight turned harsh!"))      
    
          return 0
          
        when 2
          if PBWeather::SANDSTORM
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::SANDSTORM
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:SMOOTHROCK)
          @battle.pbCommonAnimation("Sandstorm",nil,nil)
          @battle.pbDisplay(_INTL("A sandstorm brewed!"))
          return 0
        when 3
          if PBWeather::HAIL
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::HAIL
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:ICYROCK)
          @battle.pbCommonAnimation("Hail",nil,nil)
          @battle.pbDisplay(_INTL("It started to hail!"))
          return 0
        end
        
        return true
      end
    end
    Did I enter something incorrectly?
     
    Well you have an "end" after rnd(4), which seems out of place.
    If you need to end cases, then it should still be before the random.
    If you don't need to do that, then it shouldn't be there at all.
     
    This line
    should go right before
    Code:
    case rnd

    other wise it won't execute this line unless the weather is Strong Winds.
     
    Try putting some extra lines in there (for debug purpose only) to wheter your code is being executed and if so how far.
    Just add
    Code:
    @battle.pbDisplay(_INTL("Check Point X"))
    in a few different spots.
    If you see these text messages in game you know the code is recognized. That helps pinpoint the problem.
     
    I just now tried that. It's not seeing the message at all.
    Code:
    class PokeBattle_Move_178 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        case @battle.weather
        when PBWeather::HEAVYRAIN
          @battle.pbDisplay(_INTL("There is no relief from this heavy rain!"))
          return -1
        when PBWeather::HARSHSUN
          @battle.pbDisplay(_INTL("The extremely harsh sunlight was not lessened at all!"))
          return -1
        when PBWeather::STRONGWINDS
          @battle.pbDisplay(_INTL("The mysterious air current blows on regardless!"))
          return -1
      #end
        @battle.pbDisplay(_INTL("Check Point A"))
        [email protected](4)
        case rnd
        when 0
          if PBWeather::RAINDANCE
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::RAINDANCE
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:DAMPROCK)
          @battle.pbCommonAnimation("Rain",nil,nil)
          @battle.pbDisplay(_INTL("It started to rain!"))
          return 0
        when 1
          if PBWeather::SUNNYDAY
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::SUNNYDAY
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:HEATROCK)
          @battle.pbCommonAnimation("Sunny",nil,nil)
          @battle.pbDisplay(_INTL("The sunlight turned harsh!"))      
    
          return 0
          
        when 2
          if PBWeather::SANDSTORM
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::SANDSTORM
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:SMOOTHROCK)
          @battle.pbCommonAnimation("Sandstorm",nil,nil)
          @battle.pbDisplay(_INTL("A sandstorm brewed!"))
          return 0
        when 3
          if PBWeather::HAIL
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
          pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
          @battle.weather=PBWeather::HAIL
          @battle.weatherduration=5
          @battle.weatherduration=8 if attacker.hasWorkingItem(:ICYROCK)
          @battle.pbCommonAnimation("Hail",nil,nil)
          @battle.pbDisplay(_INTL("It started to hail!"))
          return 0
        end
        end
        
        return true
      end
    end
     
    Why did you comment out the first end? Its needed to let the program know that the first case ends. Otherwise it will think that everything else belongs to the last when
     
    Back
    Top