#============================================================================== # ■ Systeme de gestion de dépot d'objet sur la map #------------------------------------------------------------------------------ # Ce script a pour but de rajouter un systeme de dépot d'objet sur la map. # Les emplacements des objets sont conservé dans la sauvegarde du joueur # # # Version Date Auteur Commentaires # 1.00 24/11/2012 Tonyryu Création du script # 1.01 25/11/2012 Tonyryu Correction du positionnement # 1.02 06/12/2012 Tonyryu Correction afin de ne faire apparaitre l'option dépot que sur Scene_Item # # Attention : Ce script est ma propriété en tant que création et il est donc # soumis au droit de la propriété intellectuelle ( http://www.irpi.ccip.fr/ ). # En aucun cas, il ne doit être copié ou publié vers un autre forum sans en # avoir reçu mon accord au préalable. # #============================================================================== module AOS Depot = "Déposer" Son = "./Audio/SE/Blow2.ogg" end #============================================================================== # ** Game_Party #------------------------------------------------------------------------------ # This class handles parties. Information such as gold and items is included. # Instances of this class are referenced by $game_party. #============================================================================== class Game_Party #-------------------------------------------------------------------------- # * initialize #-------------------------------------------------------------------------- alias oas_initialize initialize def initialize oas_initialize @ListeObjetsSol = {} end #-------------------------------------------------------------------------- # * oas_prendre_objet #-------------------------------------------------------------------------- def oas_prendre_objet(pIdMap, pTileX, pTileY) return nil if !@ListeObjetsSol[pIdMap]["#{pTileX}-#{pTileY}"] defItem = @ListeObjetsSol[pIdMap]["#{pTileX}-#{pTileY}"].clone case defItem[0] when 0 item = $data_items[defItem[1]] when 1 item = $data_weapons[defItem[1]] when 2 item = $data_armors[defItem[1]] end @ListeObjetsSol[pIdMap].delete("#{pTileX}-#{pTileY}") @ListeObjetsSol.delete(pIdMap) if @ListeObjetsSol[pIdMap].size == 0 gain_item(item,defItem[2]) end #-------------------------------------------------------------------------- # * oas_deposer_objet #-------------------------------------------------------------------------- def oas_deposer_objet(pIdMap, pTileX, pTileY, pItem, pQuantity = 1) @ListeObjetsSol[pIdMap] = {} if !@ListeObjetsSol[pIdMap] if @ListeObjetsSol[pIdMap]["#{pTileX}-#{pTileY}"] Sound.play_buzzer return false end idItem = pItem.id if pItem.is_a?(RPG::Item) typeItem = 0 elsif pItem.is_a?(RPG::Weapon) typeItem = 1 elsif pItem.is_a?(RPG::Armor) typeItem = 2 end gain_item(pItem, -pQuantity) @ListeObjetsSol[pIdMap]["#{pTileX}-#{pTileY}"] = [typeItem, idItem, pQuantity] Audio.se_play(AOS::Son) return true end #-------------------------------------------------------------------------- # * oas_lister_objet_map #-------------------------------------------------------------------------- def oas_lister_objet_map(pIdMap) return @ListeObjetsSol[pIdMap] end end #============================================================================== # ** Spriteset_Map #------------------------------------------------------------------------------ # This class brings together map screen sprites, tilemaps, etc. It's used # within the Scene_Map class. #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias oas_initialize initialize def initialize @tabSpriteItem = {} oas_initialize end #-------------------------------------------------------------------------- # * oas_update #-------------------------------------------------------------------------- alias oas_update update def update oas_update oas_update_item end #-------------------------------------------------------------------------- # * update_item_icon #-------------------------------------------------------------------------- def oas_update_item # Pour chaque item posé sur la map tabObjetMap = $game_party.oas_lister_objet_map($game_map.map_id) if tabObjetMap tabObjetMap.each do | key, value | # Vérifier si un sprite existe if !@tabSpriteItem[key] @tabSpriteItem[key] = Sprite.new(@viewport1) @tabSpriteItem[key].bitmap = Cache.system("Iconset") case tabObjetMap[key][0] when 0 item = $data_items[tabObjetMap[key][1]] when 1 item = $data_weapons[tabObjetMap[key][1]] when 2 item = $data_armors[tabObjetMap[key][1]] end @tabSpriteItem[key].src_rect = Rect.new(item.icon_index % 16 * 24, item.icon_index / 16 * 24, 24, 24) @tabSpriteItem[key].x = $game_map.adjust_x(key.split('-')[0].to_i) * 32 + 4 @tabSpriteItem[key].y = $game_map.adjust_y(key.split('-')[1].to_i) * 32 + 4 end end end @tabSpriteItem.each do | key, value | if !tabObjetMap oas_dispose_item(key) @tabSpriteItem.delete(key) elsif !tabObjetMap[key] oas_dispose_item(key) @tabSpriteItem.delete(key) else @tabSpriteItem[key].x = $game_map.adjust_x(key.split('-')[0].to_i) * 32 + 4 @tabSpriteItem[key].y = $game_map.adjust_y(key.split('-')[1].to_i) * 32 + 4 end end end #-------------------------------------------------------------------------- # * oas_dispose_item #-------------------------------------------------------------------------- def oas_dispose_item(pKey) @tabSpriteItem[pKey].bitmap.dispose @tabSpriteItem[pKey].dispose end end #============================================================================== # ** Game_Map #------------------------------------------------------------------------------ # This class handles maps. It includes scrolling and passage determination # functions. The instance of this class is referenced by $game_map. #============================================================================== class Game_Map #-------------------------------------------------------------------------- # * update_interpreter #-------------------------------------------------------------------------- alias oas_update_interpreter update_interpreter def update_interpreter launchInterpreter = true tabItemMap = $game_party.oas_lister_objet_map($game_map.map_id) if tabItemMap if Input.trigger?(:C) d = $game_player.direction if tabItemMap["#{$game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0)}-#{$game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)}"] $game_party.oas_prendre_objet($game_map.map_id, $game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0), $game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)) launchInterpreter = false elsif tabItemMap["#{$game_player.x}-#{$game_player.y}"] $game_party.oas_prendre_objet($game_map.map_id, $game_player.x, $game_player.y) launchInterpreter = false end end end oas_update_interpreter if launchInterpreter end end #============================================================================== # ** Window_ItemCategory #------------------------------------------------------------------------------ # This window is for selecting a category of normal items and equipment # on the item screen or shop screen. #============================================================================== class Window_ItemCategory #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias aos_initialize initialize def initialize(pSceneItem = false) @nbColMax = 4 @sceneItem = pSceneItem aos_initialize end #-------------------------------------------------------------------------- # * Get Digit Count #-------------------------------------------------------------------------- def col_max return @nbColMax end #-------------------------------------------------------------------------- # * Create Command List #-------------------------------------------------------------------------- alias aos_make_command_list make_command_list def make_command_list aos_make_command_list if @sceneItem add_command(AOS::Depot, :depot) @nbColMax = 5 end end end #============================================================================== # ** Window_ItemList #------------------------------------------------------------------------------ # This window displays a list of party items on the item screen. #============================================================================== class Window_ItemList attr_reader :category #-------------------------------------------------------------------------- # * Include in Item List? #-------------------------------------------------------------------------- alias aos_include? include? def include?(item) if @category == :depot return !item.nil? else return aos_include?(item) end end #-------------------------------------------------------------------------- # * Display in Enabled State? #-------------------------------------------------------------------------- alias aos_enable? enable? def enable?(item) if @category == :depot return !item.nil? else return $game_party.usable?(item) end end end #============================================================================== # ** Scene_Item #------------------------------------------------------------------------------ # This class performs the item screen processing. #============================================================================== class Scene_Item #-------------------------------------------------------------------------- # * Create Category Window #-------------------------------------------------------------------------- def create_category_window @category_window = Window_ItemCategory.new(true) @category_window.viewport = @viewport @category_window.help_window = @help_window @category_window.y = @help_window.height @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # * Item [OK] #-------------------------------------------------------------------------- alias aos_determine_item determine_item def determine_item if @item_window.category == :depot if item $game_party.oas_deposer_objet($game_map.map_id, $game_player.x, $game_player.y, item) end activate_item_window else aos_determine_item end end end