Seen November 26th, 2020
Posted November 26th, 2020
4 posts
64 Days
Hello. I'm making an exclusive ability for Flygon which would put into the field a version of Sandstorm that doesn't end until it is overriden or Flygon leaves the field. However, I'm encountering a problem:
case curWeather
      when PBWeather::Sandstorm || PBWeather::HuntingSands # This is what was added
        next if !b.takesSandstormDamage?
        pbDisplay(_INTL("{1} is buffeted by the sandstorm!",b.pbThis))
        @scene.pbDamageAnimation(b)
        b.pbReduceHP(b.totalhp/16,false)
        b.pbItemHPHealCheck
        b.pbFaint if b.fainted?
Despite adding this line to the code (with HuntingSands being the weather) - it won't deal damage.

I'll leave in this spoiler every single other modification I made to insert HuntingSands - except the ones regarding the text it produces (which it produces just fine, including start - end - end of round "rages on", except, of course, for the buffered by sandstorm message, since that doesn't happen) and the ones regarding the fact that it acts the same as sandstorm for sandstorm abilities.
Thank you very much in advance :)
Spoiler:
module PBWeather
    None        = 0
    Sun         = 1
    Rain        = 2
    Sandstorm   = 3
    Hail        = 4
    HarshSun    = 5
    HeavyRain   = 6
    StrongWinds = 7
    ShadowSky   = 8
    HuntingSands = 9 # Defines it.

    def self.animationName(weather)
      case weather
      when Sun;         return "Sun"
      when Rain;        return "Rain"
      when Sandstorm;   return "Sandstorm"
      when Hail;        return "Hail"
      when HarshSun;    return "HarshSun"
      when HeavyRain;   return "HeavyRain"
      when StrongWinds; return "StrongWinds"
      when ShadowSky;   return "ShadowSky"
      when HuntingSands; return "Sandstorm" # Using same animation as Sandstorm
      end


  fixedDuration = true if NEWEST_BATTLE_MECHANICS &&
                          weather!=PBWeather::HarshSun &&
                          weather!=PBWeather::HeavyRain &&
                          weather!=PBWeather::StrongWinds &&
                          weather!=PBWeather::HuntingSands # Doesn't end unless overriden/Flygon switches in


BattleHandlers::AbilityOnSwitchIn.add(:HUNTINGSANDS, #Ability has same name as the weather.
  proc { |ability,battler,battle|
    pbBattleWeatherAbility(PBWeather::HuntingSands,battler,battle,false)
  }
)

 def pbEndPrimordialWeather
    oldWeather = @field.weather
    # End Primordial Sea, Desolate Land, Delta Stream
    case @field.weather
    # .... other cases
    when PBWeather::HuntingSands
      if !pbCheckGlobalAbility(:HUNTINGSANDS)
        @field.weather = PBWeather::None
        pbDisplay("The sandstorm fades! The hunt is off!") #Ends the weather when the ability is no longer there.
      end
    end
Seen 9 Hours Ago
Posted 2 Days Ago
21 posts
64 Days
I think I can help you.
Rather than combining them, separate them like in these two codes here:
def takesHuntingSandsDamage?
    return false if !takesIndirectDamage?
    return false if isSpecies?(:FLYGON)
    return false if inTwoTurnAttack?("0CA","0CB")   # Dig, Dive
    return false if hasActiveAbility?([:OVERCOAT,:SANDFORCE,:SANDRUSH,:SANDVEIL])
    return false if hasActiveItem?(:SAFETYGOGGLES)
    return true
  end
when PBWeather::HuntingSands
        next if !b.takesHuntingSandsDamage?
        pbDisplay(_INTL("{1} is buffeted by the sandstorm!",b.pbThis))
        @scene.pbDamageAnimation(b)
        b.pbReduceHP(b.totalhp/8,false)
        b.pbItemHPHealCheck
        b.pbFaint if b.fainted?
Seen November 26th, 2020
Posted November 26th, 2020
4 posts
64 Days
I think I can help you.
Rather than combining them, separate them like in these two codes here:
def takesHuntingSandsDamage?
    return false if !takesIndirectDamage?
    return false if isSpecies?(:FLYGON)
    return false if inTwoTurnAttack?("0CA","0CB")   # Dig, Dive
    return false if hasActiveAbility?([:OVERCOAT,:SANDFORCE,:SANDRUSH,:SANDVEIL])
    return false if hasActiveItem?(:SAFETYGOGGLES)
    return true
  end
when PBWeather::HuntingSands
        next if !b.takesHuntingSandsDamage?
        pbDisplay(_INTL("{1} is buffeted by the sandstorm!",b.pbThis))
        @scene.pbDamageAnimation(b)
        b.pbReduceHP(b.totalhp/8,false)
        b.pbItemHPHealCheck
        b.pbFaint if b.fainted?
Oh! That works perfectly. I wonder why grouping them together didn't...? Well, hooray for order, I guess. Thank you very much!