赞 | 6 |
VIP | 0 |
好人卡 | 0 |
积分 | 23 |
经验 | 29954 |
最后登录 | 2024-11-14 |
在线时间 | 1374 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 2253
- 在线时间
- 1374 小时
- 注册时间
- 2011-2-10
- 帖子
- 602
|
大雄的生化危机里的脚本,不知道这个有用吗
=begin
使用说明
copy_map_event(map_id, event_id, x, y)
复制特定地图的特定事件 到坐标 x y
如果 x y 坐标不填,事件就复制到原本的坐标
示例 copy_map_event(2, 1) # 复制地图2的事件1
copy_map_event(3, 2, 0, 0) # 复制地图3的事件2到坐标(0,0)
关于独立开关
现在每个“复制事件”有各自的独立开关,利用“复制事件”里的独立开关操作来开启。
“复制事件”的独立开关优先级高于原本“被复制事件”的独立开关。
要开/关“被复制事件”的某个独立开关可以用脚本
$game_self_switch[[map_id, event_id, "A"]] = true / false
remove_copy_event(map_id, event_id)
移除从特定地图复制过来的事件,如果复制了多个则全部移除
需要一个一个移除使用下面的方法
remove_map_event(事件id)
移除指定id的事件
复制过来的事件id为 当前地图事件id最大值 + 1
=end
class Game_Interpreter
def copy_map_event(map_id, event_id, x = nil, y = nil)
map_filename = sprintf("Data/Map%03d.rvdata2", map_id)
if File.exist?(map_filename)
event = load_data(map_filename).events[event_id]
if event
event = Game_Event.new(map_id, event)
event_id = $game_map.events.keys.max + 1
event_id += $game_map.copy_map_events.size if $game_map.copy_map_events
event.event_copy_setup(event_id, x, y)
$game_map.prepare_copy_event(event)
elsif $TEST
#msgbox("复制<地图#{map_id}>的<事件#{event_id}>失败,该事件不存在。")
#exit
end
elsif $TEST
#msgbox("从<地图#{map_id}>复制事件失败,该地图不存在。")
#exit
end
end
def remove_copy_event(map_id, event_id)
$game_map.events.each_value {|event|
if event.copy_id == event_id && event.map_id == map_id
$game_map.prepare_remove_event(event)
end
}
end
def remove_map_event(event_id)
event = $game_map.events[event_id]
$game_map.prepare_remove_event(event) if event
end
#
alias_method :copy_map_event_command_123, :command_123
=begin
def command_123
if @event_id > 0
event = get_character(@event_id)
event.copy_id ?
process_copy_self_switch(event) :
copy_map_event_command_123
end
end
=end
def process_copy_self_switch(event)
event.copy_self_switch ||= {}
event.copy_self_switch[@params[0]] = (@params[1] == 0)
all_off = true
event.copy_self_switch.each_value {|key| break all_off = false if key}
event.copy_self_switch = nil if all_off
$game_map.need_refresh = true
end
end
#
class Spriteset_Map
def add_copy_event(event)
@character_sprites.push(Sprite_Character.new(@viewport1, event))
end
def remove_copy_event(event)
@character_sprites.each {|sprite|
if sprite.character == event
@character_sprites.delete(sprite)
sprite.dispose
return
end
}
end
end
#
class Scene_Map
attr(:spriteset)
end
class Game_Map
attr(:copy_map_events)
def prepare_copy_event(event)
@copy_map_events ||= {}
@tile_events.push(event) if event.tile?
@copy_map_events[event] = true
end
def prepare_remove_event(event)
@copy_map_events ||= {}
@tile_events.delete(event) if event.tile?
@copy_map_events[event] = false
end
alias_method :copy_map_events_update_events, :update_events
def update_events
copy_map_events_update_events
if @copy_map_events
delete_ids = []
in_map = SceneManager.scene_is?(Scene_Map)
@copy_map_events.each {|event, copy|
if copy
@events[event.id] = event
SceneManager.scene.spriteset.add_copy_event(event) if in_map
else
delete_ids.push(event.id)
SceneManager.scene.spriteset.remove_copy_event(event) if in_map
end
}
delete_ids.each {|id| @events.delete(id)}
@copy_map_events = nil
end
end
end
class Game_Event
attr(:copy_id, :map_id)
attr_accessor :copy_self_switch
def event_copy_setup(id, x, y)
@copy_id = @id
@id = id
moveto(x, y) if x && y
end
def update #注意:方法覆盖
super
check_event_trigger_auto
return unless @interpreter
@interpreter.setup(@list, @id) unless @interpreter.running?
@interpreter.update
end
def conditions_met?(page) #注意:方法覆盖
c = page.condition
if c.switch1_valid
if c.switch1_id == 3
return false unless $game_e[[@id,"found"]] == true
else
return false unless $game_switches[c.switch1_id]
end
end
if c.switch2_valid
if c.switch2_id == 3
return false unless $game_e[[@id,"found"]] == true
else
return false unless $game_switches[c.switch2_id]
end
end
if c.variable_valid
return false if $game_variables[c.variable_id] < c.variable_value
end
if c.self_switch_valid
return false unless @copy_self_switch ?
@copy_self_switch[c.self_switch_ch] :
$game_self_switches[[@map_id, @event.id, c.self_switch_ch]]
end
if c.item_valid
item = $data_items[c.item_id]
return false unless $game_party.has_item?(item)
end
if c.actor_valid
actor = $game_actors[c.actor_id]
return false unless $game_party.members.include?(actor)
end
if page.list[0].code == 108
key = [@map_id, @event.id, page.list[0].parameters[0].split('出现条件:独立开关操作')[1].to_s]
return false if $game_self_switches[key] != true
end
return true
end
end |
|