RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Adjust Landing in a Jump Script

0 Members and 1 Guest are viewing this topic.

*
Rep: +0/-0Level 75
RMRK Junior
Hello all I wonder if you could help please...

Below is a sample code of a jumping script.

Code: [Select]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Simple Jump System by Nathmatt
# Version: 1.03
# Type: Custom Movement System
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This is the config:
#
# (Jump_Distance) is how far you want to jump.
#
# (Cant_Jump) is the terrain tag that you cant jump on.
#
# (Off_Switch_id) is the swith id used to turn off the jump.
#
# (Jump_key) is the key used to jump if using tons ads custom controls.
#
# (Jump_Animation) is if you want a speacial graphic for jumping
# add _jmp so 001-Fighter01 would be 001-Fighter01_jmp.
#
#-------------------------------------------------------------------------------
module Nathmatt_Config
Jump_Distance = 2
Jump_Animation = false
Off_Switch_id = 50
Jump_Key = 'Space'
# Terrain_Tags
Cant_Jump = 1
end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This is the update method:
#
#-------------------------------------------------------------------------------

class Game_Player < Game_Character


alias nathmatt_update update
def update
nathmatt_update
actor = $game_party.actors[0] unless actor == $game_party.actors[0]
if $tons_version != nil && $tons_version >= 5.40 &&
TONS_OF_ADDONS::CUSTOM_CONTROLS
if Input.trigger?(Input::Key[Nathmatt_Config::Jump_Key])
unless jumping? ||
$game_switches [Nathmatt_Config::Off_Switch_id]
c = Nathmatt_Config::Cant_Jump
d = Nathmatt_Config::Jump_Distance
case direction
when 2 then jump(0,d) unless check_terrain(0,d,c)
when 4 then jump(-d,0) unless check_terrain(-d,0,c)
when 6 then jump(d,0) unless check_terrain(d,0,c)
when 8 then jump(0,-d) unless check_terrain(0,-d,c)
end
end
end
else
if Input.trigger?(Input::A)
unless jumping? ||
$game_switches [Nathmatt_Config::Off_Switch_id]
c = Nathmatt_Config::Cant_Jump
d = Nathmatt_Config::Jump_Distance
case direction
when 2 then jump(0,d) unless check_terrain(0,d,c)
when 4 then jump(-d,0) unless check_terrain(-d,0,c)
when 6 then jump(d,0) unless check_terrain(d,0,c)
when 8 then jump(0,-d) unless check_terrain(0,-d,c)
end
end
end
end
if jumping? && Nathmatt_Config::Jump_Animation
@character_name_org = actor.character_name
@character_name = @character_name_org+'_jmp'
end
if @character_name != actor.character_name
@character_name = actor.character_name unless jumping?
end
end

def check_terrain(x,y,condition)
px = $game_player.x + x
py = $game_player.y + y
if $game_map.terrain_tag(px,py) == condition
return true
else
return false
end
end

end

It works great however I just want to be able to change one little thing...

Say if a player needs to jump 4 Tiles
and the Jump_Distance = 8
Instead of jumping all 8 Tiles
He should only Jump 4 because that's where the closest land place is.

Basically what I want to do is check the passiblity of each of the 8 tiles in front of character on all 3 layers and if there is an event there. Then I want the character to jump to the closest option. In example...

---Example 1----
(start) x x x o o x o o (max jump length*) *8 tiles

*x = can't pass *o = passable ground. (*each represent a tile)

If the Example 1 The player is jumping to the right, because the 4th tile is available to land on then the player should land there instead of the 8th tile because that's the max jump length.

The only time a player should jump 8 tiles is when a situation like this comes up as shown in Example 2.
---Example 2----
(start) x x x x x x x o (finish)

If also possible can it be defined within that code that the minimum jump length is 2 tiles?

I hope my explanation above helps.

****
Hey... my name's... Sashikinaroji...
Rep:
Level 83
fear me...
An interesting fix would be to do a mario style system where you can jump and adjust how far you go manually with the buttons... But I am not sure how to implement such a method... I am but an Eventer... I just have intriguing ideas...
Ok, DON'T EXPECT HELP FROM ME~! I will perhaps rant a bit, but don't expect me to do graphics for you, even if I say I will... I won't.

***
Rep:
Level 82
aka DigiDeity
Try this out:
Code: [Select]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Simple Jump System by Nathmatt
# Version: 1.03
# Type: Custom Movement System
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This is the config:
#
# (Jump_Distance) is how far you want to jump.
#
# (Cant_Jump) is the terrain tag that you cant jump on.
#
# (Off_Switch_id) is the swith id used to turn off the jump.
#
# (Jump_key) is the key used to jump if using tons ads custom controls.
#
# (Jump_Animation) is if you want a speacial graphic for jumping
# add _jmp so 001-Fighter01 would be 001-Fighter01_jmp.
#
#-------------------------------------------------------------------------------
module Nathmatt_Config
Jump_Distance = 2
Jump_Animation = false
Off_Switch_id = 50
Jump_Key = 'Space'
# Terrain_Tags
Cant_Jump = 1
end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This is the update method:
#
#-------------------------------------------------------------------------------

class Game_Player < Game_Character


alias nathmatt_update update
def update
nathmatt_update
actor = $game_party.actors[0] unless actor == $game_party.actors[0]
if $tons_version != nil && $tons_version >= 5.40 &&
TONS_OF_ADDONS::CUSTOM_CONTROLS
if Input.trigger?(Input::Key[Nathmatt_Config::Jump_Key])
unless jumping? ||
$game_switches [Nathmatt_Config::Off_Switch_id]
c = Nathmatt_Config::Cant_Jump
max_d = Nathmatt_Config::Jump_Distance
for i in 1..max_d
case direction
when 2; if check_terrain(0,i,c) then d = i end; break;
when 4; if check_terrain(-i,0,c) then d = i end; break;
when 6; if check_terrain(i,0,c) then d = i end; break;
when 8; if check_terrain(0,-i,c) then d = i end; break;
end
end
case direction
when 2 then jump(0,d) unless check_terrain(0,d,c)
when 4 then jump(-d,0) unless check_terrain(-d,0,c)
when 6 then jump(d,0) unless check_terrain(d,0,c)
when 8 then jump(0,-d) unless check_terrain(0,-d,c)
end
end
end
else
if Input.trigger?(Input::A)
unless jumping? ||
$game_switches [Nathmatt_Config::Off_Switch_id]
c = Nathmatt_Config::Cant_Jump
max_d = Nathmatt_Config::Jump_Distance
for i in 1..max_d
case direction
when 2; if check_terrain(0,i,c) then d = i end; break;
when 4; if check_terrain(-i,0,c) then d = i end; break;
when 6; if check_terrain(i,0,c) then d = i end; break;
when 8; if check_terrain(0,-i,c) then d = i end; break;
end
end
case direction
when 2 then jump(0,d) unless check_terrain(0,d,c)
when 4 then jump(-d,0) unless check_terrain(-d,0,c)
when 6 then jump(d,0) unless check_terrain(d,0,c)
when 8 then jump(0,-d) unless check_terrain(0,-d,c)
end
end
end
end
if jumping? && Nathmatt_Config::Jump_Animation
@character_name_org = actor.character_name
@character_name = @character_name_org+'_jmp'
end
if @character_name != actor.character_name
@character_name = actor.character_name unless jumping?
end
end

def check_terrain(x,y,condition)
px = $game_player.x + x
py = $game_player.y + y
if $game_map.terrain_tag(px,py) == condition
return true
else
return false
end
end

end
I wasn't bale to test it, cause there some other scripts this one uses so it wasn't possible. :( But it should work.

Deity
Greetings
DigiDeity

├Work┤
├Contact┤