• 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.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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] Help with ability that lets you use moves while asleep

  • 79
    Posts
    9
    Years
    • Seen Jan 12, 2024
    I'm attempting to create a custom ability that lets you use moves successfully without having to use Sleep Talk. I tried modeling it after the move Snore, and found that there's an effect that works exactly like what I'm looking for: pbCanUseWhileAsleep?

    How exactly would I use this in the script of an ability? I started out with this:
    Code:
    if attacker.hasWorkingAbility(:LUCIDDREAMING) && 
       attacker.status==PBStatuses::SLEEP
    but I have no idea where to go from there. Also, where would be the best place to put this script?

    Thanks!
     
    That seems like a good start. Can't you say something like "if canUseWhileAsleep or has Lucid Dreaming"? I'm guessing the change will look a bit like this:

    Code:
    [color=red]if !thismove.pbCanUseWhileAsleep? # Snore/Sleep Talk/Outrage[/color]
    [color=green]if !(thismove.pbCanUseWhileAsleep? || self.hasWorkingAbility(:LUCIDDREAMING)) # Snore/Sleep Talk/Outrage[/color]

    (I haven't actually read the code around that line, so this might not quite work as-written, but hopefully it will point you in the right direction)
     
    Last edited:
    Can't you say something like "if canUseWhileAsleep or has Lucid Dreaming"? I'm guessing the change will look a bit like this:

    Code:
    [color=red]if !thismove.pbCanUseWhileAsleep? # Snore/Sleep Talk/Outrage[/color]
    [color=green]if !(thismove.pbCanUseWhileAsleep? || self.hasWorkingAbility(:LUCIDDREAMING)) # Snore/Sleep Talk/Outrage[/color]

    (I haven't actually read the code around that line, so this might not quite work as-written, but hopefully it will point you in the right direction)

    Wow, that was way easier than I was making it haha. I followed what you did, and added it to PokeBattle_Battler here:
    Code:
        # Do nothing if using Snore/Sleep Talk
        if self.status==PBStatuses::SLEEP && (move.pbCanUseWhileAsleep? [COLOR="Red"]|| self.hasWorkingAbility(:LUCIDDREAMING))[/COLOR]
          @battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis)) 
          return false
        end
    and here:
    Code:
        if !turneffects[PBEffects::SkipAccuracyCheck]
          if self.status==PBStatuses::SLEEP
            self.statusCount-=1
            if self.statusCount<=0
              self.pbCureStatus
            else
              self.pbContinueStatus
              PBDebug.log("[Status] #{pbThis} remained asleep (count: #{self.statusCount})")
              if !(thismove.pbCanUseWhileAsleep? [COLOR="red"]|| self.hasWorkingAbility(:LUCIDDREAMING))[/COLOR] # Snore/Sleep Talk/Outrage
                PBDebug.log("[Move failed] #{pbThis} couldn't use #{thismove.name} while asleep")
                return false
              end
            end
          end
    And it appears to be working! Not sure if there are other places I should add it to, I wouldn't think I'd need to add it to the code for Snore and Sleep Talk. Thank you!
     
    There should be a check for status conditions in pbSuccessCheck or a script related to that. There you can add a check for the ability.
    Since I can't look into it now i might name the wrong script but it is a good place to start
     
    Can't you say something like "if canUseWhileAsleep or has Lucid Dreaming"? I'm guessing the change will look a bit like this

    This worked! I commented earlier but for some reason it didn't go through. I added it in Pokebattler here:
    Code:
       [COLOR="Green"] # Do nothing if using Snore/Sleep Talk[/COLOR]
        if self.status==PBStatuses::SLEEP && [COLOR="Red"]([/COLOR]move.pbCanUseWhileAsleep? [COLOR="Red"]|| self.hasWorkingAbility(:LUCIDDREAMING))[/COLOR]
          @battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis)) 
          return false
        end
    and here:
    Code:
        if !turneffects[PBEffects::SkipAccuracyCheck]
          if self.status==PBStatuses::SLEEP
            self.statusCount-=1
            if self.statusCount<=0
              self.pbCureStatus
            else
              self.pbContinueStatus
              PBDebug.log("[Status] #{pbThis} remained asleep (count: #{self.statusCount})")
              if ![COLOR="red"]([/COLOR]thismove.pbCanUseWhileAsleep? [COLOR="red"]|| self.hasWorkingAbility(:LUCIDDREAMING)[/COLOR] [COLOR="Green"]# Snore/Sleep Talk/Outrage[/COLOR]
                PBDebug.log("[Move failed] #{pbThis} couldn't use #{thismove.name} while asleep")
                return false
              end
            end
          end
        end
    Pokemon with it can attack while asleep, and they still wake up after a certain amount of turns :smile:
     
    Back
    Top