RPG Fusion
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.



 
AccueilPortailRechercherDernières imagesS'enregistrerConnexion
-34%
Le deal à ne pas rater :
-34% LG OLED55B3 – TV OLED 4K 55″ 2023 – 100Hz HDR 10+, ...
919 € 1399 €
Voir le deal

 

 Sauter au dessus de terrains

Aller en bas 
AuteurMessage
Invité
Invité
Anonymous



Sauter au dessus de terrains Empty
MessageSujet: Sauter au dessus de terrains   Sauter au dessus de terrains EmptyMar 05 Fév 2008, 18:39

Sauter au dessus de terrains
-----------------------------


Auteur : Si quelqu'un le connaît Fait le parvenir !

Grâce à ce script, vous pouvez sauter par dessus une case de terrain, en appuyant sur [ESPACE]. Il est configurable, voir fin du post !


Créez un script au dessus de Main apellé "walljump" avec :



Code:
#==============================================================================
# ? WallJump Script
#------------------------------------------------------------------------------
#==============================================================================

#==============================================================================
# ? 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

Paramètres du script :
JumpID = 1 # Le numéro de terrain au-dessus du quel on peut sauter.
MaxJump = 2 # Le maximum de cases que l'on peut sauter.
Il faut en jeu appuyer sur [ESPACE] pour sauter.
Revenir en haut Aller en bas
 
Sauter au dessus de terrains
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Sauter
» Nom au dessus du personnage
» L' avatar du dessus
» Crache-moi dessus... peu me chaut.
» superposer des animations /events par dessus une image

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
RPG Fusion :: BANQUE DU CODE :: Antre des Scripts :: Divers-
Sauter vers:  
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser