• 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] Held item that triggers weather

Razyrwynd

Certified Space Frog Addict
5
Posts
7
Years
  • Hi.
    I'm trying to add a Snow Globe as a held item that summons Hail whenever the holder is brought into battle (lasting the standard 5 turns).
    I'm still fairly new when it comes to scripting, so I'm having difficulty figuring this one out. Any help would be appreciated.
     
    824
    Posts
    8
    Years
  • PokeBattle_Battler (with the R), lines 1008-1019 are used to trigger Snow Warning. Adding in the red stuff will add the Snow Globe.

    Code:
            if [COLOR="red"]([/COLOR]self.hasWorkingAbility(:SNOWWARNING)[COLOR="Red"] || self.hasWorkingItem(:SNOWGLOBE))[/COLOR] && (@battle.weather!=PBWeather::HAIL || @battle.weatherduration!=-1)
              @battle.weather=PBWeather::HAIL
              if USENEWBATTLEMECHANICS
                @battle.weatherduration=5
                @battle.weatherduration=8 if hasWorkingItem(:ICYROCK)
              else
                @battle.weatherduration=-1
              end
              @battle.pbCommonAnimation("Hail",nil,nil)
              [COLOR="red"]if self.hasWorkingAbility(:SNOWWARNING)[/COLOR]
                @battle.pbDisplay(_INTL("{1}'s {2} made it hail!",pbThis,PBAbilities.getName(self.ability)))
                PBDebug.log("[Ability triggered] #{pbThis}'s Snow Warning made it hail")[COLOR="red"]
              else
                @battle.pbDisplay(_INTL("{1}'s {2} made it hail!",pbThis,PBItems.getName(self.item)))
                PBDebug.log("[Item triggered] #{pbThis}'s Snow Globe made it hail")
              end[/COLOR]
            end

    Note that:
    - if a Pokemon has both Snow Warning (ability) and a Snow Globe (item), the ability will trigger and the item will not.
    - the Snow Globe does not make the holder immune to the damaging effects of hail.
    - the Snow Globe would be treated like a permanent item, not a consumable like the berries, gems, or terrain seeds in the main series. If you want to make it consumable, add the line
    Code:
    self.pbConsumeItem
    before the two ends at the bottom of the code.
     

    Razyrwynd

    Certified Space Frog Addict
    5
    Posts
    7
    Years
  • PokeBattle_Battler (with the R), lines 1008-1019 are used to trigger Snow Warning. Adding in the red stuff will add the Snow Globe.

    Code:
            if [COLOR="red"]([/COLOR]self.hasWorkingAbility(:SNOWWARNING)[COLOR="Red"] || self.hasWorkingItem(:SNOWGLOBE))[/COLOR] && (@battle.weather!=PBWeather::HAIL || @battle.weatherduration!=-1)
              @battle.weather=PBWeather::HAIL
              if USENEWBATTLEMECHANICS
                @battle.weatherduration=5
                @battle.weatherduration=8 if hasWorkingItem(:ICYROCK)
              else
                @battle.weatherduration=-1
              end
              @battle.pbCommonAnimation("Hail",nil,nil)
              [COLOR="red"]if self.hasWorkingAbility(:SNOWWARNING)[/COLOR]
                @battle.pbDisplay(_INTL("{1}'s {2} made it hail!",pbThis,PBAbilities.getName(self.ability)))
                PBDebug.log("[Ability triggered] #{pbThis}'s Snow Warning made it hail")[COLOR="red"]
              else
                @battle.pbDisplay(_INTL("{1}'s {2} made it hail!",pbThis,PBItems.getName(self.item)))
                PBDebug.log("[Item triggered] #{pbThis}'s Snow Globe made it hail")
              end[/COLOR]
            end

    Note that:
    - if a Pokemon has both Snow Warning (ability) and a Snow Globe (item), the ability will trigger and the item will not.
    - the Snow Globe does not make the holder immune to the damaging effects of hail.
    - the Snow Globe would be treated like a permanent item, not a consumable like the berries, gems, or terrain seeds in the main series. If you want to make it consumable, add the line
    Code:
    self.pbConsumeItem
    before the two ends at the bottom of the code.
    thank you!
     

    Razyrwynd

    Certified Space Frog Addict
    5
    Posts
    7
    Years

  • ok, now I have another problem. I added the code as you said, but now when I try to playtest, I get an error message saying there's a syntax error in PokeBattle_Battler line 3376 (which is literally just "end"). I don't know what happened or how to fix it

    EDIT: Nevermind I fixed it
     
    Last edited:
    Back
    Top