• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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] Trying to create sand footprints

  • 90
    Posts
    6
    Years
    • Seen Nov 24, 2023
    I'm currently trying to change the script for Essentials 21.1 so that characters can leave footprints while walking on sand. The way it works is that, whenever a character moves to a new tile, the script activates an animation from the database (like the grass rustle animation, for example) that plays on the tile that the character was previously on. This method works well for the player, but the issue is with the npcs. If I load up my save state and I have an NPC who:
    • is on same map that I am
    • was initially placed on a sand tile and is constantly moving
    the game will immediately crash while trying to play the footprint animation.

    This is the code that I made for the sand footprints animation
    Code:
    def triggerLeaveTile #This function already existed within Essentials, but I added the "if" with leaveFootstep
        if @oldX && @oldY && @oldMap &&
           (@oldX != self.x || @oldY != self.y || @oldMap != self.map.map_id)
          EventHandlers.trigger(:on_leave_tile, self, @oldMap, @oldX, @oldY)
          if $map_factory.getTerrainTagFromCoords(self.map.map_id, @oldX, @oldY, true).shows_sand_step
            leaveFootstep
          end
        end
        @oldX = self.x
        @oldY = self.y
        @oldMap = self.map.map_id
      end
      
      def leaveFootstep #This is the function that I made (@stepshape is initially = 0)
        if @stepshape == 1
          @stepshape = 0
        else
          @stepshape = 1
        end
        if (@oldX && @oldY)
          spriteset = $scene.spriteset(map_id)
          if (@oldX == self.x && @oldY != self.y)
            spriteset&.addUserAnimation(8 + @stepshape, @oldX, @oldY, true, 1)
          elsif (@oldX != self.x && @oldY == self.y)
            spriteset&.addUserAnimation(10 + @stepshape, @oldX, @oldY, true, 1)
          end
        end
      end

    And this is the error message I get when I load up my savestate:

    Code:
    Exception: NoMethodError
    Message: undefined method `spriteset' for #<Scene_DebugIntro>
    
    Backtrace:
    Game_Character:410:in `leaveFootstep'
    Game_Character:395:in `triggerLeaveTile'
    Game_Character:421:in `increase_steps'
    Game_Character:584:in `move_generic'
    Game_Character:591:in `move_down'
    Game_Character:770:in `move_forward'
    Game_Character:430:in `move_type_random'
    Game_Character:950:in `update_command_new'
    Game_Character:943:in `update_command'
    Game_Character:927:in `update'

    Can anyone help me understand what went wrong? I saw other functions within the [[ Game Clases ]] section of the script use "spriteset = $scene.spriteset(map_id)" and they don't cause the game to crash, so I'm kind of at a loss here.
     
    Back
    Top