查看: 1973|回复: 1

[已经过期] “显示NPC名字”脚本和“NPC大小判断”脚本冲突了,怎么办

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2016-1-22 00:54:55 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 yang1zhi 于 2016-1-22 16:19 编辑



NPC名字
  1. #==============================================================================
  2. # 本脚本来自[url]www.66rpg.com[/url],转载、使用请保留此信息
  3. #==============================================================================
  4. # 作者:柳柳
  5. #
  6. # 使用方法:插入到main前即可,之后就会显示每个事件的名字。
  7. # 不想显示名字的NPC直接把名字设置为一个空格就行了。
  8. #
  9. # 附加功能:名字颜色区分:比如一个NPC的名字是  柳柳,2  就会用2号颜色(红色)显示
  10. #
  11. # 修改NPC名的方法:$game_map.events[事件ID编号].name =
  12. # 比如某个宝箱,原名宝箱,打开后名为“打开的宝箱”,则
  13. # $game_map.events[@event_id].name = "打开的宝箱" 或者
  14. # $game_map.events[2].name = "打开的宝箱" (假设宝箱是2号事件)
  15. #
  16. # 修改颜色定义:70-88行,131-149行,自己随便改。
  17. #
  18. # 给主角带上名字:192行,改 "" 为 "主角" 或者 $game_party.actors[0].name 即可
  19. #
  20. # 是否显示姓名的开关:157行,开头的井号去掉。则以后39号开关打开的时候才会显示姓名
  21. #
  22. #==============================================================================
  23. # ■ Game_Event
  24. #------------------------------------------------------------------------------
  25. #  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
  26. # 在 Game_Map 类的内部使用。
  27. #==============================================================================
  28. class Game_Event < Game_Character
  29. #——————————————————————————————————————
  30. # 用来返回名称
  31. #——————————————————————————————————————
  32. def name
  33.    return @event.name
  34. end  
  35. def name=(newname)
  36.    @event.name = newname
  37. end
  38. end

  39. #==============================================================================
  40. # ■ Sprite_Character
  41. #------------------------------------------------------------------------------
  42. #  角色显示用脚本。监视 Game_Character 类的实例、
  43. # 自动变化脚本状态。
  44. #==============================================================================

  45. class Sprite_Character < RPG::Sprite
  46. #--------------------------------------------------------------------------
  47. # ● 定义实例变量
  48. #--------------------------------------------------------------------------
  49. attr_accessor :character                # 角色
  50.    #--------------------------------------------------------------------------
  51. # ● 初始化对像
  52. #     viewport  : 查看端口
  53. #     character : 角色 (Game_Character)
  54. #--------------------------------------------------------------------------
  55. def initialize(viewport, character = nil)
  56.    name = character.name
  57.    super(viewport)
  58.    @character = character
  59.    @namesprite = Sprite.new
  60.    @namesprite.bitmap = Bitmap.new(160, 48)
  61.    @namesprite.bitmap.font.name = "黑体"
  62.    @namesprite.bitmap.font.size = 14
  63.    @namesprite.bitmap.font.color.set(255, 0, 0)
  64.    @evname = name
  65.    @evname_split = name.split(/,/)[0]
  66.    if name[0, 2]=="EV"
  67.      @evname_split = " "
  68.    end
  69.    if name.split(/,/)[1] != nil
  70.      case name.split(/,/)[1]
  71.      when "0"
  72.        @namesprite.bitmap.font.color.set(255, 0, 0)
  73.      when "1"
  74.        @namesprite.bitmap.font.color.set(128, 0, 0)
  75.      when "2"
  76.        @namesprite.bitmap.font.color.set(255, 0, 0)
  77.      when "3"
  78.        @namesprite.bitmap.font.color.set(128, 0, 0)
  79.      when "4"
  80.        @namesprite.bitmap.font.color.set(128, 0, 0)
  81.      when "5"
  82.        @namesprite.bitmap.font.color.set(255, 0, 0)
  83.      when "6"
  84.        @namesprite.bitmap.font.color.set(255, 0, 0)
  85.      when "7"
  86.        @namesprite.bitmap.font.color.set(192, 0, 0)
  87.      else
  88.        @namesprite.bitmap.font.color.set(255, 0, 0)
  89.      end
  90.    end
  91.    if @evname_split != "" and @evname_split != nil
  92.      @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1)
  93.    end
  94.    update
  95. end
  96.    #--------------------------------------------------------------------------
  97. # ● 更新画面
  98. #--------------------------------------------------------------------------
  99. def update
  100.    super
  101.    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  102.    if @tile_id != @character.tile_id or
  103.       @character_name != @character.character_name or
  104.       @character_hue != @character.character_hue
  105.      # 记忆元件 ID 与文件名、色相
  106.      @tile_id = @character.tile_id
  107.      @character_name = @character.character_name
  108.      @character_hue = @character.character_hue
  109.      # 元件 ID 为有效值的情况下
  110.      if @tile_id >= 384
  111.        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  112.          @tile_id, @character.character_hue)
  113.        self.src_rect.set(0, 0, 32, 32)
  114.        self.ox = 16
  115.        self.oy = 32
  116.      # 元件 ID 为无效值的情况下
  117.      else
  118.        self.bitmap = RPG::Cache.character(@character.character_name,
  119.          @character.character_hue)
  120.        @cw = bitmap.width / 4
  121.        @ch = bitmap.height / 4
  122.        self.ox = @cw / 2
  123.        self.oy = @ch
  124.      end
  125.    end
  126.    if @evname != @character.name
  127.      @namesprite.bitmap.clear
  128.      @evname = @character.name
  129.      @evname_split = @character.name.split(/,/)[0]
  130.      if @character.name.split(/,/)[1] != nil
  131.        case @character.name.split(/,/)[1]
  132.        when "0"
  133.          @namesprite.bitmap.font.color.set(255, 0, 0)
  134.        when "1"
  135.          @namesprite.bitmap.font.color.set(128, 0, 0)
  136.        when "2"
  137.          @namesprite.bitmap.font.color.set(255, 0, 0)
  138.        when "3"
  139.          @namesprite.bitmap.font.color.set(128, 0, 0)
  140.        when "4"
  141.          @namesprite.bitmap.font.color.set(128, 0, 0)
  142.         
  143.        when "5"
  144.          @namesprite.bitmap.font.color.set(255, 0, 0)
  145.        when "6"
  146.          @namesprite.bitmap.font.color.set(255, 0, 0)
  147.        when "7"
  148.          @namesprite.bitmap.font.color.set(192, 0, 0)
  149.        else
  150.          @namesprite.bitmap.font.color.set(255, 0, 0)
  151.        end
  152.      end
  153.      if @evname_split != "" and @evname_split != nil
  154.        @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1)
  155.      end
  156.    end
  157.    @namesprite.x = self.x - 80
  158.    @namesprite.y = self.y-self.oy+35-60
  159.    #@namesprite.visible = $game_switches[39]
  160.    # 设置可视状态
  161.    self.visible = (not @character.transparent)
  162.    @namesprite.visible = @character.character_name == "" ? false : self.visible
  163.    # 图形是角色的情况下
  164.    if @tile_id == 0
  165.      # 设置传送目标的矩形
  166.      sx = @character.pattern * @cw
  167.      sy = (@character.direction - 2) / 2 * @ch
  168.      self.src_rect.set(sx, sy, @cw, @ch)
  169.    end
  170.    # 设置脚本的坐标
  171.    self.x = @character.screen_x
  172.    self.y = @character.screen_y
  173.    self.z = @character.screen_z(@ch)
  174.    # 设置不透明度、合成方式、茂密
  175.    self.opacity = @character.opacity
  176.    self.blend_type = @character.blend_type
  177.    self.bush_depth = @character.bush_depth
  178.    # 动画
  179.    if @character.animation_id != 0
  180.      animation = $data_animations[@character.animation_id]
  181.      animation(animation, true)
  182.      @character.animation_id = 0
  183.    end
  184. end
  185. end
  186. #==============================================================================
  187. # ■ Game_Player
  188. #------------------------------------------------------------------------------
  189. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  190. # 本类的实例请参考 $game_player。
  191. #==============================================================================

  192. class Game_Player < Game_Character
  193. def name
  194.    return ""#$game_party.actors[0].name
  195. end
  196. end
  197. #==============================================================================
  198. # 本脚本来自[url]www.66rpg.com[/url],转载、使用请保留此信息
  199. #==============================================================================
复制代码


NPC大小判断
  1. # ===========================================================================
  2. # ★ WF-RGSS Scripts ★
  3. #    LargeCharacter イベント当たり判定調整スクリプト
  4. # バージョン   : rev-4.4 (2013-8-25)
  5. # 作者         : WF-RGSS担当 (WHITE-FLUTE)
  6. # サポート先URI: [url]http://www.whiteflute.org/wfrgss/[/url]
  7. # ---------------------------------------------------------------------------
  8. # 機能:
  9. # ・イベントの大きさを感知し、当たり判定を調整します。
  10. # ・ある程度マップの処理を軽量化します。
  11. # ---------------------------------------------------------------------------
  12. # 影響:
  13. # ・軽量化スクリプトと競合します。
  14. #   詳細は readme.txt を参照してください。
  15. # ---------------------------------------------------------------------------
  16. # 設置場所     :Sprite_Character より下、Mainより上
  17. # 必要スクリプト:
  18. # ・共通スクリプト(rev-17以降)、共通実行スクリプト(rev-17以降)
  19. # 注意事項:
  20. #   ▽ ほかの軽量化スクリプトとの併用は避けてください。
  21. # ===========================================================================

  22. class Sprite_Character < RPG::Sprite
  23.   #------------------------------------------------------------------------
  24.   # ● カスタマイズ ポイント
  25.   #------------------------------------------------------------------------
  26.   # 認知されるキャラクターの大きさを指定します。
  27.   
  28.   LARGE_SET  = 24 * 3
  29.   LARGE_SIZE = 32 * 2

  30. end

  31. #==============================================================================
  32. # ◆ PassagesList
  33. #------------------------------------------------------------------------------
  34. #  キャラクターの位置を判定するリストです
  35. #==============================================================================

  36. class PassagesList
  37.   # 継承禁止
  38.   include FinalClass
  39.   #--------------------------------------------------------------------------
  40.   # ● オブジェクト初期化
  41.   #--------------------------------------------------------------------------
  42.   def initialize
  43.     @list = Hash.new
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● クリア
  47.   #--------------------------------------------------------------------------
  48.   def clear
  49.     @list.clear
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ◆ 位置情報ID
  53.   #--------------------------------------------------------------------------
  54.   def passages( x , y )
  55.     ( x << 9 ) + y
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ◆ キャラクタ通行不能情報更新
  59.   #--------------------------------------------------------------------------
  60.   def update( event_id , old_r , new_r , xsize = 1 , ysize = 1)
  61.     if xsize > 1 or ysize > 1
  62.       xr = xsize / 2
  63.       yr = -(ysize - 1)
  64.       unless old_r.nil?
  65.         for i in -xr..xr
  66.           for j in yr..0
  67.             outevent( event_id , old_r + i * 512 + j )
  68.           end
  69.         end
  70.       end
  71.       unless new_r.nil?
  72.         for i in -xr..xr
  73.           for j in yr..0
  74.             inevent( event_id , new_r + i * 512 + j )
  75.           end
  76.         end
  77.       end
  78.     else
  79.       unless old_r.nil?
  80.         outevent( event_id , old_r )
  81.       end
  82.       unless new_r.nil?
  83.         inevent( event_id , new_r )
  84.       end
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ◆ キャラクタ通行不能情報読み取り イベント用
  89.   #--------------------------------------------------------------------------
  90.   def passages_event( x , y )
  91.     if (val = @list[passages( x , y )])
  92.       if val.is_a?(Fixnum)
  93.         return $game_map.events[val].passable_event?
  94.       else
  95.         for event_id in val
  96.           event = $game_map.events[event_id]
  97.           return false unless event.passable_event?
  98.         end
  99.         return true
  100.       end
  101.     else
  102.       return true
  103.     end
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ◆ キャラクタ通行不能情報読み取り プレイヤー用
  107.   #--------------------------------------------------------------------------
  108.   def passages_player( x , y )
  109.     if (val = @list[passages( x , y )])
  110.       if val.is_a?(Fixnum)
  111.         return $game_map.events[val].passable_player?
  112.       else
  113.         for event_id in val
  114.           event = $game_map.events[event_id]
  115.           return false unless event.passable_player?
  116.         end
  117.         return true
  118.       end
  119.     else
  120.       return true
  121.     end
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● イベント存在判定
  125.   #--------------------------------------------------------------------------
  126.   def include?( x , y )
  127.     @list[passages( x , y )]
  128.   end
  129.   private
  130.   #--------------------------------------------------------------------------
  131.   # ◆(内部専用)◆ イベント位置代入
  132.   #--------------------------------------------------------------------------
  133.   def inevent( event_id , r )
  134.     val = @list[r]
  135.     if val.nil?
  136.       @list[r] = event_id
  137.     elsif val.is_a?(Fixnum)
  138.       @list[r] = [ val , event_id ] if val != event_id
  139.     else
  140.       @list[r] = val.push( event_id ) unless val.include?( event_id )
  141.     end
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ◆(内部専用)◆ イベント位置撤去
  145.   #--------------------------------------------------------------------------
  146.   def outevent( event_id , r )
  147.     val = @list[r]
  148.     if val.is_a?(Fixnum)
  149.       @list.delete(r)
  150.     elsif val.is_a?(Array)
  151.       val.delete( event_id )
  152.       if val.size < 2
  153.         @list[r] = val.at(0)
  154.       else
  155.         @list[r] = val
  156.       end
  157.     end
  158.   end
  159. end


  160. #==============================================================================
  161. # ■ Game_Map
  162. #------------------------------------------------------------------------------
  163. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  164. # このクラスのインスタンスは $game_map で参照されます。
  165. #==============================================================================
  166. class Game_Map
  167.   # 継承禁止
  168.   include FinalClass
  169.   #--------------------------------------------------------------------------
  170.   # ● 公開インスタンス変数
  171.   #--------------------------------------------------------------------------
  172.   attr_reader :width_scroll             # ◆ スクロール X 座標最大
  173.   attr_reader :height_scroll            # ◆ スクロール Y 座標最大
  174.   attr_reader :onscreen_x               # ◆ 画面内判定 X 座標
  175.   attr_reader :onscreen_y               # ◆ 画面内判定 Y 座標
  176.   attr_reader :passages_char
  177.   #--------------------------------------------------------------------------
  178.   # ● 定数
  179.   #--------------------------------------------------------------------------
  180.   DISPLAY_X            = 1280                 # ◆ ディスプレイX
  181.   DISPLAY_Y            = 960                  # ◆ ディスプレイY
  182.   TILE_SET_WORK        = [ 2 , 1 , 0 ].freeze # ◆ タイルマップレイヤー順序
  183.   #--------------------------------------------------------------------------
  184.   # ● オブジェクト初期化
  185.   #--------------------------------------------------------------------------
  186.   alias _wfrgss_initialize initialize
  187.   def initialize
  188.     _wfrgss_initialize
  189.     @passages_char = PassagesList.new
  190.     @onscreen_x = 0
  191.     @onscreen_y = 0
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● セットアップ
  195.   #     map_id : マップ ID
  196.   #--------------------------------------------------------------------------
  197.   alias _wfrgss_setup_ setup
  198.   def setup(map_id)
  199.     @passages_char.clear
  200.     _wfrgss_setup_(map_id)
  201.     @events[0] = $game_player
  202.     @onscreen_x = @display_x + DISPLAY_X # 1280
  203.     @onscreen_y = @display_y + DISPLAY_Y # 960
  204.     @width_scroll = ( (@map.width  - 20) << 7 )
  205.     @height_scroll= ( (@map.height - 15) << 7 )
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 下にスクロール
  209.   #     distance : スクロールする距離
  210.   #--------------------------------------------------------------------------
  211.   def scroll_down(distance)
  212.     @display_y += distance
  213.     @display_y = @height_scroll if @display_y > @height_scroll
  214.     @onscreen_y = @display_y + DISPLAY_Y # 960
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● 左にスクロール
  218.   #     distance : スクロールする距離
  219.   #--------------------------------------------------------------------------
  220.   def scroll_left(distance)
  221.     @display_x -= distance
  222.     @display_x = 0 if @display_x < 0
  223.     @onscreen_x = @display_x + DISPLAY_X # 1280
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 右にスクロール
  227.   #     distance : スクロールする距離
  228.   #--------------------------------------------------------------------------
  229.   def scroll_right(distance)
  230.     @display_x += distance
  231.     @display_x = @width_scroll if @display_x > @width_scroll
  232.     @onscreen_x = @display_x + DISPLAY_X # 1280
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # ● 上にスクロール
  236.   #     distance : スクロールする距離
  237.   #--------------------------------------------------------------------------
  238.   def scroll_up(distance)
  239.     @display_y -= distance
  240.     @display_y = 0 if @display_y < 0
  241.     @onscreen_y = @display_y + DISPLAY_Y # 960
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 任意座標にスクロール
  245.   #     distance : スクロールする距離
  246.   #--------------------------------------------------------------------------
  247.   def scroll_any( distance_x , distance_y )
  248.     @display_x += distance_x
  249.     if @display_x < 0
  250.       @display_x = 0
  251.     elsif @display_x > @width_scroll
  252.       @display_x = @width_scroll
  253.     end
  254.     @display_y += distance_y
  255.     if @display_y < 0
  256.       @display_y = 0
  257.     elsif @display_y > @height_scroll
  258.       @display_y = @height_scroll
  259.     end
  260.     @onscreen_x = @display_x + DISPLAY_X # 1280
  261.     @onscreen_y = @display_y + DISPLAY_Y # 960
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ● 任意座標にスクロール
  265.   #--------------------------------------------------------------------------
  266.   def scroll_fix( display_x , display_y )
  267.     @display_x = display_x
  268.     if @display_x < 0
  269.       @display_x = 0
  270.     elsif @display_x > @width_scroll
  271.       @display_x = @width_scroll
  272.     end
  273.     @display_y = display_y
  274.     if @display_y < 0
  275.       @display_y = 0
  276.     elsif @display_y > @height_scroll
  277.       @display_y = @height_scroll
  278.     end
  279.     @onscreen_x = @display_x + DISPLAY_X # 1280
  280.     @onscreen_y = @display_y + DISPLAY_Y # 960
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ● 通行可能判定
  284.   #     x          : X 座標
  285.   #     y          : Y 座標
  286.   #     d          : 方向 (0,2,4,6,8,10)
  287.   #                  ※ 0,10 = 全方向通行不可の場合を判定 (ジャンプなど)
  288.   #     self_event : 自分 (イベントが通行判定をする場合)
  289.   #--------------------------------------------------------------------------
  290.   def passable?( x , y , d , self_event = nil )
  291.     return false unless valid?(x, y)
  292.     bit = (1 << (( d >> 1 ) - 1)) & 0x0f
  293.     if (val = @passages_char.include?( x , y ))
  294.       ret = nil
  295.       if val.is_a?(Fixnum)
  296.         event = @events[val]
  297.         if event.tile_id >= 0 and event != self_event
  298.           return ret unless (ret = passable_tile?( bit, event)).nil?
  299.         end
  300.       else
  301.         for event_id in val
  302.           event = @events[event_id]
  303.           if event.tile_id >= 0 and event != self_event
  304.             return ret unless (ret = passable_tile?( bit, event)).nil?
  305.           end
  306.         end
  307.       end
  308.     end
  309.     for i in TILE_SET_WORK
  310.       tile_id = @map.data[x, y, i]
  311.       return false if tile_id.nil?
  312.       if (@terrain_tags[tile_id]).zero?
  313.         if (@passages[tile_id] & bit).nonzero?
  314.           return false
  315.         elsif @passages[tile_id] & 0x0f == 0x0f
  316.           return false
  317.         end
  318.       end
  319.       return true if (@priorities[tile_id]).zero?
  320.     end
  321.     return true
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ● 表示 X 座標 * 128
  325.   #--------------------------------------------------------------------------
  326.   def display_x=(display_x)
  327.     if display_x.is_a?(Fixnum)
  328.       @display_x = display_x
  329.       @onscreen_x = @display_x + DISPLAY_X # 1280
  330.     end
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # ● 表示 Y 座標 * 128
  334.   #--------------------------------------------------------------------------
  335.   def display_y=(display_y)
  336.     if display_y.is_a?(Fixnum)
  337.       @display_y = display_y
  338.       @onscreen_y = @display_y + DISPLAY_Y # 960
  339.     end
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ● 指定位置のイベント ID 取得
  343.   #     x          : X 座標
  344.   #     y          : Y 座標
  345.   #--------------------------------------------------------------------------
  346.   def check_event(x, y)
  347.     if ( val = @passages_char.include?( x , y ))
  348.       if val.is_a?(Fixnum)
  349.         return val
  350.       else
  351.         return val.at(0)
  352.       end
  353.     else
  354.       return nil
  355.     end
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● 指定位置のイベント ID 取得
  359.   #--------------------------------------------------------------------------
  360.   def check_event_player( x , y )
  361.     @passages_char.include?( x , y )
  362.   end
  363.   private
  364.   #--------------------------------------------------------------------------
  365.   # ◆(内部専用)◆ 通行可能判定 (タイル)
  366.   #--------------------------------------------------------------------------
  367.   def passable_tile?( bit , tile )
  368.     if (@terrain_tags[tile.tile_id]).zero?
  369.       if (@passages[tile.tile_id] & bit).nonzero?
  370.         return false
  371.       elsif @passages[tile.tile_id] & 0x0f == 0x0f
  372.         return false
  373.       end
  374.     end
  375.     return true if (@priorities[tile.tile_id]).zero?
  376.     nil
  377.   end
  378. end


  379. #==============================================================================
  380. # ■ LargeCharacter
  381. #------------------------------------------------------------------------------
  382. #  当たり判定が巨大なキャラクターを扱うモジュールです。
  383. #==============================================================================

  384. module LargeCharacter
  385.   #--------------------------------------------------------------------------
  386.   # ◆ 移動情報更新
  387.   #--------------------------------------------------------------------------
  388.   def move_update
  389.     @pre_x = (@x << 7)
  390.     @pre_y = (@y << 7)
  391.     $game_map.passages_char.update( @id, passages( @old_x, @old_y),
  392.                                    passages( @x, @y),@x_size,@y_size)
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ◆ 移動情報更新
  396.   #--------------------------------------------------------------------------
  397.   def move_update_setup
  398.     @pre_x = (@x << 7)
  399.     @pre_y = (@y << 7)
  400.     $game_map.passages_char.update( @id, nil,passages( @x, @y),@x_size,@y_size)
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ◆ 大きさの更新
  404.   #--------------------------------------------------------------------------
  405.   def size_update( old_x_size , old_y_size )
  406.    
  407.     $game_map.passages_char.update( @id, passages( @x, @y),nil,
  408.                                    old_x_size , old_y_size)
  409.    
  410.     $game_map.passages_char.update( @id, nil,passages( @x, @y),@x_size,@y_size)
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # ● 通行可能判定
  414.   #--------------------------------------------------------------------------
  415.   def passable?(x, y, d)
  416.     case d
  417.     when 2
  418.       start_x = x - ( @x_size >> 1 )
  419.       end_x = start_x + @x_size
  420.       ry = y
  421.       for rx in start_x ... end_x
  422.         return false unless super( rx , ry , d )
  423.       end
  424.     when 4
  425.       start_y = y - @y_size + 1
  426.       end_y = y
  427.       rx = x - ( @x_size >> 1 )
  428.       for ry in start_y .. end_y
  429.         return false unless super( rx , ry , d )
  430.       end
  431.     when 6
  432.       start_y = y - @y_size + 1
  433.       end_y = y
  434.       rx = x + ( @x_size >> 1 )
  435.       for ry in start_y .. end_y
  436.         return false unless super( rx , ry , d )
  437.       end
  438.     when 8
  439.       start_x = x - ( @x_size >> 1 )
  440.       end_x = start_x + @x_size
  441.       ry = y - @y_size + 1
  442.       for rx in start_x ... end_x
  443.         return false unless super( rx , ry , d )
  444.       end
  445.     else
  446.       start_x = x - ( @x_size >> 1 )
  447.       start_y = y - @y_size + 1
  448.       end_x = start_x + @x_size
  449.       end_y = y
  450.       for rx in start_x ... end_x
  451.         for ry in start_y .. end_y
  452.           return false unless super( rx , ry , d )
  453.         end
  454.       end
  455.     end
  456.     return true
  457.   end
  458.   private
  459.   #--------------------------------------------------------------------------
  460.   # ◆(内部専用)◆ 接触イベントの起動判定
  461.   #--------------------------------------------------------------------------
  462.   def check_event_trigger_touch(x, y)
  463.     super if self.is_a?(Game_Player)
  464.     return false if $game_system.map_interpreter.running?
  465.     return false unless @trigger == 2 or @trigger == 1
  466.     x_left = x - ( @x_size >> 1 )
  467.     x_right = x + ( @x_size >> 1 )
  468.     y_up = ( y - @y_size + 1 )
  469.     if x_left <= $game_player.x and x_right >= $game_player.x and
  470.        y_up <= $game_player.y and y >= $game_player.y
  471.       if not jumping? and not over_trigger?
  472.         start
  473.         return true
  474.       end
  475.     end
  476.     return false
  477.   end
  478. end


  479. #==============================================================================
  480. # ■ Game_Character (分割定義 1) (abstract class)
  481. #------------------------------------------------------------------------------
  482. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  483. # クラスのスーパークラスとして使用されます。
  484. #==============================================================================

  485. class Game_Character
  486.   include Abstract
  487.   
  488.   attr_reader :onscreen
  489.   #--------------------------------------------------------------------------
  490.   # ● 定数
  491.   #--------------------------------------------------------------------------
  492.   ONSCREEN_X           = 1792 # 画面内X領域
  493.   ONSCREEN_Y           = 1536 # 画面内Y領域
  494.   DISPLAY_X            = 1280
  495.   DISPLAY_Y            = 960
  496.   #--------------------------------------------------------------------------
  497.   # ● オブジェクト初期化
  498.   #--------------------------------------------------------------------------
  499.   alias _wfrgss_initialize initialize
  500.   def initialize
  501.     _wfrgss_initialize
  502.     @old_x = @x   # 前回の座標
  503.     @old_y = @y   #
  504.     @x_size = 1
  505.     @y_size = 1
  506.     @pre_x = 0   # 実座標の移動判定に用いる 常に128の整数倍
  507.     @pre_y = 0   #
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # ◆ キャラクタ再更新メソッド
  511.   #--------------------------------------------------------------------------
  512.   def self.character_method( chrmethod )
  513.     __failure_type_call__( chrmethod ) unless chrmethod.is_a?(Method)
  514.     @@charchange = chrmethod
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # ◆ キャラクタ再更新メソッド クリア
  518.   #--------------------------------------------------------------------------
  519.   def self.clear_character_method
  520.     @@charchange = nil
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   # ● フレーム更新
  524.   #--------------------------------------------------------------------------
  525.   def update
  526.     sx = @real_x - $game_map.onscreen_x
  527.     sy = @real_y - $game_map.onscreen_y
  528.     if (@onscreen = (sx.abs <= ONSCREEN_X and sy.abs <= ONSCREEN_Y))
  529.       if jumping?
  530.         update_jump
  531.       elsif moving?
  532.         update_move
  533.       else
  534.         update_stop
  535.       end
  536.       if @anime_count > 36 - ( @move_speed * 2 )
  537.         if not @step_anime and @stop_count > 0
  538.           @pattern = @original_pattern
  539.         else
  540.           @pattern = (@pattern + 1) & 0x3
  541.         end
  542.         @anime_count = 0
  543.       end
  544.     else
  545.       if jumping?
  546.         update_jump
  547.       elsif moving?
  548.         update_move
  549.       else
  550.         update_stop
  551.       end
  552.     end
  553.     if @wait_count > 0
  554.       @wait_count -= 1
  555.       return
  556.     end
  557.     if @move_route_forcing
  558.       move_type_custom
  559.       return
  560.     end
  561.     return if @starting or lock?
  562.     return unless @onscreen
  563.     if @move_frequency != @reserve_move_frequency
  564.       @reserve_move_frequency = @move_frequency
  565.       @stop_frequency =  (40 - @move_frequency * 2) * (6 - @move_frequency)
  566.     end
  567.     if @stop_count > @stop_frequency
  568.       case @move_type
  569.       when 0  # 停止
  570.         move_type_stop
  571.       when 1  # ランダム
  572.         move_type_random
  573.       when 2  # 近づく
  574.         move_type_toward_player
  575.       when 3  # カスタム
  576.         move_type_custom
  577.       end
  578.     end
  579.   end
  580.   #--------------------------------------------------------------------------
  581.   # ● 移動タイプ : 停止
  582.   #--------------------------------------------------------------------------
  583.   def move_type_stop
  584.     @wait_count = rand(36) + 36
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # ● フレーム更新 (ジャンプ)
  588.   #--------------------------------------------------------------------------
  589.   def update_jump
  590.     @jump_count -= 1
  591.     @real_x = (@real_x * @jump_count + @pre_x) / (@jump_count + 1)
  592.     @real_y = (@real_y * @jump_count + @pre_y) / (@jump_count + 1)
  593.   end
  594.   #--------------------------------------------------------------------------
  595.   # ● フレーム更新 (移動)
  596.   #--------------------------------------------------------------------------
  597.   def update_move
  598.     distance = (1 << (@move_speed - 1))
  599.     if @pre_y > @real_y
  600.       @real_y += distance
  601.       @real_y = @pre_y if @real_y > @pre_y
  602.     elsif @pre_y < @real_y
  603.       @real_y -= distance
  604.       @real_y = @pre_y if @real_y < @pre_y
  605.     end
  606.     if @pre_x < @real_x
  607.       @real_x -= distance
  608.       @real_x = @pre_x if @real_x < @pre_x
  609.     elsif @pre_x > @real_x
  610.       @real_x += distance
  611.       @real_x = @pre_x if @real_x > @pre_x
  612.     end
  613.     if @walk_anime
  614.       @anime_count += 3
  615.     elsif @step_anime
  616.       @anime_count += 2
  617.     end
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● フレーム更新 (停止)
  621.   #--------------------------------------------------------------------------
  622.   def update_stop
  623.     if @step_anime
  624.       @anime_count += 2
  625.     elsif @pattern != @original_pattern
  626.       @anime_count += 3
  627.     end
  628.     @stop_count += 2 unless @starting or lock?
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ◆ 位置情報ID
  632.   #--------------------------------------------------------------------------
  633.   def passages( x , y )
  634.     ( x << 9 ) + y
  635.   end
  636.   #--------------------------------------------------------------------------
  637.   # ◆ 移動情報更新
  638.   #--------------------------------------------------------------------------
  639.   def move_update
  640.     @pre_x = (@x << 7)
  641.     @pre_y = (@y << 7)
  642.     $game_map.passages_char.update( @id, passages( @old_x, @old_y),
  643.                                    passages( @x, @y))
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ◆ 移動情報更新
  647.   #--------------------------------------------------------------------------
  648.   def move_update_setup
  649.     @pre_x = (@x << 7)
  650.     @pre_y = (@y << 7)
  651.     $game_map.passages_char.update( @id, nil, passages( @x, @y))
  652.   end
  653.   #--------------------------------------------------------------------------
  654.   # ● 移動中判定
  655.   #--------------------------------------------------------------------------
  656.   def moving?
  657.     (@real_x != @pre_x or @real_y != @pre_y)
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # ● 通行可能判定
  661.   #--------------------------------------------------------------------------
  662.   def passable_event?
  663.     @through
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # ● 通行可能判定
  667.   #--------------------------------------------------------------------------
  668.   def passable_player?
  669.     @through or @character_name.empty?
  670.   end
  671.   #--------------------------------------------------------------------------
  672.   # ● 通行可能判定
  673.   #     x : X 座標
  674.   #     y : Y 座標
  675.   #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
  676.   #--------------------------------------------------------------------------
  677.   def passable?(x, y, d)
  678.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  679.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  680.     return false unless $game_map.valid?(new_x, new_y)
  681.     return true if @through
  682.     return false unless $game_map.passable?( x, y, d, self)
  683.     return false unless $game_map.passable?( new_x, new_y, 10 - d)
  684.     return false unless character_passable?( new_x , new_y )
  685.     true
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # ● キャラクターの大きさを設定
  689.   #--------------------------------------------------------------------------
  690.   def size_change( size_x , size_y )
  691.     return if size_x == @x_size and size_y == @y_size
  692.     if size_x <= 1 and size_y <= 1
  693.       if @x_size > 1 or @y_size > 1
  694.         old_x_size = @x_size
  695.         old_y_size = @y_size
  696.         @x_size = 1
  697.         @y_size = 1
  698.         size_update( old_x_size , old_y_size )
  699.         new_character = self.dup
  700.         $game_map.events[@id] = new_character
  701.         @@charchange.call( @id , new_character )
  702.       end
  703.     else
  704.       unless @x_size > 1 or @y_size > 1
  705.         @x_size = size_x
  706.         @y_size = size_y
  707.         self.extend(LargeCharacter)
  708.         size_update( 1 , 1 )
  709.       else
  710.         old_x_size = @x_size
  711.         old_y_size = @y_size
  712.         @x_size = size_x
  713.         @y_size = size_y
  714.         size_update( old_x_size , old_y_size )
  715.       end
  716.     end
  717.     nil
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● 以前の座標を記録
  721.   #--------------------------------------------------------------------------
  722.   def old_point
  723.     @old_x = @x
  724.     @old_y = @y
  725.   end
  726.   #--------------------------------------------------------------------------
  727.   # ● 指定位置に移動
  728.   #     x : X 座標
  729.   #     y : Y 座標
  730.   #--------------------------------------------------------------------------
  731.   def moveto(x, y)
  732.     old_point
  733.     @x = x % $game_map.width
  734.     @y = y % $game_map.height
  735.     move_update
  736.     @real_x = @x << 7
  737.     @real_y = @y << 7
  738.     @prelock_direction = 0
  739.   end
  740.   #--------------------------------------------------------------------------
  741.   # ● 下に移動
  742.   #     turn_enabled : その場での向き変更を許可するフラグ
  743.   #--------------------------------------------------------------------------
  744.   def move_down(turn_enabled = true)
  745.     if turn_enabled
  746.       turn_down
  747.     end
  748.     if passable?(@x, @y, 2)
  749.       turn_down
  750.       old_point
  751.       @y += 1
  752.       move_update
  753.       increase_steps
  754.     else
  755.       check_event_trigger_touch(@x, @y+1)
  756.     end
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   # ● 左に移動
  760.   #     turn_enabled : その場での向き変更を許可するフラグ
  761.   #--------------------------------------------------------------------------
  762.   def move_left(turn_enabled = true)
  763.     if turn_enabled
  764.       turn_left
  765.     end
  766.     if passable?(@x, @y, 4)
  767.       turn_left
  768.       old_point
  769.       @x -= 1
  770.       move_update
  771.       increase_steps
  772.     else
  773.       check_event_trigger_touch(@x-1, @y)
  774.     end
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ● 右に移動
  778.   #     turn_enabled : その場での向き変更を許可するフラグ
  779.   #--------------------------------------------------------------------------
  780.   def move_right(turn_enabled = true)
  781.     if turn_enabled
  782.       turn_right
  783.     end
  784.     if passable?(@x, @y, 6)
  785.       turn_right
  786.       old_point
  787.       @x += 1
  788.       move_update
  789.       increase_steps
  790.     else
  791.       check_event_trigger_touch(@x+1, @y)
  792.     end
  793.   end
  794.   #--------------------------------------------------------------------------
  795.   # ● 上に移動
  796.   #     turn_enabled : その場での向き変更を許可するフラグ
  797.   #--------------------------------------------------------------------------
  798.   def move_up(turn_enabled = true)
  799.     if turn_enabled
  800.       turn_up
  801.     end
  802.     if passable?(@x, @y, 8)
  803.       turn_up
  804.       old_point
  805.       @y -= 1
  806.       move_update
  807.       increase_steps
  808.     else
  809.       check_event_trigger_touch(@x, @y-1)
  810.     end
  811.   end
  812.   #--------------------------------------------------------------------------
  813.   # ● 左下に移動
  814.   #--------------------------------------------------------------------------
  815.   def move_lower_left
  816.     unless @direction_fix
  817.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  818.     end
  819.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
  820.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
  821.       old_point
  822.       @x -= 1
  823.       @y += 1
  824.       move_update
  825.       increase_steps
  826.     end
  827.   end
  828.   #--------------------------------------------------------------------------
  829.   # ● 右下に移動
  830.   #--------------------------------------------------------------------------
  831.   def move_lower_right
  832.     unless @direction_fix
  833.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  834.     end
  835.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
  836.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
  837.       old_point
  838.       @x += 1
  839.       @y += 1
  840.       move_update
  841.       increase_steps
  842.     end
  843.   end
  844.   #--------------------------------------------------------------------------
  845.   # ● 左上に移動
  846.   #--------------------------------------------------------------------------
  847.   def move_upper_left
  848.     unless @direction_fix
  849.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  850.     end
  851.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
  852.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
  853.       old_point
  854.       @x -= 1
  855.       @y -= 1
  856.       move_update
  857.       increase_steps
  858.     end
  859.   end
  860.   #--------------------------------------------------------------------------
  861.   # ● 右上に移動
  862.   #--------------------------------------------------------------------------
  863.   def move_upper_right
  864.     unless @direction_fix
  865.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  866.     end
  867.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
  868.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
  869.       old_point
  870.       @x += 1
  871.       @y -= 1
  872.       move_update
  873.       increase_steps
  874.     end
  875.   end
  876.   #--------------------------------------------------------------------------
  877.   # ● ジャンプ
  878.   #     x_plus : X 座標加算値
  879.   #     y_plus : Y 座標加算値
  880.   #--------------------------------------------------------------------------
  881.   def jump(x_plus, y_plus)
  882.     if x_plus != 0 or y_plus != 0
  883.       if x_plus.abs > y_plus.abs
  884.         x_plus < 0 ? turn_left : turn_right
  885.       else
  886.         y_plus < 0 ? turn_up : turn_down
  887.       end
  888.     end
  889.     new_x = @x + x_plus
  890.     new_y = @y + y_plus
  891.     if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  892.       straighten
  893.       old_point
  894.       @x = new_x
  895.       @y = new_y
  896.       move_update
  897.       distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
  898.       @jump_peak = 10 + distance - @move_speed
  899.       @jump_count = @jump_peak * 2
  900.       @stop_count = 0
  901.     end
  902.   end
  903. end

  904. #==============================================================================
  905. # ■ Game_Event
  906. #------------------------------------------------------------------------------
  907. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  908. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  909. #==============================================================================
  910. class Game_Event < Game_Character
  911.   alias __wfrgss_chr_initialize__ initialize
  912.   #--------------------------------------------------------------------------
  913.   # ● オブジェクト初期化
  914.   #     map_id : マップ ID
  915.   #     event  : イベント (RPG::Event)
  916.   #--------------------------------------------------------------------------
  917.   def initialize(map_id, event)
  918.     @event = event
  919.     moveto_setup(@event.x, @event.y)
  920.     __wfrgss_chr_initialize__(map_id, event)
  921.   end
  922.   #--------------------------------------------------------------------------
  923.   # ◆ キャラクタ通行可能判定
  924.   #--------------------------------------------------------------------------
  925.   def character_passable?( x , y )
  926.     $game_map.passages_char.passages_event( x , y )
  927.   end
  928.   #--------------------------------------------------------------------------
  929.   # ● 指定位置に移動
  930.   #     x : X 座標
  931.   #     y : Y 座標
  932.   #--------------------------------------------------------------------------
  933.   def moveto_setup(x, y)
  934.     @x = @old_x = ( x % $game_map.width )
  935.     @y = @old_y = ( y % $game_map.height )
  936.     move_update_setup
  937.     @real_x = (@x << 7)
  938.     @real_y = (@y << 7)
  939.     @prelock_direction = 0
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # ● オーバートリガー判定 (同位置を起動条件とするか否か)
  943.   #--------------------------------------------------------------------------
  944.   def over_trigger?
  945.     return false if @character_name != "" and not @through
  946.     return false unless $game_map.passable?(@x, @y, 0)
  947.     true
  948.   end
  949. end

  950. #==============================================================================
  951. # ■ Game_Player
  952. #------------------------------------------------------------------------------
  953. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  954. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  955. #==============================================================================

  956. class Game_Player < Game_Character
  957.   #--------------------------------------------------------------------------
  958.   # ● 定数
  959.   #--------------------------------------------------------------------------
  960.   TRIGGER_DECISION = [0].freeze
  961.   TRIGGER_PLAYER = [1,2].freeze
  962.   TRIGGER_EVENT = [0,1,2].freeze
  963.   #--------------------------------------------------------------------------
  964.   # ● 起動トリガー
  965.   #--------------------------------------------------------------------------
  966.   def trigger
  967.     5
  968.   end
  969.   #--------------------------------------------------------------------------
  970.   # ● 起動中判定
  971.   #--------------------------------------------------------------------------
  972.   def starting
  973.     false
  974.   end
  975.   #--------------------------------------------------------------------------
  976.   # ● 通行可能判定
  977.   #     x : X 座標
  978.   #     y : Y 座標
  979.   #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
  980.   #--------------------------------------------------------------------------
  981.   if $DEBUG
  982.     def passable?(x, y, d)
  983.       new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  984.       new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  985.       return false unless $game_map.valid?(new_x, new_y)
  986.       return true if Input.press?(Input::CTRL)
  987.       super
  988.     end
  989.   else
  990.     def passable?(x, y, d)
  991.       new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  992.       new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  993.       return false unless $game_map.valid?(new_x, new_y)
  994.       super
  995.     end
  996.   end
  997.   #--------------------------------------------------------------------------
  998.   # ◆ キャラクタ通行可能判定
  999.   #--------------------------------------------------------------------------
  1000.   def character_passable?( x , y )
  1001.     $game_map.passages_char.passages_player( x , y )
  1002.   end
  1003.   #--------------------------------------------------------------------------
  1004.   # ● 指定位置に移動
  1005.   #     x : X 座標
  1006.   #     y : Y 座標
  1007.   #--------------------------------------------------------------------------
  1008.   def moveto_setup(x, y)
  1009.     @x = x % $game_map.width
  1010.     @y = y % $game_map.height
  1011.     move_update_setup
  1012.     @real_x = (@x << 7)
  1013.     @real_y = (@y << 7)
  1014.     @prelock_direction = 0
  1015.     center(@x, @y)
  1016.   end
  1017.   #--------------------------------------------------------------------------
  1018.   # ● 同位置のイベント起動判定
  1019.   #--------------------------------------------------------------------------
  1020.   def check_event_trigger_here(triggers)
  1021.     return false if $game_system.map_interpreter.running?
  1022.     if ( val = $game_map.check_event_player( x , y ))
  1023.       if val.is_a?(Array)
  1024.         for event_id in val
  1025.           event = $game_map.events[event_id]
  1026.           if triggers.include?(event.trigger)
  1027.             if not event.jumping? and event.over_trigger?
  1028.               event.start
  1029.               return true
  1030.             end
  1031.           end
  1032.         end
  1033.       end
  1034.     end
  1035.     return false
  1036.   end
  1037.   #--------------------------------------------------------------------------
  1038.   # ● 正面のイベント起動判定
  1039.   #--------------------------------------------------------------------------
  1040.   def check_event_trigger_there(triggers)
  1041.     return false if $game_system.map_interpreter.running?
  1042.     new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  1043.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  1044.     if ( val = $game_map.check_event_player( new_x , new_y ))
  1045.       if val.is_a?(Fixnum)
  1046.         event = $game_map.events[val]
  1047.         if triggers.include?(event.trigger)
  1048.           unless event.jumping? or event.over_trigger?
  1049.             event.start
  1050.             return true
  1051.           end
  1052.         end
  1053.       else
  1054.         for event_id in val
  1055.           event = $game_map.events[event_id]
  1056.           if triggers.include?(event.trigger)
  1057.             unless event.jumping? or event.over_trigger?
  1058.               event.start
  1059.               return true
  1060.             end
  1061.           end
  1062.         end
  1063.       end
  1064.     end
  1065.     return false unless $game_map.counter?(new_x, new_y)
  1066.     new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  1067.     new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  1068.     if ( val = $game_map.check_event_player( new_x , new_y ))
  1069.       if val.is_a?(Fixnum)
  1070.         event = $game_map.events[val]
  1071.         if TRIGGER_PLAYER.include?(event.trigger)
  1072.           unless event.jumping? or event.over_trigger?
  1073.             event.start
  1074.             return true
  1075.           end
  1076.         end
  1077.       else
  1078.         for event_id in val
  1079.           event = $game_map.events[event_id]
  1080.           if TRIGGER_PLAYER.include?(event.trigger)
  1081.             unless event.jumping? or event.over_trigger?
  1082.               event.start
  1083.               return true
  1084.             end
  1085.           end
  1086.         end
  1087.       end
  1088.     end
  1089.     return false
  1090.   end
  1091.   #--------------------------------------------------------------------------
  1092.   # ● 接触イベントの起動判定
  1093.   #--------------------------------------------------------------------------
  1094.   def check_event_trigger_touch(x, y)
  1095.     return false if $game_system.map_interpreter.running?
  1096.     if ( val = $game_map.check_event_player( x , y ))
  1097.       if val.is_a?(Fixnum)
  1098.         event = $game_map.events[val]
  1099.         if TRIGGER_PLAYER.include?(event.trigger)
  1100.          unless event.jumping? or event.over_trigger?
  1101.             event.start
  1102.             return true
  1103.           end
  1104.         end
  1105.       else
  1106.         for event_id in val
  1107.           event = $game_map.events[event_id]
  1108.           if TRIGGER_PLAYER.include?(event.trigger)
  1109.             unless event.jumping? or event.over_trigger?
  1110.               event.start
  1111.               return true
  1112.             end
  1113.           end
  1114.         end
  1115.       end
  1116.     end
  1117.     return false
  1118.   end
  1119. end


  1120. #==============================================================================
  1121. # ■ Spriteset_Map
  1122. #------------------------------------------------------------------------------
  1123. #  マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは
  1124. # Scene_Map クラスの内部で使用されます。
  1125. #==============================================================================
  1126. class Spriteset_Map
  1127.   #--------------------------------------------------------------------------
  1128.   # ● オブジェクト初期化
  1129.   #--------------------------------------------------------------------------
  1130.   def initialize
  1131.     @viewport1 = Viewport.new(0, 0, 640, 480)
  1132.     @viewport2 = Viewport.new(0, 0, 640, 480)
  1133.     @viewport3 = Viewport.new(0, 0, 640, 480)
  1134.     @viewport2.z = 200
  1135.     @viewport3.z = 5000
  1136.     @tilemap = Tilemap.new(@viewport1)
  1137.     @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  1138.     for i in 0..6
  1139.       autotile_name = $game_map.autotile_names[i]
  1140.       @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  1141.     end
  1142.     @tilemap.map_data = $game_map.data
  1143.     @tilemap.priorities = $game_map.priorities
  1144.     @panorama = Plane.new(@viewport1)
  1145.     @panorama.z = -1000
  1146.     @fog = Plane.new(@viewport1)
  1147.     @fog.z = 3000
  1148.     @character_sprites = Hash.new
  1149.     $game_map.events.each do | i , event |
  1150.       @character_sprites[i] = Sprite_Character.new(@viewport1, event)
  1151.     end
  1152.     Game_Character.character_method( charcter_method )
  1153.     @weather = RPG::Weather.new(@viewport1)
  1154.     @picture_sprites = []
  1155.     for i in 1..50
  1156.       @picture_sprites.push(Sprite_Picture.new(@viewport2,
  1157.         $game_screen.pictures[i]))
  1158.     end
  1159.     @timer_sprite = Sprite_Timer.new
  1160.     update
  1161.   end
  1162.   #--------------------------------------------------------------------------
  1163.   # ● 解放
  1164.   #--------------------------------------------------------------------------
  1165.   def dispose
  1166.     @tilemap.tileset.dispose
  1167.     for i in 0..6
  1168.       @tilemap.autotiles[i].dispose
  1169.     end
  1170.     @tilemap.dispose
  1171.     @panorama.dispose
  1172.     @fog.dispose
  1173.     unless @character_sprites.nil?
  1174.       @character_sprites.each_value do | sprite |
  1175.         sprite.dispose unless sprite.nil?
  1176.       end
  1177.     end
  1178.     @weather.dispose
  1179.     for sprite in @picture_sprites
  1180.       sprite.dispose
  1181.     end
  1182.     @timer_sprite.dispose
  1183.     @viewport1.dispose
  1184.     @viewport2.dispose
  1185.     @viewport3.dispose
  1186.   end
  1187.   #--------------------------------------------------------------------------
  1188.   # ● フレーム更新
  1189.   #--------------------------------------------------------------------------
  1190.   def update
  1191.     if @panorama_name != $game_map.panorama_name or
  1192.        @panorama_hue != $game_map.panorama_hue
  1193.       @panorama_name = $game_map.panorama_name
  1194.       @panorama_hue = $game_map.panorama_hue
  1195.       if @panorama.bitmap != nil
  1196.         @panorama.bitmap.dispose
  1197.         @panorama.bitmap = nil
  1198.       end
  1199.       if @panorama_name != ""
  1200.         @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  1201.       end
  1202.       Graphics.frame_reset
  1203.     end
  1204.     if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  1205.       @fog_name = $game_map.fog_name
  1206.       @fog_hue = $game_map.fog_hue
  1207.       if @fog.bitmap != nil
  1208.         @fog.bitmap.dispose
  1209.         @fog.bitmap = nil
  1210.       end
  1211.       if @fog_name != ""
  1212.         @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  1213.       end
  1214.       Graphics.frame_reset
  1215.     end
  1216.     @tilemap.ox = $game_map.display_x / 4
  1217.     @tilemap.oy = $game_map.display_y / 4
  1218.     @tilemap.update
  1219.     @panorama.ox = $game_map.display_x / 8
  1220.     @panorama.oy = $game_map.display_y / 8
  1221.     @fog.zoom_x = $game_map.fog_zoom / 100.0
  1222.     @fog.zoom_y = $game_map.fog_zoom / 100.0
  1223.     @fog.opacity = $game_map.fog_opacity
  1224.     @fog.blend_type = $game_map.fog_blend_type
  1225.     @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  1226.     @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  1227.     @fog.tone = $game_map.fog_tone
  1228.     $game_map.events.each do | i , event |
  1229.       @character_sprites[i].update if event.onscreen
  1230.     end
  1231.     @weather.type = $game_screen.weather_type
  1232.     @weather.max = $game_screen.weather_max
  1233.     @weather.ox = $game_map.display_x / 4
  1234.     @weather.oy = $game_map.display_y / 4
  1235.     @weather.update
  1236.     for sprite in @picture_sprites
  1237.       sprite.update
  1238.     end
  1239.     @timer_sprite.update
  1240.     @viewport1.tone = $game_screen.tone
  1241.     @viewport1.ox = $game_screen.shake
  1242.     @viewport3.color = $game_screen.flash_color
  1243.     @viewport1.update
  1244.     @viewport3.update
  1245.   end
  1246.   #--------------------------------------------------------------------------
  1247.   # ● キャラクター再代入 メソッド
  1248.   #--------------------------------------------------------------------------
  1249.   def charcter_method
  1250.     self.method(:charcter_change)
  1251.   end
  1252.   private
  1253.   #--------------------------------------------------------------------------
  1254.   # ◆(内部専用)◆ キャラクター再代入
  1255.   #--------------------------------------------------------------------------
  1256.   def charcter_change( character_id , character )
  1257.     if @character_sprites[character_id]
  1258.       @character_sprites[character_id].character = character
  1259.     end
  1260.   end
  1261. end

  1262. #==============================================================================
  1263. # ■ Sprite_Character
  1264. #------------------------------------------------------------------------------
  1265. #  キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを
  1266. # 監視し、スプライトの状態を自動的に変化させます。
  1267. #==============================================================================
  1268. class Sprite_Character < RPG::Sprite
  1269.   #--------------------------------------------------------------------------
  1270.   # ● 公開インスタンス変数
  1271.   #--------------------------------------------------------------------------
  1272.   attr_reader :character                # キャラクター
  1273.   #--------------------------------------------------------------------------
  1274.   # ● オブジェクト初期化
  1275.   #     viewport  : ビューポート
  1276.   #     character : キャラクター (Game_Character)
  1277.   #--------------------------------------------------------------------------
  1278.   def initialize(viewport, character = nil)
  1279.     begin
  1280.       super(viewport)
  1281.       @character = character
  1282.       update
  1283.     rescue Exception
  1284.       dispose
  1285.       raise
  1286.     end
  1287.   end
  1288.   #--------------------------------------------------------------------------
  1289.   # ● 解放
  1290.   #--------------------------------------------------------------------------
  1291.   def dispose
  1292.     unless self.bitmap.nil?
  1293.       self.bitmap.dispose
  1294.       self.bitmap = nil
  1295.     end
  1296.     super
  1297.   end
  1298.   #--------------------------------------------------------------------------
  1299.   # ● キャラクター代入
  1300.   #--------------------------------------------------------------------------
  1301.   def character=(character)
  1302.     if character.is_a?(Game_Character)
  1303.       @character = character
  1304.     end
  1305.   end
  1306.   #--------------------------------------------------------------------------
  1307.   # ● フレーム更新
  1308.   #--------------------------------------------------------------------------
  1309.   def update
  1310.     super
  1311.     if (self.visible = (not @character.transparent))
  1312.       if @tile_id != @character.tile_id or
  1313.          @character_name != @character.character_name or
  1314.          @character_hue != @character.character_hue
  1315.         @tile_id = @character.tile_id
  1316.         @character_name = @character.character_name
  1317.         @character_hue = @character.character_hue
  1318.         if @tile_id >= 384
  1319.           self.bitmap = RPG::Cache.tile( $game_map.tileset_name ,
  1320.                                          @tile_id , @character.character_hue )
  1321.           self.src_rect.set(0, 0, 32, 32)
  1322.           self.ox = 16
  1323.           self.oy = 32
  1324.           @character.size_change( 1, 1)
  1325.         else
  1326.           self.bitmap = RPG::Cache.character( @character.character_name ,
  1327.                                               @character.character_hue )
  1328.           @cw = bitmap.width >> 2
  1329.           @ch = bitmap.height >> 2
  1330.           self.ox = @cw >> 1
  1331.           self.oy = @ch
  1332.           if @cw >= LARGE_SET or @ch >= LARGE_SET
  1333.             size_x = 1
  1334.             size_y = 1
  1335.             until @cw < ( LARGE_SET + LARGE_SIZE * size_x )
  1336.               size_x += 1
  1337.             end
  1338.             until @ch < ( LARGE_SET + LARGE_SIZE * size_y )
  1339.               size_y += 1
  1340.             end
  1341.             @character.size_change((size_x << 1) + 1, size_y + 1)
  1342.           else
  1343.             @character.size_change( 1, 1)
  1344.           end
  1345.         end
  1346.       end
  1347.       if @tile_id.zero?
  1348.         sx = @character.pattern * @cw
  1349.         sy = ((@character.direction - 2) >> 1 ) * @ch
  1350.         self.src_rect.set(sx, sy, @cw, @ch)
  1351.       end
  1352.       self.x = @character.screen_x
  1353.       self.y = @character.screen_y
  1354.       self.z = @character.screen_z(@ch)
  1355.       self.opacity = @character.opacity
  1356.       self.blend_type = @character.blend_type
  1357.       self.bush_depth = @character.bush_depth
  1358.       unless @character.animation_id.zero?
  1359.         animation = $data_animations.at(@character.animation_id)
  1360.         animation(animation, true)
  1361.         @character.animation_id = 0
  1362.       end
  1363.     end
  1364.   end
  1365. end
复制代码



base
  1. # coding: utf-8
  2. # ===========================================================================
  3. # ★ WF-RGSS Scripts ★
  4. #    共通スクリプト(XP/VX/VXAce両対応版)
  5. # バージョン   : rev-29 (2013-3-26)
  6. # 作者         : WF-RGSS担当 (WHITE-FLUTE)
  7. # サポート先URI: [url]http://www.whiteflute.org/wfrgss/[/url]
  8. # ---------------------------------------------------------------------------
  9. # 機能:
  10. # ・このセクションより後ろのスクリプトでSyntaxError が発生しても
  11. #   別の例外にすりかえられるため、詳細情報が削除されなくなります。
  12. #   (VXAceでは標準で削除されなくなりました。)
  13. # ・SyntaxErrorの情報をファイルに書き出します。
  14. # ・不用意なデバッグモードへの遷移を防止します。
  15. #   (元からデバッグモードの場合は問題ありません。)
  16. # ・不正なデバッグモードへの遷移を阻害します。
  17. # ・デバッグコンソールを表示しデバッグしやすくします。
  18. # ---------------------------------------------------------------------------
  19. # 影響:
  20. # ・外部コマンド実行など一部の組み込み関数が未定義になります。
  21. # ・例外 SyntaxError は作成できません。(XP/VX)
  22. #   (※ ScriptSyntaxError にすりかえられます。)
  23. # ---------------------------------------------------------------------------
  24. # 設置場所:一番最初のセクション(Game_Temp(XP)/モジュール(VX/VXAce)よりも前)
  25. # 必要スクリプト:
  26. # ・共通実行スクリプト(VXAce は、Exit-EXで置き換える事ができます。)
  27. # 注意事項:
  28. #   共通実行スクリプトをMainセクションに上書きして利用することを推奨します。                       
  29. # ===========================================================================
  30. BEGIN {

  31. module WFRGSS
  32.   # -------------------------------------------------------------------------
  33.   # ● 調整ポイント
  34.   # -------------------------------------------------------------------------
  35.   # デバッグモード遷移を阻害するかを設定します。
  36.   # 確実に保護できるわけではありませんので過信は禁物です。

  37.   DEBUG_CHECK = true

  38.   # -------------------------------------------------------------------------
  39.   # デバッグモード時、デバッグコンソールを表示します。
  40.   # (VXAceでは設定に関わらず標準装備されています。)

  41.   DEBUG_CONSOLE = false

  42.   # -------------------------------------------------------------------------
  43.   # リリースモード時、デバッグメッセージを消去します。

  44.   DELETE_DEBUG_MESSAGE = false

  45.   # -------------------------------------------------------------------------
  46.   # XPのみ。 デバッグフラグをVX/VXAce準拠に修正するか?
  47.   # (!)スクリプト対応が必要となります。

  48.   DEBUG_FLAG_CHANGE = false


  49.   # -------------------------------------------------------------------------
  50.   # 調整ポイント終わり
  51.   # -------------------------------------------------------------------------
  52. end



  53. # ---------------------------------------------------------------------------
  54. # ● 例外定義
  55. # ---------------------------------------------------------------------------

  56. # 継承例外
  57. class InheritanceError < Exception;end

  58. # Mix-in 例外
  59. class IncludeError < Exception;end
  60.   
  61. # 仮想クラス、メソッドの使用
  62. class AbstractError < NotImplementedError;end

  63. # ◆ バグ検出
  64. #    バグ以外、絶対にありえない状態になったときに発生させてください。
  65. # ※ バグ報告を行うためのものなので途中で破棄してはいけません。
  66. class BugDetected < Exception;end

  67. # ◆ 内部バグ報告用
  68. # これは、WFRGSS でバグしかありえない状態に陥ったときに発生します。
  69. # ※ バグ報告を行うためのものなので途中で破棄してはいけません。
  70. class InternalBugDetected < BugDetected;end

  71. # イベント階層が深すぎる場合
  72. class EventDeepError < SystemStackError;end

  73. # 初期化失敗
  74. class InitializeError < TypeError;end

  75. # アサーション失敗
  76. class AssertionError < Exception;end

  77. # ◆ 例外 Hangup
  78. # ハングアップしたとみなされたときに投げられる例外。
  79. # 深い階層からでは捉えられないことがあるため、注意が必要
  80. # RPGVX/VXAceにはありませんが、XPとの互換性を保つため、設定しています。
  81. class Hangup < Exception;end

  82. # ◆ 例外 Reset
  83. # Graphics.update の呼び出し時にF12が押されていると投げられる例外。(XP)
  84. # F12 が押されていると投げられる例外(VX)
  85. # これがセクション外に出ると
  86. # 最初のセクションから再び実行をやり直そうとします。
  87. # この操作は、組み込みクラスのメソッドにて、
  88. # alias や undef が使われていると
  89. # 不具合の元になります。
  90. class Reset < Exception;end

  91. # セキュリティ違反
  92. class SecurityHazard < Exception;end

  93. # RPGXP互換性のため
  94. if WFRGSS::DEBUG_FLAG_CHANGE
  95.   $TEST = $DEBUG
  96.   $DEBUG = false
  97. else
  98.   $TEST = false unless $TEST
  99. end

  100. module WFRGSS
  101.   @@debug = ($TEST or $DEBUG)
  102.   def self.check
  103.     debug = ($TEST or $DEBUG)
  104.     if debug != @@debug or (@@debug and
  105.        (FileTest.file?("Game.rgssad") or FileTest.file?("Game.rgss2a") or
  106.         FileTest.file?("Game.rgss3a")))
  107.       raise(SecurityHazard ,"Insecure - debug flag can't be change.")
  108.     end
  109.   end
  110. end

  111. # ---------------------------------------------------------------------------
  112. # ◆◆ デバッグモード阻止対策
  113. # ---------------------------------------------------------------------------
  114. # デバッグモード防止策
  115. if defined? untrace_var
  116.   undef untrace_var
  117.   # デバッグモードでない場合、デバッグモードへの遷移を禁止する
  118.   proc = Proc.new {
  119.     if $DEBUG
  120.       $DEBUG = false
  121.       $TEST = false
  122.       $BTEST = false
  123.       raise(SecurityHazard ,"Insecure - debug flag can't be change.", caller(1))
  124.     end
  125.   }
  126.   trace_var( :$DEBUG , proc )
  127.   trace_var( :$-d , proc )    # $DEBUG の別名
  128.   proc = nil
  129.   
  130.   # デバッグモードでない場合、デバッグモードへの遷移を禁止する
  131.   proc = Proc.new {
  132.     if $TEST
  133.       $DEBUG = false
  134.       $TEST = false
  135.       $BTEST = false
  136.       raise(SecurityHazard ,"Insecure - debug flag can't be change.", caller(1))
  137.     end
  138.   }
  139.   trace_var( :$TEST , proc )  # RPGVX デバッグフラグ
  140.   proc = nil
  141.   
  142.   # 戦闘テストで無い場合、戦闘テストへの遷移を禁止する
  143.   proc = Proc.new {
  144.     if $BTEST
  145.       $DEBUG = false
  146.       $TEST = false
  147.       $BTEST = false
  148.       raise(SecurityHazard ,"Insecure - battle test flag can't be change.",
  149.                caller(1))
  150.     end
  151.   }
  152.   trace_var( :$BTEST , proc )
  153.   proc = nil
  154. end

  155. unless defined? ScriptSyntaxError
  156.   # RGSSでは、本来持っているSyntaxErrorの詳細情報をすべて削除してしまい、
  157.   # デバッグが非常に困難になってしまいます。
  158.   # そのために用意されている例外です。
  159.   # ※特にイベントスクリプト上でSyntaxErrorを出すととても悲惨なことに…
  160.   #  「スクリプト実行中に SyntaxError が発生しました。」だけで
  161.   #   すぐに修正できるのでしょうか?
  162.   class ScriptSyntaxError < Exception;end
  163.   # -------------------------------------------------------------------------
  164.   # ◆ 組み込み例外クラス SyntaxError <obsolete>
  165.   # -------------------------------------------------------------------------
  166.   # RGSSでは、本来持っているSyntaxErrorの詳細情報をすべて削除してしまうため、
  167.   # SyntaxError のコンストラクタを乗っ取って別の例外にすりかえています。
  168.   # ※ SyntaxError のインスタンスは作成できません。
  169.   class SyntaxError < ScriptError
  170.     ERROR = Hash.new
  171.   end
  172.   class << SyntaxError
  173.     #--------------------------------------------------------------------------
  174.     # ◆ (!※継承禁止※!)
  175.     #--------------------------------------------------------------------------
  176.     def SyntaxError.inherited( subclass )
  177.       raise( InheritanceError ,
  178.              "can't inherit class #{subclass} from #{self}" , caller(1) )
  179.     end
  180.     private_class_method(:inherited)
  181.     unless defined? BasicObject
  182.       undef allocate
  183.       undef new
  184.       #------------------------------------------------------------------------
  185.       # ◆ 強制的に別の例外にすりかえる
  186.       #------------------------------------------------------------------------
  187.       def new( errors , *args )
  188.         error_message = make_error_message(errors)
  189.         error_message_dump(error_message)
  190.         ScriptSyntaxError.new(error_message)
  191.       end
  192.     else
  193.       alias __wfrgss__new__ new unless $!
  194.       def new( errors , *args )
  195.         error_message = make_error_message(errors)
  196.         error_message_dump(error_message)
  197.         __wfrgss__new__(errors)
  198.       end
  199.     end
  200.     private
  201.     #----------------------------------------------------------------------------
  202.     # ◆(内部専用)◆ エラーメッセージ作成
  203.     #----------------------------------------------------------------------------
  204.     def make_error_message( error_message )
  205.       extra = ""
  206.       unless (error_message[/^(?:Section)?{?(\d+)}?:(\d+):/]).nil?
  207.         nums = $1.to_i     # セクションを拾い出した場合
  208.         extra = $RGSS_SCRIPTS.at(nums).at(1)
  209.         unless $2.nil?
  210.           lines = $2.to_i
  211.           unless ($RGSS_SCRIPTS.at(nums).at(3)).nil?
  212.             details = show_details_source_code( nums , lines )
  213.             unless details.empty?
  214.              error_message += "\n** script source code:\n#{details}"
  215.             else
  216.               error_message +=
  217.               "\n** script source code:#{lines} unknown data.\n"
  218.             end
  219.           end
  220.         end
  221.       end
  222.       error_message.gsub!(/^(?:Section)?{?(\d+)}?:/){"( #{extra} ):#{$1}:lines "}
  223.       error_message
  224.     end
  225.     #--------------------------------------------------------------------------
  226.     # ◆(内部専用)◆ 情報を書きこみ
  227.     #--------------------------------------------------------------------------
  228.     def error_message_dump(error_message)
  229.       e = Zlib::crc32(error_message)
  230.       return if SyntaxError::ERROR[e]
  231.       SyntaxError::ERROR[e] = true
  232.       File.open("syntaxerror.txt","a") do | file |
  233.         file.write("*SyntaxError - " +
  234.                   (Time.now).strftime("%Y-%m-%d %H:%M:%S (%A)") + "\n")
  235.         file.write( "#{error_message}\n" )
  236.       end
  237.     end
  238.     #--------------------------------------------------------------------------
  239.     # ◆(内部専用)◆ ソースコード位置読み込み
  240.     #--------------------------------------------------------------------------
  241.     def show_details_source_code( nums , lines )
  242.       details = ""
  243.       splitstr = ($RGSS_SCRIPTS.at(nums).at(3)).split(/\r\n/)
  244.       if lines < 4
  245.         ranges = ( 0...( lines + 3 ))
  246.       else
  247.         ranges = (( lines - 4 )...( lines + 3 ))
  248.       end
  249.       for i in ranges
  250.         unless (splitstr.at(i)).nil?
  251.           if i != (lines - 1)
  252.             details += "|" + splitstr.at(i) + "\n"
  253.           else
  254.             details += ">" + splitstr.at(i) + "\n"
  255.           end
  256.         else
  257.           details += "[End of File]\n"
  258.           break
  259.         end
  260.       end
  261.       splitstr = nil
  262.       rpgvxace? ? details.force_encoding("UTF-8") : details
  263.     end
  264.   end


  265.   # -------------------------------------------------------------------------
  266.   # ◆ RGSS 組み込みモジュール Graphics
  267.   # -------------------------------------------------------------------------

  268.   class << Graphics
  269.     #------------------------------------------------------------------------
  270.     # ◆ リセットを無視する Graphics.update
  271.     #------------------------------------------------------------------------
  272.     def Graphics.safe_update
  273.       begin
  274.         update
  275.       rescue Reset
  276.         # リセット操作を無視する。
  277.         # ただしカーソルアニメーションなどが巻き戻される。
  278.         nil
  279.       end
  280.     end

  281.     if WFRGSS::DEBUG_CHECK
  282.     #------------------------------------------------------------------------
  283.     # ◆ Graphics.update にチェックを加える
  284.     #------------------------------------------------------------------------
  285.       alias ___original__update___ update
  286.       def Graphics.update
  287.         WFRGSS.check
  288.         ___original__update___
  289.       end
  290.       private(:___original__update___)
  291.     end
  292.   end

  293.   module Graphics
  294.     # -----------------------------------------------------------------------
  295.     # ◆ クラス変数
  296.     # -----------------------------------------------------------------------
  297.     @@rate = 0
  298.     @@count = 0
  299.     # -----------------------------------------------------------------------
  300.     # ◆ フレームレートを一時的に変更
  301.     # -----------------------------------------------------------------------
  302.     def self.frame_workset( frame_rates )
  303.       @@rate = Graphics.frame_rate
  304.       @@count = Graphics.frame_count
  305.       Graphics.frame_rate = frame_rates
  306.     end
  307.     # -----------------------------------------------------------------------
  308.     # ◆ フレームレートを元に戻す
  309.     # -----------------------------------------------------------------------
  310.     def self.frame_restore
  311.       cnt = Graphics.frame_count - @@count
  312.       cnt *= @@rate
  313.       cnt /= Graphics.frame_rate
  314.       Graphics.frame_count = @@count + cnt
  315.       Graphics.frame_rate = @@rate
  316.     end
  317.     # -----------------------------------------------------------------------
  318.     # ◆ 解像度横の幅(VX/VXAceでは無視される)
  319.     # -----------------------------------------------------------------------
  320.     unless defined? Graphics.width
  321.       def self.width
  322.         640
  323.        end
  324.     end
  325.     # -----------------------------------------------------------------------
  326.     # ◆ 解像度縦の幅(VX/VXAceでは無視される)
  327.     # -----------------------------------------------------------------------
  328.     unless defined? Graphics.height
  329.       def self.height
  330.         480
  331.       end
  332.     end
  333.   end
  334. end

  335. # ---------------------------------------------------------------------------
  336. # ◆ 組み込みモジュール GC
  337. # ---------------------------------------------------------------------------
  338. module GC
  339.   module_function
  340.   #--------------------------------------------------------------------------
  341.   # ◆ 安全にガーベージコレクションを行う
  342.   #--------------------------------------------------------------------------
  343.   def update_start
  344.     Graphics.safe_update
  345.     start
  346.     Graphics.safe_update
  347.   end
  348. end

  349. }

  350. unless defined? Abstract
  351. # -----------------------------------------------------------------------------
  352. # ◆◆ 組み込みクラス Class
  353. # -----------------------------------------------------------------------------
  354. class Class
  355.   # ---------------------------------------------------------------------------
  356.   # ◆ クラス変数
  357.   # ---------------------------------------------------------------------------
  358.   @@_abstract_class = Hash.new
  359.   # ---------------------------------------------------------------------------
  360.   # ◆ 抽象クラス追加
  361.   # ---------------------------------------------------------------------------
  362.   def self.abstract_class( klass )
  363.     __failure_type_call__( klass ) unless klass.is_a?(Class)
  364.     unless @@_abstract_class[klass.__id__]
  365.       @@_abstract_class[klass.__id__] = klass
  366.     end
  367.   end
  368.   # ---------------------------------------------------------------------------
  369.   # ◆ 抽象クラス判定
  370.   # ---------------------------------------------------------------------------
  371.   def self.abstract?( klass )
  372.     @@_abstract_class[klass.__id__]
  373.   end
  374. end

  375. module Abstract
  376.   # ---------------------------------------------------------------------------
  377.   # ◆ 抽象化
  378.   # ---------------------------------------------------------------------------
  379.   def self.included( klass )
  380.     if klass.include?(FinalClass)
  381.       # FinalClass モジュールが既にインクルードされている
  382.       raise( IncludeError ,
  383.            "can't include #{klass} from #{self}" , caller(1) )
  384.     end
  385.     Class.abstract_class( klass )   
  386.     klass.extend(Abstract_Class__)
  387.   end
  388.   private_class_method(:included)
  389. end

  390. # ---------------------------------------------------------------------------
  391. # ◆ 抽象化 ※ 特異メソッド専用 ※
  392. # ---------------------------------------------------------------------------
  393. module Abstract_Class__
  394.   # -------------------------------------------------------------------------
  395.   # ◆ ※ 抽象クラス
  396.   # -------------------------------------------------------------------------
  397.   def allocate
  398.     return super unless Class.abstract?( self )
  399.     raise( AbstractError ,
  400.       "class #{self} cannot use it because of the abstraction class.",
  401.       caller(1) )
  402.   end
  403.   # -------------------------------------------------------------------------
  404.   # ◆ ※ 抽象クラス
  405.   # -------------------------------------------------------------------------
  406.   def new( *args )
  407.     return super unless Class.abstract?( self )
  408.     raise( AbstractError ,
  409.       "class #{self} cannot use it because of the abstraction class.",
  410.       caller(1) )
  411.   end
  412.   # -------------------------------------------------------------------------
  413.   # ◆ ※ Mix-in 制限
  414.   # -------------------------------------------------------------------------
  415.   def self.included( klass )
  416.     unless self.is_a?(Class)
  417.       raise( IncludeError ,
  418.            "can't include #{klass} from #{self}" , caller(1) )
  419.     end
  420.   end
  421. end

  422. module FinalClass
  423.   # ---------------------------------------------------------------------------
  424.   # ◆ 継承できないクラス
  425.   # ---------------------------------------------------------------------------
  426.   def self.included( klass )
  427.     if Class.abstract?( klass )
  428.       # Abstract モジュールが既にインクルードされている
  429.       raise( IncludeError ,
  430.              "can't include #{klass} from #{self}" , caller(1) )
  431.     end
  432.     klass.module_eval(<<-End)
  433.       def self.inherited( subclass )
  434.         raise( InheritanceError ,
  435.         sprintf("can't inherit class %s from %s",subclass.inspect,
  436.                 self.inspect ) , caller(1) )
  437.       end
  438.       private_class_method(:inherited)
  439.     End
  440.   end
  441.   private_class_method(:included)
  442. end

  443. # ---------------------------------------------------------------------------
  444. # ◆ 組み込みモジュール Kernel
  445. # ---------------------------------------------------------------------------

  446. module Kernel
  447.   # ---------------------------------------------------------------------------
  448.   # ◆ 危険な関数を未定義に設定
  449.   # ---------------------------------------------------------------------------
  450.   # 外部コマンド読み込みなど危険な操作は明示的に禁止にします。
  451.   # ※ これらのコマンドの必要性が(通常は)ないうえ、
  452.   #    危険(システム破壊をもたらすことがある)なため取り外しています。
  453.   # ※ もし、これらを使用する場合は、効果と危険性を考慮してください。
  454.   # ---------------------------------------------------------------------------
  455.   # 外部コマンドを実行する。
  456.   undef `       #` # 外部コマンドを実行する。
  457.   undef exec    # 外部コマンドを実行する 制御を返さない。
  458.   undef fork    # サブシェルを生成する。
  459.   undef system  # 外部コマンドを実行する。
  460.   undef abort   # 後処理を行わずに強制終了する。後処理が必要な時に困る。
  461.   undef exit!   # abort と同じ。
  462.   undef open    # コマンドが実行できる。(ファイルを開くならIO.openを用いる)
  463.   #--------------------------------------------------------------------------
  464.   private
  465.   #--------------------------------------------------------------------------
  466.   # ◆ RPGVX/VXAce かどうか
  467.   #--------------------------------------------------------------------------
  468.   def rpgvx?
  469.     defined? Graphics.resize_screen
  470.   end
  471.   #--------------------------------------------------------------------------
  472.   # ◆ RPGVXAce かどうか
  473.   #--------------------------------------------------------------------------
  474.   def rpgvxace?
  475.     defined? BasicObject
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ◆ RGSSのバージョン
  479.   #--------------------------------------------------------------------------
  480.   def rgss_version
  481.     rpgvx? ? (rpgvxace? ? 3 : 2 ) : 1
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ◆ テストモードかどうか
  485.   #--------------------------------------------------------------------------
  486.   def debug?
  487.     $DEBUG or $TEST
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # ◆ デバッグコンソール
  491.   #--------------------------------------------------------------------------
  492.   if WFRGSS::DEBUG_CONSOLE and debug? and (not rpgvxace?)
  493.     unless $@
  494.       $VERBOSE = true
  495.       alias wfrgss_p p
  496.       Win32API.new("kernel32","AllocConsole",'v','l').call
  497.       $stdout.reopen("conout$","w")
  498.       def p(*a)
  499.         a.each{|v|$stdout.puts(String.utf82ansi(v.inspect))}
  500.       end
  501.     end
  502.   elsif WFRGSS::DELETE_DEBUG_MESSAGE
  503.     unless $@
  504.       alias display_p p
  505.       def p(*a)
  506.         # 何も出力しない
  507.       end
  508.     end
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ◆ 例外セット
  512.   #    例外を発生させます。
  513.   #--------------------------------------------------------------------------
  514.   # ◆ method_missing と同様
  515.   #--------------------------------------------------------------------------
  516.   def __failure_method_call__( method_name , *args )
  517.     raise( NoMethodError ,
  518.            "undefined method `#{method_name}' for #{self}" , caller(2) )
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ◆ オーバーライドが必要
  522.   #--------------------------------------------------------------------------
  523.   def __override_required_call__( method_name , *args )
  524.     raise( AbstractError ,
  525.            "It is necessary to do override to use method `#{method_name}'" +
  526.            " of this class #{self}. " +
  527.            "(or, it tried to call the method of a super-class.)" , caller(2))
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ◆ 例外 TypeErrorを発生させる
  531.   #--------------------------------------------------------------------------
  532.   def __failure_type_call__( object_type )
  533.     e = ( object_type.class ).to_s
  534.     raise( TypeError , "no implicit conversion from #{e}" , caller(2) )
  535.   end
  536.   #--------------------------------------------------------------------------
  537.   # ◆ 例外 RangeErrorを発生させる ( num が Numeric でない場合はBugDetected )
  538.   #--------------------------------------------------------------------------
  539.   def __outof_range_call__( num , str , call_value = 2 )
  540.     if num.is_a?(Numeric)
  541.       if str.is_a?(String)
  542.         raise( RangeError , "#{num} out of range of #{str}",caller(call_value))
  543.       else
  544.         e = ( str.class ).to_s
  545.         raise(TypeError,"no implicit conversion from #{e}",caller(call_value))
  546.       end
  547.     else
  548.       e = ( num.class ).to_s
  549.       raise( BugDetected, "[BUG] no implicit conversion from #{e} (TypeError)",
  550.              caller(1))
  551.     end
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # ◆ 例外 ArgumentErrorを発生させる ( str が String でない場合はBugDetected )
  555.   #--------------------------------------------------------------------------
  556.   def __invalid_value_call__( str , value , call_value = 2 )
  557.     if str.is_a?(String)
  558.       raise( ArgumentError , "invalid #{str} for #{value.to_s}")
  559.     else
  560.       e = ( str.class ).to_s
  561.       raise( BugDetected, "[BUG] no implicit conversion from #{e} (TypeError)",
  562.              caller(1))
  563.     end
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # ◆ 例外 SecurityErrorを発生させる ( str が String でない場合はBugDetected )
  567.   #--------------------------------------------------------------------------
  568.   def __insecure_call__( str )
  569.     if str.is_a?(String)
  570.       raise( SecurityError , "Insecure operation - #{str}" , caller(2) )
  571.     else
  572.       e = ( str.class ).to_s
  573.       raise( BugDetected, "[BUG] no implicit conversion from #{e} (TypeError)",
  574.              caller(1))
  575.     end
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # ◆ バグを報告する。 ( str が String でない場合も BugDetected )
  579.   #--------------------------------------------------------------------------
  580.   def __report_bug( str )
  581.     if str.is_a?(String)
  582.       raise( BugDetected , str , caller(1))
  583.     else
  584.       e = ( str.class ).to_s
  585.       raise( BugDetected ,
  586.              "[BUG] no implicit conversion from #{e} (TypeError)" , caller(1) )
  587.     end
  588.   end
  589.   #--------------------------------------------------------------------------
  590.   # ◆ バグを報告する。(異常な値を検出)
  591.   #--------------------------------------------------------------------------
  592.   def __report_bug_invalid_value( value )
  593.     raise( BugDetected , "[BUG] invalid value for #{value}", caller(1))
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ◆※!※◆ WF-RGSS の バグを報告する。
  597.   #    ※ このメソッドは WF-RGSS 内部バグを報告するためのものです。
  598.   #    ※ カスタマイズ時にバグを報告したい場合は、
  599.   #       __report_bug( str ) を使用してください。
  600.   #--------------------------------------------------------------------------
  601.   def __report_internal_bug( str )
  602.     if str.is_a?(String)
  603.       raise( InternalBugDetected , str , caller(1))
  604.     else
  605.       e = ( str.class ).to_s
  606.       raise( InternalBugDetected ,
  607.              "[BUG] no implicit conversion from #{e} (TypeError)" , caller(1) )
  608.     end
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ◆ チェック関連メソッド
  612.   #    型や範囲をチェックします。
  613.   #--------------------------------------------------------------------------
  614.   # ◆ 型が合わない場合、例外 TypeErrorを発生させる
  615.   #    (※ klass が異常な場合はBugDetected )
  616.   #--------------------------------------------------------------------------
  617.   def _type_check_( object_type , klass , call_value = 2 )
  618.     begin
  619.       return if object_type.is_a?(klass)
  620.       e = ( object_type.class ).to_s
  621.       raise( TypeError,"no implicit conversion from #{e}")
  622.     rescue TypeError => errobj
  623.       # 例外の報告位置をすりかえる
  624.       if errobj.message[/^no/].nil?
  625.         raise( BugDetected , "[BUG] #{errobj.message} (TypeError)",caller(1))
  626.       else
  627.         raise( TypeError , errobj.message , caller(call_value))
  628.       end
  629.     end
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ◆ Fixnum の範囲を検証する ※範囲が異常なら例外を発生させる
  633.   #--------------------------------------------------------------------------
  634.   def _fixnum_range_check( value , minimum , maximum )
  635.     __failure_type_call__( value , 3 ) unless value.is_a?(Fixnum)
  636.     unless value >= minimum and value <= maximum
  637.       # 範囲外のため、例外を発生させる
  638.       call_ary = caller(1)
  639.       if call_ary.size > 0
  640.         sections = call_ary.at(0)
  641.         str = sections + " ( range #{minimum} .. #{maximum} )"
  642.       else
  643.         str = "caller method (unknown) ( range #{minimum} .. #{maximum} )"
  644.       end
  645.       __outof_range_call__( value , str , 3 )
  646.     end
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ◆ Integer の範囲にまとめる (※処理速度が求められる箇所では用いない)
  650.   #    ※異常範囲が認められていない場合は、↑のメソッドを用いること
  651.   #--------------------------------------------------------------------------
  652.   def _integer_range_value( value , minimum , maximum )
  653.     __failure_type_call__( value , 3 ) unless value.is_a?(Integer)
  654.     if value < minimum
  655.       return minimum
  656.     elsif value > maximum
  657.       return maximum
  658.     else
  659.       return value
  660.     end
  661.   end
  662.   # ---------------------------------------------------------------------------
  663.   # 可視性を変更
  664.   public
  665.   # これ以降はモジュール関数として定義
  666.   module_function
  667.   # ---------------------------------------------------------------------------
  668.   # ◆ 真 を検証
  669.   # ---------------------------------------------------------------------------
  670.   def assert_if( value )
  671.     unless value
  672.       raise(AssertionError,"Assertion Failed (false for true)",caller(1))
  673.     end
  674.   end
  675.   # ---------------------------------------------------------------------------
  676.   # ◆ 偽 を検証
  677.   # ---------------------------------------------------------------------------
  678.   def assert_unless( value )
  679.     if value
  680.       raise(AssertionError,"Assertion Failed (true for false)",caller(1))
  681.     end
  682.   end
  683. end

  684. # ---------------------------------------------------------------------------
  685. # ◆ 組み込みクラス Object
  686. # ---------------------------------------------------------------------------
  687. class Object
  688.   # 可視性を変更
  689.   private
  690.   #--------------------------------------------------------------------------
  691.   # ◆ Mix-in禁止を実装
  692.   #--------------------------------------------------------------------------
  693.   def self.__cannot_mixin( klass )
  694.     raise( IncludeError ,
  695.            "can't include #{klass} from #{self}" , caller(2) )
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ◆ 継承禁止を実装
  699.   #--------------------------------------------------------------------------
  700.   def self.__cannot_inherited( subclass )
  701.     raise( InheritanceError ,
  702.            "can't inherit class #{subclass} from #{self}" , caller(2) )
  703.   end
  704.   #--------------------------------------------------------------------------
  705.   # ◆ 抽象クラス (かならず継承が必要となる)
  706.   #--------------------------------------------------------------------------
  707.   def __abstract_class( target )
  708.     klass = self.class
  709.     unless target.is_a?(Class) or target.is_a?(Module)
  710.       __report_bug("[BUG] class or modules required (TypeError)")
  711.     end
  712.     until ( klass = klass.superclass ) == Object
  713.       return if klass == target
  714.     end
  715.     raise( AbstractError ,
  716.       "class #{target} cannot use it because of the abstraction class.",
  717.       caller(2) )
  718.   end
  719. end

  720. # ---------------------------------------------------------------------------
  721. # ◆ 組み込みクラス String
  722. # ---------------------------------------------------------------------------
  723. class String
  724.   # ---------------------------------------------------------------------------
  725.   # ◆ 定数
  726.   # ---------------------------------------------------------------------------
  727.   CP_ACP   = 0         # ANSI コード
  728.   CP_UTF7  = 65000     # UTF-7 コード
  729.   CP_UTF8  = 65001     # UTF-8 コード
  730.   EMPTY_STR = "".freeze
  731.   #--------------------------------------------------------------------------
  732.   # ◆ クラス変数
  733.   #--------------------------------------------------------------------------
  734.   @@rm = Win32API.new('kernel32','RtlZeroMemory',%w(p l),'l').freeze
  735.   # 文字列をワイド文字列(Unicode)にマップするAPI
  736.   @@mb2wc = Win32API.new('kernel32',
  737.                         'MultiByteToWideChar', %w(i l p i p i), 'l').freeze
  738.   # ワイド文字列を新しい文字列にマップするAPI
  739.   @@wc2mb = Win32API.new('kernel32',
  740.                       'WideCharToMultiByte', %w(i l p i p i p p), 'l').freeze
  741.   #--------------------------------------------------------------------------
  742.   # ◆ クリア
  743.   #--------------------------------------------------------------------------
  744.   unless rpgvxace?
  745.     def clear
  746.       @@rm.call( self , self.size )
  747.       self.replace("")
  748.     end
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ◆ エンコード
  752.   #--------------------------------------------------------------------------
  753.   def encode_by_
  754.     for i in 0...self.size
  755.       self[i] = 256 - self[i]
  756.     end
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   # ◆ UTF-8 → ANSI 変換
  760.   #--------------------------------------------------------------------------
  761.   unless rpgvxace?
  762.     def self.utf82ansi( str )
  763.       to_multibyte( to_widechar( str , CP_UTF8 ) , CP_ACP )
  764.     end
  765.   else
  766.     def self.utf82ansi( str )
  767.      to_multibyte(to_widechar(str,CP_UTF8),CP_ACP).force_encoding("ASCII-8BIT")
  768.     end
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # ◆ ANSI → UTF-8 変換
  772.   #--------------------------------------------------------------------------
  773.   unless rpgvxace?
  774.     def self.ansi2utf8( str )
  775.       to_multibyte( to_widechar( str , CP_ACP ) , CP_UTF8 )
  776.     end
  777.   else
  778.     def self.ansi2utf8( str )
  779.       to_multibyte(to_widechar(str,CP_ACP),CP_UTF8).force_encoding("UTF-8")
  780.     end
  781.   end
  782.   private  # 可視性を private に変更
  783.   #--------------------------------------------------------------------------
  784.   # ◆(内部専用)◆ ワイド文字列( Unicode ) へ変換
  785.   #--------------------------------------------------------------------------
  786.   def self.to_widechar( str , codepage )
  787.     length = @@mb2wc.call( codepage , 0 , str , -1 , nil , 0 )
  788.     unless length.zero?
  789.       buffer = "\x00" * ( length << 1 )
  790.       unless (@@mb2wc.call( codepage ,0,str,-1,buffer,length)).zero?
  791.         return buffer
  792.       else
  793.         return ""
  794.       end
  795.     else
  796.       return ""
  797.     end
  798.   end
  799.   private_class_method(:to_widechar)
  800.   #--------------------------------------------------------------------------
  801.   # ◆(内部専用)◆ ワイド文字列( Unicode ) から 文字列を取得する
  802.   #--------------------------------------------------------------------------
  803.   def self.to_multibyte( str , codepage )
  804.     length = @@wc2mb.call( codepage , 0 , str , -1 , nil , 0 , nil , nil )
  805.     unless length.zero?
  806.       buffer = "\x00" * length
  807.       unless (@@wc2mb.call(codepage,0,str,-1,buffer,buffer.size,nil,nil)).zero?
  808.         return buffer
  809.       else
  810.         return ""
  811.       end
  812.     else
  813.       return ""
  814.     end
  815.   end
  816.   private_class_method(:to_multibyte)
  817. end

  818. # ---------------------------------------------------------------------------
  819. # ◆ モジュール ErrorLogWriter
  820. # ---------------------------------------------------------------------------

  821. module ErrorLogWriter
  822.   #--------------------------------------------------------------------------
  823.   # ◆(内部専用)◆ Mix-in 禁止
  824.   #--------------------------------------------------------------------------
  825.   def self.included( klass )
  826.     __cannot_mixin( klass )
  827.   end
  828.   private_class_method(:included)
  829.   
  830.   ERROR_SECTION_NUM = (/^(?:Section)?{?(\d+)}?:/).freeze
  831.   ERROR_SECTION     = (/^(?:Section)?{?\d+}?:/).freeze
  832.   DOUBLE_CRLF       = (/\n\n/).freeze
  833.   # -------------------------------------------------------------------------
  834.   # ◆ エラー情報を記録 ( DEBUG のみ )
  835.   # -------------------------------------------------------------------------
  836.   def self.write( errobj )
  837.     return unless debug?
  838.     begin
  839.       begin
  840.         Graphics.safe_update
  841.       rescue SecurityHazard
  842.       end
  843.       sleep(0.1)
  844.       File.open("errors.txt","a") do | file |
  845.         file.write("*Error - " +
  846.                   (Time.now).strftime("%Y-%m-%d %H:%M:%S (%A)") + "\n")
  847.         file.write( "Exception : #{errobj.class}\n" )
  848.         file.write( errobj.message )
  849.         unless $@.nil? and $@.empty?
  850.           backtrace = ""
  851.           for str in $@.dup
  852.             unless (str[ERROR_SECTION_NUM]).nil?
  853.               extra = $RGSS_SCRIPTS.at($1.to_i).at(1)
  854.               str.gsub!(ERROR_SECTION) { "( " + extra + " ):" }
  855.             end
  856.             backtrace += str
  857.            end
  858.           file.write( "\ntrace:\n" + $@.inspect + "\n" )
  859.         end
  860.       end
  861.     rescue Exception => errs
  862.       raise( errs ,
  863.       errs.message + "\n (" + (errobj.class).to_s + " )\n" + errobj.message )
  864.     end
  865.   end
  866. end

  867. end

  868. module MessageBox
  869.   #----------------------------------------------------------------------------
  870.   # ◆(内部専用)◆ Mix-in 禁止
  871.   #----------------------------------------------------------------------------
  872.   def self.included( klass )
  873.     raise( IncludeError , "can't include #{klass} from #{self}" , caller(1) )
  874.   end
  875.   private_class_method(:included)
  876.   # ---------------------------------------------------------------------------
  877.   # ◆ 定数
  878.   # ---------------------------------------------------------------------------
  879.   MB_OK               = 0x0    #
  880.   MB_OKCANCEL         = 0x1    #
  881.   MB_ABORTRETRYIGNORE = 0x2    #
  882.   MB_YESNOCANCEL      = 0x3    #
  883.   MB_YESNO            = 0x4    #
  884.   MB_RETRYCANCEL      = 0x5    #
  885.   
  886.   MB_ICONERROR        = 0x10     # エラー
  887.   MB_ICONQUESTION     = 0x20     # 問い合わせ
  888.   MB_ICONWARNING      = 0x30     # 警告
  889.   MB_ICONINFORMATION  = 0x40     # 情報
  890.   MB_SYSTEMMODAL      = 0x1000   # システムモーダル
  891.   MB_TASKMODAL        = 0x2000   # タスクモーダル
  892.   MB_TOPMOST          = 0x040000 # 最前面
  893.   MB_FATAL            = 0x042010 # 致命的エラー用
  894.   MB_WARN             = 0x042030 # 警告
  895.   
  896.   IDOK     = 1
  897.   IDCANCEL = 2
  898.   IDABORT  = 3
  899.   IDRETRY  = 4
  900.   IDIGNORE = 5
  901.   IDYES    = 6
  902.   IDNO     = 7
  903.   # ---------------------------------------------------------------------------
  904.   # ◆ 内部使用定数
  905.   # ---------------------------------------------------------------------------
  906.   ERROR_SECTION_NUM = (/^(?:Section)?{?(\d+)}?:/).freeze
  907.   ERROR_SECTION     = (/^(?:Section)?{?\d+}?:/).freeze
  908.   DOUBLE_CRLF       = (/\n\n/).freeze

  909.   begin
  910.     # メッセージボックス
  911.     @@mb = Win32API.new('user32', 'MessageBoxA', %w(p p p i), 'i').freeze
  912.   rescue Exception
  913.     # 取得失敗
  914.     Script_Deleter.finalizer
  915.     raise( LoadError , "cannot read modules.(user32.dll)",caller(0))  
  916.   end
  917.   begin
  918.     # ini ファイルから、セクションのキーを取得するAPI
  919.     @@gpps = Win32API.new('kernel32',
  920.                       'GetPrivateProfileStringA',%w(p p p p l p),'l').freeze
  921.   rescue Exception
  922.     # 取得失敗
  923.     Script_Deleter.finalizer
  924.     raise( LoadError , "cannot read modules.(kernel32.dll)",caller(0))
  925.   end
  926.   #--------------------------------------------------------------------------
  927.   # ◆(!要注意メソッド!)◆ メッセージボックスを表示
  928.   #   ※警告 :例外 Hangup 対策をかならず行うこと!
  929.   #--------------------------------------------------------------------------
  930.   def self.messagebox( message , title , type )
  931.     begin
  932.       # 停止対策用
  933.       begin
  934.         Graphics.safe_update
  935.       rescue SecurityHazard
  936.       end
  937.       @@mb.call(0, String.utf82ansi( message ), String.utf82ansi( title ),type)
  938.     rescue Hangup
  939.       nil # !※例外時にここを通過せずに外部に投げられる恐れあり
  940.     ensure
  941.       # !※例外時にここを通過せずに外部に投げられる恐れあり
  942.       begin
  943.         Graphics.safe_update
  944.       rescue SecurityHazard
  945.       end
  946.     end
  947.   end
  948.   #--------------------------------------------------------------------------
  949.   # ◆(!特定外使用禁止!)◆ 致命的エラーを通知
  950.   #   ※警告 :例外 Hangup 対策をかならず行うこと!
  951.   #--------------------------------------------------------------------------
  952.   def self.fatalerror( errobj )
  953.     begin
  954.       ErrorLogWriter.write( errobj )
  955.       error_message , tracer = error_message_setup( errobj )
  956.       # 瞬間消去
  957.       Graphics.transition(0)
  958.       Audio.bgm_stop
  959.       Audio.bgs_stop
  960.       Audio.me_stop
  961.       Audio.se_stop
  962.       if debug? and ( not (tracer[/^(?:Section)?{?(\d+)}?:(\d+)/]).nil? )
  963.         # セクションを拾い出した場合
  964.         nums = $1.to_i
  965.         extra = $RGSS_SCRIPTS.at(nums).at(1)
  966.         lines = $2.to_i
  967.         tracer = "#{extra} の #{lines} 行目で、\n"
  968.         error_message = tracer + error_message
  969.       end
  970.       title = "\x00" * 256
  971.       @@gpps.call( 'Game' , 'Title' , '' , title , 255 , '.\\Game.ini' )
  972.       title = String.ansi2utf8(title)
  973.       title.tr("\x00","")
  974.       # マウスカーソルを表示        
  975.       Input.mouse_show if Input.method_defined?(:mouse_show)
  976.       # メッセージボックス
  977.       messagebox( error_message , title , MB_FATAL )
  978.     rescue Hangup
  979.       nil # !※例外時にここを通過せずに外部に投げられる恐れあり
  980.     end
  981.   rescue Hangup
  982.     nil
  983.   end
  984.   # ---------------------------------------------------------------------------
  985.   # ◆ 異常終了のメッセージを整形
  986.   # ---------------------------------------------------------------------------
  987.   def self.error_message_setup( errobj )
  988.     Graphics.freeze
  989.     begin
  990.       Graphics.safe_update
  991.     rescue SecurityHazard
  992.     end
  993.     _message = ""
  994.     # バックトレースを記憶する
  995.     unless $@.nil? or ($@.at(0)).nil?
  996.       tracer =  ($@.at(0)).dup
  997.       # バックトレースを解析する
  998.       backtrace = ""
  999.       i = 0
  1000.       for str in $@.dup
  1001.         unless (str[ERROR_SECTION_NUM]).nil?
  1002.           extra = $RGSS_SCRIPTS.at($1.to_i).at(1)
  1003.           str.gsub!(ERROR_SECTION) { "( " + extra + " ):" }
  1004.         end
  1005.         backtrace += str
  1006.       end
  1007.       unless errobj.is_a?(SystemStackError)
  1008.         if rpgvxace?
  1009.           _message = errobj.message.force_encoding("UTF-8") +
  1010.                      "\n** backtrace:\n" + backtrace
  1011.         else
  1012.           _message = errobj.message + "\n** backtrace:\n" + backtrace
  1013.         end
  1014.       end
  1015.     else
  1016.       tracer = "" # バックトレース取得失敗
  1017.       if rpgvxace?
  1018.         _message = errobj.message.force_encoding("UTF-8")
  1019.       else
  1020.         _message = errobj.message
  1021.       end
  1022.     end   
  1023.     until (_message[DOUBLE_CRLF]).nil?
  1024.       _message.gsub!(DOUBLE_CRLF){ "\n" }
  1025.     end
  1026.     if debug?
  1027.       _message = "解決できない例外 " + (errobj.class).inspect +
  1028.                  " が発生したため、処理を継続できません。\n" +
  1029.                  _message
  1030.     else
  1031.       _message = "解決できない例外 " + (errobj.class).inspect +
  1032.                  " が発生したため、処理を継続できませんでした。\n" +
  1033.                  "お手数をおかけして申し訳ありません。\n\n詳細情報:\n" +
  1034.                  _message
  1035.     end
  1036.     return _message, tracer
  1037.   end
  1038. end

  1039. # RGSS2 環境だと、リセットは阻止できない。
  1040. if $@ and WFRGSS::DEBUG_CONSOLE and debug?
  1041.   p "例外 Reset が外部へ投げられました。"
  1042. end
复制代码



main
  1. # coding: utf-8
  2. # ===========================================================================
  3. # ★ WF-RGSS Scripts ★
  4. #    共通実行スクリプト(XP/VX/VXAce両対応版)
  5. # バージョン   : rev-29 (2013-3-26)
  6. # 作者         : WF-RGSS担当 (WHITE-FLUTE)
  7. # サポート先URI: [url]http://www.whiteflute.org/wfrgss/[/url]
  8. # ---------------------------------------------------------------------------
  9. # 機能:
  10. # ・デバッグモードで例外が発生したとき、エラーを errors.txt に記録します。
  11. # ・高速なリセットを利用できるようになります。
  12. # ---------------------------------------------------------------------------
  13. # 影響:
  14. # ・ファイルが見つからない例外は、 元の Errno::ENOENT が補足されます。
  15. # ---------------------------------------------------------------------------
  16. # 設置場所     :Mainセクション(一番最後)に上書き
  17. #                または、Mainセクションの直前
  18. # 必要スクリプト:
  19. # ・共通スクリプト
  20. # 注意事項:
  21. # ▽ 共通スクリプトが必要です。
  22. #    改造して使用することを推奨しますが、そのまま使ってもOKです。
  23. # ▽ デバッグモードでエラーを記録する場合、
  24. #    現在のユーザで書き込みを行えることが必要になります。
  25. #==============================================================================
  26. # ◆ Main ( Execute )
  27. #------------------------------------------------------------------------------
  28. #  各クラスの定義が終わった後、ここから実際の処理が始まります。
  29. #==============================================================================

  30. # ---------------------------------------------------------------------------
  31. # ◆ 処理実行
  32. # ---------------------------------------------------------------------------
  33. # スレッド例外で即座に中断しないようにする。(デバッグ時は無効)
  34. # ※ true に設定する場合はご注意ください。
  35. #    終了する前に解放が必要なものもあります。
  36. Thread.abort_on_exception = false
  37. # RPGVX 互換
  38. if rpgvx? and (not rpgvxace?)
  39.   unless Font.exist?("UmePlus Gothic")
  40.     print "UmePlus Gothic フォントが見つかりません。"
  41.     exit
  42.   end
  43. end

  44. begin
  45.   unless rpgvxace?
  46.     # トランジション準備
  47.     Graphics.freeze
  48.     # シーンオブジェクトを作成
  49.     # ★ 最初のシーンはここに設定します。 ★

  50.     $scene = Scene_Title.new

  51.     # ★ --------------------------------------------------------------------
  52.     # $scene が有効な限り main メソッドを呼び出す
  53.     $scene.main until $scene.nil?
  54.     # フェードアウト
  55.     Graphics.transition(20)

  56.   else
  57.     rgss_main { SceneManager.run }
  58.   end
  59.     # 以下、例外処理
  60. rescue BugDetected, InternalBugDetected => errobj
  61.   begin
  62.     MessageBox.fatalerror( errobj )
  63.     raise SystemExit.new(1)
  64.   rescue Hangup
  65.     nil
  66.   end

  67. rescue Reset
  68.   # -------------------------------------------------------------------------
  69.   # ◆ F12 リセット( 例外 Reset < Exception )
  70.   # -------------------------------------------------------------------------
  71.   # ※retry する場合は、
  72.   #   かならず、ウィンドウやスプライトが確実に解放される必要があります。
  73.   # ※ RGSS2環境ではF12の機構を封じないと封じ込められません。
  74.   
  75.   raise
  76. rescue Hangup => errobj
  77.   # -------------------------------------------------------------------------
  78.   # ◆ 致命的例外 Hangup
  79.   # -------------------------------------------------------------------------
  80.   begin
  81.     MessageBox.fatalerror( errobj )
  82.     raise SystemExit.new(1)
  83.   rescue Hangup
  84.     nil
  85.   end
  86. rescue SystemExit => errobj
  87.   # -------------------------------------------------------------------------
  88.   # ◆ 終了要求 ( Alt + F4 など )
  89.   # -------------------------------------------------------------------------
  90.   # 例外が正常終了で無い場合は、例外 SystemExitを再発生させます。
  91.   raise unless (errobj.status).zero?

  92. rescue Exception => errobj
  93.   # -------------------------------------------------------------------------
  94.   # ◆ 例外処理
  95.   # 特に指定されていない例外を補足します。
  96.   # ※ rev-2 より、Errno::ENOENT もここで補足します。
  97.   # -------------------------------------------------------------------------
  98.   begin
  99.     MessageBox.fatalerror( errobj )
  100.     raise SystemExit.new(1)
  101.   rescue Hangup
  102.     nil
  103.   end

  104. ensure
  105.   unless $!.is_a?(Reset)
  106.   # -------------------------------------------------------------------------
  107.   # ● 後処理
  108.   # -------------------------------------------------------------------------
  109.   # 後処理を記述します。
  110.   # スクリプト内容によってはここで解放処理が必要になることがあります。
  111.   # ★ 後処理を記述します。 ★


  112.   # ★ ----------------------------------------------------------------------
  113.   else
  114.     $! = nil unless rpgvxace?
  115.   end
  116. end

  117. exit # Mainセクションが後に控えている時に処理が渡らないようにする
复制代码


xppatch
  1. # ===========================================================================
  2. # ★ WF-RGSS Scripts ★
  3. #    デバッグ修正スクリプト(XP専用)
  4. # バージョン   : rev-1 (2013-3-26)
  5. # 作者         : WF-RGSS担当 (WHITE-FLUTE)
  6. # サポート先URI: [url]http://www.whiteflute.org/wfrgss/[/url]
  7. # ---------------------------------------------------------------------------
  8. # 機能:
  9. # ・RPGツクールXP上にて、デバッグ時にスレッドを使えるようにします。
  10. # ---------------------------------------------------------------------------
  11. # 設置場所:Scene_Debugより下、Mainより上
  12. # 必要スクリプト:
  13. # ・共通スクリプト(rev-29以降)
  14. # 注意事項:
  15. #   共通スクリプトを導入しないとエラーになります。
  16. # ===========================================================================
  17. raise "It doesn't correspond to RGSS of this version." if rpgvx?

  18. class Game_Player < Game_Character
  19.   #--------------------------------------------------------------------------
  20.   # ● 通行可能判定 (再定義)
  21.   #--------------------------------------------------------------------------
  22.   def passable?(x, y, d)
  23.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  24.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  25.     return false unless $game_map.valid?(new_x, new_y)
  26.     return true if debug? and Input.press?(Input::CTRL)
  27.     super
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● フレーム更新 (再定義)
  31.   #--------------------------------------------------------------------------
  32.   def update
  33.     last_moving = moving?
  34.     update_moving
  35.     last_real_x = @real_x
  36.     last_real_y = @real_y
  37.     super
  38.     update_scroll
  39.     update_encounter_and_event_check( last_moving )
  40.   end
  41.   private
  42.   #--------------------------------------------------------------------------
  43.   # ◆(内部専用)◆ 移動制御
  44.   #--------------------------------------------------------------------------
  45.   def update_moving
  46.     unless moving? or $game_system.map_interpreter.running? or
  47.            @move_route_forcing or $game_temp.message_window_showing
  48.       case Input.dir4
  49.       when 2
  50.         move_down
  51.       when 4
  52.         move_left
  53.       when 6
  54.         move_right
  55.       when 8
  56.         move_up
  57.       end
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ◆(内部専用)◆ スクロール制御
  62.   #--------------------------------------------------------------------------
  63.   def update_scroll
  64.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  65.       $game_map.scroll_down(@real_y - last_real_y)
  66.     elsif @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  67.       $game_map.scroll_up(last_real_y - @real_y)
  68.     end
  69.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  70.       $game_map.scroll_left(last_real_x - @real_x)
  71.     elsif @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  72.       $game_map.scroll_right(@real_x - last_real_x)
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ◆(内部専用)◆ エンカウントとイベントの処理
  77.   #--------------------------------------------------------------------------
  78.   def update_encounter_and_event_check( last_moving )
  79.     unless moving?
  80.       update_encounter( last_moving )
  81.       event_check
  82.     end
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ◆(内部専用)◆ エンカウントの処理
  86.   #--------------------------------------------------------------------------
  87.   def update_encounter( last_moving )
  88.     if last_moving
  89.       result = check_event_trigger_here([1,2])
  90.       unless result
  91.         unless debug? and Input.press?(Input::CTRL)
  92.           if @encounter_count > 0
  93.             @encounter_count -= 1
  94.           end
  95.         end
  96.       end
  97.     end
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ◆(内部専用)◆ イベントの処理
  101.   #--------------------------------------------------------------------------
  102.   def event_check
  103.     if Input.trigger?(Input::C)
  104.       check_event_trigger_here([0])
  105.       check_event_trigger_there([0,1,2])
  106.     end
  107.   end
  108. end

  109. class Scene_Map
  110.   private
  111.   #--------------------------------------------------------------------------
  112.   # ● フレーム更新 (再定義)
  113.   #--------------------------------------------------------------------------
  114.   def update
  115.     main_update
  116.     update_goto_scene
  117.     update_transition
  118.     return if $game_temp.message_window_showing
  119.     update_encounter
  120.     update_menu_calling
  121.     update_debug
  122.     update_call_scene
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ◆(内部専用)◆ 更新処理
  126.   #--------------------------------------------------------------------------
  127.   def main_update
  128.     loop do
  129.       $game_map.update
  130.       $game_system.map_interpreter.update
  131.       $game_player.update
  132.       $game_system.update
  133.       $game_screen.update
  134.       break unless $game_temp.player_transferring
  135.       transfer_player
  136.       break if $game_temp.transition_processing
  137.     end
  138.     @spriteset.update
  139.     @message_window.update
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ◆(内部専用)◆ シーン直行
  143.   #--------------------------------------------------------------------------
  144.   def update_goto_scene
  145.     if $game_temp.gameover
  146.       $scene = Scene_Gameover.new
  147.       return
  148.     end
  149.     if $game_temp.to_title
  150.       $scene = Scene_Title.new
  151.       return
  152.     end
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ◆(内部専用)◆ トランジションの処理
  156.   #--------------------------------------------------------------------------
  157.   def update_transition
  158.     if $game_temp.transition_processing
  159.       $game_temp.transition_processing = false
  160.       if $game_temp.transition_name == ""
  161.         Graphics.transition(20)
  162.       else
  163.         Graphics.transition(40, "Graphics/Transitions/" +
  164.           $game_temp.transition_name)
  165.       end
  166.     end
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ◆(内部専用)◆ エンカウントの処理
  170.   #--------------------------------------------------------------------------
  171.   def update_encounter
  172.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  173.       unless $game_system.map_interpreter.running? or
  174.              $game_system.encounter_disabled
  175.         n = rand($game_map.encounter_list.size)
  176.         troop_id = $game_map.encounter_list[n]
  177.         if $data_troops[troop_id]
  178.           $game_temp.battle_calling = true
  179.           $game_temp.battle_troop_id = troop_id
  180.           $game_temp.battle_can_escape = true
  181.           $game_temp.battle_can_lose = false
  182.           $game_temp.battle_proc = nil
  183.         end
  184.       end
  185.     end
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ◆(内部専用)◆ メニュー遷移
  189.   #--------------------------------------------------------------------------
  190.   def update_menu_calling
  191.     if Input.trigger?(Input::B)
  192.       unless $game_system.map_interpreter.running? or
  193.              $game_system.menu_disabled
  194.         $game_temp.menu_calling = true
  195.         $game_temp.menu_beep = true
  196.       end
  197.     end
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ◆(内部専用)◆ デバッグ遷移
  201.   #--------------------------------------------------------------------------
  202.   def update_debug
  203.     $game_temp.debug_calling = true if debug? and Input.press?(Input::F9)
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ◆(内部専用)◆ シーン呼び出し
  207.   #--------------------------------------------------------------------------
  208.   def update_call_scene
  209.     unless $game_player.moving?
  210.       if $game_temp.battle_calling
  211.         call_battle
  212.       elsif $game_temp.shop_calling
  213.         call_shop
  214.       elsif $game_temp.name_calling
  215.         call_name
  216.       elsif $game_temp.menu_calling
  217.         call_menu
  218.       elsif $game_temp.save_calling
  219.         call_save
  220.       elsif $game_temp.debug_calling
  221.         call_debug
  222.       end
  223.     end
  224.   end
  225. end
复制代码



拜访顺序是base,largechara,main,xppatch

这个脚本另外还有两个部件脚本,不过只是和这个冲突。
这两个哪个在下面,就哪个生效,另一个失效。
NPC名字脚本就是在NPC头上显示名字的脚本。
NPC大小判断就是可以判断事件的图片大小,根据图片位图进行事件的判断。比如大的事件不能通过小的通道。  
梦石
0
星屑
1788
在线时间
1313 小时
注册时间
2012-8-4
回帖
724
发表于 2016-1-22 11:19:17 | 显示全部楼层
本帖最后由 夜狠简单 于 2016-1-22 11:21 编辑

首先我单独使用的时候有错误
1.jpg

而楼主遇到的问题就是 同样的函数 ,应该都是靠近Main的被使用

然后这是我整合的,错误的地方就是单独使用的时候出现错误的地方
NPC大小和名字整合]# ===========================================================================
# ★ WF-RGSS Scripts ★
#    LargeCharacter イベント当たり判定調整スクリプト
# バージョン   : rev-4.4 (2013-8-25)
# 作者         : WF-RGSS担当 (WHITE-FLUTE)
# サポート先URI: http://www.whiteflute.org/wfrgss/
# ---------------------------------------------------------------------------
# 機能:
# ・イベントの大きさを感知し、当たり判定を調整します。
# ・ある程度マップの処理を軽量化します。
# ---------------------------------------------------------------------------
# 影響:
# ・軽量化スクリプトと競合します。
#   詳細は readme.txt を参照してください。
# ---------------------------------------------------------------------------
# 設置場所     :Sprite_Character より下、Mainより上
# 必要スクリプト:
# ・共通スクリプト(rev-17以降)、共通実行スクリプト(rev-17以降)
# 注意事項:
#   ▽ ほかの軽量化スクリプトとの併用は避けてください。
# ===========================================================================


class Sprite_Character < RPG::Sprite
  #------------------------------------------------------------------------
  # ● カスタマイズ ポイント
  #------------------------------------------------------------------------
  # 認知されるキャラクターの大きさを指定します。

  LARGE_SET  = 24 * 3
  LARGE_SIZE = 32 * 2

  
  #--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :character                # 角色
   #--------------------------------------------------------------------------
# ● 初始化对像
#     viewport  : 查看端口
#     character : 角色 (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
   name = character.name
   super(viewport)
   @character = character
   @namesprite = Sprite.new
   @namesprite.bitmap = Bitmap.new(160, 48)
   @namesprite.bitmap.font.name = "黑体"
   @namesprite.bitmap.font.size = 14
   @namesprite.bitmap.font.color.set(255, 0, 0)
   @evname = name
   @evname_split = name.split(/,/)[0]
   if name[0, 2]=="EV"
     @evname_split = " "
   end
   if name.split(/,/)[1] != nil
     case name.split(/,/)[1]
     when "0"
       @namesprite.bitmap.font.color.set(255, 0, 0)
     when "1"
       @namesprite.bitmap.font.color.set(128, 0, 0)
     when "2"
       @namesprite.bitmap.font.color.set(255, 0, 0)
     when "3"
       @namesprite.bitmap.font.color.set(128, 0, 0)
     when "4"
       @namesprite.bitmap.font.color.set(128, 0, 0)
     when "5"
       @namesprite.bitmap.font.color.set(255, 0, 0)
     when "6"
       @namesprite.bitmap.font.color.set(255, 0, 0)
     when "7"
       @namesprite.bitmap.font.color.set(192, 0, 0)
     else
       @namesprite.bitmap.font.color.set(255, 0, 0)
     end
   end
   if @evname_split != "" and @evname_split != nil
     @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1)
   end
   update
end
   #--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
   super
   # 元件 ID、文件名、色相与现在的情况存在差异的情况下
   if @tile_id != @character.tile_id or
      @character_name != @character.character_name or
      @character_hue != @character.character_hue
     # 记忆元件 ID 与文件名、色相
     @tile_id = @character.tile_id
     @character_name = @character.character_name
     @character_hue = @character.character_hue
     # 元件 ID 为有效值的情况下
     if @tile_id >= 384
       self.bitmap = RPG::Cache.tile($game_map.tileset_name,
         @tile_id, @character.character_hue)
       self.src_rect.set(0, 0, 32, 32)
       self.ox = 16
       self.oy = 32
     # 元件 ID 为无效值的情况下
     else
       self.bitmap = RPG::Cache.character(@character.character_name,
         @character.character_hue)
       @cw = bitmap.width / 4
       @ch = bitmap.height / 4
       self.ox = @cw / 2
       self.oy = @ch
     end
   end
   if @evname != @character.name
     @namesprite.bitmap.clear
     @evname = @character.name
     @evname_split = @character.name.split(/,/)[0]
     if @character.name.split(/,/)[1] != nil
       case @character.name.split(/,/)[1]
       when "0"
         @namesprite.bitmap.font.color.set(255, 0, 0)
       when "1"
         @namesprite.bitmap.font.color.set(128, 0, 0)
       when "2"
         @namesprite.bitmap.font.color.set(255, 0, 0)
       when "3"
         @namesprite.bitmap.font.color.set(128, 0, 0)
       when "4"
         @namesprite.bitmap.font.color.set(128, 0, 0)

       when "5"
         @namesprite.bitmap.font.color.set(255, 0, 0)
       when "6"
         @namesprite.bitmap.font.color.set(255, 0, 0)
       when "7"
         @namesprite.bitmap.font.color.set(192, 0, 0)
       else
         @namesprite.bitmap.font.color.set(255, 0, 0)
       end
     end
     if @evname_split != "" and @evname_split != nil
       @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1)
     end
   end
   @namesprite.x = self.x - 80
   @namesprite.y = self.y-self.oy+35-60
   #@namesprite.visible = $game_switches[39]
   # 设置可视状态
   self.visible = (not @character.transparent)
   @namesprite.visible = @character.character_name == "" ? false : self.visible
   # 图形是角色的情况下
   if @tile_id == 0
     # 设置传送目标的矩形
     sx = @character.pattern * @cw
     sy = (@character.direction - 2) / 2 * @ch
     self.src_rect.set(sx, sy, @cw, @ch)
   end
   # 设置脚本的坐标
   self.x = @character.screen_x
   self.y = @character.screen_y
   self.z = @character.screen_z(@ch)
   # 设置不透明度、合成方式、茂密
   self.opacity = @character.opacity
   self.blend_type = @character.blend_type
   self.bush_depth = @character.bush_depth
   # 动画
   if @character.animation_id != 0
     animation = $data_animations[@character.animation_id]
     animation(animation, true)
     @character.animation_id = 0
   end
end
  
end

#==============================================================================
# ◆ PassagesList
#------------------------------------------------------------------------------
#  キャラクターの位置を判定するリストです
#==============================================================================

class PassagesList
  # 継承禁止
  include FinalClass
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @list = Hash.new
  end
  #--------------------------------------------------------------------------
  # ● クリア
  #--------------------------------------------------------------------------
  def clear
    @list.clear
  end
  #--------------------------------------------------------------------------
  # ◆ 位置情報ID
  #--------------------------------------------------------------------------
  def passages( x , y )
    ( x << 9 ) + y
  end
  #--------------------------------------------------------------------------
  # ◆ キャラクタ通行不能情報更新
  #--------------------------------------------------------------------------
  def update( event_id , old_r , new_r , xsize = 1 , ysize = 1)
    if xsize > 1 or ysize > 1
      xr = xsize / 2
      yr = -(ysize - 1)
      unless old_r.nil?
        for i in -xr..xr
          for j in yr..0
            outevent( event_id , old_r + i * 512 + j )
          end
        end
      end
      unless new_r.nil?
        for i in -xr..xr
          for j in yr..0
            inevent( event_id , new_r + i * 512 + j )
          end
        end
      end
    else
      unless old_r.nil?
        outevent( event_id , old_r )
      end
      unless new_r.nil?
        inevent( event_id , new_r )
      end
    end
  end
  #--------------------------------------------------------------------------
  # ◆ キャラクタ通行不能情報読み取り イベント用
  #--------------------------------------------------------------------------
  def passages_event( x , y )
    if (val = @list[passages( x , y )])
      if val.is_a?(Fixnum)
        return $game_map.events[val].passable_event?
      else
        for event_id in val
          event = $game_map.events[event_id]
          return false unless event.passable_event?
        end
        return true
      end
    else
      return true
    end
  end
  #--------------------------------------------------------------------------
  # ◆ キャラクタ通行不能情報読み取り プレイヤー用
  #--------------------------------------------------------------------------
  def passages_player( x , y )
    if (val = @list[passages( x , y )])
      if val.is_a?(Fixnum)
        return $game_map.events[val].passable_player?
      else
        for event_id in val
          event = $game_map.events[event_id]
          return false unless event.passable_player?
        end
        return true
      end
    else
      return true
    end
  end
  #--------------------------------------------------------------------------
  # ● イベント存在判定
  #--------------------------------------------------------------------------
  def include?( x , y )
    @list[passages( x , y )]
  end
  private
  #--------------------------------------------------------------------------
  # ◆(内部専用)◆ イベント位置代入
  #--------------------------------------------------------------------------
  def inevent( event_id , r )
    val = @list[r]
    if val.nil?
      @list[r] = event_id
    elsif val.is_a?(Fixnum)
      @list[r] = [ val , event_id ] if val != event_id
    else
      @list[r] = val.push( event_id ) unless val.include?( event_id )
    end
  end
  #--------------------------------------------------------------------------
  # ◆(内部専用)◆ イベント位置撤去
  #--------------------------------------------------------------------------
  def outevent( event_id , r )
    val = @list[r]
    if val.is_a?(Fixnum)
      @list.delete(r)
    elsif val.is_a?(Array)
      val.delete( event_id )
      if val.size < 2
        @list[r] = val.at(0)
      else
        @list[r] = val
      end
    end
  end
end


#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================
class Game_Map
  # 継承禁止
  include FinalClass
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :width_scroll             # ◆ スクロール X 座標最大
  attr_reader :height_scroll            # ◆ スクロール Y 座標最大
  attr_reader :onscreen_x               # ◆ 画面内判定 X 座標
  attr_reader :onscreen_y               # ◆ 画面内判定 Y 座標
  attr_reader :passages_char
  #--------------------------------------------------------------------------
  # ● 定数
  #--------------------------------------------------------------------------
  DISPLAY_X            = 1280                 # ◆ ディスプレイX
  DISPLAY_Y            = 960                  # ◆ ディスプレイY
  TILE_SET_WORK        = [ 2 , 1 , 0 ].freeze # ◆ タイルマップレイヤー順序
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias _wfrgss_initialize initialize
  def initialize
    _wfrgss_initialize
    @passages_char = PassagesList.new
    @onscreen_x = 0
    @onscreen_y = 0
  end
  #--------------------------------------------------------------------------
  # ● セットアップ
  #     map_id : マップ ID
  #--------------------------------------------------------------------------
  alias _wfrgss_setup_ setup
  def setup(map_id)
    @passages_char.clear
    _wfrgss_setup_(map_id)
    @events[0] = $game_player
    @onscreen_x = @display_x + DISPLAY_X # 1280
    @onscreen_y = @display_y + DISPLAY_Y # 960
    @width_scroll = ( (@map.width  - 20) << 7 )
    @height_scroll= ( (@map.height - 15) << 7 )
  end
  #--------------------------------------------------------------------------
  # ● 下にスクロール
  #     distance : スクロールする距離
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    @display_y += distance
    @display_y = @height_scroll if @display_y > @height_scroll
    @onscreen_y = @display_y + DISPLAY_Y # 960
  end
  #--------------------------------------------------------------------------
  # ● 左にスクロール
  #     distance : スクロールする距離
  #--------------------------------------------------------------------------
  def scroll_left(distance)
    @display_x -= distance
    @display_x = 0 if @display_x < 0
    @onscreen_x = @display_x + DISPLAY_X # 1280
  end
  #--------------------------------------------------------------------------
  # ● 右にスクロール
  #     distance : スクロールする距離
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    @display_x += distance
    @display_x = @width_scroll if @display_x > @width_scroll
    @onscreen_x = @display_x + DISPLAY_X # 1280
  end
  #--------------------------------------------------------------------------
  # ● 上にスクロール
  #     distance : スクロールする距離
  #--------------------------------------------------------------------------
  def scroll_up(distance)
    @display_y -= distance
    @display_y = 0 if @display_y < 0
    @onscreen_y = @display_y + DISPLAY_Y # 960
  end
  #--------------------------------------------------------------------------
  # ● 任意座標にスクロール
  #     distance : スクロールする距離
  #--------------------------------------------------------------------------
  def scroll_any( distance_x , distance_y )
    @display_x += distance_x
    if @display_x < 0
      @display_x = 0
    elsif @display_x > @width_scroll
      @display_x = @width_scroll
    end
    @display_y += distance_y
    if @display_y < 0
      @display_y = 0
    elsif @display_y > @height_scroll
      @display_y = @height_scroll
    end
    @onscreen_x = @display_x + DISPLAY_X # 1280
    @onscreen_y = @display_y + DISPLAY_Y # 960
  end
  #--------------------------------------------------------------------------
  # ● 任意座標にスクロール
  #--------------------------------------------------------------------------
  def scroll_fix( display_x , display_y )
    @display_x = display_x
    if @display_x < 0
      @display_x = 0
    elsif @display_x > @width_scroll
      @display_x = @width_scroll
    end
    @display_y = display_y
    if @display_y < 0
      @display_y = 0
    elsif @display_y > @height_scroll
      @display_y = @height_scroll
    end
    @onscreen_x = @display_x + DISPLAY_X # 1280
    @onscreen_y = @display_y + DISPLAY_Y # 960
  end
  #--------------------------------------------------------------------------
  # ● 通行可能判定
  #     x          : X 座標
  #     y          : Y 座標
  #     d          : 方向 (0,2,4,6,8,10)
  #                  ※ 0,10 = 全方向通行不可の場合を判定 (ジャンプなど)
  #     self_event : 自分 (イベントが通行判定をする場合)
  #--------------------------------------------------------------------------
  def passable?( x , y , d , self_event = nil )
    return false unless valid?(x, y)
    bit = (1 << (( d >> 1 ) - 1)) & 0x0f
    if (val = @passages_char.include?( x , y ))
      ret = nil
      if val.is_a?(Fixnum)
        event = @events[val]
        if event.tile_id >= 0 and event != self_event
          return ret unless (ret = passable_tile?( bit, event)).nil?
        end
      else
        for event_id in val
          event = @events[event_id]
          if event.tile_id >= 0 and event != self_event
            return ret unless (ret = passable_tile?( bit, event)).nil?
          end
        end
      end
    end
    for i in TILE_SET_WORK
      tile_id = @map.data[x, y, i]
      return false if tile_id.nil?
      if (@terrain_tags[tile_id]).zero?
        if (@passages[tile_id] & bit).nonzero?
          return false
        elsif @passages[tile_id] & 0x0f == 0x0f
          return false
        end
      end
      return true if (@priorities[tile_id]).zero?
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 表示 X 座標 * 128
  #--------------------------------------------------------------------------
  def display_x=(display_x)
    if display_x.is_a?(Fixnum)
      @display_x = display_x
      @onscreen_x = @display_x + DISPLAY_X # 1280
    end
  end
  #--------------------------------------------------------------------------
  # ● 表示 Y 座標 * 128
  #--------------------------------------------------------------------------
  def display_y=(display_y)
    if display_y.is_a?(Fixnum)
      @display_y = display_y
      @onscreen_y = @display_y + DISPLAY_Y # 960
    end
  end
  #--------------------------------------------------------------------------
  # ● 指定位置のイベント ID 取得
  #     x          : X 座標
  #     y          : Y 座標
  #--------------------------------------------------------------------------
  def check_event(x, y)
    if ( val = @passages_char.include?( x , y ))
      if val.is_a?(Fixnum)
        return val
      else
        return val.at(0)
      end
    else
      return nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 指定位置のイベント ID 取得
  #--------------------------------------------------------------------------
  def check_event_player( x , y )
    @passages_char.include?( x , y )
  end
  private
  #--------------------------------------------------------------------------
  # ◆(内部専用)◆ 通行可能判定 (タイル)
  #--------------------------------------------------------------------------
  def passable_tile?( bit , tile )
    if (@terrain_tags[tile.tile_id]).zero?
      if (@passages[tile.tile_id] & bit).nonzero?
        return false
      elsif @passages[tile.tile_id] & 0x0f == 0x0f
        return false
      end
    end
    return true if (@priorities[tile.tile_id]).zero?
    nil
  end
end


#==============================================================================
# ■ LargeCharacter
#------------------------------------------------------------------------------
#  当たり判定が巨大なキャラクターを扱うモジュールです。
#==============================================================================

module LargeCharacter
  #--------------------------------------------------------------------------
  # ◆ 移動情報更新
  #--------------------------------------------------------------------------
  def move_update
    @pre_x = (@x << 7)
    @pre_y = (@y << 7)
    $game_map.passages_char.update( @id, passages( @old_x, @old_y),
                                   passages( @x, @y),@x_size,@y_size)
  end
  #--------------------------------------------------------------------------
  # ◆ 移動情報更新
  #--------------------------------------------------------------------------
  def move_update_setup
    @pre_x = (@x << 7)
    @pre_y = (@y << 7)
    $game_map.passages_char.update( @id, nil,passages( @x, @y),@x_size,@y_size)
  end
  #--------------------------------------------------------------------------
  # ◆ 大きさの更新
  #--------------------------------------------------------------------------
  def size_update( old_x_size , old_y_size )

    $game_map.passages_char.update( @id, passages( @x, @y),nil,
                                   old_x_size , old_y_size)

    $game_map.passages_char.update( @id, nil,passages( @x, @y),@x_size,@y_size)
  end
  #--------------------------------------------------------------------------
  # ● 通行可能判定
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    case d
    when 2
      start_x = x - ( @x_size >> 1 )
      end_x = start_x + @x_size
      ry = y
      for rx in start_x ... end_x
        return false unless super( rx , ry , d )
      end
    when 4
      start_y = y - @y_size + 1
      end_y = y
      rx = x - ( @x_size >> 1 )
      for ry in start_y .. end_y
        return false unless super( rx , ry , d )
      end
    when 6
      start_y = y - @y_size + 1
      end_y = y
      rx = x + ( @x_size >> 1 )
      for ry in start_y .. end_y
        return false unless super( rx , ry , d )
      end
    when 8
      start_x = x - ( @x_size >> 1 )
      end_x = start_x + @x_size
      ry = y - @y_size + 1
      for rx in start_x ... end_x
        return false unless super( rx , ry , d )
      end
    else
      start_x = x - ( @x_size >> 1 )
      start_y = y - @y_size + 1
      end_x = start_x + @x_size
      end_y = y
      for rx in start_x ... end_x
        for ry in start_y .. end_y
          return false unless super( rx , ry , d )
        end
      end
    end
    return true
  end
  private
  #--------------------------------------------------------------------------
  # ◆(内部専用)◆ 接触イベントの起動判定
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    super if self.is_a?(Game_Player)
    return false if $game_system.map_interpreter.running?
    return false unless @trigger == 2 or @trigger == 1
    x_left = x - ( @x_size >> 1 )
    x_right = x + ( @x_size >> 1 )
    y_up = ( y - @y_size + 1 )
    if x_left <= $game_player.x and x_right >= $game_player.x and
       y_up <= $game_player.y and y >= $game_player.y
      if not jumping? and not over_trigger?
        start
        return true
      end
    end
    return false
  end
end


#==============================================================================
# ■ Game_Character (分割定義 1) (abstract class)
#------------------------------------------------------------------------------
#  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
# クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Character
  include Abstract

  attr_reader :onscreen
  #--------------------------------------------------------------------------
  # ● 定数
  #--------------------------------------------------------------------------
  ONSCREEN_X           = 1792 # 画面内X領域
  ONSCREEN_Y           = 1536 # 画面内Y領域
  DISPLAY_X            = 1280
  DISPLAY_Y            = 960
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias _wfrgss_initialize initialize
  def initialize
    _wfrgss_initialize
    @old_x = @x   # 前回の座標
    @old_y = @y   #
    @x_size = 1
    @y_size = 1
    @pre_x = 0   # 実座標の移動判定に用いる 常に128の整数倍
    @pre_y = 0   #
  end
  #--------------------------------------------------------------------------
  # ◆ キャラクタ再更新メソッド
  #--------------------------------------------------------------------------
  def self.character_method( chrmethod )
    __failure_type_call__( chrmethod ) unless chrmethod.is_a?(Method)
    @@charchange = chrmethod
  end
  #--------------------------------------------------------------------------
  # ◆ キャラクタ再更新メソッド クリア
  #--------------------------------------------------------------------------
  def self.clear_character_method
    @@charchange = nil
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    sx = @real_x - $game_map.onscreen_x
    sy = @real_y - $game_map.onscreen_y
    if (@onscreen = (sx.abs <= ONSCREEN_X and sy.abs <= ONSCREEN_Y))
      if jumping?
        update_jump
      elsif moving?
        update_move
      else
        update_stop
      end
      if @anime_count > 36 - ( @move_speed * 2 )
        if not @step_anime and @stop_count > 0
          @pattern = @original_pattern
        else
          @pattern = (@pattern + 1) & 0x3
        end
        @anime_count = 0
      end
    else
      if jumping?
        update_jump
      elsif moving?
        update_move
      else
        update_stop
      end
    end
    if @wait_count > 0
      @wait_count -= 1
      return
    end
    if @move_route_forcing
      move_type_custom
      return
    end
    return if @starting or lock?
    return unless @onscreen
    if @move_frequency != @reserve_move_frequency
      @reserve_move_frequency = @move_frequency
      @stop_frequency =  (40 - @move_frequency * 2) * (6 - @move_frequency)
    end
    if @stop_count > @stop_frequency
      case @move_type
      when 0  # 停止
        move_type_stop
      when 1  # ランダム
        move_type_random
      when 2  # 近づく
        move_type_toward_player
      when 3  # カスタム
        move_type_custom
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 移動タイプ : 停止
  #--------------------------------------------------------------------------
  def move_type_stop
    @wait_count = rand(36) + 36
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (ジャンプ)
  #--------------------------------------------------------------------------
  def update_jump
    @jump_count -= 1
    @real_x = (@real_x * @jump_count + @pre_x) / (@jump_count + 1)
    @real_y = (@real_y * @jump_count + @pre_y) / (@jump_count + 1)
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (移動)
  #--------------------------------------------------------------------------
  def update_move
    distance = (1 << (@move_speed - 1))
    if @pre_y > @real_y
      @real_y += distance
      @real_y = @pre_y if @real_y > @pre_y
    elsif @pre_y < @real_y
      @real_y -= distance
      @real_y = @pre_y if @real_y < @pre_y
    end
    if @pre_x < @real_x
      @real_x -= distance
      @real_x = @pre_x if @real_x < @pre_x
    elsif @pre_x > @real_x
      @real_x += distance
      @real_x = @pre_x if @real_x > @pre_x
    end
    if @walk_anime
      @anime_count += 3
    elsif @step_anime
      @anime_count += 2
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (停止)
  #--------------------------------------------------------------------------
  def update_stop
    if @step_anime
      @anime_count += 2
    elsif @pattern != @original_pattern
      @anime_count += 3
    end
    @stop_count += 2 unless @starting or lock?
  end
  #--------------------------------------------------------------------------
  # ◆ 位置情報ID
  #--------------------------------------------------------------------------
  def passages( x , y )
    ( x << 9 ) + y
  end
  #--------------------------------------------------------------------------
  # ◆ 移動情報更新
  #--------------------------------------------------------------------------
  def move_update
    @pre_x = (@x << 7)
    @pre_y = (@y << 7)
    $game_map.passages_char.update( @id, passages( @old_x, @old_y),
                                   passages( @x, @y))
  end
  #--------------------------------------------------------------------------
  # ◆ 移動情報更新
  #--------------------------------------------------------------------------
  def move_update_setup
    @pre_x = (@x << 7)
    @pre_y = (@y << 7)
    $game_map.passages_char.update( @id, nil, passages( @x, @y))
  end
  #--------------------------------------------------------------------------
  # ● 移動中判定
  #--------------------------------------------------------------------------
  def moving?
    (@real_x != @pre_x or @real_y != @pre_y)
  end
  #--------------------------------------------------------------------------
  # ● 通行可能判定
  #--------------------------------------------------------------------------
  def passable_event?
    @through
  end
  #--------------------------------------------------------------------------
  # ● 通行可能判定
  #--------------------------------------------------------------------------
  def passable_player?
    @through or @character_name.empty?
  end
  #--------------------------------------------------------------------------
  # ● 通行可能判定
  #     x : X 座標
  #     y : Y 座標
  #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return false unless $game_map.valid?(new_x, new_y)
    return true if @through
    return false unless $game_map.passable?( x, y, d, self)
    return false unless $game_map.passable?( new_x, new_y, 10 - d)
    return false unless character_passable?( new_x , new_y )
    true
  end
  #--------------------------------------------------------------------------
  # ● キャラクターの大きさを設定
  #--------------------------------------------------------------------------
  def size_change( size_x , size_y )
    return if size_x == @x_size and size_y == @y_size
    if size_x <= 1 and size_y <= 1
      if @x_size > 1 or @y_size > 1
        old_x_size = @x_size
        old_y_size = @y_size
        @x_size = 1
        @y_size = 1
        size_update( old_x_size , old_y_size )
        new_character = self.dup
        $game_map.events[@id] = new_character
        @@charchange.call( @id , new_character )
      end
    else
      unless @x_size > 1 or @y_size > 1
        @x_size = size_x
        @y_size = size_y
        self.extend(LargeCharacter)
        size_update( 1 , 1 )
      else
        old_x_size = @x_size
        old_y_size = @y_size
        @x_size = size_x
        @y_size = size_y
        size_update( old_x_size , old_y_size )
      end
    end
    nil
  end
  #--------------------------------------------------------------------------
  # ● 以前の座標を記録
  #--------------------------------------------------------------------------
  def old_point
    @old_x = @x
    @old_y = @y
  end
  #--------------------------------------------------------------------------
  # ● 指定位置に移動
  #     x : X 座標
  #     y : Y 座標
  #--------------------------------------------------------------------------
  def moveto(x, y)
    old_point
    @x = x % $game_map.width
    @y = y % $game_map.height
    move_update
    @real_x = @x << 7
    @real_y = @y << 7
    @prelock_direction = 0
  end
  #--------------------------------------------------------------------------
  # ● 下に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_down(turn_enabled = true)
    if turn_enabled
      turn_down
    end
    if passable?(@x, @y, 2)
      turn_down
      old_point
      @y += 1
      move_update
      increase_steps
    else
      check_event_trigger_touch(@x, @y+1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 左に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_left(turn_enabled = true)
    if turn_enabled
      turn_left
    end
    if passable?(@x, @y, 4)
      turn_left
      old_point
      @x -= 1
      move_update
      increase_steps
    else
      check_event_trigger_touch(@x-1, @y)
    end
  end
  #--------------------------------------------------------------------------
  # ● 右に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_right(turn_enabled = true)
    if turn_enabled
      turn_right
    end
    if passable?(@x, @y, 6)
      turn_right
      old_point
      @x += 1
      move_update
      increase_steps
    else
      check_event_trigger_touch(@x+1, @y)
    end
  end
  #--------------------------------------------------------------------------
  # ● 上に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_up(turn_enabled = true)
    if turn_enabled
      turn_up
    end
    if passable?(@x, @y, 8)
      turn_up
      old_point
      @y -= 1
      move_update
      increase_steps
    else
      check_event_trigger_touch(@x, @y-1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 左下に移動
  #--------------------------------------------------------------------------
  def move_lower_left
    unless @direction_fix
      @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      old_point
      @x -= 1
      @y += 1
      move_update
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● 右下に移動
  #--------------------------------------------------------------------------
  def move_lower_right
    unless @direction_fix
      @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      old_point
      @x += 1
      @y += 1
      move_update
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● 左上に移動
  #--------------------------------------------------------------------------
  def move_upper_left
    unless @direction_fix
      @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      old_point
      @x -= 1
      @y -= 1
      move_update
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● 右上に移動
  #--------------------------------------------------------------------------
  def move_upper_right
    unless @direction_fix
      @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      old_point
      @x += 1
      @y -= 1
      move_update
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # ● ジャンプ
  #     x_plus : X 座標加算値
  #     y_plus : Y 座標加算値
  #--------------------------------------------------------------------------
  def jump(x_plus, y_plus)
    if x_plus != 0 or y_plus != 0
      if x_plus.abs > y_plus.abs
        x_plus < 0 ? turn_left : turn_right
      else
        y_plus < 0 ? turn_up : turn_down
      end
    end
    new_x = @x + x_plus
    new_y = @y + y_plus
    if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
      straighten
      old_point
      @x = new_x
      @y = new_y
      move_update
      distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
      @jump_peak = 10 + distance - @move_speed
      @jump_count = @jump_peak * 2
      @stop_count = 0
    end
  end
end

#==============================================================================
# ■ Game_Event
#------------------------------------------------------------------------------
#  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
# イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
#==============================================================================
class Game_Event < Game_Character
  alias __wfrgss_chr_initialize__ initialize
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     map_id : マップ ID
  #     event  : イベント (RPG::Event)
  #--------------------------------------------------------------------------
  #——————————————————————————————————————
# 用来返回名称
#——————————————————————————————————————
def name
   return @event.name
end

def name=(newname)
   @event.name = newname
end

  
  def initialize(map_id, event)
    @event = event
    moveto_setup(@event.x, @event.y)
    __wfrgss_chr_initialize__(map_id, event)
  end
  #--------------------------------------------------------------------------
  # ◆ キャラクタ通行可能判定
  #--------------------------------------------------------------------------
  def character_passable?( x , y )
    $game_map.passages_char.passages_event( x , y )
  end
  #--------------------------------------------------------------------------
  # ● 指定位置に移動
  #     x : X 座標
  #     y : Y 座標
  #--------------------------------------------------------------------------
  def moveto_setup(x, y)
    @x = @old_x = ( x % $game_map.width )
    @y = @old_y = ( y % $game_map.height )
    move_update_setup
    @real_x = (@x << 7)
    @real_y = (@y << 7)
    @prelock_direction = 0
  end
  #--------------------------------------------------------------------------
  # ● オーバートリガー判定 (同位置を起動条件とするか否か)
  #--------------------------------------------------------------------------
  def over_trigger?
    return false if @character_name != "" and not @through
    return false unless $game_map.passable?(@x, @y, 0)
    true
  end
end

#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
#==============================================================================

class Game_Player < Game_Character
  
  def name
   return ""#$game_party.actors[0].name
end

  #--------------------------------------------------------------------------
  # ● 定数
  #--------------------------------------------------------------------------
  TRIGGER_DECISION = [0].freeze
  TRIGGER_PLAYER = [1,2].freeze
  TRIGGER_EVENT = [0,1,2].freeze
  #--------------------------------------------------------------------------
  # ● 起動トリガー
  #--------------------------------------------------------------------------
  def trigger
    5
  end
  #--------------------------------------------------------------------------
  # ● 起動中判定
  #--------------------------------------------------------------------------
  def starting
    false
  end
  #--------------------------------------------------------------------------
  # ● 通行可能判定
  #     x : X 座標
  #     y : Y 座標
  #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
  #--------------------------------------------------------------------------
  if $DEBUG
    def passable?(x, y, d)
      new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
      new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
      return false unless $game_map.valid?(new_x, new_y)
      return true if Input.press?(Input::CTRL)
      super
    end
  else
    def passable?(x, y, d)
      new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
      new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
      return false unless $game_map.valid?(new_x, new_y)
      super
    end
  end
  #--------------------------------------------------------------------------
  # ◆ キャラクタ通行可能判定
  #--------------------------------------------------------------------------
  def character_passable?( x , y )
    $game_map.passages_char.passages_player( x , y )
  end
  #--------------------------------------------------------------------------
  # ● 指定位置に移動
  #     x : X 座標
  #     y : Y 座標
  #--------------------------------------------------------------------------
  def moveto_setup(x, y)
    @x = x % $game_map.width
    @y = y % $game_map.height
    move_update_setup
    @real_x = (@x << 7)
    @real_y = (@y << 7)
    @prelock_direction = 0
    center(@x, @y)
  end
  #--------------------------------------------------------------------------
  # ● 同位置のイベント起動判定
  #--------------------------------------------------------------------------
  def check_event_trigger_here(triggers)
    return false if $game_system.map_interpreter.running?
    if ( val = $game_map.check_event_player( x , y ))
      if val.is_a?(Array)
        for event_id in val
          event = $game_map.events[event_id]
          if triggers.include?(event.trigger)
            if not event.jumping? and event.over_trigger?
              event.start
              return true
            end
          end
        end
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ● 正面のイベント起動判定
  #--------------------------------------------------------------------------
  def check_event_trigger_there(triggers)
    return false if $game_system.map_interpreter.running?
    new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    if ( val = $game_map.check_event_player( new_x , new_y ))
      if val.is_a?(Fixnum)
        event = $game_map.events[val]
        if triggers.include?(event.trigger)
          unless event.jumping? or event.over_trigger?
            event.start
            return true
          end
        end
      else
        for event_id in val
          event = $game_map.events[event_id]
          if triggers.include?(event.trigger)
            unless event.jumping? or event.over_trigger?
              event.start
              return true
            end
          end
        end
      end
    end
    return false unless $game_map.counter?(new_x, new_y)
    new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    if ( val = $game_map.check_event_player( new_x , new_y ))
      if val.is_a?(Fixnum)
        event = $game_map.events[val]
        if TRIGGER_PLAYER.include?(event.trigger)
          unless event.jumping? or event.over_trigger?
            event.start
            return true
          end
        end
      else
        for event_id in val
          event = $game_map.events[event_id]
          if TRIGGER_PLAYER.include?(event.trigger)
            unless event.jumping? or event.over_trigger?
              event.start
              return true
            end
          end
        end
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ● 接触イベントの起動判定
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    return false if $game_system.map_interpreter.running?
    if ( val = $game_map.check_event_player( x , y ))
      if val.is_a?(Fixnum)
        event = $game_map.events[val]
        if TRIGGER_PLAYER.include?(event.trigger)
         unless event.jumping? or event.over_trigger?
            event.start
            return true
          end
        end
      else
        for event_id in val
          event = $game_map.events[event_id]
          if TRIGGER_PLAYER.include?(event.trigger)
            unless event.jumping? or event.over_trigger?
              event.start
              return true
            end
          end
        end
      end
    end
    return false
  end
end


#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
#  マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは
# Scene_Map クラスの内部で使用されます。
#==============================================================================
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 200
    @viewport3.z = 5000
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names
      @tilemap.autotiles = RPG::Cache.autotile(autotile_name)
    end
    @tilemap.map_data = $game_map.data
    @tilemap.priorities = $game_map.priorities
    @panorama = Plane.new(@viewport1)
    @panorama.z = -1000
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
    @character_sprites = Hash.new
    $game_map.events.each do | i , event |
      @character_sprites = Sprite_Character.new(@viewport1, event)
    end
    Game_Character.character_method( charcter_method )
    @weather = RPG::Weather.new(@viewport1)
    @picture_sprites = []
    for i in 1..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2,
        $game_screen.pictures))
    end
    @timer_sprite = Sprite_Timer.new
    update
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    @tilemap.tileset.dispose
    for i in 0..6
      @tilemap.autotiles.dispose
    end
    @tilemap.dispose
    @panorama.dispose
    @fog.dispose
    unless @character_sprites.nil?
      @character_sprites.each_value do | sprite |
        sprite.dispose unless sprite.nil?
      end
    end
    @weather.dispose
    for sprite in @picture_sprites
      sprite.dispose
    end
    @timer_sprite.dispose
    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    if @panorama_name != $game_map.panorama_name or
       @panorama_hue != $game_map.panorama_hue
      @panorama_name = $game_map.panorama_name
      @panorama_hue = $game_map.panorama_hue
      if @panorama.bitmap != nil
        @panorama.bitmap.dispose
        @panorama.bitmap = nil
      end
      if @panorama_name != ""
        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
      end
      Graphics.frame_reset
    end
    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
      @fog_name = $game_map.fog_name
      @fog_hue = $game_map.fog_hue
      if @fog.bitmap != nil
        @fog.bitmap.dispose
        @fog.bitmap = nil
      end
      if @fog_name != ""
        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
      end
      Graphics.frame_reset
    end
    @tilemap.ox = $game_map.display_x / 4
    @tilemap.oy = $game_map.display_y / 4
    @tilemap.update
    @panorama.ox = $game_map.display_x / 8
    @panorama.oy = $game_map.display_y / 8
    @fog.zoom_x = $game_map.fog_zoom / 100.0
    @fog.zoom_y = $game_map.fog_zoom / 100.0
    @fog.opacity = $game_map.fog_opacity
    @fog.blend_type = $game_map.fog_blend_type
    @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
    @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
    @fog.tone = $game_map.fog_tone
    $game_map.events.each do | i , event |
      @character_sprites.update if event.onscreen
    end
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.ox = $game_map.display_x / 4
    @weather.oy = $game_map.display_y / 4
    @weather.update
    for sprite in @picture_sprites
      sprite.update
    end
    @timer_sprite.update
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    @viewport3.color = $game_screen.flash_color
    @viewport1.update
    @viewport3.update
  end
  #--------------------------------------------------------------------------
  # ● キャラクター再代入 メソッド
  #--------------------------------------------------------------------------
  def charcter_method
    self.method(:charcter_change)
  end
  private
  #--------------------------------------------------------------------------
  # ◆(内部専用)◆ キャラクター再代入
  #--------------------------------------------------------------------------
  def charcter_change( character_id , character )
    if @character_sprites[character_id]
      @character_sprites[character_id].character = character
    end
  end
end

#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
#  キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを
# 監視し、スプライトの状態を自動的に変化させます。
#==============================================================================
class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :character                # キャラクター
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     viewport  : ビューポート
  #     character : キャラクター (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    begin
      super(viewport)
      @character = character
      update
    rescue Exception
      dispose
      raise
    end
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    unless self.bitmap.nil?
      self.bitmap.dispose
      self.bitmap = nil
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● キャラクター代入
  #--------------------------------------------------------------------------
  def character=(character)
    if character.is_a?(Game_Character)
      @character = character
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    if (self.visible = (not @character.transparent))
      if @tile_id != @character.tile_id or
         @character_name != @character.character_name or
         @character_hue != @character.character_hue
        @tile_id = @character.tile_id
        @character_name = @character.character_name
        @character_hue = @character.character_hue
        if @tile_id >= 384
          self.bitmap = RPG::Cache.tile( $game_map.tileset_name ,
                                         @tile_id , @character.character_hue )
          self.src_rect.set(0, 0, 32, 32)
          self.ox = 16
          self.oy = 32
          @character.size_change( 1, 1)
        else
          self.bitmap = RPG::Cache.character( @character.character_name ,
                                              @character.character_hue )
          @cw = bitmap.width >> 2
          @ch = bitmap.height >> 2
          self.ox = @cw >> 1
          self.oy = @ch
          if @cw >= LARGE_SET or @ch >= LARGE_SET
            size_x = 1
            size_y = 1
            until @cw < ( LARGE_SET + LARGE_SIZE * size_x )
              size_x += 1
            end
            until @ch < ( LARGE_SET + LARGE_SIZE * size_y )
              size_y += 1
            end
            @character.size_change((size_x << 1) + 1, size_y + 1)
          else
            @character.size_change( 1, 1)
          end
        end
      end
      if @tile_id.zero?
        sx = @character.pattern * @cw
        sy = ((@character.direction - 2) >> 1 ) * @ch
        self.src_rect.set(sx, sy, @cw, @ch)
      end
      self.x = @character.screen_x
      self.y = @character.screen_y
      self.z = @character.screen_z(@ch)
      self.opacity = @character.opacity
      self.blend_type = @character.blend_type
      self.bush_depth = @character.bush_depth
      unless @character.animation_id.zero?
        animation = $data_animations.at(@character.animation_id)
        animation(animation, true)
        @character.animation_id = 0
      end
    end
  end
end

点评

依然不行。我上传了大小判断的其他一起用的脚本。能知道是什么原因吗  发表于 2016-1-22 16:20
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部