Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> A jumping script, not mine but i thought i should share it
Guy2610
post Jun 28 2006, 11:50 AM
Post #1


Level 4
Group Icon

Group: Member
Posts: 52
Type: Event Designer
RM Skill: Skilled




Hi everyone! I haven't been here in a while cause my computer is a piece of crap and extremely slow but i'm gonna start posting more. Well anyway, i have this jumping script that is pretty cool. It allows you to set how far you want your hero to jump and what he can jump over. It was made by Huitzilopoctli at rmxp.net but seeing as how the site is gone i thought i would post this because i don't think anyone else has it. well here it is. Insert above main and enjoy. :Smilie6: Oh to get it to work right go into the database to the tileset section and mark anything you want the hero to be able jump over with the terrain tag 1. :Thumbsup1:

Demo at the bottom.

CODE
#==============================================================================
# ■ WallJump Script
#------------------------------------------------------------------------------
# Enables jumping around the map
# Made by: Huitzilopoctli of rmxp.net as part of Interactive World
#------------------------------------------------------------------------------
# Press the A Input (ShiftKey) to jump
# The player will be able to jump over any passable tile, or 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
# To lock the player's facing while moving, hold down CTRL
#==============================================================================

#==============================================================================
# ● Customisation
#==============================================================================

JumpID = 1 # 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

# forces Game_Character's passable method to be used, so CTRL no longer makes
# the hero able to walk through walls
def passable?(x, y, d)
super(x, y, d)
end

def leap
# 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)

# Ow!
unless $game_map.terrain_tag(@x + xdir, @y + ydir) == JumpID or
$game_map.passable?(@x + xdir, @y + ydir, @direction, self)
# make the player jump
route = RPG::MoveRoute.new
route.list.clear
route.list.push(RPG::MoveCommand.new(37))
route.list.push(RPG::MoveCommand.new(14, [0, 0]))
route.list.push(RPG::MoveCommand.new(38))
route.list.push(RPG::MoveCommand.new(0))
route.repeat = false
$game_player.force_move_route(route)

# shake the screen
$game_screen.start_shake(7, 7, 5)

# display an "Ouch!" message
$game_temp.message_text = "Ouch!"
return
end

# finds the jumpable distance
dist = jumpable_distance

# wall jump
if dist.between?(1, MaxJump - 1) and
!$game_map.passable?(@x + (dist + 1) * xdir, @y + (dist + 1) * ydir, @direction, self) and
!($game_map.terrain_tag(@x + (dist + 1) * xdir, @y + (dist + 1) * ydir) == JumpID)
# finds the reverse direction
bounce_dir = @direction == 2 ? 8 : (@direction == 4 ? 6 : (@direction == 6 ? 4 : 2))

# finds the wall-jump distance
b_dist = jumpable_distance(bounce_dir, MaxJump + 2, @x + dist * xdir, @y + dist * ydir)

# finds the additions to x and y made by the reverse direction
b_xdir = (bounce_dir == 6 ? 1 : bounce_dir == 4 ? -1 : 0)
b_ydir = (bounce_dir == 2 ? 1 : bounce_dir == 8 ? -1 : 0)

# create the move_route
route = RPG::MoveRoute.new
route.list.clear
route.list.push(RPG::MoveCommand.new(37))
# add the normal jump
route.list.push(RPG::MoveCommand.new(14, [xdir * dist, ydir * dist]))
# add the wall jump
route.list.push(RPG::MoveCommand.new(14, [b_xdir * b_dist, b_ydir * b_dist]))
route.list.push(RPG::MoveCommand.new(38))
route.list.push(RPG::MoveCommand.new(0))
route.repeat = false

$game_player.force_move_route(route)

return
end

# creates a route for a normal jump and forces the player to follow it
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
# calls the normal update method
update_primary

# locks the facing if CTRL is pressed, else unlocks it
@direction_fix = Input.press?(Input::CTRL)

# leaps if Input::A is triggered
leap if Input.trigger?(Input::A) && !moving?
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


DEMO :Smilie6:

This post has been edited by Guy2610: Jul 5 2006, 09:56 AM


__________________________
269!!! my class number at central

You cannot kill what you did not create-Duality
You can't see California without Marlon Brando's eyes-eyeless

I may not have money, a car, or a job, but...I'm In Band!
Go to the top of the page
 
+Quote Post
   
CERU
post Jul 11 2006, 07:29 PM
Post #2


Level 2
Group Icon

Group: Member
Posts: 19
Type: None
RM Skill: Undisclosed




Jumping down doesn't work ..
Go to the top of the page
 
+Quote Post
   
Guy2610
post Jul 22 2006, 11:58 AM
Post #3


Level 4
Group Icon

Group: Member
Posts: 52
Type: Event Designer
RM Skill: Skilled




What do you mean? Jumping in all directions worked for me. Did you make sure to go in the database and give all the jumpable tiles the terrain tag it says in the script?

This post has been edited by Guy2610: Jul 24 2006, 09:31 AM


__________________________
269!!! my class number at central

You cannot kill what you did not create-Duality
You can't see California without Marlon Brando's eyes-eyeless

I may not have money, a car, or a job, but...I'm In Band!
Go to the top of the page
 
+Quote Post
   
Master WGS
post Jul 22 2011, 11:40 AM
Post #4



Group Icon

Group: Member
Posts: 1
Type: None
RM Skill: Undisclosed




Is there any way to disable the "Ouch!" message that pops up?
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Jul 23 2011, 06:21 AM
Post #5


Level 50
Group Icon

Group: +Gold Member
Posts: 1,520
Type: Scripter
RM Skill: Undisclosed




About a third of the way in to the script, you'll find the line
CODE
$game_temp.message_text = "Ouch!"

(You can just Ctrl + F for in in the script editor), if you put a # at the start of that line then it will stop showing the message smile.gif


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
carnie_natas
post Aug 24 2011, 02:45 PM
Post #6


~Noctem~Shinai~
Group Icon

Group: Revolutionary
Posts: 261
Type: Developer
RM Skill: Advanced




QUOTE (Night_Runner @ Jul 23 2011, 06:21 AM) *
About a third of the way in to the script, you'll find the line
CODE
$game_temp.message_text = "Ouch!"

(You can just Ctrl + F for in in the script editor), if you put a # at the start of that line then it will stop showing the message smile.gif

Hey night runner figured you'd know, what would i use in the script part of eventing to call this script for say a minigame or just one specific map as well as disable the script when i want.

This post has been edited by carnie_natas: Aug 24 2011, 02:46 PM


__________________________
Light one up!
You can run.....But you'll only die tired!
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th May 2013 - 05:29 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker