赞 | 4 |
VIP | 44 |
好人卡 | 11 |
积分 | 12 |
经验 | 54954 |
最后登录 | 2021-10-2 |
在线时间 | 1276 小时 |
Lv3.寻梦者 ○赛
- 梦石
- 0
- 星屑
- 1249
- 在线时间
- 1276 小时
- 注册时间
- 2013-1-22
- 帖子
- 2246
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 天地有正气 于 2013-12-21 08:29 编辑
一下是我的鼠标脚本,寻路算法和窗口扩大(从赛尔号单机版找来的)
因为脚本变形,所以 @fog
窗口扩大- # ————————————————————————————————————
- # 本脚本来自www.66rpg.com,转载请保留此信息
- # ————————————————————————————————————
-
- class Win32API
- GAME_INI_FILE = ".\\Game.ini"
- HWND_TOPMOST = 0
- HWND_TOP = -1
- SWP_NOMOVE = 0
- SWP_FRAMECHANGED = 0
- HWND_NOTTOPMOST = 0
- WM_GETMINMAXINFO = 24
- end
- $width = 1024
- $height = 704
- #==============================================================================
- # ■ Spriteset_Map
- #------------------------------------------------------------------------------
- # 处理地图画面活动块和元件的类。本类在 Scene_Map 类的内部使用。
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- @viewport2 = Viewport.new(0, 0, $width, $height) #——生成图片
- @viewport3 = Viewport.new(0, 0, $width, $height) #——生成画面闪烁用的部分
- $viewport4 = Viewport.new(640, 0, $width-640, 480) #——右侧
- $viewport5 = Viewport.new(0, 480, 640, $height-480) #——下侧
- $viewport6 = Viewport.new(640, 480, $width-640, $height-480) #——右下角
- $viewport1 = Viewport.new(0, 0, 1024, 704) #——主窗口
- @viewport_weather = Viewport.new(0, 0, $width, $height) #——生成天气专用
- @viewport2.z = 200 #——生成图片的深度
- @viewport3.z = 5000 #——生成画面闪烁用的深度
- @tilemap = Tilemap.new($viewport1) #——主窗口
- @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
- @tilemap2 = Tilemap.new($viewport4) #——右侧
- @tilemap2.tileset = RPG::Cache.tileset($game_map.tileset_name)
- @tilemap3 = Tilemap.new($viewport5) #——下侧
- @tilemap3.tileset = RPG::Cache.tileset($game_map.tileset_name)
- @tilemap4 = Tilemap.new($viewport6) #——右下角
- @tilemap4.tileset = RPG::Cache.tileset($game_map.tileset_name)
- for i in 0..6 #——生成自动元件
- autotile_name = $game_map.autotile_names[i]
- @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
- @tilemap2.autotiles[i] = RPG::Cache.autotile(autotile_name)
- @tilemap3.autotiles[i] = RPG::Cache.autotile(autotile_name)
- @tilemap4.autotiles[i] = RPG::Cache.autotile(autotile_name)
- end
- @tilemap.map_data = $game_map.data #——生成地图数据
- @tilemap2.map_data = $game_map.data
- @tilemap3.map_data = $game_map.data
- @tilemap4.map_data = $game_map.data
- @tilemap.priorities = $game_map.priorities #——生成优先
- @tilemap2.priorities = $game_map.priorities
- @tilemap3.priorities = $game_map.priorities
- @tilemap4.priorities = $game_map.priorities
- @character_sprites = [] #——生成事件
- for i in $game_map.events.keys.sort
- sprite = Sprite_Character.new($viewport1, $game_map.events[i])
- @character_sprites.push(sprite)
- sprite = Sprite_Character.new($viewport4, $game_map.events[i])
- @character_sprites.push(sprite)
- sprite = Sprite_Character.new($viewport5, $game_map.events[i])
- @character_sprites.push(sprite)
- sprite = Sprite_Character.new($viewport6, $game_map.events[i])
- @character_sprites.push(sprite)
- end #——下面继续生成角色
- @character_sprites.push(Sprite_Character.new($viewport1, $game_player))
- @character_sprites.push(Sprite_Character.new($viewport4, $game_player))
- @character_sprites.push(Sprite_Character.new($viewport5, $game_player))
- @character_sprites.push(Sprite_Character.new($viewport6, $game_player))
- #——下面生成远景
- @panorama = Plane.new($viewport1)
- @panorama.z = -1000
- @panorama2 = Plane.new($viewport4)
- @panorama2.z = -1000
- @panorama3 = Plane.new($viewport5)
- @panorama3.z = -1000
- @panorama4 = Plane.new($viewport6)
- @panorama4.z = -1000
- #——下面生成雾
- [url=home.php?mod=space&uid=14217]@fog[/url] = Plane.new($viewport1)
- @fog.z = 3000
- @fog2 = Plane.new($viewport4)
- @fog2.z = 3000
- @fog3 = Plane.new($viewport5)
- @fog3.z = 3000
- @fog4 = Plane.new($viewport6)
- @fog4.z = 3000
- #——下面生成天气
- @weather = Weather.new(@viewport_weather)
- @picture_sprites = [] #——这里生成图片
- for i in 1..50
- @picture_sprites.push(Sprite_Picture.new(@viewport2, $game_screen.pictures[i]))
- end
- @timer_sprite = Sprite_Timer.new #——生成计时器
- #——刷新
- update
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- @tilemap.tileset.dispose #——释放元件地图
- @tilemap2.tileset.dispose
- @tilemap3.tileset.dispose
- @tilemap4.tileset.dispose
- for i in 0..6
- @tilemap.autotiles[i].dispose
- @tilemap2.autotiles[i].dispose
- @tilemap3.autotiles[i].dispose
- @tilemap4.autotiles[i].dispose
- end
- @tilemap.dispose
- @tilemap2.dispose
- @tilemap3.dispose
- @tilemap4.dispose
- @panorama.dispose #——释放远景平面
- @panorama2.dispose
- @panorama3.dispose
- @panorama4.dispose
- @fog.dispose #——释放雾平面
- @fog2.dispose
- @fog3.dispose
- @fog4.dispose
- for sprite in @character_sprites #——释放角色活动块
- sprite.dispose
- end
- @weather.dispose
- for sprite in @picture_sprites
- sprite.dispose
- end
- # 释放计时器块
- @timer_sprite.dispose
- # 释放显示端口
- $viewport1.dispose
- @viewport2.dispose
- @viewport3.dispose
- $viewport4.dispose
- $viewport5.dispose
- $viewport6.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 远景与现在的情况有差异发情况下
- if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue
- @panorama_name = $game_map.panorama_name
- @panorama_hue = $game_map.panorama_hue
- if @panorama.bitmap != nil
- @panorama.bitmap.dispose
- @panorama.bitmap = nil
- @panorama2.bitmap.dispose
- @panorama2.bitmap = nil
- @panorama3.bitmap.dispose
- @panorama3.bitmap = nil
- @panorama4.bitmap.dispose
- @panorama4.bitmap = nil
- end
- if @panorama_name != ""
- @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
- @panorama2.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
- @panorama3.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
- @panorama4.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
- end
- Graphics.frame_reset
- end
- # 雾与现在的情况有差异的情况下
- if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
- @fog_name = $game_map.fog_name
- @fog_hue = $game_map.fog_hue
- if @fog.bitmap != nil
- @fog.bitmap.dispose
- @fog.bitmap = nil
- @fog2.bitmap.dispose
- @fog2.bitmap = nil
- @fog3.bitmap.dispose
- @fog3.bitmap = nil
- @fog4.bitmap.dispose
- @fog4.bitmap = nil
- end
- if @fog_name != ""
- @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
- @fog2.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
- @fog3.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
- @fog4.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
- end
- Graphics.frame_reset
- end
- # 刷新元件地图
- @tilemap.ox = $game_map.display_x / 4
- @tilemap.oy = $game_map.display_y / 4
- @tilemap.update
- @tilemap2.ox = @tilemap.ox
- @tilemap2.oy = @tilemap.oy
- @tilemap2.update
- @tilemap3.ox = @tilemap.ox
- @tilemap3.oy = @tilemap.oy + 480
- @tilemap3.update
- @tilemap4.ox = @tilemap.ox
- @tilemap4.oy = @tilemap.oy + 480
- @tilemap4.update
- # 刷新远景平面
- @panorama.ox = $game_map.display_x / 8
- @panorama.oy = $game_map.display_y / 8
- @panorama2.ox = @panorama.ox
- @panorama2.oy = @panorama.oy
- @panorama3.ox = @panorama.ox
- @panorama3.oy = @panorama.oy + 480
- @panorama4.ox = @panorama.ox
- @panorama4.oy = @panorama.oy + 480
- # 刷新雾平面
- @[email protected][email protected][email protected]_x = $game_map.fog_zoom / 100.0
- @[email protected][email protected][email protected]_y = $game_map.fog_zoom / 100.0
- @[email protected][email protected][email protected] = $game_map.fog_opacity
- @[email protected][email protected][email protected]_type = $game_map.fog_blend_type
- @fog4.tone = @fog3.tone = @fog2.tone = @fog.tone = $game_map.fog_tone
- @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
- @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
- @fog2.ox = @fog.ox #+ 140#*@fog.zoom_x
- @fog2.oy = @fog.oy
- @fog3.ox = @fog.ox
- @fog3.oy = @fog.oy + 480
- @fog4.ox = @fog.ox
- @fog4.oy = @fog.oy + 480
- # 刷新角色活动块
- for sprite in @character_sprites
- sprite.update
- end
- # 刷新天候图形
- @weather.type = $game_screen.weather_type
- @weather.max = $game_screen.weather_max
- @weather.ox = $game_map.display_x / 4
- @weather.oy = $game_map.display_y / 4
- @weather.update
- # 刷新图片
- for sprite in @picture_sprites
- sprite.update
- end
- # 刷新计时器块
- @timer_sprite.update
- # 设置画面的色调与震动位置
- $viewport1.tone = $game_screen.tone
- $viewport1.ox = $game_screen.shake
- $viewport4.tone = $game_screen.tone
- $viewport4.ox = $game_screen.shake+640
- $viewport5.tone = $game_screen.tone
- $viewport5.ox = $game_screen.shake
- $viewport6.tone = $game_screen.tone
- $viewport6.ox = $game_screen.shake+640
- # 设置画面的闪烁色
- @viewport3.color = $game_screen.flash_color
- # 刷新显示端口
- $viewport1.update
- @viewport3.update
- $viewport4.update
- $viewport5.update
- $viewport6.update
- end
- end
- class Weather
- def initialize(viewport = nil)
- @type = 0
- @max = 0
- @ox = 0
- @oy = 0
- color1 = Color.new(255, 255, 255, 255)
- color2 = Color.new(255, 255, 255, 128)
- @rain_bitmap = Bitmap.new(7, 56)
- for i in 0..6
- @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1)
- end
- @storm_bitmap = Bitmap.new(34, 64)
- for i in 0..31
- @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2)
- @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1)
- @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2)
- end
- @snow_bitmap = Bitmap.new(6, 6)
- @snow_bitmap.fill_rect(0, 1, 6, 4, color2)
- @snow_bitmap.fill_rect(1, 0, 4, 6, color2)
- @snow_bitmap.fill_rect(1, 2, 4, 2, color1)
- @snow_bitmap.fill_rect(2, 1, 2, 4, color1)
- @sprites = []
- for i in 1..40
- sprite = Sprite.new(viewport)
- sprite.z = 1000
- sprite.visible = false
- sprite.opacity = 0
- @sprites.push(sprite)
- end
- end
- def dispose
- for sprite in @sprites
- sprite.dispose
- end
- @rain_bitmap.dispose
- @storm_bitmap.dispose
- @snow_bitmap.dispose
- end
- def type=(type)
- return if @type == type
- @type = type
- case @type
- when 1
- bitmap = @rain_bitmap
- when 2
- bitmap = @storm_bitmap
- when 3
- bitmap = @snow_bitmap
- else
- bitmap = nil
- end
- for i in 1..40
- sprite = @sprites[i]
- if sprite != nil
- sprite.visible = (i <= @max)
- sprite.bitmap = bitmap
- end
- end
- end
- def ox=(ox)
- return if @ox == ox;
- @ox = ox
- for sprite in @sprites
- sprite.ox = @ox
- end
- end
- def oy=(oy)
- return if @oy == oy;
- @oy = oy
- for sprite in @sprites
- sprite.oy = @oy
- end
- end
- def max=(max)
- return if @max == max;
- @max = [[max, 0].max, 40].min
- for i in 1..40
- sprite = @sprites[i]
- if sprite != nil
- sprite.visible = (i <= @max)
- end
- end
- end
- def update
- return if @type == 0
- for i in 1..@max
- sprite = @sprites[i]
- if sprite == nil
- break
- end
- if @type == 1
- sprite.x -= 2
- sprite.y += 16
- sprite.opacity -= 8
- end
- if @type == 2
- sprite.x -= 8
- sprite.y += 16
- sprite.opacity -= 12
- end
- if @type == 3
- sprite.x -= 2
- sprite.y += 8
- sprite.opacity -= 8
- end
- x = sprite.x - @ox
- y = sprite.y - @oy
- if sprite.opacity < 64 or x < -50 or x > $width+150 or y < -300 or y > $height+100
- sprite.x = rand($width+150) - 50 + @ox
- sprite.y = rand($height+100) - 200 + @oy
- sprite.opacity = 255
- end
- end
- end
- attr_reader :type
- attr_reader :max
- attr_reader :ox
- attr_reader :oy
- end
- #==============================================================================
- # ■ Game_Player
- #------------------------------------------------------------------------------
- # 处理主角的类。事件启动的判定、以及地图的滚动等功能。
- # 本类的实例请参考 $game_player。
- #==============================================================================
-
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 恒量
- #--------------------------------------------------------------------------
- CENTER_X = ($width/2 - 16) * 4
- CENTER_Y = ($height/2 - 16) * 4
- #--------------------------------------------------------------------------
- # ● 可以通行判定
- # x : X 坐标
- # y : Y 坐标
- # d : 方向 (0,2,4,6,8) ※ 0 = 全方向不能通行的情况判定 (跳跃用)
- #--------------------------------------------------------------------------
- def passable?(x, y, d)
- # 求得新的坐标
- new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
- new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
- # 坐标在地图外的情况下
- unless $game_map.valid?(new_x, new_y)
- # 不能通行
- return false
- end
- # 调试模式为 ON 并且 按下 CTRL 键的情况下
- if $DEBUG and Input.press?(Input::CTRL)
- # 可以通行
- return true
- end
- super
- end
- #--------------------------------------------------------------------------
- # ● 像通到画面中央一样的设置地图的显示位置
- #--------------------------------------------------------------------------
- def center(x, y)
- max_x = ($game_map.width - 20) * 128
- max_y = ($game_map.height - 15) * 128
- $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
- $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
- $game_map.scroll_down(0)
- $game_map.scroll_right(0)
- end
- #--------------------------------------------------------------------------
- # ● 向指定的位置移动
- # x : X 座標
- # y : Y 座標
- #--------------------------------------------------------------------------
- def moveto(x, y)
- super
- # 自连接
- center(x, y)
- # 生成遇敌计数
- make_encounter_count
- end
- #--------------------------------------------------------------------------
- # ● 增加步数
- #--------------------------------------------------------------------------
- def increase_steps
- super
- # 不是强制移动路线的场合
- unless @move_route_forcing
- # 增加步数
- $game_party.increase_steps
- # 步数是偶数的情况下
- if $game_party.steps % 2 == 0
- # 检查连续伤害
- $game_party.check_map_slip_damage
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取遇敌计数
- #--------------------------------------------------------------------------
- def encounter_count
- return @encounter_count
- end
- #--------------------------------------------------------------------------
- # ● 生成遇敌计数
- #--------------------------------------------------------------------------
- def make_encounter_count
- # 两种颜色震动的图像
- if $game_map.map_id != 0
- n = $game_map.encounter_step
- @encounter_count = rand(n) + rand(n) + 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- # 同伴人数为 0 的情况下
- if $game_party.actors.size == 0
- # 清除角色的文件名及对像
- @character_name = ""
- @character_hue = 0
- # 分支结束
- return
- end
- # 获取带头的角色
- actor = $game_party.actors[0]
- # 设置角色的文件名及对像
- @character_name = actor.character_name
- @character_hue = actor.character_hue
- # 初始化不透明度和合成方式子
- @opacity = 255
- @blend_type = 0
- end
- #--------------------------------------------------------------------------
- # ● 同位置的事件启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_here(triggers)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 全部事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == @x and event.y == @y and triggers.include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是同位置的事件
- if not event.jumping? and event.over_trigger?
- event.start
- result = true
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 正面事件的启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_there(triggers)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 计算正面坐标
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- # 全部事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == new_x and event.y == new_y and
- triggers.include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- # 找不到符合条件的事件的情况下
- if result == false
- # 正面的元件是计数器的情况下
- if $game_map.counter?(new_x, new_y)
- # 计算 1 元件里侧的坐标
- new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- # 全事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == new_x and event.y == new_y and
- triggers.include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 接触事件启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 全事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == x and event.y == y and [1,2].include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 画面更新
- #--------------------------------------------------------------------------
- def update
- # 本地变量记录移动信息
- last_moving = moving?
- # 移动中、事件执行中、强制移动路线中、
- # 信息窗口一个也不显示的时候
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing
- # 如果方向键被按下、主角就朝那个方向移动
- case Input.dir4
- when 2
- move_down
- when 4
- move_left
- when 6
- move_right
- when 8
- move_up
- end
- end
- # 本地变量记忆坐标
- last_real_x = @real_x
- last_real_y = @real_y
- super
- # 角色向下移动、画面上的位置在中央下方的情况下
- if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
- # 画面向下卷动
- $game_map.scroll_down(@real_y - last_real_y)
- end
- # 角色向左移动、画面上的位置在中央左方的情况下
- if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
- # 画面向左卷动
- $game_map.scroll_left(last_real_x - @real_x)
- end
- # 角色向右移动、画面上的位置在中央右方的情况下
- if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
- # 画面向右卷动
- $game_map.scroll_right(@real_x - last_real_x)
- end
- # 角色向上移动、画面上的位置在中央上方的情况下
- if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
- # 画面向上卷动
- $game_map.scroll_up(last_real_y - @real_y)
- end
- # 不在移动中的情况下
- unless moving?
- # 上次主角移动中的情况
- if last_moving
- # 与同位置的事件接触就判定为事件启动
- result = check_event_trigger_here([1,2])
- # 没有可以启动的事件的情况下
- if result == false
- # 调试模式为 ON 并且按下 CTRL 键的情况下除外
- unless $DEBUG and Input.press?(Input::CTRL)
- # 遇敌计数下降
- if @encounter_count > 0
- @encounter_count -= 1
- end
- end
- end
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 判定为同位置以及正面的事件启动
- check_event_trigger_here([0])
- check_event_trigger_there([0,1,2])
- end
- end
- end
- end
- #==============================================================================
- # ■ Scene_Gameover
- #------------------------------------------------------------------------------
- # 处理游戏结束画面的类。
- #==============================================================================
-
- class Scene_Gameover
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 生成游戏结束图形
- if $game_temp.in_battle
- @temp_sprite = Spriteset_Battle.new
- else
- @temp_sprite = Spriteset_Map.new
- end
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
- @sprite.opacity = 0
- # 停止 BGM、BGS
- $game_system.bgm_play(nil)
- $game_system.bgs_play(nil)
- # 演奏游戏结束 ME
- $game_system.me_play($data_system.gameover_me)
- # 执行过渡
- Graphics.transition(0)
- # 主循环
- for i in 0..120
- @sprite.opacity +=4
- Graphics.update
- end
- @temp_sprite.dispose
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面情报
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 释放游戏结束图形
- @sprite.bitmap.dispose
- @sprite.dispose
- # 执行过度
- Graphics.transition(0)
- # 准备过渡
- if $BTEST
- $scene = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- for i in 0..30
- @sprite.opacity -=10
- Graphics.update
- end
- # 切换到标题画面
- $scene = Scene_Title.new
- end
- end
- end
- #==============================================================================
- # ■ Scene_Title
- #------------------------------------------------------------------------------
- # 处理标题画面的类。
- #==============================================================================
-
- class Scene_Title
- #--------------------------------------------------------------------------
- # ● 住处理
- #--------------------------------------------------------------------------
- def main
- # 战斗测试的情况下
- if $BTEST
- battle_test
- return
- end
- # 载入数据库
- $data_actors = load_data("Data/Actors.rxdata")
- $data_classes = load_data("Data/Classes.rxdata")
- $data_skills = load_data("Data/Skills.rxdata")
- $data_items = load_data("Data/Items.rxdata")
- $data_weapons = load_data("Data/Weapons.rxdata")
- $data_armors = load_data("Data/Armors.rxdata")
- $data_enemies = load_data("Data/Enemies.rxdata")
- $data_troops = load_data("Data/Troops.rxdata")
- $data_states = load_data("Data/States.rxdata")
- $data_animations = load_data("Data/Animations.rxdata")
- $data_tilesets = load_data("Data/Tilesets.rxdata")
- $data_common_events = load_data("Data/CommonEvents.rxdata")
- $data_system = load_data("Data/System.rxdata")
- # 生成系统对像
- $game_system = Game_System.new
- # 生成标题图形
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.title($data_system.title_name)
- @sprite.opacity = 0
- # 生成命令窗口
- s1 = "新游戏"
- s2 = "继续"
- s3 = "退出"
- @command_window = Window_Command.new(192, [s1, s2, s3])
- @command_window.back_opacity = 160
- @command_window.x = $width /2 - @command_window.width / 2
- @command_window.y = $height /2 +132
- # 判定继续的有效性
- # 存档文件一个也不存在的时候也调查
- # 有効为 @continue_enabled 为 true、無効为 false
- @continue_enabled = false
- for i in 0..3
- if FileTest.exist?("Save#{i+1}.rxdata")
- @continue_enabled = true
- end
- end
- # 继续为有效的情况下、光标停止在继续上
- # 无效的情况下、继续的文字显示为灰色
- if @continue_enabled
- @command_window.index = 1
- else
- @command_window.disable_item(1)
- end
- # 演奏标题 BGM
- $game_system.bgm_play($data_system.title_bgm)
- # 停止演奏 ME、BGS
- Audio.me_stop
- Audio.bgs_stop
- # 执行过渡
- Graphics.transition(0)
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换就中断循环
- if $scene != self
- break
- end
- end
- # 装备过渡
- Graphics.freeze
- # 释放命令窗口
- @command_window.dispose
- # 释放标题图形
- @sprite.bitmap.dispose
- @sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- if @sprite.opacity < 255
- @sprite.opacity += 15
- end
- # 刷新命令窗口
- @command_window.update
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 命令窗口的光标位置的分支
- case @command_window.index
- when 0 # 新游戏
- command_new_game
- when 1 # 继续
- command_continue
- when 2 # 退出
- command_shutdown
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 命令 : 新游戏
- #--------------------------------------------------------------------------
- def command_new_game
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 停止 BGM
- Audio.bgm_stop
- # 重置测量游戏时间用的画面计数器
- Graphics.frame_count = 0
- # 生成各种游戏对像
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_screen = Game_Screen.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- # 设置初期同伴位置
- $game_party.setup_starting_members
- # 设置初期位置的地图
- $game_map.setup($data_system.start_map_id)
- # 主角向初期位置移动
- $game_player.moveto($data_system.start_x, $data_system.start_y)
- # 刷新主角
- $game_player.refresh
- # 执行地图设置的 BGM 与 BGS 的自动切换
- $game_map.autoplay
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 切换地图画面
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 命令 : 继续
- #--------------------------------------------------------------------------
- def command_continue
- # 继续无效的情况下
- unless @continue_enabled
- # 演奏无效 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到读档画面
- $scene = Scene_Load.new
- end
- #--------------------------------------------------------------------------
- # ● 命令 : 退出
- #--------------------------------------------------------------------------
- def command_shutdown
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # BGM、BGS、ME 的淡入淡出
- Audio.bgm_fade(800)
- Audio.bgs_fade(800)
- Audio.me_fade(800)
- # 退出
- tempBitmap = Sprite.new
- tempBitmap.bitmap = Bitmap.new($width,$height)
- tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
- tempBitmap.opacity = 0
- for i in 0..20
- tempBitmap.opacity+=14
- Graphics.update
- end
- $scene = nil
- end
- #--------------------------------------------------------------------------
- # ● 战斗测试
- #--------------------------------------------------------------------------
- def battle_test
- # 载入数据库 (战斗测试用)
- $data_actors = load_data("Data/BT_Actors.rxdata")
- $data_classes = load_data("Data/BT_Classes.rxdata")
- $data_skills = load_data("Data/BT_Skills.rxdata")
- $data_items = load_data("Data/BT_Items.rxdata")
- $data_weapons = load_data("Data/BT_Weapons.rxdata")
- $data_armors = load_data("Data/BT_Armors.rxdata")
- $data_enemies = load_data("Data/BT_Enemies.rxdata")
- $data_troops = load_data("Data/BT_Troops.rxdata")
- $data_states = load_data("Data/BT_States.rxdata")
- $data_animations = load_data("Data/BT_Animations.rxdata")
- $data_tilesets = load_data("Data/BT_Tilesets.rxdata")
- $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
- $data_system = load_data("Data/BT_System.rxdata")
- # 重置测量游戏时间用的画面计数器
- Graphics.frame_count = 0
- # 生成各种游戏对像
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_screen = Game_Screen.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- # 设置战斗测试用同伴
- $game_party.setup_battle_test_members
- # 设置队伍 ID、可以逃走标志、战斗背景
- $game_temp.battle_troop_id = $data_system.test_troop_id
- $game_temp.battle_can_escape = true
- $game_map.battleback_name = $data_system.battleback_name
- # 演奏战斗开始 BGM
- $game_system.se_play($data_system.battle_start_se)
- # 演奏战斗 BGM
- $game_system.bgm_play($game_system.battle_bgm)
- # 切换到战斗画面
- $scene = Scene_Battle.new
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 处理地图画面的类。
- #==============================================================================
-
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 生成活动块
- @spriteset = Spriteset_Map.new
- # 生成信息窗口
- @message_window = Window_Message.new
- tempBitmap = Sprite.new
- tempBitmap.bitmap = Bitmap.new($width,$height)
- tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
- # 执行过渡
- Graphics.transition(0)
- for i in 0..10
- tempBitmap.opacity-=25
- Graphics.update
- end
- tempBitmap.bitmap.dispose
- tempBitmap.dispose
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 标题画面切换中的情况下
- if $scene.is_a?(Scene_Title)
- @message_window.dispose
- tempBitmap = Sprite.new
- tempBitmap.bitmap = Bitmap.new($width,$height)
- tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
- tempBitmap.opacity = 0
- for i in 0..25
- tempBitmap.opacity +=11
- Graphics.update
- end
- tempBitmap.bitmap.dispose
- tempBitmap.dispose
- Graphics.transition(0)
- @spriteset.dispose
- else
- @message_window.dispose
- @spriteset.dispose
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 循环
- loop do
- # 按照地图、实例、主角的顺序刷新
- # (本更新顺序不会在的满足事件的执行条件下成为给予角色瞬间移动
- # 的机会的重要因素)
- $game_map.update
- $game_system.map_interpreter.update
- $game_player.update
- # 系统 (计时器)、画面刷新
- $game_system.update
- $game_screen.update
- # 如果主角在场所移动中就中断循环
- unless $game_temp.player_transferring
- break
- end
- # 执行场所移动
- transfer_player
- # 处理过渡中的情况下、中断循环
- if $game_temp.transition_processing
- break
- end
- end
- # 刷新活动块
- @spriteset.update
- # 刷新信息窗口
- @message_window.update
- # 游戏结束的情况下
- if $game_temp.gameover
- # 切换的游戏结束画面
- $scene = Scene_Gameover.new
- return
- end
- # 返回标题画面的情况下
- if $game_temp.to_title
- # 切换到标题画面
- $scene = Scene_Title.new
- return
- end
- # 处理过渡中的情况下
- if $game_temp.transition_processing
- # 清除过渡处理中标志
- $game_temp.transition_processing = false
- # 执行过渡
- Graphics.transition(0)
- end
- # 显示信息窗口中的情况下
- if $game_temp.message_window_showing
- return
- end
- # 遇敌计数为 0 且、且遇敌列表不为空的情况下
- if $game_player.encounter_count == 0 and $game_map.encounter_list != []
- # 不是在事件执行中或者禁止遇敌中
- unless $game_system.map_interpreter.running? or
- $game_system.encounter_disabled
- # 确定队伍
- n = rand($game_map.encounter_list.size)
- troop_id = $game_map.encounter_list[n]
- # 队伍有效的话
- if $data_troops[troop_id] != nil
- # 设置调用战斗标志
- $game_temp.battle_calling = true
- $game_temp.battle_troop_id = troop_id
- $game_temp.battle_can_escape = true
- $game_temp.battle_can_lose = false
- $game_temp.battle_proc = nil
- end
- end
- end
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 不是在事件执行中或菜单禁止中
- unless $game_system.map_interpreter.running? or
- $game_system.menu_disabled
- # 设置菜单调用标志以及 SE 演奏
- $game_temp.menu_calling = true
- $game_temp.menu_beep = true
- end
- end
- # 调试模式为 ON 并且按下 F9 键的情况下
- if $DEBUG and Input.press?(Input::F9)
- # 设置调用调试标志
- $game_temp.debug_calling = true
- end
- # 不在主角移动中的情况下
- unless $game_player.moving?
- # 执行各种画面的调用
- if $game_temp.battle_calling
- call_battle
- elsif $game_temp.shop_calling
- call_shop
- elsif $game_temp.name_calling
- call_name
- elsif $game_temp.menu_calling
- call_menu
- elsif $game_temp.save_calling
- call_save
- elsif $game_temp.debug_calling
- call_debug
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 调用战斗
- #--------------------------------------------------------------------------
- def call_battle
- # 清除战斗调用标志
- $game_temp.battle_calling = false
- # 清除菜单调用标志
- $game_temp.menu_calling = false
- $game_temp.menu_beep = false
- # 生成遇敌计数
- $game_player.make_encounter_count
- # 记忆地图 BGM 、停止 BGM
- $game_temp.map_bgm = $game_system.playing_bgm
- $game_system.bgm_stop
- # 演奏战斗开始 SE
- $game_system.se_play($data_system.battle_start_se)
- # 演奏战斗 BGM
- $game_system.bgm_play($game_system.battle_bgm)
- # 矫正主角姿势
- $game_player.straighten
- # 切换到战斗画面
- $scene = Scene_Battle.new
- end
- #--------------------------------------------------------------------------
- # ● 调用商店
- #--------------------------------------------------------------------------
- def call_shop
- # 清除商店调用标志
- $game_temp.shop_calling = false
- # 矫正主角姿势
- $game_player.straighten
- # 切换到商店画面
- $scene = Scene_Shop.new
- end
- #--------------------------------------------------------------------------
- # ● 调用名称输入
- #--------------------------------------------------------------------------
- def call_name
- # 清除商店调用名称输入标志
- $game_temp.name_calling = false
- # 矫正主角姿势
- $game_player.straighten
- # 切换到名称输入画面
- $scene = Scene_Name.new
- end
- #--------------------------------------------------------------------------
- # ● 调用菜单
- #--------------------------------------------------------------------------
- def call_menu
- # 清除商店调用菜单标志
- $game_temp.menu_calling = false
- # 已经设置了菜单 SE 演奏标志的情况下
- if $game_temp.menu_beep
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 清除菜单演奏 SE 标志
- $game_temp.menu_beep = false
- end
- # 矫正主角姿势
- $game_player.straighten
- # 切换到菜单画面
- $scene = Scene_Menu.new
- end
- #--------------------------------------------------------------------------
- # ● 调用存档
- #--------------------------------------------------------------------------
- def call_save
- # 矫正主角姿势
- $game_player.straighten
- # 切换到存档画面
- $scene = Scene_Save.new
- end
- #--------------------------------------------------------------------------
- # ● 调用调试
- #--------------------------------------------------------------------------
- def call_debug
- # 清除商店调用调试标志
- $game_temp.debug_calling = false
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 矫正主角姿势
- $game_player.straighten
- # 切换到调试画面
- $scene = Scene_Debug.new
- end
- #--------------------------------------------------------------------------
- # ● 主角的场所移动
- #--------------------------------------------------------------------------
- def transfer_player
- # 清除主角场所移动调试标志
- $game_temp.player_transferring = false
- # 移动目标与现在的地图有差异的情况下
- if $game_map.map_id != $game_temp.player_new_map_id
- # 设置新地图
- $game_map.setup($game_temp.player_new_map_id)
- end
- # 设置主角位置
- $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
- # 设置主角朝向
- case $game_temp.player_new_direction
- when 2 # 下
- $game_player.turn_down
- when 4 # 左
- $game_player.turn_left
- when 6 # 右
- $game_player.turn_right
- when 8 # 上
- $game_player.turn_up
- end
- # 矫正主角姿势
- $game_player.straighten
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 在生成活动块
- @spriteset.dispose
- @spriteset = Spriteset_Map.new
- # 处理过渡中的情况下
- if $game_temp.transition_processing
- # 清除过渡处理中标志
- $game_temp.transition_processing = false
- # 执行过渡
- $_t_Bitmap=Sprite.new
- $_t_Bitmap.bitmap = Bitmap.new($width,$height)
- $_t_Bitmap.bitmap.fill_rect(0,0,$width,$height,Color.new(0,0,0,255))
- Graphics.transition(0)
- for i in 0..10
- $_t_Bitmap.opacity-=26
- Graphics.update
- end
- $_t_Bitmap.bitmap.dispose
- $_t_Bitmap.dispose
- end
- # 执行地图设置的 BGM、BGS 的自动切换
- $game_map.autoplay
- # 设置画面
- Graphics.frame_reset
- # 刷新输入信息
- Input.update
- end
- end
- #==============================================================================
- # ■ Interpreter (分割定义 5)
- #------------------------------------------------------------------------------
- # 执行事件命令的注释器。本类在 Game_System 类
- # 和 Game_Event 类的内部使用。
- #==============================================================================
-
- class Interpreter
- #--------------------------------------------------------------------------
- # ● 场所移动
- #--------------------------------------------------------------------------
- def command_201
- # 战斗中的情况
- if $game_temp.in_battle
- # 继续
- return true
- end
- # 场所移动中、信息显示中、过渡处理中的情况下
- if $game_temp.player_transferring or
- $game_temp.message_window_showing or
- $game_temp.transition_processing
- # 结束
- return false
- end
- # 设置场所移动标志
- $game_temp.player_transferring = true
- # 指定方法为 [直接指定] 的情况下
- if @parameters[0] == 0
- # 设置主角的移动目标
- $game_temp.player_new_map_id = @parameters[1]
- $game_temp.player_new_x = @parameters[2]
- $game_temp.player_new_y = @parameters[3]
- $game_temp.player_new_direction = @parameters[4]
- # 指定方法为 [使用变量指定] 的情况下
- else
- # 设置主角的移动目标
- $game_temp.player_new_map_id = $game_variables[@parameters[1]]
- $game_temp.player_new_x = $game_variables[@parameters[2]]
- $game_temp.player_new_y = $game_variables[@parameters[3]]
- $game_temp.player_new_direction = @parameters[4]
- end
- # 推进索引
- @index += 1
- # 有淡入淡出的情况下
- if @parameters[5] == 0
- # 准备过渡
- tempBitmap = Sprite.new
- tempBitmap.bitmap = Bitmap.new($width,$height)
- tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
- tempBitmap.opacity = 0
- for i in 0..10
- tempBitmap.opacity+=26
- Graphics.update
- end
- Graphics.freeze
- tempBitmap.bitmap.dispose
- tempBitmap.dispose
- # 设置过渡处理中标志
- $game_temp.transition_processing = true
- $game_temp.transition_name = ""
- end
- # 结束
- return false
- end
- #--------------------------------------------------------------------------
- # ● 设置事件位置
- #--------------------------------------------------------------------------
- def command_202
- # 战斗中的情况下
- if $game_temp.in_battle
- # 继续
- return true
- end
- # 获取角色
- character = get_character(@parameters[0])
- # 角色不存在的情况下
- if character == nil
- # 继续
- return true
- end
- # 指定方法为 [直接指定] 的情况下
- if @parameters[1] == 0
- # 设置角色的位置
- character.moveto(@parameters[2], @parameters[3])
- # 指定方法为 [使用变量指定] 的情况下
- elsif @parameters[1] == 1
- # 设置角色的位置
- character.moveto($game_variables[@parameters[2]],
- $game_variables[@parameters[3]])
- # 指定方法为 [与其它事件交换] 的情况下
- else
- old_x = character.x
- old_y = character.y
- character2 = get_character(@parameters[2])
- if character2 != nil
- character.moveto(character2.x, character2.y)
- character2.moveto(old_x, old_y)
- end
- end
- # 设置觉得的朝向
- case @parameters[4]
- when 8 # 上
- character.turn_up
- when 6 # 右
- character.turn_right
- when 2 # 下
- character.turn_down
- when 4 # 左
- character.turn_left
- end
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 地图的滚动
- #--------------------------------------------------------------------------
- def command_203
- # 战斗中的情况下
- if $game_temp.in_battle
- # 继续
- return true
- end
- # 已经在滚动中的情况下
- if $game_map.scrolling?
- # 结束
- return false
- end
- # 开始滚动
- $game_map.start_scroll(@parameters[0], @parameters[1], @parameters[2])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 更改地图设置
- #--------------------------------------------------------------------------
- def command_204
- case @parameters[0]
- when 0 # 远景
- $game_map.panorama_name = @parameters[1]
- $game_map.panorama_hue = @parameters[2]
- when 1 # 雾
- $game_map.fog_name = @parameters[1]
- $game_map.fog_hue = @parameters[2]
- $game_map.fog_opacity = @parameters[3]
- $game_map.fog_blend_type = @parameters[4]
- $game_map.fog_zoom = @parameters[5]
- $game_map.fog_sx = @parameters[6]
- $game_map.fog_sy = @parameters[7]
- when 2 # 战斗背景
- $game_map.battleback_name = @parameters[1]
- $game_temp.battleback_name = @parameters[1]
- end
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 更改雾的色调
- #--------------------------------------------------------------------------
- def command_205
- # 开始更改色调
- $game_map.start_fog_tone_change(@parameters[0], @parameters[1] * 2)
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 更改雾的不透明度
- #--------------------------------------------------------------------------
- def command_206
- # 开始更改不透明度
- $game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * 2)
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 显示动画
- #--------------------------------------------------------------------------
- def command_207
- # 获取角色
- character = get_character(@parameters[0])
- # 角色不存在的情况下
- if character == nil
- # 继续
- return true
- end
- # 设置动画 ID
- character.animation_id = @parameters[1]
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 更改透明状态
- #--------------------------------------------------------------------------
- def command_208
- # 设置主角的透明状态
- $game_player.transparent = (@parameters[0] == 0)
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 设置移动路线
- #--------------------------------------------------------------------------
- def command_209
- # 获取角色
- character = get_character(@parameters[0])
- # 角色不存在的情况下
- if character == nil
- # 继续
- return true
- end
- # 强制移动路线
- character.force_move_route(@parameters[1])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 移动结束后等待
- #--------------------------------------------------------------------------
- def command_210
- # 如果不在战斗中
- unless $game_temp.in_battle
- # 设置移动结束后待机标志
- @move_route_waiting = true
- end
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 开始过渡
- #--------------------------------------------------------------------------
- def command_221
- # 显示信息窗口中的情况下
- if $game_temp.message_window_showing
- # 结束
- return false
- end
- # 准备过渡
- Graphics.freeze
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 执行过渡
- #--------------------------------------------------------------------------
- def command_222
- # 已经设置了过渡处理中标志的情况下
- if $game_temp.transition_processing
- # 结束
- return false
- end
- # 设置过渡处理中标志
- $game_temp.transition_processing = true
- $game_temp.transition_name = @parameters[0]
- # 推进索引
- @index += 1
- # 结束
- return false
- end
- #--------------------------------------------------------------------------
- # ● 更改画面色调
- #--------------------------------------------------------------------------
- def command_223
- # 开始更改色调
- $game_screen.start_tone_change(@parameters[0], @parameters[1] * 2)
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 画面闪烁
- #--------------------------------------------------------------------------
- def command_224
- # 开始闪烁
- $game_screen.start_flash(@parameters[0], @parameters[1] * 2)
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 画面震动
- #--------------------------------------------------------------------------
- def command_225
- # 震动开始
- $game_screen.start_shake(@parameters[0], @parameters[1],
- @parameters[2] * 2)
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 显示图片
- #--------------------------------------------------------------------------
- def command_231
- # 获取图片编号
- number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
- # 指定方法为 [直接指定] 的情况下
- if @parameters[3] == 0
- x = @parameters[4]
- y = @parameters[5]
- # 指定方法为 [使用变量指定] 的情况下
- else
- x = $game_variables[@parameters[4]]
- y = $game_variables[@parameters[5]]
- end
- # 显示图片
- $game_screen.pictures[number].show(@parameters[1], @parameters[2],
- x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 移动图片
- #--------------------------------------------------------------------------
- def command_232
- # 获取图片编号
- number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
- # 指定方法为 [直接指定] 的情况下
- if @parameters[3] == 0
- x = @parameters[4]
- y = @parameters[5]
- # 指定方法为 [使用变量指定] 的情况下
- else
- x = $game_variables[@parameters[4]]
- y = $game_variables[@parameters[5]]
- end
- # 移动图片
- $game_screen.pictures[number].move(@parameters[1] * 2, @parameters[2],
- x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 旋转图片
- #--------------------------------------------------------------------------
- def command_233
- # 获取图片编号
- number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
- # 设置旋转速度
- $game_screen.pictures[number].rotate(@parameters[1])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 更改图片色调
- #--------------------------------------------------------------------------
- def command_234
- # 获取图片编号
- number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
- # 开始更改色调
- $game_screen.pictures[number].start_tone_change(@parameters[1],
- @parameters[2] * 2)
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 删除图片
- #--------------------------------------------------------------------------
- def command_235
- # 获取图片编号
- number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
- # 删除图片
- $game_screen.pictures[number].erase
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 天候设置
- #--------------------------------------------------------------------------
- def command_236
- # 设置天候
- $game_screen.weather(@parameters[0], @parameters[1], @parameters[2])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 演奏 BGM
- #--------------------------------------------------------------------------
- def command_241
- # 演奏 BGM
- $game_system.bgm_play(@parameters[0])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● BGM 的淡入淡出
- #--------------------------------------------------------------------------
- def command_242
- # 淡入淡出 BGM
- $game_system.bgm_fade(@parameters[0])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 演奏 BGS
- #--------------------------------------------------------------------------
- def command_245
- # 演奏 BGS
- $game_system.bgs_play(@parameters[0])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● BGS 的淡入淡出
- #--------------------------------------------------------------------------
- def command_246
- # 淡入淡出 BGS
- $game_system.bgs_fade(@parameters[0])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 记忆 BGM / BGS
- #--------------------------------------------------------------------------
- def command_247
- # 记忆 BGM / BGS
- $game_system.bgm_memorize
- $game_system.bgs_memorize
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 还原 BGM / BGS
- #--------------------------------------------------------------------------
- def command_248
- # 还原 BGM / BGS
- $game_system.bgm_restore
- $game_system.bgs_restore
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 演奏 ME
- #--------------------------------------------------------------------------
- def command_249
- # 演奏 ME
- $game_system.me_play(@parameters[0])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 演奏 SE
- #--------------------------------------------------------------------------
- def command_250
- # 演奏 SE
- $game_system.se_play(@parameters[0])
- # 继续
- return true
- end
- #--------------------------------------------------------------------------
- # ● 停止 SE
- #--------------------------------------------------------------------------
- def command_251
- # 停止 SE
- Audio.se_stop
- # 继续
- return true
- end
- end
- #==============================================================================
- # ■ Game_Enemy
- #------------------------------------------------------------------------------
- # 处理敌人的类。本类在 Game_Troop 类 ($game_troop) 的
- # 内部使用。
- #==============================================================================
-
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # troop_id : 循环 ID
- # member_index : 循环成员的索引
- #--------------------------------------------------------------------------
- def initialize(troop_id, member_index)
- super()
- @troop_id = troop_id
- @member_index = member_index
- troop = $data_troops[@troop_id]
- @enemy_id = troop.members[@member_index].enemy_id
- enemy = $data_enemies[@enemy_id]
- @battler_name = enemy.battler_name
- @battler_hue = enemy.battler_hue
- @hp = maxhp
- @sp = maxsp
- @hidden = troop.members[@member_index].hidden
- @immortal = troop.members[@member_index].immortal
- end
- #--------------------------------------------------------------------------
- # ● 获取敌人 ID
- #--------------------------------------------------------------------------
- def id
- return @enemy_id
- end
- #--------------------------------------------------------------------------
- # ● 获取索引
- #--------------------------------------------------------------------------
- def index
- return @member_index
- end
- #--------------------------------------------------------------------------
- # ● 获取名称
- #--------------------------------------------------------------------------
- def name
- return $data_enemies[@enemy_id].name
- end
- #--------------------------------------------------------------------------
- # ● 获取基本 MaxHP
- #--------------------------------------------------------------------------
- def base_maxhp
- return $data_enemies[@enemy_id].maxhp
- end
- #--------------------------------------------------------------------------
- # ● 获取基本 MaxSP
- #--------------------------------------------------------------------------
- def base_maxsp
- return $data_enemies[@enemy_id].maxsp
- end
- #--------------------------------------------------------------------------
- # ● 获取基本力量
- #--------------------------------------------------------------------------
- def base_str
- return $data_enemies[@enemy_id].str
- end
- #--------------------------------------------------------------------------
- # ● 获取基本灵巧
- #--------------------------------------------------------------------------
- def base_dex
- return $data_enemies[@enemy_id].dex
- end
- #--------------------------------------------------------------------------
- # ● 获取基本速度
- #--------------------------------------------------------------------------
- def base_agi
- return $data_enemies[@enemy_id].agi
- end
- #--------------------------------------------------------------------------
- # ● 获取基本魔力
- #--------------------------------------------------------------------------
- def base_int
- return $data_enemies[@enemy_id].int
- end
- #--------------------------------------------------------------------------
- # ● 获取基本攻击力
- #--------------------------------------------------------------------------
- def base_atk
- return $data_enemies[@enemy_id].atk
- end
- #--------------------------------------------------------------------------
- # ● 获取基本物理防御
- #--------------------------------------------------------------------------
- def base_pdef
- return $data_enemies[@enemy_id].pdef
- end
- #--------------------------------------------------------------------------
- # ● 获取基本魔法防御
- #--------------------------------------------------------------------------
- def base_mdef
- return $data_enemies[@enemy_id].mdef
- end
- #--------------------------------------------------------------------------
- # ● 获取基本回避修正
- #--------------------------------------------------------------------------
- def base_eva
- return $data_enemies[@enemy_id].eva
- end
- #--------------------------------------------------------------------------
- # ● 普通攻击 获取攻击方动画 ID
- #--------------------------------------------------------------------------
- def animation1_id
- return $data_enemies[@enemy_id].animation1_id
- end
- #--------------------------------------------------------------------------
- # ● 普通攻击 获取对像方动画 ID
- #--------------------------------------------------------------------------
- def animation2_id
- return $data_enemies[@enemy_id].animation2_id
- end
- #--------------------------------------------------------------------------
- # ● 获取属性修正值
- # element_id : 属性 ID
- #--------------------------------------------------------------------------
- def element_rate(element_id)
- # 获取对应属性有效度的数值
- table = [0,200,150,100,50,0,-100]
- result = table[$data_enemies[@enemy_id].element_ranks[element_id]]
- # 状态能防御本属性的情况下效果减半
- for i in @states
- if $data_states[i].guard_element_set.include?(element_id)
- result /= 2
- end
- end
- # 过程结束
- return result
- end
- #--------------------------------------------------------------------------
- # ● 获取属性有效度
- #--------------------------------------------------------------------------
- def state_ranks
- return $data_enemies[@enemy_id].state_ranks
- end
- #--------------------------------------------------------------------------
- # ● 属性防御判定
- # state_id : 状态 ID
- #--------------------------------------------------------------------------
- def state_guard?(state_id)
- return false
- end
- #--------------------------------------------------------------------------
- # ● 获取普通攻击属性
- #--------------------------------------------------------------------------
- def element_set
- return []
- end
- #--------------------------------------------------------------------------
- # ● 获取普通攻击的状态变化 (+)
- #--------------------------------------------------------------------------
- def plus_state_set
- return []
- end
- #--------------------------------------------------------------------------
- # ● 获取普通攻击的状态变化 (-)
- #--------------------------------------------------------------------------
- def minus_state_set
- return []
- end
- #--------------------------------------------------------------------------
- # ● 获取行动
- #--------------------------------------------------------------------------
- def actions
- return $data_enemies[@enemy_id].actions
- end
- #--------------------------------------------------------------------------
- # ● 获取 EXP
- #--------------------------------------------------------------------------
- def exp
- return $data_enemies[@enemy_id].exp
- end
- #--------------------------------------------------------------------------
- # ● 获取金钱
- #--------------------------------------------------------------------------
- def gold
- return $data_enemies[@enemy_id].gold
- end
- #--------------------------------------------------------------------------
- # ● 获取物品 ID
- #--------------------------------------------------------------------------
- def item_id
- return $data_enemies[@enemy_id].item_id
- end
- #--------------------------------------------------------------------------
- # ● 获取武器 ID
- #--------------------------------------------------------------------------
- def weapon_id
- return $data_enemies[@enemy_id].weapon_id
- end
- #--------------------------------------------------------------------------
- # ● 获取放具 ID
- #--------------------------------------------------------------------------
- def armor_id
- return $data_enemies[@enemy_id].armor_id
- end
- #--------------------------------------------------------------------------
- # ● 获取宝物出现率
- #--------------------------------------------------------------------------
- def treasure_prob
- return $data_enemies[@enemy_id].treasure_prob
- end
- #--------------------------------------------------------------------------
- # ● 取得战斗画面 X 坐标
- #--------------------------------------------------------------------------
- def screen_x
- return $data_troops[@troop_id].members[@member_index].x*$width/640
- end
- #--------------------------------------------------------------------------
- # ● 取得战斗画面 Y 坐标
- #--------------------------------------------------------------------------
- def screen_y
- return $data_troops[@troop_id].members[@member_index].y*$height/480
- end
- #--------------------------------------------------------------------------
- # ● 取得战斗画面 Z 坐标
- #--------------------------------------------------------------------------
- def screen_z
- return screen_y
- end
- #--------------------------------------------------------------------------
- # ● 逃跑
- #--------------------------------------------------------------------------
- def escape
- # 设置击中标志
- @hidden = true
- # 清除当前行动
- self.current_action.clear
- end
- #--------------------------------------------------------------------------
- # ● 变身
- # enemy_id : 变身为的敌人 ID
- #--------------------------------------------------------------------------
- def transform(enemy_id)
- # 更改敌人 ID
- @enemy_id = enemy_id
- # 更改战斗图形
- @battler_name = $data_enemies[@enemy_id].battler_name
- @battler_hue = $data_enemies[@enemy_id].battler_hue
- # 在生成行动
- make_action
- end
- #--------------------------------------------------------------------------
- # ● 生成行动
- #--------------------------------------------------------------------------
- def make_action
- # 清除当前行动
- self.current_action.clear
- # 无法行动的情况
- unless self.movable?
- # 过程结束
- return
- end
- # 抽取现在有效的行动
- available_actions = []
- rating_max = 0
- for action in self.actions
- # 确认回合条件
- n = $game_temp.battle_turn
- a = action.condition_turn_a
- b = action.condition_turn_b
- if (b == 0 and n != a) or
- (b > 0 and (n < 1 or n < a or n % b != a % b))
- next
- end
- # 确认 HP 条件
- if self.hp * 100.0 / self.maxhp > action.condition_hp
- next
- end
- # 确认等级条件
- if $game_party.max_level < action.condition_level
- next
- end
- # 确认开关条件
- switch_id = action.condition_switch_id
- if switch_id > 0 and $game_switches[switch_id] == false
- next
- end
- # 符合条件 : 添加本行动
- available_actions.push(action)
- if action.rating > rating_max
- rating_max = action.rating
- end
- end
- # 最大概率值作为 3 合计计算(0 除外)
- ratings_total = 0
- for action in available_actions
- if action.rating > rating_max - 3
- ratings_total += action.rating - (rating_max - 3)
- end
- end
- # 概率合计不为 0 的情况下
- if ratings_total > 0
- # 生成随机数
- value = rand(ratings_total)
- # 设置对应生成随机数的当前行动
- for action in available_actions
- if action.rating > rating_max - 3
- if value < action.rating - (rating_max - 3)
- self.current_action.kind = action.kind
- self.current_action.basic = action.basic
- self.current_action.skill_id = action.skill_id
- self.current_action.decide_random_target_for_enemy
- return
- else
- value -= action.rating - (rating_max - 3)
- end
- end
- end
- end
- end
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 处理地图的类。包含卷动以及可以通行的判断功能。
- # 本类的实例请参考 $game_map 。
- #==============================================================================
-
- class Game_Map
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :tileset_name # 元件 文件名
- attr_accessor :autotile_names # 自动元件 文件名
- attr_accessor :panorama_name # 全景 文件名
- attr_accessor :panorama_hue # 全景 色相
- attr_accessor :fog_name # 雾 文件名
- attr_accessor :fog_hue # 雾 色相
- attr_accessor :fog_opacity # 雾 不透明度
- attr_accessor :fog_blend_type # 雾 混合方式
- attr_accessor :fog_zoom # 雾 放大率
- attr_accessor :fog_sx # 雾 SX
- attr_accessor :fog_sy # 雾 SY
- attr_accessor :battleback_name # 战斗背景 文件名
- attr_accessor :display_x # 显示 X 坐标 * 128
- attr_accessor :display_y # 显示 Y 坐标 * 128
- attr_accessor :need_refresh # 刷新要求标志
- attr_reader :passages # 通行表
- attr_reader :priorities # 优先表
- attr_reader :terrain_tags # 地形标记表
- attr_reader :events # 事件
- attr_reader :fog_ox # 雾 原点 X 坐标
- attr_reader :fog_oy # 雾 原点 Y 坐标
- attr_reader :fog_tone # 雾 色调
- #--------------------------------------------------------------------------
- # ● 初始化条件
- #--------------------------------------------------------------------------
- def initialize
- @map_id = 0
- @display_x = 0
- @display_y = 0
- end
- #--------------------------------------------------------------------------
- # ● 设置
- # map_id : 地图 ID
- #--------------------------------------------------------------------------
- def setup(map_id)
- # 地图 ID 记录到 @map_id
- @map_id = map_id
- # 地图文件装载后、设置到 @map
- @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
- # 定义实例变量设置地图元件信息
- tileset = $data_tilesets[@map.tileset_id]
- @tileset_name = tileset.tileset_name
- @autotile_names = tileset.autotile_names
- @panorama_name = tileset.panorama_name
- @panorama_hue = tileset.panorama_hue
- @fog_name = tileset.fog_name
- @fog_hue = tileset.fog_hue
- @fog_opacity = tileset.fog_opacity
- @fog_blend_type = tileset.fog_blend_type
- @fog_zoom = tileset.fog_zoom
- @fog_sx = tileset.fog_sx
- @fog_sy = tileset.fog_sy
- @battleback_name = tileset.battleback_name
- @passages = tileset.passages
- @priorities = tileset.priorities
- @terrain_tags = tileset.terrain_tags
- # 初始化显示坐标
- @display_x = 0
- @display_y = 0
- # 清除刷新要求标志
- @need_refresh = false
- # 设置地图事件数据
- @events = {}
- for i in @map.events.keys
- @events[i] = Game_Event.new(@map_id, @map.events[i])
- end
- # 设置公共事件数据
- @common_events = {}
- for i in 1...$data_common_events.size
- @common_events[i] = Game_CommonEvent.new(i)
- end
- # 初始化雾的各种信息
- @fog_ox = 0
- @fog_oy = 0
- @fog_tone = Tone.new(0, 0, 0, 0)
- @fog_tone_target = Tone.new(0, 0, 0, 0)
- @fog_tone_duration = 0
- @fog_opacity_duration = 0
- @fog_opacity_target = 0
- # 初始化滚动信息
- @scroll_direction = 2
- @scroll_rest = 0
- @scroll_speed = 4
- end
- #--------------------------------------------------------------------------
- # ● 获取地图 ID
- #--------------------------------------------------------------------------
- def map_id
- return @map_id
- end
- #--------------------------------------------------------------------------
- # ● 获取宽度
- #--------------------------------------------------------------------------
- def width
- return @map.width
- end
- #--------------------------------------------------------------------------
- # ● 获取高度
- #--------------------------------------------------------------------------
- def height
- return @map.height
- end
- #--------------------------------------------------------------------------
- # ● 获取遇敌列表
- #--------------------------------------------------------------------------
- def encounter_list
- return @map.encounter_list
- end
- #--------------------------------------------------------------------------
- # ● 获取遇敌步数
- #--------------------------------------------------------------------------
- def encounter_step
- return @map.encounter_step
- end
- #--------------------------------------------------------------------------
- # ● 获取地图数据
- #--------------------------------------------------------------------------
- def data
- return @map.data
- end
- #--------------------------------------------------------------------------
- # ● BGM / BGS 自动切换
- #--------------------------------------------------------------------------
- def autoplay
- if @map.autoplay_bgm
- $game_system.bgm_play(@map.bgm)
- end
- if @map.autoplay_bgs
- $game_system.bgs_play(@map.bgs)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- # 地图 ID 有效
- if @map_id > 0
- # 刷新全部的地图事件
- for event in @events.values
- event.refresh
- end
- # 刷新全部的公共事件
- for common_event in @common_events.values
- common_event.refresh
- end
- end
- # 清除刷新要求标志
- @need_refresh = false
- end
- #--------------------------------------------------------------------------
- # ● 滚动
- # distance : 滚动距离
- #--------------------------------------------------------------------------
- def scroll_down(distance)
- @display_y = [@display_y + distance, (self.height - ($height / 32.0)) * 128].min
- end
- #--------------------------------------------------------------------------
- def scroll_left(distance)
- @display_x = [@display_x - distance, 0].max
- end
- #--------------------------------------------------------------------------
- def scroll_right(distance)
- @display_x = [@display_x + distance, (self.width - ($width / 32.0)) * 128].min
- end
- #--------------------------------------------------------------------------
- def scroll_up(distance)
- @display_y = [@display_y - distance, 0].max
- end
- #--------------------------------------------------------------------------
- # ● 有效坐标判定
- # x : X 坐标
- # y : Y 坐标
- #--------------------------------------------------------------------------
- def valid?(x, y)
- return (x >= 0 and x < width and y >= 0 and y < height)
- end
- #--------------------------------------------------------------------------
- # ● 可以通行判定
- # x : X 坐标
- # y : Y 坐标
- # d : 方向 (0,2,4,6,8,10)
- # ※ 0,10 = 全方向不能通行的情况的判定 (跳跃等)
- # self_event : 自己 (判定事件可以通行的情况下)
- #--------------------------------------------------------------------------
- def passable?(x, y, d, self_event = nil)
- # 被给予的坐标地图外的情况下
- unless valid?(x, y)
- # 不能通行
- return false
- end
- # 方向 (0,2,4,6,8,10) 与障碍物接触 (0,1,2,4,8,0) 后变换
- bit = (1 << (d / 2 - 1)) & 0x0f
- # 循环全部的事件
- for event in events.values
- # 自己以外的元件与坐标相同的情况
- if event.tile_id >= 0 and event != self_event and
- event.x == x and event.y == y and not event.through
- # 如果障碍物的接触被设置的情况下
- if @passages[event.tile_id] & bit != 0
- # 不能通行
- return false
- # 如果全方向的障碍物的接触被设置的情况下
- elsif @passages[event.tile_id] & 0x0f == 0x0f
- # 不能通行
- return false
- # 这以外的优先度为 0 的情况下
- elsif @priorities[event.tile_id] == 0
- # 可以通行
- return true
- end
- end
- end
- # 从层按从上到下的顺序调查循环
- for i in [2, 1, 0]
- # 取得元件 ID
- tile_id = data[x, y, i]
- # 取得元件 ID 失败
- if tile_id == nil
- # 不能通行
- return false
- # 如果障碍物的接触被设置的情况下
- elsif @passages[tile_id] & bit != 0
- # 不能通行
- return false
- # 如果全方向的障碍物的接触被设置的情况下
- elsif @passages[tile_id] & 0x0f == 0x0f
- # 不能通行
- return false
- # 这以外的优先度为 0 的情况下
- elsif @priorities[tile_id] == 0
- # 可以通行
- return true
- end
- end
- # 可以通行
- return true
- end
- #--------------------------------------------------------------------------
- # ● 茂密判定
- # x : X 坐标
- # y : Y 坐标
- #--------------------------------------------------------------------------
- def bush?(x, y)
- if @map_id != 0
- for i in [2, 1, 0]
- tile_id = data[x, y, i]
- if tile_id == nil
- return false
- elsif @passages[tile_id] & 0x40 == 0x40
- return true
- end
- end
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● 反击判定
- # x : X 坐标
- # y : Y 坐标
- #--------------------------------------------------------------------------
- def counter?(x, y)
- if @map_id != 0
- for i in [2, 1, 0]
- tile_id = data[x, y, i]
- if tile_id == nil
- return false
- elsif @passages[tile_id] & 0x80 == 0x80
- return true
- end
- end
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● 地获取地形标志
- # x : X 坐标
- # y : Y 坐标
- #--------------------------------------------------------------------------
- def terrain_tag(x, y)
- if @map_id != 0
- for i in [2, 1, 0]
- tile_id = data[x, y, i]
- if tile_id == nil
- return 0
- elsif @terrain_tags[tile_id] > 0
- return @terrain_tags[tile_id]
- end
- end
- end
- return 0
- end
- #--------------------------------------------------------------------------
- # ● 获取指定位置的事件 ID
- # x : X 坐标
- # y : Y 坐标
- #--------------------------------------------------------------------------
- def check_event(x, y)
- for event in $game_map.events.values
- if event.x == x and event.y == y
- return event.id
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 滚动开始
- # direction : 滚动方向
- # distance : 滚动距离
- # speed : 滚动速度
- #--------------------------------------------------------------------------
- def start_scroll(direction, distance, speed)
- @scroll_direction = direction
- @scroll_rest = distance * 128
- @scroll_speed = speed
- end
- #--------------------------------------------------------------------------
- # ● 滚动中判定
- #--------------------------------------------------------------------------
- def scrolling?
- return @scroll_rest > 0
- end
- #--------------------------------------------------------------------------
- # ● 开始变更雾的色调
- # tone : 色调
- # duration : 时间
- #--------------------------------------------------------------------------
- def start_fog_tone_change(tone, duration)
- @fog_tone_target = tone.clone
- @fog_tone_duration = duration
- if @fog_tone_duration == 0
- @fog_tone = @fog_tone_target.clone
- end
- end
- #--------------------------------------------------------------------------
- # ● 开始变更雾的不透明度
- # opacity : 不透明度
- # duration : 时间
- #--------------------------------------------------------------------------
- def start_fog_opacity_change(opacity, duration)
- @fog_opacity_target = opacity * 1.0
- @fog_opacity_duration = duration
- if @fog_opacity_duration == 0
- @fog_opacity = @fog_opacity_target
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 还原必要的地图
- if $game_map.need_refresh
- refresh
- end
- # 滚动中的情况下
- if @scroll_rest > 0
- # 滚动速度变化为地图坐标系的距离
- distance = 2 ** @scroll_speed
- # 执行滚动
- case @scroll_direction
- when 2 # 下
- scroll_down(distance)
- when 4 # 左
- scroll_left(distance)
- when 6 # 右
- scroll_right(distance)
- when 8 # 上
- scroll_up(distance)
- end
- # 滚动距离的减法运算
- @scroll_rest -= distance
- end
- # 更新地图事件
- for event in @events.values
- event.update
- end
- # 更新公共事件
- for common_event in @common_events.values
- common_event.update
- end
- # 处理雾的滚动
- @fog_ox -= @fog_sx / 8.0
- @fog_oy -= @fog_sy / 8.0
- # 处理雾的色调变更
- if @fog_tone_duration >= 1
- d = @fog_tone_duration
- target = @fog_tone_target
- @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
- @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
- @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
- @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
- @fog_tone_duration -= 1
- end
- # 处理雾的不透明度变更
- if @fog_opacity_duration >= 1
- d = @fog_opacity_duration
- @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
- @fog_opacity_duration -= 1
- end
- end
- end
- #==============================================================================
- # ■ Sprite_Character
- #------------------------------------------------------------------------------
- # 角色显示用脚本。监视 Game_Character 类的实例、
- # 自动变化脚本状态。
- #==============================================================================
-
- class Sprite_Character < RPG::Sprite
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :character # 角色
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # viewport : 查看端口
- # character : 角色 (Game_Character)
- #--------------------------------------------------------------------------
- def initialize(viewport, character = nil)
- super(viewport)
- @vp = viewport
- @character = character
- update
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- # 元件 ID、文件名、色相与现在的情况存在差异的情况下
- if @tile_id != @character.tile_id or
- @character_name != @character.character_name or
- @character_hue != @character.character_hue
- # 记忆元件 ID 与文件名、色相
- @tile_id = @character.tile_id
- @character_name = @character.character_name
- @character_hue = @character.character_hue
- # 元件 ID 为有效值的情况下
- if @tile_id >= 384
- self.bitmap = RPG::Cache.tile($game_map.tileset_name,
- @tile_id, @character.character_hue)
- self.src_rect.set(0, 0, 32, 32)
- self.ox = 16
- self.oy = 32
- # 元件 ID 为无效值的情况下
- else
- self.bitmap = RPG::Cache.character(@character.character_name,
- @character.character_hue)
- @cw = bitmap.width / 4
- @ch = bitmap.height / 4
- self.ox = @cw / 2
- self.oy = @ch
- end
- end
- # 设置可视状态
- self.visible = (not @character.transparent)
- # 图形是角色的情况下
- if @tile_id == 0
- # 设置传送目标的矩形
- sx = @character.pattern * @cw
- sy = (@character.direction - 2) / 2 * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- end
- # 设置脚本的坐标
- self.x = @character.screen_x
- #if @character == $game_player
- if @vp == $viewport5 or @vp == $viewport6
- self.y = @character.screen_y-480
- self.z = @character.screen_z(@ch)-480
- else
- self.y = @character.screen_y
- self.z = @character.screen_z(@ch)
- end
- #else
- #self.y = @character.screen_y
- #self.z = @character.screen_z(@ch)
- #end
- # 设置不透明度、合成方式、茂密
- self.opacity = @character.opacity
- self.blend_type = @character.blend_type
- self.bush_depth = @character.bush_depth
- # 动画
- if @character.animation_id != 0
- animation = $data_animations[@character.animation_id]
- animation(animation, true)
- @character.animation_id = 0
- end
- end
- end
-
- class Weather
- def initialize(viewport = nil)
- @type = 0
- @max = 0
- @ox = 0
- @oy = 0
- color1 = Color.new(255, 255, 255, 255)
- color2 = Color.new(255, 255, 255, 128)
- @rain_bitmap = Bitmap.new(7, 56)
- for i in 0..6
- @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1)
- end
- @storm_bitmap = Bitmap.new(34, 64)
- for i in 0..31
- @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2)
- @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1)
- @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2)
- end
- @snow_bitmap = Bitmap.new(6, 6)
- @snow_bitmap.fill_rect(0, 1, 6, 4, color2)
- @snow_bitmap.fill_rect(1, 0, 4, 6, color2)
- @snow_bitmap.fill_rect(1, 2, 4, 2, color1)
- @snow_bitmap.fill_rect(2, 1, 2, 4, color1)
- @sprites = []
- for i in 1..40
- sprite = Sprite.new(viewport)
- sprite.z = 1000
- sprite.visible = false
- sprite.opacity = 0
- @sprites.push(sprite)
- end
- end
- def dispose
- for sprite in @sprites
- sprite.dispose
- end
- @rain_bitmap.dispose
- @storm_bitmap.dispose
- @snow_bitmap.dispose
- end
- def type=(type)
- return if @type == type
- @type = type
- case @type
- when 1
- bitmap = @rain_bitmap
- when 2
- bitmap = @storm_bitmap
- when 3
- bitmap = @snow_bitmap
- else
- bitmap = nil
- end
- for i in 1..40
- sprite = @sprites[i]
- if sprite != nil
- sprite.visible = (i <= @max)
- sprite.bitmap = bitmap
- end
- end
- end
- def ox=(ox)
- return if @ox == ox;
- @ox = ox
- for sprite in @sprites
- sprite.ox = @ox
- end
- end
- def oy=(oy)
- return if @oy == oy;
- @oy = oy
- for sprite in @sprites
- sprite.oy = @oy
- end
- end
- def max=(max)
- return if @max == max;
- @max = [[max, 0].max, 40].min
- for i in 1..40
- sprite = @sprites[i]
- if sprite != nil
- sprite.visible = (i <= @max)
- end
- end
- end
- def update
- return if @type == 0
- for i in 1..@max
- sprite = @sprites[i]
- if sprite == nil
- break
- end
- if @type == 1
- sprite.x -= 2
- sprite.y += 16
- sprite.opacity -= 8
- end
- if @type == 2
- sprite.x -= 8
- sprite.y += 16
- sprite.opacity -= 12
- end
- if @type == 3
- sprite.x -= 2
- sprite.y += 8
- sprite.opacity -= 8
- end
- x = sprite.x - @ox
- y = sprite.y - @oy
- if sprite.opacity < 64 or x < -50 or x > $width+150 or y < -300 or y > $height+100
- sprite.x = rand($width+150) - 50 + @ox
- sprite.y = rand($height+100) - 200 + @oy
- sprite.opacity = 255
- end
- end
- end
- attr_reader :type
- attr_reader :max
- attr_reader :ox
- attr_reader :oy
- end
复制代码 寻路算法- #==============================================================================
- # ■ Find_Path
- #------------------------------------------------------------------------------
- # 寻路算法--完整鼠标系统(四方向)专用版
- # By whbm
- #==============================================================================
- class Find_Path
- #--------------------------------------------------------------------------
- def initialize #初始化
- @open_list = []
- @close_lise = []
- @path = []
- end #结束初始化
- #--------------------------------------------------------------------------
- def fp_passable?(x, y, d, tr_x = -2, tr_y = -2) #开始判定通行
- return false if (tr_x == @unable_xa or
- tr_x == @unable_xb or
- tr_y == @unable_ya or
- tr_y == @unable_yb)
- if [2, 4, 6, 8].include?(d)
- if $game_player.passable?(x, y, d)
- return true
- else
- return false
- end
- end
- end #结束判定通行
- #--------------------------------------------------------------------------
- def get_g(now_point) #开始计算G值
- d = now_point[2]
- return 0 if d == 5
- father_point = get_father_point(now_point)
- g = father_point[3] + 10
- return g
- end #结束计算G值
- #--------------------------------------------------------------------------
- def get_h(now_point) #开始计算H值
- now_x = now_point[0]
- now_y = now_point[1]
- #print @trg_x,now_x,@trg_y,now_y
- h = (@trg_x - now_x).abs + (@trg_y - now_y).abs
- return h * 10
- end #结束计算H值
- #--------------------------------------------------------------------------
- def get_f(now_point) #开始计算F值
- f = now_point[3] + now_point[4]
- return f
- end #结束计算F值
- #--------------------------------------------------------------------------
- def get_point(x, y) #取已知坐标点
- if @open_list.size != 0
- @open_list.each do |point|
- if point[0] == x and point[1] == y
- return point
- break
- end
- end
- end
- if @close_list.size != 0
- @close_list.each do |point|
- if point[0] == x and point[1] == y
- return point
- break
- end
- end
- end
- end #结束取已知坐标点
- #--------------------------------------------------------------------------
- def get_father_point(now_point) #取已知点的父节点
- d = now_point[2]
- return now_point if d == 5
- x = now_point[0] + (d == 6 ? 1 : (d == 4 ? -1 : 0))
- y = now_point[1] + (d == 2 ? 1 : (d == 8 ? -1 : 0))
- return get_point(x, y)
- end #结束取已知点的父节点
- #--------------------------------------------------------------------------
- def new_point(x, y, d) #开始建立新节点
- #print x,y,d
- point = [x, y, d]
- point.push get_g(point)
- point.push get_h(point)
- point.push get_f(point)
- return point
- end #结束建立新节点
- #--------------------------------------------------------------------------
- def get_direction(self_x, self_y, trg_x, trg_y)
- if trg_x > self_x
- if trg_y - self_y > - ( trg_x - self_x ) and
- trg_y - self_y < ( trg_x - self_x )
- return 6
- end
- if trg_y - self_y > ( trg_x - self_x )
- return 2
- end
- if trg_y - self_y < - ( trg_x - self_x )
- return 8
- end
- end
- if trg_x < self_x
- if trg_y - self_y > - ( self_x - trg_x ) and
- trg_y - self_y < ( self_x - trg_x )
- return 4
- end
- if trg_y - self_y > ( self_x - trg_x )
- return 2
- end
- if trg_y - self_y < - ( self_x - trg_x )
- return 8
- end
- end
- end
- #--------------------------------------------------------------------------
- def get_d_x_y(x, y, d)
- d_x = x + (d == 6 ? 1 : (d == 4 ? -1 : 0))
- d_y = y + (d == 2 ? 1 : (d == 8 ? -1 : 0))
- return d_x, d_y
- end
- #--------------------------------------------------------------------------
- def find_short_path_other(self_x, self_y, trg_x, trg_y,
- real_self_x, real_self_y, real_trg_x, real_trg_y)
- @self_x = self_x
- @self_y = self_y
- @now_x = self_x
- @now_y = self_y
- @trg_x = trg_x
- @trg_y = trg_y
- @path = []
- direction = get_direction(real_self_x, real_self_y, real_trg_x, real_trg_y)
- @now_trg_x, @now_trg_y = get_d_x_y(@self_x, @self_y, direction)
- while fp_passable?(@now_x, @now_y, direction)
- @path.push direction
- @now_x = @now_trg_x
- @now_y = @now_trg_y
- @now_trg_x, @now_trg_y = get_d_x_y(@now_x, @now_y, direction)
- end
- return @path
- end
- #--------------------------------------------------------------------------
- def find_short_path(self_x, self_y, trg_x, trg_y,
- real_self_x, real_self_y, real_trg_x, real_trg_y) #开始搜索路径
-
- return find_short_path_other(self_x, self_y, trg_x, trg_y,
- real_self_x, real_self_y, real_trg_x, real_trg_y) if not
- (fp_passable?(trg_x, trg_y + 1, 8) or
- fp_passable?(trg_x + 1, trg_y, 4) or
- fp_passable?(trg_x - 1, trg_y, 6) or
- fp_passable?(trg_x, trg_y - 1, 2)) and @goal_type != 1
-
-
- #根据屏幕限定搜索面积..加速
- @unable_xa = $game_map.display_x / 128 - 1
- @unable_ya = $game_map.display_y / 128 - 1
- @unable_xb = $game_map.display_x / 128 + 20
- @unable_yb = $game_map.display_y / 128 + 20
-
-
- @self_x = self_x
- @self_y = self_y
- @now_x = self_x
- @now_y = self_y
- @trg_x = trg_x
- @trg_y = trg_y
- @open_list = []
- @close_list = []
- #准备搜索
- #print @self_x,@self_y
- @now_point = new_point(@self_x, @self_y, 5) #令起始点为当前点
- @open_list.push @now_point #将当前点加入关闭列表
- #开始搜索
- begin
- loop do
- check_trg = check_around_point(@now_point)
- if check_trg == true
- @path = get_path
- break
- end
- @now_point = get_lowest_f_point
- if @now_point == [] or @now_point == nil
- @path = []
- break
- end
- end
- rescue Hangup
- retry
- end
- return @path
- end #结束搜索路径
- #--------------------------------------------------------------------------
- def find_player_short_path(trg_x, trg_y,
- real_trg_x, real_trg_y) #寻找角色的最短路径
- self_x = $game_player.x
- self_y = $game_player.y
- real_self_x = $game_player.screen_x
- real_self_y = $game_player.screen_y
- @goal_type, event = $game_map.check_event_custom_exist(real_trg_x, real_trg_y)
- if @goal_type == 1
- trg_x = event.x
- trg_y = event.y
- end
- return find_short_path(self_x, self_y, trg_x, trg_y,
- real_self_x, real_self_y, real_trg_x, real_trg_y)
- end #结束角色的寻找路径
- #--------------------------------------------------------------------------
- def get_path #取得最终的路径
- path = []
- now_point = @open_list[@open_list.size - 1]
- path.push(10 - now_point[2])
- last_point = now_point
- loop do
- now_point = get_father_point(now_point)
- break if now_point[2] == 5
- path.push(10 - now_point[2])
- end
- return path.reverse
- end #结束取得最终的路径
- #--------------------------------------------------------------------------
- def get_lowest_f_point #开始取得最低F值的点
- if @open_list == []
- return []
- end
- last_lowest_f_point = @open_list[0]
- @open_list.each do |point|
- last_lowest_f_point = point if point[5] < last_lowest_f_point[5]
- end
- return last_lowest_f_point
- end #结束取得最低F值点
- #--------------------------------------------------------------------------
- def check_around_point(point) #开始检查已知点的八方节点
- for d in [1, 2, 3, 4, 6, 7, 8, 9]
- x = point[0] + ((d == 9 or d == 6 or d == 3) ? 1 : ((d == 7 or d == 4 or d == 1) ? -1 : 0))
- y = point[1] + ((d == 1 or d == 2 or d == 3) ? 1 : ((d == 7 or d == 8 or d == 9) ? -1 : 0))
- if in_close_list?(x, y) #在关闭列表中
- next
- elsif in_open_list?(x, y) #在开启列表中
- get_new_g_point = new_point(x, y, 10 - d)
- get_last_g_point = get_point(x, y)
- if get_new_g_point[3] >= get_last_g_point[3]
- next
- else
- #如果改变父节点是新G值更小则确定改变
- @open_list[@open_list.index(get_last_g_point)] = get_new_g_point
- end
- else
- if fp_passable?(point[0], point[1], d, x, y)
- # 如果不在开启列表中、且不在关闭列表中、且通行则添加它到新八周节点
- @open_list.push new_point(x, y, 10 - d)
- #如果将目标点添加到了开启列表中就返回true
- return true if x == @trg_x and y == @trg_y
- return true if @goal_type == 1 and [1, 0, -1].include?(x - @trg_x) and [1, 0, -1].include?(y - @trg_y)
- end
- end
- end
- #此刻没有找到目标点并将当前点加入关闭列表并在开启列表中删除
- @close_list.push point
- @open_list.delete(point)
- #此刻没找到目标点并返回false
- return false
- end #结束计算已知点的八方节点
- #--------------------------------------------------------------------------
- def in_open_list?(x, y) #开始检查谋点是否在开启列表中
- @open_list.each do |point|
- return true if point[0] == x and point[1] == y
- end
- return false
- end #结束检查谋点是否在开启列表中
- #--------------------------------------------------------------------------
- def in_close_list?(x, y) #开始检查谋点是否在关闭列表中
- @close_list.each do |point|
- return true if point[0] == x and point[1] == y
- end
- return false
- end #结束检查谋点是否在关闭列表中
- #--------------------------------------------------------------------------
- end
复制代码 鼠标脚本- #==============================================================================
- # ■ 完整鼠标系统(四方向)
- #------------------------------------------------------------------------------
- # 使用时务必配合专用寻路算法
- # By whbm
- #==============================================================================
- #下面做一下介绍与使用说明:
- # 在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
- #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
- #后果了吧)
- # 在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
- #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
- #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
- #点,那时在单击NPC即可。
- # 当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
- #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
- #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
- #那两个注释。
- # 当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
- #==============================================================================
- class Game_Event
- attr_accessor :flag
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 处理地图的类。包含卷动以及可以通行的判断功能。
- # 本类的实例请参考 $game_map 。
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ● 检查鼠标处是否有自定义的事件并返回类型
- #--------------------------------------------------------------------------
- def check_event_custom(mouse_x, mouse_y)
- for event in $game_map.events.values #循环所有事件检查
- event_width = RPG::Cache.character(event.character_name,event.character_hue).width / 4
- event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 4
- if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
- for i in 0...event.list.size
- if event.list[i].parameters[0] == "Item" #类型判断
- event.flag = 1
- elsif event.list[i].parameters[0] == "Npc" #类型判断
- event.flag = 2
- else
- event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
- end
- return event.flag #返回事件类型标志
- end
- end
- end
- return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
- return $mouse_icon_id #使鼠标图不变化
- end
- #--------------------------------------------------------------------------
- # ● 检查鼠标处是否有事件可以开启
- #--------------------------------------------------------------------------
- def check_event_custom_start(mouse_x, mouse_y)
- for event in $game_map.events.values #循环所有事件检查
- #事件角色图片宽度、高度
- event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
- event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
- #判断是否鼠标在事件上
- if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
- way_x = $game_player.x - event.x
- way_y = $game_player.y - event.y
- if ([1, -1].include?($game_player.x-event.x) and $game_player.y-event.y == 0) or ([1, -1].include?($game_player.y-event.y) and $game_player.x-event.x == 0)
- for i in 0...event.list.size
- if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
- #判断主角朝向
- if way_x == -1
- p_direction = 6 if way_y == 0
- elsif way_x == 0
- p_direction = 2 if way_y == -1
- p_direction = 8 if way_y == 1
- else
- p_direction = 4 if way_y == 0
- end
- event.start #开启事件
- return 1, p_direction #返回即将开启事件以及角色朝向
- end
- end
- end
- end
- end
- return 0, 5 #返回不会开启事件以及角色朝向不变
- end
- #--------------------------------------------------------------------------
- # ● 检查鼠标处是否存在自定义事件 for 寻路
- #--------------------------------------------------------------------------
- def check_event_custom_exist(mouse_x, mouse_y)
- for event in $game_map.events.values #循环所有事件检查
- #事件角色图片宽度、高度
- event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
- event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
- if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
- for i in 0...event.list.size
- return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
- end
- end
- end
- return 0, event #返回不存在自定义事件,以及事件体
- end
- end
- #=================以下两个用来调整战斗时的手感问题,可以自己试试。
- $敌人选框扩大 = 20
- $角色选框扩大 = 30
- #==============================================================================
- # ● API调用
- #==============================================================================
- $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
- $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
- $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
- $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
- $Window_HWND = $GetActiveWindow.call
- $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
- module Mouse
- LEFT = 0x01
- RIGHT = 0x02
- def self.init(sprite = nil)
- $ShowCursor.call(0)
-
- @show_cursor = false
-
- @mouse_sprite = Sprite.new
- @mouse_sprite.z = 99999
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')
- @left_press = false
- @right_press = false
- @left_trigger = false
- @right_trigger = false
- @left_repeat = false
- @right_repeat = false
- @click_lock = false
-
- update
- end
- def self.exit
- @mouse_sprite.bitmap.dispose
- @mouse_sprite.dispose
- @show_cursor = true
- $ShowCursor.call(1)
- end
- def self.mouse_debug
- return @mouse_debug.bitmap
- end
- def self.update
- left_down = $GetKeyState.call(0x01)
- right_down = $GetKeyState.call(0x02)
- if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
- @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
- @a = !@a
- end
- if $scene.is_a?(Scene_Map) == false
- $mouse_icon_id = 0
- end
- if $mouse_icon_id != $mouse_icon_id_last
- case $mouse_icon_id
- when 1
- if @a
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
- else
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
- end
- when 2
- if @a
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
- else
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
- end
- when 11
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
- when 12
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
- when 13
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
- when 14
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
- when 16
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
- when 17
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
- when 18
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
- when 19
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
- when 0
- @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标1')
- end
- $mouse_icon_id_last = $mouse_icon_id
- end
- @click_lock = false
- mouse_x, mouse_y = self.get_mouse_pos
- if @mouse_sprite != nil
- @mouse_sprite.x = mouse_x
- @mouse_sprite.y = mouse_y
- end
- if left_down[7] == 1
- @left_repeat = (not @left_repeat)
- @left_trigger = (not @left_press)
- @left_press = true
- else
- @left_press = false
- @left_trigger = false
- @left_repeat = false
- end
- if right_down[7] == 1
- @right_repeat = (not @right_repeat)
- @right_trigger = (not @right_press)
- @right_press = true
- else
- @right_press = false
- @right_trigger = false
- @right_repeat = false
- end
- end
- def self.get_mouse_pos
- point_var = [0, 0].pack('ll')
- if $GetCursorPos.call(point_var) != 0
- if $ScreenToClient.call($Window_HWND, point_var) != 0
- x, y = point_var.unpack('ll')
- if (x < 0) or (x > 10000) then x = 0 end
- if (y < 0) or (y > 10000) then y = 0 end
- if x > 1024 then x = 1024 end
- if y > 704 then y = 704 end
- return x, y
- else
- return 0, 0
- end
- else
- return 0, 0
- end
- end
- def self.press?(mouse_code)
- if mouse_code == LEFT
- if @click_lock
- return false
- else
- return @left_press
- end
- elsif mouse_code == RIGHT
- return @right_press
- else
- return false
- end
- end
- def self.trigger?(mouse_code)
- if mouse_code == LEFT
- if @click_lock
- return false
- else
- return @left_trigger
- end
- elsif mouse_code == RIGHT
- return @right_trigger
- else
- return false
- end
- end
- def self.repeat?(mouse_code)
- if mouse_code == LEFT
- if @click_lock
- return false
- else
- return @left_repeat
- end
- elsif mouse_code == RIGHT
- return @right_repeat
- else
- return false
- end
- end
- def self.click_lock?
- return @click_lock
- end
- def self.click_lock
- @click_lock = true
- end
- def self.click_unlock
- @click_lock = false
- end
- end
- module Input
- if @self_update == nil
- @self_update = method('update')
- @self_press = method('press?')
- @self_trigger = method('trigger?')
- @self_repeat = method('repeat?')
- end
- def self.update
- @self_update.call
- Mouse.update
- end
- def self.press?(key_code)
- if @self_press.call(key_code)
- return true
- end
- if key_code == C
- return Mouse.press?(Mouse::LEFT)
- elsif key_code == B
- return Mouse.press?(Mouse::RIGHT)
- else
- return @self_press.call(key_code)
- end
- end
- def self.trigger?(key_code)
- if @self_trigger.call(key_code)
- return true
- end
- if key_code == C
- return Mouse.trigger?(Mouse::LEFT)
- elsif key_code == B
- return Mouse.trigger?(Mouse::RIGHT)
- else
- return @self_trigger.call(key_code)
- end
- end
- def self.repeat?(key_code)
- if @self_repeat.call(key_code)
- return true
- end
- if key_code == C
- return Mouse.repeat?(Mouse::LEFT)
- elsif key_code == B
- return Mouse.repeat?(Mouse::RIGHT)
- else
- return @self_repeat.call(key_code)
- end
- end
- end
- class Window_Selectable
- if @self_alias == nil
- alias self_update update
- @self_alias = true
- end
- def update
- self_update
- if self.active and @item_max > 0
- index_var = @index
- tp_index = @index
- mouse_x, mouse_y = Mouse.get_mouse_pos
- mouse_not_in_rect = true
- for i in 0...@item_max
- @index = i
- update_cursor_rect
- top_x = self.cursor_rect.x + self.x + 16
- top_y = self.cursor_rect.y + self.y + 16
- bottom_x = top_x + self.cursor_rect.width
- bottom_y = top_y + self.cursor_rect.height
- if (mouse_x > top_x) and (mouse_y > top_y) and
- (mouse_x < bottom_x) and (mouse_y < bottom_y)
- mouse_not_in_rect = false
- if tp_index != @index
- tp_index = @index
- $game_system.se_play($data_system.cursor_se)
- end
- break
- end
- end
- if mouse_not_in_rect
- @index = index_var
- update_cursor_rect
- Mouse.click_lock
- else
- Mouse.click_unlock
- end
- end
- end
- end
- class Window_NameInput
- if @self_alias == nil
- alias self_update update
- @self_alias = true
- end
- def update
- self_update
- if self.active
- index_var = @index
- mouse_x, mouse_y = Mouse.get_mouse_pos
- mouse_not_in_rect = true
- for i in (0...CHARACTER_TABLE.size).to_a.push(180)
- @index = i
- update_cursor_rect
- top_x = self.cursor_rect.x + self.x + 16
- top_y = self.cursor_rect.y + self.y + 16
- bottom_x = top_x + self.cursor_rect.width
- bottom_y = top_y + self.cursor_rect.height
- if (mouse_x > top_x) and (mouse_y > top_y) and
- (mouse_x < bottom_x) and (mouse_y < bottom_y)
- mouse_not_in_rect = false
- break
- end
- end
- if mouse_not_in_rect
- @index = index_var
- update_cursor_rect
- Mouse.click_lock
- else
- Mouse.click_unlock
- end
- end
- end
- end
- class Window_InputNumber
- if @self_alias == nil
- alias self_update update
- @self_alias = true
- end
- def update
- self_update
- mouse_x, mouse_y = Mouse.get_mouse_pos
- if self.active and @digits_max > 0
- index_var = @index
- mouse_not_in_rect = true
- for i in 0...@digits_max
- @index = i
- update_cursor_rect
- top_x = self.cursor_rect.x + self.x + 16
- bottom_x = top_x + self.cursor_rect.width
- if (mouse_x > top_x) and (mouse_x < bottom_x)
- mouse_not_in_rect = false
- break
- end
- end
- if mouse_not_in_rect
- @index = index_var
- update_cursor_rect
- Mouse.click_lock
- else
- Mouse.click_unlock
- end
- end
- if @last_mouse_y == nil
- @last_mouse_y = mouse_y
- end
- check_pos = (@last_mouse_y - mouse_y).abs
- if check_pos > 10
- $game_system.se_play($data_system.cursor_se)
- place = 10 ** (@digits_max - 1 - @index)
- n = @number / place % 10
- @number -= n * place
- n = (n + 1) % 10 if mouse_y < @last_mouse_y
- n = (n + 9) % 10 if mouse_y > @last_mouse_y
- @number += n * place
- refresh
- @last_mouse_y = mouse_y
- end
- end
- end
- class Scene_File
- if @self_alias == nil
- alias self_update update
- @self_alias = true
- end
- def update
- mouse_x, mouse_y = Mouse.get_mouse_pos
- Mouse.click_lock
- idx = 0
- for i in @savefile_windows
- top_x = i.x + 16
- top_y = i.y + 16
- bottom_x = top_x + i.width
- bottom_y = top_y + i.height
- if (mouse_x > top_x) and (mouse_y > top_y) and
- (mouse_x < bottom_x) and (mouse_y < bottom_y)
- i.selected = true
- if @file_index != idx
- @file_index = idx
- $game_system.se_play($data_system.cursor_se)
- end
- Mouse.click_unlock
- else
- i.selected = false
- end
- idx += 1
- end
- self_update
- end
- end
- class Arrow_Enemy
- if @self_alias == nil
- alias self_update update
- @self_alias = true
- end
- def update
- mouse_x, mouse_y = Mouse.get_mouse_pos
- idx = 0
- for i in $game_troop.enemies do
- if i.exist?
- top_x = i.screen_x - self.ox
- top_y = i.screen_y - self.oy
- bottom_x = top_x + self.src_rect.width
- bottom_y = top_y + self.src_rect.height
- if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
- (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
- if @index != idx
- $game_system.se_play($data_system.cursor_se)
- @index = idx
- end
- end
- end
- idx += 1
- end
- self_update
- end
- end
- class Arrow_Actor
- if @self_alias == nil
- alias self_update update
- @self_alias = true
- end
- def update
- mouse_x, mouse_y = Mouse.get_mouse_pos
- idx = 0
- for i in $game_party.actors do
- if i.exist?
- top_x = i.screen_x - self.ox
- top_y = i.screen_y - self.oy
- bottom_x = top_x + self.src_rect.width
- bottom_y = top_y + self.src_rect.height
- if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
- (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
- if @index != idx
- $game_system.se_play($data_system.cursor_se)
- @index = idx
- end
- end
- end
- idx += 1
- end
- self_update
- end
- end
- #==============================================================================
- # ■ Game_Player
- #------------------------------------------------------------------------------
- # 处理主角的类。事件启动的判定、以及地图的滚动等功能。
- # 本类的实例请参考 $game_player。
- # 鼠标控制角色的主程序
- #==============================================================================
- class Game_Player
- if @self_alias == nil
- alias self_update update
- @self_alias = true
- end
- #--------------------------------------------------------------------------
- # ● 得到鼠标的状态
- #--------------------------------------------------------------------------
- def get_mouse_sta
- return @mouse_sta
- end
- #--------------------------------------------------------------------------
- # ● 完整鼠标系统
- #--------------------------------------------------------------------------
- def update
- mouse_x, mouse_y = Mouse.get_mouse_pos
- @mtp_x = mouse_x
- @mtp_y = mouse_y
- unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
- #得到鼠标图标方向
- $mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y) if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
- else
- #令鼠标图标为正常
- $mouse_icon_id = 0 if @mouse_sta != 2
- end
-
- #单击鼠标时进行判断寻路或跟随
- if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
- unless $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
- #初始化
- @mouse_sta = 1
- p_direction = 5
- #检查鼠标处能否开启事件
- event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
- #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
- @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
- if @mouse_sta != 2
- #鼠标状态不为跟随状态则取数据并初始化路径
- trg_x = (mouse_x + $game_map.display_x / 4) / 32
- trg_y = (mouse_y + $game_map.display_y / 4) / 32
- @paths = []
- @paths_id = 0
- if event_start == 0 #若不能开启事件
- if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
- find_path = Find_Path.new
- @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
- end
- else #若能开启事件则改变角色朝向
- @direction = p_direction
- end
- end
- end
- end
- #开始移动
- if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing #排除无效情况
- if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
- case @paths[@paths_id] #判断路径
- when 6
- @last_move_x = true
- move_right
- @paths_id += 1
- @direction = 6
- when 4
- @last_move_x = true
- move_left
- @paths_id += 1
- @direction = 4
- when 2
- @last_move_x = false
- move_down
- @direction = 2
- @paths_id += 1
- when 8
- @last_move_x = false
- move_up
- @direction = 8
- @paths_id += 1
- end
- end
- end
- elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
- if Mouse.press?(Mouse::LEFT) #持续按住鼠标
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing #排除无效情况
- #跟随方向判断并跟随
- if @mtp_x > self.screen_x
- if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
- @mtp_y - self.screen_y < @mtp_x - self.screen_x
- move_right
- $mouse_icon_id = 16
- @direction = 6
- end
- if @mtp_y - self.screen_y > @mtp_x - self.screen_x
- move_down
- $mouse_icon_id = 12
- @direction = 2
- end
- if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
- move_up
- $mouse_icon_id = 18
- @direction = 8
- end
- end
- if @mtp_x < self.screen_x
- if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
- @mtp_y - self.screen_y < self.screen_x - @mtp_x
- move_left
- $mouse_icon_id = 14
- @direction = 4
- end
- if @mtp_y - self.screen_y > self.screen_x - @mtp_x
- move_down
- $mouse_icon_id = 12
- @direction = 2
- end
- if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
- move_up
- $mouse_icon_id = 18
- @direction = 8
- end
- end
- end
- else #没状态的情况
- $mouse_icon_id = 0
- @mouse_sta = 0
- @paths_id = @paths.size #终止寻路移动
- end
- end
- self_update
- end
- end
- Mouse.init
- END { Mouse.exit }
复制代码 然后我发现,如果不插这一段的话会出错......- if $myfirst == nil
-
- $myfirst = 'myGod'
- 宽度=1024
- 高度=704
- 游戏ini名=".\\Game.ini"
- val = "\0"*256
- gps = Win32API.new('kernel32', 'GetPrivateProfileString','pppplp', 'l')
- gps.call("Game", "Title", "", val, 256, 游戏ini名)
- val.delete!("\0")
- title = val
- fw = Win32API.new('user32', 'FindWindow', 'pp', 'i')
- hWnd = fw.call("RGSS Player", title)
- swp = Win32API.new('user32', 'SetWindowPos', 'lliiiii', 'i')
- pointwds = [0,0,0,0].pack('llll')
- pointcet = [0, 0].pack('ll')
- wdsrect = Win32API.new('user32.dll', 'GetWindowRect', 'lp', 'l')
- client_screen = Win32API.new("user32", "ClientToScreen", 'ip', 'i')
- wdsrect.call(hWnd,pointwds)
- client_screen.call(hWnd, pointcet)
- wds = pointwds.unpack('llll')
- cet = pointcet.unpack('ll')
- addw = wds[2] - wds[0] - 640
- addh = wds[3] - wds[1] - 480
- x = wds[0] - (宽度 - 1024) / 2
- y = wds[1] - (高度 - 704) / 2
- swp.call(hWnd, 0, x, y, 宽度 + addw, 高度 + addh, 0x20)
-
- end
- class Window_Item
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- if item.is_a?(RPG::Item) and
- $game_party.item_can_use?(item.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4 + index % 2 * (288 + 32)
- y = index / 2 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y , bitmap, Rect.new(0, 0, 32, 32), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
- end
- end
复制代码 然后就可以共存了,但是鼠标寻路走几下就走不了了,这是怎么回事?求大大们帮忙讲解一下。
@晴兰 @protosssonny @紫英晓狼1130 @876加几 @火烧兔子 @end55rpg @1426 @美丽晨露 @whbm @高手们 @fux2 |
|