Rpg²S Forum uses cookies. Read the Privacy Policy for more info. To remove this message, please click the button to the right:    I accept the use of cookies

Vai al contenuto

Rpg²S Forum uses cookies. Read the Privacy Policy for more info. To remove this message, please click the button to the right:    I accept the use of cookies

Screen Contest #90

Kamikun






  • Si prega di effettuare il log in prima di rispondere
Richiesta inventario in stile Resident Evil

    Misterdiablo94
  • Nuovo Arrivato

  • Utenti
  • Rens: 13
  • 2
  • Stelletta
  • 47 messaggi
  • Sesso:Maschio
  • Abilità:Esperto

#1 Inviato 04 July 2019 - 22:03 PM

Allora dato che per i miei due videogiochi ho utilizzato uno script inventario in stile Resident Evil su RPG Maker VX Ace, e siccome mi piacerebbe sviluppare un terzo capitolo su MV, vorrei che qualcuno mi aiutasse a riscrivere il codice per MV.

C'è qualcuno disposto ad aiutarmi? Lo script è questo. 

module RE_MENU
  BAR_POSITION_X = 3
  BAR_POSITION_Y = 0
end

module Special_Map
 
  Archive_ID = 12
  Archive_x = 17
  Archive_y = 13
 
  Option_ID = 11
  Option_x = 17
  Option_y = 13

  Map_ID_Variable = 6
  Coord_x_Variable = 7
  Coord_y_Variable = 8
 
  def self.set_coordinates
    $game_variables[Map_ID_Variable] = $game_map.map_id
    $game_variables[Coord_x_Variable] = $game_player.x
    $game_variables[Coord_y_Variable] = $game_player.y
  end
 
end

class Scene_Menu < Scene_MenuBase
    alias re_inventory_create_command_window create_command_window
    def create_command_window
        re_inventory_create_command_window
        @command_window.set_handler(:inventory,      method(:command_inventory))
    end
  
    def command_inventory
        SceneManager.call(Scene_RE_Menu)   
    end

end

class Window_MenuCommand < Window_Command
    alias re_inventory_add_main_commands add_main_commands
    def add_main_commands
        add_command("RE Inventory",   :inventory,   main_commands_enabled)
        re_inventory_add_main_commands
    end
end

class Scene_RE_Menu < Scene_Base

    attr_reader :help_window
  
    def start
        super
    Special_Map.set_coordinates
        load_windowskin
    $game_party.last_item.object = nil
    create_menu_window
        create_face_window
        create_name_window
        create_life_window       
        create_help_window
        create_weapon_window
        create_ammo_window
        create_equip_window
        create_use_window
        create_item_window
    @item_index = 0
    @item_window.select(-1)
    @menu_window.select(1)
    @menu_window.activate
    create_background
    end
 
    def load_windowskin
        @windowskin = Bitmap.new("Graphics/System/re_menu_skin")
    @windowskin2 = Bitmap.new("Graphics/System/re_menu_ski2")
    end

    def create_menu_window
    @menu_window = Window_RE_Command.new(167,10)
    @menu_window.windowskin = @windowskin
    @menu_window.set_handler(:option, method(:open_option))
    @menu_window.set_handler(:item, method(:go_inventory))
        @menu_window.set_handler(:exit, method(:return_map))
    @menu_window.set_handler(:cancel, method(:return_scene))
  end

    def create_face_window
        @face_window = Window_Base.new(0,43,100,100)
        @face_window.windowskin = @windowskin
        @face_window.padding = 8
        @face_window.contents = Bitmap.new(84,84)
        @face_window.draw_actor_face($game_party.members[0],-6,-6)   
    @face_window.hide
    end
  
    def create_name_window
        @name_window = Window_Base.new(0,138,100,48)
        @name_window.windowskin = @windowskin
        @name_window.draw_text(-16,0,100,24,$game_party.members[0].name,1)
    @name_window.hide
    end
  
    def create_life_window
        @life_window = Window_Base.new(100,54,259,50)
        @life_window.windowskin = @windowskin
  
        life_refresh
    end
  
    def create_help_window
        @help_window = Window_Help2.new(3,305,358,Graphics.height - 30)
        @help_window.windowskin = @windowskin
    end
  
    def create_weapon_window
        @weapon_window = Window_Base.new(0,53,Graphics.width-440,90)
        @weapon_window.windowskin = @windowskin
        @weapon_window.draw_RE_weapon($game_player.actor.weapons[0],0,0) if $game_player.actor.weapons[0]
    end
  
    def create_ammo_window
        @ammo_window = Window_Base.new(430,90+48,Graphics.width-430,48)
        @ammo_window.windowskin = @windowskin
        ammo_refresh
    @ammo_window.hide
    end
  
    def create_equip_window
        @equip_window = Window_RE_Equip.new(248,130+48)
        @equip_window.windowskin = @windowskin2
        @equip_window.set_handler(:cancel, method(:item_back))
        @equip_window.set_handler(:equip, method(:equip_weapon))
        @equip_window.set_handler(:remove, method(:remove_weapon))
    @equip_window.set_handler(:reload, method(:reload_weapon))
        @equip_window.deactivate
        @equip_window.hide
    end
  
    def    create_use_window
        @use_window = Window_RE_Use.new(248,130+48)
    @use_window.windowskin = @windowskin2
        @use_window.set_handler(:cancel, method(:item_back))
        @use_window.set_handler(:use, method(:use_item))
        @use_window.deactivate
        @use_window.hide
    end
  
    def    create_item_window
        @item_window = Window_RE_Item.new(359,20+33,191,395-48) #(353,40+48,191,375-48)    New Version (353,10+33,191,400-48)
        @item_window.windowskin = @windowskin
        @item_window.set_handler(:ok, method(:on_item_ok))
        @item_window.set_handler(:cancel, method(:exit_inventory))       
        @item_window.refresh
    end

  def create_background

   @background_sprite = Sprite.new

   @background_sprite.bitmap = Cache.picture ("Background Inventory")

   @background_sprite.x = 0

   @background_sprite.y = 0
 end
 
  
    def item_back
        @use_window.hide
        @equip_window.hide
  
        @item_window.refresh
        @item_window.activate
 
    end
  
    def on_item_ok
    $game_party.last_item.object = @item_window.item
        if @item_window.item.is_a?(RPG::Item)
            @use_window.set_item(@item_window.item)
            @use_window.refresh
            @use_window.activate
            @use_window.show
          
        elsif @item_window.item.is_a?(RPG::Weapon)
            @equip_window.set_item(@item_window.item)
            @equip_window.refresh
            @equip_window.activate
            @equip_window.show
    else
      RPG::SE.stop
      @item_window.activate
        end
    end
  
    def item
        @item_window.item
    end
  
    def equip_weapon
        $game_player.actor.change_equip(0,@item_window.item)
        weapon_refresh
        item_back
    end
  
    def remove_weapon
        $game_player.actor.change_equip(0,nil)
        weapon_refresh
        item_back
    end
 
  def reload_weapon
    weapon = $weapons.find{|weapon| weapon.weapon.name == $data_weapons[item.id].name}
    $game_party.items.each { |item|
      if item.id == weapon.magazine.id
        $game_party.lose_item(weapon.magazine,1)
        weapon.bullets += weapon.max
        Audio.se_play("Audio/Se/#{weapon.wav_name}_reload", 100, 100)
        break
      end
    }
    if weapon == $game_player.equipped_weapon
      weapon_refresh
    else
      ammo_refresh
    end
        item_back
  end
  
    def ammo_refresh
    @ammo_window.contents.clear
        if $game_player.equipped_weapon != nil
            string = sprintf( "Munizioni : %d",$game_player.equipped_weapon.bullets)
        else
            string =""
        end
        @ammo_window.draw_text(0,0,Graphics.width-430,24,string,0)
  
  end
 
    def weapon_refresh
        @weapon_window.contents.clear
        @weapon_window.draw_RE_weapon($game_player.actor.weapons[0],0,0) if $game_player.actor.weapons[0]
    ammo_refresh
    end
  
    def item_target_actors
        if !item.for_friend?
          []
        elsif item.for_all?
          $game_party.members
        else
          [$game_player.actor]
        end
    end
 
      #--------------------------------------------------------------------------
      # * Use Item on Actor
      #--------------------------------------------------------------------------
        def use_item_to_actors
            user = $game_player.actor
            item_target_actors.each do |target|
                item.repeats.times { target.item_apply(user, item) }
            end
        end
      #--------------------------------------------------------------------------
      # * Use Item
      #--------------------------------------------------------------------------
        def use_item
            Sound.play_use_item
            $game_player.actor.use_item(item)
            use_item_to_actors
            check_common_event
            check_gameover
            weapon_refresh
            life_refresh
      RPG::BGS.stop
            item_back
        end
  
      #--------------------------------------------------------------------------
      # * Determine if Common Event Is Reserved
      #    Transition to the map screen if the event call is reserved.
      #--------------------------------------------------------------------------
        def check_common_event
            SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
        end
      
    def life_refresh
 
    bar1 = Bitmap.new("Graphics/System/life_bar")
    bar2 = Bitmap.new("Graphics/System/blood_bar")
    x = RE_MENU::BAR_POSITION_X
    y = RE_MENU::BAR_POSITION_Y
  
    @life_window.contents.blt(x,y,bar2,bar2.rect)
  
    rate = $game_player.actor.hp*1.0/$game_player.actor.mhp
    rect = Rect.new(0,0,bar1.width * rate,bar1.height)
  
    @life_window.contents.blt(x,y,bar1,rect)
  end

  def go_inventory
    @item_window.select(0)
    @menu_window.select(-1)
    @menu_window.deactivate
    @item_window.activate
  end
 
  def exit_inventory
    @help_window.clear
    @item_index = @item_window.index
    @item_window.select(-1)
    @item_window.deactivate
    @menu_window.select(1)
    @menu_window.activate
  end
 
  def open_option
    $game_player.transparent = true
    $game_system.save_bgm
    RPG::BGS.stop
    $game_player.reserve_transfer(Special_Map::Option_ID,Special_Map::Option_x,Special_Map::Option_y)
    $game_player.perform_transfer
    SceneManager.call(Scene_Map)
    $game_switches[10] = false
  end
 
  def open_archive
    $game_player.transparent = true
    $game_system.save_bgm
    RPG::BGS.stop
    $game_player.reserve_transfer(Special_Map::Archive_ID,Special_Map::Archive_x,Special_Map::Archive_y)
    $game_player.perform_transfer
    SceneManager.call(Scene_Map)
    $game_switches[10] = false
  end

  def return_map
    map = $game_variables[Special_Map::Map_ID_Variable]
    x = $game_variables[Special_Map::Coord_x_Variable]
    y = $game_variables[Special_Map::Coord_y_Variable]
    if $game_map.map_id != map #se esco da un menu...
      $game_player.reserve_transfer(map,x,y) #ritorna nella mappa
      $game_system.replay_bgm #Riparte la bgm
      $game_switches[980] = true #si attiva la switch per togliere la dissolvenza
      $game_temp.reserve_common_event(43) #Si attiva l'evento comune per togliere la dissolvenza
    end
    return_scene
  end
end

class Window_RE_Equip < Window_Command

    def initialize(x,y)
        super(x,y)
    end
  
    def window_width
        return (Graphics.width-430)
    end
  
    def make_command_list
        add_command("Equip",   :equip,   equip_ok?)
        add_command("Rimuovi",  :remove,  remove_ok?)
    add_command("Ricarica",  :reload,  reload_ok?)
    end
 
  def reload_ok?
    if @item
     a = $weapons.find{|weapon| weapon.weapon.name == $data_weapons[@item.id].name}
     a && a.bullets == 0
   else
    b = false
    end
  end
 
    def equip_ok?
        @item != $game_player.actor.weapons[0]
    end
  
    def remove_ok?
        @item == $game_player.actor.weapons[0]
    end

    def set_item(item)       
        @item = item
    end
end

class Window_RE_Use < Window_Command

    def initialize(x,y)
        super(x,y)
    end
  
    def window_width
        return (Graphics.width-430)
    end
  
    def make_command_list
        add_command("Usa",   :use,   use_ok?)
    end
  
    def use_ok?
        actor = $game_player.actor
        actor.usable?(@item) && actor.item_test(actor,@item)
    end
  
    def set_item(item)
        @item = item
    end
end

#==============================================================================
# ** Window_ItemList
#------------------------------------------------------------------------------
#  This window displays a list of party items on the item screen.
#==============================================================================

class Window_RE_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @help_window = SceneManager.scene.help_window
    @data = []
  
  end

  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 2
  end
  def item_width
    return 80
  end
  def item_height
    return 80
  end
  def spacing
     return 0
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  #--------------------------------------------------------------------------
  # * Include in Item List?
  #--------------------------------------------------------------------------
  def include?(item)
        return true
  end
  #--------------------------------------------------------------------------
  # * Create Item List
  #--------------------------------------------------------------------------
    def make_item_list
        actor = $game_party.members[0]
        @data = actor.weapons
        @data += $game_party.all_items.select {|item| include?(item) }
    #    @data.push(nil) if include?(nil)
    end
  #--------------------------------------------------------------------------
  # * Restore Previous Selection Position
  #--------------------------------------------------------------------------
  def select_last
    select(@data.index($game_party.last_item.object) || 0)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
        rect = item_rect(index)
        if item.is_a?(RPG::Weapon)
            draw_RE_weapon(item,rect.x,rect.y+10)
        else
            draw_RE_item(item,rect.x,rect.y+10)
        end   
    end
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
    select_last
  end
end


class Window_Help2 < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x,y,width,height)
    super(x,y,width,height)
  
  end
  #--------------------------------------------------------------------------
  # * Set Text
  #--------------------------------------------------------------------------
  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Clear
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #     item : Skills and items etc.
  #--------------------------------------------------------------------------
  def set_item(item)
    set_text(item ? item.name + "" + item.description : "")
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    self.contents.font.size = 20
   # draw_text_ex(4, 0, @text)
    a = @text.scan(/(.+)/)
    draw_text(4,0, width , 24, a[0][0]) if a[0]
    draw_text(4,24, width , 24, a[1][0]) if a[1]
  end
end

class Window_Base

    def draw_RE_weapon(item, x, y, enabled = true)
        bmp = Bitmap.new(90,70)
        bmp.fill_rect(bmp.rect,Color.new(255,255,255))
        bitmap = Cache.RE_weapon(item.name) rescue bmp

    a = $weapons.find{|weapon| weapon.weapon.name == $data_weapons[item.id].name}
  
  
    image = Bitmap.new(90,70)
    image.blt((80-bitmap.width)/2,(60-bitmap.height)/2,bitmap,bitmap.rect)
  
    image.draw_text(-15,40,85,20,a.bullets,2) if a
        rect = Rect.new(0,0,90,70)
        contents.blt(x, y, image, rect, enabled ? 255 : translucent_alpha)
        bmp.dispose
    end
  
    def draw_RE_item(item, x, y, enabled = true)
        bmp = Bitmap.new(90,70)
        bmp.fill_rect(bmp.rect,Color.new(255,255,255))
        bitmap = Cache.RE_item(item.name) rescue bmp
  
    image = Bitmap.new(90,70)
    image.blt((80-bitmap.width)/2,(60-bitmap.height)/2,bitmap,bitmap.rect)
      
    image.draw_text(-15,40,85,20,$game_party.item_number(item),2)
        rect = Rect.new(0,0,90,70)
        contents.blt(x,y,image, rect, enabled ? 255 : translucent_alpha)
        bmp.dispose
    end
      
end

class Window_RE_Command < Window_HorzCommand
  def window_width
    return Graphics.width
  end
 
  def make_command_list
    add_command("", :option)
    add_command("", :item)
    add_command("", :exit)
  end
 
  def col_max
    return 6
  end
  
  def spacing
    return 1
  end
 
  def item_width
    (width - standard_padding * 1 + spacing) / col_max - spacing #10
  end
end

module Cache
  
    def self.RE_weapon(filename)
        load_bitmap("Graphics/Weapons/", filename)
    end
  
    def self.RE_item(filename)
        load_bitmap("Graphics/Items/", filename)
    end
end





  • Feed RSS