Jump to content
Rpg²S Forum
  • 0

Problema conflitto fra due script


Grawel
 Share

Question

Avrei un problema di compatibilita con 2 script molto utili il primo permette di far saltare il personaggio tenendo conto dei tail in cui puo e non puo saltare

#------------------------------------------------------------------------------#
#  Galv's Jump Ability
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.6
#------------------------------------------------------------------------------#
#  2013-06-02 - Version 1.6 - fixed a bug with region block jumping
#  2013-03-14 - Version 1.5 - fixed priority bug when jumping behind things
#                           - cleaned up code a bit
#  2013-01-15 - Version 1.4 - added follower jumping
#  2013-01-11 - Version 1.3 - added ability to make event pages block jumping
#  2012-12-05 - Version 1.2 - fixed some more bugs
#  2012-11-30 - Version 1.1 - fixed jumping in vehicles bug
#  2012-11-29 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  This script allows the player to jump with the press of a button. The player
#  will jump as far as their max distance will take them without landing on a
#  blocked tile. Use regions to block players jumping completely to prevent the
#  player from doing things like jumping between rooms.
#------------------------------------------------------------------------------#
#  INSTRUCTIONS:
#  Put script under Materials and above Main
#  Read options and settings below.
#------------------------------------------------------------------------------#
  
#------------------------------------------------------------------------------#
#  COMMENT FOR EVENT (Must be first event command)
#------------------------------------------------------------------------------#
#
#  <block>
#
#  add this comment as the first event command of a page to make it unable to
#  be jumped over. Change the page to a new event page without the comment when
#  you want it to be jumpable.
  
#------------------------------------------------------------------------------#
#  NOTETAG FOR ACTORS, ARMORS, WEAPONS
#------------------------------------------------------------------------------#
#
#  <jump_bonus: x>        # Adds that many tiles to jump distance
#
#------------------------------------------------------------------------------#
#  Only the jump bonus for the party leader and his/her equips are calculated
#------------------------------------------------------------------------------#
#  SCRIPT CALL:
#  You can change an actor's jump bonus (that was set with the notetag) during
#  the game with a script call:
#
#  jump_bonus(actor_id,jump_bonus)
#
#  EXAMPLE:
#  jump_bonus(3,2)         # Changes actor 3's jump bonus to 2
#------------------------------------------------------------------------------#
  
($imported ||= {})["Galvs_Jump_Ability"] = true
module Galv_Jump
    
#------------------------------------------------------------------------------#
#  SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
# ISTRUZIONI ITALIANE
#cambiare i parametri sotto come si desidera
#
#per modificarli durante il gioco :
# CON SCRIPT:    jump_bonus(IDeroe,ValoreDiJump)
# con equip: aggiungere nei commenti: <jump_bonus: x>
#
#
#
#------------------------------------------------------------------------------#
  DISABLE_SWITCH =40         # Cannot jump when this switch is ON
    
  BUTTON = :X                # Button to press to jump. :X is "a" key.
    
  DEFAULT_DISTANCE = 1      # Distance player can jump with no bonuses
  SPRINT_BONUS = -1           # Distance increased with a running jump
    
  JUMP_SE = ["Jump2", 50, 120]
    
  MAX_JUMP_BONUS = 3         # The maximum bonus you can get from equips/actors
    
  NO_JUMP_REGIONS = [1,2,3]  # Region ID's that the player cannot jump over
  
#------------------------------------------------------------------------------#
#  END SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
  
end
  
class RPG::BaseItem
  def jump_bonus
    if @jump_bonus.nil?
      if @note =~ /<jump_bonus: (.*)>/i
        @jump_bonus = $1.to_i
      else
        @jump_bonus = 0
      end
    end
    @jump_bonus
  end
end # RPG::BaseItem
  
  
class Game_Player < Game_Character
  attr_accessor :priority_type
    
  alias galv_jump_player_initialize initialize
  def initialize
    galv_jump_player_initialize
    @jump_equip_bonus = 0
  end
  
  alias galv_jump_player_refresh refresh
  def refresh
    get_jump_equip_bonus
    galv_jump_player_refresh
  end
    
  def get_jump_equip_bonus
    bonus = 0 + $game_party.leader.jump_bonus
    $game_party.leader.equips.each { |eq| bonus += eq.jump_bonus if !eq.nil?}
    @jump_equip_bonus = [bonus,Galv_Jump::MAX_JUMP_BONUS].min
  end
    
  alias galv_jump_move_by_input move_by_input
  def move_by_input
    return if jumping?
    @priority_type = 1 if !jumping?
    galv_jump_move_by_input
    if !$game_switches[Galv_Jump::DISABLE_SWITCH] && Input.trigger?(Galv_Jump::BUTTON)
      do_jump if !$game_map.interpreter.running? && !jumping? && normal_walk?
    end
  end
    
  def do_jump
    get_bonuses
    @distance = Galv_Jump::DEFAULT_DISTANCE + @jump_bonus
    check_region
    check_distance
    if @can_jump
      RPG::SE.new(Galv_Jump::JUMP_SE[0], Galv_Jump::JUMP_SE[1], Galv_Jump::JUMP_SE[2]).play
      jump(@jump_x, @jump_y)
      @followers.each { |f| f.jump(@x - f.x, @y - f.y) }
    end
  end
    
  def get_bonuses
    @jump_bonus = 0 + @jump_equip_bonus
    @jump_bonus += Galv_Jump::SPRINT_BONUS if dash? && moving?
  end
    
  def check_region
    @max_x = 0
    @max_y = 0
    case @direction
    when 2
      @max_y = @distance
      (@distance+1).times { |i| return @max_y = i if stopper?(@x, @y+i+1) }
    when 4
      @max_x = -@distance
      (@distance+1).times { |i| return @max_x = -i if stopper?(@x-i-1, @y) }
    when 6
      @max_x = @distance
      (@distance+1).times { |i| return @max_x = i if stopper?(@x+i+1, @y) }
    when 8
      @max_y = -@distance
      (@distance+1).times { |i| return @max_y = -i if stopper?(@x, @y-i-1) }
    end
  end
    
  def stopper?(x,y)
    Galv_Jump::NO_JUMP_REGIONS.include?($game_map.region_id(x,y)) ||
      !$game_map.stopper_event?(x,y)
  end
    
  def canpass?(x,y)
    map_passable?(x, y, @direction) &&
    $game_map.blocking_event?(x,y) ||
    Galv_Jump::NO_JUMP_REGIONS.include?($game_map.region_id(x,y))
  end
    
  def check_distance
    @jump_x = 0
    @jump_y = 0
    ch = []
    @can_jump = true
  
    case @direction
    when 2
      @jump_y = @distance
      @distance.times { |i| ch << @jump_y - i if canpass?(@x, @y + @jump_y - i) }
      ch.delete_if {|x| x > @max_y }
      @jump_y = ch.max if !ch.empty?
    when 4
      @jump_x = -@distance
      @distance.times { |i| ch << @jump_x + i if canpass?(@x + @jump_x + i, @y) }
      ch.delete_if {|x| x < @max_x }
      @jump_x = ch.min if !ch.empty?
    when 6
      @jump_x = @distance
      @distance.times { |i| ch << @jump_x - i if canpass?(@x + @jump_x - i, @y) }
      ch.delete_if {|x| x > @max_x }
      @jump_x = ch.max if !ch.empty?
    when 8
      @jump_y = -@distance
      @distance.times { |i| ch << @jump_y + i if canpass?(@x, @y + @jump_y + i) }
      ch.delete_if {|x| x < @max_y }
      @jump_y = ch.min if !ch.empty?
    end
    if ch.empty?
      @jump_y = 0
      @jump_x = 0
      @can_jump = false
    end
  end
    
  def jump(x_plus, y_plus)
    @priority_type = 1.5
    super
  end
end # Game_Player < Game_Character
  
  
class Game_Map
  def blocking_event?(x,y)
    events_xy(x,y).each { |e| return false if e.priority_type == 1 }
     return true
   end
  
  def stopper_event?(x,y)
    events_xy(x,y).each { |e|
      next if e.list.nil?
      return false if e.list[0].code == 108 && e.list[0].parameters[0] == "<block>"
    }
     return true
   end
end # Game_Map
  
  
class Game_Actor < Game_Battler
  attr_accessor :jump_bonus
    
  alias galv_jump_actor_initialize initialize
  def initialize(actor_id)
    galv_jump_actor_initialize(actor_id)
    @jump_bonus = $data_actors[actor_id].jump_bonus
  end
end # Game_Actor < Game_Battler
  
  
class Scene_Menu < Scene_MenuBase
  def return_scene
    $game_player.refresh
    super
  end
end # Scene_Menu < Scene_MenuBase
  
class Game_Interpreter
  def jump_bonus(actor,bonus)
    $game_actors[actor].jump_bonus = bonus
    $game_player.refresh
  end
end # Game_Interpreter

il secondo ESTREMAMENTE UTILE gestisce la grafica dei tail...quando passarci sopra e quando sotto per mette di far camminare il personaggo in diagonale in alcuni tail...

###--------------------------------------------------------------------------###
#  CP Terrain Tags script                                                      #
#  Version 1.2                                                                 #
#                                                                              #
#      Credits:                                                                #
#  Original code by: Neon Black                                                #
#  Modified by:                                                                #
#                                                                              #
#  This work is licensed under the Creative Commons Attribution-NonCommercial  #
#  3.0 Unported License. To view a copy of this license, visit                 #
#  http://creativecommons.org/licenses/by-nc/3.0/.                             #
#  Permissions beyond the scope of this license are available at               #
#  http://cphouseset.wordpress.com/liscense-and-terms-of-use/.                 #
#                                                                              #
#      Contact:                                                                #
#  NeonBlack - neonblack23@live.com (e-mail) or "neonblack23" on skype         #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
#      Revision information:                                                   #
#  V1.2 - 12.22.2012                                                           #
#   Fixed an issue related to loading a saved game                             #
#  V1.1 - 12.3.2012                                                            #
#   Rewrote passage checking                                                   #
#   Fixed various passability issues                                           #
#  V1.0 - 11.30.2012                                                           #
#   Wrote and debugged main script                                             #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
#      Compatibility:                                                          #
#  Alias       - Game_CharacterBase: passable?                                 #
#                Game_Player: moveto                                           #
#                Game_Follower: chase_preceding_character                      #
#                Game_Map: setup,                                              #
#                Scene_Load: on_load_success                                   #
#  Overwrites  - Game_Player: move_by_input                                    #
#                Game_Map: check_passage                                       #
#  New Objects - Game_CharacterBase: move_slope, slope_passable?               #
#                Game_Player: move_modif_direction, move_slope                 #
#                Game_Map: reset_map, init_fold, init_setup, add_tile_id,      #
#                          bridge_flip, bridge?                                #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
#      Instructions:                                                           #
#  Place this script in the "Materials" section of the scripts above main.     #
#  This script allows tiles on a map to be tagged using regions to change the  #
#  properties of those tiles.  This includes slopes, cover, blockers, and      #
#  bridges.  Each terrain type is detailed with each config option below.      #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
#      Config:                                                                 #
#  This is the config section of the script.  This script is split into a few  #
#  parts to make using it a little easier.  You may change these values to     #
#  fit your liking.                                                            #
#                                                                              #
module CP      # Do not edit                                                   #
module TERRAIN #  these lines.                                                 #
#                                                                              #
###-----                                                                -----###
#      Slope Options:                                                          #
# Slope terrains cause the player to move diagonally while walking over them,  #
# much like a horizontal stair case.  This only affects horizontal movement    #
# and has no effect on vertical movement.  As a general rule of thumb, all     #
# stair tiles must be marked with these tags even if they cannot be walked on. #
# Also, both slopes do not work if the bottom edges are touching, so avoid     #
# creating maps where this happens.  Note that events are no affected by these #
# tags, only player and followers are.                                         #
#                                                                              #
# Region tag for a slope with a shape like \.                                  #
DOWN_RIGHT = 16 # Default = 16                                                 #
#                                                                              #
# Region tag for a slope with a shape like /.                                  #
DOWN_LEFT  = 17 # Default = 17                                                 #
#                                                                              #
###-----                                                                -----###
#      Cover Options:                                                          #
# This affects cover and blocking region tags.  Cover tags cause the tile      #
# tagged to appear above characters and events.  Block tags cause the tagged   #
# tile to become impassible.  Because auto tiles have odd passage settings on  #
# inside tiles, it is recommended to use these tags on edges of cover tiles.   #
#                                                                              #
# The region tag for cover tiles.                                              #
COVER = 18 # Default = 18                                                      #
#                                                                              #
# The region id to use for block tiles.                                        #
BLOCK = 19 # Default = 19                                                      #
#                                                                              #
###-----                                                                -----###
#      Bridge Options:                                                         #
# This affects bridge and catwalk type tiles.  Bridges use tileset A while     #
# catwalks use tilesets B-E.  Bridges flip when the player steps onto a region #
# tagged as a lower or upper tile.  To prevent bugs, a player can only step    #
# from a bridge or catwalk tile onto another bridge or catwalk tile or a       #
# lower/upper region of the same type.  Also note that bridges use the CLEAR   #
# tile from above for when the bridge is flipped to lower.  Events also do NOT #
# function properly with bridges, so avoid having events on bridges.           #
#                                                                              #
# The region IDs to use for bridges and catwalks.                              #
BRIDGE = 20 # Default = 20                                                     #
CATWALK = 21 # Default = 21                                                    #
#                                                                              #
# The region tags for the upper and lower enterances of the bridge.            #
LOWER = 22 # Default = 22                                                      #
UPPER = 23 # Default = 23                                                      #
###--------------------------------------------------------------------------###


###--------------------------------------------------------------------------###
#  The following lines are the actual core code of the script.  While you are  #
#  certainly invited to look, modifying it may result in undesirable results.  #
#  Modify at your own risk!                                                    #
###--------------------------------------------------------------------------###


end
end

$imported = {} if $imported.nil?
$imported["CP_TERRAIN"] = 1.1

class Game_CharacterBase
  def move_slope(horz, vert)
    @move_succeed = slope_passable?(x, y, horz, vert)
    if @move_succeed
      @x = $game_map.round_x_with_direction(@x, horz)
      @y = $game_map.round_y_with_direction(@y, vert)
      @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
      @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
      increase_steps
    end
    set_direction(horz) if @direction == reverse_dir(horz)
    set_direction(vert) if @direction == reverse_dir(vert)
  end
  
  def slope_passable?(x, y, horz, vert)
    x2 = $game_map.round_x_with_direction(x, horz)
    y2 = $game_map.round_y_with_direction(y, vert)
    return false unless $game_map.valid?(x2, y2)
    return true if @through || debug_through?
    return false if collide_with_characters?(x2, y2)
    (map_passable?(x, y, horz) && map_passable?(x2, y2, reverse_dir(vert))) ||
    (map_passable?(x, y, vert) && map_passable?(x2, y2, reverse_dir(horz)))
  end
  
  alias cp_terrain_pass passable?
  def passable?(x, y, d)
    x2 = $game_map.round_x_with_direction(x, d)
    y2 = $game_map.round_y_with_direction(y, d)
    if region_id == CP::TERRAIN::BRIDGE || region_id == CP::TERRAIN::CATWALK
      return true if @through || debug_through?
      sets = [CP::TERRAIN::BRIDGE, CP::TERRAIN::CATWALK]
      $game_map.bridge? ? sets.push(CP::TERRAIN::LOWER) : sets.push(CP::TERRAIN::UPPER)
      return false unless sets.include?($game_map.region_id(x2, y2))
    end
    cp_terrain_pass(x, y, d)
  end
end

class Game_Player < Game_Character
  def move_by_input
    return if !movable? || $game_map.interpreter.running?
    move_modif_direction
  end

  def move_modif_direction
    dir = Input.dir4
    return if dir <= 0
    case dir
    when 4
      if region_id == CP::TERRAIN::DOWN_LEFT
        set_direction(4)
        move_slope(4, 2)
      elsif $game_map.region_id(@x - 1, @y) == CP::TERRAIN::DOWN_RIGHT
        set_direction(4)
        move_slope(4, 8)
      else
        move_straight(dir)
      end
    when 6
      if region_id == CP::TERRAIN::DOWN_RIGHT
        set_direction(6)
        move_slope(6, 2)
      elsif $game_map.region_id(@x + 1, @y) == CP::TERRAIN::DOWN_LEFT
        set_direction(6)
        move_slope(6, 8)
      else
        move_straight(dir)
      end
    else
      move_straight(dir)
    end
    $game_map.bridge_flip(region_id)
  end
  
  def move_slope(horz, vert)
    @followers.move if slope_passable?(@x, @y, horz, vert)
    super
  end
  
  alias cp_fix_moveto moveto
  def moveto(x, y)
    cp_fix_moveto(x, y)
    $game_map.bridge_flip(region_id)
  end
end

class Game_Follower < Game_Character
  alias cp_slopes_chase chase_preceding_character
  def chase_preceding_character
    set_direction(@preceding_character.direction) unless moving?
    cp_slopes_chase
  end
end

class Game_Map
  alias cp_terrain_setup setup
  def setup(map_id)
    init_fold
    cp_terrain_setup(map_id)
    init_setup
  end
  
  def reset_map
    tf = @flip
    init_fold
    @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
    @tileset_id = @map.tileset_id
    init_setup
    id = tf ? CP::TERRAIN::LOWER : CP::TERRAIN::UPPER
    bridge_flip(id)
  end
  
  def init_fold
    @flip = false if @flip.nil?
    return_tiles
  end
  
  def init_setup
    @bridges = []; @catwalks = []; @tile_flag_set = {}
    width.times do |x|
      height.times do |y|
        id = region_id(x, y)
        if id == CP::TERRAIN::BRIDGE || id == CP::TERRAIN::UPPER
          bset = [x, y]
          bset.push(data[x, y, 2])
          bset.push(tileset.flags[data[x, y, 0]])
          @bridges.push(bset)
          add_tile_id(data[x, y, 0])
        end
        if id == CP::TERRAIN::CATWALK
          bset = [x, y]
          bset.push(tileset.flags[data[x, y, 2]])
          @catwalks.push(bset) 
        end
        next unless id == CP::TERRAIN::COVER
        add_tile_id(data[x, y, 0])
        data[x, y, 2] = data[x, y, 0]
        data[x, y, 0] = 0
        tileset.flags[data[x, y, 2]] = 0x10
      end
    end
  end
  
  def add_tile_id(id)
    @tile_flag_set = {} if @tile_flag_set.nil?
    return if @tile_flag_set.include?(id)
    @tile_flag_set[id] = tileset.flags[id]
  end
  
  def check_passage(x, y, bit)
    @tile_flag_set = {} if @tile_flag_set.nil?
    rid = region_id(x, y)
    return false if rid == CP::TERRAIN::BLOCK
    all_tiles(x, y).each do |tile_id|
      if (rid == CP::TERRAIN::BRIDGE && bridge?) ||
         (rid == CP::TERRAIN::COVER && tile_id == 0)
        flag = 0x600
      elsif @tile_flag_set.include?(tile_id) && rid != CP::TERRAIN::COVER
        flag = @tile_flag_set[tile_id]
      else
        flag = tileset.flags[tile_id]
      end
      next if flag & 0x10 != 0            # [☆]: No effect on passage
      return true  if flag & bit == 0     # [○] : Passable
      return false if flag & bit == bit   # [×] : Impassable
    end
    return false                          # Impassable
  end
  
  def bridge_flip(id)
    @flip = false if @flip.nil?
    case id
    when CP::TERRAIN::LOWER
      return if @flip
      @bridges.each do |set|
        x, y = set[0..1]
        data[x, y, 2] = data[x, y, 0]
        data[x, y, 0] = 0
        tileset.flags[data[x, y, 2]] = 0x10
      end
      @catwalks.each do |set|
        x, y = set[0..1]
        tileset.flags[data[x, y, 2]] = 0x10
      end
      @flip = true
    when CP::TERRAIN::UPPER
      return_tiles
    end
  end
  
  def return_tiles
    return if !@flip
    @bridges.each do |set|
      x, y = set[0..1]
      data[x, y, 0] = data[x, y, 2]
      data[x, y, 2] = set[2]
      tileset.flags[data[x, y, 0]] = set[3]
    end
    @catwalks.each do |set|
      x, y = set[0..1]
      tileset.flags[data[x, y, 2]] = set[2]
    end
    @flip = false
  end
  
  def bridge?
    @flip = false if @flip.nil?
    return @flip
  end
end

class Scene_Load < Scene_File
  alias cp_terrain_load on_load_success
  def on_load_success
    $game_map.reset_map
    cp_terrain_load
  end
end


###--------------------------------------------------------------------------###
#  End of script.                                                              #
###--------------------------------------------------------------------------###

vi prego di risolvere il mio problema grazie in anticipo

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...