• 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] Apply Yawn effect on every pokemon on the field ?

hirokimura

Miltank's Fanboy Number One
  • 150
    Posts
    7
    Years
    Hello guys !
    I'm planning to do something in my game.
    Kinda like a field effect that apply Yawn effect to both pokemons. It would be that as long as the terrain is ON, at the end of each turn, it applies Yawn to every pokemon battling.
    Thing is, I don't even know where to start.
    I don't need it cooked, but, can someone help me to see what I should do first ?
    Thank you !
     
    Look up where the terrain field effects are applied (Ctrl+Shift+F is your friend) and look into how Yawn is implemented. Certain Pokémon will be immune to this effect of course.
     
    Thanks for the answer !
    I progressed a bit : I can now have my Bells field functions well and I can start it with a move.
    I tweaked a bit with grassy's healing at the end of the round, but seems I cant get it working : here is my code
    Code:
    def pbBellsYawn(battler)
        return if battler.fainted?
        # Bells putting Yawn
        if @field.terrain == :Bells && battler.pbCanSleep? && battler.effects[PBEffects::Yawn] > 0
          PBDebug.log("[Lingering effect] Bells made #{battler.pbThis(true)} drowsy!")
          battler.effects[PBEffects::Yawn] = 2
          pbDisplay(_INTL("The bells made {2} drowsy!", battler.pbThis))
        end
      end

    Idk what I'm doing wrong, but I feel I'm closer to the goal.
     
    It looks like your code is defined in the Battle class. How is pbBellsYawn being called? I did notice that battler.effects[PBEffects::Yawn] > 0 only returns true if the battler is already under the effect of Yawn. By changing > to >= allows Pokémon who are not under the effect of Yawn to gain the effect.
     
    Last edited:
    Thanks for the help !
    Indeed, I defined the process but I didn't call it, so it didn't work haha !
    After calling it, I got few errors, and fixed them with your advices and others, here is the final code just for the record
    Code:
    #----------------------------------------------------------------
        # End Of Round Yawn from Bells Terrain
      #=============================================================================
    def pbBellsYawn(battler)
        return if battler.fainted?
        # Bells putting Yawn
        if @field.terrain == :Bells && battler.pbCanSleepYawn? && battler.effects[PBEffects::Yawn] == 0
          PBDebug.log("[Lingering effect] Bells made #{battler.pbThis(true)} drowsy!")
          battler.effects[PBEffects::Yawn] = 2
          pbDisplay(_INTL("The bells made {1} drowsy!", battler.pbThis))
        end
      end
    Thank you very much for the help ! It's very appreciated !
     
    Back
    Top