设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1504|回复: 5
打印 上一主题 下一主题

[已经过期] 关于鼠标系统和窗口扩大系统的整合

[复制链接]

Lv3.寻梦者

○赛

梦石
0
星屑
1249
在线时间
1276 小时
注册时间
2013-1-22
帖子
2246

贵宾

跳转到指定楼层
1
发表于 2013-12-20 22:37:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 天地有正气 于 2013-12-21 08:29 编辑

一下是我的鼠标脚本,寻路算法和窗口扩大(从赛尔号单机版找来的)
因为脚本变形,所以 @fog
窗口扩大
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————

  4. class Win32API
  5.   GAME_INI_FILE = ".\\Game.ini"
  6.   HWND_TOPMOST = 0
  7.   HWND_TOP = -1
  8.   SWP_NOMOVE   = 0
  9.   SWP_FRAMECHANGED = 0
  10.   HWND_NOTTOPMOST = 0
  11.   WM_GETMINMAXINFO = 24
  12. end
  13. $width = 1024
  14. $height = 704
  15. #==============================================================================
  16. # ■ Spriteset_Map
  17. #------------------------------------------------------------------------------
  18. #  处理地图画面活动块和元件的类。本类在 Scene_Map 类的内部使用。
  19. #==============================================================================
  20. class Spriteset_Map
  21.   #--------------------------------------------------------------------------
  22.   # ● 初始化对像
  23.   #--------------------------------------------------------------------------
  24.   def initialize
  25.     @viewport2 = Viewport.new(0, 0, $width, $height)  #——生成图片
  26.     @viewport3 = Viewport.new(0, 0, $width, $height)  #——生成画面闪烁用的部分
  27.     $viewport4 = Viewport.new(640, 0, $width-640, 480)  #——右侧
  28.     $viewport5 = Viewport.new(0, 480, 640, $height-480) #——下侧
  29.     $viewport6 = Viewport.new(640, 480, $width-640, $height-480) #——右下角
  30.     $viewport1 = Viewport.new(0, 0, 1024, 704) #——主窗口
  31.     @viewport_weather = Viewport.new(0, 0, $width, $height) #——生成天气专用
  32.     @viewport2.z = 200  #——生成图片的深度
  33.     @viewport3.z = 5000 #——生成画面闪烁用的深度
  34.     @tilemap = Tilemap.new($viewport1)  #——主窗口
  35.     @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  36.     @tilemap2 = Tilemap.new($viewport4) #——右侧
  37.     @tilemap2.tileset = RPG::Cache.tileset($game_map.tileset_name)
  38.     @tilemap3 = Tilemap.new($viewport5) #——下侧
  39.     @tilemap3.tileset = RPG::Cache.tileset($game_map.tileset_name)
  40.     @tilemap4 = Tilemap.new($viewport6) #——右下角
  41.     @tilemap4.tileset = RPG::Cache.tileset($game_map.tileset_name)
  42.     for i in 0..6 #——生成自动元件
  43.       autotile_name = $game_map.autotile_names[i]
  44.       @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  45.       @tilemap2.autotiles[i] = RPG::Cache.autotile(autotile_name)
  46.       @tilemap3.autotiles[i] = RPG::Cache.autotile(autotile_name)
  47.       @tilemap4.autotiles[i] = RPG::Cache.autotile(autotile_name)
  48.     end
  49.     @tilemap.map_data = $game_map.data  #——生成地图数据
  50.     @tilemap2.map_data = $game_map.data
  51.     @tilemap3.map_data = $game_map.data
  52.     @tilemap4.map_data = $game_map.data
  53.     @tilemap.priorities = $game_map.priorities  #——生成优先
  54.     @tilemap2.priorities = $game_map.priorities
  55.     @tilemap3.priorities = $game_map.priorities
  56.     @tilemap4.priorities = $game_map.priorities
  57.     @character_sprites = [] #——生成事件
  58.     for i in $game_map.events.keys.sort
  59.       sprite = Sprite_Character.new($viewport1, $game_map.events[i])
  60.       @character_sprites.push(sprite)
  61.       sprite = Sprite_Character.new($viewport4, $game_map.events[i])
  62.       @character_sprites.push(sprite)
  63.       sprite = Sprite_Character.new($viewport5, $game_map.events[i])
  64.       @character_sprites.push(sprite)
  65.       sprite = Sprite_Character.new($viewport6, $game_map.events[i])
  66.       @character_sprites.push(sprite)
  67.     end  #——下面继续生成角色
  68.     @character_sprites.push(Sprite_Character.new($viewport1, $game_player))
  69.     @character_sprites.push(Sprite_Character.new($viewport4, $game_player))
  70.     @character_sprites.push(Sprite_Character.new($viewport5, $game_player))
  71.     @character_sprites.push(Sprite_Character.new($viewport6, $game_player))
  72.     #——下面生成远景
  73.     @panorama = Plane.new($viewport1)
  74.     @panorama.z = -1000
  75.     @panorama2 = Plane.new($viewport4)
  76.     @panorama2.z = -1000
  77.     @panorama3 = Plane.new($viewport5)
  78.     @panorama3.z = -1000
  79.     @panorama4 = Plane.new($viewport6)
  80.     @panorama4.z = -1000
  81.     #——下面生成雾   
  82.    [url=home.php?mod=space&uid=14217]@fog[/url] = Plane.new($viewport1)
  83.     @fog.z = 3000
  84.     @fog2 = Plane.new($viewport4)
  85.     @fog2.z = 3000
  86.     @fog3 = Plane.new($viewport5)
  87.     @fog3.z = 3000
  88.     @fog4 = Plane.new($viewport6)
  89.     @fog4.z = 3000
  90.     #——下面生成天气
  91.     @weather = Weather.new(@viewport_weather)
  92.     @picture_sprites = [] #——这里生成图片
  93.     for i in 1..50
  94.       @picture_sprites.push(Sprite_Picture.new(@viewport2, $game_screen.pictures[i]))
  95.     end
  96.     @timer_sprite = Sprite_Timer.new #——生成计时器
  97.     #——刷新
  98.     update
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 释放
  102.   #--------------------------------------------------------------------------
  103.   def dispose
  104.     @tilemap.tileset.dispose    #——释放元件地图
  105.     @tilemap2.tileset.dispose
  106.     @tilemap3.tileset.dispose
  107.     @tilemap4.tileset.dispose
  108.     for i in 0..6
  109.       @tilemap.autotiles[i].dispose
  110.       @tilemap2.autotiles[i].dispose
  111.       @tilemap3.autotiles[i].dispose
  112.       @tilemap4.autotiles[i].dispose
  113.     end
  114.     @tilemap.dispose
  115.     @tilemap2.dispose
  116.     @tilemap3.dispose
  117.     @tilemap4.dispose
  118.     @panorama.dispose    #——释放远景平面
  119.     @panorama2.dispose
  120.     @panorama3.dispose
  121.     @panorama4.dispose
  122.     @fog.dispose    #——释放雾平面
  123.     @fog2.dispose
  124.     @fog3.dispose
  125.     @fog4.dispose
  126.     for sprite in @character_sprites    #——释放角色活动块
  127.       sprite.dispose
  128.     end
  129.     @weather.dispose   
  130.     for sprite in @picture_sprites
  131.       sprite.dispose
  132.     end
  133.     # 释放计时器块
  134.     @timer_sprite.dispose
  135.     # 释放显示端口
  136.     $viewport1.dispose
  137.     @viewport2.dispose
  138.     @viewport3.dispose
  139.     $viewport4.dispose
  140.     $viewport5.dispose
  141.     $viewport6.dispose
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 刷新画面
  145.   #--------------------------------------------------------------------------
  146.   def update
  147.     # 远景与现在的情况有差异发情况下
  148.     if @panorama_name != $game_map.panorama_name or  @panorama_hue != $game_map.panorama_hue
  149.       @panorama_name = $game_map.panorama_name
  150.       @panorama_hue = $game_map.panorama_hue
  151.       if @panorama.bitmap != nil
  152.         @panorama.bitmap.dispose
  153.         @panorama.bitmap = nil
  154.         @panorama2.bitmap.dispose
  155.         @panorama2.bitmap = nil
  156.         @panorama3.bitmap.dispose
  157.         @panorama3.bitmap = nil
  158.         @panorama4.bitmap.dispose
  159.         @panorama4.bitmap = nil
  160.       end
  161.       if @panorama_name != ""
  162.         @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  163.         @panorama2.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  164.         @panorama3.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  165.         @panorama4.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  166.       end
  167.       Graphics.frame_reset
  168.     end
  169.     # 雾与现在的情况有差异的情况下
  170.     if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  171.       @fog_name = $game_map.fog_name
  172.       @fog_hue = $game_map.fog_hue
  173.     if @fog.bitmap != nil
  174.       @fog.bitmap.dispose
  175.       @fog.bitmap = nil
  176.       @fog2.bitmap.dispose
  177.       @fog2.bitmap = nil
  178.       @fog3.bitmap.dispose
  179.       @fog3.bitmap = nil
  180.       @fog4.bitmap.dispose
  181.       @fog4.bitmap = nil
  182.     end
  183.     if @fog_name != ""
  184.       @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  185.       @fog2.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  186.       @fog3.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  187.       @fog4.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  188.     end
  189.       Graphics.frame_reset
  190.     end
  191.     # 刷新元件地图
  192.     @tilemap.ox = $game_map.display_x / 4
  193.     @tilemap.oy = $game_map.display_y / 4
  194.     @tilemap.update
  195.     @tilemap2.ox = @tilemap.ox
  196.     @tilemap2.oy = @tilemap.oy
  197.     @tilemap2.update
  198.     @tilemap3.ox = @tilemap.ox
  199.     @tilemap3.oy = @tilemap.oy + 480
  200.     @tilemap3.update
  201.     @tilemap4.ox = @tilemap.ox
  202.     @tilemap4.oy = @tilemap.oy + 480
  203.     @tilemap4.update
  204.     # 刷新远景平面
  205.     @panorama.ox = $game_map.display_x / 8
  206.     @panorama.oy = $game_map.display_y / 8
  207.     @panorama2.ox = @panorama.ox
  208.     @panorama2.oy = @panorama.oy
  209.     @panorama3.ox = @panorama.ox
  210.     @panorama3.oy = @panorama.oy + 480
  211.     @panorama4.ox = @panorama.ox
  212.     @panorama4.oy = @panorama.oy + 480
  213.     # 刷新雾平面
  214.     @[email protected][email protected][email protected]_x = $game_map.fog_zoom / 100.0
  215.     @[email protected][email protected][email protected]_y = $game_map.fog_zoom / 100.0
  216.     @[email protected][email protected][email protected] = $game_map.fog_opacity
  217.     @[email protected][email protected][email protected]_type = $game_map.fog_blend_type
  218.     @fog4.tone = @fog3.tone = @fog2.tone = @fog.tone = $game_map.fog_tone
  219.     @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  220.     @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  221.     @fog2.ox = @fog.ox #+ 140#*@fog.zoom_x
  222.     @fog2.oy = @fog.oy
  223.     @fog3.ox = @fog.ox
  224.     @fog3.oy = @fog.oy + 480
  225.     @fog4.ox = @fog.ox
  226.     @fog4.oy = @fog.oy + 480
  227.     # 刷新角色活动块
  228.     for sprite in @character_sprites
  229.       sprite.update
  230.     end
  231.     # 刷新天候图形
  232.     @weather.type = $game_screen.weather_type
  233.     @weather.max = $game_screen.weather_max
  234.     @weather.ox = $game_map.display_x / 4
  235.     @weather.oy = $game_map.display_y / 4
  236.     @weather.update  
  237.     # 刷新图片
  238.     for sprite in @picture_sprites
  239.       sprite.update
  240.     end
  241.     # 刷新计时器块
  242.     @timer_sprite.update
  243.     # 设置画面的色调与震动位置
  244.     $viewport1.tone = $game_screen.tone
  245.     $viewport1.ox = $game_screen.shake
  246.     $viewport4.tone = $game_screen.tone
  247.     $viewport4.ox = $game_screen.shake+640
  248.     $viewport5.tone = $game_screen.tone
  249.     $viewport5.ox = $game_screen.shake  
  250.     $viewport6.tone = $game_screen.tone
  251.     $viewport6.ox = $game_screen.shake+640
  252.     # 设置画面的闪烁色
  253.     @viewport3.color = $game_screen.flash_color
  254.     # 刷新显示端口
  255.     $viewport1.update
  256.     @viewport3.update
  257.     $viewport4.update
  258.     $viewport5.update
  259.     $viewport6.update
  260.   end
  261. end
  262.   class Weather
  263.     def initialize(viewport = nil)
  264.       @type = 0
  265.       @max = 0
  266.       @ox = 0
  267.       @oy = 0
  268.       color1 = Color.new(255, 255, 255, 255)
  269.       color2 = Color.new(255, 255, 255, 128)
  270.       @rain_bitmap = Bitmap.new(7, 56)
  271.       for i in 0..6
  272.         @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1)
  273.       end
  274.       @storm_bitmap = Bitmap.new(34, 64)
  275.       for i in 0..31
  276.         @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2)
  277.         @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1)
  278.         @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2)
  279.       end
  280.       @snow_bitmap = Bitmap.new(6, 6)
  281.       @snow_bitmap.fill_rect(0, 1, 6, 4, color2)
  282.       @snow_bitmap.fill_rect(1, 0, 4, 6, color2)
  283.       @snow_bitmap.fill_rect(1, 2, 4, 2, color1)
  284.       @snow_bitmap.fill_rect(2, 1, 2, 4, color1)
  285.       @sprites = []
  286.       for i in 1..40
  287.         sprite = Sprite.new(viewport)
  288.         sprite.z = 1000
  289.         sprite.visible = false
  290.         sprite.opacity = 0
  291.         @sprites.push(sprite)
  292.       end
  293.     end
  294.     def dispose
  295.       for sprite in @sprites
  296.         sprite.dispose
  297.       end
  298.       @rain_bitmap.dispose
  299.       @storm_bitmap.dispose
  300.       @snow_bitmap.dispose
  301.     end
  302.     def type=(type)
  303.       return if @type == type
  304.       @type = type
  305.       case @type
  306.       when 1
  307.         bitmap = @rain_bitmap
  308.       when 2
  309.         bitmap = @storm_bitmap
  310.       when 3
  311.         bitmap = @snow_bitmap
  312.       else
  313.         bitmap = nil
  314.       end
  315.       for i in 1..40
  316.         sprite = @sprites[i]
  317.         if sprite != nil
  318.           sprite.visible = (i <= @max)
  319.           sprite.bitmap = bitmap
  320.         end
  321.       end
  322.     end
  323.     def ox=(ox)
  324.       return if @ox == ox;
  325.       @ox = ox
  326.       for sprite in @sprites
  327.         sprite.ox = @ox
  328.       end
  329.     end
  330.     def oy=(oy)
  331.       return if @oy == oy;
  332.       @oy = oy
  333.       for sprite in @sprites
  334.         sprite.oy = @oy
  335.       end
  336.     end
  337.     def max=(max)
  338.       return if @max == max;
  339.       @max = [[max, 0].max, 40].min
  340.       for i in 1..40
  341.         sprite = @sprites[i]
  342.         if sprite != nil
  343.           sprite.visible = (i <= @max)
  344.         end
  345.       end
  346.     end
  347.     def update
  348.       return if @type == 0
  349.       for i in 1..@max
  350.         sprite = @sprites[i]
  351.         if sprite == nil
  352.           break
  353.         end
  354.         if @type == 1
  355.           sprite.x -= 2
  356.           sprite.y += 16
  357.           sprite.opacity -= 8
  358.         end
  359.         if @type == 2
  360.           sprite.x -= 8
  361.           sprite.y += 16
  362.           sprite.opacity -= 12
  363.         end
  364.         if @type == 3
  365.           sprite.x -= 2
  366.           sprite.y += 8
  367.           sprite.opacity -= 8
  368.         end
  369.         x = sprite.x - @ox
  370.         y = sprite.y - @oy
  371.         if sprite.opacity < 64 or x < -50 or x > $width+150 or y < -300 or y > $height+100
  372.           sprite.x = rand($width+150) - 50 + @ox
  373.           sprite.y = rand($height+100) - 200 + @oy
  374.           sprite.opacity = 255
  375.         end
  376.       end
  377.     end
  378.     attr_reader :type
  379.     attr_reader :max
  380.     attr_reader :ox
  381.     attr_reader :oy
  382.   end
  383. #==============================================================================
  384. # ■ Game_Player
  385. #------------------------------------------------------------------------------
  386. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  387. # 本类的实例请参考 $game_player。
  388. #==============================================================================

  389. class Game_Player < Game_Character
  390.   #--------------------------------------------------------------------------
  391.   # ● 恒量
  392.   #--------------------------------------------------------------------------
  393.   CENTER_X = ($width/2 - 16) * 4   
  394.   CENTER_Y = ($height/2 - 16) * 4   
  395.   #--------------------------------------------------------------------------
  396.   # ● 可以通行判定
  397.   #     x : X 坐标
  398.   #     y : Y 坐标
  399.   #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向不能通行的情况判定 (跳跃用)
  400.   #--------------------------------------------------------------------------
  401.   def passable?(x, y, d)
  402.     # 求得新的坐标
  403.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  404.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  405.     # 坐标在地图外的情况下
  406.     unless $game_map.valid?(new_x, new_y)
  407.       # 不能通行
  408.       return false
  409.     end
  410.     # 调试模式为 ON 并且 按下 CTRL 键的情况下
  411.     if $DEBUG and Input.press?(Input::CTRL)
  412.       # 可以通行
  413.       return true
  414.     end
  415.     super
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● 像通到画面中央一样的设置地图的显示位置
  419.   #--------------------------------------------------------------------------
  420.   def center(x, y)
  421.     max_x = ($game_map.width - 20) * 128
  422.     max_y = ($game_map.height - 15) * 128
  423.     $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
  424.     $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
  425.     $game_map.scroll_down(0)
  426.     $game_map.scroll_right(0)
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # ● 向指定的位置移动
  430.   #     x : X 座標
  431.   #     y : Y 座標
  432.   #--------------------------------------------------------------------------
  433.   def moveto(x, y)
  434.     super
  435.     # 自连接
  436.     center(x, y)
  437.     # 生成遇敌计数
  438.     make_encounter_count
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # ● 增加步数
  442.   #--------------------------------------------------------------------------
  443.   def increase_steps
  444.     super
  445.     # 不是强制移动路线的场合
  446.     unless @move_route_forcing
  447.       # 增加步数
  448.       $game_party.increase_steps
  449.       # 步数是偶数的情况下
  450.       if $game_party.steps % 2 == 0
  451.         # 检查连续伤害
  452.         $game_party.check_map_slip_damage
  453.       end
  454.     end
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ● 获取遇敌计数
  458.   #--------------------------------------------------------------------------
  459.   def encounter_count
  460.     return @encounter_count
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● 生成遇敌计数
  464.   #--------------------------------------------------------------------------
  465.   def make_encounter_count
  466.     # 两种颜色震动的图像
  467.     if $game_map.map_id != 0
  468.       n = $game_map.encounter_step
  469.       @encounter_count = rand(n) + rand(n) + 1
  470.     end
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # ● 刷新
  474.   #--------------------------------------------------------------------------
  475.   def refresh
  476.     # 同伴人数为 0 的情况下
  477.     if $game_party.actors.size == 0
  478.       # 清除角色的文件名及对像
  479.       @character_name = ""
  480.       @character_hue = 0
  481.       # 分支结束
  482.       return
  483.     end
  484.     # 获取带头的角色
  485.     actor = $game_party.actors[0]
  486.     # 设置角色的文件名及对像
  487.     @character_name = actor.character_name
  488.     @character_hue = actor.character_hue
  489.     # 初始化不透明度和合成方式子
  490.     @opacity = 255
  491.     @blend_type = 0
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 同位置的事件启动判定
  495.   #--------------------------------------------------------------------------
  496.   def check_event_trigger_here(triggers)
  497.     result = false
  498.     # 事件执行中的情况下
  499.     if $game_system.map_interpreter.running?
  500.       return result
  501.     end
  502.     # 全部事件的循环
  503.     for event in $game_map.events.values
  504.       # 事件坐标与目标一致的情况下
  505.       if event.x == @x and event.y == @y and triggers.include?(event.trigger)
  506.         # 跳跃中以外的情况下、启动判定是同位置的事件
  507.         if not event.jumping? and event.over_trigger?
  508.           event.start
  509.           result = true
  510.         end
  511.       end
  512.     end
  513.     return result
  514.   end
  515.   #--------------------------------------------------------------------------
  516.   # ● 正面事件的启动判定
  517.   #--------------------------------------------------------------------------
  518.   def check_event_trigger_there(triggers)
  519.     result = false
  520.     # 事件执行中的情况下
  521.     if $game_system.map_interpreter.running?
  522.       return result
  523.     end
  524.     # 计算正面坐标
  525.     new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  526.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  527.     # 全部事件的循环
  528.     for event in $game_map.events.values
  529.       # 事件坐标与目标一致的情况下
  530.       if event.x == new_x and event.y == new_y and
  531.          triggers.include?(event.trigger)
  532.         # 跳跃中以外的情况下、启动判定是正面的事件
  533.         if not event.jumping? and not event.over_trigger?
  534.           event.start
  535.           result = true
  536.         end
  537.       end
  538.     end
  539.     # 找不到符合条件的事件的情况下
  540.     if result == false
  541.       # 正面的元件是计数器的情况下
  542.       if $game_map.counter?(new_x, new_y)
  543.         # 计算 1 元件里侧的坐标
  544.         new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  545.         new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  546.         # 全事件的循环
  547.         for event in $game_map.events.values
  548.           # 事件坐标与目标一致的情况下
  549.           if event.x == new_x and event.y == new_y and
  550.              triggers.include?(event.trigger)
  551.             # 跳跃中以外的情况下、启动判定是正面的事件
  552.             if not event.jumping? and not event.over_trigger?
  553.               event.start
  554.               result = true
  555.             end
  556.           end
  557.         end
  558.       end
  559.     end
  560.     return result
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● 接触事件启动判定
  564.   #--------------------------------------------------------------------------
  565.   def check_event_trigger_touch(x, y)
  566.     result = false
  567.     # 事件执行中的情况下
  568.     if $game_system.map_interpreter.running?
  569.       return result
  570.     end
  571.     # 全事件的循环
  572.     for event in $game_map.events.values
  573.       # 事件坐标与目标一致的情况下
  574.       if event.x == x and event.y == y and [1,2].include?(event.trigger)
  575.         # 跳跃中以外的情况下、启动判定是正面的事件
  576.         if not event.jumping? and not event.over_trigger?
  577.           event.start
  578.           result = true
  579.         end
  580.       end
  581.     end
  582.     return result
  583.   end
  584.   #--------------------------------------------------------------------------
  585.   # ● 画面更新
  586.   #--------------------------------------------------------------------------
  587.   def update
  588.     # 本地变量记录移动信息
  589.     last_moving = moving?
  590.     # 移动中、事件执行中、强制移动路线中、
  591.     # 信息窗口一个也不显示的时候
  592.     unless moving? or $game_system.map_interpreter.running? or
  593.            @move_route_forcing or $game_temp.message_window_showing
  594.       # 如果方向键被按下、主角就朝那个方向移动
  595.       case Input.dir4
  596.       when 2
  597.         move_down
  598.       when 4
  599.         move_left
  600.       when 6
  601.         move_right
  602.       when 8
  603.         move_up
  604.       end
  605.     end
  606.     # 本地变量记忆坐标
  607.     last_real_x = @real_x
  608.     last_real_y = @real_y
  609.     super
  610.     # 角色向下移动、画面上的位置在中央下方的情况下
  611.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  612.       # 画面向下卷动
  613.       $game_map.scroll_down(@real_y - last_real_y)
  614.     end
  615.     # 角色向左移动、画面上的位置在中央左方的情况下
  616.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  617.       # 画面向左卷动
  618.       $game_map.scroll_left(last_real_x - @real_x)
  619.     end
  620.     # 角色向右移动、画面上的位置在中央右方的情况下
  621.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  622.       # 画面向右卷动
  623.       $game_map.scroll_right(@real_x - last_real_x)
  624.     end
  625.     # 角色向上移动、画面上的位置在中央上方的情况下
  626.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  627.       # 画面向上卷动
  628.       $game_map.scroll_up(last_real_y - @real_y)
  629.     end
  630.     # 不在移动中的情况下
  631.     unless moving?
  632.       # 上次主角移动中的情况
  633.       if last_moving
  634.         # 与同位置的事件接触就判定为事件启动
  635.         result = check_event_trigger_here([1,2])
  636.         # 没有可以启动的事件的情况下
  637.         if result == false
  638.           # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  639.           unless $DEBUG and Input.press?(Input::CTRL)
  640.             # 遇敌计数下降
  641.             if @encounter_count > 0
  642.               @encounter_count -= 1
  643.             end
  644.           end
  645.         end
  646.       end
  647.       # 按下 C 键的情况下
  648.       if Input.trigger?(Input::C)
  649.         # 判定为同位置以及正面的事件启动
  650.         check_event_trigger_here([0])
  651.         check_event_trigger_there([0,1,2])
  652.       end
  653.     end
  654.   end
  655. end
  656. #==============================================================================
  657. # ■ Scene_Gameover
  658. #------------------------------------------------------------------------------
  659. #  处理游戏结束画面的类。
  660. #==============================================================================

  661. class Scene_Gameover
  662.   #--------------------------------------------------------------------------
  663.   # ● 主处理
  664.   #--------------------------------------------------------------------------
  665.   def main
  666.     # 生成游戏结束图形
  667.     if $game_temp.in_battle
  668.       @temp_sprite = Spriteset_Battle.new
  669.     else
  670.       @temp_sprite = Spriteset_Map.new
  671.     end
  672.     @sprite = Sprite.new
  673.     @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
  674.     @sprite.opacity = 0
  675.     # 停止 BGM、BGS
  676.     $game_system.bgm_play(nil)
  677.     $game_system.bgs_play(nil)
  678.     # 演奏游戏结束 ME
  679.     $game_system.me_play($data_system.gameover_me)
  680.     # 执行过渡
  681.     Graphics.transition(0)
  682.     # 主循环
  683.     for i in 0..120
  684.       @sprite.opacity +=4
  685.       Graphics.update
  686.     end
  687.     @temp_sprite.dispose
  688.     loop do
  689.       # 刷新游戏画面
  690.       Graphics.update
  691.       # 刷新输入信息
  692.       Input.update
  693.       # 刷新画面情报
  694.       update
  695.       # 如果画面被切换的话就中断循环
  696.       if $scene != self
  697.         break
  698.       end
  699.     end
  700.     # 释放游戏结束图形
  701.     @sprite.bitmap.dispose
  702.     @sprite.dispose
  703.     # 执行过度
  704.     Graphics.transition(0)
  705.     # 准备过渡
  706.     if $BTEST
  707.       $scene = nil
  708.     end
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # ● 刷新画面
  712.   #--------------------------------------------------------------------------
  713.   def update
  714.     # 按下 C 键的情况下
  715.     if Input.trigger?(Input::C)
  716.       for i in 0..30
  717.         @sprite.opacity -=10
  718.         Graphics.update
  719.       end      
  720.       # 切换到标题画面
  721.       $scene = Scene_Title.new
  722.     end
  723.   end
  724. end
  725. #==============================================================================
  726. # ■ Scene_Title
  727. #------------------------------------------------------------------------------
  728. #  处理标题画面的类。
  729. #==============================================================================

  730. class Scene_Title
  731.   #--------------------------------------------------------------------------
  732.   # ● 住处理
  733.   #--------------------------------------------------------------------------
  734.   def main
  735.     # 战斗测试的情况下
  736.     if $BTEST
  737.       battle_test
  738.       return
  739.     end
  740.     # 载入数据库
  741.     $data_actors        = load_data("Data/Actors.rxdata")
  742.     $data_classes       = load_data("Data/Classes.rxdata")
  743.     $data_skills        = load_data("Data/Skills.rxdata")
  744.     $data_items         = load_data("Data/Items.rxdata")
  745.     $data_weapons       = load_data("Data/Weapons.rxdata")
  746.     $data_armors        = load_data("Data/Armors.rxdata")
  747.     $data_enemies       = load_data("Data/Enemies.rxdata")
  748.     $data_troops        = load_data("Data/Troops.rxdata")
  749.     $data_states        = load_data("Data/States.rxdata")
  750.     $data_animations    = load_data("Data/Animations.rxdata")
  751.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  752.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  753.     $data_system        = load_data("Data/System.rxdata")
  754.     # 生成系统对像
  755.     $game_system = Game_System.new
  756.     # 生成标题图形
  757.     @sprite = Sprite.new
  758.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  759.     @sprite.opacity = 0
  760.     # 生成命令窗口
  761.     s1 = "新游戏"
  762.     s2 = "继续"
  763.     s3 = "退出"
  764.     @command_window = Window_Command.new(192, [s1, s2, s3])
  765.     @command_window.back_opacity = 160
  766.     @command_window.x = $width /2 - @command_window.width / 2
  767.     @command_window.y = $height  /2 +132
  768.     # 判定继续的有效性
  769.     # 存档文件一个也不存在的时候也调查
  770.     # 有効为 @continue_enabled 为 true、無効为 false
  771.     @continue_enabled = false
  772.     for i in 0..3
  773.       if FileTest.exist?("Save#{i+1}.rxdata")
  774.         @continue_enabled = true
  775.       end
  776.     end
  777.     # 继续为有效的情况下、光标停止在继续上
  778.     # 无效的情况下、继续的文字显示为灰色
  779.     if @continue_enabled
  780.       @command_window.index = 1
  781.     else
  782.       @command_window.disable_item(1)
  783.     end
  784.     # 演奏标题 BGM
  785.     $game_system.bgm_play($data_system.title_bgm)
  786.     # 停止演奏 ME、BGS
  787.     Audio.me_stop
  788.     Audio.bgs_stop
  789.     # 执行过渡
  790.     Graphics.transition(0)
  791.     # 主循环
  792.     loop do
  793.       # 刷新游戏画面
  794.       Graphics.update
  795.       # 刷新输入信息
  796.       Input.update
  797.       # 刷新画面
  798.       update
  799.       # 如果画面被切换就中断循环
  800.       if $scene != self
  801.         break
  802.       end
  803.     end
  804.     # 装备过渡
  805.     Graphics.freeze
  806.     # 释放命令窗口
  807.     @command_window.dispose
  808.     # 释放标题图形
  809.     @sprite.bitmap.dispose
  810.     @sprite.dispose
  811.   end
  812.   #--------------------------------------------------------------------------
  813.   # ● 刷新画面
  814.   #--------------------------------------------------------------------------
  815.   def update
  816.     if @sprite.opacity < 255
  817.       @sprite.opacity += 15
  818.     end   
  819.     # 刷新命令窗口
  820.     @command_window.update
  821.     # 按下 C 键的情况下
  822.     if Input.trigger?(Input::C)
  823.       # 命令窗口的光标位置的分支
  824.       case @command_window.index
  825.       when 0  # 新游戏
  826.         command_new_game
  827.       when 1  # 继续
  828.         command_continue
  829.       when 2  # 退出
  830.         command_shutdown
  831.       end
  832.     end
  833.   end
  834.   #--------------------------------------------------------------------------
  835.   # ● 命令 : 新游戏
  836.   #--------------------------------------------------------------------------
  837.   def command_new_game
  838.     # 演奏确定 SE
  839.     $game_system.se_play($data_system.decision_se)
  840.     # 停止 BGM
  841.     Audio.bgm_stop
  842.     # 重置测量游戏时间用的画面计数器
  843.     Graphics.frame_count = 0
  844.     # 生成各种游戏对像
  845.     $game_temp          = Game_Temp.new
  846.     $game_system        = Game_System.new
  847.     $game_switches      = Game_Switches.new
  848.     $game_variables     = Game_Variables.new
  849.     $game_self_switches = Game_SelfSwitches.new
  850.     $game_screen        = Game_Screen.new
  851.     $game_actors        = Game_Actors.new
  852.     $game_party         = Game_Party.new
  853.     $game_troop         = Game_Troop.new
  854.     $game_map           = Game_Map.new
  855.     $game_player        = Game_Player.new
  856.     # 设置初期同伴位置
  857.     $game_party.setup_starting_members
  858.     # 设置初期位置的地图
  859.     $game_map.setup($data_system.start_map_id)
  860.     # 主角向初期位置移动
  861.     $game_player.moveto($data_system.start_x, $data_system.start_y)
  862.     # 刷新主角
  863.     $game_player.refresh
  864.     # 执行地图设置的 BGM 与 BGS 的自动切换
  865.     $game_map.autoplay
  866.     # 刷新地图 (执行并行事件)
  867.     $game_map.update
  868.     # 切换地图画面
  869.     $scene = Scene_Map.new
  870.   end
  871.   #--------------------------------------------------------------------------
  872.   # ● 命令 : 继续
  873.   #--------------------------------------------------------------------------
  874.   def command_continue
  875.     # 继续无效的情况下
  876.     unless @continue_enabled
  877.       # 演奏无效 SE
  878.       $game_system.se_play($data_system.buzzer_se)
  879.       return
  880.     end
  881.     # 演奏确定 SE
  882.     $game_system.se_play($data_system.decision_se)
  883.     # 切换到读档画面
  884.     $scene = Scene_Load.new
  885.   end
  886.   #--------------------------------------------------------------------------
  887.   # ● 命令 : 退出
  888.   #--------------------------------------------------------------------------
  889.   def command_shutdown
  890.     # 演奏确定 SE
  891.     $game_system.se_play($data_system.decision_se)
  892.     # BGM、BGS、ME 的淡入淡出
  893.     Audio.bgm_fade(800)
  894.     Audio.bgs_fade(800)
  895.     Audio.me_fade(800)
  896.     # 退出
  897.     tempBitmap = Sprite.new
  898.     tempBitmap.bitmap = Bitmap.new($width,$height)
  899.     tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
  900.     tempBitmap.opacity = 0
  901.     for i in 0..20
  902.       tempBitmap.opacity+=14
  903.       Graphics.update
  904.     end
  905.     $scene = nil
  906.   end
  907.   #--------------------------------------------------------------------------
  908.   # ● 战斗测试
  909.   #--------------------------------------------------------------------------
  910.   def battle_test
  911.     # 载入数据库 (战斗测试用)
  912.     $data_actors        = load_data("Data/BT_Actors.rxdata")
  913.     $data_classes       = load_data("Data/BT_Classes.rxdata")
  914.     $data_skills        = load_data("Data/BT_Skills.rxdata")
  915.     $data_items         = load_data("Data/BT_Items.rxdata")
  916.     $data_weapons       = load_data("Data/BT_Weapons.rxdata")
  917.     $data_armors        = load_data("Data/BT_Armors.rxdata")
  918.     $data_enemies       = load_data("Data/BT_Enemies.rxdata")
  919.     $data_troops        = load_data("Data/BT_Troops.rxdata")
  920.     $data_states        = load_data("Data/BT_States.rxdata")
  921.     $data_animations    = load_data("Data/BT_Animations.rxdata")
  922.     $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
  923.     $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
  924.     $data_system        = load_data("Data/BT_System.rxdata")
  925.     # 重置测量游戏时间用的画面计数器
  926.     Graphics.frame_count = 0
  927.     # 生成各种游戏对像
  928.     $game_temp          = Game_Temp.new
  929.     $game_system        = Game_System.new
  930.     $game_switches      = Game_Switches.new
  931.     $game_variables     = Game_Variables.new
  932.     $game_self_switches = Game_SelfSwitches.new
  933.     $game_screen        = Game_Screen.new
  934.     $game_actors        = Game_Actors.new
  935.     $game_party         = Game_Party.new
  936.     $game_troop         = Game_Troop.new
  937.     $game_map           = Game_Map.new
  938.     $game_player        = Game_Player.new
  939.     # 设置战斗测试用同伴
  940.     $game_party.setup_battle_test_members
  941.     # 设置队伍 ID、可以逃走标志、战斗背景
  942.     $game_temp.battle_troop_id = $data_system.test_troop_id
  943.     $game_temp.battle_can_escape = true
  944.     $game_map.battleback_name = $data_system.battleback_name
  945.     # 演奏战斗开始 BGM
  946.     $game_system.se_play($data_system.battle_start_se)
  947.     # 演奏战斗 BGM
  948.     $game_system.bgm_play($game_system.battle_bgm)
  949.     # 切换到战斗画面
  950.     $scene = Scene_Battle.new
  951.   end
  952. end
  953. #==============================================================================
  954. # ■ Scene_Map
  955. #------------------------------------------------------------------------------
  956. #  处理地图画面的类。
  957. #==============================================================================

  958. class Scene_Map
  959.   #--------------------------------------------------------------------------
  960.   # ● 主处理
  961.   #--------------------------------------------------------------------------
  962.   def main
  963.     # 生成活动块
  964.     @spriteset = Spriteset_Map.new
  965.     # 生成信息窗口
  966.     @message_window = Window_Message.new
  967.     tempBitmap = Sprite.new
  968.     tempBitmap.bitmap = Bitmap.new($width,$height)
  969.     tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
  970.      # 执行过渡
  971.     Graphics.transition(0)
  972.     for i in 0..10
  973.       tempBitmap.opacity-=25
  974.       Graphics.update
  975.     end
  976.     tempBitmap.bitmap.dispose
  977.     tempBitmap.dispose
  978.     # 主循环
  979.     loop do
  980.       # 刷新游戏画面
  981.       Graphics.update
  982.       # 刷新输入信息
  983.       Input.update
  984.       # 刷新画面
  985.       update
  986.       # 如果画面切换的话就中断循环
  987.       if $scene != self
  988.         break
  989.       end
  990.     end
  991.     # 标题画面切换中的情况下
  992.     if $scene.is_a?(Scene_Title)
  993.       @message_window.dispose
  994.       tempBitmap = Sprite.new
  995.       tempBitmap.bitmap = Bitmap.new($width,$height)
  996.       tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
  997.       tempBitmap.opacity = 0
  998.       for i in 0..25
  999.         tempBitmap.opacity +=11
  1000.         Graphics.update
  1001.       end
  1002.       tempBitmap.bitmap.dispose
  1003.       tempBitmap.dispose
  1004.       Graphics.transition(0)
  1005.       @spriteset.dispose
  1006.     else
  1007.       @message_window.dispose
  1008.       @spriteset.dispose
  1009.     end
  1010.   end
  1011.   #--------------------------------------------------------------------------
  1012.   # ● 刷新画面
  1013.   #--------------------------------------------------------------------------
  1014.   def update
  1015.     # 循环
  1016.     loop do
  1017.       # 按照地图、实例、主角的顺序刷新
  1018.       # (本更新顺序不会在的满足事件的执行条件下成为给予角色瞬间移动
  1019.       #  的机会的重要因素)
  1020.       $game_map.update
  1021.       $game_system.map_interpreter.update
  1022.       $game_player.update
  1023.       # 系统 (计时器)、画面刷新
  1024.       $game_system.update
  1025.       $game_screen.update
  1026.       # 如果主角在场所移动中就中断循环
  1027.       unless $game_temp.player_transferring
  1028.         break
  1029.       end
  1030.       # 执行场所移动
  1031.       transfer_player
  1032.       # 处理过渡中的情况下、中断循环
  1033.       if $game_temp.transition_processing
  1034.         break
  1035.       end
  1036.     end
  1037.     # 刷新活动块
  1038.     @spriteset.update
  1039.     # 刷新信息窗口
  1040.     @message_window.update
  1041.     # 游戏结束的情况下
  1042.     if $game_temp.gameover
  1043.       # 切换的游戏结束画面
  1044.       $scene = Scene_Gameover.new
  1045.       return
  1046.     end
  1047.     # 返回标题画面的情况下
  1048.     if $game_temp.to_title
  1049.       # 切换到标题画面
  1050.       $scene = Scene_Title.new
  1051.       return
  1052.     end
  1053.     # 处理过渡中的情况下
  1054.     if $game_temp.transition_processing
  1055.       # 清除过渡处理中标志
  1056.       $game_temp.transition_processing = false
  1057.       # 执行过渡
  1058.       Graphics.transition(0)
  1059.     end
  1060.     # 显示信息窗口中的情况下
  1061.     if $game_temp.message_window_showing
  1062.       return
  1063.     end
  1064.     # 遇敌计数为 0 且、且遇敌列表不为空的情况下
  1065.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  1066.       # 不是在事件执行中或者禁止遇敌中
  1067.       unless $game_system.map_interpreter.running? or
  1068.              $game_system.encounter_disabled
  1069.         # 确定队伍
  1070.         n = rand($game_map.encounter_list.size)
  1071.         troop_id = $game_map.encounter_list[n]
  1072.         # 队伍有效的话
  1073.         if $data_troops[troop_id] != nil
  1074.           # 设置调用战斗标志
  1075.           $game_temp.battle_calling = true
  1076.           $game_temp.battle_troop_id = troop_id
  1077.           $game_temp.battle_can_escape = true
  1078.           $game_temp.battle_can_lose = false
  1079.           $game_temp.battle_proc = nil
  1080.         end
  1081.       end
  1082.     end
  1083.     # 按下 B 键的情况下
  1084.     if Input.trigger?(Input::B)
  1085.       # 不是在事件执行中或菜单禁止中
  1086.       unless $game_system.map_interpreter.running? or
  1087.              $game_system.menu_disabled
  1088.         # 设置菜单调用标志以及 SE 演奏
  1089.         $game_temp.menu_calling = true
  1090.         $game_temp.menu_beep = true
  1091.       end
  1092.     end
  1093.     # 调试模式为 ON 并且按下 F9 键的情况下
  1094.     if $DEBUG and Input.press?(Input::F9)
  1095.       # 设置调用调试标志
  1096.       $game_temp.debug_calling = true
  1097.     end
  1098.     # 不在主角移动中的情况下
  1099.     unless $game_player.moving?
  1100.       # 执行各种画面的调用
  1101.       if $game_temp.battle_calling
  1102.         call_battle
  1103.       elsif $game_temp.shop_calling
  1104.         call_shop
  1105.       elsif $game_temp.name_calling
  1106.         call_name
  1107.       elsif $game_temp.menu_calling
  1108.         call_menu
  1109.       elsif $game_temp.save_calling
  1110.         call_save
  1111.       elsif $game_temp.debug_calling
  1112.         call_debug
  1113.       end
  1114.     end
  1115.   end
  1116.   #--------------------------------------------------------------------------
  1117.   # ● 调用战斗
  1118.   #--------------------------------------------------------------------------
  1119.   def call_battle
  1120.     # 清除战斗调用标志
  1121.     $game_temp.battle_calling = false
  1122.     # 清除菜单调用标志
  1123.     $game_temp.menu_calling = false
  1124.     $game_temp.menu_beep = false
  1125.     # 生成遇敌计数
  1126.     $game_player.make_encounter_count
  1127.     # 记忆地图 BGM 、停止 BGM
  1128.     $game_temp.map_bgm = $game_system.playing_bgm
  1129.     $game_system.bgm_stop
  1130.     # 演奏战斗开始 SE
  1131.     $game_system.se_play($data_system.battle_start_se)
  1132.     # 演奏战斗 BGM
  1133.     $game_system.bgm_play($game_system.battle_bgm)
  1134.     # 矫正主角姿势
  1135.     $game_player.straighten
  1136.     # 切换到战斗画面
  1137.     $scene = Scene_Battle.new
  1138.   end
  1139.   #--------------------------------------------------------------------------
  1140.   # ● 调用商店
  1141.   #--------------------------------------------------------------------------
  1142.   def call_shop
  1143.     # 清除商店调用标志
  1144.     $game_temp.shop_calling = false
  1145.     # 矫正主角姿势
  1146.     $game_player.straighten
  1147.     # 切换到商店画面
  1148.     $scene = Scene_Shop.new
  1149.   end
  1150.   #--------------------------------------------------------------------------
  1151.   # ● 调用名称输入
  1152.   #--------------------------------------------------------------------------
  1153.   def call_name
  1154.     # 清除商店调用名称输入标志
  1155.     $game_temp.name_calling = false
  1156.     # 矫正主角姿势
  1157.     $game_player.straighten
  1158.     # 切换到名称输入画面
  1159.     $scene = Scene_Name.new
  1160.   end
  1161.   #--------------------------------------------------------------------------
  1162.   # ● 调用菜单
  1163.   #--------------------------------------------------------------------------
  1164.   def call_menu
  1165.     # 清除商店调用菜单标志
  1166.     $game_temp.menu_calling = false
  1167.     # 已经设置了菜单 SE 演奏标志的情况下
  1168.     if $game_temp.menu_beep
  1169.       # 演奏确定 SE
  1170.       $game_system.se_play($data_system.decision_se)
  1171.       # 清除菜单演奏 SE 标志
  1172.       $game_temp.menu_beep = false
  1173.     end
  1174.     # 矫正主角姿势
  1175.     $game_player.straighten
  1176.     # 切换到菜单画面
  1177.     $scene = Scene_Menu.new
  1178.   end
  1179.   #--------------------------------------------------------------------------
  1180.   # ● 调用存档
  1181.   #--------------------------------------------------------------------------
  1182.   def call_save
  1183.     # 矫正主角姿势
  1184.     $game_player.straighten
  1185.     # 切换到存档画面
  1186.     $scene = Scene_Save.new
  1187.   end
  1188.   #--------------------------------------------------------------------------
  1189.   # ● 调用调试
  1190.   #--------------------------------------------------------------------------
  1191.   def call_debug
  1192.     # 清除商店调用调试标志
  1193.     $game_temp.debug_calling = false
  1194.     # 演奏确定 SE
  1195.     $game_system.se_play($data_system.decision_se)
  1196.     # 矫正主角姿势
  1197.     $game_player.straighten
  1198.     # 切换到调试画面
  1199.     $scene = Scene_Debug.new
  1200.   end
  1201.   #--------------------------------------------------------------------------
  1202.   # ● 主角的场所移动
  1203.   #--------------------------------------------------------------------------
  1204.   def transfer_player
  1205.     # 清除主角场所移动调试标志
  1206.     $game_temp.player_transferring = false
  1207.     # 移动目标与现在的地图有差异的情况下
  1208.     if $game_map.map_id != $game_temp.player_new_map_id
  1209.       # 设置新地图
  1210.       $game_map.setup($game_temp.player_new_map_id)
  1211.     end
  1212.     # 设置主角位置
  1213.     $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
  1214.     # 设置主角朝向
  1215.     case $game_temp.player_new_direction
  1216.     when 2  # 下
  1217.       $game_player.turn_down
  1218.     when 4  # 左
  1219.       $game_player.turn_left
  1220.     when 6  # 右
  1221.       $game_player.turn_right
  1222.     when 8  # 上
  1223.       $game_player.turn_up
  1224.     end
  1225.     # 矫正主角姿势
  1226.     $game_player.straighten
  1227.     # 刷新地图 (执行并行事件)
  1228.     $game_map.update
  1229.     # 在生成活动块
  1230.     @spriteset.dispose
  1231.     @spriteset = Spriteset_Map.new
  1232.     # 处理过渡中的情况下
  1233.     if $game_temp.transition_processing
  1234.       # 清除过渡处理中标志
  1235.       $game_temp.transition_processing = false
  1236.       # 执行过渡
  1237.       $_t_Bitmap=Sprite.new
  1238.       $_t_Bitmap.bitmap = Bitmap.new($width,$height)
  1239.       $_t_Bitmap.bitmap.fill_rect(0,0,$width,$height,Color.new(0,0,0,255))
  1240.       Graphics.transition(0)
  1241.       for i in 0..10
  1242.         $_t_Bitmap.opacity-=26
  1243.         Graphics.update
  1244.       end
  1245.       $_t_Bitmap.bitmap.dispose
  1246.       $_t_Bitmap.dispose
  1247.     end
  1248.     # 执行地图设置的 BGM、BGS 的自动切换
  1249.     $game_map.autoplay
  1250.     # 设置画面
  1251.     Graphics.frame_reset
  1252.     # 刷新输入信息
  1253.     Input.update
  1254.   end
  1255. end
  1256. #==============================================================================
  1257. # ■ Interpreter (分割定义 5)
  1258. #------------------------------------------------------------------------------
  1259. #  执行事件命令的注释器。本类在 Game_System 类
  1260. # 和 Game_Event 类的内部使用。
  1261. #==============================================================================

  1262. class Interpreter
  1263.   #--------------------------------------------------------------------------
  1264.   # ● 场所移动
  1265.   #--------------------------------------------------------------------------
  1266.   def command_201
  1267.     # 战斗中的情况
  1268.     if $game_temp.in_battle
  1269.       # 继续
  1270.       return true
  1271.     end
  1272.     # 场所移动中、信息显示中、过渡处理中的情况下
  1273.     if $game_temp.player_transferring or
  1274.        $game_temp.message_window_showing or
  1275.        $game_temp.transition_processing
  1276.       # 结束
  1277.       return false
  1278.     end
  1279.     # 设置场所移动标志
  1280.     $game_temp.player_transferring = true
  1281.     # 指定方法为 [直接指定] 的情况下
  1282.     if @parameters[0] == 0
  1283.       # 设置主角的移动目标
  1284.       $game_temp.player_new_map_id = @parameters[1]
  1285.       $game_temp.player_new_x = @parameters[2]
  1286.       $game_temp.player_new_y = @parameters[3]
  1287.       $game_temp.player_new_direction = @parameters[4]
  1288.     # 指定方法为 [使用变量指定] 的情况下
  1289.     else
  1290.       # 设置主角的移动目标
  1291.       $game_temp.player_new_map_id = $game_variables[@parameters[1]]
  1292.       $game_temp.player_new_x = $game_variables[@parameters[2]]
  1293.       $game_temp.player_new_y = $game_variables[@parameters[3]]
  1294.       $game_temp.player_new_direction = @parameters[4]
  1295.     end
  1296.     # 推进索引
  1297.     @index += 1
  1298.     # 有淡入淡出的情况下
  1299.     if @parameters[5] == 0
  1300.       # 准备过渡   
  1301.       tempBitmap = Sprite.new
  1302.       tempBitmap.bitmap = Bitmap.new($width,$height)
  1303.       tempBitmap.bitmap.fill_rect(0, 0, $width, $height, Color.new(0,0,0,255))
  1304.       tempBitmap.opacity = 0
  1305.       for i in 0..10
  1306.         tempBitmap.opacity+=26
  1307.         Graphics.update
  1308.       end
  1309.       Graphics.freeze
  1310.       tempBitmap.bitmap.dispose
  1311.       tempBitmap.dispose
  1312.       # 设置过渡处理中标志
  1313.       $game_temp.transition_processing = true
  1314.       $game_temp.transition_name = ""
  1315.     end
  1316.     # 结束
  1317.     return false
  1318.   end
  1319.   #--------------------------------------------------------------------------
  1320.   # ● 设置事件位置
  1321.   #--------------------------------------------------------------------------
  1322.   def command_202
  1323.     # 战斗中的情况下
  1324.     if $game_temp.in_battle
  1325.       # 继续
  1326.       return true
  1327.     end
  1328.     # 获取角色
  1329.     character = get_character(@parameters[0])
  1330.     # 角色不存在的情况下
  1331.     if character == nil
  1332.       # 继续
  1333.       return true
  1334.     end
  1335.     # 指定方法为 [直接指定] 的情况下
  1336.     if @parameters[1] == 0
  1337.       # 设置角色的位置
  1338.       character.moveto(@parameters[2], @parameters[3])
  1339.     # 指定方法为 [使用变量指定] 的情况下
  1340.     elsif @parameters[1] == 1
  1341.       # 设置角色的位置
  1342.       character.moveto($game_variables[@parameters[2]],
  1343.         $game_variables[@parameters[3]])
  1344.     # 指定方法为 [与其它事件交换] 的情况下
  1345.     else
  1346.       old_x = character.x
  1347.       old_y = character.y
  1348.       character2 = get_character(@parameters[2])
  1349.       if character2 != nil
  1350.         character.moveto(character2.x, character2.y)
  1351.         character2.moveto(old_x, old_y)
  1352.       end
  1353.     end
  1354.     # 设置觉得的朝向
  1355.     case @parameters[4]
  1356.     when 8  # 上
  1357.       character.turn_up
  1358.     when 6  # 右
  1359.       character.turn_right
  1360.     when 2  # 下
  1361.       character.turn_down
  1362.     when 4  # 左
  1363.       character.turn_left
  1364.     end
  1365.     # 继续
  1366.     return true
  1367.   end
  1368.   #--------------------------------------------------------------------------
  1369.   # ● 地图的滚动
  1370.   #--------------------------------------------------------------------------
  1371.   def command_203
  1372.     # 战斗中的情况下
  1373.     if $game_temp.in_battle
  1374.       # 继续
  1375.       return true
  1376.     end
  1377.     # 已经在滚动中的情况下
  1378.     if $game_map.scrolling?
  1379.       # 结束
  1380.       return false
  1381.     end
  1382.     # 开始滚动
  1383.     $game_map.start_scroll(@parameters[0], @parameters[1], @parameters[2])
  1384.     # 继续
  1385.     return true
  1386.   end
  1387.   #--------------------------------------------------------------------------
  1388.   # ● 更改地图设置
  1389.   #--------------------------------------------------------------------------
  1390.   def command_204
  1391.     case @parameters[0]
  1392.     when 0  # 远景
  1393.       $game_map.panorama_name = @parameters[1]
  1394.       $game_map.panorama_hue = @parameters[2]
  1395.     when 1  # 雾
  1396.       $game_map.fog_name = @parameters[1]
  1397.       $game_map.fog_hue = @parameters[2]
  1398.       $game_map.fog_opacity = @parameters[3]
  1399.       $game_map.fog_blend_type = @parameters[4]
  1400.       $game_map.fog_zoom = @parameters[5]
  1401.       $game_map.fog_sx = @parameters[6]
  1402.       $game_map.fog_sy = @parameters[7]
  1403.     when 2  # 战斗背景
  1404.       $game_map.battleback_name = @parameters[1]
  1405.       $game_temp.battleback_name = @parameters[1]
  1406.     end
  1407.     # 继续
  1408.     return true
  1409.   end
  1410.   #--------------------------------------------------------------------------
  1411.   # ● 更改雾的色调
  1412.   #--------------------------------------------------------------------------
  1413.   def command_205
  1414.     # 开始更改色调
  1415.     $game_map.start_fog_tone_change(@parameters[0], @parameters[1] * 2)
  1416.     # 继续
  1417.     return true
  1418.   end
  1419.   #--------------------------------------------------------------------------
  1420.   # ● 更改雾的不透明度
  1421.   #--------------------------------------------------------------------------
  1422.   def command_206
  1423.     # 开始更改不透明度
  1424.     $game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * 2)
  1425.     # 继续
  1426.     return true
  1427.   end
  1428.   #--------------------------------------------------------------------------
  1429.   # ● 显示动画
  1430.   #--------------------------------------------------------------------------
  1431.   def command_207
  1432.     # 获取角色
  1433.     character = get_character(@parameters[0])
  1434.     # 角色不存在的情况下
  1435.     if character == nil
  1436.       # 继续
  1437.       return true
  1438.     end
  1439.     # 设置动画 ID
  1440.     character.animation_id = @parameters[1]
  1441.     # 继续
  1442.     return true
  1443.   end
  1444.   #--------------------------------------------------------------------------
  1445.   # ● 更改透明状态
  1446.   #--------------------------------------------------------------------------
  1447.   def command_208
  1448.     # 设置主角的透明状态
  1449.     $game_player.transparent = (@parameters[0] == 0)
  1450.     # 继续
  1451.     return true
  1452.   end
  1453.   #--------------------------------------------------------------------------
  1454.   # ● 设置移动路线
  1455.   #--------------------------------------------------------------------------
  1456.   def command_209
  1457.     # 获取角色
  1458.     character = get_character(@parameters[0])
  1459.     # 角色不存在的情况下
  1460.     if character == nil
  1461.       # 继续
  1462.       return true
  1463.     end
  1464.     # 强制移动路线
  1465.     character.force_move_route(@parameters[1])
  1466.     # 继续
  1467.     return true
  1468.   end
  1469.   #--------------------------------------------------------------------------
  1470.   # ● 移动结束后等待
  1471.   #--------------------------------------------------------------------------
  1472.   def command_210
  1473.     # 如果不在战斗中
  1474.     unless $game_temp.in_battle
  1475.       # 设置移动结束后待机标志
  1476.       @move_route_waiting = true
  1477.     end
  1478.     # 继续
  1479.     return true
  1480.   end
  1481.   #--------------------------------------------------------------------------
  1482.   # ● 开始过渡
  1483.   #--------------------------------------------------------------------------
  1484.   def command_221
  1485.     # 显示信息窗口中的情况下
  1486.     if $game_temp.message_window_showing
  1487.       # 结束
  1488.       return false
  1489.     end
  1490.     # 准备过渡
  1491.     Graphics.freeze
  1492.     # 继续
  1493.     return true
  1494.   end
  1495.   #--------------------------------------------------------------------------
  1496.   # ● 执行过渡
  1497.   #--------------------------------------------------------------------------
  1498.   def command_222
  1499.     # 已经设置了过渡处理中标志的情况下
  1500.     if $game_temp.transition_processing
  1501.       # 结束
  1502.       return false
  1503.     end
  1504.     # 设置过渡处理中标志
  1505.     $game_temp.transition_processing = true
  1506.     $game_temp.transition_name = @parameters[0]
  1507.     # 推进索引
  1508.     @index += 1
  1509.     # 结束
  1510.     return false
  1511.   end
  1512.   #--------------------------------------------------------------------------
  1513.   # ● 更改画面色调
  1514.   #--------------------------------------------------------------------------
  1515.   def command_223
  1516.     # 开始更改色调
  1517.     $game_screen.start_tone_change(@parameters[0], @parameters[1] * 2)
  1518.     # 继续
  1519.     return true
  1520.   end
  1521.   #--------------------------------------------------------------------------
  1522.   # ● 画面闪烁
  1523.   #--------------------------------------------------------------------------
  1524.   def command_224
  1525.     # 开始闪烁
  1526.     $game_screen.start_flash(@parameters[0], @parameters[1] * 2)
  1527.     # 继续
  1528.     return true
  1529.   end
  1530.   #--------------------------------------------------------------------------
  1531.   # ● 画面震动
  1532.   #--------------------------------------------------------------------------
  1533.   def command_225
  1534.     # 震动开始
  1535.     $game_screen.start_shake(@parameters[0], @parameters[1],
  1536.       @parameters[2] * 2)
  1537.     # 继续
  1538.     return true
  1539.   end
  1540.   #--------------------------------------------------------------------------
  1541.   # ● 显示图片
  1542.   #--------------------------------------------------------------------------
  1543.   def command_231
  1544.     # 获取图片编号
  1545.     number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
  1546.     # 指定方法为 [直接指定] 的情况下
  1547.     if @parameters[3] == 0
  1548.       x = @parameters[4]
  1549.       y = @parameters[5]
  1550.     # 指定方法为 [使用变量指定] 的情况下
  1551.     else
  1552.       x = $game_variables[@parameters[4]]
  1553.       y = $game_variables[@parameters[5]]
  1554.     end
  1555.     # 显示图片
  1556.     $game_screen.pictures[number].show(@parameters[1], @parameters[2],
  1557.       x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9])
  1558.     # 继续
  1559.     return true
  1560.   end
  1561.   #--------------------------------------------------------------------------
  1562.   # ● 移动图片
  1563.   #--------------------------------------------------------------------------
  1564.   def command_232
  1565.     # 获取图片编号
  1566.     number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
  1567.     # 指定方法为 [直接指定] 的情况下
  1568.     if @parameters[3] == 0
  1569.       x = @parameters[4]
  1570.       y = @parameters[5]
  1571.     # 指定方法为 [使用变量指定] 的情况下
  1572.     else
  1573.       x = $game_variables[@parameters[4]]
  1574.       y = $game_variables[@parameters[5]]
  1575.     end
  1576.     # 移动图片
  1577.     $game_screen.pictures[number].move(@parameters[1] * 2, @parameters[2],
  1578.       x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9])
  1579.     # 继续
  1580.     return true
  1581.   end
  1582.   #--------------------------------------------------------------------------
  1583.   # ● 旋转图片
  1584.   #--------------------------------------------------------------------------
  1585.   def command_233
  1586.     # 获取图片编号
  1587.     number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
  1588.     # 设置旋转速度
  1589.     $game_screen.pictures[number].rotate(@parameters[1])
  1590.     # 继续
  1591.     return true
  1592.   end
  1593.   #--------------------------------------------------------------------------
  1594.   # ● 更改图片色调
  1595.   #--------------------------------------------------------------------------
  1596.   def command_234
  1597.     # 获取图片编号
  1598.     number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
  1599.     # 开始更改色调
  1600.     $game_screen.pictures[number].start_tone_change(@parameters[1],
  1601.       @parameters[2] * 2)
  1602.     # 继续
  1603.     return true
  1604.   end
  1605.   #--------------------------------------------------------------------------
  1606.   # ● 删除图片
  1607.   #--------------------------------------------------------------------------
  1608.   def command_235
  1609.     # 获取图片编号
  1610.     number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
  1611.     # 删除图片
  1612.     $game_screen.pictures[number].erase
  1613.     # 继续
  1614.     return true
  1615.   end
  1616.   #--------------------------------------------------------------------------
  1617.   # ● 天候设置
  1618.   #--------------------------------------------------------------------------
  1619.   def command_236
  1620.     # 设置天候
  1621.     $game_screen.weather(@parameters[0], @parameters[1], @parameters[2])
  1622.     # 继续
  1623.     return true
  1624.   end
  1625.   #--------------------------------------------------------------------------
  1626.   # ● 演奏 BGM
  1627.   #--------------------------------------------------------------------------
  1628.   def command_241
  1629.     # 演奏 BGM
  1630.     $game_system.bgm_play(@parameters[0])
  1631.     # 继续
  1632.     return true
  1633.   end
  1634.   #--------------------------------------------------------------------------
  1635.   # ● BGM 的淡入淡出
  1636.   #--------------------------------------------------------------------------
  1637.   def command_242
  1638.     # 淡入淡出 BGM
  1639.     $game_system.bgm_fade(@parameters[0])
  1640.     # 继续
  1641.     return true
  1642.   end
  1643.   #--------------------------------------------------------------------------
  1644.   # ● 演奏 BGS
  1645.   #--------------------------------------------------------------------------
  1646.   def command_245
  1647.     # 演奏 BGS
  1648.     $game_system.bgs_play(@parameters[0])
  1649.     # 继续
  1650.     return true
  1651.   end
  1652.   #--------------------------------------------------------------------------
  1653.   # ● BGS 的淡入淡出
  1654.   #--------------------------------------------------------------------------
  1655.   def command_246
  1656.     # 淡入淡出 BGS
  1657.     $game_system.bgs_fade(@parameters[0])
  1658.     # 继续
  1659.     return true
  1660.   end
  1661.   #--------------------------------------------------------------------------
  1662.   # ● 记忆 BGM / BGS
  1663.   #--------------------------------------------------------------------------
  1664.   def command_247
  1665.     # 记忆 BGM / BGS
  1666.     $game_system.bgm_memorize
  1667.     $game_system.bgs_memorize
  1668.     # 继续
  1669.     return true
  1670.   end
  1671.   #--------------------------------------------------------------------------
  1672.   # ● 还原 BGM / BGS
  1673.   #--------------------------------------------------------------------------
  1674.   def command_248
  1675.     # 还原 BGM / BGS
  1676.     $game_system.bgm_restore
  1677.     $game_system.bgs_restore
  1678.     # 继续
  1679.     return true
  1680.   end
  1681.   #--------------------------------------------------------------------------
  1682.   # ● 演奏 ME
  1683.   #--------------------------------------------------------------------------
  1684.   def command_249
  1685.     # 演奏 ME
  1686.     $game_system.me_play(@parameters[0])
  1687.     # 继续
  1688.     return true
  1689.   end
  1690.   #--------------------------------------------------------------------------
  1691.   # ● 演奏 SE
  1692.   #--------------------------------------------------------------------------
  1693.   def command_250
  1694.     # 演奏 SE
  1695.     $game_system.se_play(@parameters[0])
  1696.     # 继续
  1697.     return true
  1698.   end
  1699.   #--------------------------------------------------------------------------
  1700.   # ● 停止 SE
  1701.   #--------------------------------------------------------------------------
  1702.   def command_251
  1703.     # 停止 SE
  1704.     Audio.se_stop
  1705.     # 继续
  1706.     return true
  1707.   end
  1708. end
  1709. #==============================================================================
  1710. # ■ Game_Enemy
  1711. #------------------------------------------------------------------------------
  1712. #  处理敌人的类。本类在 Game_Troop 类 ($game_troop) 的
  1713. # 内部使用。
  1714. #==============================================================================

  1715. class Game_Enemy < Game_Battler
  1716.   #--------------------------------------------------------------------------
  1717.   # ● 初始化对像
  1718.   #     troop_id     : 循环 ID
  1719.   #     member_index : 循环成员的索引
  1720.   #--------------------------------------------------------------------------
  1721.   def initialize(troop_id, member_index)
  1722.     super()
  1723.     @troop_id = troop_id
  1724.     @member_index = member_index
  1725.     troop = $data_troops[@troop_id]
  1726.     @enemy_id = troop.members[@member_index].enemy_id
  1727.     enemy = $data_enemies[@enemy_id]
  1728.     @battler_name = enemy.battler_name
  1729.     @battler_hue = enemy.battler_hue
  1730.     @hp = maxhp
  1731.     @sp = maxsp
  1732.     @hidden = troop.members[@member_index].hidden
  1733.     @immortal = troop.members[@member_index].immortal
  1734.   end
  1735.   #--------------------------------------------------------------------------
  1736.   # ● 获取敌人 ID
  1737.   #--------------------------------------------------------------------------
  1738.   def id
  1739.     return @enemy_id
  1740.   end
  1741.   #--------------------------------------------------------------------------
  1742.   # ● 获取索引
  1743.   #--------------------------------------------------------------------------
  1744.   def index
  1745.     return @member_index
  1746.   end
  1747.   #--------------------------------------------------------------------------
  1748.   # ● 获取名称
  1749.   #--------------------------------------------------------------------------
  1750.   def name
  1751.     return $data_enemies[@enemy_id].name
  1752.   end
  1753.   #--------------------------------------------------------------------------
  1754.   # ● 获取基本 MaxHP
  1755.   #--------------------------------------------------------------------------
  1756.   def base_maxhp
  1757.     return $data_enemies[@enemy_id].maxhp
  1758.   end
  1759.   #--------------------------------------------------------------------------
  1760.   # ● 获取基本 MaxSP
  1761.   #--------------------------------------------------------------------------
  1762.   def base_maxsp
  1763.     return $data_enemies[@enemy_id].maxsp
  1764.   end
  1765.   #--------------------------------------------------------------------------
  1766.   # ● 获取基本力量
  1767.   #--------------------------------------------------------------------------
  1768.   def base_str
  1769.     return $data_enemies[@enemy_id].str
  1770.   end
  1771.   #--------------------------------------------------------------------------
  1772.   # ● 获取基本灵巧
  1773.   #--------------------------------------------------------------------------
  1774.   def base_dex
  1775.     return $data_enemies[@enemy_id].dex
  1776.   end
  1777.   #--------------------------------------------------------------------------
  1778.   # ● 获取基本速度
  1779.   #--------------------------------------------------------------------------
  1780.   def base_agi
  1781.     return $data_enemies[@enemy_id].agi
  1782.   end
  1783.   #--------------------------------------------------------------------------
  1784.   # ● 获取基本魔力
  1785.   #--------------------------------------------------------------------------
  1786.   def base_int
  1787.     return $data_enemies[@enemy_id].int
  1788.   end
  1789.   #--------------------------------------------------------------------------
  1790.   # ● 获取基本攻击力
  1791.   #--------------------------------------------------------------------------
  1792.   def base_atk
  1793.     return $data_enemies[@enemy_id].atk
  1794.   end
  1795.   #--------------------------------------------------------------------------
  1796.   # ● 获取基本物理防御
  1797.   #--------------------------------------------------------------------------
  1798.   def base_pdef
  1799.     return $data_enemies[@enemy_id].pdef
  1800.   end
  1801.   #--------------------------------------------------------------------------
  1802.   # ● 获取基本魔法防御
  1803.   #--------------------------------------------------------------------------
  1804.   def base_mdef
  1805.     return $data_enemies[@enemy_id].mdef
  1806.   end
  1807.   #--------------------------------------------------------------------------
  1808.   # ● 获取基本回避修正
  1809.   #--------------------------------------------------------------------------
  1810.   def base_eva
  1811.     return $data_enemies[@enemy_id].eva
  1812.   end
  1813.   #--------------------------------------------------------------------------
  1814.   # ● 普通攻击 获取攻击方动画 ID
  1815.   #--------------------------------------------------------------------------
  1816.   def animation1_id
  1817.     return $data_enemies[@enemy_id].animation1_id
  1818.   end
  1819.   #--------------------------------------------------------------------------
  1820.   # ● 普通攻击 获取对像方动画 ID
  1821.   #--------------------------------------------------------------------------
  1822.   def animation2_id
  1823.     return $data_enemies[@enemy_id].animation2_id
  1824.   end
  1825.   #--------------------------------------------------------------------------
  1826.   # ● 获取属性修正值
  1827.   #     element_id : 属性 ID
  1828.   #--------------------------------------------------------------------------
  1829.   def element_rate(element_id)
  1830.     # 获取对应属性有效度的数值
  1831.     table = [0,200,150,100,50,0,-100]
  1832.     result = table[$data_enemies[@enemy_id].element_ranks[element_id]]
  1833.     # 状态能防御本属性的情况下效果减半
  1834.     for i in @states
  1835.       if $data_states[i].guard_element_set.include?(element_id)
  1836.         result /= 2
  1837.       end
  1838.     end
  1839.     # 过程结束
  1840.     return result
  1841.   end
  1842.   #--------------------------------------------------------------------------
  1843.   # ● 获取属性有效度
  1844.   #--------------------------------------------------------------------------
  1845.   def state_ranks
  1846.     return $data_enemies[@enemy_id].state_ranks
  1847.   end
  1848.   #--------------------------------------------------------------------------
  1849.   # ● 属性防御判定
  1850.   #     state_id : 状态 ID
  1851.   #--------------------------------------------------------------------------
  1852.   def state_guard?(state_id)
  1853.     return false
  1854.   end
  1855.   #--------------------------------------------------------------------------
  1856.   # ● 获取普通攻击属性
  1857.   #--------------------------------------------------------------------------
  1858.   def element_set
  1859.     return []
  1860.   end
  1861.   #--------------------------------------------------------------------------
  1862.   # ● 获取普通攻击的状态变化 (+)
  1863.   #--------------------------------------------------------------------------
  1864.   def plus_state_set
  1865.     return []
  1866.   end
  1867.   #--------------------------------------------------------------------------
  1868.   # ● 获取普通攻击的状态变化 (-)
  1869.   #--------------------------------------------------------------------------
  1870.   def minus_state_set
  1871.     return []
  1872.   end
  1873.   #--------------------------------------------------------------------------
  1874.   # ● 获取行动
  1875.   #--------------------------------------------------------------------------
  1876.   def actions
  1877.     return $data_enemies[@enemy_id].actions
  1878.   end
  1879.   #--------------------------------------------------------------------------
  1880.   # ● 获取 EXP
  1881.   #--------------------------------------------------------------------------
  1882.   def exp
  1883.     return $data_enemies[@enemy_id].exp
  1884.   end
  1885.   #--------------------------------------------------------------------------
  1886.   # ● 获取金钱
  1887.   #--------------------------------------------------------------------------
  1888.   def gold
  1889.     return $data_enemies[@enemy_id].gold
  1890.   end
  1891.   #--------------------------------------------------------------------------
  1892.   # ● 获取物品 ID
  1893.   #--------------------------------------------------------------------------
  1894.   def item_id
  1895.     return $data_enemies[@enemy_id].item_id
  1896.   end
  1897.   #--------------------------------------------------------------------------
  1898.   # ● 获取武器 ID
  1899.   #--------------------------------------------------------------------------
  1900.   def weapon_id
  1901.     return $data_enemies[@enemy_id].weapon_id
  1902.   end
  1903.   #--------------------------------------------------------------------------
  1904.   # ● 获取放具 ID
  1905.   #--------------------------------------------------------------------------
  1906.   def armor_id
  1907.     return $data_enemies[@enemy_id].armor_id
  1908.   end
  1909.   #--------------------------------------------------------------------------
  1910.   # ● 获取宝物出现率
  1911.   #--------------------------------------------------------------------------
  1912.   def treasure_prob
  1913.     return $data_enemies[@enemy_id].treasure_prob
  1914.   end
  1915.   #--------------------------------------------------------------------------
  1916.   # ● 取得战斗画面 X 坐标
  1917.   #--------------------------------------------------------------------------
  1918.   def screen_x
  1919.     return $data_troops[@troop_id].members[@member_index].x*$width/640
  1920.   end
  1921.   #--------------------------------------------------------------------------
  1922.   # ● 取得战斗画面 Y 坐标
  1923.   #--------------------------------------------------------------------------
  1924.   def screen_y
  1925.     return $data_troops[@troop_id].members[@member_index].y*$height/480
  1926.   end
  1927.   #--------------------------------------------------------------------------
  1928.   # ● 取得战斗画面 Z 坐标
  1929.   #--------------------------------------------------------------------------
  1930.   def screen_z
  1931.     return screen_y
  1932.   end
  1933.   #--------------------------------------------------------------------------
  1934.   # ● 逃跑
  1935.   #--------------------------------------------------------------------------
  1936.   def escape
  1937.     # 设置击中标志
  1938.     @hidden = true
  1939.     # 清除当前行动
  1940.     self.current_action.clear
  1941.   end
  1942.   #--------------------------------------------------------------------------
  1943.   # ● 变身
  1944.   #     enemy_id : 变身为的敌人 ID
  1945.   #--------------------------------------------------------------------------
  1946.   def transform(enemy_id)
  1947.     # 更改敌人 ID
  1948.     @enemy_id = enemy_id
  1949.     # 更改战斗图形
  1950.     @battler_name = $data_enemies[@enemy_id].battler_name
  1951.     @battler_hue = $data_enemies[@enemy_id].battler_hue
  1952.     # 在生成行动
  1953.     make_action
  1954.   end
  1955.   #--------------------------------------------------------------------------
  1956.   # ● 生成行动
  1957.   #--------------------------------------------------------------------------
  1958.   def make_action
  1959.     # 清除当前行动
  1960.     self.current_action.clear
  1961.     # 无法行动的情况
  1962.     unless self.movable?
  1963.       # 过程结束
  1964.       return
  1965.     end
  1966.     # 抽取现在有效的行动
  1967.     available_actions = []
  1968.     rating_max = 0
  1969.     for action in self.actions
  1970.       # 确认回合条件
  1971.       n = $game_temp.battle_turn
  1972.       a = action.condition_turn_a
  1973.       b = action.condition_turn_b
  1974.       if (b == 0 and n != a) or
  1975.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  1976.         next
  1977.       end
  1978.       # 确认 HP 条件
  1979.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  1980.         next
  1981.       end
  1982.       # 确认等级条件
  1983.       if $game_party.max_level < action.condition_level
  1984.         next
  1985.       end
  1986.       # 确认开关条件
  1987.       switch_id = action.condition_switch_id
  1988.       if switch_id > 0 and $game_switches[switch_id] == false
  1989.         next
  1990.       end
  1991.       # 符合条件 : 添加本行动
  1992.       available_actions.push(action)
  1993.       if action.rating > rating_max
  1994.         rating_max = action.rating
  1995.       end
  1996.     end
  1997.     # 最大概率值作为 3 合计计算(0 除外)
  1998.     ratings_total = 0
  1999.     for action in available_actions
  2000.       if action.rating > rating_max - 3
  2001.         ratings_total += action.rating - (rating_max - 3)
  2002.       end
  2003.     end
  2004.     # 概率合计不为 0 的情况下
  2005.     if ratings_total > 0
  2006.       # 生成随机数
  2007.       value = rand(ratings_total)
  2008.       # 设置对应生成随机数的当前行动
  2009.       for action in available_actions
  2010.         if action.rating > rating_max - 3
  2011.           if value < action.rating - (rating_max - 3)
  2012.             self.current_action.kind = action.kind
  2013.             self.current_action.basic = action.basic
  2014.             self.current_action.skill_id = action.skill_id
  2015.             self.current_action.decide_random_target_for_enemy
  2016.             return
  2017.           else
  2018.             value -= action.rating - (rating_max - 3)
  2019.           end
  2020.         end
  2021.       end
  2022.     end
  2023.   end
  2024. end
  2025. #==============================================================================
  2026. # ■ Game_Map
  2027. #------------------------------------------------------------------------------
  2028. #  处理地图的类。包含卷动以及可以通行的判断功能。
  2029. # 本类的实例请参考 $game_map 。
  2030. #==============================================================================

  2031. class Game_Map
  2032.   #--------------------------------------------------------------------------
  2033.   # ● 定义实例变量
  2034.   #--------------------------------------------------------------------------
  2035.   attr_accessor :tileset_name             # 元件 文件名
  2036.   attr_accessor :autotile_names           # 自动元件 文件名
  2037.   attr_accessor :panorama_name            # 全景 文件名
  2038.   attr_accessor :panorama_hue             # 全景 色相
  2039.   attr_accessor :fog_name                 # 雾 文件名
  2040.   attr_accessor :fog_hue                  # 雾 色相
  2041.   attr_accessor :fog_opacity              # 雾 不透明度
  2042.   attr_accessor :fog_blend_type           # 雾 混合方式
  2043.   attr_accessor :fog_zoom                 # 雾 放大率
  2044.   attr_accessor :fog_sx                   # 雾 SX
  2045.   attr_accessor :fog_sy                   # 雾 SY
  2046.   attr_accessor :battleback_name          # 战斗背景 文件名
  2047.   attr_accessor :display_x                # 显示 X 坐标 * 128
  2048.   attr_accessor :display_y                # 显示 Y 坐标 * 128
  2049.   attr_accessor :need_refresh             # 刷新要求标志
  2050.   attr_reader   :passages                 # 通行表
  2051.   attr_reader   :priorities               # 优先表
  2052.   attr_reader   :terrain_tags             # 地形标记表
  2053.   attr_reader   :events                   # 事件
  2054.   attr_reader   :fog_ox                   # 雾 原点 X 坐标
  2055.   attr_reader   :fog_oy                   # 雾 原点 Y 坐标
  2056.   attr_reader   :fog_tone                 # 雾 色调
  2057.   #--------------------------------------------------------------------------
  2058.   # ● 初始化条件
  2059.   #--------------------------------------------------------------------------
  2060.   def initialize
  2061.     @map_id = 0
  2062.     @display_x = 0
  2063.     @display_y = 0
  2064.   end
  2065.   #--------------------------------------------------------------------------
  2066.   # ● 设置
  2067.   #     map_id : 地图 ID
  2068.   #--------------------------------------------------------------------------
  2069.   def setup(map_id)
  2070.     # 地图 ID 记录到 @map_id
  2071.     @map_id = map_id
  2072.     # 地图文件装载后、设置到 @map
  2073.     @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
  2074.     # 定义实例变量设置地图元件信息
  2075.     tileset = $data_tilesets[@map.tileset_id]
  2076.     @tileset_name = tileset.tileset_name
  2077.     @autotile_names = tileset.autotile_names
  2078.     @panorama_name = tileset.panorama_name
  2079.     @panorama_hue = tileset.panorama_hue
  2080.     @fog_name = tileset.fog_name
  2081.     @fog_hue = tileset.fog_hue
  2082.     @fog_opacity = tileset.fog_opacity
  2083.     @fog_blend_type = tileset.fog_blend_type
  2084.     @fog_zoom = tileset.fog_zoom
  2085.     @fog_sx = tileset.fog_sx
  2086.     @fog_sy = tileset.fog_sy
  2087.     @battleback_name = tileset.battleback_name
  2088.     @passages = tileset.passages
  2089.     @priorities = tileset.priorities
  2090.     @terrain_tags = tileset.terrain_tags
  2091.     # 初始化显示坐标
  2092.     @display_x = 0
  2093.     @display_y = 0
  2094.     # 清除刷新要求标志
  2095.     @need_refresh = false
  2096.     # 设置地图事件数据
  2097.     @events = {}
  2098.     for i in @map.events.keys
  2099.       @events[i] = Game_Event.new(@map_id, @map.events[i])
  2100.     end
  2101.     # 设置公共事件数据
  2102.     @common_events = {}
  2103.     for i in 1...$data_common_events.size
  2104.       @common_events[i] = Game_CommonEvent.new(i)
  2105.     end
  2106.     # 初始化雾的各种信息
  2107.     @fog_ox = 0
  2108.     @fog_oy = 0
  2109.     @fog_tone = Tone.new(0, 0, 0, 0)
  2110.     @fog_tone_target = Tone.new(0, 0, 0, 0)
  2111.     @fog_tone_duration = 0
  2112.     @fog_opacity_duration = 0
  2113.     @fog_opacity_target = 0
  2114.     # 初始化滚动信息
  2115.     @scroll_direction = 2
  2116.     @scroll_rest = 0
  2117.     @scroll_speed = 4
  2118.   end
  2119.   #--------------------------------------------------------------------------
  2120.   # ● 获取地图 ID
  2121.   #--------------------------------------------------------------------------
  2122.   def map_id
  2123.     return @map_id
  2124.   end
  2125.   #--------------------------------------------------------------------------
  2126.   # ● 获取宽度
  2127.   #--------------------------------------------------------------------------
  2128.   def width
  2129.     return @map.width
  2130.   end
  2131.   #--------------------------------------------------------------------------
  2132.   # ● 获取高度
  2133.   #--------------------------------------------------------------------------
  2134.   def height
  2135.     return @map.height
  2136.   end
  2137.   #--------------------------------------------------------------------------
  2138.   # ● 获取遇敌列表
  2139.   #--------------------------------------------------------------------------
  2140.   def encounter_list
  2141.     return @map.encounter_list
  2142.   end
  2143.   #--------------------------------------------------------------------------
  2144.   # ● 获取遇敌步数
  2145.   #--------------------------------------------------------------------------
  2146.   def encounter_step
  2147.     return @map.encounter_step
  2148.   end
  2149.   #--------------------------------------------------------------------------
  2150.   # ● 获取地图数据
  2151.   #--------------------------------------------------------------------------
  2152.   def data
  2153.     return @map.data
  2154.   end
  2155.   #--------------------------------------------------------------------------
  2156.   # ● BGM / BGS 自动切换
  2157.   #--------------------------------------------------------------------------
  2158.   def autoplay
  2159.     if @map.autoplay_bgm
  2160.       $game_system.bgm_play(@map.bgm)
  2161.     end
  2162.     if @map.autoplay_bgs
  2163.       $game_system.bgs_play(@map.bgs)
  2164.     end
  2165.   end
  2166.   #--------------------------------------------------------------------------
  2167.   # ● 刷新
  2168.   #--------------------------------------------------------------------------
  2169.   def refresh
  2170.     # 地图 ID 有效
  2171.     if @map_id > 0
  2172.       # 刷新全部的地图事件
  2173.       for event in @events.values
  2174.         event.refresh
  2175.       end
  2176.       # 刷新全部的公共事件
  2177.       for common_event in @common_events.values
  2178.         common_event.refresh
  2179.       end
  2180.     end
  2181.     # 清除刷新要求标志
  2182.     @need_refresh = false
  2183.   end
  2184.   #--------------------------------------------------------------------------
  2185.   # ● 滚动
  2186.   #     distance : 滚动距离
  2187.   #--------------------------------------------------------------------------
  2188.   def scroll_down(distance)
  2189.     @display_y = [@display_y + distance, (self.height - ($height / 32.0)) * 128].min
  2190.   end
  2191.   #--------------------------------------------------------------------------
  2192.   def scroll_left(distance)
  2193.     @display_x = [@display_x - distance, 0].max
  2194.   end
  2195.   #--------------------------------------------------------------------------
  2196.   def scroll_right(distance)
  2197.     @display_x = [@display_x + distance, (self.width - ($width / 32.0)) * 128].min
  2198.   end
  2199.   #--------------------------------------------------------------------------
  2200.   def scroll_up(distance)
  2201.     @display_y = [@display_y - distance, 0].max
  2202.   end
  2203.   #--------------------------------------------------------------------------
  2204.   # ● 有效坐标判定
  2205.   #     x          : X 坐标
  2206.   #     y          : Y 坐标
  2207.   #--------------------------------------------------------------------------
  2208.   def valid?(x, y)
  2209.     return (x >= 0 and x < width and y >= 0 and y < height)
  2210.   end
  2211.   #--------------------------------------------------------------------------
  2212.   # ● 可以通行判定
  2213.   #     x          : X 坐标
  2214.   #     y          : Y 坐标
  2215.   #     d          : 方向 (0,2,4,6,8,10)
  2216.   #                  ※ 0,10 = 全方向不能通行的情况的判定 (跳跃等)
  2217.   #     self_event : 自己 (判定事件可以通行的情况下)
  2218.   #--------------------------------------------------------------------------
  2219.   def passable?(x, y, d, self_event = nil)
  2220.     # 被给予的坐标地图外的情况下
  2221.     unless valid?(x, y)
  2222.       # 不能通行
  2223.       return false
  2224.     end
  2225.     # 方向 (0,2,4,6,8,10) 与障碍物接触 (0,1,2,4,8,0) 后变换
  2226.     bit = (1 << (d / 2 - 1)) & 0x0f
  2227.     # 循环全部的事件
  2228.     for event in events.values
  2229.       # 自己以外的元件与坐标相同的情况
  2230.       if event.tile_id >= 0 and event != self_event and
  2231.          event.x == x and event.y == y and not event.through
  2232.         # 如果障碍物的接触被设置的情况下
  2233.         if @passages[event.tile_id] & bit != 0
  2234.           # 不能通行
  2235.           return false
  2236.         # 如果全方向的障碍物的接触被设置的情况下
  2237.         elsif @passages[event.tile_id] & 0x0f == 0x0f
  2238.           # 不能通行
  2239.           return false
  2240.         # 这以外的优先度为 0 的情况下
  2241.         elsif @priorities[event.tile_id] == 0
  2242.           # 可以通行
  2243.           return true
  2244.         end
  2245.       end
  2246.     end
  2247.     # 从层按从上到下的顺序调查循环
  2248.     for i in [2, 1, 0]
  2249.       # 取得元件 ID
  2250.       tile_id = data[x, y, i]
  2251.       # 取得元件 ID 失败
  2252.       if tile_id == nil
  2253.         # 不能通行
  2254.         return false
  2255.       # 如果障碍物的接触被设置的情况下
  2256.       elsif @passages[tile_id] & bit != 0
  2257.         # 不能通行
  2258.         return false
  2259.       # 如果全方向的障碍物的接触被设置的情况下
  2260.       elsif @passages[tile_id] & 0x0f == 0x0f
  2261.         # 不能通行
  2262.         return false
  2263.       # 这以外的优先度为 0 的情况下
  2264.       elsif @priorities[tile_id] == 0
  2265.         # 可以通行
  2266.         return true
  2267.       end
  2268.     end
  2269.     # 可以通行
  2270.     return true
  2271.   end
  2272.   #--------------------------------------------------------------------------
  2273.   # ● 茂密判定
  2274.   #     x          : X 坐标
  2275.   #     y          : Y 坐标
  2276.   #--------------------------------------------------------------------------
  2277.   def bush?(x, y)
  2278.     if @map_id != 0
  2279.       for i in [2, 1, 0]
  2280.         tile_id = data[x, y, i]
  2281.         if tile_id == nil
  2282.           return false
  2283.         elsif @passages[tile_id] & 0x40 == 0x40
  2284.           return true
  2285.         end
  2286.       end
  2287.     end
  2288.     return false
  2289.   end
  2290.   #--------------------------------------------------------------------------
  2291.   # ● 反击判定
  2292.   #     x          : X 坐标
  2293.   #     y          : Y 坐标
  2294.   #--------------------------------------------------------------------------
  2295.   def counter?(x, y)
  2296.     if @map_id != 0
  2297.       for i in [2, 1, 0]
  2298.         tile_id = data[x, y, i]
  2299.         if tile_id == nil
  2300.           return false
  2301.         elsif @passages[tile_id] & 0x80 == 0x80
  2302.           return true
  2303.         end
  2304.       end
  2305.     end
  2306.     return false
  2307.   end
  2308.   #--------------------------------------------------------------------------
  2309.   # ● 地获取地形标志
  2310.   #     x          : X 坐标
  2311.   #     y          : Y 坐标
  2312.   #--------------------------------------------------------------------------
  2313.   def terrain_tag(x, y)
  2314.     if @map_id != 0
  2315.       for i in [2, 1, 0]
  2316.         tile_id = data[x, y, i]
  2317.         if tile_id == nil
  2318.           return 0
  2319.         elsif @terrain_tags[tile_id] > 0
  2320.           return @terrain_tags[tile_id]
  2321.         end
  2322.       end
  2323.     end
  2324.     return 0
  2325.   end
  2326.   #--------------------------------------------------------------------------
  2327.   # ● 获取指定位置的事件 ID
  2328.   #     x          : X 坐标
  2329.   #     y          : Y 坐标
  2330.   #--------------------------------------------------------------------------
  2331.   def check_event(x, y)
  2332.     for event in $game_map.events.values
  2333.       if event.x == x and event.y == y
  2334.         return event.id
  2335.       end
  2336.     end
  2337.   end
  2338.   #--------------------------------------------------------------------------
  2339.   # ● 滚动开始
  2340.   #     direction : 滚动方向
  2341.   #     distance  : 滚动距离
  2342.   #     speed     : 滚动速度
  2343.   #--------------------------------------------------------------------------
  2344.   def start_scroll(direction, distance, speed)
  2345.     @scroll_direction = direction
  2346.     @scroll_rest = distance * 128
  2347.     @scroll_speed = speed
  2348.   end
  2349.   #--------------------------------------------------------------------------
  2350.   # ● 滚动中判定
  2351.   #--------------------------------------------------------------------------
  2352.   def scrolling?
  2353.     return @scroll_rest > 0
  2354.   end
  2355.   #--------------------------------------------------------------------------
  2356.   # ● 开始变更雾的色调
  2357.   #     tone     : 色调
  2358.   #     duration : 时间
  2359.   #--------------------------------------------------------------------------
  2360.   def start_fog_tone_change(tone, duration)
  2361.     @fog_tone_target = tone.clone
  2362.     @fog_tone_duration = duration
  2363.     if @fog_tone_duration == 0
  2364.       @fog_tone = @fog_tone_target.clone
  2365.     end
  2366.   end
  2367.   #--------------------------------------------------------------------------
  2368.   # ● 开始变更雾的不透明度
  2369.   #     opacity  : 不透明度
  2370.   #     duration : 时间
  2371.   #--------------------------------------------------------------------------
  2372.   def start_fog_opacity_change(opacity, duration)
  2373.     @fog_opacity_target = opacity * 1.0
  2374.     @fog_opacity_duration = duration
  2375.     if @fog_opacity_duration == 0
  2376.       @fog_opacity = @fog_opacity_target
  2377.     end
  2378.   end
  2379.   #--------------------------------------------------------------------------
  2380.   # ● 刷新画面
  2381.   #--------------------------------------------------------------------------
  2382.   def update
  2383.     # 还原必要的地图
  2384.     if $game_map.need_refresh
  2385.       refresh
  2386.     end
  2387.     # 滚动中的情况下
  2388.     if @scroll_rest > 0
  2389.       # 滚动速度变化为地图坐标系的距离
  2390.       distance = 2 ** @scroll_speed
  2391.       # 执行滚动
  2392.       case @scroll_direction
  2393.       when 2  # 下
  2394.         scroll_down(distance)
  2395.       when 4  # 左
  2396.         scroll_left(distance)
  2397.       when 6  # 右
  2398.         scroll_right(distance)
  2399.       when 8  # 上
  2400.         scroll_up(distance)
  2401.       end
  2402.       # 滚动距离的减法运算
  2403.       @scroll_rest -= distance
  2404.     end
  2405.     # 更新地图事件
  2406.     for event in @events.values
  2407.       event.update
  2408.     end
  2409.     # 更新公共事件
  2410.     for common_event in @common_events.values
  2411.       common_event.update
  2412.     end
  2413.     # 处理雾的滚动
  2414.     @fog_ox -= @fog_sx / 8.0
  2415.     @fog_oy -= @fog_sy / 8.0
  2416.     # 处理雾的色调变更
  2417.     if @fog_tone_duration >= 1
  2418.       d = @fog_tone_duration
  2419.       target = @fog_tone_target
  2420.       @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
  2421.       @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
  2422.       @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
  2423.       @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
  2424.       @fog_tone_duration -= 1
  2425.     end
  2426.     # 处理雾的不透明度变更
  2427.     if @fog_opacity_duration >= 1
  2428.       d = @fog_opacity_duration
  2429.       @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
  2430.       @fog_opacity_duration -= 1
  2431.     end
  2432.   end
  2433. end
  2434. #==============================================================================
  2435. # ■ Sprite_Character
  2436. #------------------------------------------------------------------------------
  2437. #  角色显示用脚本。监视 Game_Character 类的实例、
  2438. # 自动变化脚本状态。
  2439. #==============================================================================

  2440. class Sprite_Character < RPG::Sprite
  2441.   #--------------------------------------------------------------------------
  2442.   # ● 定义实例变量
  2443.   #--------------------------------------------------------------------------
  2444.   attr_accessor :character                # 角色
  2445.   #--------------------------------------------------------------------------
  2446.   # ● 初始化对像
  2447.   #     viewport  : 查看端口
  2448.   #     character : 角色 (Game_Character)
  2449.   #--------------------------------------------------------------------------
  2450.   def initialize(viewport, character = nil)
  2451.     super(viewport)
  2452.     @vp = viewport
  2453.     @character = character
  2454.     update
  2455.   end
  2456.   #--------------------------------------------------------------------------
  2457.   # ● 更新画面
  2458.   #--------------------------------------------------------------------------
  2459.   def update
  2460.     super
  2461.     # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  2462.     if @tile_id != @character.tile_id or
  2463.        @character_name != @character.character_name or
  2464.        @character_hue != @character.character_hue
  2465.       # 记忆元件 ID 与文件名、色相
  2466.       @tile_id = @character.tile_id
  2467.       @character_name = @character.character_name
  2468.       @character_hue = @character.character_hue
  2469.       # 元件 ID 为有效值的情况下
  2470.       if @tile_id >= 384
  2471.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  2472.           @tile_id, @character.character_hue)
  2473.         self.src_rect.set(0, 0, 32, 32)
  2474.         self.ox = 16
  2475.         self.oy = 32
  2476.       # 元件 ID 为无效值的情况下
  2477.       else
  2478.         self.bitmap = RPG::Cache.character(@character.character_name,
  2479.           @character.character_hue)
  2480.         @cw = bitmap.width / 4
  2481.         @ch = bitmap.height / 4
  2482.         self.ox = @cw / 2
  2483.         self.oy = @ch
  2484.       end
  2485.     end
  2486.     # 设置可视状态
  2487.     self.visible = (not @character.transparent)
  2488.     # 图形是角色的情况下
  2489.     if @tile_id == 0
  2490.       # 设置传送目标的矩形
  2491.       sx = @character.pattern * @cw
  2492.       sy = (@character.direction - 2) / 2 * @ch
  2493.       self.src_rect.set(sx, sy, @cw, @ch)
  2494.     end
  2495.     # 设置脚本的坐标
  2496.     self.x = @character.screen_x
  2497.     #if @character == $game_player
  2498.       if @vp == $viewport5 or @vp == $viewport6
  2499.         self.y = @character.screen_y-480
  2500.         self.z = @character.screen_z(@ch)-480
  2501.       else
  2502.         self.y = @character.screen_y
  2503.         self.z = @character.screen_z(@ch)
  2504.       end
  2505.     #else
  2506.       #self.y = @character.screen_y
  2507.       #self.z = @character.screen_z(@ch)
  2508.     #end
  2509.     # 设置不透明度、合成方式、茂密
  2510.     self.opacity = @character.opacity
  2511.     self.blend_type = @character.blend_type
  2512.     self.bush_depth = @character.bush_depth
  2513.     # 动画
  2514.     if @character.animation_id != 0
  2515.       animation = $data_animations[@character.animation_id]
  2516.       animation(animation, true)
  2517.       @character.animation_id = 0
  2518.     end
  2519.   end
  2520. end

  2521.   class Weather
  2522.     def initialize(viewport = nil)
  2523.       @type = 0
  2524.       @max = 0
  2525.       @ox = 0
  2526.       @oy = 0
  2527.       color1 = Color.new(255, 255, 255, 255)
  2528.       color2 = Color.new(255, 255, 255, 128)
  2529.       @rain_bitmap = Bitmap.new(7, 56)
  2530.       for i in 0..6
  2531.         @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1)
  2532.       end
  2533.       @storm_bitmap = Bitmap.new(34, 64)
  2534.       for i in 0..31
  2535.         @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2)
  2536.         @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1)
  2537.         @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2)
  2538.       end
  2539.       @snow_bitmap = Bitmap.new(6, 6)
  2540.       @snow_bitmap.fill_rect(0, 1, 6, 4, color2)
  2541.       @snow_bitmap.fill_rect(1, 0, 4, 6, color2)
  2542.       @snow_bitmap.fill_rect(1, 2, 4, 2, color1)
  2543.       @snow_bitmap.fill_rect(2, 1, 2, 4, color1)
  2544.       @sprites = []
  2545.       for i in 1..40
  2546.         sprite = Sprite.new(viewport)
  2547.         sprite.z = 1000
  2548.         sprite.visible = false
  2549.         sprite.opacity = 0
  2550.         @sprites.push(sprite)
  2551.       end
  2552.     end
  2553.     def dispose
  2554.       for sprite in @sprites
  2555.         sprite.dispose
  2556.       end
  2557.       @rain_bitmap.dispose
  2558.       @storm_bitmap.dispose
  2559.       @snow_bitmap.dispose
  2560.     end
  2561.     def type=(type)
  2562.       return if @type == type
  2563.       @type = type
  2564.       case @type
  2565.       when 1
  2566.         bitmap = @rain_bitmap
  2567.       when 2
  2568.         bitmap = @storm_bitmap
  2569.       when 3
  2570.         bitmap = @snow_bitmap
  2571.       else
  2572.         bitmap = nil
  2573.       end
  2574.       for i in 1..40
  2575.         sprite = @sprites[i]
  2576.         if sprite != nil
  2577.           sprite.visible = (i <= @max)
  2578.           sprite.bitmap = bitmap
  2579.         end
  2580.       end
  2581.     end
  2582.     def ox=(ox)
  2583.       return if @ox == ox;
  2584.       @ox = ox
  2585.       for sprite in @sprites
  2586.         sprite.ox = @ox
  2587.       end
  2588.     end
  2589.     def oy=(oy)
  2590.       return if @oy == oy;
  2591.       @oy = oy
  2592.       for sprite in @sprites
  2593.         sprite.oy = @oy
  2594.       end
  2595.     end
  2596.     def max=(max)
  2597.       return if @max == max;
  2598.       @max = [[max, 0].max, 40].min
  2599.       for i in 1..40
  2600.         sprite = @sprites[i]
  2601.         if sprite != nil
  2602.           sprite.visible = (i <= @max)
  2603.         end
  2604.       end
  2605.     end
  2606.     def update
  2607.       return if @type == 0
  2608.       for i in 1..@max
  2609.         sprite = @sprites[i]
  2610.         if sprite == nil
  2611.           break
  2612.         end
  2613.         if @type == 1
  2614.           sprite.x -= 2
  2615.           sprite.y += 16
  2616.           sprite.opacity -= 8
  2617.         end
  2618.         if @type == 2
  2619.           sprite.x -= 8
  2620.           sprite.y += 16
  2621.           sprite.opacity -= 12
  2622.         end
  2623.         if @type == 3
  2624.           sprite.x -= 2
  2625.           sprite.y += 8
  2626.           sprite.opacity -= 8
  2627.         end
  2628.         x = sprite.x - @ox
  2629.         y = sprite.y - @oy
  2630.         if sprite.opacity < 64 or x < -50 or x > $width+150 or y < -300 or y > $height+100
  2631.           sprite.x = rand($width+150) - 50 + @ox
  2632.           sprite.y = rand($height+100) - 200 + @oy
  2633.           sprite.opacity = 255
  2634.         end
  2635.       end
  2636.     end
  2637.     attr_reader :type
  2638.     attr_reader :max
  2639.     attr_reader :ox
  2640.     attr_reader :oy
  2641.   end
复制代码
寻路算法
  1. #==============================================================================
  2. # ■ Find_Path
  3. #------------------------------------------------------------------------------
  4. #  寻路算法--完整鼠标系统(四方向)专用版
  5. #   By whbm
  6. #==============================================================================
  7. class Find_Path
  8. #--------------------------------------------------------------------------
  9. def initialize  #初始化
  10. @open_list = []
  11. @close_lise = []
  12. @path = []
  13. end  #结束初始化
  14. #--------------------------------------------------------------------------
  15. def fp_passable?(x, y, d, tr_x = -2, tr_y = -2)  #开始判定通行
  16. return false if (tr_x == @unable_xa or
  17.                  tr_x == @unable_xb or
  18.                  tr_y == @unable_ya or
  19.                  tr_y == @unable_yb)
  20. if [2, 4, 6, 8].include?(d)
  21.    if $game_player.passable?(x, y, d)
  22.      return true
  23.    else
  24.      return false
  25.    end
  26. end
  27. end  #结束判定通行
  28. #--------------------------------------------------------------------------
  29. def get_g(now_point)  #开始计算G值
  30. d = now_point[2]
  31. return 0 if d == 5
  32. father_point = get_father_point(now_point)
  33. g = father_point[3] + 10
  34. return g
  35. end  #结束计算G值
  36. #--------------------------------------------------------------------------
  37. def get_h(now_point)  #开始计算H值
  38. now_x = now_point[0]
  39. now_y = now_point[1]
  40. #print @trg_x,now_x,@trg_y,now_y
  41. h = (@trg_x - now_x).abs + (@trg_y - now_y).abs
  42. return h * 10
  43. end  #结束计算H值
  44. #--------------------------------------------------------------------------
  45. def get_f(now_point)  #开始计算F值
  46. f = now_point[3] + now_point[4]
  47. return f
  48. end  #结束计算F值
  49. #--------------------------------------------------------------------------
  50. def get_point(x, y) #取已知坐标点
  51. if @open_list.size != 0
  52.    @open_list.each do |point|
  53.      if point[0] == x and point[1] == y
  54.        return point
  55.        break
  56.      end
  57.    end
  58. end
  59. if @close_list.size != 0
  60.    @close_list.each do |point|
  61.      if point[0] == x and point[1] == y
  62.        return point
  63.        break
  64.      end
  65.    end
  66. end
  67. end  #结束取已知坐标点
  68. #--------------------------------------------------------------------------
  69. def get_father_point(now_point)  #取已知点的父节点
  70. d = now_point[2]
  71. return now_point if d == 5
  72. x = now_point[0] + (d == 6 ? 1 : (d == 4 ? -1 : 0))
  73. y = now_point[1] + (d == 2 ? 1 : (d == 8 ? -1 : 0))
  74. return get_point(x, y)
  75. end  #结束取已知点的父节点
  76. #--------------------------------------------------------------------------
  77. def new_point(x, y, d)  #开始建立新节点
  78. #print x,y,d
  79. point = [x, y, d]
  80. point.push get_g(point)
  81. point.push get_h(point)
  82. point.push get_f(point)
  83. return point
  84. end  #结束建立新节点
  85. #--------------------------------------------------------------------------
  86. def get_direction(self_x, self_y, trg_x, trg_y)
  87.   if trg_x > self_x
  88.     if trg_y - self_y > -  ( trg_x - self_x ) and
  89.       trg_y - self_y < ( trg_x - self_x )
  90.       return 6
  91.     end
  92.     if trg_y - self_y > ( trg_x - self_x )
  93.       return 2
  94.     end
  95.     if trg_y - self_y < - ( trg_x - self_x )
  96.       return 8
  97.     end
  98.   end
  99.   if trg_x < self_x
  100.     if trg_y - self_y > - ( self_x - trg_x ) and
  101.       trg_y - self_y < ( self_x - trg_x )
  102.       return 4
  103.     end
  104.     if trg_y - self_y > ( self_x - trg_x )
  105.       return 2
  106.     end
  107.     if trg_y - self_y < - ( self_x - trg_x )
  108.       return 8
  109.     end
  110.   end
  111. end
  112. #--------------------------------------------------------------------------
  113. def get_d_x_y(x, y, d)
  114.   d_x = x + (d == 6 ? 1 : (d == 4 ? -1 : 0))
  115.   d_y = y + (d == 2 ? 1 : (d == 8 ? -1 : 0))
  116.   return d_x, d_y
  117. end
  118. #--------------------------------------------------------------------------
  119. def find_short_path_other(self_x, self_y, trg_x, trg_y,
  120.                           real_self_x, real_self_y, real_trg_x, real_trg_y)
  121.   @self_x = self_x
  122.   @self_y = self_y
  123.   @now_x = self_x
  124.   @now_y = self_y
  125.   @trg_x = trg_x
  126.   @trg_y = trg_y
  127.   @path = []
  128.   direction = get_direction(real_self_x, real_self_y, real_trg_x, real_trg_y)
  129.   @now_trg_x, @now_trg_y = get_d_x_y(@self_x, @self_y, direction)
  130.   while fp_passable?(@now_x, @now_y, direction)
  131.     @path.push direction
  132.     @now_x = @now_trg_x
  133.     @now_y = @now_trg_y
  134.     @now_trg_x, @now_trg_y = get_d_x_y(@now_x, @now_y, direction)
  135.   end
  136.   return @path
  137. end
  138. #--------------------------------------------------------------------------
  139. def find_short_path(self_x, self_y, trg_x, trg_y,
  140.                     real_self_x, real_self_y, real_trg_x, real_trg_y)  #开始搜索路径
  141.   
  142. return find_short_path_other(self_x, self_y, trg_x, trg_y,
  143.                               real_self_x, real_self_y, real_trg_x, real_trg_y) if not
  144.                   (fp_passable?(trg_x, trg_y + 1, 8) or
  145.                    fp_passable?(trg_x + 1, trg_y, 4) or
  146.                    fp_passable?(trg_x - 1, trg_y, 6) or
  147.                    fp_passable?(trg_x, trg_y - 1, 2)) and @goal_type != 1
  148.                   
  149.                   
  150.   #根据屏幕限定搜索面积..加速
  151. @unable_xa = $game_map.display_x / 128 - 1
  152. @unable_ya = $game_map.display_y / 128 - 1
  153. @unable_xb = $game_map.display_x / 128 + 20
  154. @unable_yb = $game_map.display_y / 128 + 20


  155. @self_x = self_x
  156. @self_y = self_y
  157. @now_x = self_x
  158. @now_y = self_y
  159. @trg_x = trg_x
  160. @trg_y = trg_y
  161. @open_list = []
  162. @close_list = []
  163. #准备搜索
  164. #print @self_x,@self_y
  165. @now_point = new_point(@self_x, @self_y, 5) #令起始点为当前点
  166. @open_list.push @now_point #将当前点加入关闭列表
  167. #开始搜索
  168. begin
  169. loop do
  170.    check_trg = check_around_point(@now_point)
  171.    if check_trg == true
  172.      @path = get_path
  173.      break
  174.    end
  175.    @now_point = get_lowest_f_point
  176.    if @now_point == [] or @now_point == nil
  177.      @path = []
  178.      break
  179.    end
  180. end
  181. rescue Hangup
  182.   retry
  183. end
  184. return @path
  185. end  #结束搜索路径
  186. #--------------------------------------------------------------------------
  187. def find_player_short_path(trg_x, trg_y,
  188.                            real_trg_x, real_trg_y)  #寻找角色的最短路径
  189. self_x = $game_player.x
  190. self_y = $game_player.y
  191. real_self_x = $game_player.screen_x
  192. real_self_y = $game_player.screen_y
  193. @goal_type, event = $game_map.check_event_custom_exist(real_trg_x, real_trg_y)
  194. if @goal_type == 1
  195.    trg_x = event.x
  196.    trg_y = event.y
  197. end
  198. return find_short_path(self_x, self_y, trg_x, trg_y,
  199.                         real_self_x, real_self_y, real_trg_x, real_trg_y)
  200. end  #结束角色的寻找路径
  201. #--------------------------------------------------------------------------
  202. def get_path  #取得最终的路径
  203. path = []
  204. now_point = @open_list[@open_list.size - 1]
  205. path.push(10 - now_point[2])
  206. last_point = now_point
  207. loop do
  208.    now_point = get_father_point(now_point)
  209.    break if now_point[2] == 5
  210.    path.push(10 - now_point[2])
  211. end
  212. return path.reverse
  213. end  #结束取得最终的路径
  214. #--------------------------------------------------------------------------
  215. def get_lowest_f_point  #开始取得最低F值的点
  216. if @open_list == []
  217.    return []
  218. end
  219. last_lowest_f_point = @open_list[0]
  220. @open_list.each do |point|
  221.    last_lowest_f_point = point if point[5] < last_lowest_f_point[5]
  222. end
  223. return last_lowest_f_point
  224. end  #结束取得最低F值点
  225. #--------------------------------------------------------------------------
  226. def check_around_point(point)  #开始检查已知点的八方节点
  227. for d in [1, 2, 3, 4, 6, 7, 8, 9]
  228.    x = point[0] + ((d == 9 or d == 6 or d == 3) ? 1 : ((d == 7 or d == 4 or d == 1) ? -1 : 0))
  229.    y = point[1] + ((d == 1 or d == 2 or d == 3) ? 1 : ((d == 7 or d == 8 or d == 9) ? -1 : 0))
  230.    if in_close_list?(x, y) #在关闭列表中
  231.      next
  232.    elsif in_open_list?(x, y) #在开启列表中
  233.      get_new_g_point = new_point(x, y, 10 - d)
  234.      get_last_g_point = get_point(x, y)
  235.      if get_new_g_point[3] >= get_last_g_point[3]
  236.        next
  237.      else
  238.        #如果改变父节点是新G值更小则确定改变
  239.        @open_list[@open_list.index(get_last_g_point)] = get_new_g_point
  240.      end
  241.    else
  242.      if fp_passable?(point[0], point[1], d, x, y)
  243.        # 如果不在开启列表中、且不在关闭列表中、且通行则添加它到新八周节点
  244.        @open_list.push new_point(x, y, 10 - d)
  245.        #如果将目标点添加到了开启列表中就返回true
  246.        return true if x == @trg_x and y == @trg_y
  247.        return true if @goal_type == 1 and [1, 0, -1].include?(x - @trg_x) and [1, 0, -1].include?(y - @trg_y)
  248.      end
  249.    end
  250. end
  251. #此刻没有找到目标点并将当前点加入关闭列表并在开启列表中删除
  252. @close_list.push point
  253. @open_list.delete(point)
  254. #此刻没找到目标点并返回false
  255. return false
  256. end  #结束计算已知点的八方节点
  257. #--------------------------------------------------------------------------
  258. def in_open_list?(x, y)  #开始检查谋点是否在开启列表中
  259. @open_list.each do |point|
  260.    return true if point[0] == x and point[1] == y
  261. end
  262. return false
  263. end  #结束检查谋点是否在开启列表中
  264. #--------------------------------------------------------------------------
  265. def in_close_list?(x, y)  #开始检查谋点是否在关闭列表中
  266. @close_list.each do |point|
  267.    return true if point[0] == x and point[1] == y
  268. end
  269. return false
  270. end  #结束检查谋点是否在关闭列表中
  271. #--------------------------------------------------------------------------
  272. end
复制代码
鼠标脚本
  1. #==============================================================================
  2. # ■ 完整鼠标系统(四方向)
  3. #------------------------------------------------------------------------------
  4. #  使用时务必配合专用寻路算法
  5. #   By whbm
  6. #==============================================================================
  7. #下面做一下介绍与使用说明:
  8. #    在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
  9. #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
  10. #后果了吧)
  11. #    在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
  12. #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
  13. #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
  14. #点,那时在单击NPC即可。
  15. #    当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
  16. #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
  17. #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
  18. #那两个注释。
  19. #    当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
  20. #==============================================================================
  21. class Game_Event
  22.   attr_accessor :flag
  23. end
  24. #==============================================================================
  25. # ■ Game_Map
  26. #------------------------------------------------------------------------------
  27. #  处理地图的类。包含卷动以及可以通行的判断功能。
  28. # 本类的实例请参考 $game_map 。
  29. #==============================================================================
  30. class Game_Map
  31.   #--------------------------------------------------------------------------
  32.   # ● 检查鼠标处是否有自定义的事件并返回类型
  33.   #--------------------------------------------------------------------------
  34.   def check_event_custom(mouse_x, mouse_y)
  35.     for event in $game_map.events.values #循环所有事件检查
  36.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / 4
  37.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 4
  38.       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
  39.         for i in 0...event.list.size
  40.           if event.list[i].parameters[0] == "Item" #类型判断
  41.             event.flag = 1
  42.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  43.             event.flag = 2
  44.           else
  45.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  46.           end
  47.           return event.flag #返回事件类型标志
  48.         end
  49.       end
  50.     end
  51.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  52.     return $mouse_icon_id #使鼠标图不变化
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 检查鼠标处是否有事件可以开启
  56.   #--------------------------------------------------------------------------
  57.   def check_event_custom_start(mouse_x, mouse_y)
  58.     for event in $game_map.events.values #循环所有事件检查
  59.       #事件角色图片宽度、高度
  60.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  61.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  62.       #判断是否鼠标在事件上
  63.       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
  64.         way_x = $game_player.x - event.x
  65.         way_y = $game_player.y - event.y
  66.         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)
  67.           for i in 0...event.list.size
  68.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  69.               #判断主角朝向
  70.               if way_x == -1
  71.                 p_direction = 6 if way_y == 0
  72.               elsif way_x == 0
  73.                 p_direction = 2 if way_y == -1
  74.                 p_direction = 8 if way_y == 1
  75.               else
  76.                 p_direction = 4 if way_y == 0
  77.               end
  78.               event.start #开启事件
  79.               return 1, p_direction #返回即将开启事件以及角色朝向
  80.             end
  81.           end
  82.         end
  83.       end
  84.     end
  85.     return 0, 5 #返回不会开启事件以及角色朝向不变
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  89.   #--------------------------------------------------------------------------
  90.   def check_event_custom_exist(mouse_x, mouse_y)
  91.     for event in $game_map.events.values #循环所有事件检查
  92.       #事件角色图片宽度、高度
  93.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  94.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  95.       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
  96.         for i in 0...event.list.size
  97.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  98.         end
  99.       end
  100.     end
  101.     return 0, event #返回不存在自定义事件,以及事件体
  102.   end
  103. end


  104. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  105. $敌人选框扩大 = 20
  106. $角色选框扩大 = 30


  107. #==============================================================================
  108. # ● API调用
  109. #==============================================================================
  110. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  111. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  112. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  113. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  114. $Window_HWND = $GetActiveWindow.call
  115. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  116. module Mouse  
  117. LEFT = 0x01
  118. RIGHT = 0x02

  119. def self.init(sprite = nil)
  120.    $ShowCursor.call(0)
  121.    
  122.    @show_cursor = false
  123.    
  124.    @mouse_sprite = Sprite.new
  125.    @mouse_sprite.z = 99999
  126.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')

  127.    @left_press = false
  128.    @right_press = false
  129.    @left_trigger = false
  130.    @right_trigger = false
  131.    @left_repeat = false
  132.    @right_repeat = false
  133.    @click_lock = false
  134.    
  135.    update
  136. end
  137. def self.exit
  138.    @mouse_sprite.bitmap.dispose
  139.    @mouse_sprite.dispose
  140.    @show_cursor = true
  141.    $ShowCursor.call(1)
  142. end
  143. def self.mouse_debug
  144.    return @mouse_debug.bitmap
  145. end
  146. def self.update
  147.    left_down = $GetKeyState.call(0x01)
  148.    right_down = $GetKeyState.call(0x02)
  149.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  150.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  151.      @a = !@a
  152.    end
  153.    if $scene.is_a?(Scene_Map) == false
  154.      $mouse_icon_id = 0
  155.    end
  156.    if $mouse_icon_id != $mouse_icon_id_last
  157.      case $mouse_icon_id
  158.      when 1
  159.        if @a
  160.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
  161.        else
  162.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
  163.        end
  164.      when 2
  165.        if @a
  166.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
  167.        else
  168.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
  169.        end
  170.      when 11
  171.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
  172.      when 12
  173.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
  174.      when 13
  175.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
  176.      when 14
  177.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
  178.      when 16
  179.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
  180.      when 17
  181.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
  182.      when 18
  183.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
  184.      when 19
  185.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
  186.      when 0
  187.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标1')
  188.      end
  189.      $mouse_icon_id_last = $mouse_icon_id
  190.    end
  191.    @click_lock = false
  192.    mouse_x, mouse_y = self.get_mouse_pos
  193.    if @mouse_sprite != nil
  194.      @mouse_sprite.x = mouse_x
  195.      @mouse_sprite.y = mouse_y
  196.    end
  197.    if left_down[7] == 1
  198.      @left_repeat = (not @left_repeat)
  199.      @left_trigger = (not @left_press)
  200.      @left_press = true
  201.    else
  202.      @left_press = false
  203.      @left_trigger = false
  204.      @left_repeat = false
  205.    end
  206.    if right_down[7] == 1
  207.      @right_repeat = (not @right_repeat)
  208.      @right_trigger = (not @right_press)
  209.      @right_press = true
  210.    else
  211.      @right_press = false
  212.      @right_trigger = false
  213.      @right_repeat = false
  214.    end
  215. end
  216. def self.get_mouse_pos
  217.    point_var = [0, 0].pack('ll')
  218.    if $GetCursorPos.call(point_var) != 0
  219.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  220.        x, y = point_var.unpack('ll')
  221.        if (x < 0) or (x > 10000) then x = 0 end
  222.        if (y < 0) or (y > 10000) then y = 0 end
  223.        if x > 1024 then x = 1024 end
  224.        if y > 704 then y = 704 end
  225.        return x, y
  226.      else
  227.        return 0, 0
  228.      end
  229.    else
  230.      return 0, 0
  231.    end
  232. end
  233. def self.press?(mouse_code)
  234.    if mouse_code == LEFT
  235.      if @click_lock
  236.        return false
  237.      else
  238.        return @left_press
  239.      end
  240.    elsif mouse_code == RIGHT
  241.      return @right_press
  242.    else
  243.      return false
  244.    end
  245. end
  246. def self.trigger?(mouse_code)
  247.    if mouse_code == LEFT
  248.      if @click_lock
  249.        return false
  250.      else
  251.        return @left_trigger
  252.      end
  253.    elsif mouse_code == RIGHT
  254.      return @right_trigger
  255.    else
  256.      return false
  257.    end
  258. end
  259. def self.repeat?(mouse_code)
  260.    if mouse_code == LEFT
  261.      if @click_lock
  262.        return false
  263.      else
  264.        return @left_repeat
  265.      end
  266.    elsif mouse_code == RIGHT
  267.      return @right_repeat
  268.    else
  269.      return false
  270.    end
  271. end
  272. def self.click_lock?
  273.    return @click_lock
  274. end
  275. def self.click_lock
  276.    @click_lock = true
  277. end
  278. def self.click_unlock
  279.    @click_lock = false
  280. end
  281. end
  282. module Input
  283. if @self_update == nil
  284.    @self_update = method('update')
  285.    @self_press = method('press?')
  286.    @self_trigger = method('trigger?')
  287.    @self_repeat = method('repeat?')
  288. end
  289. def self.update
  290.    @self_update.call
  291.    Mouse.update
  292. end
  293. def self.press?(key_code)
  294.    if @self_press.call(key_code)
  295.      return true
  296.    end
  297.    if key_code == C
  298.      return Mouse.press?(Mouse::LEFT)
  299.    elsif key_code == B
  300.      return Mouse.press?(Mouse::RIGHT)
  301.    else
  302.      return @self_press.call(key_code)
  303.    end
  304. end
  305. def self.trigger?(key_code)
  306.    if @self_trigger.call(key_code)
  307.      return true
  308.    end
  309.    if key_code == C
  310.      return Mouse.trigger?(Mouse::LEFT)
  311.    elsif key_code == B
  312.      return Mouse.trigger?(Mouse::RIGHT)
  313.    else
  314.      return @self_trigger.call(key_code)
  315.    end
  316. end
  317. def self.repeat?(key_code)
  318.    if @self_repeat.call(key_code)
  319.      return true
  320.    end
  321.    if key_code == C
  322.      return Mouse.repeat?(Mouse::LEFT)
  323.    elsif key_code == B
  324.      return Mouse.repeat?(Mouse::RIGHT)
  325.    else
  326.      return @self_repeat.call(key_code)
  327.    end
  328. end
  329. end
  330. class Window_Selectable
  331. if @self_alias == nil
  332.    alias self_update update
  333.    @self_alias = true
  334. end
  335. def update
  336.    self_update
  337.    if self.active and @item_max > 0
  338.      index_var = @index
  339.      tp_index = @index
  340.      mouse_x, mouse_y = Mouse.get_mouse_pos
  341.      mouse_not_in_rect = true
  342.      for i in 0...@item_max
  343.        @index = i
  344.        update_cursor_rect
  345.        top_x = self.cursor_rect.x + self.x + 16
  346.        top_y = self.cursor_rect.y + self.y + 16
  347.        bottom_x = top_x + self.cursor_rect.width
  348.        bottom_y = top_y + self.cursor_rect.height
  349.        if (mouse_x > top_x) and (mouse_y > top_y) and
  350.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  351.          mouse_not_in_rect = false
  352.          if tp_index != @index
  353.            tp_index = @index
  354.            $game_system.se_play($data_system.cursor_se)
  355.          end
  356.          break
  357.        end
  358.      end
  359.      if mouse_not_in_rect
  360.        @index = index_var
  361.        update_cursor_rect
  362.        Mouse.click_lock
  363.      else
  364.        Mouse.click_unlock               
  365.      end
  366.    end
  367. end
  368. end
  369. class Window_NameInput
  370. if @self_alias == nil
  371.    alias self_update update
  372.    @self_alias = true
  373. end
  374. def update
  375.    self_update
  376.    if self.active
  377.      index_var = @index
  378.      mouse_x, mouse_y = Mouse.get_mouse_pos
  379.      mouse_not_in_rect = true
  380.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  381.        @index = i
  382.        update_cursor_rect
  383.        top_x = self.cursor_rect.x + self.x + 16
  384.        top_y = self.cursor_rect.y + self.y + 16
  385.        bottom_x = top_x + self.cursor_rect.width
  386.        bottom_y = top_y + self.cursor_rect.height
  387.        if (mouse_x > top_x) and (mouse_y > top_y) and
  388.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  389.          mouse_not_in_rect = false
  390.          break
  391.        end
  392.      end
  393.      if mouse_not_in_rect
  394.        @index = index_var
  395.        update_cursor_rect
  396.        Mouse.click_lock
  397.      else
  398.        Mouse.click_unlock
  399.      end
  400.    end
  401. end
  402. end
  403. class Window_InputNumber
  404. if @self_alias == nil
  405.    alias self_update update
  406.    @self_alias = true
  407. end
  408. def update
  409.    self_update
  410.    mouse_x, mouse_y = Mouse.get_mouse_pos
  411.    if self.active and @digits_max > 0
  412.      index_var = @index
  413.      mouse_not_in_rect = true
  414.      for i in 0...@digits_max
  415.        @index = i
  416.        update_cursor_rect
  417.        top_x = self.cursor_rect.x + self.x + 16
  418.        bottom_x = top_x + self.cursor_rect.width
  419.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  420.          mouse_not_in_rect = false
  421.          break
  422.        end
  423.      end
  424.      if mouse_not_in_rect
  425.        @index = index_var
  426.        update_cursor_rect
  427.        Mouse.click_lock
  428.      else
  429.        Mouse.click_unlock
  430.      end
  431.    end
  432.    if @last_mouse_y == nil
  433.      @last_mouse_y = mouse_y
  434.    end
  435.    check_pos = (@last_mouse_y - mouse_y).abs
  436.    if check_pos > 10
  437.      $game_system.se_play($data_system.cursor_se)
  438.      place = 10 ** (@digits_max - 1 - @index)
  439.      n = @number / place % 10
  440.      @number -= n * place
  441.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  442.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  443.      @number += n * place
  444.      refresh
  445.      @last_mouse_y = mouse_y
  446.    end
  447. end
  448. end
  449. class Scene_File
  450. if @self_alias == nil
  451.    alias self_update update
  452.    @self_alias = true
  453. end
  454. def update
  455.    mouse_x, mouse_y = Mouse.get_mouse_pos
  456.    Mouse.click_lock
  457.    idx = 0
  458.    for i in @savefile_windows
  459.      top_x = i.x + 16
  460.      top_y = i.y + 16
  461.      bottom_x = top_x + i.width
  462.      bottom_y = top_y + i.height
  463.      if (mouse_x > top_x) and (mouse_y > top_y) and
  464.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  465.        i.selected = true
  466.        if @file_index != idx
  467.          @file_index = idx
  468.          $game_system.se_play($data_system.cursor_se)
  469.        end            
  470.        Mouse.click_unlock
  471.      else
  472.        i.selected = false
  473.      end
  474.      idx += 1
  475.    end
  476.    self_update
  477. end
  478. end
  479. class Arrow_Enemy
  480. if @self_alias == nil
  481.    alias self_update update
  482.    @self_alias = true
  483. end
  484. def update
  485.    mouse_x, mouse_y = Mouse.get_mouse_pos
  486.    idx = 0
  487.    for i in $game_troop.enemies do
  488.      if i.exist?
  489.        top_x = i.screen_x - self.ox
  490.        top_y = i.screen_y - self.oy
  491.        bottom_x = top_x + self.src_rect.width
  492.        bottom_y = top_y + self.src_rect.height
  493.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  494.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  495.          if @index != idx
  496.            $game_system.se_play($data_system.cursor_se)
  497.            @index = idx
  498.          end
  499.        end
  500.      end
  501.      idx += 1
  502.    end
  503.    self_update
  504. end
  505. end
  506. class Arrow_Actor
  507. if @self_alias == nil
  508.    alias self_update update
  509.    @self_alias = true
  510. end
  511. def update
  512.    mouse_x, mouse_y = Mouse.get_mouse_pos
  513.    idx = 0
  514.    for i in $game_party.actors do
  515.      if i.exist?
  516.        top_x = i.screen_x - self.ox
  517.        top_y = i.screen_y - self.oy
  518.        bottom_x = top_x + self.src_rect.width
  519.        bottom_y = top_y + self.src_rect.height
  520.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  521.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  522.          if @index != idx
  523.            $game_system.se_play($data_system.cursor_se)
  524.            @index = idx
  525.          end
  526.        end
  527.      end
  528.      idx += 1
  529.    end
  530.    self_update
  531. end
  532. end
  533. #==============================================================================
  534. # ■ Game_Player
  535. #------------------------------------------------------------------------------
  536. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  537. # 本类的实例请参考 $game_player。
  538. #   鼠标控制角色的主程序
  539. #==============================================================================
  540. class Game_Player
  541. if @self_alias == nil
  542.    alias self_update update
  543.    @self_alias = true
  544. end
  545. #--------------------------------------------------------------------------
  546. # ● 得到鼠标的状态
  547. #--------------------------------------------------------------------------
  548. def get_mouse_sta
  549.    return @mouse_sta
  550. end
  551. #--------------------------------------------------------------------------
  552. # ● 完整鼠标系统
  553. #--------------------------------------------------------------------------
  554. def update
  555.    mouse_x, mouse_y = Mouse.get_mouse_pos
  556.    @mtp_x = mouse_x
  557.    @mtp_y = mouse_y
  558.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  559.      #得到鼠标图标方向
  560.      $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)
  561.    else
  562.      #令鼠标图标为正常
  563.      $mouse_icon_id = 0 if @mouse_sta != 2
  564.    end
  565.    
  566.    #单击鼠标时进行判断寻路或跟随
  567.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  568.      unless $game_system.map_interpreter.running? or
  569.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  570.        #初始化
  571.        @mouse_sta = 1
  572.        p_direction = 5
  573.        #检查鼠标处能否开启事件
  574.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  575.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  576.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  577.        if @mouse_sta != 2
  578.          #鼠标状态不为跟随状态则取数据并初始化路径
  579.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  580.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  581.          @paths = []
  582.          @paths_id = 0
  583.          if event_start == 0 #若不能开启事件
  584.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  585.              find_path = Find_Path.new
  586.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  587.            end
  588.          else #若能开启事件则改变角色朝向
  589.            @direction = p_direction
  590.          end
  591.        end
  592.      end
  593.    end

  594.    #开始移动
  595.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  596.      unless moving? or $game_system.map_interpreter.running? or
  597.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  598.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  599.          case @paths[@paths_id] #判断路径
  600.          when 6
  601.            @last_move_x = true
  602.            move_right
  603.            @paths_id += 1
  604.            @direction = 6
  605.          when 4
  606.            @last_move_x = true
  607.            move_left
  608.            @paths_id += 1
  609.            @direction = 4
  610.          when 2
  611.            @last_move_x = false
  612.            move_down
  613.            @direction = 2
  614.            @paths_id += 1
  615.          when 8
  616.            @last_move_x = false
  617.            move_up
  618.            @direction = 8
  619.            @paths_id += 1
  620.          end
  621.        end
  622.      end
  623.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  624.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  625.        unless moving? or $game_system.map_interpreter.running? or
  626.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  627.          #跟随方向判断并跟随
  628.          if @mtp_x > self.screen_x
  629.            if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
  630.               @mtp_y - self.screen_y < @mtp_x - self.screen_x
  631.              move_right
  632.              $mouse_icon_id = 16
  633.              @direction = 6
  634.            end
  635.            if @mtp_y - self.screen_y > @mtp_x - self.screen_x
  636.              move_down
  637.              $mouse_icon_id = 12
  638.              @direction = 2
  639.            end
  640.            if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
  641.              move_up
  642.              $mouse_icon_id = 18
  643.              @direction = 8
  644.            end
  645.          end
  646.          if @mtp_x < self.screen_x
  647.            if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
  648.               @mtp_y - self.screen_y < self.screen_x - @mtp_x
  649.              move_left
  650.              $mouse_icon_id = 14
  651.              @direction = 4
  652.            end
  653.            if @mtp_y - self.screen_y > self.screen_x - @mtp_x
  654.              move_down
  655.              $mouse_icon_id = 12
  656.              @direction = 2
  657.            end
  658.            if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
  659.              move_up
  660.              $mouse_icon_id = 18
  661.              @direction = 8
  662.            end
  663.          end
  664.        end
  665.      else #没状态的情况
  666.        $mouse_icon_id = 0
  667.        @mouse_sta = 0
  668.        @paths_id = @paths.size #终止寻路移动
  669.      end
  670.    end
  671. self_update
  672. end
  673. end
  674. Mouse.init
  675. END { Mouse.exit }
复制代码
然后我发现,如果不插这一段的话会出错......
  1. if $myfirst == nil
  2.   
  3.    $myfirst = 'myGod'  
  4.    宽度=1024
  5.    高度=704
  6.    游戏ini名=".\\Game.ini"
  7.    val = "\0"*256
  8.    gps = Win32API.new('kernel32', 'GetPrivateProfileString','pppplp', 'l')
  9.    gps.call("Game", "Title", "", val, 256, 游戏ini名)
  10.    val.delete!("\0")
  11.    title = val
  12.    fw = Win32API.new('user32', 'FindWindow', 'pp', 'i')
  13.    hWnd = fw.call("RGSS Player", title)
  14.    swp = Win32API.new('user32', 'SetWindowPos', 'lliiiii', 'i')

  15.    pointwds = [0,0,0,0].pack('llll')
  16.    pointcet = [0, 0].pack('ll')

  17.    wdsrect = Win32API.new('user32.dll', 'GetWindowRect', 'lp', 'l')
  18.    client_screen = Win32API.new("user32", "ClientToScreen", 'ip', 'i')

  19.    wdsrect.call(hWnd,pointwds)
  20.    client_screen.call(hWnd, pointcet)

  21.    wds = pointwds.unpack('llll')
  22.    cet = pointcet.unpack('ll')

  23.    addw =  wds[2] - wds[0] - 640
  24.    addh =  wds[3] - wds[1] - 480

  25.    x = wds[0] - (宽度 - 1024) / 2
  26.    y = wds[1] - (高度 - 704) / 2

  27.    swp.call(hWnd, 0, x, y, 宽度 + addw, 高度 + addh, 0x20)
  28.    
  29. end
  30. class Window_Item
  31.   def draw_item(index)
  32.     item = @data[index]
  33.     case item
  34.     when RPG::Item
  35.       number = $game_party.item_number(item.id)
  36.     when RPG::Weapon
  37.       number = $game_party.weapon_number(item.id)
  38.     when RPG::Armor
  39.       number = $game_party.armor_number(item.id)
  40.     end
  41.     if item.is_a?(RPG::Item) and
  42.        $game_party.item_can_use?(item.id)
  43.       self.contents.font.color = normal_color
  44.     else
  45.       self.contents.font.color = disabled_color
  46.     end
  47.     x = 4 + index % 2 * (288 + 32)
  48.     y = index / 2 * 32
  49.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  50.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  51.     bitmap = RPG::Cache.icon(item.icon_name)
  52.     opacity = self.contents.font.color == normal_color ? 255 : 128
  53.     self.contents.blt(x, y , bitmap, Rect.new(0, 0, 32, 32), opacity)
  54.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  55.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  56.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  57.   end
  58. end
复制代码
然后就可以共存了,但是鼠标寻路走几下就走不了了,这是怎么回事?求大大们帮忙讲解一下。
@晴兰 @protosssonny @紫英晓狼1130 @876加几 @火烧兔子 @end55rpg @1426 @美丽晨露 @whbm @高手们   @fux2  

Lv3.寻梦者

梦石
0
星屑
3846
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
2
发表于 2013-12-21 08:33:52 | 只看该作者
走几下之后有没有卡顿?
可以用F2看看FPS是否突然降为零
如果是的话,就要用清理内存和防卡脚本了

评分

参与人数 1星屑 +120 收起 理由
myownroc + 120 塞糖

查看全部评分

《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv3.寻梦者

○赛

梦石
0
星屑
1249
在线时间
1276 小时
注册时间
2013-1-22
帖子
2246

贵宾

3
 楼主| 发表于 2013-12-21 08:35:34 | 只看该作者
紫英晓狼1130 发表于 2013-12-21 08:33
走几下之后有没有卡顿?
可以用F2看看FPS是否突然降为零
如果是的话,就要用清理内存和防卡脚本了 ...

赞!真的是这样!我测试时就发现了,但我以为是脚本不兼容!谢谢!等一会我就去试!
回复 支持 反对

使用道具 举报

Lv3.寻梦者

○赛

梦石
0
星屑
1249
在线时间
1276 小时
注册时间
2013-1-22
帖子
2246

贵宾

4
 楼主| 发表于 2013-12-21 17:13:21 | 只看该作者
紫英晓狼1130 发表于 2013-12-21 08:33
走几下之后有没有卡顿?
可以用F2看看FPS是否突然降为零
如果是的话,就要用清理内存和防卡脚本了 ...

我加了清理内存和防卡脚本,但问题仍旧在。求解?
另外,如何使启动时游戏窗口的位置改变?我那个总是原来的位置。
希望您帮忙解答,麻烦您了
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3846
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
5
发表于 2013-12-21 17:51:34 | 只看该作者
天地有正气 发表于 2013-12-21 17:13
我加了清理内存和防卡脚本,但问题仍旧在。求解?
另外,如何使启动时游戏窗口的位置改变?我那个总是原 ...

其实窗口扩大FPS一定会降的,没办法解决…
但我仔细看了一下脚本,总觉得脚本不太对劲(个人感觉…),如果FPS还是非常低的话,推荐跟换分辨率的脚本,我之前做的仙剑三外传标题里窗口分辨率是根据癫狂侠客的DKRM的窗口定义改的,理论上支持各种鼠标(在范例里是全鼠标基础版),地图上FPS能达到30左右
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv3.寻梦者

○赛

梦石
0
星屑
1249
在线时间
1276 小时
注册时间
2013-1-22
帖子
2246

贵宾

6
 楼主| 发表于 2013-12-21 20:57:09 | 只看该作者
紫英晓狼1130 发表于 2013-12-21 17:51
其实窗口扩大FPS一定会降的,没办法解决…
但我仔细看了一下脚本,总觉得脚本不太对劲(个人感觉…),如 ...

我也觉得不大对劲...
顺便说一下我下载了你的标题范例,发现了有些小漏洞= =
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-30 07:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表