#============================================================================== # ☆★☆ 提取放置物脚本(修改) ☆★☆ #------------------------------------------------------------------------------ # 简洁版 - 美兽 # - 2007.4.12 # 修改版 - zhouzhuofan1 # - 2015.5.30 #------------------------------------------------------------------------------ # 爱护环境,人人有责,现实中切勿乱丢垃圾。 #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # 脚本原理: # 是从仓库地图中提取事件,将其拷贝放入指定的位置, # 依此达成随时随地生成新事件的功能,如此可节省大量用RGSS编写事件所消耗的体力, # 很多地方写的很保守,尽量减少冲突几率。。 # 此为简洁版,场所移动后便清除。 # - 美兽 #------------------------------------------------------------------------------ =begin Note: 生成物品的方法: Drop_Item.make_events(map_id,event_id,item_x,item_y,item_direction) map_id : 仓库地图的ID。 event_id : 仓库中对应事件的ID。 item_x、item_y :新事件的X与Y坐标 item_direction :新事件的朝向 (2、4、6、8分别对应下、左、右、上,填其他数时不改变朝向) =end #============================================================================== module Drop_Item def self.make_events(map_id,event_id,item_x,item_y,item_direction) return unless self.is_map? map = load_data(sprintf("Data/Map%03d.rxdata", map_id)) temp = Marshal.load(Marshal.dump(map)) if !$game_system.map_events_number $game_system.map_events_number = {} end sum = $game_system.map_events_number m_id = $game_map.map_id sum[m_id] == nil ? sum[m_id] = 2000 : sum[m_id] += 1 new_event_id = sum[m_id] temp.events[event_id].id = new_event_id temp.events[event_id].x,temp.events[event_id].y = item_x,item_y $game_map.events[new_event_id] = Game_Event.new(m_id,temp.events[event_id]) case item_direction when 2 $game_map.events[new_event_id].turn_down when 4 $game_map.events[new_event_id].turn_left when 6 $game_map.events[new_event_id].turn_right when 8 $game_map.events[new_event_id].turn_up end refresh_map(new_event_id) end def self.refresh_map(i) return unless self.is_map? $scene.spriteset.refresh_events(i) end def self.is_map? (return true) if $scene.is_a?(Scene_Map) return false end end class Game_System attr_accessor :map_events_number attr_accessor :map_data end class Scene_Map attr_accessor :spriteset end class Spriteset_Map def refresh_events(i) sprite = Sprite_Character.new(@viewport1, $game_map.events[i]) @character_sprites.push(sprite) end end
#============================================================================== # ☆★☆ 提取放置物脚本(修改-强化) ☆★☆ #------------------------------------------------------------------------------ # 强化版 - 美兽 # - 2007.4.12 # 修改-强化版 - zhouzhuofan1 # - 2015.6.6 #------------------------------------------------------------------------------ # 爱护环境,人人有责,现实中切勿乱丢垃圾。 #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # 脚本原理: # 是从仓库地图中提取事件,将其拷贝放入指定的位置, # 依此达成随时随地生成新事件的功能,如此可节省大量用RGSS编写事件所消耗的体力,很多地方写的 # 很保守,尽量减少冲突几率。。 # 此为强化版,可实现新事件的保存,但代价是冲突的随之增大,若只想单纯实现ARPG # 一类的物品掉落,场所移动后便清除,请使用简洁版。 # - 美兽 #------------------------------------------------------------------------------ =begin Note: 一:生成物品主方法: Drop_Item.make_events(map_id,event_id,item_x,item_y,item_direction,save=false) map_id : 仓库地图的ID。 event_id : 仓库中对应事件的ID。 item_x、item_y :新事件的X与Y坐标 item_direction :新事件的朝向 (2、4、6、8分别对应下、左、右、上,填其他数时不改变朝向) save : 是否存储标志; 默认为false,即不存储,场所移动等转换场景后事件会消失; true为存储,取档、关机、登火星,返回后事件仍存在。 二:删除事件方法: 事件名若包含"delete"字段,则执行完毕会立即自我清除; 注:任何事件皆如此。 三:备注: 此脚本用法十分灵活,种植、建设、舍弃、掉宝等功能都可用以达成。 =end #============================================================================== module Drop_Item def self.make_events(map_id,event_id,item_x,item_y,item_direction,save=false) return unless self.is_map? map = self.map_data_load(map_id) temp = Marshal.load(Marshal.dump(map)) if !$game_system.map_events_number $game_system.map_events_number = {} end sum = $game_system.map_events_number m_id = $game_map.map_id sum[m_id] == nil ? sum[m_id] = 2000 : sum[m_id] += 1 new_event_id = sum[m_id] temp.events[event_id].id = new_event_id temp.events[event_id].x,temp.events[event_id].y = item_x,item_y $game_map.events[new_event_id] = Game_Event.new(m_id,temp.events[event_id]) if save now_map = self.map_data_load(m_id) now_map.events[new_event_id] = temp.events[event_id] self.map_data_save(m_id,now_map) end case item_direction when 2 $game_map.events[new_event_id].turn_down when 4 $game_map.events[new_event_id].turn_left when 6 $game_map.events[new_event_id].turn_right when 8 $game_map.events[new_event_id].turn_up end refresh_map(new_event_id) end def self.map_data_init for i in 1..999 begin map = load_data(sprintf("Data/Map%03d.rxdata", i)) rescue Errno::ENOENT next end $game_system.map_data[i] = Marshal.load(Marshal.dump(map)) end end def self.map_data_save(map_id,event) $game_system.map_data[$game_map.map_id] = event end def self.map_data_load(map_id) if !$game_system.map_data $game_system.map_data = {} self.map_data_init end return $game_system.map_data[map_id] end def self.delete_events(event_id) return unless self.is_map? $game_map.events.delete(event_id) self.refresh_map end def self.refresh_map(i) return unless self.is_map? $scene.spriteset.refresh_events(i) end def self.is_map? (return true) if $scene.is_a?(Scene_Map) return false end end class Game_Map def setup(map_id) @map_id = map_id @map = Drop_Item.map_data_load(@map_id) tileset = $data_tilesets[@map.tileset_id] @tileset_name = tileset.tileset_name @autotile_names = tileset.autotile_names @panorama_name = tileset.panorama_name @panorama_hue = tileset.panorama_hue @fog_name = tileset.fog_name @fog_hue = tileset.fog_hue @fog_opacity = tileset.fog_opacity @fog_blend_type = tileset.fog_blend_type @fog_zoom = tileset.fog_zoom @fog_sx = tileset.fog_sx @fog_sy = tileset.fog_sy @battleback_name = tileset.battleback_name @passages = tileset.passages @priorities = tileset.priorities @terrain_tags = tileset.terrain_tags @display_x = 0 @display_y = 0 @need_refresh = false @events = {} for i in @map.events.keys @events[i] = Game_Event.new(@map_id, @map.events[i]) end @common_events = {} for i in 1...$data_common_events.size @common_events[i] = Game_CommonEvent.new(i) end @fog_ox = 0 @fog_oy = 0 @fog_tone = Tone.new(0, 0, 0, 0) @fog_tone_target = Tone.new(0, 0, 0, 0) @fog_tone_duration = 0 @fog_opacity_duration = 0 @fog_opacity_target = 0 @scroll_direction = 2 @scroll_rest = 0 @scroll_speed = 4 end end class Interpreter def command_end @list = nil if @main and @event_id > 0 if $game_map.events[@event_id].event.name[/delete/].nil? $game_map.events[@event_id].unlock else if $scene.is_a?(Scene_Map) Drop_Item.delete_events(@event_id) now_map = Drop_Item.map_data_load($game_map.map_id) now_map.events.delete(@event_id) Drop_Item.map_data_save($game_map.map_id,now_map) end end end end end class Game_System attr_accessor :map_events_number attr_accessor :map_data end class Game_Event < Game_Character attr_accessor :event end class Scene_Map attr_accessor :spriteset end class Spriteset_Map def refresh_events(i) sprite = Sprite_Character.new(@viewport1, $game_map.events[i]) @character_sprites.push(sprite) end end
截图.png (96.71 KB, 下载次数: 41)
191.03 KB, 下载次数: 134
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |