The PokéCommunity Forums Fan Games Game Development Pokémon Essentials
Scripting Question Help with ability that lets you use moves while asleep

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.

Reply
 
Thread Tools
  #1    
Old October 8th, 2018 (1:48 PM).
Tommaniacal Tommaniacal is offline
     
    Join Date: Apr 2016
    Posts: 28
    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!
    Reply With Quote
      #2    
    Old October 8th, 2018 (1:57 PM). Edited 4 Weeks Ago by mgriffin.
    mgriffin's Avatar
    mgriffin mgriffin is offline
       
      Join Date: Apr 2014
      Posts: 136
      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:
      if !thismove.pbCanUseWhileAsleep? # Snore/Sleep Talk/Outrage
      if !(thismove.pbCanUseWhileAsleep? || self.hasWorkingAbility(:LUCIDDREAMING)) # Snore/Sleep Talk/Outrage
      (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)
      Reply With Quote
        #3    
      Old 4 Weeks Ago (7:27 PM).
      Tommaniacal Tommaniacal is offline
         
        Join Date: Apr 2016
        Posts: 28
        Quote:
        Originally Posted by mgriffin View Post
        Can't you say something like "if canUseWhileAsleep or has Lucid Dreaming"? I'm guessing the change will look a bit like this:

        Code:
        if !thismove.pbCanUseWhileAsleep? # Snore/Sleep Talk/Outrage
        if !(thismove.pbCanUseWhileAsleep? || self.hasWorkingAbility(:LUCIDDREAMING)) # Snore/Sleep Talk/Outrage
        (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? || self.hasWorkingAbility(:LUCIDDREAMING))
              @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? || self.hasWorkingAbility(:LUCIDDREAMING)) # 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!
        Reply With Quote
          #4    
        Old 4 Weeks Ago (10:26 PM).
        Ego13's Avatar
        Ego13 Ego13 is offline
        hollow_ego
           
          Join Date: Jul 2017
          Location: Larua Region
          Gender: Male
          Nature: Calm
          Posts: 213
          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
          __________________
          Looking for spriters to help with

          Pokemon Hollow on pokecommunity.com
          Reply With Quote
            #5    
          Old 4 Weeks Ago (7:09 AM).
          Tommaniacal Tommaniacal is offline
             
            Join Date: Apr 2016
            Posts: 28
            Quote:
            Originally Posted by mgriffin View Post
            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:
                # Do nothing if using Snore/Sleep Talk
                if self.status==PBStatuses::SLEEP && (move.pbCanUseWhileAsleep? || self.hasWorkingAbility(:LUCIDDREAMING))
                  @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? || self.hasWorkingAbility(:LUCIDDREAMING) # Snore/Sleep Talk/Outrage
                        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:
            Reply With Quote
            Reply

            Quick Reply

            Join the conversation!

            Create an account to post a reply in this thread, participate in other discussions, and more!

            Create a PokéCommunity Account
            Thread Tools

            Posting Rules
            You may not post new threads
            You may not post replies
            You may not post attachments
            You may not edit your posts

            BB code is On
            Smilies are On
            [IMG] code is On
            HTML code is Off

            Forum Jump


            All times are GMT -8. The time now is 2:35 PM.