• 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] Rock Smash HM item field animation not working?

  • 5
    Posts
    6
    Years
    • Seen Dec 22, 2019
    This is in essentials V 17.2

    I currently have a working script for a rock smash field item. The animation works fine when I just walk up to the rock and trigger the event like that, but whenever I stand next to the rock facing the rock, open the menu and use the item from there, it does not play the animation. The rock still breaks, the text still pops up saying I used rock smash, and the sound still happens, but the rock just vanishes without blowing up.

    Here is the code from the rock smash section in PField_Moves
    I have certain parts of it commented out in order to make the item work correctly.

    Code:
    def pbRockSmashRandomEncounter
      if rand(100)<25
        pbEncounter(EncounterTypes::RockSmash)
      end
    end
    
    def Kernel.pbRockSmash
      move = getID(PBMoves,:ROCKSMASH)
      movefinder = nil
      movefinder = Kernel.pbCheckMove(move)
      if $PokemonBag.pbQuantity(PBItems::POKEASSISTROCKSMASH)==0
        Kernel.pbMessage(_INTL("It's a rugged rock, but a Pokémon may be able to smash it."))
        return false
      else 
        if Kernel.pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use Rock Smash?"))
           movefinder = nil
           speciesname = (movefinder) ? movefinder.name : $Trainer.name
           Kernel.pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move)))
           pbHiddenMoveAnimation(movefinder)
           return true
        end
      end
    end
    
    #HiddenMoveHandlers::CanUseMove.add(:ROCKSMASH,proc{|move,pkmn,showmsg|
    #   return false if !pbCheckHiddenMoveBadge(BADGEFORROCKSMASH,showmsg)
    #   facingEvent = $game_player.pbFacingEvent
    #   if !facingEvent || facingEvent.name!="Rock"
    #     Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
    #     return false
    #   end
    #   return true
    #})
    
    #HiddenMoveHandlers::UseMove.add(:ROCKSMASH,proc{|move,pokemon|
    #   if !pbHiddenMoveAnimation(pokemon)
    #     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
    #   end
    #   facingEvent = $game_player.pbFacingEvent
    #   if facingEvent
    #     pbSmashEvent(facingEvent)
    #     pbRockSmashRandomEncounter
    #   end
    #   return true
    #})
    
    def canUseMoveRockSmash?
       showmsg = true
       facingEvent = $game_player.pbFacingEvent
       if !facingEvent || facingEvent.name!="Rock"
         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
         return false
       end
       return true
    end
    
    def useMoveRockSmash
       if !pbHiddenMoveAnimation(nil)
         Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Rock Smash"))
       end
       facingEvent = $game_player.pbFacingEvent
       if facingEvent
         pbSmashEvent(facingEvent)
       end
       return true
    end

    Here is the code from the item effects section.

    Code:
    ItemHandlers::UseFromBag.add(:POKEASSISTROCKSMASH,proc{|item|
       next canUseMoveRockSmash? ? 2 : 0
    })
    
    ItemHandlers::UseInField.add(:POKEASSISTROCKSMASH,proc{|item|
       useMoveRockSmash if canUseMoveRockSmash?
    })

    Any help is greatly appreciated! Thanks!
     
    Back
    Top