• 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] Help with ability that lets you use moves while asleep

79
Posts
8
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!
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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:
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    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!
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • 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
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    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