module EventHelper
def self.get_rpg_event(event_id, map_id=$game_map.map_id)
map = $game_map.instance_variable_get(:@map)
if map_id != $game_map.map_id
map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
end
return map.events[event_id]
end
ICE_REGION = 9 # 溜冰区域
end
# 溜冰
class Game_Player
alias ice_move_straight move_straight
def move_straight(d, turn_ok = true)
old_real_x, old_real_y = @real_x, @real_y
n = ($game_player.region_id == EventHelper::ICE_REGION ? 1+rand(3) : 1)
n.times { ice_move_straight(d, turn_ok) }
@real_x, @real_y = old_real_x, old_real_y
end
alias ice_update_anime_pattern update_anime_pattern
def update_anime_pattern
ice_update_anime_pattern
@pattern = @original_pattern if $game_player.region_id == EventHelper::ICE_REGION
end
end
# 下一条字幕转脚本 by 晴兰
class Game_Interpreter
def 字幕脚本
x,y = @index+1, @list
if y[x].code==105
y[x].code = 355
y[x].parameters = ['']
y[x].code = 655 while y[x+=1].code == 405
end
end
def hit_test_player
evt = $game_map.events[@event_id]
return (evt.x==$game_player.x and evt.y==$game_player.y)
end
def hit_test_event(ss="D")
evt = $game_map.events[@event_id]
list = $game_map.events.values.select{|e|
e.x==evt.x and e.y==evt.y and !(e.erased)}
if list.size > 1
list.each {|e|
$game_self_switches[[$game_map.map_id, e.id, ss]] = true }
end
end
# 点灯游戏和引爆器的4向触发器(十字型触发)
def trigger_4way(kwargs={})
range = kwargs[:range] || (1..1)
ss = kwargs[:self_switch] || "D"
flip = kwargs[:flip] || false
evt = $game_map.events[@event_id]
list=[evt]
range.each{|r|
list += $game_map.events_xy(evt.x+r, evt.y) +
$game_map.events_xy(evt.x-r, evt.y) +
$game_map.events_xy(evt.x, evt.y+r) +
$game_map.events_xy(evt.x, evt.y-r)
}
list.uniq!
ntrue = list.select{|e|$game_self_switches[[$game_map.map_id, e.id, ss]]}.size
list.each {|e|
$game_self_switches[[$game_map.map_id, e.id, ss]] =
flip ? (!$game_self_switches[[$game_map.map_id, e.id, ss]]) : true
}
ntrue_new = list.select{|e|$game_self_switches[[$game_map.map_id, e.id, ss]]}.size
return ntrue_new - ntrue #返回:触发区域内增加的打开的独立开关的个数
end
# 两个事件之间的坐标距离
def event_dist(a, b)
($game_map.events[a].x - $game_map.events[b].x).abs +
($game_map.events[a].y - $game_map.events[b].y).abs
end
end
class Game_Event
attr_accessor :id
attr_accessor :erased
end
class Game_Map
# rpg_evt:需要刷新的事件RPG::Event, 用上面的get_rpg_event获得
# xy:坐标
# dir:朝向
# ss:需要打开的独立开关列表("ABCD")
def spawn_event(rpg_evt, x, y, dir=2, ss="")
new_id = 1 + @map.events.keys.max
new_evt = RPG::Event.new(x, y)
new_evt.id = new_id
new_evt.pages = rpg_evt.pages
@map.events[new_id] = new_evt
@events[new_id] = Game_Event.new(@map_id, new_evt)
@events[new_id].set_direction(dir)
ss.each_char{|c| $game_self_switches[[@map_id, new_id, c]] = true }
# 刷新图块
refresh_tile_events
SceneManager.scene.instance_eval { @spriteset.refresh_characters }
end
end