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

hirokimura

Miltank's Fanboy Number One
150
Posts
6
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 !
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    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.
     

    hirokimura

    Miltank's Fanboy Number One
    150
    Posts
    6
    Years
  • 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.
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    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:

    hirokimura

    Miltank's Fanboy Number One
    150
    Posts
    6
    Years
  • 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