Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Easy Scipt needed.

Hello i need a script. I think it should be fairly easy for you scripters out there (i am not one and have no idea about scritping). I want it so that you can put a terrain tag on a tileset (a ledge) and when you aproach it and press down you will jump One space over the ledge (as in most pokemon games.) I all ready have a reflection script that uses the terrain tag 7 and i dont thnik this new one should interfear with it. I know you can use events for this and that is what i am doing at the moment but i would MUCH rather use it through script.
 
the script here:
http://www.rmxp.org/forums/showpost.php?p=47184&postcount=2
will let you jump by button...and you can set the terrain tag for jumpable tiles but I don't know how to make it jump automatically.

EDIT:: Hey I did it XD
Code:
#===========================================================================
# paste above main
# â–  Jump Script
#------------------------------------------------------------------------------
# Enables jumping around the map
# Made by: Huitzilopoctli of rmxp.net as part of Interactive World
# Edited by: ToriVerly
#------------------------------------------------------------------------------
# The player will be able to jump over any any tile with a TerrainID the same
# as the JumpID.
# The player must land on a passable tile without a solid event blocking it
# If the player can't jump the full 2 tiles, it will go 1 or, failing that, none
# To stop the player from jumping over a particular event, make the first
#   command for the event a comment, containing this word: \Tall
# To create a 'tall' tile that will stop the player from jumping over it even if
#   the tile below is jumpable, set the tile's id to not the JumpID or 0
#==============================================================================

#==============================================================================
# ● Customization
#==============================================================================

JumpID  = 6 # The terrain ID of the tiles which can be jumped over
MaxJump = 2 # The longest jump that can be made by the player

#==============================================================================
# ● Game_Player
#==============================================================================

class Game_Player < Game_Character
    
  def leap
    # finds the jumpable distance
    dist = jumpable_distance
    
    # finds the increases to x & y for the current direction
    xdir = (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    ydir = (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    
    route = RPG::MoveRoute.new
    route.list.clear
    route.list.push(RPG::MoveCommand.new(37))
    route.list.push(RPG::MoveCommand.new(14, [xdir * dist, ydir * dist]))
    route.list.push(RPG::MoveCommand.new(38))
    route.list.push(RPG::MoveCommand.new(0))
    route.repeat = false
    
    $game_player.force_move_route(route)
  end
  
  alias update_primary update
  def update
    update_primary

    leap if moving? && @direction == 2 && $game_map.terrain_tag($game_player.x,$game_player.y+1) == JumpID #Jumps when facing down
    leap if moving? && @direction == 8 && $game_map.terrain_tag($game_player.x,$game_player.y-1) == JumpID #Jumps when facing up
    leap if moving? && @direction == 6 && $game_map.terrain_tag($game_player.x+1,$game_player.y) == JumpID #Jumps when facing right
    leap if moving? && @direction == 4 && $game_map.terrain_tag($game_player.x-1,$game_player.y) == JumpID #Jumps when facing left

  end
  
  def jumpable_distance(dir = @direction, max_dist = MaxJump, x = @x, y = @y)
    xdir = (dir == 6 ? 1 : dir == 4 ? -1 : 0)
    ydir = (dir == 2 ? 1 : dir == 8 ? -1 : 0)
    
    jumpable_tiles = []
    
    for i in 0..max_dist
      check_x = x + i * xdir
      check_y = y + i * ydir
      
      e = $game_map.events[$game_map.check_event(check_x, check_y)]
      if e
        if e.list[0].parameters[0] =~ "\Tall"
          break
        end
        if not e.through
          next
        end
      end
      
      if $game_map.passable?(check_x, check_y, dir, self) or
                              $game_map.terrain_tag(check_x, check_y) == JumpID
        jumpable_tiles.push(i)
      end
    end
    
    jumpable_tiles.reverse.each do |i|
      check_x = x + i * xdir
      check_y = y + i * ydir
      
      return i if $game_map.passable?(check_x, check_y, dir, self)
    end
    
    return 0
  end
  
end
#__________________ [url]http://www.tsubasachronicle[/url]
Hope it works for ya, enjoy!:)
 
Thanks ToriVoly. I'm not sure if there is a problem with the script or if it is my dumbness in scripting. I set the terrain tag to 6 on the tile that you can jump over. when you aproach it and you press down (as if to jump off of it) nothing happends. Mabey you can tell me what im doing rong?
 
You might need a little bit of a 'running start.' I set it to work if only you're moving because else wise, you'll just jump off the edge if you were standing there facing down. Try backing up a little and moving forward. Sorry it's like this, i'm not really a scripter, I just throught I'd try.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top