The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Tutorial Turn HM moves into items

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Reply
 
Thread Tools
  #76    
Old March 30th, 2017 (10:09 AM).
Mashirosakura's Avatar
Mashirosakura Mashirosakura is offline
     
    Join Date: Jan 2017
    Gender: Male
    Posts: 50
    Quote:
    Originally Posted by M3rein View Post
    Look at the error. Please. "isSurfableTag?".
    Hasn't fixed anything, sadly. I put it where the error was but there's still an issue.
    Reply With Quote

    Relevant Advertising!

      #77    
    Old March 31st, 2017 (6:55 AM).
    FL's Avatar
    FL FL is offline
    Pokémon Island Creator
       
      Join Date: Sep 2010
      Gender: Male
      Posts: 1,725
      Quote:
      Originally Posted by Mashirosakura View Post
      It fixed the initial activating surf animation issue. Now a new one has started, when I move in any direction in the water afterwards. I'll put an image below.
      I tested my tutorial again on V 16.2, even on bridges. The working code:

      Code:
      def canUseMoveSurf?
        if !$DEBUG &&
           !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
          Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
          return false
        end
        if $PokemonGlobal.surfing
          Kernel.pbMessage(_INTL("You're already surfing."))
          return false
        end
        if $game_player.pbHasDependentEvents?
          Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
          return false
        end
        if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
          Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
          return false
        end
        terrain=Kernel.pbFacingTerrainTag
        notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
        if !PBTerrain.isSurfable?(terrain) || !notCliff
          Kernel.pbMessage(_INTL("No surfing here!"))
          return false
        end
        return true
      end
       
      def useMoveSurf
        $game_temp.in_menu=false
        if !pbHiddenMoveAnimation(nil)
          Kernel.pbMessage(_INTL("{1} used Surfboard!",$Trainer.name))
        end
        surfbgm=pbGetMetadata(0,MetadataSurfBGM)
        pbCueBGM(surfbgm,0.5) if surfbgm
        pbStartSurfing()
        return true
      end
      __________________
      Reply With Quote
        #78    
      Old April 1st, 2017 (2:48 AM).
      Mashirosakura's Avatar
      Mashirosakura Mashirosakura is offline
         
        Join Date: Jan 2017
        Gender: Male
        Posts: 50
        Quote:
        Originally Posted by FL View Post
        I tested my tutorial again on V 16.2, even on bridges. The working code:

        Code:
        def canUseMoveSurf?
          if !$DEBUG &&
             !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
            Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
            return false
          end
          if $PokemonGlobal.surfing
            Kernel.pbMessage(_INTL("You're already surfing."))
            return false
          end
          if $game_player.pbHasDependentEvents?
            Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
            return false
          end
          if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
            Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
            return false
          end
          terrain=Kernel.pbFacingTerrainTag
          notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
          if !PBTerrain.isSurfable?(terrain) || !notCliff
            Kernel.pbMessage(_INTL("No surfing here!"))
            return false
          end
          return true
        end
         
        def useMoveSurf
          $game_temp.in_menu=false
          if !pbHiddenMoveAnimation(nil)
            Kernel.pbMessage(_INTL("{1} used Surfboard!",$Trainer.name))
          end
          surfbgm=pbGetMetadata(0,MetadataSurfBGM)
          pbCueBGM(surfbgm,0.5) if surfbgm
          pbStartSurfing()
          return true
        end
        It must be something on my end then, because I'm still getting the error with PBEndSurf
        Reply With Quote
          #79    
        Old 3 Weeks Ago (7:07 AM).
        MissKanabellle MissKanabellle is offline
           
          Join Date: Jan 2018
          Posts: 2
          Hi, could I get a little help with my surf code? I am trying to replace the HM with a surfboard item which works up until I try to actually surf then it throws out this error:

          [Pokémon Essentials version 17.2]

          Exception: NoMethodError

          Message: undefined method `hp' for nil:NilClass

          Following Pokemon:419:in `check_surf'

          Following Pokemon:880:in `pbSurf'

          PField_FieldMoves:847

          PField_FieldMoves:842:in `call'

          EventHandlers:54:in `trigger'

          EventHandlers:49:in `each'

          EventHandlers:49:in `trigger'

          Scene_Map:223:in `follow_update'

          Following Pokemon:1551:in `update'

          Scene_Map:234:in `main'

          This is my code so far:

          Code:
          def Kernel.pbSurf
          if $game_player.pbHasDependentEvents?
          return false
          end
          if $DEBUG || movefinder=Kernel.pbCheckMove(:SURF)
          if $DEBUG || $PokemonBag.pbQuantity(PBItems::SURFBOARD)>0
          if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to swim?"))
          speciesname=!movefinder ? $Trainer.name : movefinder.name
          Kernel.pbMessage(_INTL("You started swimming!",speciesname))
          
          surfbgm=pbGetMetadata(0,MetadataSurfBGM)
          if surfbgm
          pbCueBGM(surfbgm,0.5)
          end
          
          pbStartSurfing()
          return true
          end
          end
          end
          return false
          end
          
          def pbStartSurfing()
          Kernel.pbCancelVehicles
          $PokemonEncounters.clearStepCount
          $PokemonGlobal.surfing=true
          Kernel.pbUpdateVehicle
          Kernel.pbJumpToward
          Kernel.pbUpdateVehicle
          $game_player.check_event_trigger_here([1,2])
          end
          
          def pbEndSurf(xOffset,yOffset)
          return false if !$PokemonGlobal.surfing
          x=$game_player.x
          y=$game_player.y
          currentTag=$game_map.terrain_tag(x,y)
          facingTag=Kernel.pbFacingTerrainTag
          if pbIsSurfableTag?(currentTag) && !pbIsSurfableTag?(facingTag)
          if Kernel.pbJumpToward
          Kernel.pbCancelVehicles
          $game_map.autoplayAsCue
          $game_player.increase_steps
          result=$game_player.check_event_trigger_here([1,2])
          Kernel.pbOnStepTaken(result)
          end
          return true
          end
          return false
          end
          
          Events.onAction+=proc{|sender,e|
          terrain=Kernel.pbFacingTerrainTag
          notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
          if PBTerrain.isSurfable?(terrain) && !$PokemonGlobal.surfing && 
          !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
          Kernel.pbSurf
          return
          end
          }
          
          def canUseMoveSurf?
            if !$DEBUG &&
               !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
              Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
              return false
            end
            if $PokemonGlobal.surfing
              Kernel.pbMessage(_INTL("You're already surfing."))
              return false
            end
            if $game_player.pbHasDependentEvents?
              Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
              return false
            end
            if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
              Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
              return false
            end
            terrain=Kernel.pbFacingTerrainTag
            notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
            if !PBTerrain.isSurfable?(terrain) || !notCliff
              Kernel.pbMessage(_INTL("No surfing here!"))
              return false
            end
            return true
          end
           
          def useMoveSurf
            $game_temp.in_menu=false
            if !pbHiddenMoveAnimation(nil)
              Kernel.pbMessage(_INTL("{1} used Surfboard!",$Trainer.name))
            end
            surfbgm=pbGetMetadata(0,MetadataSurfBGM)
            pbCueBGM(surfbgm,0.5) if surfbgm
            pbStartSurfing()
            return true
          end
          
          HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
          if !pbHiddenMoveAnimation(pokemon)
          Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
          end
          pbStartSurfing()
          return true
          })
          And this is what I have for the effects
          Code:
          ItemHandlers::UseFromBag.add(:SURFBOARD,proc{|item|
             next canUseMoveSurf? ? 2 : 0
          })
          
          ItemHandlers::UseInField.add(:SURFBOARD,proc{|item|
             useMoveSurf if canUseMoveSurf?
          })
          I have it defined in the items like this:
          527,SURFBOARD,Surfboard,Surfboards,8,0,"This Surfboard is used to travel across the water.",2,0,6
          Reply With Quote
            #80    
          Old 3 Weeks Ago (12:32 PM). Edited 3 Weeks Ago by mgriffin.
          mgriffin mgriffin is online now
             
            Join Date: Apr 2014
            Location: London, United Kingdom
            Posts: 24
            Quote:
            Originally Posted by MissKanabellle View Post
            Message: undefined method `hp' for nil:NilClass
            Following Pokemon:419:in `check_surf'
            Following Pokemon:880:in `pbSurf'
            I think all the stuff you've written so far is fine, but you need to additionally make some changes in the following pokemon script that you've added to support surf (because it overwrites the core Essentials surfing code with its own code).

            If you understand the changes that you made elsewhere you should be able to work out how to make similar changes in Following Pokemon (probably around line 880 or 419 as those are the lines mentioned in your error).

            EDIT: I did something similar a while back, see this pastebin, specifically the part after "@@ -122154,23 +122323,30 @@ # Follow_Pokemon.rb", red is removed, green is added. Keep in mind that my item was called FLOATY and I wanted to keep the HM moves functional.
            Reply With Quote
              #81    
            Old 3 Weeks Ago (1:41 PM).
            MissKanabellle MissKanabellle is offline
               
              Join Date: Jan 2018
              Posts: 2
              AH! Thank you, I didn't even think about updating the Follow Pokemon code. It's working now :)
              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

              Sponsored Links
              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 12:47 AM.