#下面可修改([]中为通常的样子): 合成方式 = 0 #@blend_tepe【1 】:0~2 透明速度 = 10 #[url=home.php?mod=space&uid=316553]@opacity[/url] 【10 】:0~255 下降速度 = 1 #@jy 【1 】:0~50 X放大率 = 0.1 #@zoom_x 【0.1 or -0.03】:-1~1 Y放大率 = 0.1 #@zoom_y 【0.1 or -0.03】:-1~1 残影 = true #shadow 【true / false】 残光 = false #show_light 【true / false】 旋转 = false #angle 【true、false】 动态 = true#true #anima 【true、false】 #由于残光会建立94个图像,内存低就把show_light 给false掉吧~~ #加入鼠标转向专利一个~~我是仿windows显示时间屏保的鼠标制作的~~ #是关于Math的算法,不是只有8方向,而是360个= =!!~ #把【85】行去掉“#”就会掉many FPS 不过很华丽~~(注:先开启旋转,残光功能!) #-----------------------------------分割线-------------------------------------- #如果需要在游戏中调用修改鼠标各项设置:见204行处的方法调用,不需要改变的量用nil #表示! #============================================================================== module Mouse attr_accessor :count #变换动画计数 attr_accessor :npc #指向NPC attr_accessor :wait #指针变成角色正在移动 attr_accessor :enemy #指针指向敌人 attr_accessor :coach #coach icons switch #====================================================== #change icon! #====================================================== def self.npc if [url=home.php?mod=space&uid=113826]@NPC[/url] != true @count = 10 [url=home.php?mod=space&uid=113826]@NPC[/url] = true end end def self.wait if [url=home.php?mod=space&uid=36110]@Wait[/url] != true @count = 10 [url=home.php?mod=space&uid=36110]@Wait[/url] = true end end def self.enemy if @enemy != true @count = 10 @enemy = true end end def self.coach if [url=home.php?mod=space&uid=288325]@COACH[/url] != true @count = 10 [url=home.php?mod=space&uid=288325]@COACH[/url] = true end end #====================================================== #end #====================================================== def self.text end def self.into_menu Sound.play_ok SceneManager.call(Scene_Menu) Window_MenuCommand::init_command_position end def self.init2 #Directions @dir = 0 @old_x, @old_y = 0, 0 #Animations @light_id = 1 @mouse_sprite1 = Sprite.new; @mouse_sprite1.z = 9999; @mouse_sprite1.bitmap = Bitmap.new("Graphics/Icons/#{@light_id}"); @light_id = 1 @canyin = [] @rmenu = nil#右键菜单 @rightmenu = false @mouse_touch = false @count = 0 @npc,@wait,@coach = false end def self.setbb(a,b,c,d,e,f,g,h,i) @blend_tepe = a if a != nil @opacity = b if b != nil @jy = c if c != nil @zoom_x = d if d != nil @zoom_y = e if e != nil [url=home.php?mod=space&uid=22469]@light[/url] = f if f != nil [url=home.php?mod=space&uid=31758]@Shadow[/url] = g if g != nil [url=home.php?mod=space&uid=124954]@Angle[/url] = h if h != nil @anima = i if i != nil end def self.show_light(mx, my) @canyin.each{|s|s.opacity <= 0 ? (s.visible = false ; @canyin.delete(s)) : s.opacity -= 25} if @light @light_id < 94 ? @light_id += 1 : @light_id = 1 i = @light_id eval("@mouse_sprite#{i} = Sprite.new") eval("@mouse_sprite#{i}.x = #{mx}") eval("@mouse_sprite#{i}").y = my eval("@mouse_sprite#{i}").blend_type = @blend_tepe eval("@mouse_sprite#{i}").z = 9999; #eval("@mouse_sprite#{i}").angle = @mouse_sprite.angle eval("@mouse_sprite#{i}").bitmap = Bitmap.new("Graphics/Icons/#{@light_id}") for i in 1..94 begin eval("@mouse_sprite#{i}").opacity -= @opacity #10 eval("@mouse_sprite#{i}").y += @jy#1 eval("@mouse_sprite#{i}").zoom_x += @zoom_x#0.105 eval("@mouse_sprite#{i}").zoom_y += @zoom_y#0.105 eval("@mouse_sprite#{i}").dispose if eval("@mouse_sprite#{i}").opacity <= 0 rescue end end if @plight == true self.update_light end end return if !@angle a = 0 #被废掉的朝向 hu = [(@old_x - mx), (@old_y - my)] return if hu[0] == 0 or hu[1] == 0 math = 135 - self.atoa(Math.atan(hu[1]/hu[0])) if hu[0] > 0 @mouse_sprite.angle = math - 90 else @mouse_sprite.angle = math + 90 end #p math @old_x, @old_y = mx, my end def self.plight return unless @light @l = Sprite.new @l.z = 999999 @pcount = 30 @l.blend_type = 1 @l.bitmap = Bitmap.new("Graphics/Icons/#{@pcount}"); @l.ox = @l.bitmap.width / 2 @l.oy = @l.bitmap.height / 2 @l.x, @l.y = @mouse_sprite.x, @mouse_sprite.y @plight = true end def self.update_light @pcount += 1 @l.bitmap = Bitmap.new("Graphics/Icons/#{@pcount}") @l.zoom_x += 0.1 @l.zoom_y += 0.1 @l.opacity -= 10 if @pcount >= 70 @l.dispose @pcount = 0 @plight = false end end def self.atoa(hu)#弧度转角度 return (hu * 180) / Math::PI # end #============================================================================== #New Part! #============================================================================== def self.moving(x,y) return if ![url=home.php?mod=space&uid=31758]@Shadow[/url] == true sprite = Sprite.new sprite.z = 999 sprite.bitmap = @mouse_sprite.bitmap if !@mouse_sprite.disposed?#Bitmap.new("Graphics/Mouse/1.png") sprite.x = x sprite.y = y sprite.opacity = 200 sprite.angle = @mouse_sprite.angle @canyin.push sprite end def self.canyin return @canyin.size end def self.right_menu(x,y) @rmenu.dispose if @rmenu != nil @rmenu = Sprite.new @rmenu.z = 1000 # @rmenu.bitmap.fill_rect(0, 0, 150, 32*n, Color.new(255,255,255)) # @rmenu.bitmap.font.color = Color.new(68,34,255) # n.times{|i| # @rmenu.bitmap.fill_rect(0, i*32, 150, 1, Color.new(0,0,0)) # @rmenu.bitmap.draw_text(0, i*32, 150, 32,text[i][0]) # } @rmenu.x,@rmenu.y = x,y @rmenu.opacity = 200 @rightmenu = true end def self.mouse_touch=(bar) @mouse_touch = bar end def self.mouse_touch return @mouse_touch end def self.check if Mouse.trigger?(Mouse::LEFT) if @rightmenu mx,my = Mouse.get_mouse_pos lx = @rmenu.x - @rmenu.ox rx = lx + @rmenu.bitmap.width ty = @rmenu.y - @rmenu.oy by = ty + @rmenu.bitmap.height if mx < lx or mx > rx or my < ty or my > by or @rmenu.bitmap.get_pixel(mx-lx,my-ty).alpha == 0 else a = [] text.size.times{|t|a << [t*32 , ([email]my-@rmenu.y[/email]).abs].min} eval(text[(a.max/32).to_i][1]) end @rightmenu = false @rmenu.dispose @rmenu = nil return end end end end Mouse.init2 Mouse.setbb(合成方式, 透明速度, 下降速度, X放大率, Y放大率,残光,残影,旋转,动态)
41.14 KB, 下载次数: 45
加上去吧,不加不知道能不能用。
#encoding:utf-8 # 鼠标指针变换功能 v2.2 (2014.1.24) # ·需· 鼠标系统(SionMouseSystem)v2.1+ # 说明: # 鼠标指针图片参考 Grpahics\System\VariableCursor.png # 单个指针图片大小默认是64x64,图片的中心为鼠标坐标 # # 事件中添加注释: 鼠标指针i # 鼠标移动到此事件上时鼠标指针自动切换到对应图片 # 可以参考范例里的事件注释 # # class << Mouse CursorSize = 64 #单个图标大小 def create_cursor(vp) dispose_cursor if @sprite [url=home.php?mod=space&uid=114926]@sprite[/url] = Sprite.new(vp) @sprite.z = 9999 if File.exist?('Graphics/System/VariableCursor.png') @sprite.bitmap = Cache.system('VariableCursor') else msgbox("Graphics/System/VariableCursor.png 缺失") exit end @sprite.src_rect.set(0, 0, CursorSize, CursorSize) @sprite.ox = CursorSize / 2 @sprite.oy = CursorSize / 2 update_cursor end def change_cursor(i) @sprite.src_rect.x = i * CursorSize end end class Scene_Map alias_method :change_cursor_update_mouse_action, :update_mouse_action def update_mouse_action Mouse.change_cursor(0) $game_map.events_xy($game_map.mouse_map_x, \ $game_map.mouse_map_y).each {|event| if event.mouse_start? break Mouse.change_cursor(1) elsif event.cursor_index break Mouse.change_cursor(event.cursor_index) end } change_cursor_update_mouse_action end alias_method :change_cursor_sion_mouse_call_menu, :call_menu def call_menu Mouse.change_cursor(0) change_cursor_sion_mouse_call_menu end end class Game_Event attr_reader :locked, :cursor_index alias_method :change_cursor_lock, :lock def lock Mouse.change_cursor(0) change_cursor_lock end alias_method :change_cursor_sion_mouse_start, :sion_mouse_start def sion_mouse_start Mouse.change_cursor(0) change_cursor_sion_mouse_start end def sion_mouse_read_event_notes @mouse_start = false @cursor_index = nil @list.each {|cmd| break if sion_mouse_scan_list(cmd)} unless empty? end def sion_mouse_scan_list(cmd) # 覆盖 return false unless cmd.code == 108 || cmd.code == 408 text = cmd.parameters[0] if text.include?("鼠标启动") @mouse_start = true @cursor_index = 1 #设置鼠标启动对应的鼠标指针索引 elsif /鼠标指针(\d+)/ =~ text @cursor_index = $1.to_i end return @cursor_index end end class Game_Player < Game_Character alias_method :change_cursor_make_encounter_count, :make_encounter_count def make_encounter_count Mouse.change_cursor(0) change_cursor_make_encounter_count end end
#encoding:utf-8 # Sion 鼠标系统(SionMouseSystem)v3.02 (2014/2/20) # ·需· Sion_MouseBase v3.00+ # v3.02(2014/2/20) 事件执行过程中,卷动地图后不会自动跳转到玩家位置了。 =begin 说明 主要功能 1,自动寻路,按住 D 键可以扩大寻路的范围 2,变量输入框改良 3,鼠标启动事件: 在事件中加入“注释”:鼠标启动 该事件将无法用其它方式启动,只能用鼠标左键点击启动 3.00 新增鼠标滚轮支持,菜单可以直接用鼠标滚轮翻页了 现在在光标矩形外按鼠标不会响应了,必须移动到对应的选项上按才行。 还改进了一些个蛋挞的问题。 鼠标指针图片 MouseCursor.png 放入 Graphics\System 文件夹 路径点指示图片 $Arrow.png 放入 Graphics\Characters 文件夹 如果未放入会使用RM自带图片代替缺失文件 =end #============================================================================== # ■ 常数设置 #============================================================================== module KsOfSion Clip_Cursor = true # 鼠标锁定在游戏窗口内,需要关闭设置为false Dbclick_Frame = 15 # 双击的最大间隔帧数。在地图画面双击进行奔跑 New_Scroll = true # 更改地图卷动方式,需要关闭设置为false Map_Scroll_Spd = 1.0 # 卷动速度 Menu_Set_Pos = true # 打开菜单时将鼠标移动到光标处 Break_Steps = 30 # 鼠标寻路最大步数,防止路径太长导致卡帧 # “30” 是默认显示格子数 长(17) + 宽(13) Find_Path_Key = 0x44 # 扩大寻路范围至全地图按键 0x44 对应 D键 # 查阅 NovaBase 中的键盘表修改,设为 0 禁用此功能 end # class Move_Sign < Game_Character # ■ 用来显示路径点的类 attr_accessor :direction def init_public_members @character_name = '!$Arrow'# 路径点箭头,置于.\Graphics\Characters文件夹 @character_index = 0 # 图片索引。$开头的行走图设为0 @move_speed = 5 # 踏步速度 @step_anime = true # 踏步动画(如果想使用静态图标就关闭这个) [url=home.php?mod=space&uid=316553]@opacity[/url] = 255 # 不透明度 @blend_type = 0 # 图片合成方式,默认为0(正常) @direction = 2 # 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列 @priority_type = 1 # 优先级(默认与人物同级:1) # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图 #============================= 参数设置完毕 =================================== unless File.exist?('Graphics/Characters/' + @character_name + '.png') @character_name = '!Flame' @character_index = 6 end @direction_fix = false @move_frequency = 6 @walk_anime = true @pattern = 1 @through = true @bush_depth = 0 @animation_id = 0 @balloon_id = 0 @transparent = true @id = 0 @x = 0 @y = 0 @real_x = 0 @real_y = 0 @tile_id = 0 end end #============================================================================== # ■ SceneManager #============================================================================== class << SceneManager alias_method :sion_mouse_run, :run alias_method :sion_mouse_call, :call alias_method :sion_mouse_return, :return def run Mouse.activate sion_mouse_run end def call(scene_class, *args) $game_map.prepare_reset_mouse_pos if @scene.instance_of?(Scene_Map) sion_mouse_call(scene_class, *args) end def return sion_mouse_return $game_map.reset_mouse_pos if KsOfSion::Menu_Set_Pos && @scene.instance_of?(Scene_Map) end end class << Mouse attr_reader :sprite end class << Input alias_method :sion_mouse_press?, :press? alias_method :sion_mouse_trigger?, :trigger? alias_method :sion_mouse_repeat?, :repeat? alias_method :sion_mouse_update, :update def update Mouse.update sion_mouse_update end def press?(key) return true if sion_mouse_press?(key) return Input.key_press?(0x01) if key == :C return Input.key_press?(0x02) if key == :B return false end def trigger?(key) return true if sion_mouse_trigger?(key) return Input.key_trigger?(0x01) if key == :C return Input.key_trigger?(0x02) if key == :B return false end def repeat?(key) return true if sion_mouse_repeat?(key) return Input.key_repeat?(0x01) if key == :C return Input.key_repeat?(0x02) if key == :B return false end end #============================================================================== # ■ Window_Selectable #------------------------------------------------------------------------------ # 拥有光标移动、滚动功能的窗口 #============================================================================== class Window_Selectable #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- alias sion_mouse_initialize initialize def initialize(x, y, width, height) sion_mouse_initialize(x, y, width, height) @move_state = 0 end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- alias sion_mouse_update update def update sion_mouse_update update_mouse_cursor end #-------------------------------------------------------------------------- # ● 按下确定键的处理 #-------------------------------------------------------------------------- alias sion_mouse_process_ok process_ok def process_ok return if Input.key_trigger?(0x01) && mouse_out_rect? sion_mouse_process_ok end #-------------------------------------------------------------------------- # ● 判断鼠标是位于光标矩形处 #-------------------------------------------------------------------------- def mouse_out_rect? if viewport.nil? vp_x, vp_y = 0, 0 else vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end mouse_rx = ox + Mouse.x - (x + vp_x + standard_padding ) mouse_ry = oy + Mouse.y - (y + vp_y + standard_padding ) return cursor_rect.x > mouse_rx || cursor_rect.y > mouse_ry || cursor_rect.x + cursor_rect.width < mouse_rx || cursor_rect.y + cursor_rect.height< mouse_ry end #-------------------------------------------------------------------------- # ● 启动后设置鼠标到index位置 / 重置鼠标滚轮状态 #-------------------------------------------------------------------------- def activate @need_set_pos = true if KsOfSion::Menu_Set_Pos Mouse.reset_z super end #-------------------------------------------------------------------------- # ● 更新鼠标和光标的位置 #-------------------------------------------------------------------------- def update_mouse_cursor if active if @need_set_pos @need_set_pos = false set_mouse_pos elsif cursor_movable? Input.dir4.zero? ? set_cursor : set_mouse_pos end end end #-------------------------------------------------------------------------- # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能 #-------------------------------------------------------------------------- def set_cursor mouse_row, mouse_col = mouse_window_area if mouse_row == -1 @move_state += 1 if need_scroll? cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand? elsif mouse_row == -2 @move_state += 1 if need_scroll? cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand? elsif mouse_col == -1 @move_state += 1 if need_scroll? cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand? elsif mouse_col == -2 @move_state += 1 if need_scroll? cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand? else @move_state = 0 new_index = (top_row + mouse_row) * col_max + mouse_col select(new_index) if new_index < item_max && new_index != @index end update_mouse_scroll end #-------------------------------------------------------------------------- # ● 判断鼠标位于菜单的第几行、第几列 #-------------------------------------------------------------------------- def mouse_window_area if viewport.nil? # necessary! vp_x, vp_y = 0, 0 else vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end mouse_x = Mouse.x mouse_y = Mouse.y item_x1 = vp_x + x + standard_padding item_y1 = vp_y + y + standard_padding item_x2 = vp_x + x - standard_padding + width item_y2 = vp_y + y - standard_padding + height if mouse_x < item_x1 mouse_col = -1 elsif mouse_x > item_x2 mouse_col = -2 else mouse_col = col_max * (mouse_x - item_x1) / (item_x2 - item_x1) end if mouse_y < item_y1 mouse_row = -1 elsif mouse_y > item_y2 mouse_row = -2 else mouse_row = page_row_max * (mouse_y - item_y1 - 1) / (item_y2 - item_y1) end return mouse_row, mouse_col end #-------------------------------------------------------------------------- # ● 更新鼠标滚轮 #-------------------------------------------------------------------------- def update_mouse_scroll z = Mouse.z return if z == 0 if need_scroll? if z < 0 cursor_pagedown else cursor_pageup end end Mouse.reset_z end #-------------------------------------------------------------------------- # ● 方向键移动光标时将鼠标移动到对应的光标位置 #-------------------------------------------------------------------------- def set_mouse_pos if viewport.nil? # necessary! vp_x, vp_y = 0, 0 else vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end item_x1 = vp_x + x + standard_padding item_y1 = vp_y + y + standard_padding get_index = [url=home.php?mod=space&uid=370741]@Index[/url] < 0 ? 0 : @index row = get_index / col_max - top_row col = get_index % col_max new_x = item_x1 + item_width * (col + 0.5) new_y = item_y1 + item_height * (row + 0.5) Mouse.set_pos(new_x, new_y) end #-------------------------------------------------------------------------- # ● 判断菜单是否需要卷动 #-------------------------------------------------------------------------- def need_scroll? item_max > col_max * page_row_max end #-------------------------------------------------------------------------- # ● 判断是否为水平卷动菜单 #-------------------------------------------------------------------------- def is_horzcommand? return false end end class Window_HorzCommand #-------------------------------------------------------------------------- # ● 判断是否为水平卷动菜单 #-------------------------------------------------------------------------- def is_horzcommand? return true end end #============================================================================== # ■ Window_NameInput #------------------------------------------------------------------------------ # 名字输入画面中,选择文字的窗口。 #============================================================================== class Window_NameInput #-------------------------------------------------------------------------- # ● 设置列数 #-------------------------------------------------------------------------- def col_max return 10 end #-------------------------------------------------------------------------- # ● 设置填充的Item个数 #-------------------------------------------------------------------------- def item_max return 90 end #-------------------------------------------------------------------------- # ● 设置填充的Item个数 #-------------------------------------------------------------------------- def item_width return 32 end #-------------------------------------------------------------------------- # ● 判断鼠标位于菜单的第几行、第几列 #-------------------------------------------------------------------------- def mouse_window_area if viewport.nil? vp_x, vp_y = 0, 0 else vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end mouse_x = Mouse.x mouse_y = Mouse.y item_x1 = vp_x + x + standard_padding item_y1 = vp_y + y + standard_padding item_x2 = vp_x + x - standard_padding + width item_y2 = vp_y + y - standard_padding + height if mouse_x < item_x1 mouse_col = -1 elsif mouse_x > item_x2 mouse_col = -2 elsif mouse_x < item_x1 + 160 mouse_col = (mouse_x - item_x1)/32 elsif mouse_x > item_x2 - 160 mouse_col = 9 - (item_x2 - mouse_x)/32 else mouse_col = mouse_x > x + width/2 ? 5 : 4 end if mouse_y < item_y1 mouse_row = -1 elsif mouse_y > item_y2 mouse_row = -2 else mouse_row = page_row_max * (mouse_y - item_y1 - 1)/(item_y2 - item_y1) end return mouse_row, mouse_col end #-------------------------------------------------------------------------- # ● 方向键移动光标时将鼠标移动到对应的光标位置 #-------------------------------------------------------------------------- def set_mouse_pos if viewport.nil? # necessary! vp_x, vp_y = 0, 0 else vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end item_x1 = vp_x + x + standard_padding item_y1 = vp_y + y + standard_padding get_index = @index < 0 ? 0 : @index row = get_index / col_max - top_row col = get_index % col_max new_x = item_x1 + item_width * (col + 0.5) new_y = item_y1 + item_height * (row + 0.5) new_x += 14 if col > 4 Mouse.set_pos(new_x, new_y) end end #============================================================================== # ■ Window_NumberInput #------------------------------------------------------------------------------ # 重写了数值输入的方法以适应鼠标 #============================================================================== class Window_NumberInput < Window_Base #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_reader :extra_window #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- alias sion_mouse_initialize initialize def initialize(arg) sion_mouse_initialize(arg) create_extra_window end #-------------------------------------------------------------------------- # ● 启动 #-------------------------------------------------------------------------- alias sion_mouse_start start def start sion_mouse_start deactivate extra_start end #-------------------------------------------------------------------------- # ● 创建新的数值输入窗口 #-------------------------------------------------------------------------- def create_extra_window @extra_window = Window_NumberInput_Ex.new @extra_window.x = (Graphics.width - @extra_window.width) / 2 @extra_window.number_proc = Proc.new {|n| [url=home.php?mod=space&uid=27178]@Number[/url] = n } @extra_window.index_proc = Proc.new {|n| @index = n } @extra_window.close_proc = Proc.new { close } @extra_window.refresh_proc = Proc.new { refresh } end #-------------------------------------------------------------------------- # ● 激活新窗口 #-------------------------------------------------------------------------- def extra_start case $game_message.position when 0; @extra_window.y = y + height + 4 when 1; @extra_window.y = @message_window.y - @extra_window.height - 8 when 2; @extra_window.y = y - @extra_window.height - 4 else ; @extra_window.y = 8 end @extra_window.variable_id = $game_message.num_input_variable_id @extra_window.digits_max = @digits_max @extra_window.number = @number @extra_window.open @extra_window.activate end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- def update super @extra_window.update update_cursor end #-------------------------------------------------------------------------- # ● 关闭窗口 #-------------------------------------------------------------------------- def close super @extra_window.close @extra_window.deactivate end end #============================================================================== # ■ Window_NumberInput_Ex #------------------------------------------------------------------------------ # 新的数值输入窗口(NewClass) #============================================================================== class Window_NumberInput_Ex < Window_Selectable #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_accessor :number_proc attr_accessor :index_proc attr_accessor :close_proc attr_accessor :refresh_proc attr_accessor :number attr_accessor :digits_max attr_accessor :variable_id #-------------------------------------------------------------------------- # ● 数字表 #-------------------------------------------------------------------------- TABLE = [ 7, 8, 9, 4, 5, 6, 1, 2, 3, '←',0,'确定',] #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize super(0, 0, 120, fitting_height(4)) self.openness = 0 @index = 0 @number = 0 @old_window_index = 0 @digits_max = 0 12.times {|i| draw_text(item_rect(i), TABLE[i], 1) } end #-------------------------------------------------------------------------- # ● 获取项目的绘制矩形 #-------------------------------------------------------------------------- def item_rect(index) rect = Rect.new rect.x = index % 3 * 32 rect.y = index / 3 * line_height rect.width = 32 rect.height = line_height return rect end #-------------------------------------------------------------------------- # ● 将光标设置到鼠标所在的位置 #-------------------------------------------------------------------------- def set_cursor mouse_row, mouse_col = mouse_window_area if mouse_row >= 0 && mouse_col >= 0 new_index = mouse_row * 3 + mouse_col select(new_index) if new_index <= 11 end end #-------------------------------------------------------------------------- # ● 判断鼠标位于新数值输入窗口的第几行、第几列 #-------------------------------------------------------------------------- def mouse_window_area if viewport.nil? vp_x, vp_y = 0, 0 else vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end mouse_x = Mouse.x mouse_y = Mouse.y item_x1 = vp_x + x + standard_padding item_y1 = vp_y + y + standard_padding item_x2 = vp_x + x - standard_padding + width item_y2 = vp_y + y - standard_padding + height if mouse_x < item_x1 mouse_col = -1 elsif mouse_x > item_x2 mouse_col = -2 else mouse_col = (mouse_x - item_x1) / 32 end if mouse_y < item_y1 mouse_row = -1 elsif mouse_y > item_y2 mouse_row = -2 else mouse_row = 4 * (mouse_y - item_y1 - 1) / (item_y2 - item_y1) end return mouse_row, mouse_col end #-------------------------------------------------------------------------- # ● 获取文字 #-------------------------------------------------------------------------- def get_number return false if @index == 9 || @index == 11 return TABLE[@index] end #-------------------------------------------------------------------------- # ● 判定光标位置是否在“退格”上 #-------------------------------------------------------------------------- def is_delete? @index == 9 end #-------------------------------------------------------------------------- # ● 判定光标位置是否在“确定”上 #-------------------------------------------------------------------------- def is_ok? @index == 11 end #-------------------------------------------------------------------------- # ● 更新光标 #-------------------------------------------------------------------------- def update_cursor cursor_rect.set(item_rect(@index)) end #-------------------------------------------------------------------------- # ● 判定光标是否可以移动 #-------------------------------------------------------------------------- def cursor_movable? active end #-------------------------------------------------------------------------- # ● 光标向下移动 # wrap : 允许循环 #-------------------------------------------------------------------------- def cursor_down(wrap) if @index < 9 or wrap @index = (index + 3) % 12 end end #-------------------------------------------------------------------------- # ● 光标向上移动 # wrap : 允许循环 #-------------------------------------------------------------------------- def cursor_up(wrap) if @index >= 3 or wrap @index = (index + 9) % 12 end end #-------------------------------------------------------------------------- # ● 光标向右移动 # wrap : 允许循环 #-------------------------------------------------------------------------- def cursor_right(wrap) if @index % 3 < 2 @index += 1 elsif wrap @index -= 2 end end #-------------------------------------------------------------------------- # ● 光标向左移动 # wrap : 允许循环 #-------------------------------------------------------------------------- def cursor_left(wrap) if @index % 3 > 0 @index -= 1 elsif wrap @index += 2 end end #-------------------------------------------------------------------------- # ● 处理光标的移动 #-------------------------------------------------------------------------- def process_cursor_move super update_cursor end #-------------------------------------------------------------------------- # ● “确定”、“删除字符”和“取消输入”的处理 #-------------------------------------------------------------------------- def process_handling return unless open? && active process_jump if Input.trigger?(:A) process_back if Input.repeat?(:B) process_ok if Input.trigger?(:C) end #-------------------------------------------------------------------------- # ● 跳转“确定” #-------------------------------------------------------------------------- def process_jump if @index != 11 @index = 11 Sound.play_cursor end end #-------------------------------------------------------------------------- # ● 后退一个字符 #-------------------------------------------------------------------------- def process_back Sound.play_cancel place = 10 ** (@digits_max - 1 - @old_window_index) n = (@number / place) % 10 @number -= n * place @number_proc.call(@number) @old_window_index -= 1 if @old_window_index > 0 @index_proc.call(@old_window_index) @refresh_proc.call end #-------------------------------------------------------------------------- # ● 按下确定键时的处理 #-------------------------------------------------------------------------- def process_ok return if Input.key_trigger?(0x01) && mouse_out_rect? if get_number Sound.play_cursor place = 10 ** (@digits_max - 1 - @old_window_index) n = get_number - (@number / place) % 10 @number += n * place @number_proc.call(@number) @old_window_index += 1 if @old_window_index < @digits_max - 1 @index_proc.call(@old_window_index) @refresh_proc.call elsif is_delete? process_back elsif is_ok? on_input_ok end end #-------------------------------------------------------------------------- # ● 确定 #-------------------------------------------------------------------------- def on_input_ok @index = 0 @old_window_index = 0 $game_variables[@variable_id] = @number Sound.play_ok @close_proc.call end #-------------------------------------------------------------------------- # ● 方向键移动光标时将鼠标移动到对应的光标位置 #-------------------------------------------------------------------------- def set_mouse_pos if viewport.nil? # necessary! vp_x, vp_y = 0, 0 else vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end item_x1 = vp_x + x + standard_padding item_y1 = vp_y + y + standard_padding get_index = @index < 0 ? 0 : @index new_x = item_x1 + 32 * (get_index % 3 + 0.5) new_y = item_y1 + 24 * (get_index / 3 + 0.5) Mouse.set_pos(new_x, new_y) end end #============================================================================== # ■ Window_Message #------------------------------------------------------------------------------ # 显示文字信息的窗口。 #============================================================================== class Window_Message < Window_Base #-------------------------------------------------------------------------- # ● 处理数值的输入(覆盖原方法) #-------------------------------------------------------------------------- def input_number @number_window.start Fiber.yield while @number_window.extra_window.active end end #============================================================================== # ■ Window_PartyCommand #------------------------------------------------------------------------------ # 战斗画面中,选择“战斗/撤退”的窗口。 #============================================================================== class Window_PartyCommand < Window_Command #-------------------------------------------------------------------------- # ● 方向键移动光标时将鼠标移动到对应的光标位置 #-------------------------------------------------------------------------- def set_mouse_pos if viewport.nil? vp_x, vp_y = 0, 0 else #vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end item_x1 = x + standard_padding item_y1 = vp_y + y + standard_padding get_index = @index < 0 ? 0 : @index row = get_index / col_max - top_row col = get_index % col_max new_x = item_x1 + item_width * (col + 0.5) new_y = item_y1 + item_height * (row + 0.5) Mouse.set_pos(new_x, new_y) end end #============================================================================== # ■ Window_ActorCommand #------------------------------------------------------------------------------ # 战斗画面中,选择角色行动的窗口。 #============================================================================== class Window_ActorCommand < Window_Command #-------------------------------------------------------------------------- # ● 方向键移动光标时将鼠标移动到对应的光标位置 #-------------------------------------------------------------------------- def set_mouse_pos if viewport.nil? vp_x, vp_y = 0, 0 else #vp_x = viewport.rect.x - viewport.ox vp_y = viewport.rect.y - viewport.oy end item_x1 = Graphics.width - width + standard_padding item_y1 = vp_y + y + standard_padding get_index = @index < 0 ? 0 : @index row = get_index / col_max - top_row col = get_index % col_max new_x = item_x1 + item_width * (col + 0.5) new_y = item_y1 + item_height * (row + 0.5) Mouse.set_pos(new_x, new_y) end end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ # 处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。 # 本类的实例请参考 $game_player 。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● 由方向移动(覆盖原方法) #-------------------------------------------------------------------------- def move_by_input return if !movable? || $game_map.interpreter.running? if Input.dir4 > 0 move_straight(Input.dir4) reset_move_path else move_by_mouse end end #-------------------------------------------------------------------------- # ● 非移动中的处理(覆盖原方法) # last_moving : 此前是否正在移动 #-------------------------------------------------------------------------- def update_nonmoving(last_moving) return if $game_map.interpreter.running? if last_moving $game_party.on_player_walk return if check_touch_event end if movable? && Input.trigger?(:C) # 防止按下鼠标左键绘制路径时触发事件或载具切换 return if Input.key_press?(0x01) return if get_on_off_vehicle return if check_action_event end update_encounter if last_moving end #-------------------------------------------------------------------------- # ● 判定是否跑步状态(覆盖原方法) #-------------------------------------------------------------------------- def dash? return false if @move_route_forcing return false if $game_map.disable_dash? return false if vehicle return Input.press?(:A) || @mouse_dash end #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- alias sion_mouse_initialize initialize def initialize sion_mouse_initialize reset_move_path @moveto_x = 0 @moveto_y = 0 end #-------------------------------------------------------------------------- # ● 移动到指定位置 #-------------------------------------------------------------------------- alias sion_mouse_moveto moveto def moveto(x, y) sion_mouse_moveto(x, y) $mouse_move_sign.moveto( x, y ) end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- alias sion_mouse_update update def update sion_mouse_update clear_unreachable_sign end #-------------------------------------------------------------------------- # ● 处理卷动 #-------------------------------------------------------------------------- alias sion_mouse_update_scroll update_scroll def update_scroll(last_real_x, last_real_y) return if $game_map.scrolling? KsOfSion::New_Scroll ? new_update_scroll : sion_mouse_update_scroll(last_real_x, last_real_y) end #-------------------------------------------------------------------------- # ● 重置移动路径相关信息 #-------------------------------------------------------------------------- def reset_move_path @mouse_dash = false @mouse_move_path = [] $mouse_move_sign.transparent = true end #-------------------------------------------------------------------------- # ● 新的卷动地图方法 #-------------------------------------------------------------------------- def new_update_scroll return if $game_message.busy? || $game_message.visible horz_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.width vert_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.height ax = $game_map.adjust_x( @real_x ) ay = $game_map.adjust_y( @real_y ) if ay>center_y; $game_map.new_scroll_down (vert_speed * (ay - center_y)) elsif ay<center_y; $game_map.new_scroll_up (vert_speed * (center_y - ay)) end if ax>center_x; $game_map.new_scroll_right(horz_speed * (ax - center_x)) elsif ax<center_x; $game_map.new_scroll_left (horz_speed * (center_x - ax)) end end #-------------------------------------------------------------------------- # ● 消除不能抵达图标 #-------------------------------------------------------------------------- def clear_unreachable_sign return if Input.key_press?(0x01) if $mouse_move_sign.direction == 4 && Mouse.dk_count % 20 == 1 $mouse_move_sign.transparent = true $mouse_move_sign.direction = 2 end end #-------------------------------------------------------------------------- # ● 由鼠标移动 #-------------------------------------------------------------------------- def move_by_mouse unless @mouse_move_path.empty? # 移动路线数组不为空则执行移动 dir = @mouse_move_path.shift if passable?(x, y, dir) && !@mouse_move_path.empty? move_straight(dir) elsif @mouse_move_path.empty? # 判断是否是最后一步 x2 = $game_map.round_x_with_direction(x, dir) y2 = $game_map.round_y_with_direction(y, dir) move_straight(dir) unless dir.zero? unless @x == x2 && @y == y2 # 如果移动失败,检查是否启动前方事件 check_event_trigger_there([0,1,2]) get_on_off_vehicle unless $game_map.setup_starting_event end $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2 @mouse_dash = false elsif @mouse_move_path[0].zero? # 目标点无法抵达,调整朝向→目标点 @mouse_move_path.shift @direction = dir @mouse_dash = false else draw_move_path end end end #-------------------------------------------------------------------------- # ● 地图界面按下鼠标左键的处理 #-------------------------------------------------------------------------- def left_button_action @moveto_x = $game_map.mouse_map_x @moveto_y = $game_map.mouse_map_y return mouse_same_pos_action if @moveto_x == @x && @moveto_y == @y return if mouse_trigger_event? return unless drawable? draw_player_move_path end #-------------------------------------------------------------------------- # ● 绘制玩家移动路径 #-------------------------------------------------------------------------- def draw_player_move_path @mouse_dash = true if Mouse.double_click?# 双击冲刺 if Input.key_states[1] % 10 == 1 #按住鼠标左键10帧绘制1次路径 $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图 for i in 1..4 # 判断目标点是否为角色周围四点 if @x == $game_map.round_x_with_direction(@moveto_x, i * 2) && @y == $game_map.round_y_with_direction(@moveto_y, i * 2) $mouse_move_sign.transparent = true @mouse_move_path = [10 - i * 2] return end end draw_move_path end end #-------------------------------------------------------------------------- # ● 鼠标位置与玩家一致的处理 #-------------------------------------------------------------------------- def mouse_same_pos_action unless moving? || (vehicle && !vehicle.movable?) check_event_trigger_here([0]) # 判断是否触发重合点事件 get_on_off_vehicle if !$game_map.setup_starting_event && $game_map.airship.pos?(@x, @y) # 判断是否要上、下飞艇 end end #-------------------------------------------------------------------------- # ● trigger 鼠标左键的处理 #-------------------------------------------------------------------------- def mouse_trigger_event? if Input.key_trigger?(0x01) $game_map.events_xy(@moveto_x, @moveto_y).each {|event| if event.mouse_start? event.start return true end } end return false end #-------------------------------------------------------------------------- # ● 绘制移动路径 @array[move_directions...] #-------------------------------------------------------------------------- def draw_move_path @mouse_move_path = case @vehicle_type when :walk; draw_walk_path when :boat; draw_boat_path when :ship; draw_ship_path when :airship; draw_air_path end end #-------------------------------------------------------------------------- # ● 判定是否可以绘制移动路径 #-------------------------------------------------------------------------- def drawable? return false if @move_route_forcing || @followers.gathering? return false if @vehicle_getting_on || @vehicle_getting_off return true end #-------------------------------------------------------------------------- # ● 绘制行走路径 @array[move_directions...] #-------------------------------------------------------------------------- def draw_walk_path # 准备绘制路径表格 sheet = Table.new($game_map.width, $game_map.height) reversed_chase_path = []; chase_path = [] reversed_chase_point = []; chase_point = [] new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y] sheet[x, y] = 1; sheet[@moveto_x, @moveto_y] = 2 reach_point = false step = 3 loop do #loop1 开始填充表格 draw_path = false check_points = new_start_points new_start_points = [] loop do #loop2 从起点开始正向填充 point_x = check_points.shift break if point_x == nil point_y = check_points.shift left_x = $game_map.round_x(point_x - 1) right_x = $game_map.round_x(point_x + 1) up_y = $game_map.round_y(point_y - 1) down_y = $game_map.round_y(point_y + 1) # 判断路径是否连通 path_step = step - 1 if sheet[left_x, point_y] == path_step && $game_map.passable?(left_x, point_y, 6) && $game_map.passable?(point_x, point_y, 4) chase_path.push(4) chase_point = [left_x, point_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[right_x, point_y] == path_step && $game_map.passable?(right_x, point_y, 4) && $game_map.passable?(point_x, point_y, 6) chase_path.push(6) chase_point = [right_x, point_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[point_x, up_y] == path_step && $game_map.passable?(point_x, up_y, 2) && $game_map.passable?(point_x, point_y, 8) chase_path.push(8) chase_point = [point_x, up_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[point_x, down_y] == path_step && $game_map.passable?(point_x, down_y, 8) && $game_map.passable?(point_x, point_y, 2) chase_path.push(2) chase_point = [point_x, down_y] reversed_chase_point = [point_x, point_y] reach_point = true; break end # 以需要抵达该点的步数填充路径表格 # if sheet[left_x, point_y] == 0 && $game_map.passable?(left_x, point_y, 6) && !collide_with_events?(left_x, point_y) && $game_map.passable?(point_x, point_y, 4) && !collide_with_vehicles?(left_x, point_y) #judge_end sheet[left_x, point_y] = step draw_path = true new_start_points.push(left_x, point_y) end if sheet[right_x, point_y] == 0 && $game_map.passable?(right_x, point_y, 4) && !collide_with_events?(right_x, point_y) && $game_map.passable?(point_x, point_y, 6) && !collide_with_vehicles?(right_x, point_y)#judge_end sheet[right_x, point_y] = step draw_path = true new_start_points.push(right_x, point_y) end if sheet[point_x, up_y] == 0 && $game_map.passable?(point_x, up_y, 2) && !collide_with_events?(point_x, up_y) && $game_map.passable?(point_x, point_y, 8) && !collide_with_vehicles?(point_x, up_y) #judge_end sheet[point_x, up_y] = step draw_path = true new_start_points.push(point_x, up_y) end if sheet[point_x, down_y] == 0 && $game_map.passable?(point_x, down_y, 8) && !collide_with_events?(point_x, down_y) && $game_map.passable?(point_x, point_y, 2) && !collide_with_vehicles?(point_x, down_y) #judge_end sheet[point_x, down_y] = step draw_path = true new_start_points.push(point_x, down_y) end end#endOfLoop2 break if !draw_path || reach_point draw_path = false check_points = new_end_points new_end_points = [] step += 1 break if step > KsOfSion::Break_Steps && !Input.key_press?(KsOfSion::Find_Path_Key) loop do #loop3 从终点开始反向填充 point_x = check_points.shift break if point_x == nil point_y = check_points.shift left_x = $game_map.round_x(point_x - 1) right_x = $game_map.round_x(point_x + 1) up_y = $game_map.round_y(point_y - 1) down_y = $game_map.round_y(point_y + 1) # 判断路径是否连通 path_step = step - 1 if sheet[left_x, point_y] == path_step && $game_map.passable?(left_x, point_y, 6) && $game_map.passable?(point_x, point_y, 4) chase_path.push(6) chase_point = [point_x, point_y] reversed_chase_point = [left_x, point_y] reach_point = true; break elsif sheet[right_x, point_y] == path_step && $game_map.passable?(right_x, point_y, 4) && $game_map.passable?(point_x, point_y, 6) chase_path.push(4) chase_point = [point_x, point_y] reversed_chase_point = [right_x, point_y] reach_point = true; break elsif sheet[point_x, up_y] == path_step && $game_map.passable?(point_x, up_y, 2) && $game_map.passable?(point_x, point_y, 8) chase_path.push(2) chase_point = [point_x, point_y] reversed_chase_point = [point_x, up_y] reach_point = true; break elsif sheet[point_x, down_y] == path_step && $game_map.passable?(point_x, down_y, 8) && $game_map.passable?(point_x, point_y, 2) chase_path.push(8) chase_point = [point_x, point_y] reversed_chase_point = [point_x, down_y] reach_point = true; break end # 以需要抵达该点的步数填充路径表格 # if sheet[left_x, point_y] == 0 && $game_map.passable?(left_x, point_y, 6) && !collide_with_events?(left_x, point_y) && $game_map.passable?(point_x, point_y, 4) && !collide_with_vehicles?(left_x, point_y) #judge_end sheet[left_x, point_y] = step draw_path = true new_end_points.push(left_x, point_y) end if sheet[right_x, point_y] == 0 && $game_map.passable?(right_x, point_y, 4) && !collide_with_events?(right_x, point_y) && $game_map.passable?(point_x, point_y, 6) && !collide_with_vehicles?(right_x, point_y)#judge_end sheet[right_x, point_y] = step draw_path = true new_end_points.push(right_x, point_y) end if sheet[point_x, up_y] == 0 && $game_map.passable?(point_x, up_y, 2) && !collide_with_events?(point_x, up_y) && $game_map.passable?(point_x, point_y, 8) && !collide_with_vehicles?(point_x, up_y) #judge_end sheet[point_x, up_y] = step draw_path = true new_end_points.push(point_x, up_y) end if sheet[point_x, down_y] == 0 && $game_map.passable?(point_x, down_y, 8) && !collide_with_events?(point_x, down_y) && $game_map.passable?(point_x, point_y, 2) && !collide_with_vehicles?(point_x, down_y) #judge_end sheet[point_x, down_y] = step draw_path = true new_end_points.push(point_x, down_y) end end#endOfLoop3 break if !draw_path || reach_point step += 1 end #endOfLoop1 路径表格填充完毕 $mouse_move_sign.transparent = false # 判断指定地点能否抵达 if reach_point $mouse_move_sign.direction = 2 else return not_reach_point end # 根据路径表格绘制最短移动路径(反向) steps = step / 2 * 2 + 1 loop_times = step / 2 point_x, point_y = reversed_chase_point[0], reversed_chase_point[1] for i in 1..loop_times # forLoop steps -= 2 if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs if sheet[$game_map.round_x(point_x - 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) && $game_map.passable?(point_x, point_y, 4) #judge_end reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) && $game_map.passable?(point_x, point_y, 6) #judge_end reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) && $game_map.passable?(point_x, point_y, 2) #judge_end reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) && $game_map.passable?(point_x, point_y, 8) #judge_end reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) end else if sheet[point_x, $game_map.round_y(point_y + 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) && $game_map.passable?(point_x, point_y, 2) #judge_end reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) && $game_map.passable?(point_x, point_y, 8) #judge_end reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) && $game_map.passable?(point_x, point_y, 4) #judge_end reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) && $game_map.passable?(point_x, point_y, 6) #judge_end reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) end end end #endOfForLoop # 根据路径表格绘制最短移动路径(正向) steps = step / 2 * 2 loop_times = step / 2 point_x, point_y = chase_point[0], chase_point[1] for i in 2..loop_times # forLoop steps -= 2 if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs if sheet[point_x, $game_map.round_y(point_y + 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) && $game_map.passable?(point_x, point_y, 2) #judge_end chase_path.push(2) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) && $game_map.passable?(point_x, point_y, 8) #judge_end chase_path.push(8) point_y = $game_map.round_y(point_y - 1) elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) && $game_map.passable?(point_x, point_y, 4) #judge_end chase_path.push(4) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) && $game_map.passable?(point_x, point_y, 6) #judge_end chase_path.push(6) point_x = $game_map.round_x(point_x + 1) end else if sheet[$game_map.round_x(point_x - 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) && $game_map.passable?(point_x, point_y, 4) #judge_end chase_path.push(4) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps && $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) && $game_map.passable?(point_x, point_y, 6) #judge_end chase_path.push(6) point_x = $game_map.round_x(point_x + 1) elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) && $game_map.passable?(point_x, point_y, 2) #judge_end chase_path.push(2) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps && $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) && $game_map.passable?(point_x, point_y, 8) #judge_end chase_path.push(8) point_y = $game_map.round_y(point_y - 1) end end end #endOfForLoop reversed_chase_path.reverse + chase_path end#walk ## def not_reach_point $mouse_move_sign.direction = 4 dx = 0; dy = 0; dir = 0 if @moveto_x - x > 0 if @moveto_x - x > $game_map.width - @moveto_x + x && $game_map.loop_vertical? dx = $game_map.width - @moveto_x + x; dir = 4 else dx = @moveto_x - x; dir = 6 end else if x - @moveto_x > $game_map.width - x + @moveto_x && $game_map.loop_vertical? dx = $game_map.width - x + @moveto_x; dir = 6 else dx = x - @moveto_x; dir = 4 end end if @moveto_y - y > 0 if @moveto_y - y > $game_map.height - @moveto_y + y && $game_map.loop_horizontal? dy = $game_map.height - @moveto_y + y dir = 8 if dy > dx else dy = @moveto_y - y dir = 2 if dy > dx end else if y - @moveto_y > $game_map.height - y + @moveto_y && $game_map.loop_horizontal? dy = $game_map.height - y + @moveto_y dir = 2 if dy > dx else dy = y - @moveto_y dir = 8 if dy > dx end end return [dir, 0] # 0方向用于防止移动过程中触发事件 end #-------------------------------------------------------------------------- # ● 绘制boat的移动路径 @array[move_directions...] #-------------------------------------------------------------------------- def draw_boat_path # 准备绘制路径表格 sheet = Table.new($game_map.width, $game_map.height) reversed_chase_path = []; chase_path = [] reversed_chase_point = []; chase_point = [] new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y] sheet[x, y] = 1; sheet[@moveto_x, @moveto_y] = 2 reach_point = false step = 3 loop do #loop1 开始填充表格 draw_path = false check_points = new_start_points new_start_points = [] loop do #loop2 从起点开始正向填充 point_x = check_points.shift break if point_x == nil point_y = check_points.shift left_x = $game_map.round_x(point_x - 1) right_x = $game_map.round_x(point_x + 1) up_y = $game_map.round_y(point_y - 1) down_y = $game_map.round_y(point_y + 1) # 判断路径是否连通 path_step = step - 1 if sheet[left_x, point_y] == path_step chase_path.push(4) chase_point = [left_x, point_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[right_x, point_y] == path_step chase_path.push(6) chase_point = [right_x, point_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[point_x, up_y] == path_step chase_path.push(8) chase_point = [point_x, up_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[point_x, down_y] == path_step chase_path.push(2) chase_point = [point_x, down_y] reversed_chase_point = [point_x, point_y] reach_point = true; break end # 以需要抵达该点的步数填充路径表格 # if sheet[left_x, point_y] == 0 && $game_map.boat_passable?(left_x, point_y) && !collide_with_events?(left_x, point_y) && !collide_with_vehicles?(left_x, point_y) #judge_end sheet[left_x, point_y] = step draw_path = true new_start_points.push(left_x, point_y) end if sheet[right_x, point_y] == 0 && $game_map.boat_passable?(right_x, point_y) && !collide_with_events?(right_x, point_y) && !collide_with_vehicles?(right_x, point_y) #judge_end sheet[right_x, point_y] = step draw_path = true new_start_points.push(right_x, point_y) end if sheet[point_x, up_y] == 0 && $game_map.boat_passable?(point_x, up_y) && !collide_with_events?(point_x, up_y) && !collide_with_vehicles?(point_x, up_y) #judge_end sheet[point_x, up_y] = step draw_path = true new_start_points.push(point_x, up_y) end if sheet[point_x, down_y] == 0 && $game_map.boat_passable?(point_x, down_y) && !collide_with_events?(point_x, down_y) && !collide_with_vehicles?(point_x, down_y) #judge_end sheet[point_x, down_y] = step draw_path = true new_start_points.push(point_x, down_y) end end#endOfLoop2 break if !draw_path || reach_point draw_path = false check_points = new_end_points new_end_points = [] step += 1 break if step > KsOfSion::Break_Steps && !Input.key_press?(KsOfSion::Find_Path_Key) loop do #loop3 从终点开始反向填充 point_x = check_points.shift break if point_x == nil point_y = check_points.shift left_x = $game_map.round_x(point_x - 1) right_x = $game_map.round_x(point_x + 1) up_y = $game_map.round_y(point_y - 1) down_y = $game_map.round_y(point_y + 1) # 判断路径是否连通 path_step = step - 1 if sheet[left_x, point_y] == path_step chase_path.push(6) chase_point = [point_x, point_y] reversed_chase_point = [left_x, point_y] reach_point = true; break elsif sheet[right_x, point_y] == path_step chase_path.push(4) chase_point = [point_x, point_y] reversed_chase_point = [right_x, point_y] reach_point = true; break elsif sheet[point_x, up_y] == path_step chase_path.push(2) chase_point = [point_x, point_y] reversed_chase_point = [point_x, up_y] reach_point = true; break elsif sheet[point_x, down_y] == path_step chase_path.push(8) chase_point = [point_x, point_y] reversed_chase_point = [point_x, down_y] reach_point = true; break end # 以需要抵达该点的步数填充路径表格 # if sheet[left_x, point_y] == 0 && $game_map.boat_passable?(left_x, point_y) && !collide_with_events?(left_x, point_y) && !collide_with_vehicles?(left_x, point_y) #judge_end sheet[left_x, point_y] = step draw_path = true new_end_points.push(left_x, point_y) end if sheet[right_x, point_y] == 0 && $game_map.boat_passable?(right_x, point_y) && !collide_with_events?(right_x, point_y) && !collide_with_vehicles?(right_x, point_y) #judge_end sheet[right_x, point_y] = step draw_path = true new_end_points.push(right_x, point_y) end if sheet[point_x, up_y] == 0 && $game_map.boat_passable?(point_x, up_y) && !collide_with_events?(point_x, up_y) && !collide_with_vehicles?(point_x, up_y) #judge_end sheet[point_x, up_y] = step draw_path = true new_end_points.push(point_x, up_y) end if sheet[point_x, down_y] == 0 && $game_map.boat_passable?(point_x, down_y) && !collide_with_events?(point_x, down_y) && !collide_with_vehicles?(point_x, down_y) #judge_end sheet[point_x, down_y] = step draw_path = true new_end_points.push(point_x, down_y) end end#endOfLoop3 break if !draw_path || reach_point step += 1 end #endOfLoop1 路径表格填充完毕 $mouse_move_sign.transparent = false # 判断指定地点能否抵达 reach_point ? $mouse_move_sign.direction = 2 : (return not_reach_point) # 根据路径表格绘制最短移动路径(正向) steps = step / 2 * 2 loop_times = step / 2 point_x, point_y = chase_point[0], chase_point[1] for i in 2..loop_times # forLoop steps -= 2 if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs if sheet[point_x, $game_map.round_y(point_y + 1)] == steps chase_path.push(2) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps chase_path.push(8) point_y = $game_map.round_y(point_y - 1) elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps chase_path.push(4) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps chase_path.push(6) point_x = $game_map.round_x(point_x + 1) end else if sheet[$game_map.round_x(point_x - 1), point_y] == steps chase_path.push(4) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps chase_path.push(6) point_x = $game_map.round_x(point_x + 1) elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps chase_path.push(2) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps chase_path.push(8) point_y = $game_map.round_y(point_y - 1) end end end #endOfForLoop # 如果指定点无法抵达或者登陆 return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path) # 根据路径表格绘制最短移动路径(反向) steps = step / 2 * 2 + 1 loop_times = step / 2 point_x, point_y = reversed_chase_point[0], reversed_chase_point[1] for i in 1..loop_times # forLoop steps -= 2 if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs if sheet[$game_map.round_x(point_x - 1), point_y] == steps reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) end else if sheet[point_x, $game_map.round_y(point_y + 1)] == steps reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) end end end #endOfForLoop return reversed_chase_path.reverse + chase_path end#boat #-------------------------------------------------------------------------- # ● 绘制ship的移动路径 @array[move_directions...] #-------------------------------------------------------------------------- def draw_ship_path # 准备绘制路径表格 sheet = Table.new($game_map.width, $game_map.height) reversed_chase_path = []; chase_path = [] reversed_chase_point = []; chase_point = [] new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y] sheet[x, y] = 1; sheet[@moveto_x, @moveto_y] = 2 reach_point = false step = 3 loop do #loop1 开始填充表格 draw_path = false check_points = new_start_points new_start_points = [] loop do #loop2 从起点开始正向填充 point_x = check_points.shift break if point_x == nil point_y = check_points.shift left_x = $game_map.round_x(point_x - 1) right_x = $game_map.round_x(point_x + 1) up_y = $game_map.round_y(point_y - 1) down_y = $game_map.round_y(point_y + 1) # 判断路径是否连通 path_step = step - 1 if sheet[left_x, point_y] == path_step chase_path.push(4) chase_point = [left_x, point_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[right_x, point_y] == path_step chase_path.push(6) chase_point = [right_x, point_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[point_x, up_y] == path_step chase_path.push(8) chase_point = [point_x, up_y] reversed_chase_point = [point_x, point_y] reach_point = true; break elsif sheet[point_x, down_y] == path_step chase_path.push(2) chase_point = [point_x, down_y] reversed_chase_point = [point_x, point_y] reach_point = true; break end # 以需要抵达该点的步数填充路径表格 # if sheet[left_x, point_y] == 0 && $game_map.ship_passable?(left_x, point_y) && !collide_with_events?(left_x, point_y) && !collide_with_vehicles?(left_x, point_y) #judge_end sheet[left_x, point_y] = step draw_path = true new_start_points.push(left_x, point_y) end if sheet[right_x, point_y] == 0 && $game_map.ship_passable?(right_x, point_y) && !collide_with_events?(right_x, point_y) && !collide_with_vehicles?(right_x, point_y) #judge_end sheet[right_x, point_y] = step draw_path = true new_start_points.push(right_x, point_y) end if sheet[point_x, up_y] == 0 && $game_map.ship_passable?(point_x, up_y) && !collide_with_events?(point_x, up_y) && !collide_with_vehicles?(point_x, up_y) #judge_end sheet[point_x, up_y] = step draw_path = true new_start_points.push(point_x, up_y) end if sheet[point_x, down_y] == 0 && $game_map.ship_passable?(point_x, down_y) && !collide_with_events?(point_x, down_y) && !collide_with_vehicles?(point_x, down_y) #judge_end sheet[point_x, down_y] = step draw_path = true new_start_points.push(point_x, down_y) end end#endOfLoop2 break if !draw_path || reach_point draw_path = false check_points = new_end_points new_end_points = [] step += 1 break if step > KsOfSion::Break_Steps && !Input.key_press?(KsOfSion::Find_Path_Key) loop do #loop3 从终点开始反向填充 point_x = check_points.shift break if point_x == nil point_y = check_points.shift left_x = $game_map.round_x(point_x - 1) right_x = $game_map.round_x(point_x + 1) up_y = $game_map.round_y(point_y - 1) down_y = $game_map.round_y(point_y + 1) # 判断路径是否连通 path_step = step - 1 if sheet[left_x, point_y] == path_step chase_path.push(6) chase_point = [point_x, point_y] reversed_chase_point = [left_x, point_y] reach_point = true; break elsif sheet[right_x, point_y] == path_step chase_path.push(4) chase_point = [point_x, point_y] reversed_chase_point = [right_x, point_y] reach_point = true; break elsif sheet[point_x, up_y] == path_step chase_path.push(2) chase_point = [point_x, point_y] reversed_chase_point = [point_x, up_y] reach_point = true; break elsif sheet[point_x, down_y] == path_step chase_path.push(8) chase_point = [point_x, point_y] reversed_chase_point = [point_x, down_y] reach_point = true; break end # 以需要抵达该点的步数填充路径表格 # if sheet[left_x, point_y] == 0 && $game_map.ship_passable?(left_x, point_y) && !collide_with_events?(left_x, point_y) && !collide_with_vehicles?(left_x, point_y) #judge_end sheet[left_x, point_y] = step draw_path = true new_end_points.push(left_x, point_y) end if sheet[right_x, point_y] == 0 && $game_map.ship_passable?(right_x, point_y) && !collide_with_events?(right_x, point_y) && !collide_with_vehicles?(right_x, point_y) #judge_end sheet[right_x, point_y] = step draw_path = true new_end_points.push(right_x, point_y) end if sheet[point_x, up_y] == 0 && $game_map.ship_passable?(point_x, up_y) && !collide_with_events?(point_x, up_y) && !collide_with_vehicles?(point_x, up_y) #judge_end sheet[point_x, up_y] = step draw_path = true new_end_points.push(point_x, up_y) end if sheet[point_x, down_y] == 0 && $game_map.ship_passable?(point_x, down_y) && !collide_with_events?(point_x, down_y) && !collide_with_vehicles?(point_x, down_y) #judge_end sheet[point_x, down_y] = step draw_path = true new_end_points.push(point_x, down_y) end end#endOfLoop3 break if !draw_path || reach_point step += 1 end #endOfLoop1 路径表格填充完毕 $mouse_move_sign.transparent = false # 判断指定地点能否抵达 reach_point ? $mouse_move_sign.direction = 2 : (return not_reach_point) # 根据路径表格绘制最短移动路径(正向) steps = step / 2 * 2 loop_times = step / 2 point_x, point_y = chase_point[0], chase_point[1] for i in 2..loop_times # forLoop steps -= 2 if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs if sheet[point_x, $game_map.round_y(point_y + 1)] == steps chase_path.push(2) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps chase_path.push(8) point_y = $game_map.round_y(point_y - 1) elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps chase_path.push(4) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps chase_path.push(6) point_x = $game_map.round_x(point_x + 1) end else if sheet[$game_map.round_x(point_x - 1), point_y] == steps chase_path.push(4) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps chase_path.push(6) point_x = $game_map.round_x(point_x + 1) elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps chase_path.push(2) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps chase_path.push(8) point_y = $game_map.round_y(point_y - 1) end end end #endOfForLoop # 如果指定点无法抵达或者登陆 return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path) # 根据路径表格绘制最短移动路径(反向) steps = step / 2 * 2 + 1 loop_times = step / 2 point_x, point_y = reversed_chase_point[0], reversed_chase_point[1] for i in 1..loop_times # forLoop steps -= 2 if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs if sheet[$game_map.round_x(point_x - 1), point_y] == steps reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) end else if sheet[point_x, $game_map.round_y(point_y + 1)] == steps reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) end end end #endOfForLoop return reversed_chase_path.reverse + chase_path end#ship #-------------------------------------------------------------------------- # ● 绘制airship的移动路径 @array[move_directions...] #-------------------------------------------------------------------------- def draw_air_path $mouse_move_sign.transparent = false # 准备绘制路径表格 sheet = Table.new($game_map.width, $game_map.height) new_check_point = [x, y]; sheet[x, y] = 1 reach_point = false; step = 2 loop do #loop1 check_point = new_check_point new_check_point = [] loop do #loop2 point_x = check_point.shift break if point_x == nil point_y = check_point.shift if point_x == @moveto_x && point_y == @moveto_y reach_point = true; break end left_x = $game_map.round_x(point_x - 1) right_x = $game_map.round_x(point_x + 1) up_y = $game_map.round_y(point_y - 1) down_y = $game_map.round_y(point_y + 1) # 以需要抵达该点的步数填充路径表格 # if sheet[left_x, point_y] == 0 sheet[left_x, point_y] = step new_check_point.push(left_x, point_y) end if sheet[right_x, point_y] == 0 sheet[right_x, point_y] = step new_check_point.push(right_x, point_y) end if sheet[point_x, up_y] == 0 sheet[point_x, up_y] = step new_check_point.push(point_x, up_y) end if sheet[point_x, down_y] == 0 sheet[point_x, down_y] = step new_check_point.push(point_x, down_y) end end#endOfLoop2 break if reach_point step += 1 end #endOfLoop1 # 根据路径表格绘制最短移动路径 # reversed_chase_path = []; step -= 1 point_x, point_y = @moveto_x, @moveto_y for i in 2..step step -= 1 if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs if sheet[$game_map.round_x(point_x - 1), point_y] == step reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == step reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) end else if sheet[point_x, $game_map.round_y(point_y + 1)] == step reversed_chase_path.push(8) point_y = $game_map.round_y(point_y + 1) elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step reversed_chase_path.push(2) point_y = $game_map.round_y(point_y - 1) elsif sheet[$game_map.round_x(point_x - 1), point_y] == step reversed_chase_path.push(6) point_x = $game_map.round_x(point_x - 1) elsif sheet[$game_map.round_x(point_x + 1), point_y] == step reversed_chase_path.push(4) point_x = $game_map.round_x(point_x + 1) end end end #endOfForLoop return reversed_chase_path.reverse end#airship #-------------------------------------------------------------------------- # ● 判断目标点是否能抵达、登陆,用于船只路径绘制 #-------------------------------------------------------------------------- def landable?(x, y, path) case @vehicle_type when :ship; return $game_map.ship_passable?(x, y) || $game_map.passable?(x, y, 10 - path[-1]) when :boat; return $game_map.boat_passable?(x, y) || $game_map.passable?(x, y, 10 - path[-1]) end end end #============================================================================== # ■ Game_Map #------------------------------------------------------------------------------ # 管理地图的类。拥有卷动地图以及判断通行度的功能。 # 本类的实例请参考 $game_map 。 #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- alias sion_mouse_initialize initialize def initialize sion_mouse_initialize creat_move_sign ### set_constants end #-------------------------------------------------------------------------- # ● 更新画面 # main : 事件解释器更新的标志 #-------------------------------------------------------------------------- alias sion_mouse_update update def update(main = false) sion_mouse_update(main) update_move_sign end #-------------------------------------------------------------------------- # ● 设置显示位置 #-------------------------------------------------------------------------- alias sion_mouse_set_display_pos set_display_pos def set_display_pos(x, y) sion_mouse_set_display_pos(x, y) @_display_y_ = @display_y @_display_x_ = @display_x end #-------------------------------------------------------------------------- # ● 创建显示路径点的事件 #-------------------------------------------------------------------------- def creat_move_sign $mouse_move_sign = Move_Sign.new end #-------------------------------------------------------------------------- # ● 更新显示路径点的事件 #-------------------------------------------------------------------------- def set_constants @mouse_pos_setted = true @set_pos_prepared = false @mouse_old_x = 0 @mouse_old_y = 0 end #-------------------------------------------------------------------------- # ● 更新显示路径点的事件 #-------------------------------------------------------------------------- def update_move_sign $mouse_move_sign.update end #-------------------------------------------------------------------------- # ● 获取鼠标位于的地图块的x、y坐标 #-------------------------------------------------------------------------- def mouse_map_x round_x((@display_x + Mouse.x / 32.0).to_i) end def mouse_map_y round_y((@display_y + Mouse.y / 32.0).to_i) end #-------------------------------------------------------------------------- # ● 返回地图画面时重设鼠标坐标 #-------------------------------------------------------------------------- def reset_mouse_pos return if @mouse_pos_setted Mouse.set_pos(@mouse_old_x, @mouse_old_y) @mouse_pos_setted = true @set_pos_prepared = false end #-------------------------------------------------------------------------- # ● 重设鼠标的坐标 #-------------------------------------------------------------------------- def prepare_reset_mouse_pos return if @set_pos_prepared @mouse_pos_setted = false @mouse_old_x = Mouse.x @mouse_old_y = Mouse.y @set_pos_prepared = true end #-------------------------------------------------------------------------- # ● 向下卷动 #-------------------------------------------------------------------------- def new_scroll_down(distance) if loop_vertical? @_display_y_ += distance @_display_y_ %= @map.height @parallax_y += distance if @parallax_loop_y else last_y = @_display_y_ @_display_y_ = [@_display_y_ + distance, height - screen_tile_y].min @parallax_y += @_display_y_ - last_y end @display_y = (@_display_y_ * 32).round / 32.0 end #-------------------------------------------------------------------------- # ● 向左卷动 #-------------------------------------------------------------------------- def new_scroll_left(distance) if loop_horizontal? @_display_x_ += @map.width - distance @_display_x_ %= @map.width @parallax_x -= distance if @parallax_loop_x else last_x = @_display_x_ @_display_x_ = [@_display_x_ - distance, 0].max @parallax_x += @_display_x_ - last_x end @display_x = (@_display_x_ * 32).round / 32.0 end #-------------------------------------------------------------------------- # ● 向右卷动 #-------------------------------------------------------------------------- def new_scroll_right(distance) if loop_horizontal? @_display_x_ += distance @_display_x_ %= @map.width @parallax_x += distance if @parallax_loop_x else last_x = @_display_x_ @_display_x_ = [@_display_x_ + distance, (width - screen_tile_x)].min @parallax_x += @_display_x_ - last_x end @display_x = (@_display_x_ * 32).round / 32.0 end #-------------------------------------------------------------------------- # ● 向上卷动 #-------------------------------------------------------------------------- def new_scroll_up(distance) if loop_vertical? @_display_y_ += @map.height - distance @_display_y_ %= @map.height @parallax_y -= distance if @parallax_loop_y else last_y = @_display_y_ @_display_y_ = [@_display_y_ - distance, 0].max @parallax_y += @_display_y_ - last_y end @display_y = (@_display_y_ * 32).round / 32.0 end end #============================================================================== # ■ Spriteset_Map #------------------------------------------------------------------------------ # 处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。 #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # ● 生成路径点精灵 #-------------------------------------------------------------------------- alias sion_mouse_create_characters create_characters def create_characters sion_mouse_create_characters @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign)) end end #============================================================================== # ■ SceneManager #============================================================================== class << SceneManager alias sion_mouse_snapshot_for_background snapshot_for_background def snapshot_for_background Mouse.sprite.visible = false sion_mouse_snapshot_for_background Mouse.sprite.visible = true end end #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ # 地图画面 #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● 画面更新 #-------------------------------------------------------------------------- alias sion_mouse_update_scene update_scene def update_scene sion_mouse_update_scene update_mouse_action unless scene_changing? || $game_map.interpreter.running? end #-------------------------------------------------------------------------- # ● 场所移动前的处理 #-------------------------------------------------------------------------- alias sion_mouse_pre_transfer pre_transfer def pre_transfer $game_player.reset_move_path sion_mouse_pre_transfer end #-------------------------------------------------------------------------- # ● 监听鼠标左键的按下 #-------------------------------------------------------------------------- def update_mouse_action $game_player.left_button_action if Input.key_press?(0x01) end end #============================================================================== # ■ Scene_File #------------------------------------------------------------------------------ # 存档画面和读档画面共同的父类 #============================================================================== class Scene_File < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- alias sion_mouse_start start def start sion_mouse_start @move_state = 0 set_mouse_pos end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- alias sion_mouse_update update def update sion_mouse_update Input.dir4.zero? ? set_cursor : set_mouse_pos end #-------------------------------------------------------------------------- # ● 更新光标 #-------------------------------------------------------------------------- def set_cursor @move_state += 1 last_index = @index if mouse_which_window == -2 if (@move_state - 1) % 6 == 0 @index = (@index + 1) % item_max if @index < item_max - 1 end elsif mouse_which_window == -1 if (@move_state - 1) % 6 == 0 @index = (@index - 1 + item_max) % item_max if @index > 0 end else @move_state = 0 @index = top_index + mouse_which_window end ensure_cursor_visible if @index != last_index @savefile_windows[last_index].selected = false @savefile_windows[@index].selected = true end end #-------------------------------------------------------------------------- # ● 判断鼠标位于哪个窗口 #-------------------------------------------------------------------------- def mouse_which_window mouse_x = Mouse.x mouse_y = Mouse.y if mouse_y < @help_window.height + 14 mouse_row = -1 elsif mouse_y > Graphics.height - 14 mouse_row = -2 else mouse_row = 4 * (mouse_y - @help_window.height) / (Graphics.height - @help_window.height) end return mouse_row end #-------------------------------------------------------------------------- # ● 方向键移动光标时将鼠标移动到对应的光标位置 #-------------------------------------------------------------------------- def set_mouse_pos new_x = 40 new_y = @help_window.height + savefile_height * (@index - top_index) + 24 Mouse.set_pos(new_x, new_y) end end #============================================================================== # ■ Game_Event #------------------------------------------------------------------------------ # 处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。 # 在 Game_Map 类的内部使用。 #============================================================================== class Game_Event < Game_Character alias_method :sion_mouse_start, :start alias_method :sion_mouse_setup_page, :setup_page def start return if mouse_start? && !Input.key_press?(0x01) sion_mouse_start end def mouse_start? @mouse_start end def setup_page(p) sion_mouse_setup_page(p) sion_mouse_read_event_notes end def sion_mouse_read_event_notes @mouse_start = false @list.each {|cmd| break if sion_mouse_scan_list(cmd)} unless empty? end def sion_mouse_scan_list(cmd) return false unless cmd.code == 108 || cmd.code == 408 return @mouse_start = cmd.parameters[0].include?("鼠标启动") end end #encoding:utf-8 #============================================================================== # ■ BattleManager #------------------------------------------------------------------------------ # 战斗过程的管理器。 #============================================================================== class << BattleManager alias_method :sion_mouse_on_encounter, :on_encounter # 遇敌后重置移动路径 def on_encounter $game_player.reset_move_path sion_mouse_on_encounter end end if $SINOVA #验证组件完整性 if $SINOVA[:mouseBase] if $SINOVA[:mouseBase] >= 3.00 #所需组件版本 $SINOVA[:mouseBaseSystem] = 3.01 #当前组件版本 else msgbox "Sion_MouseBase 版本过低,需 3.00 以上" exit end else msgbox "Nova_TypeIn 需置于 Sion_MouseBase 脚本之下" exit end else msgbox "Nova_TypeIn 需置于 NovaBase 脚本之下" exit end
#encoding:utf-8 # 基础鼠标模组 v3.02 (2014/2/15) # ·需· SiNova_Input v1.00+ # v3.02 添加方法,以便兼容以前写的脚本 # 鼠标指针图片 MouseCursor.png 放入 Graphics\System 文件夹 module Mouse end class << Mouse DK_Frame = 15 # 判断双击间隔帧数 attr_reader\ :dk_count GetMousePos = API_.new 'SiNova|GetMousePos|p|v' SetMousePos = API_.new 'SiNova|SetMousePos|II|v' MouseZ = API_.new 'SiNova|MouseZ|v|i' MouseZReset = API_.new 'SiNova|MouseZReset|v|v' def activate(vp = nil) @buf = [0, 0].pack("ii") @ck_count = 0 @dk_count = 0 hide_system_cursor create_cursor(vp) end def update update_cursor update_mouse_lock update_mouse_scroll update_double_click end def deactivate show_system_cursor dispose_cursor end def create_cursor(vp) dispose_cursor if @sprite @sprite = Sprite.new(vp) @sprite.z = 9999 if File.exist?('Graphics/System/MouseCursor.png') @sprite.bitmap = Cache.system('MouseCursor') else @sprite.bitmap = Bitmap.new(24, 24) @sprite.bitmap.blt(0, 0, Cache.system('Iconset'), Rect.new(5 * 24, 24 * 24, 24, 24)) end update_cursor end def dispose_cursor return if @sprite.disposed? @sprite.bitmap.dispose @sprite.dispose update end # def x @sprite.x end def y @sprite.y end def z MouseZ.call end def reset_z MouseZReset.call end # 3.01 new -- def press?(sym) case sym when :L; Input.key_press? 0x01 when :R; Input.key_press? 0x02 when :M; Input.key_press? 0x05 end end def trigger?(sym) case sym when :L; Input.key_trigger? 0x01 when :R; Input.key_trigger? 0x02 when :M; Input.key_trigger? 0x05 end end def repeat?(sym) case sym when :L; Input.key_repeat? 0x01 when :R; Input.key_repeat? 0x02 when :M; Input.key_repeat? 0x05 end end #-- def update_cursor GetMousePos.call @buf @sprite.x, @sprite.y = *@buf.unpack("ii") end def update_mouse_scroll @mouseZ end # def update_double_click if Input.key_trigger?(0x01) if @dk_count <= DK_Frame @dk_count = DK_Frame @double_click = true else # 非双击,重置 dk_count @dk_count = 0 @double_click = false end else @double_click = false end @dk_count += 1 end def double_click? @double_click end # def update_mouse_lock # press Alt + L 锁定 Alt + O 解除锁定 if Input.key_press?(0x12) return lock if Input.key_trigger?(0x4C) return unlock if Input.key_trigger?(0x4F) end end # def lock API_.call 'SiNova|MouseLock|v|v' end def unlock API_.call 'SiNova|MouseUnLock|v|v' end def show_system_cursor api_sc = API_.new 'User32|ShowCursor|p|l' begin state = api_sc.call(1) end while state < 0 end def hide_system_cursor api_sc = API_.new 'User32|ShowCursor|p|l' begin state = api_sc.call(0) end while state >= 0 end def set_pos(x, y) SetMousePos.call(x, y) end end if $SINOVA #验证组件完整性 if $SINOVA[:input] if $SINOVA[:input] >= 1.00 #所需组件版本 $SINOVA[:mouseBase] = 3.02 #当前组件版本 else msgbox "SiNova_Input 版本过低,需 1.00 以上" exit end else msgbox "Nova_TypeIn 需置于 SiNova_Input 脚本之下" exit end else msgbox "Nova_TypeIn 需置于 NovaBase 脚本之下" exit end
#encoding:utf-8 # 输入窗口范例 v1.00 (2014/2/15) # ·需· SiNova_Input v1.00+ # v1.01 优化了转码方式 # 事件中调用输入窗: # typein_active(1) 使用1号变量获取输入字符,其余参数参考下面 class Game_Interpreter # =========================== TypeIn_W = 200 # 默认输入窗宽 TypeIn_H = 30 # 默认输入窗高 def typein_active( # 参数说明: var_id , # 接收输入文本的变量号 w= TypeIn_W, # 宽 h= TypeIn_H, # 高 x= (Graphics.width - w) / 2 , # x 坐标,默认为居中 y= (Graphics.height - h) / 2 , # y 坐标,默认为居中 text= "" # 输入窗默认字符 ) # 参数 end wait_for_message @typeIn_port = TypeIn_Port.new( x, y, w, h, text ) while @typeIn_port.active # 按下回车跳出循环 @typeIn_port.update Fiber.yield end $game_variables[var_id] = @typeIn_port.text @typeIn_port.dispose end end # 输入窗类 =========================================== class TypeIn_Port < Viewport attr_reader\ :active, :text def padding; 3 end #设置边距 def backColor; Color.new(0, 0, 0, 150) end #背景颜色 def cursorColor; Color.new(255, 255, 255) end #光标颜色 def initialize(x, y, w, h, text="") super(x, y, w, h) setup_sprites(w, h) init_members(text) refresh_cursor update end # def init_members(text) @active = true @text = text setup_apis end def setup_apis API_.call 'SiNova|TypeInActivate|v|l' @api_GetTypeInText = API_.new 'SiNova|GetTypeInText|v|p' @api_SetTypeInPos = API_.new 'SiNova|SetTypeInPos|ii|v' end def setup_sprites(w, h) create_back_ground(w, h) create_text_field(w, h) create_cursor(h) end # def dispose API_.call 'SiNova|TypeInDeactivate|v|v' dispose_back_ground dispose_text_field dispose_cursor super end # # 背景 def create_back_ground(w, h) @back_ground = Sprite.new bitmap = Bitmap.new(w, h) bitmap.fill_rect( bitmap.rect, backColor ) @back_ground.bitmap = bitmap @back_ground.viewport = self end def dispose_back_ground @back_ground.bitmap.dispose @back_ground.dispose end # 字符输入区域 def create_text_field(w, h) @text_field = Sprite.new @text_field.x = padding @text_field.y = padding pd = padding * 2 w -= pd h -= pd bitmap = Bitmap.new( w, h ) bitmap.font.size = h @text_field.bitmap = bitmap @text_field.viewport = self end def update_text_field #更新输入文字 t = @api_GetTypeInText.call.clone.force_encoding "utf-8" return if t.empty? wl = self.rect.width - text_width(@text) - padding wn = text_width(t) while wn > wl #判断可否加入新文字 t.chop! return if t.empty? wn = text_width(t) end @text.insert(@cursor_i, t) redraw_texts # 更新光标索引 @cursor_i += t.length @cursor.x += wn refresh_cursor end def dispose_text_field @text_field.bitmap.dispose @text_field.dispose end # 光标 def create_cursor(h) @cursor = Sprite.new @cursor.ox = -4 @cursor.oy = -padding bitmap = Bitmap.new(1, h - padding * 2) bitmap.fill_rect( bitmap.rect, cursorColor ) @cursor.bitmap = bitmap @cursor_i = 0 @cursor.viewport = self end def update_cursor @cursor_c += 1 if @cursor_c >= 40 @cursor.visible = !@cursor.visible @cursor_c = 0 end end def dispose_cursor @cursor.bitmap.dispose @cursor.dispose end # def update update_text_field update_cursor update_input end def update_input if Input.key_repeat? 0x08 process_backspace elsif Input.key_repeat? 0x25 process_left_arrow elsif Input.key_repeat? 0x27 process_right_arrow elsif Input.key_trigger? 0x0D process_enter elsif Input.key_trigger? 0x1B process_esc end end # 按下回车键的处理 def process_enter @active = false end # 按下Esc键的处理 def process_esc end # # 删除一个字符 def process_backspace if @cursor_i == 0 @text = @text[1, @text.length - 1] unless @text.empty? else @cursor.x -= text_width @text[@cursor_i - 1] @text = @text[0, @cursor_i-1] + @text[@cursor_i, @text.length-@cursor_i] @cursor_i -= 1 end redraw_texts refresh_cursor end # def process_left_arrow return if @cursor_i == 0 @cursor.x -= text_width @text[@cursor_i - 1] @cursor_i -= 1 refresh_cursor end def process_right_arrow return if @cursor_i == @text.length @cursor.x += text_width @text[@cursor_i] @cursor_i += 1 refresh_cursor end # def refresh_cursor @cursor.visible = true @cursor_c = 0 @api_SetTypeInPos.call(rect.x + @cursor.x + 2, rect.y + 8) end # def redraw_texts @text_field.bitmap.clear rect = @text_field.bitmap.rect rect.width += 10 @text_field.bitmap.draw_text( rect, @text ) end #~ def redraw_texts(nt, nt_w) #~ x = text_width @text[0, @cursor_i] #~ w = @text_field.bitmap.width #~ h = @text_field.bitmap.height #~ bitmap = Bitmap.new( w, h ) #~ srcR = Rect.new( x, 0, w - x, h ) #~ bitmap.blt( x, 0, @text_field.bitmap, srcR) #~ @text_field.bitmap.clear_rect( srcR ) #~ @text_field.bitmap.draw_text( srcR, nt ) #~ @text_field.bitmap.blt( x + nt_w, 0, bitmap, srcR ) #~ bitmap.dispose #~ @text.insert( @cursor_i, nt ) #~ end def text_width(text) @text_field.bitmap.text_size(text).width end end if $SINOVA #验证组件完整性 if $SINOVA[:input] if $SINOVA[:input] >= 1.00 #所需组件版本 $SINOVA[:typeIn] = 1.01 #当前组件版本 else msgbox "SiNova_Input 版本过低,需 1.00 以上" exit end else msgbox "Nova_TypeIn 需置于 SiNova_Input 脚本之下" exit end else msgbox "Nova_TypeIn 需置于 NovaBase 脚本之下" exit end
#encoding:utf-8 # SiNova_Input v1.03 (2014/2/15) # ·需· NovaBase v10000+ # 使用此模块,F1 的按键设置将无用 # 1.03 修改一个方法命名 # 1.02 修复脚本内按键判断 # 1.01 可设置按键改为 12 个 # 系统保留按键 F5 ~ F9 SHIFT ALT 功能恢复,消除了可能的冲突 class << Input attr_reader\ :dir4, :dir8, :key_states def init # 在这里查表修改对应按键 0 代表无设置 # 你可以通过脚本在游戏中调整这些按键,做出在游戏中让玩家设置按键的效果 # 按键对应 ASCII 值请查看键盘表 # 例如把“左”设置为 0x41 按下 A 键就可以往左移动了。 # WASD 的值都写在下面了,自己填到左边试试。 keys = [#键盘 -> Symbol 0, # -> :A 0x58, # X -> :B 0x5A, # Z -> :C 0, # -> :X 0, # -> :Y 0, # -> :Z 0x51, # Q -> :L 0x45, # E -> :R 0, # -> :LEFT 左 A键 0x41 0, # -> :UP 上 W键 0x57 0, # -> :RIGHT 右 D键 0x44 0 # -> :DOWN 下 S键 0x53 ] # 设置时注意后面的逗号不要弄丢了 # 然后调用方法 Input.setup_keys(keys) 把你设置的 keys 应用到 DLL 里 setup_keys(keys) # 应用上面设置的键位 # PS:在 Input 模块内调用就不必加 "Input." 了 # @dkey_map = { # 注释为对应的默认按键 # 例如 Input.press?( :A ) 就是判断 Shift 键是否按下 # 这些按键无法更改 A: 0, # L&R Shift B: 1, # Esc C: 2, # Enter Space X: 3, # Y: 4, # Z: 5, # L: 6, # PageUp R: 7, # PageDown LEFT: 8, # 左 UP: 9, # 下 RIGHT: 10,# 右 DOWN: 11,# 上 Arrow Key F5: 12,# F5 F6: 13,# F6 F7: 14,# F7 F8: 15,# F8 F9: 16,# F9 Debug 菜单 CTRL: 17,# Ctrl Debug 穿透 ALT: 18,# Alt SHIFT: 0, # 等同于 :A # Interpreters Key Judge 2 => 11, 4 => 8, 6 => 10, 8 => 9 } 8.times {|i| @dkey_map[i + 11] = i} # init_keys init_apis end # def init_keys key_max = 190 key_num = 19 @key_buf = Array.new(key_max) {0}.pack("I*") @dkey_buf = Array.new(key_num) {0}.pack("I*") @key_states = Array.new(key_max) {0} @dkey_states = Array.new(key_num) {0} @dir4 = 0 @dir8 = 0 @dir_state = 0 end def init_apis @api_UpdateKeys = API_.new 'SiNova|UpdateKeys|v|v' API_.call 'SiNova|LoadKeyBuf|pp|v', @key_buf, @dkey_buf end def setup_keys(keys) API_.call 'SiNova|LoadDKeySet|p|i', keys.pack("I*") end def update @api_UpdateKeys.call @key_states = @key_buf.unpack("I*") @dkey_states = @dkey_buf.unpack("I*") update_dir_state end # arrow keys def update_dir_state if press?(:DOWN) if press?(:LEFT); @dir8 = 1 elsif press?(:RIGHT); @dir8 = 3 else @dir8 = 2 end @dir4 = 2 @dir_state += 1 elsif press?(:LEFT) @dir8 = press?(:UP) ? 7 : 4 @dir4 = 4 @dir_state += 1 elsif press?(:RIGHT) @dir8 = press?(:UP) ? 9 : 6 @dir4 = 6 @dir_state += 1 elsif press?(:UP) @dir8 = 8 @dir4 = 8 @dir_state += 1 else @dir8 = 0 @dir4 = 0 @dir_state = 0 end end def press?(btn) @dkey_states[@dkey_map[btn]] != 0 rescue p btn end def trigger?(btn) @dkey_states[@dkey_map[btn]] == 1 end def repeat?(btn) s = @dkey_states[@dkey_map[btn]] s == 1 || s > 19 && s % 5 == 1 end # def key_press?(k) @key_states[k] != 0 end def key_trigger?(k) @key_states[k] == 1 end def key_repeat?(k) s = @key_states[k] s == 1 || s > 19 && s % 5 == 1 end # def dir_trigger? @dir_state == 1 end def dir_repeat? dir_trigger? || @dir_state > 19 && @dir_state % 5 == 1 end # def any_key_press? @key_states.any? {|s| s != 0} end def any_key_trigger? @key_states.any? {|s| s == 1} end end class << SceneManager alias_method :siNova_input_run, :run def run Input.init siNova_input_run end end if $SINOVA #验证组件完整性 if $SINOVA[:version] >= 10001 #所需组件版本 $SINOVA[:input] = 1.03 #当前组件版本 else msgbox "NovaBase 版本过低,至少需 10001 以上" exit end else msgbox "SiNova_Input 需置于 NovaBase 脚本之下" exit end
#encoding:utf-8 # 游戏结束时的额外处理,这里显示一张图片演示功能。 API_.call 'SiNova|ProcessEndEx|v|v' #API_.call 'SiNova|ProcessEndEx|i|v', 0 #关闭 class << Graphics attr_writer :game_exit # 在这里添加游戏结束时进行的处理 def process_endEx s = Sprite.new s.bitmap = Bitmap.new("gameEnd") s.z = 11111 Graphics.wait(120) end alias_method :siNovaEndEx_update, :update def update siNovaEndEx_update if @game_exit process_endEx exit end end end # class << SceneManager def exit Graphics.game_exit = true end end class Scene_Title def command_shutdown Graphics.game_exit = true end end class Scene_End def command_shutdown Graphics.game_exit = true end end if $SINOVA #验证组件完整性 if $SINOVA[:version] >= 10013 #所需组件版本 $SINOVA[:endEx] = 1.00 #当前组件版本 else msgbox "NovaBase 版本过低,至少需 10013 以上" exit end else msgbox "SiNova_Input 需置于 NovaBase 脚本之下" exit end
#encoding:utf-8 # ·需· NovaBase v10000+ API_.call 'SiNova|BackGroundRun|i|v', 1
#encoding:utf-8 #这个范例是普通功能的演示,Debug 窗使用方法请参考另一个工程。 #因为有鼠标脚本隐藏了系统鼠标,不便于 Debug 窗功能的演示 - -b =begin SiNova.dll RM 功能扩展 v.10013 (2014/3/14) update log: 10013(2014/3/14) -- 加入游戏结束处理。可以在玩家 x 掉游戏时做一些代码处理 参考 SiNova_EndEx 10012(2014/2/21) -- DEBUG: tab 键将置换为2个空格。 10010(2014/2/15) -- 加入 DEBUG 功能 使用说明: 需在游戏目录下加入 SiNova.dll,它为 RM 添加了以下功能: 1. F3 放大缩小屏幕 F4 切换鼠标是否锁定在窗口内部 系统会自动记录这些信息,应用在下次启动时 可以在下方自己设置这两个按键 2. 重写 Input 模块 ·全键盘接口 Input.key_press?(key) 判断某个按键是否按下 Input.key_trigger?(key) 判断某个按键是否刚被按下 Input.key_repeat?(key) 持续按住按键会间隔返回 true key 为按键对应的 ASCII 值,查看键盘表获取 例如要判断 A 键是否按下就是 Input.key_press?( 0x41 ) ·按键设置接口 提供 12 个可设置的按键。 参考 SiNova_Input v1.01 设置按键,可以在游戏中随时修改。 3. 后台运行功能 开启: API_.call 'SiNova|BackGroundRun|i|v', 1 关闭: API_.call 'SiNova|BackGroundRun|i|v', 0 4. 输入法接口 ·DLL 函数 参数 返回值 说明 TypeInActivate v l 创建输入窗,焦点转到该窗口;返回窗口句柄 TypeInDeactivate v v 销毁输入窗口,焦点返回主窗口 GetTypeInText v p 获取输入窗口内文字,并清空该窗口 SetTypeInPos ii v 设置输入法出现的位置 输入窗口激活时: 焦点总在输入窗口 Input模块只响应功能键 5. 完整鼠标接口 ·DLL 函数 参数 返回值 说明 GetMousePos p(II) v 获取鼠标坐标 MouseZ v i 鼠标滚轮状态,上滚此值 +1,下滚 -1 MouseZReset v v 重置鼠标滚轮状态为 0 MouseLock v v 锁定鼠标在游戏窗口内 MouseUnLock v v 解除锁定 MouseSetPos ii v 把鼠标设置到 x, y 处 6. Debug 窗口功能 =end #~ if File.exist? "PubNova.dll" #~ File.delete "SiNova.dll" if File.exist? "SiNova.dll" #~ File.rename( "PubNova.dll", "SiNova.dll" ) #~ end unless $SINOVA # 2个系统键,查阅<键盘表>改成你需要的键。如果不想使用此功能就设置为0 key1 = 0x72 # F3键 缩放屏幕 key2 = 0x73 # F4键 切换鼠标锁定 # ========== 以下非设置部分 ============ $SINOVA = {} $SINOVA[:version] = 10013 # 当前版本 $SINOVA[:lib] = 'SiNova' # 文件确认 unless File.exist?("#{$SINOVA[:lib]}.dll") msgbox "未找到 #{$SINOVA[:lib]}.dll" exit end module API_ # ============================ def self.new(str); Win32API.new(*str.split('|')) end def self.call(str, *args); new(str).call(*args) end end # DLL版本验证 if $SINOVA[:version] > API_.call('SiNova|NovaVersion|v|l') msgbox "#{$SINOVA[:lib]}.dll 版本过低,请前往发布页面更新。" exit end # 尝试加载 $SINOVA[:main] = API_.new "#{$SINOVA[:lib]}|Hook|v|l" case $SINOVA[:main].call when 0 msgbox "加载 #{$SINOVA[:lib]}.dll 失败" exit when -1 msgbox "游戏已运行" exit end # 读取2个系统键 API_.call 'SiNova|LoadSysKeySet|ii|v', key1, key2 class Numeric # ============================ def max(v); self > v ? self : v end # 取最大值 def min(v); self < v ? self : v end # 取最小值 end end
#============================================================================== # ■ VXAce_SP1 #------------------------------------------------------------------------------ # プリセットスクリプトの不具合を修正します。ユーザー定義のスクリプト素材は、 # 原則としてこのセクションより下に配置してください。 #============================================================================== #------------------------------------------------------------------------------ # 【修正内容】 #------------------------------------------------------------------------------ # ●イベントコマンド[ステートの変更]にて、同じステートの付加と解除を同時に実 # 行した際、二回目以降の付加が失敗する不具合を修正しました。 # ●イベントコマンド[アニメーションの表示]にて、表示中のアニメーションがマッ # プのスクロールに同期しない不具合を修正しました。 # ●自動戦闘の行動が正常に選択されない不具合を修正しました。 # ●装備できなくなった装備品が外れたことにより、さらに別の装備品が装備できなく # なったとき、その装備品が増殖してしまう不具合を修正しました。 # ●イベントコマンド[ピクチャの消去]を実行した後に余分な負荷がかかる不具合を # 修正しました。 # ●移動ルートのオプション[移動できない場合は飛ばす]にチェックを入れた状態で # トリガー[プレイヤーから接触]のイベントに接触すると、イベントが実行中であ # っても起動予約がされてしまう不具合を修正しました。 # ●魔法反射されたスキルに対してステート有効度が反映されない不具合を修正しまし # た。 # ●フォントのデフォルト設定にて太字または斜体を有効にしていても、ステータス画 # 面を切り替えたとき等に無効な状態に戻ってしまう不具合を修正しました。 #------------------------------------------------------------------------------ class Game_Battler attr_accessor :magic_reflection #-------------------------------------------------------------------------- # ● 敵対関係の判定 #-------------------------------------------------------------------------- alias vxace_sp1_opposite? opposite? def opposite?(battler) vxace_sp1_opposite?(battler) || battler.magic_reflection end end #------------------------------------------------------------------------------ class Game_Actor #-------------------------------------------------------------------------- # ● 装備できない装備品を外す # item_gain : 外した装備品をパーティに戻す #-------------------------------------------------------------------------- alias vxace_sp1_release_unequippable_items release_unequippable_items def release_unequippable_items(item_gain = true) loop do last_equips = equips.dup vxace_sp1_release_unequippable_items(item_gain) return if equips == last_equips end end #-------------------------------------------------------------------------- # ● 自動戦闘時の戦闘行動を作成 #-------------------------------------------------------------------------- def make_auto_battle_actions @actions.size.times do |i| @actions[i] = make_action_list.max_by {|action| action.value } end end end #------------------------------------------------------------------------------ class Game_Player #-------------------------------------------------------------------------- # ● マップイベントの起動 # triggers : トリガーの配列 # normal : プライオリティ[通常キャラと同じ]かそれ以外か #-------------------------------------------------------------------------- alias vxace_sp1_start_map_event start_map_event def start_map_event(x, y, triggers, normal) return if $game_map.interpreter.running? vxace_sp1_start_map_event(x, y, triggers, normal) end end #------------------------------------------------------------------------------ class Game_Picture #-------------------------------------------------------------------------- # ● ピクチャの消去 #-------------------------------------------------------------------------- alias vxace_sp1_erase erase def erase vxace_sp1_erase @origin = 0 end end #------------------------------------------------------------------------------ class Game_Interpreter #-------------------------------------------------------------------------- # ● ステートの変更 #-------------------------------------------------------------------------- alias vxace_sp1_command_313 command_313 def command_313 vxace_sp1_command_313 $game_party.clear_results end end #------------------------------------------------------------------------------ class Sprite_Character #-------------------------------------------------------------------------- # ● 位置の更新 #-------------------------------------------------------------------------- alias vxace_sp1_update_position update_position def update_position move_animation(@character.screen_x - x, @character.screen_y - y) vxace_sp1_update_position end #-------------------------------------------------------------------------- # ● アニメーションの移動 #-------------------------------------------------------------------------- def move_animation(dx, dy) if @animation && @animation.position != 3 @ani_ox += dx @ani_oy += dy @ani_sprites.each do |sprite| sprite.x += dx sprite.y += dy end end end end #------------------------------------------------------------------------------ class Sprite_Picture #-------------------------------------------------------------------------- # ● 転送元ビットマップの更新 #-------------------------------------------------------------------------- alias vxace_sp1_update_bitmap update_bitmap def update_bitmap if @picture.name.empty? self.bitmap = nil else vxace_sp1_update_bitmap end end end #------------------------------------------------------------------------------ class Window_Base #-------------------------------------------------------------------------- # ● フォント設定のリセット #-------------------------------------------------------------------------- alias vxace_sp1_reset_font_settings reset_font_settings def reset_font_settings vxace_sp1_reset_font_settings contents.font.bold = Font.default_bold contents.font.italic = Font.default_italic end end #------------------------------------------------------------------------------ class Scene_Battle #-------------------------------------------------------------------------- # ● 魔法反射の発動 #-------------------------------------------------------------------------- alias vxace_sp1_invoke_magic_reflection invoke_magic_reflection def invoke_magic_reflection(target, item) @subject.magic_reflection = true vxace_sp1_invoke_magic_reflection(target, item) @subject.magic_reflection = false end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |