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


Forum traitant du logiciel RPG Maker tout en français ! Entraide, tutos, scripts, ressources, hébergement de vos projets RPG Maker 2000, 2003, XP et VX. Venez les présenter !
 
AccueilDernières imagesRechercherS'enregistrerConnexion
Le Deal du moment : -24%
PC Portable Gaming 15.6″ Medion Erazer Deputy ...
Voir le deal
759.99 €

 

 [VX]8 directions

Aller en bas 
AuteurMessage
Naqqah
Administrateur
Administrateur
Naqqah


Masculin Nombre de messages : 844
Age : 28
Localisation : Parti manger un ours
Date d'inscription : 22/02/2009

[VX]8 directions Empty
MessageSujet: [VX]8 directions   [VX]8 directions EmptySam 13 Fév - 13:02

Auteur : Inconnu

Fonction :
Permet d'avoir plus de direction pour le héros : en diagonale

Installation :
Allez dans l'éditeur de script, copiez le script et collez le au dessus de "Main"

Utilisation :
Aucune

Code :
Code:
#==============================================================================

# ¦ Game_Player

#------------------------------------------------------------------------------

# ?????????????????????????????????????

# ??????????????????????? $game_player ????????

#==============================================================================



class Game_Player < Game_Character
 
  #--------------------------------------------------------------------------
 
  # ? ??
 
  #--------------------------------------------------------------------------
 
  CENTER_X = (544 / 2 - 16) * 8 # ????? X ?? * 8
 
  CENTER_Y = (416 / 2 - 16) * 8 # ????? Y ?? * 8
 
  #--------------------------------------------------------------------------
 
  # ? ??????????
 
  #--------------------------------------------------------------------------
 
  attr_reader :vehicle_type # ????????????? (-1:??)
 
  #--------------------------------------------------------------------------
 
  # ? ?????????
 
  #--------------------------------------------------------------------------
 
  def initialize
   
    super
   
    @vehicle_type = -1
   
    @vehicle_getting_on = false # ??????????
   
    @vehicle_getting_off = false # ???????????
   
    @transferring = false # ???????
   
    @new_map_id = 0 # ??? ??? ID
   
    @new_x = 0 # ??? X ??
   
    @new_y = 0 # ??? Y ??
   
    @new_direction = 0 # ??????
   
    @walking_bgm = nil # ???? BGM ???
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????
 
  #--------------------------------------------------------------------------
 
  def stopping?
   
    return false if @vehicle_getting_on
   
    return false if @vehicle_getting_off
   
    return super
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ???????
 
  # map_id : ??? ID
 
  # x : X ??
 
  # y : Y ??
 
  # direction : ??????
 
  #--------------------------------------------------------------------------
 
  def reserve_transfer(map_id, x, y, direction)
   
    @transferring = true
   
    @new_map_id = map_id
   
    @new_x = x
   
    @new_y = y
   
    @new_direction = direction
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????????
 
  #--------------------------------------------------------------------------
 
  def transfer?
   
    return @transferring
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ???????
 
  #--------------------------------------------------------------------------
 
  def perform_transfer
   
    return unless @transferring
   
    @transferring = false
   
    set_direction(@new_direction)
   
    if $game_map.map_id != @new_map_id
     
      $game_map.setup(@new_map_id) # ???????
     
    end
   
    moveto(@new_x, @new_y)
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????????
 
  # x : X ??
 
  # y : Y ??
 
  #--------------------------------------------------------------------------
 
  def map_passable?(x, y)
   
    case @vehicle_type
     
    when 0 # ???
     
      return $game_map.boat_passable?(x, y)
     
    when 1 # ???
     
      return $game_map.ship_passable?(x, y)
     
    when 2 # ???
     
      return true
     
    else # ??
     
      return $game_map.passable?(x, y)
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  # x : X ??
 
  # y : Y ??
 
  #--------------------------------------------------------------------------
 
  def can_walk?(x, y)
   
    last_vehicle_type = @vehicle_type # ?????????
   
    @vehicle_type = -1 # ?????????
   
    result = passable?(x, y) # ??????
   
    @vehicle_type = last_vehicle_type # ?????????
   
    return result
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????????
 
  # x : X ??
 
  # y : Y ??
 
  #--------------------------------------------------------------------------
 
  def airship_land_ok?(x, y)
   
    unless $game_map.airship_land_ok?(x, y)
     
      return false # ?????????????
     
    end
   
    unless $game_map.events_xy(x, y).empty?
     
      return false # ????????????????????
     
    end
   
    return true # ???
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????????????????
 
  #--------------------------------------------------------------------------
 
  def in_vehicle?
   
    return @vehicle_type >= 0
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????????????
 
  #--------------------------------------------------------------------------
 
  def in_airship?
   
    return @vehicle_type == 2
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ????????
 
  #--------------------------------------------------------------------------
 
  def dash?
   
    return false if @move_route_forcing
   
    return false if $game_map.disable_dash?
   
    return false if in_vehicle?
   
    return Input.press?(Input::A)
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ????????????
 
  #--------------------------------------------------------------------------
 
  def debug_through?
   
    return false unless $TEST
   
    return Input.press?(Input::CTRL)
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????????????????????
 
  # x : X ??
 
  # y : Y ??
 
  #--------------------------------------------------------------------------
 
  def center(x, y)
   
    display_x = x * 256 - CENTER_X # ?????
   
    unless $game_map.loop_horizontal? # ?????????
     
      max_x = ($game_map.width - 17) * 256 # ??????
     
      display_x = [0, [display_x, max_x].min].max # ?????
     
    end
   
    display_y = y * 256 - CENTER_Y # ?????
   
    unless $game_map.loop_vertical? # ?????????
     
      max_y = ($game_map.height - 13) * 256 # ??????
     
      display_y = [0, [display_y, max_y].min].max # ?????
     
    end
   
    $game_map.set_display_pos(display_x, display_y) # ??????
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ???????
 
  # x : X ??
 
  # y : Y ??
 
  #--------------------------------------------------------------------------
 
  def moveto(x, y)
   
    super
   
    center(x, y) # ??????
   
    make_encounter_count # ?????????
   
    if in_vehicle? # ?????????
     
      vehicle = $game_map.vehicles[@vehicle_type] # ??????
     
      vehicle.refresh # ??????
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ????
 
  #--------------------------------------------------------------------------
 
  def increase_steps
   
    super
   
    return if @move_route_forcing
   
    return if in_vehicle?
   
    $game_party.increase_steps
   
    $game_party.on_player_walk
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????? ??????
 
  #--------------------------------------------------------------------------
 
  def encounter_count
   
    return @encounter_count
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????? ??????
 
  #--------------------------------------------------------------------------
 
  def make_encounter_count
   
    if $game_map.map_id != 0
     
      n = $game_map.encounter_step
     
      @encounter_count = rand(n) + rand(n) + 1 # ????? 2 ???????
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  # area : ?????? (RPG::Area)
 
  #--------------------------------------------------------------------------
 
  def in_area?(area)
   
    return false if area == nil
   
    return false if $game_map.map_id != area.map_id
   
    return false if @x < area.rect.x
   
    return false if @y < area.rect.y
   
    return false if @x >= area.rect.x + area.rect.width
   
    return false if @y >= area.rect.y + area.rect.height
   
    return true
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????????????? ID ???
 
  #--------------------------------------------------------------------------
 
  def make_encounter_troop_id
   
    encounter_list = $game_map.encounter_list.clone
   
    for area in $data_areas.values
     
      encounter_list += area.encounter_list if in_area?(area)
     
    end
   
    if encounter_list.empty?
     
      make_encounter_count
     
      return 0
     
    end
   
    return encounter_list[rand(encounter_list.size)]
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def refresh
   
    if $game_party.members.size == 0
     
      @character_name = ""
     
      @character_index = 0
     
    else
     
      actor = $game_party.members[0] # ??????????
     
      @character_name = actor.character_name
     
      @character_index = actor.character_index
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ????????????
 
  # triggers : ???????
 
  #--------------------------------------------------------------------------
 
  def check_event_trigger_here(triggers)
   
    return false if $game_map.interpreter.running?
   
    result = false
   
    for event in $game_map.events_xy(@x, @y)
     
      if triggers.include?(event.trigger) and event.priority_type != 1
       
        event.start
       
        result = true if event.starting
       
      end
     
    end
   
    return result
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ???????????
 
  # triggers : ???????
 
  #--------------------------------------------------------------------------
 
  def check_event_trigger_there(triggers)
   
    return false if $game_map.interpreter.running?
   
    result = false
   
    front_x = $game_map.x_with_direction(@x, @direction)
   
    front_y = $game_map.y_with_direction(@y, @direction)
   
    for event in $game_map.events_xy(front_x, front_y)
     
      if triggers.include?(event.trigger) and event.priority_type == 1
       
        event.start
       
        result = true
       
      end
     
    end
   
    if result == false and $game_map.counter?(front_x, front_y)
     
      front_x = $game_map.x_with_direction(front_x, @direction)
     
      front_y = $game_map.y_with_direction(front_y, @direction)
     
      for event in $game_map.events_xy(front_x, front_y)
       
        if triggers.include?(event.trigger) and event.priority_type == 1
         
          event.start
         
          result = true
         
        end
       
      end
     
    end
   
    return result
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ???????????
 
  # x : X ??
 
  # y : Y ??
 
  #--------------------------------------------------------------------------
 
  def check_event_trigger_touch(x, y)
   
    return false if $game_map.interpreter.running?
   
    result = false
   
    for event in $game_map.events_xy(x, y)
     
      if [1,2].include?(event.trigger) and event.priority_type == 1
       
        event.start
       
        result = true
       
      end
     
    end
   
    return result
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????????????
 
  #--------------------------------------------------------------------------
 
  def move_by_input
   
    return unless movable?
   
    return if $game_map.interpreter.running?
   
    case Input.dir8
     
    when 1
     
      move_lower_left
     
    when 2
     
      move_down
     
    when 3
     
      move_lower_right
     
    when 4
     
      move_left
     
    when 6
     
      move_right
     
    when 7
     
      move_upper_left
     
    when 8
     
      move_up
     
    when 9
     
      move_upper_right
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def movable?
   
    return false if moving? # ???
   
    return false if @move_route_forcing # ????????
   
    return false if @vehicle_getting_on # ???????
   
    return false if @vehicle_getting_off # ????????
   
    return false if $game_message.visible # ????????
   
    return false if in_airship? and not $game_map.airship.movable?
   
    return true
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def update
   
    last_real_x = @real_x
   
    last_real_y = @real_y
   
    last_moving = moving?
   
    move_by_input
   
    super
   
    update_scroll(last_real_x, last_real_y)
   
    update_vehicle
   
    update_nonmoving(last_moving)
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ???????
 
  #--------------------------------------------------------------------------
 
  def update_scroll(last_real_x, last_real_y)
   
    ax1 = $game_map.adjust_x(last_real_x)
   
    ay1 = $game_map.adjust_y(last_real_y)
   
    ax2 = $game_map.adjust_x(@real_x)
   
    ay2 = $game_map.adjust_y(@real_y)
   
    if ay2 > ay1 and ay2 > CENTER_Y
     
      $game_map.scroll_down(ay2 - ay1)
     
    end
   
    if ax2 < ax1 and ax2 < CENTER_X
     
      $game_map.scroll_left(ax1 - ax2)
     
    end
   
    if ax2 > ax1 and ax2 > CENTER_X
     
      $game_map.scroll_right(ax2 - ax1)
     
    end
   
    if ay2 < ay1 and ay2 < CENTER_Y
     
      $game_map.scroll_up(ay1 - ay2)
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def update_vehicle
   
    return unless in_vehicle?
   
    vehicle = $game_map.vehicles[@vehicle_type]
   
    if @vehicle_getting_on # ?????
     
      if not moving?
       
        @direction = vehicle.direction # ?????
       
        @move_speed = vehicle.speed # ???????
       
        @vehicle_getting_on = false # ??????
       
        @transparent = true # ???
       
      end
     
    elsif @vehicle_getting_off # ??????
     
      if not moving? and vehicle.altitude == 0
       
        @vehicle_getting_off = false # ???????
       
        @vehicle_type = -1 # ????????
       
        @transparent = false # ?????
       
      end
     
    else # ?????????
     
      vehicle.sync_with_player # ????????????
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ???????????
 
  # last_moving : ??????????
 
  #--------------------------------------------------------------------------
 
  def update_nonmoving(last_moving)
   
    return if $game_map.interpreter.running?
   
    return if moving?
   
    return if check_touch_event if last_moving
   
    if not $game_message.visible and Input.trigger?(Input::C)
     
      return if get_on_off_vehicle
     
      return if check_action_event
     
    end
   
    update_encounter if last_moving
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ?????????
 
  #--------------------------------------------------------------------------
 
  def update_encounter
   
    return if $TEST and Input.press?(Input::CTRL) # ????????
   
    return if in_vehicle? # ??????????
   
    if $game_map.bush?(@x, @y) # ????
     
      @encounter_count -= 2 # ????? 2 ???
     
    else # ??????
     
      @encounter_count -= 1 # ????? 1 ???
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??(???)???????????
 
  #--------------------------------------------------------------------------
 
  def check_touch_event
   
    return false if in_airship?
   
    return check_event_trigger_here([1,2])
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ????????????????
 
  #--------------------------------------------------------------------------
 
  def check_action_event
   
    return false if in_airship?
   
    return true if check_event_trigger_here([0])
   
    return check_event_trigger_there([0,1,2])
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def get_on_off_vehicle
   
    return false unless movable?
   
    if in_vehicle?
     
      return get_off_vehicle
     
    else
     
      return get_on_vehicle
     
    end
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  # ??????????????????
 
  #--------------------------------------------------------------------------
 
  def get_on_vehicle
   
    front_x = $game_map.x_with_direction(@x, @direction)
   
    front_y = $game_map.y_with_direction(@y, @direction)
   
    if $game_map.airship.pos?(@x, @y) # ???????????
     
      get_on_airship
     
      return true
     
    elsif $game_map.ship.pos?(front_x, front_y) # ??????????
     
      get_on_ship
     
      return true
     
    elsif $game_map.boat.pos?(front_x, front_y) # ??????????
     
      get_on_boat
     
      return true
     
    end
   
    return false
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def get_on_boat
   
    @vehicle_getting_on = true # ????????
   
    @vehicle_type = 0 # ????????
   
    force_move_forward # ????
   
    @walking_bgm = RPG::BGM::last # ???? BGM ??
   
    $game_map.boat.get_on # ??????
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def get_on_ship
   
    @vehicle_getting_on = true # ??
   
    @vehicle_type = 1 # ????????
   
    force_move_forward # ????
   
    @walking_bgm = RPG::BGM::last # ???? BGM ??
   
    $game_map.ship.get_on # ??????
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ??????
 
  #--------------------------------------------------------------------------
 
  def get_on_airship
   
    @vehicle_getting_on = true # ???????
   
    @vehicle_type = 2 # ????????
   
    @through = true # ???? ON
   
    @walking_bgm = RPG::BGM::last # ???? BGM ??
   
    $game_map.airship.get_on # ??????
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ????????
 
  # ?????????????????
 
  #--------------------------------------------------------------------------
 
  def get_off_vehicle
   
    if in_airship? # ???
     
      return unless airship_land_ok?(@x, @y) # ???????
     
    else # ???·???
     
      front_x = $game_map.x_with_direction(@x, @direction)
     
      front_y = $game_map.y_with_direction(@y, @direction)
     
      return unless can_walk?(front_x, front_y) # ???????
     
    end
   
    $game_map.vehicles[@vehicle_type].get_off # ?????
   
    if in_airship? # ???
     
      @direction = 2 # ????
     
    else # ???·???
     
      force_move_forward # ????
     
      @transparent = false # ?????
     
    end
   
    @vehicle_getting_off = true # ????????
   
    @move_speed = 4 # ???????
   
    @through = false # ???? OFF
   
    @walking_bgm.play # ???? BGM ??
   
    make_encounter_count # ?????????
   
  end
 
  #--------------------------------------------------------------------------
 
  # ? ????????
 
  #--------------------------------------------------------------------------
 
  def force_move_forward
   
    @through = true # ???? ON
   
    move_forward # ????
   
    @through = false # ???? OFF
   
  end
 
end

Merci à RPG Creative
Revenir en haut Aller en bas
 
[VX]8 directions
Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
New RPG Maker :: Making :: Ressources :: Grand livre des ressources :: Partage de scripts :: Utilitaire-
Sauter vers: