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

Project1

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

[讨论] 请大家分析这些脚本是干什么的

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
49 小时
注册时间
2012-1-11
帖子
114
跳转到指定楼层
1
发表于 2012-3-27 12:23:23 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 精灵使者 于 2012-3-28 15:09 编辑

第一个:
  1. #===============================================================================
  2. #◆のびハザメニュー画面カスタマイズスクリプト
  3. #
  4. #再定義しているのでなるべく素材の上の方に導入することをお勧めします。
  5. #同じ個所を再定義しているスクリプトを新たに導入すると競合する恐れがあります。
  6. #===============================================================================
  7. #==============================================================================
  8. # ■ Window_Base
  9. #------------------------------------------------------------------------------
  10. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  11. #==============================================================================

  12. class Window_Base < Window
  13. module NOBIHAZARD
  14.   module MENU
  15. #-------------------------------------------------------------------------------
  16. #●カスタマイズ項目
  17. #-------------------------------------------------------------------------------   
  18.     #Lvの描画
  19.     DRAW_LV = false
  20.     #HPの描画を有効にするか
  21.     DRAW_HP_VALUE = false
  22.    
  23.     #HPゲージの描画を有効にするか
  24.     DRAW_HP_G = true
  25.    
  26.     #HPゲージの色
  27.     FINE = 11
  28.     FINE2 = 29
  29.    
  30.     CAUTION = 17
  31.     CAUTION2 = 6
  32.    
  33.     CAUTION3 = 20
  34.     CAUTION4 = 21
  35.    
  36.     DANGER = 10
  37.     DANGER2 = 2
  38.    
  39.     #MPゲージの描画を有効にするか
  40.     DRAW_MP_G = true
  41.    
  42.     #MPゲージの色
  43.     MP_G1 = 22
  44.     MP_G2 = 23
  45.    
  46.    
  47.     #
  48.     BULLET = "Bul."           # 弾薬表示名(長すぎると表示が潰れます)
  49.    
  50.     #通常は変更しないでください
  51.     BULLET_ID = 1000          # 素手の変数のID
  52.    
  53.     #通常は変更しないでください
  54.     BULLET_MAX_ID = 1500      # 素手の変数のID_最大値
  55.    
  56.     #BULLETゲージの色
  57.     BULLET_G1 = 17#20
  58.     BULLET_G2 = 18#21

  59.    
  60.   end
  61. end
  62. end
复制代码
第二个:
  1. #==============================================================================
  2. # ■ Window_MenuStatus
  3. #==============================================================================
  4. # ■ Window_Base
  5. #------------------------------------------------------------------------------
  6. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  7. #==============================================================================

  8. class Window_Base < Window
  9.   #--------------------------------------------------------------------------
  10.   # ● FINEの文字色の取得
  11.   #--------------------------------------------------------------------------
  12.   def fine_color
  13.     return text_color(NOBIHAZARD::MENU::FINE)
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● FINEの文字色の取得2
  17.   #--------------------------------------------------------------------------
  18.   def fine_color2
  19.     return text_color(NOBIHAZARD::MENU::FINE2)
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # ● CAUTIONの文字色の取得
  23.   #--------------------------------------------------------------------------
  24.   def caution_color
  25.     return text_color(NOBIHAZARD::MENU::CAUTION)
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● CAUTIONの文字色の取得2
  29.   #--------------------------------------------------------------------------
  30.   def caution_color2
  31.     return text_color(NOBIHAZARD::MENU::CAUTION2)
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● CAUTIONの文字色の取得3
  35.   #--------------------------------------------------------------------------
  36.   def caution_color3
  37.     return text_color(NOBIHAZARD::MENU::CAUTION3)
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● CAUTIONの文字色の取得4
  41.   #--------------------------------------------------------------------------
  42.   def caution_color4
  43.     return text_color(NOBIHAZARD::MENU::CAUTION4)
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● DANGERの文字色の取得
  47.   #--------------------------------------------------------------------------
  48.   def danger_color
  49.     return text_color(NOBIHAZARD::MENU::DANGER)
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● DANGERの文字色の取得
  53.   #--------------------------------------------------------------------------
  54.   def danger_color2
  55.     return text_color(NOBIHAZARD::MENU::DANGER2)
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● HP の文字色を取得
  59.   #     actor : アクター
  60.   #--------------------------------------------------------------------------
  61.   def hp_gauge_color(actor)
  62.     return knockout_color if actor.hp == 0
  63.     return danger_color if actor.hp < actor.maxhp / 4
  64.     return caution_color3 if actor.hp < actor.maxhp / 2
  65.     return caution_color if actor.hp < actor.maxhp * 3 / 4
  66.     return fine_color
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● HP の文字色を取得2
  70.   #     actor : アクター
  71.   #--------------------------------------------------------------------------
  72.   def hp_gauge_color2(actor)
  73.     return knockout_color if actor.hp == 0
  74.     return danger_color2 if actor.hp < actor.maxhp / 4
  75.     return caution_color4 if actor.hp < actor.maxhp / 2
  76.     return caution_color2 if actor.hp < actor.maxhp * 3 / 4
  77.     return fine_color2
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● Bullet ゲージの色 1 の取得★カスタム
  81.   #--------------------------------------------------------------------------
  82.   def bullet_gauge_color1
  83.     return text_color(NOBIHAZARD::MENU::BULLET_G1)
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● Bullet ゲージの色 2 の取得★カスタム
  87.   #--------------------------------------------------------------------------
  88.   def bullet_gauge_color2
  89.     return text_color(NOBIHAZARD::MENU::BULLET_G2)
  90.   end

  91.   #--------------------------------------------------------------------------
  92.   # ● MP ゲージの色 1 の取得
  93.   #--------------------------------------------------------------------------
  94.   def mp_gauge_color1
  95.     return text_color(NOBIHAZARD::MENU::MP_G1)
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● MP ゲージの色 2 の取得
  99.   #--------------------------------------------------------------------------
  100.   def mp_gauge_color2
  101.     return text_color(NOBIHAZARD::MENU::MP_G2)
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● HP の文字色を取得
  105.   #     actor : アクター
  106.   #--------------------------------------------------------------------------
  107.   def hp_color(actor)
  108.     return knockout_color if actor.hp == 0
  109.     return normal_color
  110.   end  
  111.   #--------------------------------------------------------------------------
  112.   # ● Bullet の文字色を取得
  113.   # カスタムイベント
  114.   #--------------------------------------------------------------------------
  115.   def bullet_color
  116.     return normal_color #弾丸の表示色は常に同じ色。
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● アクターの歩行グラフィック描画
  120.   #     actor : アクター
  121.   #     x     : 描画先 X 座標
  122.   #     y     : 描画先 Y 座標
  123.   #--------------------------------------------------------------------------
  124.   def draw_actor_graphic(actor, x, y)
  125.     draw_character(actor.character_name, actor.character_index, x, y)
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● アクターの顔グラフィック描画(オリジナル)
  129.   #     actor : アクター
  130.   #     x     : 描画先 X 座標
  131.   #     y     : 描画先 Y 座標
  132.   #     size  : 表示サイズ
  133.   #--------------------------------------------------------------------------
  134.   def draw_actor_face(actor, x, y, size = 96)
  135.     draw_face(actor.face_name, actor.face_index, x, y, size)
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 名前の描画
  139.   #     actor : アクター
  140.   #     x     : 描画先 X 座標
  141.   #     y     : 描画先 Y 座標
  142.   #--------------------------------------------------------------------------
  143.   def draw_actor_name(actor, x, y)
  144.     self.contents.font.color = hp_color(actor)
  145.     self.contents.draw_text(x, y, 108, WLH, actor.name)
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● クラスの描画
  149.   #     actor : アクター
  150.   #     x     : 描画先 X 座標
  151.   #     y     : 描画先 Y 座標
  152.   #--------------------------------------------------------------------------
  153.   def draw_actor_class(actor, x, y)
  154.     self.contents.font.color = normal_color
  155.     self.contents.draw_text(x, y, 108, WLH, actor.class.name)
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● ステートの描画
  159.   #     actor : アクター
  160.   #     x     : 描画先 X 座標
  161.   #     y     : 描画先 Y 座標
  162.   #     width : 描画先の幅
  163.   #--------------------------------------------------------------------------
  164.   def draw_actor_state(actor, x, y, width = 96)
  165.     count = 0
  166.     for state in actor.states
  167.       draw_icon(state.icon_index, x + 24 * count, y)
  168.       count += 1
  169.       break if (24 * count > width - 24)
  170.     end
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● HP ゲージの描画
  174.   #     actor : アクター
  175.   #     x     : 描画先 X 座標
  176.   #     y     : 描画先 Y 座標
  177.   #     width : 幅
  178.   #--------------------------------------------------------------------------
  179.   def draw_actor_hp_gauge(actor, x, y, width = 120)
  180.     gw = width * actor.hp / actor.maxhp
  181.     gc1 = hp_gauge_color(actor)
  182.     gc2 = hp_gauge_color2(actor)
  183.     #gc1 = hp_gauge_color1
  184.     #gc2 = hp_gauge_color2
  185.     self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
  186.     self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● HP の描画
  190.   #     actor : アクター
  191.   #     x     : 描画先 X 座標
  192.   #     y     : 描画先 Y 座標
  193.   #     width : 幅
  194.   #--------------------------------------------------------------------------
  195.   def draw_actor_hp(actor, x, y, width = 120)
  196.     draw_actor_hp_gauge(actor, x, y, width)
  197.     self.contents.font.color = system_color
  198.     self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
  199.     if NOBIHAZARD::MENU::DRAW_HP_VALUE
  200.       self.contents.font.color = hp_color(actor)
  201.       xr = x + width
  202.       if width < 120
  203.         self.contents.draw_text(xr - 40, y, 40, WLH, actor.hp, 2)
  204.       else
  205.         self.contents.draw_text(xr - 90, y, 40, WLH, actor.hp, 2)
  206.         self.contents.font.color = normal_color
  207.         self.contents.draw_text(xr - 50, y, 10, WLH, "/", 2)
  208.         self.contents.draw_text(xr - 40, y, 40, WLH, actor.maxhp, 2)
  209.       end
  210.     end
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● bullet の描画
  214.   #     actor : アクター
  215.   #     x     : 描画先 X 座標
  216.   #     y     : 描画先 Y 座標
  217.   #     width : 幅
  218.   #--------------------------------------------------------------------------
  219.   #★カスタムスクリプト
  220.   def draw_bullet(actor, x, y, width = 120)
  221.     top_actor = $game_party.members[0]#先頭のアクターを取得
  222.     w_id = top_actor.weapon_id #先頭アクターの武器のIDをローカル変数に格納
  223.     #武器のIDから武器の残弾数が格納されているツクール変数のIDを取得
  224.     w_v_id = w_id + NOBIHAZARD::MENU::BULLET_ID
  225.     #武器のIDから武器のMAX弾数が格納されているツクール変数のIDを取得
  226.     w_max_id = w_id + NOBIHAZARD::MENU::BULLET_MAX_ID
  227.     #参照変数に---が代入されているときは、ゲージの長さは0。
  228.    draw_bullet_gauge(actor, x, y, width)
  229.     self.contents.font.color = system_color
  230.    self.contents.draw_text(x, y, 30, WLH, NOBIHAZARD::MENU::BULLET)
  231.     self.contents.font.color = bullet_color
  232.     xr = x + width
  233.     if width < 120
  234.       #self.contents.draw_text(xr - 40, y, 40, WLH, actor.hp, 2)
  235.       #現在装填数の描画
  236.       self.contens.draw_text(xr - 40, y, 40 , WLH, $game_variables[w_v_id], 2)
  237.     else
  238.       #self.contents.draw_text(xr - 90, y, 40, WLH, actor.hp, 2)
  239.       #現在装填数の描画
  240.       self.contents.draw_text(xr - 90, y, 40, WLH, $game_variables[w_v_id], 2)
  241.       self.contents.font.color = normal_color
  242.       self.contents.draw_text(xr - 50, y, 10, WLH, "/", 2)
  243.       #self.contents.draw_text(xr - 40, y, 40, WLH, actor.maxhp, 2)
  244.       #最大装填数の描画
  245.       self.contents.draw_text(xr - 40, y, 40, WLH, $game_variables[w_max_id], 2)
  246.     end
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● bullet ゲージの描画(カスタム)
  250.   #     actor : アクター
  251.   #     x     : 描画先 X 座標
  252.   #     y     : 描画先 Y 座標
  253.   #     width : 幅
  254.   #--------------------------------------------------------------------------
  255.   def draw_bullet_gauge(actor, x, y, width = 120)
  256.     top_actor = $game_party.members[0]#先頭のアクターを取得
  257.     w_id = top_actor.weapon_id #先頭アクターの武器のIDをローカル変数に格納
  258.     #武器のIDから武器の残弾数が格納されているツクール変数のIDを取得
  259.     w_v_id = w_id + NOBIHAZARD::MENU::BULLET_ID
  260.     #武器のIDから武器のMAX弾数が格納されているツクール変数のIDを取得
  261.     w_max_id = w_id + NOBIHAZARD::MENU::BULLET_MAX_ID
  262.     #参照変数に---が代入されているときは、ゲージの長さは0。
  263.     if $game_variables[w_max_id] == 0
  264.       bull = 1 # 0÷0の計算を回避。0÷0を計算させたらエラーで落ちる。
  265.     else
  266.       bull = 0
  267.     end
  268.     if $game_variables[w_v_id] == "---"
  269.       gw = 0
  270.     else
  271.     gw = width * $game_variables[w_v_id] / ($game_variables[w_max_id] + bull)
  272.   end
  273.     gc1 = bullet_gauge_color1
  274.     gc2 = bullet_gauge_color2
  275.     self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
  276.     self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● MP ゲージの描画
  280.   #     actor : アクター
  281.   #     x     : 描画先 X 座標
  282.   #     y     : 描画先 Y 座標
  283.   #     width : 幅
  284.   #--------------------------------------------------------------------------
  285.   def draw_actor_mp_gauge(actor, x, y, width = 120)
  286.     gw = width * actor.mp / [actor.maxmp, 1].max
  287.     gc1 = mp_gauge_color1
  288.     gc2 = mp_gauge_color2
  289.     self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
  290.     self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  291.   end
  292. end




  293. #------------------------------------------------------------------------------
  294. #  メニュー画面でパーティメンバーのステータスを表示するウィンドウです。
  295. #==============================================================================

  296. class Window_MenuStatus < Window_Selectable
  297.   #--------------------------------------------------------------------------
  298.   # ● リフレッシュ
  299.   #--------------------------------------------------------------------------
  300. #カスタム
  301.   def refresh
  302.     self.contents.clear
  303.     @item_max = $game_party.members.size
  304.     draw_bullet(0, 104 + 120 , WLH / 2 + WLH * 2+96)#残弾数表示
  305.     #for actor in $game_party.members
  306.     actor = $game_party.members[0]#のびハザではパーティに二人以上メンバーが居ることはないので。
  307.       draw_actor_face(actor, 2, actor.index * 96 + 2, 92)
  308.       x = 104
  309.       y = actor.index * 96 + WLH / 2
  310.       draw_actor_name(actor, x, y)
  311.       draw_top_equip_weapon
  312.       draw_actor_class(actor, x + 120, y)
  313.       
  314.       if NOBIHAZARD::MENU::DRAW_LV
  315.         draw_actor_level(actor, x, y + WLH * 1)
  316.       end
  317.       
  318.       draw_actor_state(actor, x, y + WLH * 2)
  319. #      draw_bullet(0, x + 120 , y + WLH * 1)
  320.       #draw_bullet(0, 104 + 120 , WLH / 2 + WLH * 1)#残弾数表示

  321.       if NOBIHAZARD::MENU::DRAW_HP_G
  322.         draw_actor_hp(actor, x + 120, y + WLH * 1)
  323.       end
  324.       if NOBIHAZARD::MENU::DRAW_MP_G
  325.         draw_actor_mp(actor, x + 120, y + WLH * 2)
  326.       end
  327.       
  328.       draw_item_name(actor.equips[0], x, y+96)#武器名とアイコンの描画
  329.     #end
  330.   end
  331. end

  332. #==============================================================================
  333. # ■ Window_BattleStatus
  334. #------------------------------------------------------------------------------
  335. #  バトル画面でパーティメンバーのステータスを表示するウィンドウです。
  336. #==============================================================================

  337. class Window_BattleStatus < Window_Selectable
  338.   #--------------------------------------------------------------------------
  339.   # ● 項目の描画
  340.   #     index   : 項目番号
  341.   #--------------------------------------------------------------------------
  342.   def draw_item(index)
  343.     rect = item_rect(index)
  344.     rect.x += 4
  345.     rect.width -= 8
  346.     self.contents.clear_rect(rect)
  347.     self.contents.font.color = normal_color
  348.     actor = $game_party.members[index]
  349.     draw_actor_name(actor, 4, rect.y)
  350.     draw_actor_state(actor, 114, rect.y, 48)
  351.     if NOBIHAZARD::MENU::DRAW_HP_G
  352.       draw_actor_hp(actor, 174, rect.y, 120)
  353.     end
  354.     if NOBIHAZARD::MENU::DRAW_MP_G
  355.       draw_actor_mp(actor, 310, rect.y, 70)
  356.     end
  357.   end
  358. end

  359. #==============================================================================
  360. # ■ Window_SkillStatus
  361. #------------------------------------------------------------------------------
  362. #  スキル画面で、スキル使用者のステータスを表示するウィンドウです。
  363. #==============================================================================

  364. class Window_SkillStatus < Window_Base
  365.   #--------------------------------------------------------------------------
  366.   # ● リフレッシュ
  367.   #--------------------------------------------------------------------------
  368.   def refresh
  369.     self.contents.clear
  370.     draw_actor_name(@actor, 4, 0)
  371.     if NOBIHAZARD::MENU::DRAW_LV
  372.       draw_actor_level(@actor, 140, 0)
  373.     end
  374.     if NOBIHAZARD::MENU::DRAW_HP_G
  375.       draw_actor_hp(@actor, 240, 0)
  376.     end
  377.     if NOBIHAZARD::MENU::DRAW_MP_G
  378.       draw_actor_mp(@actor, 392, 0)
  379.     end
  380.   end
  381. end
复制代码
第三个:
  1. #==============================================================================
  2. # ■ Window_Base
  3. #------------------------------------------------------------------------------
  4. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  5. #==============================================================================

  6. class Window_Base < Window
  7.   #--------------------------------------------------------------------------
  8.   # ● 自動変更顔グラフィックの描画(先頭以外のアクターのインデックスまでかわってしまう)
  9.   #     face_name  : 顔グラフィック ファイル名
  10.   #     face_index : 顔グラフィック インデックス
  11.   #     x          : 描画先 X 座標
  12.   #     y          : 描画先 Y 座標
  13.   #     size       : 表示サイズ
  14.   #--------------------------------------------------------------------------
  15.   def draw_actor_face(actor, x, y, size = 96)
  16.     #カスタム
  17.     actor = $game_party.members[0]
  18.     hp_ratio = 100 * actor.hp / actor.maxhp#HPの割合を計算
  19.     if actor.state?(5)
  20.       face_index = 6#ウィルス
  21.     elsif actor.state?(2)
  22.       face_index = 4#毒
  23.     elsif actor.state?(3)
  24.       face_index = 4#毒
  25.     elsif actor.state?(4)
  26.       face_index = 5#出血
  27.     elsif hp_ratio >=75
  28.       face_index = 0
  29.     elsif hp_ratio >=50
  30.       face_index = 1
  31.     elsif hp_ratio >=25
  32.       face_index = 2
  33.     else
  34.       face_index = 3
  35.     end
  36.     #
  37.     actor.set_graphic(actor.character_name,actor.character_index,actor.face_name,face_index)
  38.     draw_face(actor.face_name, actor.face_index, x, y, size)
  39.   end
  40. end
复制代码
第四个:
  1. #==============================================================================
  2. # ■ Window_Base
  3. #------------------------------------------------------------------------------
  4. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  5. #==============================================================================

  6. class Window_Base < Window
  7.   #--------------------------------------------------------------------------
  8.   # ● 装備している武器の顔グラフィックをメニュー画面に表示するためのスクリプトです。
  9.   #     weapon_name  : 顔グラフィック ファイル名
  10.   #     weapon_index : 顔グラフィック インデックス
  11.   #     x          : 描画先 X 座標
  12.   #     y          : 描画先 Y 座標
  13.   #     size       : 表示サイズ
  14.   #--------------------------------------------------------------------------
  15.   def draw_equip_weapon(weapon_name="", weapon_index=0, x=2, y=98, size = 96)
  16.     #カスタム
  17.     actor = $game_party.members[0]
  18.     top_weapon_id = actor.weapon_id
  19.     w_name =""#表示する武器の名前
  20.     case top_weapon_id #武器のID
  21.     #---------------------------------------------------------------------------
  22.     #●カスタマイズ項目
  23.     #---------------------------------------------------------------------------
  24.     #when右にある数字が武器のIDです。
  25.     #その後のweapon_nameとweapon_indexで表示させたい武器の顔グラフィックを指定します。
  26.     #ファイル名は""の間に正しく記入してください。間違えるとエラーが出ます。
  27.     #インデックスは範囲は0~7です。
  28.     when 0 #武器のIDが0(装備していない時)
  29.       weapon_name ="空白";weapon_index=0#すで
  30.     when 1 #武器のIDが1の時
  31.       weapon_name ="空白";weapon_index=0 #0~7
  32.     when 2
  33.       weapon_name ="武器02";weapon_index=1 #ナイフ
  34.     when 3
  35.       weapon_name ="武器04";weapon_index=3 #包丁
  36.     when 4
  37.       weapon_name ="空白";weapon_index=0 #0~7
  38.     when 5
  39.       weapon_name ="武器01";weapon_index=0 #ハンドガン
  40.     when 6
  41.       weapon_name ="武器01";weapon_index=1 #カスタムハンドガン
  42.     when 7
  43.       weapon_name ="空白";weapon_index=0 #0~7
  44.     when 8
  45.       weapon_name ="武器01";weapon_index=2 #ショットガン
  46.     when 9
  47.       weapon_name ="武器02";weapon_index=2 #レミントン
  48.     when 10
  49.       weapon_name ="武器02";weapon_index=3 #カスタムショットガン
  50.     when 11
  51.       weapon_name ="武器01";weapon_index=3 #0~7
  52.     when 12
  53.       weapon_name ="空白";weapon_index=0 #0~7
  54.     when 13
  55.       weapon_name ="武器01";weapon_index=4 #マグナムリボルバー
  56.     when 14
  57.       weapon_name ="武器01";weapon_index=7 #デザートイーグル
  58.     when 15
  59.       weapon_name ="武器02";weapon_index=5 #.44マグナム
  60.     when 16
  61.       weapon_name ="武器01";weapon_index=6 #護身用拳銃
  62.     when 17
  63.       weapon_name ="空白";weapon_index=0 #0~7
  64.     when 18
  65.       weapon_name ="武器04";weapon_index=4 #グレネードランチャー
  66.     when 19
  67.       weapon_name ="武器04";weapon_index=6 #グレネードランチャー
  68.     when 20
  69.       weapon_name ="武器04";weapon_index=5 #グレネードランチャー
  70.     when 21
  71.       weapon_name ="空白";weapon_index=0 #0~7
  72.     when 22
  73.       weapon_name ="武器02";weapon_index=7 #アサルトライフル
  74.     when 23
  75.       weapon_name ="空白";weapon_index=0 #0~7
  76.     when 24
  77.       weapon_name ="武器01";weapon_index=0 #∞ハンドガン
  78.     when 25
  79.       weapon_name ="武器02";weapon_index=7 #∞アサルトライフル
  80.     when 26
  81.       weapon_name ="武器02";weapon_index=6 #∞ロケットランチャー
  82.     when 27
  83.       weapon_name ="空白";weapon_index=0 #0~7
  84.     when 28
  85.       weapon_name ="武器02";weapon_index=6 #ロケットランチャー
  86.     when 29
  87.       weapon_name ="武器03";weapon_index=0 #バズーカ
  88.     when 30
  89.       weapon_name ="武器03";weapon_index=3 #ライフル型ロケットランチャー
  90.     when 31
  91.       weapon_name ="武器03";weapon_index=0 #バズーカ
  92.     when 32
  93.       weapon_name ="武器03";weapon_index=3 #0~7
  94.     when 33
  95.       weapon_name ="武器01";weapon_index=4 #マグナムリボルバー
  96.     when 34
  97.       weapon_name ="武器04";weapon_index=0 #ハンドキャノン
  98.     when 35
  99.       weapon_name ="空白";weapon_index=0 #0~7
  100.     when 36
  101.       weapon_name ="秘密道具01";weapon_index=0 #0~7
  102.     when 37
  103.       weapon_name ="空白";weapon_index=0 #0~7
  104.     when 38
  105.       weapon_name ="武器04";weapon_index=1 #ショットガンSA
  106.     when 39
  107.       weapon_name ="空白";weapon_index=0 #0~7
  108.     when 40
  109.       weapon_name ="空白";weapon_index=0 #0~7
  110.     when 41
  111.       weapon_name ="空白";weapon_index=0 #0~7
  112.     when 42
  113.       weapon_name ="武器02";weapon_index=1 #ナイフ
  114.     when 43
  115.       weapon_name ="空白";weapon_index=0 #0~7
  116.     when 44
  117.       weapon_name ="武器01";weapon_index=0 #ハンドガン
  118.     when 45
  119.       weapon_name ="武器01";weapon_index=1 #カスタムハンドガン
  120.     when 46
  121.       weapon_name ="空白";weapon_index=0 #0~7
  122.     when 47
  123.       weapon_name ="武器02";weapon_index=2 #レミントン
  124.     when 48
  125.       weapon_name ="武器02";weapon_index=3 #カスタムショットガン
  126.     when 49
  127.       weapon_name ="空白";weapon_index=0 #0~7
  128.     when 50
  129.       weapon_name ="武器01";weapon_index=7 #デザートイーグル
  130.     when 51
  131.       weapon_name ="空白";weapon_index=0 #デリンジャー
  132.     when 52
  133.       weapon_name ="武器05";weapon_index=2 #ボウイナイフ
  134.     end
  135.     #---------------------------------------------------------------------------
  136.     #---------------------------------------------------------------------------
  137.     #---------------------------------------------------------------------------
  138.     bitmap = Cache.face(weapon_name)
  139.     rect = Rect.new(0, 0, 0, 0)
  140.     rect.x = weapon_index % 4 * 96 + (96 - size) / 2
  141.     rect.y = weapon_index / 4 * 96 + (96 - size) / 2
  142.     rect.width = size
  143.     rect.height = size
  144.     self.contents.blt(x, y, bitmap, rect)
  145.     bitmap.dispose
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 武器の顔グラフィック描画
  149.   #     actor : アクター
  150.   #     x     : 描画先 X 座標
  151.   #     y     : 描画先 Y 座標
  152.   #     size  : 表示サイズ
  153.   #--------------------------------------------------------------------------
  154.   def draw_top_equip_weapon
  155.     draw_equip_weapon
  156.   end
  157. end
复制代码
第五个:
  1. #==============================================================================
  2. # ■ Game_Interpreter
  3. #------------------------------------------------------------------------------
  4. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  5. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  6. #==============================================================================
  7. class Game_Interpreter
  8. #--------------------------------------------------------------------------
  9. #☆カスタム
  10. #--------------------------------------------------------------------------
  11. #○追加定義
  12. #●マップイベントの呼び出し!
  13. #---------------------------------------------------------------------------
  14. # マップイベント呼び出し(ページ指定対応)
  15.   def cme(id,j)
  16.     event = $game_map.events[id]
  17.     @child_interpreter = Game_Interpreter.new(@depth+1)
  18.     @child_interpreter.setup(event.instance_variable_get(:@event).pages[j-1].list,id)
  19.   end
  20. end
  21. #イベントスクリプトから「cme(イベントID, ページ番号)」
  22. #イベントの出現条件を満たしていなくても(一時消去されていようが関係なく)
  23. #強制的にマップイベントを呼び出します。
复制代码
第六个:
  1. #==============================================================================
  2. # ■ Game_System_re
  3. #------------------------------------------------------------------------------
  4. #  タイマーを一時的に停止できるよう、再定義しました。(再定義)
  5. #==============================================================================

  6. class Game_System
  7.   #--------------------------------------------------------------------------
  8.   # ● オブジェクト初期化
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     @timer = 0
  12.     @timer_working = false
  13.     @save_disabled = false
  14.     @menu_disabled = false
  15.     @encounter_disabled = false
  16.     @save_count = 0
  17.     @version_id = 0
  18.     @timer_off = false                           # 追加
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● フレーム更新
  22.   #--------------------------------------------------------------------------
  23.   def update
  24.     if @timer_working and @timer > 0
  25.       if @timer_off == false                      # 追加
  26.         @timer -= 1
  27.       end                                         # 追加
  28.       if @timer == 0 and $game_temp.in_battle     # 戦闘中にタイマーが 0 に
  29.         $game_temp.next_scene = "map"             # なったら戦闘を中断する
  30.       end
  31.     end
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● タイマーを一時停止する # 追加
  35.   #--------------------------------------------------------------------------
  36.   def timer_stop
  37.     @timer_off = true
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● タイマーを再開する # 追加
  41.   #--------------------------------------------------------------------------
  42.   def timer_start
  43.     @timer_off = false
  44.   end
  45. end
复制代码
第七个:
  1. #
  2. #    特殊効果判定用ベーススクリプトVer1.10(RGSS2)
  3. #  (C)2007-2008 TYPE74RX-T
  4. #

  5. #==============================================================================
  6. # ■ module Kernel(機能拡張)
  7. #   (Ver1.09より実装)
  8. #     ★ rx_delete(array)
  9. #   配列で指定した要素を全て取り除く
  10. #     ★ rx_eqaror(array)
  11. #   配列で指定した要素のうちのいずれかに一致しているか
  12. #     ★ rx_eqarand(array)
  13. #   配列で指定した要素のうちのどれにも一致しているか
  14. #     ★ rx_atob(a, b)
  15. #   整数値がaからbまでの範囲内であるか
  16. #==============================================================================

  17. module Kernel
  18.   #--------------------------------------------------------------------------
  19.   # ★ 配列で指定した要素を全て取り除く
  20.   #--------------------------------------------------------------------------
  21.   def rx_delete(array)
  22.     for i in 0...array.size
  23.       self.delete(array[i])
  24.     end
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ★ 配列で指定した要素のうちのいずれかに一致しているか
  28.   #--------------------------------------------------------------------------
  29.   def rx_eqaror(array)
  30.     result = false
  31.     for i in 0...array.size
  32.       if self == array[i]
  33.         result = true
  34.         break
  35.       end
  36.     end
  37.     return result
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ★ 配列で指定した要素のうちのどれにも一致しているか
  41.   #--------------------------------------------------------------------------
  42.   def rx_eqarand(array)
  43.     result = true
  44.     for i in 0...array.size
  45.       if self != array[i]
  46.         result = false
  47.         break
  48.       end
  49.     end
  50.     return result
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ★ 整数値がaからbまでの範囲内であるか
  54.   #--------------------------------------------------------------------------
  55.   def rx_atob(a, b)
  56.     return (self >= a and self <= b)
  57.   end
  58. end

  59. #==============================================================================
  60. # ★ RX_T
  61. #------------------------------------------------------------------------------
  62. #  素材用汎用モジュールです。
  63. #==============================================================================

  64. module RX_T
  65.   #--------------------------------------------------------------------------
  66.   # ● 装備用システムワードに指定文字列が含まれているか
  67.   #--------------------------------------------------------------------------
  68.   def self.check_system_word_in_equip(sys_str, string)
  69.     return sys_str.include?(string)
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 装備用システムワードに指定文字列が含まれていれば
  73.   #   それに付随する数値を抽出
  74.   #    obj : スキル、アイテム、武器、防具 string : 指定文字列
  75.   #--------------------------------------------------------------------------
  76.   def self.get_numeric_of_system_word_in_equip(sys_str, string)
  77.     if sys_str.include?(string)
  78.       # 最後に指定のシステムワードが書かれた場所以降の文字列を取得
  79.       words_loc = sys_str.rindex(string)  # 文字位置取得
  80.       # 文字列取得(文字位置が 1 番目以上なら)
  81.       new_words = sys_str[words_loc, sys_str.length - 1] if words_loc > 0
  82.       # 数字文字列を取得(文字位置によって処理が異なる)
  83.       param = new_words.scan(/[-10-9]+/) if words_loc > 0
  84.       param = sys_str.scan(/[-10-9]+/) if words_loc < 1
  85.       numeric = param[0].to_i
  86.     else
  87.       numeric = 0
  88.     end
  89.     return numeric
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 装備用システムワードに指定文字列が含まれていれば
  93.   #   それに付随する数値群を配列化して返す
  94.   #    obj : スキル、アイテム、武器、防具 string : 指定文字列
  95.   #--------------------------------------------------------------------------
  96.   def self.get_array_of_system_word_in_equip(sys_str, string)
  97.     elements = []
  98.     if sys_str.include?(string)
  99.       # 最後に指定のシステムワードが書かれた場所以降の文字列を取得
  100.       words_loc = sys_str.rindex(string) + string.size # 文字位置取得
  101.       # 文字列取得
  102.       new_words = sys_str[words_loc, sys_str.length - 1]
  103.       # 数字文字列を配列化して取得
  104.       param = new_words.split(/s*,s*/)
  105.       numeric = param[0].to_i
  106.       # 数値を配列に入れる
  107.       for i in 0...param.size
  108.         numeric = param[i].to_i
  109.         if numeric > 0
  110.           elements.push(numeric)
  111.         else
  112.           break
  113.         end
  114.       end
  115.     end
  116.     return elements
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● システムワードに指定文字列が含まれているか
  120.   #--------------------------------------------------------------------------
  121.   def self.check_system_word_in_sys_str(obj, string)
  122.     return obj.rx_sys_str.include?(string)
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● システムワード格納変数に指定文字列が含まれていれば
  126.   #   それに付随する数値を抽出
  127.   #    obj : スキル、アイテム、武器、防具 string : 指定文字列
  128.   #--------------------------------------------------------------------------
  129.   def self.get_numeric_of_system_word_in_sys_str(obj, string)
  130.     # 素手に対応
  131.     if obj == nil
  132.       return 0
  133.     end
  134.     if obj.rx_sys_str.include?(string)
  135.       # 最後に指定のシステムワードが書かれた場所以降の文字列を取得
  136.       words_loc = obj.rx_sys_str.rindex(string)  # 文字位置取得
  137.       # 文字列取得(文字位置が 1 番目以上なら)
  138.       new_words = obj.rx_sys_str[words_loc, obj.rx_sys_str.length - 1] if words_loc > 0
  139.       # 数字文字列を取得(文字位置によって処理が異なる)
  140.       param = new_words.scan(/[-10-9]+/) if words_loc > 0
  141.       param = obj.rx_sys_str.scan(/[-10-9]+/) if words_loc < 1
  142.       numeric = param[0].to_i
  143.     else
  144.       numeric = 0
  145.     end
  146.     return numeric
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● システムワード格納変数に指定文字列が含まれていれば
  150.   #   それに付随する数値群を配列化して返す
  151.   #    obj : スキル、アイテム、武器、防具 string : 指定文字列
  152.   #--------------------------------------------------------------------------
  153.   def self.get_array_of_system_word_in_sys_str(obj, string)
  154.     elements = []
  155.     # 素手に対応
  156.     if obj == nil
  157.       return elements
  158.     end
  159.     if obj.rx_sys_str.include?(string)
  160.       # 最後に指定のシステムワードが書かれた場所以降の文字列を取得
  161.       words_loc = obj.rx_sys_str.rindex(string) + string.size # 文字位置取得
  162.       # 文字列取得
  163.       new_words = obj.rx_sys_str[words_loc, obj.rx_sys_str.length - 1]
  164.       # 数字文字列を配列化して取得
  165.       param = new_words.split(/s*,s*/)
  166.       numeric = param[0].to_i
  167.       # 数値を配列に入れる
  168.       for i in 0...param.size
  169.         numeric = param[i].to_i
  170.         if numeric > 0
  171.           elements.push(numeric)
  172.         else
  173.           break
  174.         end
  175.       end
  176.     end
  177.     return elements
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● メモにシステムワードが含まれているか
  181.   #--------------------------------------------------------------------------
  182.   def self.check_system_word_in_note(obj, string)
  183.     return obj.note.include?(string)
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● メモにシステムワードが含まれていれば、それとそれに付随する数値を返す
  187.   #    note : メモ string : 指定文字列 option : 数値も返すか否か
  188.   #--------------------------------------------------------------------------
  189.   def self.get_system_word_in_note(note, string, option = false)
  190.     if note.include?(string)
  191.       # 最後に指定のシステムワードが書かれた場所以降の文字列を取得
  192.       words_loc = note.rindex(string)  # 文字位置取得
  193.       # 文字列取得(文字位置が 1 番目以上なら)
  194.       new_words = note[words_loc, note.length - 1] if words_loc > 0
  195.       # 数字文字列を取得(文字位置によって処理が異なる)
  196.       param = new_words.scan(/[-10-9]+/) if words_loc > 0
  197.       param = note.scan(/[-10-9]+/) if words_loc < 1
  198.       # 検出された指定の文字列(と数値)を返す
  199.       return string + param[0] if param != [] and option
  200.       return string if param == [] or not option
  201.     end
  202.     return ""
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● メモにシステムワードが含まれていれば
  206.   #  それとそれに付随する配列用の数値を返す
  207.   #    note : メモ string : 指定文字列 option : 数値も返すか否か
  208.   #--------------------------------------------------------------------------
  209.   def self.get_system_word_in_note2(note, string)
  210.     str = ""
  211.     if note.include?(string)
  212.       # 最後に指定のシステムワードが書かれた場所以降の文字列を取得
  213.       words_loc = note.rindex(string) + string.size # 文字位置取得
  214.       # 文字列取得
  215.       new_words = note[words_loc, note.length - 1]
  216.       # 数字文字列を取得(文字位置によって処理が異なる)
  217.       param = new_words.split(/s*,s*/)
  218.       for i in 0...param.size
  219.         numeric = param[i].to_i
  220.         if numeric > 0
  221.           str += param[i] + ","
  222.         else
  223.           break
  224.         end
  225.       end
  226.       str = string + str
  227.     end
  228.     return str
  229.   end
  230. end

  231. #==============================================================================
  232. # ● RPG::BaseItem
  233. #------------------------------------------------------------------------------
  234. #  スキル、アイテム、武器、防具のスーパークラスです。
  235. #==============================================================================

  236. module RPG
  237.   class BaseItem
  238.     @@rx_copy_str = ""  #コピー用変数
  239.     alias rx_rgss_rxsys_initialize initialize
  240.     def initialize
  241.       rx_rgss_rxsys_initialize
  242.       # ★ システムワード用文字列変数(メモから抽出)
  243.       @rx_sys_str = ""
  244.     end
  245.     #--------------------------------------------------------------------------
  246.     # ★ メモ(システムワードが空ならメモから抽出)
  247.     #--------------------------------------------------------------------------
  248.     def note
  249.       rx_extract_sys_str_from_note if @rx_sys_str == "" or @rx_sys_str == nil
  250.       return @note
  251.     end
  252.     #--------------------------------------------------------------------------
  253.     # ★ システム用文字列変数(システムワードが空ならメモから抽出)
  254.     #--------------------------------------------------------------------------
  255.     def rx_sys_str
  256.       rx_extract_sys_str_from_note if @rx_sys_str == "" or @rx_sys_str == nil
  257.       return @rx_sys_str
  258.     end
  259.     #--------------------------------------------------------------------------
  260.     # ★ メモからシステム用文字列を排除したものをメモとして返す
  261.     #--------------------------------------------------------------------------
  262.     def rx_extract_sys_str_from_note
  263.       rx_copy_str = @@rx_copy_str
  264.       @@rx_copy_str = ""
  265.       return rx_copy_str
  266.     end
  267.   end
  268. end

  269. #==============================================================================
  270. # ● RPG::Actor
  271. #------------------------------------------------------------------------------
  272. #  アクターのデータクラスです。
  273. #==============================================================================
  274. module RPG
  275.   class Actor
  276.     alias rx_rgss_rxsys_initialize initialize
  277.     def initialize
  278.       rx_rgss_rxsys_initialize
  279.       @rx_sys_str = ""
  280.     end
  281.     #--------------------------------------------------------------------------
  282.     # ★ システム用文字列変数
  283.     #--------------------------------------------------------------------------
  284.     def rx_sys_str
  285.       return @rx_sys_str
  286.     end
  287.     #--------------------------------------------------------------------------
  288.     # ★ システム用文字列変数
  289.     #--------------------------------------------------------------------------
  290.     def rx_sys_str=(str)
  291.       @rx_sys_str = str
  292.     end
  293.   end
  294. end


  295. #==============================================================================
  296. # ● RPG::Class
  297. #------------------------------------------------------------------------------
  298. #  職業のデータクラスです。
  299. #==============================================================================
  300. module RPG
  301.   class Class
  302.     alias rx_rgss_rxsys_initialize initialize
  303.     def initialize
  304.       rx_rgss_rxsys_initialize
  305.       @rx_sys_str = ""
  306.     end
  307.     #--------------------------------------------------------------------------
  308.     # ★ システム用文字列変数
  309.     #--------------------------------------------------------------------------
  310.     def rx_sys_str
  311.       return @rx_sys_str
  312.     end
  313.     #--------------------------------------------------------------------------
  314.     # ★ システム用文字列変数
  315.     #--------------------------------------------------------------------------
  316.     def rx_sys_str=(str)
  317.       @rx_sys_str = str
  318.     end
  319.   end
  320. end

  321. #==============================================================================
  322. # ● RPG::Troop
  323. #------------------------------------------------------------------------------
  324. #  敵グループのデータクラスです。
  325. #==============================================================================
  326. module RPG
  327.   class Troop
  328.     alias rx_rgss_rxsys_initialize initialize
  329.     def initialize
  330.       rx_rgss_rxsys_initialize
  331.       @rx_sys_str = ""
  332.     end
  333.     #--------------------------------------------------------------------------
  334.     # ★ システム用文字列変数
  335.     #--------------------------------------------------------------------------
  336.     def rx_sys_str
  337.       return @rx_sys_str
  338.     end
  339.     #--------------------------------------------------------------------------
  340.     # ★ システム用文字列変数
  341.     #--------------------------------------------------------------------------
  342.     def rx_sys_str=(str)
  343.       @rx_sys_str = str
  344.     end
  345.   end
  346. end

  347. #==============================================================================
  348. # ● RPG::Enemy
  349. #------------------------------------------------------------------------------
  350. #  敵キャラのデータクラスです。
  351. #==============================================================================

  352. module RPG
  353.   class Enemy
  354.     @@rx_copy_str = ""  #コピー用変数
  355.     alias rx_rgss_rxsys_initialize initialize
  356.     def initialize
  357.       rx_rgss_rxsys_initialize
  358.       # ★ システムワード用文字列変数(メモから抽出)
  359.       @rx_sys_str = ""
  360.     end
  361.     #--------------------------------------------------------------------------
  362.     # ★ メモ(システムワードが空ならメモから抽出)
  363.     #--------------------------------------------------------------------------
  364.     def note
  365.       rx_extract_sys_str_from_note if @rx_sys_str == "" or @rx_sys_str == nil
  366.       return @note
  367.     end
  368.     #--------------------------------------------------------------------------
  369.     # ★ システム用文字列変数(システムワードが空ならメモから抽出)
  370.     #--------------------------------------------------------------------------
  371.     def rx_sys_str
  372.       rx_extract_sys_str_from_note if @rx_sys_str == "" or @rx_sys_str == nil
  373.       return @rx_sys_str
  374.     end
  375.     #--------------------------------------------------------------------------
  376.     # ★ メモからシステム用文字列を排除したものをメモとして返す
  377.     #--------------------------------------------------------------------------
  378.     def rx_extract_sys_str_from_note
  379.       rx_copy_str = @@rx_copy_str
  380.       @@rx_copy_str = ""
  381.       return rx_copy_str
  382.     end
  383.   end
  384. end

  385. #==============================================================================
  386. # ● RPG::State
  387. #------------------------------------------------------------------------------
  388. #  敵キャラのデータクラスです。
  389. #==============================================================================

  390. module RPG
  391.   class State
  392.     @@rx_copy_str = ""  #コピー用変数
  393.     alias rx_rgss_rxsys_initialize initialize
  394.     def initialize
  395.       rx_rgss_rxsys_initialize
  396.       # ★ システムワード用文字列変数(メモから抽出)
  397.       @rx_sys_str = ""
  398.     end
  399.     #--------------------------------------------------------------------------
  400.     # ★ メモ(システムワードが空ならメモから抽出)
  401.     #--------------------------------------------------------------------------
  402.     def note
  403.       rx_extract_sys_str_from_note if @rx_sys_str == "" or @rx_sys_str == nil
  404.       return @note
  405.     end
  406.     #--------------------------------------------------------------------------
  407.     # ★ システム用文字列変数(システムワードが空ならメモから抽出)
  408.     #--------------------------------------------------------------------------
  409.     def rx_sys_str
  410.       rx_extract_sys_str_from_note if @rx_sys_str == "" or @rx_sys_str == nil
  411.       return @rx_sys_str
  412.     end
  413.     #--------------------------------------------------------------------------
  414.     # ★ メモからシステム用文字列を排除したものをメモとして返す
  415.     #--------------------------------------------------------------------------
  416.     def rx_extract_sys_str_from_note
  417.       rx_copy_str = @@rx_copy_str
  418.       @@rx_copy_str = ""
  419.       return rx_copy_str
  420.     end
  421.   end
  422. end

  423. #==============================================================================
  424. # ■ Game_Battler
  425. #------------------------------------------------------------------------------
  426. #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ
  427. # スのスーパークラスとして使用されます。
  428. #==============================================================================

  429. class Game_Battler
  430.   #--------------------------------------------------------------------------
  431.   # ● オブジェクト初期化
  432.   #--------------------------------------------------------------------------
  433.   alias rx_rgss2bs1_initialize initialize
  434.   def initialize
  435.     # メソッドを呼び戻す
  436.     rx_rgss2bs1_initialize
  437.     @rx_magic_use = false  # ★ 魔法使用フラグ
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ★ 魔法使用フラグ
  441.   #--------------------------------------------------------------------------
  442.   def rx_magic_use
  443.     return @rx_magic_use
  444.   end
  445.   #--------------------------------------------------------------------------
  446.   # ★ 魔法使用フラグの操作
  447.   #--------------------------------------------------------------------------
  448.   def rx_magic_use=(use)
  449.     @rx_magic_use = use
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ★ 武器を持っているかの判定
  453.   #--------------------------------------------------------------------------
  454.   def rx_weapon_equip?
  455.     return false unless self.actor?
  456.     return (self.weapon_id > 0 or (self.two_swords_style and self.armor1_id > 0))
  457.   end
  458.   #--------------------------------------------------------------------------
  459.   # ★ 武器で攻撃しているかの判定
  460.   #--------------------------------------------------------------------------
  461.   def rx_weapon_attack?
  462.     return false unless rx_weapon_equip?
  463.     return self.action.attack?
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ★ 装備しているものに含まれているシステムワードを取得
  467.   #--------------------------------------------------------------------------
  468.   def rx_sys_str
  469.     return ""
  470.   end
  471. end

  472. #==============================================================================
  473. # ■ Game_Actor
  474. #------------------------------------------------------------------------------
  475. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  476. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  477. #==============================================================================

  478. class Game_Actor < Game_Battler
  479.   #--------------------------------------------------------------------------
  480.   # ● セットアップ
  481.   #     actor_id : アクター ID
  482.   #--------------------------------------------------------------------------
  483.   alias rx_rgss2bs1_setup setup
  484.   def setup(actor_id)
  485.     # メソッドを呼び戻す
  486.     rx_rgss2bs1_setup(actor_id)
  487.     # ★ 職業のシステムワードを初期化
  488.     format_class_rx_sys_str
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ★ 職業のシステムワードを初期化
  492.   #--------------------------------------------------------------------------
  493.   def format_class_rx_sys_str
  494.     self.class.rx_sys_str = "" if self.class.rx_sys_str == nil
  495.   end
  496.   #--------------------------------------------------------------------------
  497.   # ★ 装備しているものに含まれているシステムワードを取得
  498.   #--------------------------------------------------------------------------
  499.   def rx_sys_str
  500.     sys_str = ""
  501.     sys_str += $data_weapons[@weapon_id].rx_sys_str if @weapon_id > 0
  502.     if self.two_swords_style
  503.       sys_str += $data_weapons[@armor1_id].rx_sys_str if @armor1_id > 0
  504.     else
  505.       sys_str += $data_armors[@armor1_id].rx_sys_str if @armor1_id > 0
  506.     end
  507.     sys_str += $data_armors[@armor2_id].rx_sys_str if @armor2_id > 0
  508.     sys_str += $data_armors[@armor3_id].rx_sys_str if @armor3_id > 0
  509.     sys_str += $data_armors[@armor4_id].rx_sys_str if @armor4_id > 0
  510.     return sys_str
  511.   end
  512. end

  513. #==============================================================================
  514. # ■ Game_Enemy
  515. #------------------------------------------------------------------------------
  516. #  敵キャラを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の
  517. # 内部で使用されます。
  518. #==============================================================================

  519. class Game_Enemy < Game_Battler
  520.   #--------------------------------------------------------------------------
  521.   # ★ 装備しているものに含まれているシステムワードを取得
  522.   #--------------------------------------------------------------------------
  523.   def rx_sys_str
  524.     return ""
  525.   end
  526. end

  527. #==============================================================================
  528. # ■ Game_BattleAction
  529. #------------------------------------------------------------------------------
  530. #  戦闘行動を扱うクラスです。このクラスは Game_Battler クラスの内部で使用され
  531. # ます。
  532. #==============================================================================

  533. class Game_BattleAction
  534.   #--------------------------------------------------------------------------
  535.   # ★ 魔法(精神関係度 1 以上)を使っているかの判定
  536.   #--------------------------------------------------------------------------
  537.   def rx_magic_use?
  538.     return (skill? and $data_skills[@skill_id].spi_f >= 1)
  539.   end
  540. end
复制代码
第八个:
  1. #
  2. #    プラグイン式ダメージ特殊効果用ベーススクリプトVer1.05(RGSS2)
  3. #  (C)2007-2008 TYPE74RX-T
  4. #

  5. # ※:特殊効果判定用ベーススクリプトを先に導入してください。

  6. #==============================================================================
  7. # ■ Game_Battler
  8. #------------------------------------------------------------------------------
  9. #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ
  10. # スのスーパークラスとして使用されます。
  11. #==============================================================================

  12. class Game_Battler
  13.   #--------------------------------------------------------------------------
  14.   # ★ スキルまたはアイテムに付加されている拡張システムフラグの取得
  15.   #     obj  : スキルまたはアイテム
  16.   #--------------------------------------------------------------------------
  17.   def rx_set_system_flag(obj)
  18.     @damage2 = 0
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ★ 装備物に付加されている拡張システムフラグの取得
  22.   #     sys_str  : システムワード
  23.   #--------------------------------------------------------------------------
  24.   def rx_set_equip_sys_flag(sys_str)
  25.     @damage2 = 0
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ★ 装備物に付加されている拡張システムフラグの取得(スキル使用時)
  29.   #    (Ver1.05より追加)
  30.   #     user  : 使用者
  31.   #--------------------------------------------------------------------------
  32.   def rx_set_equip_sys_flag_user(user)
  33.    
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ★ 特殊ダメージフラグ群をセット
  37.   #--------------------------------------------------------------------------
  38.   def rx_set_special_damage_flag
  39.     @rx_special_damage_flags = []
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ★ 特殊ダメージ計算(武器攻撃)
  43.   #     attacker : 武器の使用者
  44.   #--------------------------------------------------------------------------
  45.   def rx_weapon_damage_calculation(attacker)
  46.     damage = attacker.atk * 4 - self.def * 2        # 基本計算(物理攻撃)
  47.     return damage
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ★ 特殊ダメージ計算
  51.   #     user : スキル、アイテムの使用者
  52.   #     obj  : スキル、アイテム
  53.   #--------------------------------------------------------------------------
  54.   def rx_damage_calculation(user, obj)
  55.     # 通常ダメージ計算フラグをON
  56.     @rx_normal_damage = true
  57.     # デフォルトのダメージ計算式
  58.     damage = obj.base_damage                        # 基本ダメージを取得
  59.     if damage > 0                                   # ダメージが正の数
  60.       damage += user.atk * 4 * obj.atk_f / 100      # 打撃関係度: 使用者
  61.       damage += user.spi * 2 * obj.spi_f / 100      # 精神関係度: 使用者
  62.       unless obj.ignore_defense                     # 防御力無視以外
  63.         damage -= self.def * 2 * obj.atk_f / 100    # 打撃関係度: 対象者
  64.         damage -= self.spi * 1 * obj.spi_f / 100    # 精神関係度: 対象者
  65.       end
  66.       damage = 0 if damage < 0                      # マイナスなら 0 に
  67.     elsif damage < 0                                # ダメージが負の数
  68.       damage -= user.atk * 4 * obj.atk_f / 100      # 打撃関係度: 使用者
  69.       damage -= user.spi * 2 * obj.spi_f / 100      # 精神関係度: 使用者
  70.     end
  71.     return damage
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ★ スキルまたはアイテムによる特殊ダメージ計算
  75.   #     user : スキルまたはアイテムの使用者
  76.   #     obj  : スキルまたはアイテム
  77.   #    結果は @hp_damage または @mp_damage(場合によっては両方)に代入する。
  78.   #--------------------------------------------------------------------------
  79.   def rx_special_damage(user, obj)
  80.     @rx_attack_element_flag = false         # 武器属性依存フラグの初期化
  81.     @rx_attack_element_mix = false          # 武器属性含有フラグの初期化
  82.     @rx_mix_element_set = []                # 武器属性+スキル属性
  83.     @rx_normal_damage = false               # 通常ダメージ計算フラグの初期化
  84.     # 武器属性とスキル属性を合成
  85.     @rx_mix_element_set.concat(user.element_set) if user.actor?
  86.     @rx_mix_element_set.concat(obj.element_set)
  87.     # 被ってる要素があれば、それを1つにする
  88.     @rx_mix_element_set = @rx_mix_element_set.uniq
  89.     damage_flag_count = 0
  90.     # 各種システムワードフラグのチェック(装備武器用)
  91.     rx_set_equip_sys_flag_user(user) if user.actor?
  92.     # 各種システムワードフラグのチェック(スキル用)
  93.     rx_set_system_flag(obj)
  94.     rx_set_special_damage_flag              # 特殊ダメージフラグ群をセット
  95.     damage = rx_damage_calculation(user, obj)       # 特殊ダメージ計算
  96.     if damage > 0 and not @rx_normal_damage
  97.       unless obj.ignore_defense                     # 防御力無視以外
  98.         damage -= self.def * 2 * obj.atk_f / 100    # 打撃関係度: 対象者
  99.         damage -= self.spi * 1 * obj.spi_f / 100    # 精神関係度: 対象者
  100.       end
  101.       damage = 0 if damage < 0                      # マイナスなら 0 に
  102.     end
  103.     # 武器属性依存なら(アクター限定)
  104.     if @rx_attack_element_flag and user.actor?
  105.       damage *= elements_max_rate(user.element_set)     # 属性修正(武器側)
  106.     # 武器属性とスキル属性を合成したスキルなら(アクター限定)
  107.     elsif @rx_attack_element_mix and user.actor?
  108.       damage *= elements_max_rate(@rx_mix_element_set)  # 属性修正(武器+スキル)
  109.     else
  110.       damage *= elements_max_rate(obj.element_set)      # 属性修正(スキル側)
  111.     end
  112.     damage /= 100
  113.     damage = apply_variance(damage, obj.variance)   # 分散
  114.     damage = apply_guard(damage)                    # 防御修正
  115.     if obj.damage_to_mp  
  116.       @mp_damage = damage                           # MP にダメージ
  117.     else
  118.       @hp_damage = damage                           # HP にダメージ
  119.     end
  120.     # HPMPダメージの効果があれば HP と MP の両方にダメージ
  121.     if @rx_hpmp_damage != nil
  122.       if @rx_hpmp_damage
  123.         @hp_damage = damage                         # HP にダメージ
  124.         if @damage2 != 0
  125.           @mp_damage = @damage2                     # MP にダメージ
  126.         else
  127.           @mp_damage = damage                       # MP にダメージ
  128.         end
  129.       end
  130.     end
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ★ 通常攻撃による特殊ダメージ計算
  134.   #     attacker : 攻撃者
  135.   #    結果は @hp_damage に代入する。
  136.   #--------------------------------------------------------------------------
  137.   def rx_special_damage_weapon(attacker)
  138.     rx_set_equip_sys_flag(attacker.rx_sys_str) # 各種システムワードフラグのチェック
  139.     damage = rx_weapon_damage_calculation(attacker) # 特殊ダメージ計算
  140.     damage = 0 if damage < 0                        # マイナスなら 0 に
  141.     damage *= elements_max_rate(attacker.element_set)   # 属性修正
  142.     damage /= 100
  143.     if damage == 0                                  # ダメージが 0
  144.       damage = rand(2)                              # 1/2 の確率で 1 ダメージ
  145.     elsif damage > 0                                # ダメージが正の数
  146.       @critical = (rand(100) < attacker.cri)        # クリティカル判定
  147.       @critical = false if prevent_critical         # クリティカル防止?
  148.       damage *= 3 if @critical                      # クリティカル修正
  149.     end
  150.     damage = apply_variance(damage, 20)             # 分散
  151.     damage = apply_guard(damage)                    # 防御修正
  152.     @hp_damage = damage                             # HP にダメージ
  153.     #------------------------------------------------------------------------
  154.     # ★ 「MPダメージ」スクリプト、「ダメージ吸収」スクリプトに対応
  155.     #------------------------------------------------------------------------
  156.     # 攻撃者がアクターで武器を持っていれば
  157.     if attacker.actor? and attacker.weapon_id > 0
  158.       # システムワードに「MPダメージ」が含まれていれば
  159.       if RX_T.check_system_word_in_equip(attacker.rx_sys_str, "MPダメージ")
  160.         @mp_damage = @hp_damage                      # MP にダメージ
  161.       end
  162.       # システムワードに「ダメージ吸収」が含まれていれば
  163.       if RX_T.check_system_word_in_sys_str($data_weapons[attacker.weapon_id], "ダメージ吸収")
  164.         # 吸収効果の計算処理へ
  165.         rx_make_attack_absorb_effect(attacker)
  166.       end
  167.     end
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ● 通常攻撃によるダメージ計算
  171.   #     attacker : 攻撃者
  172.   #    結果は @hp_damage に代入する。
  173.   #--------------------------------------------------------------------------
  174.   alias rx_rgss2spc_make_attack_damage_value make_attack_damage_value
  175.   def make_attack_damage_value(attacker)
  176.     # ★ システムワードに「RX-SYS」が入っていれば
  177.     if attacker.actor? and
  178.       RX_T.check_system_word_in_equip(attacker.rx_sys_str, "RX-SYS")
  179.       # 特殊ダメージ処理へ
  180.       rx_special_damage_weapon(attacker)
  181.       # メソッド終了
  182.       return
  183.     end
  184.     # メソッドを呼び戻す
  185.     rx_rgss2spc_make_attack_damage_value(attacker)
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● スキルまたはアイテムによるダメージ計算
  189.   #     user : スキルまたはアイテムの使用者
  190.   #     obj  : スキルまたはアイテム
  191.   #    結果は @hp_damage または @mp_damage に代入する。
  192.   #--------------------------------------------------------------------------
  193.   alias rx_rgss2spc_make_obj_damage_value make_obj_damage_value
  194.   def make_obj_damage_value(user, obj)
  195.     # ★ 装備物のシステムワードに「RX-SYS」が入っているかのフラグ(Ver1.05より追加)
  196.     rx_sys_equip = RX_T.check_system_word_in_equip(user.rx_sys_str, "RX-SYS") and user.actor?
  197.     # ★ スキルまたは装備物のシステムワードに「RX-SYS」が入っていれば(Ver1.05より更新)
  198.     if RX_T.check_system_word_in_sys_str(obj, "RX-SYS") or rx_sys_equip
  199.       # 特殊ダメージ処理へ
  200.       rx_special_damage(user, obj)
  201.       # メソッド終了
  202.       return
  203.     end
  204.     # メソッドを呼び戻す
  205.     rx_rgss2spc_make_obj_damage_value(user, obj)
  206.   end
  207. end
复制代码
第九个:
  1. #==============================================================================
  2. # ■ Game_Party
  3. #------------------------------------------------------------------------------
  4. #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
  5. # ラスのインスタンスは $game_party で参照されます。
  6. #==============================================================================

  7. class Game_Party < Game_Unit
  8.   #--------------------------------------------------------------------------
  9.   # ● ボックス内のアイテムの所持判定
  10.   #     item          : ボックス内のアイテム
  11.   #
  12.   #--------------------------------------------------------------------------
  13.   def keeping_has_item?(item)
  14.     if keeping_item_number(item) > 0
  15.       return true
  16.     end
  17.     return false
  18.   end
  19. end
复制代码
第十个:
  1. #
  2. #    特定アイテムの所持数を制限(RGSS2)
  3. #  (C)2008 TYPE74RX-T
  4. #

  5. #--------------------------------------------------------------------------
  6. # ★ システムワードの登録:所持可能数
  7. #--------------------------------------------------------------------------
  8. module RPG
  9.   class BaseItem
  10.     alias rx_rgss2s5_rx_extract_sys_str_from_note rx_extract_sys_str_from_note
  11.     def rx_extract_sys_str_from_note
  12.       rx_get_sys = RX_T.get_system_word_in_note(@note, "所持可能数", true)
  13.       @@rx_copy_str += rx_get_sys
  14.       @note = @note.sub(rx_get_sys, "")
  15.       @note = @note.sub("\r\n", "")
  16.       @rx_sys_str = @@rx_copy_str
  17.       # メソッドを呼び戻す
  18.       rx_rgss2s5_rx_extract_sys_str_from_note
  19.     end
  20.   end
  21. end

  22. #==============================================================================
  23. # ■ Game_Party
  24. #------------------------------------------------------------------------------
  25. #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
  26. # ラスのインスタンスは $game_party で参照されます。
  27. #==============================================================================

  28. class Game_Party < Game_Unit
  29.   #--------------------------------------------------------------------------
  30.   # ● アイテムの増加 (減少)
  31.   #     item          : アイテム
  32.   #     n             : 個数
  33.   #     include_equip : 装備品も含める
  34.   #--------------------------------------------------------------------------
  35.   alias rx_rgss2s5_gain_item gain_item
  36.   def gain_item(item, n, include_equip = true)
  37.     # ★ 所持可能数が決まっていれば専用の処理をする
  38.     rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(item, "所持可能数")
  39.     return rx_limit_gain_item(item, n, rx_limit, include_equip) if rx_limit > 0
  40.     # メソッドを呼び戻す
  41.     rx_rgss2s5_gain_item(item, n, include_equip)
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ★ 所持数制限式アイテムの増加 (減少)
  45.   #     item          : アイテム
  46.   #     n             : 個数
  47.   #     include_equip : 装備品も含める
  48.   #--------------------------------------------------------------------------
  49.   def rx_limit_gain_item(item, n, limit, include_equip = true)
  50.     number = item_number(item)
  51.     case item
  52.     when RPG::Item
  53.       @items[item.id] = [[number + n, 0].max, limit].min
  54.     when RPG::Weapon
  55.       @weapons[item.id] = [[number + n, 0].max, limit].min
  56.     when RPG::Armor
  57.       @armors[item.id] = [[number + n, 0].max, limit].min
  58.     end
  59.     n += number
  60.     if include_equip and n < 0
  61.       for actor in members
  62.         while n < 0 and actor.equips.include?(item)
  63.           actor.discard_equip(item)
  64.           n += 1
  65.         end
  66.       end
  67.     end
  68.   end
  69. end

  70. #==============================================================================
  71. # ■ Window_ShopBuy
  72. #------------------------------------------------------------------------------
  73. #  ショップ画面で、購入できる商品の一覧を表示するウィンドウです。
  74. #==============================================================================

  75. class Window_ShopBuy < Window_Selectable
  76.   #--------------------------------------------------------------------------
  77.   # ● 項目の描画
  78.   #     index : 項目番号
  79.   #--------------------------------------------------------------------------
  80.   alias rx_rgss2s5_draw_item draw_item
  81.   def draw_item(index)
  82.     # ★ 所持可能数が決まっていれば専用の処理をする
  83.     rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(@data[index], "所持可能数")
  84.     return rx_limit_draw_item(index, rx_limit) if rx_limit > 0
  85.     # メソッドを呼び戻す
  86.     rx_rgss2s5_draw_item(index)
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ★ 項目の描画(所持数制限式)
  90.   #     index : 項目番号
  91.   #--------------------------------------------------------------------------
  92.   def rx_limit_draw_item(index, limit)
  93.     item = @data[index]
  94.     number = $game_party.item_number(item)
  95.     enabled = (item.price <= $game_party.gold and number < limit)
  96.     rect = item_rect(index)
  97.     self.contents.clear_rect(rect)
  98.     draw_item_name(item, rect.x, rect.y, enabled)
  99.     rect.width -= 4
  100.     self.contents.draw_text(rect, item.price, 2)
  101.   end
  102. end

  103. #==============================================================================
  104. # ■ Scene_Shop
  105. #------------------------------------------------------------------------------
  106. #  ショップ画面の処理を行うクラスです。
  107. #==============================================================================

  108. class Scene_Shop < Scene_Base
  109.   #--------------------------------------------------------------------------
  110.   # ● 購入アイテム選択の更新
  111.   #--------------------------------------------------------------------------
  112.   alias rx_rgss2s5_update_buy_selection update_buy_selection
  113.   def update_buy_selection
  114.     # ★ 所持可能数が決まっていれば専用の処理をする
  115.     rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(@buy_window.item, "所持可能数")
  116.     return rx_limit_update_buy_selection(rx_limit) if rx_limit > 0
  117.     # メソッドを呼び戻す
  118.     rx_rgss2s5_update_buy_selection
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ★ 購入アイテム選択の更新(所持数制限式)
  122.   #--------------------------------------------------------------------------
  123.   def rx_limit_update_buy_selection(limit)
  124.     @status_window.item = @buy_window.item
  125.     if Input.trigger?(Input::B)
  126.       Sound.play_cancel
  127.       @command_window.active = true
  128.       @dummy_window.visible = true
  129.       @buy_window.active = false
  130.       @buy_window.visible = false
  131.       @status_window.visible = false
  132.       @status_window.item = nil
  133.       @help_window.set_text("")
  134.       return
  135.     end
  136.     if Input.trigger?(Input::C)
  137.       @item = @buy_window.item
  138.       number = $game_party.item_number(@item)
  139.       if @item == nil or @item.price > $game_party.gold or number == limit
  140.         Sound.play_buzzer
  141.       else
  142.         Sound.play_decision
  143.         max = @item.price == 0 ? limit : $game_party.gold / @item.price
  144.         max = [max, limit - number].min
  145.         @buy_window.active = false
  146.         @buy_window.visible = false
  147.         @number_window.set(@item, max, @item.price)
  148.         @number_window.active = true
  149.         @number_window.visible = true
  150.       end
  151.     end
  152.   end
  153. end
复制代码
第十一个:
  1. #--------------------------------------------------------------------------
  2. #☆カスタムスクリプト
  3. #--------------------------------------------------------------------------
  4. #
  5. #    ダッシュ禁止の変更(RGSS2)
  6. #  (C)2008 TYPE74RX-T
  7. #    イベントのスクリプトから設定できるように改造

  8. #==============================================================================
  9. # ■ Game_Map
  10. #------------------------------------------------------------------------------
  11. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  12. # このクラスのインスタンスは $game_map で参照されます。
  13. #==============================================================================

  14. class Game_Map
  15.   #--------------------------------------------------------------------------
  16.   # ★ ダッシュ許可
  17.   #--------------------------------------------------------------------------
  18.   def rx_enable_dash
  19.     @map.disable_dashing = false
  20.     # ダッシュを許可する
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ★ ダッシュ禁止
  24.   #--------------------------------------------------------------------------
  25.   def rx_disable_dash
  26.     @map.disable_dashing = true
  27.     # ダッシュ禁止にする
  28.   end
  29. end
  30. =begin
  31. #==============================================================================
  32. # ■ 使い方
  33. #------------------------------------------------------------------------------
  34. #  イベントコマンドのスクリプトでダッシュ禁止、ダッシュ許可の変更ができます。
  35. #
  36. #==============================================================================
  37. ★ダッシュを許可したいとき。
  38. ダッシュを許可したいところでイベントコマンドのスクリプトに・・・・

  39. $game_map.rx_enable_dash #ダッシュの許可

  40. と、一行書き込むだけでダッシュが許可されます。


  41. ★ダッシュを禁止したいとき。

  42. $game_map.rx_disable_dash #ダッシュの禁止

  43. と、スクリプトに書き込むだけでダッシュが禁止されます。
  44. =end
复制代码
第十二个:
  1. #===============================================================================
  2. #◆のびハザ自律移動カスタマイズスクリプト-by57-
  3. #
  4. #再定義しているのでなるべく素材の上の方に導入することをお勧めします。
  5. #同じ個所を再定義しているスクリプトを新たに導入すると競合する恐れがあります。
  6. #===============================================================================#==============================================================================
  7. # ■ Game_Party
  8. #------------------------------------------------------------------------------
  9. #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
  10. # ラスのインスタンスは $game_party で参照されます。
  11. #==============================================================================
  12. class Game_Player
  13.   #--------------------------------------------------------------------------
  14.   # ● 公開インスタンス変数
  15.   #--------------------------------------------------------------------------
  16.   attr_accessor :dash_speed         # ダッシュスピード(追加)
  17.   attr_accessor :move_times         # 全キャラクター移動速度倍率(追加)
  18.   #--------------------------------------------------------------------------
  19.   # ● オブジェクト初期化
  20.   #--------------------------------------------------------------------------
  21.   alias nobihazard_57_script initialize
  22.   def initialize
  23.     super
  24.     nobihazard_57_script
  25.     @dash_speed = 1.6               # ダッシュが歩行速度の何倍?(追加)
  26.     @move_times = 1                 # 全キャラクター移動速度倍率
  27.   end
  28. end
  29. #==============================================================================
  30. # ■ Game_Character(再定義)
  31. #------------------------------------------------------------------------------
  32. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  33. # クラスのスーパークラスとして使用されます。
  34. #==============================================================================
  35. class Game_Character
  36.   #--------------------------------------------------------------------------
  37.   # ● 公開インスタンス変数
  38.   #--------------------------------------------------------------------------
  39.   attr_reader   :id                       # ID
  40.   attr_reader   :x                        # マップ X 座標 (論理座標)
  41.   attr_reader   :y                        # マップ Y 座標 (論理座標)
  42.   attr_reader   :real_x                   # マップ X 座標 (実座標 * 256)
  43.   attr_reader   :real_y                   # マップ Y 座標 (実座標 * 256)
  44.   attr_reader   :tile_id                  # タイル ID  (0 なら無効)
  45.   attr_reader   :character_name           # 歩行グラフィック ファイル名
  46.   attr_reader   :character_index          # 歩行グラフィック インデックス
  47.   attr_reader   :opacity                  # 不透明度
  48.   attr_reader   :blend_type               # 合成方法
  49.   attr_reader   :direction                # 向き
  50.   attr_reader   :pattern                  # パターン
  51.   attr_reader   :move_route_forcing       # 移動ルート強制フラグ
  52.   attr_reader   :priority_type            # プライオリティタイプ
  53.   attr_reader   :through                  # すり抜け
  54.   attr_reader   :bush_depth               # 茂み深さ
  55.   attr_accessor :animation_id             # アニメーション ID
  56.   attr_accessor :balloon_id               # フキダシアイコン ID
  57.   attr_accessor :transparent              # 透明状態
  58.   #--------------------------------------------------------------------------
  59.   # ● オブジェクト初期化
  60.   #--------------------------------------------------------------------------
  61.   def initialize
  62.     @id = 0
  63.     @x = 0
  64.     @y = 0
  65.     @real_x = 0
  66.     @real_y = 0
  67.     @tile_id = 0
  68.     @character_name = ""
  69.     @character_index = 0
  70.     @opacity = 255
  71.     @blend_type = 0
  72.     @direction = 2
  73.     @pattern = 1
  74.     @move_route_forcing = false
  75.     @priority_type = 1
  76.     @through = false
  77.     @bush_depth = 0
  78.     @animation_id = 0
  79.     @balloon_id = 0
  80.     @transparent = false
  81.     @original_direction = 2               # 元の向き
  82.     @original_pattern = 1                 # 元のパターン
  83.     @move_type = 0                        # 移動タイプ
  84.     @move_speed = 4                       # 移動速度
  85.     @move_frequency = 6                   # 移動頻度
  86.     @move_route = nil                     # 移動ルート
  87.     @move_route_index = 0                 # 移動ルートの実行位置
  88.     @original_move_route = nil            # 元の移動ルート
  89.     @original_move_route_index = 0        # 元の移動ルートの実行位置
  90.     @walk_anime = true                    # 歩行アニメ
  91.     @step_anime = false                   # 足踏みアニメ
  92.     @direction_fix = false                # 向き固定
  93.     @anime_count = 0                      # アニメカウント
  94.     @stop_count = 0                       # 停止カウント
  95.     @jump_count = 0                       # ジャンプカウント
  96.     @jump_peak = 0                        # ジャンプの頂点のカウント
  97.     @wait_count = 0                       # ウェイトカウント
  98.     @locked = false                       # ロックフラグ
  99.     @prelock_direction = 0                # ロック前の向き
  100.     @move_failed = false                  # 移動失敗フラグ
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 移動中判定
  104.   #--------------------------------------------------------------------------
  105.   def moving?
  106.     return (@real_x != @x * 256 or @real_y != @y * 256)   # 論理座標と比較
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● ジャンプ中判定
  110.   #--------------------------------------------------------------------------
  111.   def jumping?
  112.     return @jump_count > 0
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 停止中判定
  116.   #--------------------------------------------------------------------------
  117.   def stopping?
  118.     return (not (moving? or jumping?))
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● ダッシュ状態判定
  122.   #--------------------------------------------------------------------------
  123.   def dash?
  124.     return false
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● デバッグすり抜け状態判定
  128.   #--------------------------------------------------------------------------
  129.   def debug_through?
  130.     return false
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 姿勢の矯正
  134.   #--------------------------------------------------------------------------
  135.   def straighten
  136.     @pattern = 1 if @walk_anime or @step_anime
  137.     @anime_count = 0
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 移動ルートの強制
  141.   #     move_route : 新しい移動ルート
  142.   #--------------------------------------------------------------------------
  143.   def force_move_route(move_route)
  144.     if @original_move_route == nil
  145.       @original_move_route = @move_route
  146.       @original_move_route_index = @move_route_index
  147.     end
  148.     @move_route = move_route
  149.     @move_route_index = 0
  150.     @move_route_forcing = true
  151.     @prelock_direction = 0
  152.     @wait_count = 0
  153.     move_type_custom
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 座標一致判定
  157.   #     x : X 座標
  158.   #     y : Y 座標
  159.   #--------------------------------------------------------------------------
  160.   def pos?(x, y)
  161.     return (@x == x and @y == y)
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● 座標一致と「すり抜け OFF」判定 (nt = No Through)
  165.   #     x : X 座標
  166.   #     y : Y 座標
  167.   #--------------------------------------------------------------------------
  168.   def pos_nt?(x, y)
  169.     return (pos?(x, y) and not @through)
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 通行可能判定
  173.   #     x : X 座標
  174.   #     y : Y 座標
  175.   #--------------------------------------------------------------------------
  176.   def passable?(x, y)
  177.     x = $game_map.round_x(x)                        # 横方向ループ補正
  178.     y = $game_map.round_y(y)                        # 縦方向ループ補正
  179.     return false unless $game_map.valid?(x, y)      # マップ外?
  180.     return true if @through or debug_through?       # すり抜け ON?
  181.     return false unless map_passable?(x, y)         # マップが通行不能?
  182.     return false if collide_with_characters?(x, y)  # キャラクターに衝突?
  183.     return true                                     # 通行可
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● マップ通行可能判定
  187.   #     x : X 座標
  188.   #     y : Y 座標
  189.   #    指定された座標のタイルが通行可能かを取得する。
  190.   #--------------------------------------------------------------------------
  191.   def map_passable?(x, y)
  192.     return $game_map.passable?(x, y)
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● キャラクター衝突判定
  196.   #     x : X 座標
  197.   #     y : Y 座標
  198.   #    プレイヤーと乗り物を含め、通常キャラの衝突を検出する。
  199.   #--------------------------------------------------------------------------
  200.   def collide_with_characters?(x, y)
  201.     for event in $game_map.events_xy(x, y)          # イベントの座標と一致
  202.       unless event.through                          # すり抜け OFF?
  203.         return true if self.is_a?(Game_Event)       # 自分がイベント
  204.         return true if event.priority_type == 1     # 相手が通常キャラ
  205.       end
  206.     end
  207.     if @priority_type == 1                          # 自分が通常キャラ
  208.       return true if $game_player.pos_nt?(x, y)     # プレイヤーの座標と一致
  209.       return true if $game_map.boat.pos_nt?(x, y)   # 小型船の座標と一致
  210.       return true if $game_map.ship.pos_nt?(x, y)   # 大型船の座標と一致
  211.     end
  212.     return false
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ● ロック (実行中のイベントが立ち止まる処理)
  216.   #--------------------------------------------------------------------------
  217.   def lock
  218.     unless @locked
  219.       @prelock_direction = @direction
  220.       turn_toward_player
  221.       @locked = true
  222.     end
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● ロック解除
  226.   #--------------------------------------------------------------------------
  227.   def unlock
  228.     if @locked
  229.       @locked = false
  230.       set_direction(@prelock_direction)
  231.     end
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● 指定位置に移動
  235.   #     x : X 座標
  236.   #     y : Y 座標
  237.   #--------------------------------------------------------------------------
  238.   def moveto(x, y)
  239.     @x = x % $game_map.width
  240.     @y = y % $game_map.height
  241.     @real_x = @x * 256
  242.     @real_y = @y * 256
  243.     @prelock_direction = 0
  244.     straighten
  245.     update_bush_depth
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● 指定方向に向き変更
  249.   #     direction : 向き
  250.   #--------------------------------------------------------------------------
  251.   def set_direction(direction)
  252.     if not @direction_fix and direction != 0
  253.       @direction = direction
  254.       @stop_count = 0
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● オブジェクトタイプ判定
  259.   #--------------------------------------------------------------------------
  260.   def object?
  261.     return (@tile_id > 0 or @character_name[0, 1] == '!')
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ● 画面 X 座標の取得
  265.   #--------------------------------------------------------------------------
  266.   def screen_x
  267.     return ($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ● 画面 Y 座標の取得
  271.   #--------------------------------------------------------------------------
  272.   def screen_y
  273.     y = ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  274.     y -= 4 unless object?
  275.     if @jump_count >= @jump_peak
  276.       n = @jump_count - @jump_peak
  277.     else
  278.       n = @jump_peak - @jump_count
  279.     end
  280.     return y - (@jump_peak * @jump_peak - n * n) / 2
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ● 画面 Z 座標の取得
  284.   #--------------------------------------------------------------------------
  285.   def screen_z
  286.     #ここから
  287.     if @jump_count >= @jump_peak
  288.       n = @jump_count - @jump_peak
  289.     else
  290.       n = @jump_peak - @jump_count
  291.     end
  292.     z = (@jump_peak * @jump_peak - n * n) / 32#ツクールXP参考に追加
  293.     #ここまで追加
  294.     if @priority_type == 2
  295.       return z + 200 #z+を追加
  296.     elsif @priority_type == 0
  297.       return z + 60 #z+を追加
  298.     elsif @tile_id > 0
  299.       pass = $game_map.passages[@tile_id]
  300.       if pass & 0x10 == 0x10    # [☆]
  301.         return z + 160 #z+を追加
  302.       else
  303.         return z + 40 #z+を追加
  304.       end
  305.     else
  306.       return z + 100 #z+を追加
  307.     end
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● フレーム更新
  311.   #--------------------------------------------------------------------------
  312.   def update
  313.     if jumping?                 # ジャンプ中
  314.       update_jump
  315.     elsif moving?               # 移動中
  316.       update_move
  317.     else                        # 停止中
  318.       update_stop
  319.     end
  320.     if @wait_count > 0          # ウェイト中
  321.       @wait_count -= 1
  322.     elsif @move_route_forcing   # 移動ルート強制中
  323.       move_type_custom
  324.     elsif not @locked           # ロック中以外
  325.       update_self_movement
  326.     end
  327.     update_animation
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # ● ジャンプ時の更新
  331.   #--------------------------------------------------------------------------
  332.   def update_jump
  333.     @jump_count -= 1
  334.     @real_x = (@real_x * @jump_count + @x * 256) / (@jump_count + 1)
  335.     @real_y = (@real_y * @jump_count + @y * 256) / (@jump_count + 1)
  336.     update_bush_depth
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● 移動時の更新
  340.   #--------------------------------------------------------------------------
  341.   def update_move
  342.     distance = 2 ** @move_speed * $game_player.move_times   # 移動速度から移動距離に変換
  343.     distance *= $game_player.dash_speed if dash? #ダッシュ状態#2 if dash?        # ダッシュ状態ならさらに倍
  344.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  345.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  346.     @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
  347.     @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
  348.     update_bush_depth unless moving?
  349.     if @walk_anime
  350.       @anime_count += 1.5
  351.     elsif @step_anime
  352.       @anime_count += 1
  353.     end
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 停止時の更新
  357.   #--------------------------------------------------------------------------
  358.   def update_stop
  359.     if @step_anime
  360.       @anime_count += 1
  361.     elsif @pattern != @original_pattern
  362.       @anime_count += 1.5
  363.     end
  364.     @stop_count += 1 unless @locked
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ● 自律移動の更新
  368.   #--------------------------------------------------------------------------
  369.   def update_self_movement
  370.     if @stop_count > 30 * (5 - @move_frequency)
  371.       case @move_type
  372.       when 1;  move_type_random
  373.       when 2;  move_type_toward_player
  374.       when 3;  move_type_custom
  375.       end
  376.     end
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● アニメカウントの更新
  380.   #--------------------------------------------------------------------------
  381.   def update_animation
  382.     speed = @move_speed + (dash? ? $game_player.dash_speed / 2 : 0)#(dash? ? 1 : 0)
  383.     #speed = @move_speed * $game_player.move_times + (dash? ? $game_player.dash_speed / 2 : 0)#(dash? ? 1 : 0)
  384.     if @anime_count > 18 - speed * 2
  385.       if not @step_anime and @stop_count > 0
  386.         @pattern = @original_pattern
  387.       else
  388.         @pattern = (@pattern + 1) % 4
  389.       end
  390.       @anime_count = 0
  391.     end
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # ● 茂み深さの更新
  395.   #--------------------------------------------------------------------------
  396.   def update_bush_depth
  397.     if object? or @priority_type != 1 or @jump_count > 0
  398.       @bush_depth = 0
  399.     else
  400.       bush = $game_map.bush?(@x, @y)
  401.       if bush and not moving?
  402.         @bush_depth = 8
  403.       elsif not bush
  404.         @bush_depth = 0
  405.       end
  406.     end
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ● 移動タイプ : ランダム
  410.   #--------------------------------------------------------------------------
  411.   def move_type_random
  412.     case rand(6)
  413.     when 0..1;  move_random
  414.     when 2..4;  move_forward
  415.     when 5;     @stop_count = 0
  416.     end
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● 移動タイプ : 近づく
  420.   #--------------------------------------------------------------------------
  421.   def move_type_toward_player
  422.     sx = @x - $game_player.x
  423.     sy = @y - $game_player.y
  424.     if sx.abs + sy.abs >= 20
  425.       move_random
  426.     else
  427.       case rand(6)
  428.       when 0..3;  move_toward_player
  429.       when 4;     move_random
  430.       when 5;     move_forward
  431.       end
  432.     end
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # ● 移動タイプ : カスタム
  436.   #--------------------------------------------------------------------------
  437.   def move_type_custom
  438.     if stopping?
  439.       command = @move_route.list[@move_route_index]   # 移動コマンドを取得
  440.       @move_failed = false
  441.       if command.code == 0                            # リストの最後
  442.         if @move_route.repeat                         # [動作を繰り返す]
  443.           @move_route_index = 0
  444.         elsif @move_route_forcing                     # 移動ルート強制中
  445.           @move_route_forcing = false                 # 強制を解除
  446.           @move_route = @original_move_route          # オリジナルを復帰
  447.           @move_route_index = @original_move_route_index
  448.           @original_move_route = nil
  449.         end
  450.       else
  451.         case command.code
  452.         when 1    # 下に移動
  453.           move_down
  454.         when 2    # 左に移動
  455.           move_left
  456.         when 3    # 右に移動
  457.           move_right
  458.         when 4    # 上に移動
  459.           move_up
  460.         when 5    # 左下に移動
  461.           move_lower_left
  462.         when 6    # 右下に移動
  463.           move_lower_right
  464.         when 7    # 左上に移動
  465.           move_upper_left
  466.         when 8    # 右上に移動
  467.           move_upper_right
  468.         when 9    # ランダムに移動
  469.           move_random
  470.         when 10   # プレイヤーに近づく
  471.           move_toward_player
  472.         when 11   # プレイヤーから遠ざかる
  473.           move_away_from_player
  474.         when 12   # 一歩前進
  475.           move_forward
  476.         when 13   # 一歩後退
  477.           move_backward
  478.         when 14   # ジャンプ
  479.           jump(command.parameters[0], command.parameters[1])
  480.         when 15   # ウェイト
  481.           @wait_count = command.parameters[0] - 1
  482.         when 16   # 下を向く
  483.           turn_down
  484.         when 17   # 左を向く
  485.           turn_left
  486.         when 18   # 右を向く
  487.           turn_right
  488.         when 19   # 上を向く
  489.           turn_up
  490.         when 20   # 右に 90 度回転
  491.           turn_right_90
  492.         when 21   # 左に 90 度回転
  493.           turn_left_90
  494.         when 22   # 180 度回転
  495.           turn_180
  496.         when 23   # 右か左に 90 度回転
  497.           turn_right_or_left_90
  498.         when 24   # ランダムに方向転換
  499.           turn_random
  500.         when 25   # プレイヤーの方を向く
  501.           turn_toward_player
  502.         when 26   # プレイヤーの逆を向く
  503.           turn_away_from_player
  504.         when 27   # スイッチ ON
  505.           $game_switches[command.parameters[0]] = true
  506.           $game_map.need_refresh = true
  507.         when 28   # スイッチ OFF
  508.           $game_switches[command.parameters[0]] = false
  509.           $game_map.need_refresh = true
  510.         when 29   # 移動速度の変更
  511.           @move_speed = command.parameters[0]
  512.         when 30   # 移動頻度の変更
  513.           @move_frequency = command.parameters[0]
  514.         when 31   # 歩行アニメ ON
  515.           @walk_anime = true
  516.         when 32   # 歩行アニメ OFF
  517.           @walk_anime = false
  518.         when 33   # 足踏みアニメ ON
  519.           @step_anime = true
  520.         when 34   # 足踏みアニメ OFF
  521.           @step_anime = false
  522.         when 35   # 向き固定 ON
  523.           @direction_fix = true
  524.         when 36   # 向き固定 OFF
  525.           @direction_fix = false
  526.         when 37   # すり抜け ON
  527.           @through = true
  528.         when 38   # すり抜け OFF
  529.           @through = false
  530.         when 39   # 透明化 ON
  531.           @transparent = true
  532.         when 40   # 透明化 OFF
  533.           @transparent = false
  534.         when 41   # グラフィック変更
  535.           set_graphic(command.parameters[0], command.parameters[1])
  536.         when 42   # 不透明度の変更
  537.           @opacity = command.parameters[0]
  538.         when 43   # 合成方法の変更
  539.           @blend_type = command.parameters[0]
  540.         when 44   # SE の演奏
  541.           command.parameters[0].play
  542.         when 45   # スクリプト
  543.           eval(command.parameters[0])
  544.         end
  545.         if not @move_route.skippable and @move_failed
  546.           return  # [移動できない場合は無視] OFF & 移動失敗
  547.         end
  548.         @move_route_index += 1
  549.       end
  550.     end
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # ● 歩数増加
  554.   #--------------------------------------------------------------------------
  555.   def increase_steps
  556.     @stop_count = 0
  557.     update_bush_depth
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # ● プレイヤーからの X 距離計算
  561.   #--------------------------------------------------------------------------
  562.   def distance_x_from_player
  563.     sx = @x - $game_player.x
  564.     if $game_map.loop_horizontal?         # 横にループしているとき
  565.       if sx.abs > $game_map.width / 2     # 絶対値がマップの半分より大きい?
  566.         sx -= $game_map.width             # マップの幅を引く
  567.       end
  568.     end
  569.     return sx
  570.   end
  571.   #--------------------------------------------------------------------------
  572.   # ● プレイヤーからの Y 距離計算
  573.   #--------------------------------------------------------------------------
  574.   def distance_y_from_player
  575.     sy = @y - $game_player.y
  576.     if $game_map.loop_vertical?           # 縦にループしているとき
  577.       if sy.abs > $game_map.height / 2    # 絶対値がマップの半分より大きい?
  578.         sy -= $game_map.height            # マップの高さを引く
  579.       end
  580.     end
  581.     return sy
  582.   end
  583.   #--------------------------------------------------------------------------
  584.   # ● 下に移動
  585.   #     turn_ok : その場での向き変更を許可
  586.   #--------------------------------------------------------------------------
  587.   def move_down(turn_ok = true)
  588.     if passable?(@x, @y+1)                  # 通行可能
  589.       turn_down
  590.       @y = $game_map.round_y(@y+1)
  591.       @real_y = (@y-1)*256
  592.       increase_steps
  593.       @move_failed = false
  594.     else                                    # 通行不可能
  595.       turn_down if turn_ok
  596.       check_event_trigger_touch(@x, @y+1)   # 接触イベントの起動判定
  597.       @move_failed = true
  598.     end
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ● 左に移動
  602.   #     turn_ok : その場での向き変更を許可
  603.   #--------------------------------------------------------------------------
  604.   def move_left(turn_ok = true)
  605.     if passable?(@x-1, @y)                  # 通行可能
  606.       turn_left
  607.       @x = $game_map.round_x(@x-1)
  608.       @real_x = (@x+1)*256
  609.       increase_steps
  610.       @move_failed = false
  611.     else                                    # 通行不可能
  612.       turn_left if turn_ok
  613.       check_event_trigger_touch(@x-1, @y)   # 接触イベントの起動判定
  614.       @move_failed = true
  615.     end
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # ● 右に移動
  619.   #     turn_ok : その場での向き変更を許可
  620.   #--------------------------------------------------------------------------
  621.   def move_right(turn_ok = true)
  622.     if passable?(@x+1, @y)                  # 通行可能
  623.       turn_right
  624.       @x = $game_map.round_x(@x+1)
  625.       @real_x = (@x-1)*256
  626.       increase_steps
  627.       @move_failed = false
  628.     else                                    # 通行不可能
  629.       turn_right if turn_ok
  630.       check_event_trigger_touch(@x+1, @y)   # 接触イベントの起動判定
  631.       @move_failed = true
  632.     end
  633.   end
  634.   #--------------------------------------------------------------------------
  635.   # ● 上に移動
  636.   #     turn_ok : その場での向き変更を許可
  637.   #--------------------------------------------------------------------------
  638.   def move_up(turn_ok = true)
  639.     if passable?(@x, @y-1)                  # 通行可能
  640.       turn_up
  641.       @y = $game_map.round_y(@y-1)
  642.       @real_y = (@y+1)*256
  643.       increase_steps
  644.       @move_failed = false
  645.     else                                    # 通行不可能
  646.       turn_up if turn_ok
  647.       check_event_trigger_touch(@x, @y-1)   # 接触イベントの起動判定
  648.       @move_failed = true
  649.     end
  650.   end
  651.   #--------------------------------------------------------------------------
  652.   # ● 左下に移動
  653.   #--------------------------------------------------------------------------
  654.   def move_lower_left
  655.     unless @direction_fix
  656.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  657.     end
  658.     if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
  659.        (passable?(@x-1, @y) and passable?(@x-1, @y+1))
  660.       @x -= 1
  661.       @y += 1
  662.       increase_steps
  663.       @move_failed = false
  664.     else
  665.       @move_failed = true
  666.     end
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # ● 右下に移動
  670.   #--------------------------------------------------------------------------
  671.   def move_lower_right
  672.     unless @direction_fix
  673.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  674.     end
  675.     if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
  676.        (passable?(@x+1, @y) and passable?(@x+1, @y+1))
  677.       @x += 1
  678.       @y += 1
  679.       increase_steps
  680.       @move_failed = false
  681.     else
  682.       @move_failed = true
  683.     end
  684.   end
  685.   #--------------------------------------------------------------------------
  686.   # ● 左上に移動
  687.   #--------------------------------------------------------------------------
  688.   def move_upper_left
  689.     unless @direction_fix
  690.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  691.     end
  692.     if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
  693.        (passable?(@x-1, @y) and passable?(@x-1, @y-1))
  694.       @x -= 1
  695.       @y -= 1
  696.       increase_steps
  697.       @move_failed = false
  698.     else
  699.       @move_failed = true
  700.     end
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # ● 右上に移動
  704.   #--------------------------------------------------------------------------
  705.   def move_upper_right
  706.     unless @direction_fix
  707.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  708.     end
  709.     if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
  710.        (passable?(@x+1, @y) and passable?(@x+1, @y-1))
  711.       @x += 1
  712.       @y -= 1
  713.       increase_steps
  714.       @move_failed = false
  715.     else
  716.       @move_failed = true
  717.     end
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● ランダムに移動
  721.   #--------------------------------------------------------------------------
  722.   def move_random
  723.     case rand(4)
  724.     when 0;  move_down(false)
  725.     when 1;  move_left(false)
  726.     when 2;  move_right(false)
  727.     when 3;  move_up(false)
  728.     end
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ● プレイヤーに近づく
  732.   #--------------------------------------------------------------------------
  733.   def move_toward_player
  734.     sx = distance_x_from_player
  735.     sy = distance_y_from_player
  736.     if sx != 0 or sy != 0
  737.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  738.         sx > 0 ? move_left : move_right   # 左右方向を優先
  739.         if @move_failed and sy != 0
  740.           sy > 0 ? move_up : move_down
  741.         end
  742.       else                                # 縦の距離のほうが長いか等しい
  743.         sy > 0 ? move_up : move_down      # 上下方向を優先
  744.         if @move_failed and sx != 0
  745.           sx > 0 ? move_left : move_right
  746.         end
  747.       end
  748.     end
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● プレイヤーから遠ざかる
  752.   #--------------------------------------------------------------------------
  753.   def move_away_from_player
  754.     sx = distance_x_from_player
  755.     sy = distance_y_from_player
  756.     if sx != 0 or sy != 0
  757.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  758.         sx > 0 ? move_right : move_left   # 左右方向を優先
  759.         if @move_failed and sy != 0
  760.           sy > 0 ? move_down : move_up
  761.         end
  762.       else                                # 縦の距離のほうが長いか等しい
  763.         sy > 0 ? move_down : move_up      # 上下方向を優先
  764.         if @move_failed and sx != 0
  765.           sx > 0 ? move_right : move_left
  766.         end
  767.       end
  768.     end
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # ● 一歩前進
  772.   #--------------------------------------------------------------------------
  773.   def move_forward
  774.     case @direction
  775.     when 2;  move_down(false)
  776.     when 4;  move_left(false)
  777.     when 6;  move_right(false)
  778.     when 8;  move_up(false)
  779.     end
  780.   end
  781.   #--------------------------------------------------------------------------
  782.   # ● 一歩後退
  783.   #--------------------------------------------------------------------------
  784.   def move_backward
  785.     last_direction_fix = @direction_fix
  786.     @direction_fix = true
  787.     case @direction
  788.     when 2;  move_up(false)
  789.     when 4;  move_right(false)
  790.     when 6;  move_left(false)
  791.     when 8;  move_down(false)
  792.     end
  793.     @direction_fix = last_direction_fix
  794.   end
  795.   #--------------------------------------------------------------------------
  796.   # ● ジャンプ(VXデフォルトジャンプ)壁に埋まります。
  797.   #     x_plus : X 座標加算値
  798.   #     y_plus : Y 座標加算値
  799.   #--------------------------------------------------------------------------
  800.   def jumpvx(x_plus, y_plus)
  801.     if x_plus.abs > y_plus.abs            # 横の距離のほうが長い
  802.       x_plus < 0 ? turn_left : turn_right
  803.     elsif x_plus.abs < y_plus.abs         # 縦の距離のほうが長い
  804.       y_plus < 0 ? turn_up : turn_down
  805.     end
  806.     @x += x_plus
  807.     @y += y_plus
  808.     distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
  809.     @jump_peak = 10 + distance - @move_speed
  810.     @jump_count = @jump_peak * 2
  811.     @stop_count = 0
  812.     straighten
  813.   end
  814.   #--------------------------------------------------------------------------
  815.   #カスタム
  816.   # ● ジャンプ(2000仕様ジャンプ)
  817.   #     x_plus : X 座標加算値
  818.   #     y_plus : Y 座標加算値
  819.   #--------------------------------------------------------------------------
  820.   def jump(x_plus, y_plus)
  821.     if x_plus == 0 and y_plus == 0
  822.       jumpvx(0,0) #直上ジャンプ用
  823.     elsif (passable?(@x + x_plus, @y + y_plus)) #ジャンプ先が通行可能かどうか?
  824.       if x_plus.abs > y_plus.abs            # 横の距離のほうが長い
  825.         x_plus < 0 ? turn_left : turn_right
  826.       elsif x_plus.abs < y_plus.abs         # 縦の距離のほうが長い
  827.         y_plus < 0 ? turn_up : turn_down
  828.       end
  829.       @x += x_plus
  830.       @y += y_plus
  831.       distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
  832.       @jump_peak = 10 + distance - @move_speed
  833.       @jump_count = @jump_peak * 2
  834.       @stop_count = 0
  835.       straighten
  836.     else #ジャンプ先が通行できないときはジャンプしない。
  837.       @move_failed = true
  838.     end
  839.   end
  840.   #--------------------------------------------------------------------------
  841.   # ● 下を向く
  842.   #--------------------------------------------------------------------------
  843.   def turn_down
  844.     set_direction(2)
  845.   end
  846.   #--------------------------------------------------------------------------
  847.   # ● 左を向く
  848.   #--------------------------------------------------------------------------
  849.   def turn_left
  850.     set_direction(4)
  851.   end
  852.   #--------------------------------------------------------------------------
  853.   # ● 右を向く
  854.   #--------------------------------------------------------------------------
  855.   def turn_right
  856.     set_direction(6)
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # ● 上を向く
  860.   #--------------------------------------------------------------------------
  861.   def turn_up
  862.     set_direction(8)
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # ● 右に 90 度回転
  866.   #--------------------------------------------------------------------------
  867.   def turn_right_90
  868.     case @direction
  869.     when 2;  turn_left
  870.     when 4;  turn_up
  871.     when 6;  turn_down
  872.     when 8;  turn_right
  873.     end
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # ● 左に 90 度回転
  877.   #--------------------------------------------------------------------------
  878.   def turn_left_90
  879.     case @direction
  880.     when 2;  turn_right
  881.     when 4;  turn_down
  882.     when 6;  turn_up
  883.     when 8;  turn_left
  884.     end
  885.   end
  886.   #--------------------------------------------------------------------------
  887.   # ● 180 度回転
  888.   #--------------------------------------------------------------------------
  889.   def turn_180
  890.     case @direction
  891.     when 2;  turn_up
  892.     when 4;  turn_right
  893.     when 6;  turn_left
  894.     when 8;  turn_down
  895.     end
  896.   end
  897.   #--------------------------------------------------------------------------
  898.   # ● 右か左に 90 度回転
  899.   #--------------------------------------------------------------------------
  900.   def turn_right_or_left_90
  901.     case rand(2)
  902.     when 0;  turn_right_90
  903.     when 1;  turn_left_90
  904.     end
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # ● ランダムに方向転換
  908.   #--------------------------------------------------------------------------
  909.   def turn_random
  910.     case rand(4)
  911.     when 0;  turn_up
  912.     when 1;  turn_right
  913.     when 2;  turn_left
  914.     when 3;  turn_down
  915.     end
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # ● プレイヤーの方を向く
  919.   #--------------------------------------------------------------------------
  920.   def turn_toward_player
  921.     sx = distance_x_from_player
  922.     sy = distance_y_from_player
  923.     if sx.abs > sy.abs                    # 横の距離のほうが長い
  924.       sx > 0 ? turn_left : turn_right
  925.     else#elsif sx.abs < sy.abs                 # 縦の距離のほうが長い
  926.       sy > 0 ? turn_up : turn_down
  927.     end
  928.   end
  929.   #--------------------------------------------------------------------------
  930.   # ● プレイヤーの逆を向く
  931.   #--------------------------------------------------------------------------
  932.   def turn_away_from_player
  933.     sx = distance_x_from_player
  934.     sy = distance_y_from_player
  935.     if sx.abs > sy.abs                    # 横の距離のほうが長い
  936.       sx > 0 ? turn_right : turn_left
  937.     else#elsif sx.abs < sy.abs                 # 縦の距離のほうが長い
  938.       sy > 0 ? turn_down : turn_up
  939.     end
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # ● グラフィックの変更
  943.   #     character_name  : 新しい歩行グラフィック ファイル名
  944.   #     character_index : 新しい歩行グラフィック インデックス
  945.   #--------------------------------------------------------------------------
  946.   def set_graphic(character_name, character_index)
  947.     @tile_id = 0
  948.     @character_name = character_name
  949.     @character_index = character_index
  950.   end
  951.   #--------------------------------------------------------------------------
  952.   # ○カスタムスクリプト
  953.   #--------------------------------------------------------------------------
  954.   # ○以下追加定義
  955.   #--------------------------------------------------------------------------
  956.   # ● 移動タイプ : 指定イベントに近づく(ランダム有り)
  957.   # ◆使い方
  958.   # イベントの移動ルート指定からスクリプトで
  959.   #「move_type_toward($game_map.interpreter.get_character(id))」
  960.   #idにはマップイベントのID(数字)を入力する。
  961.   #例:マップイベント3を追いかける
  962.   #move_type_toward($game_map.interpreter.get_character(3))
  963.   #--------------------------------------------------------------------------
  964.   def move_type_toward(character)
  965.     sx = @x - character.x
  966.     sy = @y - character.y
  967.     if sx.abs + sy.abs >= 20
  968.       move_random
  969.     else
  970.       case rand(6)
  971.       when 0..3;  move_toward(character)
  972.       when 4;     move_random
  973.       when 5;     move_forward
  974.       end
  975.     end
  976.   end
  977.   #--------------------------------------------------------------------------
  978.   # ● 指定イベントに近づく(ランダム無し)
  979.   # ◆使い方
  980.   # イベントの移動ルート指定からスクリプトで
  981.   #「move_toward($game_map.interpreter.get_character(id))」
  982.   #--------------------------------------------------------------------------
  983.   def move_toward(character)
  984.     sx = distance_x_from(character)
  985.     sy = distance_y_from(character)
  986.     if sx != 0 or sy != 0
  987.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  988.         sx > 0 ? move_left : move_right   # 左右方向を優先
  989.         if @move_failed and sy != 0
  990.           sy > 0 ? move_up : move_down
  991.         end
  992.       else                                # 縦の距離のほうが長いか等しい
  993.         sy > 0 ? move_up : move_down      # 上下方向を優先
  994.         if @move_failed and sx != 0
  995.           sx > 0 ? move_left : move_right
  996.         end
  997.       end
  998.     end
  999.   end
  1000.   #--------------------------------------------------------------------------
  1001.   # ● 指定イベントから遠ざかる
  1002.   # ◆使い方
  1003.   # イベントの移動ルート指定からスクリプトで
  1004.   #「move_away_from($game_map.interpreter.get_character(id))」
  1005.   #--------------------------------------------------------------------------
  1006.   def move_away_from(character)
  1007.     sx = distance_x_from(character)
  1008.     sy = distance_y_from(character)
  1009.     if sx != 0 or sy != 0
  1010.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  1011.         sx > 0 ? move_right : move_left   # 左右方向を優先
  1012.         if @move_failed and sy != 0
  1013.           sy > 0 ? move_down : move_up
  1014.         end
  1015.       else                                # 縦の距離のほうが長いか等しい
  1016.         sy > 0 ? move_down : move_up      # 上下方向を優先
  1017.         if @move_failed and sx != 0
  1018.           sx > 0 ? move_right : move_left
  1019.         end
  1020.       end
  1021.     end
  1022.   end
  1023.   #--------------------------------------------------------------------------
  1024.   # ● 指定イベントからの X 距離計算
  1025.   #--------------------------------------------------------------------------
  1026.   def distance_x_from(character)
  1027.     sx = @x - character.x
  1028.     if $game_map.loop_horizontal?         # 横にループしているとき
  1029.       if sx.abs > $game_map.width / 2     # 絶対値がマップの半分より大きい?
  1030.         sx -= $game_map.width             # マップの幅を引く
  1031.       end
  1032.     end
  1033.     return sx
  1034.   end
  1035.   #--------------------------------------------------------------------------
  1036.   # ● 指定イベントからの Y 距離計算
  1037.   #--------------------------------------------------------------------------
  1038.   def distance_y_from(character)
  1039.     sy = @y - character.y
  1040.     if $game_map.loop_vertical?           # 縦にループしているとき
  1041.       if sy.abs > $game_map.height / 2    # 絶対値がマップの半分より大きい?
  1042.         sy -= $game_map.height            # マップの高さを引く
  1043.       end
  1044.     end
  1045.     return sy
  1046.   end
  1047.   #--------------------------------------------------------------------------
  1048.   # ● 指定イベントの方を向く
  1049.   # ◆使い方
  1050.   # イベントの移動ルート指定からスクリプトで
  1051.   #「turn_toward($game_map.interpreter.get_character(id))」
  1052.   #--------------------------------------------------------------------------
  1053.   def turn_toward(character)
  1054.     sx = distance_x_from(character)
  1055.     sy = distance_y_from(character)
  1056.     if sx.abs > sy.abs                    # 横の距離のほうが長い
  1057.       sx > 0 ? turn_left : turn_right
  1058.     else#elsif sx.abs < sy.abs                 # 縦の距離のほうが長い
  1059.       sy > 0 ? turn_up : turn_down
  1060.     end
  1061.   end
  1062.   #--------------------------------------------------------------------------
  1063.   # ● 指定イベントの逆を向く
  1064.   # ◆使い方
  1065.   # イベントの移動ルート指定からスクリプトで
  1066.   #「turn_away_from($game_map.interpreter.get_character(id))」
  1067.   #--------------------------------------------------------------------------
  1068.   def turn_away_from(character)
  1069.     sx = distance_x_from(character)
  1070.     sy = distance_y_from(character)
  1071.     if sx.abs > sy.abs                    # 横の距離のほうが長い
  1072.       sx > 0 ? turn_right : turn_left
  1073.     else#elsif sx.abs < sy.abs                 # 縦の距離のほうが長い
  1074.       sy > 0 ? turn_down : turn_up
  1075.     end
  1076.   end
  1077.   #=====================================
  1078.   #--------------------------------------------------------------------------
  1079.   # ● 下に移動(失敗したらスイッチON)
  1080.   #     turn_ok : その場での向き変更を許可
  1081.   #◆使い方
  1082.   #イベントの移動ルート指定からスクリプトで
  1083.   #move_down_sw;@switch_no=n #nはONにしたいスイッチの番号
  1084.   #--------------------------------------------------------------------------
  1085.   def move_down_sw(turn_ok = true)
  1086.     if passable?(@x, @y+1)                  # 通行可能
  1087.       turn_down
  1088.       @y = $game_map.round_y(@y+1)
  1089.       @real_y = (@y-1)*256
  1090.       increase_steps
  1091.       @move_failed = false
  1092.     else                                    # 通行不可能
  1093.       turn_down if turn_ok
  1094.       check_event_trigger_touch(@x, @y+1)   # 接触イベントの起動判定
  1095.       $game_switches[@switch_no] = true #移動できない場合は指定のスイッチをON!
  1096.       $game_map.need_refresh = true
  1097.       @move_failed = true
  1098.     end
  1099.   end
  1100.   #--------------------------------------------------------------------------
  1101.   # ● 左に移動(失敗したらスイッチON)
  1102.   #     turn_ok : その場での向き変更を許可
  1103.   #◆使い方
  1104.   #イベントの移動ルート指定からスクリプトで
  1105.   #move_left_sw;@switch_no=n #nはONにしたいスイッチの番号
  1106.   #--------------------------------------------------------------------------
  1107.   def move_left_sw(turn_ok = true)
  1108.     if passable?(@x-1, @y)                  # 通行可能
  1109.       turn_left
  1110.       @x = $game_map.round_x(@x-1)
  1111.       @real_x = (@x+1)*256
  1112.       increase_steps
  1113.       @move_failed = false
  1114.     else                                    # 通行不可能
  1115.       turn_left if turn_ok
  1116.       check_event_trigger_touch(@x-1, @y)   # 接触イベントの起動判定
  1117.       $game_switches[@switch_no] = true #移動できない場合は指定のスイッチをON!
  1118.       $game_map.need_refresh = true
  1119.       @move_failed = true
  1120.     end
  1121.   end
  1122.   #--------------------------------------------------------------------------
  1123.   # ● 右に移動(失敗したらスイッチON)
  1124.   #     turn_ok : その場での向き変更を許可
  1125.   #◆使い方
  1126.   #イベントの移動ルート指定からスクリプトで
  1127.   #move_right_sw;@switch_no=n #nはONにしたいスイッチの番号
  1128.   #--------------------------------------------------------------------------
  1129.   def move_right_sw(turn_ok = true)
  1130.     if passable?(@x+1, @y)                  # 通行可能
  1131.       turn_right
  1132.       @x = $game_map.round_x(@x+1)
  1133.       @real_x = (@x-1)*256
  1134.       increase_steps
  1135.       @move_failed = false
  1136.     else                                    # 通行不可能
  1137.       turn_right if turn_ok
  1138.       check_event_trigger_touch(@x+1, @y)   # 接触イベントの起動判定
  1139.       $game_switches[@switch_no] = true #移動できない場合は指定のスイッチをON!
  1140.       $game_map.need_refresh = true
  1141.       @move_failed = true
  1142.     end
  1143.   end
  1144.   #--------------------------------------------------------------------------
  1145.   # ● 上に移動(失敗したらスイッチON)
  1146.   #     turn_ok : その場での向き変更を許可
  1147.   #◆使い方
  1148.   #イベントの移動ルート指定からスクリプトで
  1149.   #move_up_sw;@switch_no=n #nはONにしたいスイッチの番号
  1150.   #--------------------------------------------------------------------------
  1151.   def move_up_sw(turn_ok = true)
  1152.     if passable?(@x, @y-1)                  # 通行可能
  1153.       turn_up
  1154.       @y = $game_map.round_y(@y-1)
  1155.       @real_y = (@y+1)*256
  1156.       increase_steps
  1157.       @move_failed = false
  1158.     else                                    # 通行不可能
  1159.       turn_up if turn_ok
  1160.       check_event_trigger_touch(@x, @y-1)   # 接触イベントの起動判定
  1161.       $game_map.need_refresh = true
  1162.       $game_switches[@switch_no] = true #移動できない場合は指定のスイッチをON!
  1163.       @move_failed = true
  1164.     end
  1165.   end
  1166.   #--------------------------------------------------------------------------
  1167.   # ● 一歩前進(失敗したらスイッチON)
  1168.   #◆使い方
  1169.   #イベントの移動ルート指定からスクリプトで
  1170.   #「move_forward_sw(switch_no) #switch_noはONにしたいスイッチの番号」
  1171.   #例:move_forward_sw(1)
  1172.   #--------------------------------------------------------------------------
  1173.   def move_forward_sw(switch_no)
  1174.     @switch_no = switch_no
  1175.     case @direction
  1176.     when 2;  move_down_sw(false)
  1177.     when 4;  move_left_sw(false)
  1178.     when 6;  move_right_sw(false)
  1179.     when 8;  move_up_sw(false)
  1180.     end
  1181.   end
  1182.   #--------------------------------------------------------------------------
  1183.   # ● 指定のマスだけ前にジャンプ
  1184.   #◆使い方
  1185.   #イベントの移動ルート指定からスクリプトで
  1186.   #「jump_forward(dis_plus) #dis_plusは進みたいマスの数を入れます。
  1187.   #マイナスにすると後ろへジャンプします」
  1188.   #例:jump_forward(1) 何も書かないとエラーになります。
  1189.   #--------------------------------------------------------------------------
  1190.   def jump_forward(dis_plus)
  1191.     case @direction
  1192.     when 2;  jump(0,dis_plus)
  1193.     when 4;  jump(-dis_plus,0)
  1194.     when 6;  jump(dis_plus,0)
  1195.     when 8;  jump(0,-dis_plus)
  1196.     end
  1197.   end
  1198.   #--------------------------------------------------------------------------
  1199.   # ● 指定のマスだけ前にジャンプ、左右補正機能付き
  1200.   #◆使い方
  1201.   #イベントの移動ルート指定からスクリプトで
  1202.   #「jump_forward_ex(dis_plus,dir_plus) #dis_puls前に移動#dir_plus左右の補正
  1203.   #dis_plusは進みたいマスの数を入れます。
  1204.   #dir_pulsは左右の補正です。正の数にすると、キャラクターから見て右側に
  1205.   #負の数にすると、キャラクターから見て左側へ補正が加わります。
  1206.   #--------------------------------------------------------------------------
  1207.   #マイナスにすると後ろへジャンプします」
  1208.   #例:jump_forward_ex(1,1) 何も書かないとエラーになります。
  1209.   #キャラクターから見て、前方向へ1マス。右方向へ1マス。
  1210.   #つまり、キャラクターから見て右斜め前にジャンプします。
  1211.   #--------------------------------------------------------------------------
  1212.   def jump_forward_ex(dis_plus,dir_plus)
  1213.     case @direction
  1214.     when 2;  jump(-dir_plus,dis_plus) #下
  1215.     when 4;  jump(-dis_plus,-dir_plus) #左
  1216.     when 6;  jump(dis_plus,dir_plus) #右
  1217.     when 8;  jump(dir_plus,-dis_plus) #上
  1218.     end
  1219.   end
  1220.   #--------------------------------------------------------------------------
  1221.   # ● ランダムに指定のマスだけジャンプ
  1222.   #◆使い方
  1223.   #イベントの移動ルート指定からスクリプトで
  1224.   #「jump_random(dis_plus) #ジャンプするマスの数を入れます。」
  1225.   # ティンダロスやハンターβの回避行動にどうぞ!
  1226.   #例:jump_random(1) #何も書かないと一マスのジャンプになります。
  1227.   #--------------------------------------------------------------------------
  1228.   def jump_random(dis_plus=1)
  1229.     case rand(4)
  1230.     when 0;  jump(0,dis_plus)
  1231.     when 1;  jump(-dis_plus,0)
  1232.     when 2;  jump(dis_plus,0)
  1233.     when 3;  jump(0,-dis_plus)
  1234.     end
  1235.   end
  1236.   #--------------------------------------------------------------------------
  1237.   # ● ジャンプ先に障害物がある場合、そこを避けてジャンプする。
  1238.   #◆使い方
  1239.   #イベントの移動ルート指定からスクリプトで
  1240.   #「jump_avoid(x_plus,y_plus,avo) #avoは避けるマスの数。」
  1241.   #例:jump_avoid(3,0,1)
  1242.   #--------------------------------------------------------------------------
  1243.   def jump_avoid(x_plus,y_plus,avo)
  1244.     if passable?(@x + x_plus, @y + y_plus)
  1245.       avo = 0 #障害物がない場合は補正は0
  1246.     end
  1247.     case rand(4)
  1248.       when 0; jump(x_plus,y_plus + avo)
  1249.       when 1; jump(x_plus - avo,y_plus)
  1250.       when 2; jump(x_plus + avo,y_plus)
  1251.       when 3; jump(x_plus,y_plus - avo)
  1252.     end
  1253.   end
  1254.   #--------------------------------------------------------------------------
  1255.   # ● ジャンプしながらプレイヤーに近づく
  1256.   #--------------------------------------------------------------------------
  1257.   def jump_toward_player(dis_plus=1)
  1258.     sx = distance_x_from_player
  1259.     sy = distance_y_from_player
  1260.     if sx != 0 or sy != 0
  1261.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  1262.         sx > 0 ? jump(-dis_plus,0) : jump(dis_plus,0)   # 左右方向を優先
  1263.         if @move_failed and sy != 0
  1264.           sy > 0 ? jump(0,-dis_plus) : jump(0,dis_plus)
  1265.         end
  1266.       else                                # 縦の距離のほうが長いか等しい
  1267.         sy > 0 ? jump(0,-dis_plus) : jump(0,dis_plus)      # 上下方向を優先
  1268.         if @move_failed and sx != 0
  1269.           sx > 0 ? jump(-dis_plus,0) : jump(dis_plus,0)
  1270.         end
  1271.       end
  1272.     end
  1273.   end
  1274.   #--------------------------------------------------------------------------
  1275.   # ● ジャンプしながらプレイヤーから遠ざかる
  1276.   #--------------------------------------------------------------------------
  1277.   def jump_away_from_player(dis_plus=1)
  1278.     sx = distance_x_from_player
  1279.     sy = distance_y_from_player
  1280.     if sx != 0 or sy != 0
  1281.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  1282.         sx > 0 ? jump(dis_plus,0) : jump(-dis_plus,0)  # 左右方向を優先
  1283.         if @move_failed and sy != 0
  1284.           sy > 0 ? jump(0,dis_plus) : jump(0,-dis_plus)
  1285.         end
  1286.       else                                # 縦の距離のほうが長いか等しい
  1287.         sy > 0 ? jump(0,dis_plus) : jump(0,-dis_plus)      # 上下方向を優先
  1288.         if @move_failed and sx != 0
  1289.           sx > 0 ? jump(dis_plus,0) : jump(-dis_plus,0)
  1290.         end
  1291.       end
  1292.     end
  1293.   end
  1294.   #--------------------------------------------------------------------------
  1295.   # ● ジャンプしながら指定イベントに近づく
  1296.   # イベントの移動ルート指定からスクリプトで
  1297.   #「jump_toward($game_map.interpreter.get_character(id))(dis_plus=1)」
  1298.   #--------------------------------------------------------------------------
  1299.   def jump_toward(character)(dis_plus=1)
  1300.     sx = distance_x_from(character)
  1301.     sy = distance_y_from(character)
  1302.     if sx != 0 or sy != 0
  1303.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  1304.         sx > 0 ? jump(-dis_plus,0) : jump(dis_plus,0)   # 左右方向を優先
  1305.         if @move_failed and sy != 0
  1306.           sy > 0 ? jump(0,-dis_plus) : jump(0,dis_plus)
  1307.         end
  1308.       else                                # 縦の距離のほうが長いか等しい
  1309.         sy > 0 ? jump(0,-dis_plus) : jump(0,dis_plus)      # 上下方向を優先
  1310.         if @move_failed and sx != 0
  1311.           sx > 0 ? jump(-dis_plus,0) : jump(dis_plus,0)
  1312.         end
  1313.       end
  1314.     end
  1315.   end
  1316.   #--------------------------------------------------------------------------
  1317.   # ● ジャンプしながら指定イベントから遠ざかる
  1318.   # イベントの移動ルート指定からスクリプトで
  1319.   #「jump_away_from($game_map.interpreter.get_character(id))(dis_plus=1)」
  1320.   #--------------------------------------------------------------------------
  1321.   def jump_away_from(character)(dis_plus=1)
  1322.     sx = distance_x_from(character)
  1323.     sy = distance_y_from(character)
  1324.     if sx != 0 or sy != 0
  1325.       if sx.abs > sy.abs                  # 横の距離のほうが長い
  1326.         sx > 0 ? jump(dis_plus,0) : jump(-dis_plus,0)  # 左右方向を優先
  1327.         if @move_failed and sy != 0
  1328.           sy > 0 ? jump(0,dis_plus) : jump(0,-dis_plus)
  1329.         end
  1330.       else                                # 縦の距離のほうが長いか等しい
  1331.         sy > 0 ? jump(0,dis_plus) : jump(0,-dis_plus)      # 上下方向を優先
  1332.         if @move_failed and sx != 0
  1333.           sx > 0 ? jump(dis_plus,0) : jump(-dis_plus,0)
  1334.         end
  1335.       end
  1336.     end
  1337.   end
  1338.   #--------------------------------------------------------------------------
  1339.   # ● 変数の操作
  1340.   # 変数に値を代入
  1341.   # sub_value(id,value)#sub_(変数のID,代入される値)
  1342.   #--------------------------------------------------------------------------
  1343.   def sub_value(id,value)
  1344.     if id == nil
  1345.       print("sub_valueが正しく指定されていません")
  1346.       exit
  1347.     end
  1348.     if value == nil
  1349.       print("sub_valueが正しく指定されていません")
  1350.       exit
  1351.     end
  1352.     $game_variables[id] = value
  1353.     $game_map.need_refresh = true
  1354.   end
  1355.   #--------------------------------------------------------------------------
  1356.   # ● ツクール2000仕様のウェイトです。
  1357.   #wait_200x(数値) ウェイトする時間は数値×0.1秒で計算されます。
  1358.   #()を省略したり、0を入力したりするとウェイト0.0になります。
  1359.   #必ず数字を入力してください。文字を代入するとエラーになります。
  1360.   #--------------------------------------------------------------------------
  1361.   def wait_200x(count=0)
  1362.     n = count * 6
  1363.     if n < 0
  1364.       n = 0
  1365.     end
  1366.     if n == 0
  1367.       @wait_count = 1
  1368.     end
  1369.     return @wait_count = n
  1370.   end
  1371.   #--------------------------------------------------------------------------
  1372.   # ● ウェイトデラックス
  1373.   #wait_dx(数値)
  1374.   #ウェイトする時間を999以上指定出来ます。変数で指定することも可能です。
  1375.   #wait_dx(value,use_variables=true/false)
  1376.   #--------------------------------------------------------------------------
  1377.   def wait_dx(n,use_variables = false)
  1378.     if n < 0
  1379.       print("スクリプトwait_dxの参照している値が正しくありません!")
  1380.       exit
  1381.     else
  1382.       if use_variables == true and n > 5000
  1383.         print("参照するツクール変数のIDが最大値の5000を超えています!")
  1384.         exit
  1385.       end
  1386.     end
  1387.     if use_variables == true
  1388.       #trueのとき、n番目のツクールの変数の値だけウェイト
  1389.       @wait_count = $game_variables[n]
  1390.     else
  1391.       #falseのとき、nの値だけウェイト
  1392.       @wait_count = n
  1393.     end
  1394.     return true
  1395.   end
  1396. end
复制代码
第十三个:
  1. #==============================================================================
  2. # ■ Game_Interpreter(分割定義)
  3. #------------------------------------------------------------------------------
  4. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  5. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  6. #==============================================================================
  7. class Game_Interpreter
  8. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  9. #                 ゲーム進行                =
  10. #□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
  11. #============================================================================
  12. # ◆ スクリプト:スクリプトで使用 ◆
  13. #============================================================================
  14.   #--------------------------------------------------------------------------
  15.   # ● 変数の操作(カスタム)
  16.   #--------------------------------------------------------------------------
  17.   #--------------------------------------------------------------------------
  18.   # ● プレイヤーのX座標を取得
  19.   #--------------------------------------------------------------------------
  20.   def get_player_x(variable_id = 0)
  21.     character = get_character(-1) #-1はプレイヤーを意味する。
  22.     if variable_id > 0
  23.       $game_variables[variable_id] = character.x
  24.     end
  25.     return character.x
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● プレイヤーのY座標を取得
  29.   #--------------------------------------------------------------------------
  30.   def get_player_y(variable_id = 0)
  31.     character = get_character(-1) #-1はプレイヤーを意味する。
  32.     if variable_id > 0
  33.       $game_variables[variable_id] = character.y
  34.     end
  35.     return character.y
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● このイベントのX座標を取得
  39.   #--------------------------------------------------------------------------
  40.   def get_this_event_x(variable_id = 0)
  41.     character = get_character(0) #0はこのイベントを意味する。
  42.     if variable_id > 0
  43.       $game_variables[variable_id] = character.x
  44.     end
  45.     return character.x
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● このイベントのY座標を取得
  49.   #--------------------------------------------------------------------------
  50.   def get_this_event_y(variable_id = 0)
  51.     character = get_character(0) #0はこのイベントを意味する。
  52.     if variable_id > 0
  53.       $game_variables[variable_id] = character.y
  54.     end
  55.     return character.y
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 特定の名前を含むイベントのX座標を取得
  59.   #--------------------------------------------------------------------------
  60.   def get_name_event_x(name = "",variable_id = 0)
  61.     event_id = 0
  62.     # 該当するイベントを検索
  63.     events   = $game_map.events.values.find_all { |e| e.x == x && e.y == y }
  64.     event_id = (events.max { |a, b| a.id <=> b.id }).id unless events.empty?
  65.     character = get_character(event_id)
  66.     # 変数に代入
  67.     if variable_id > 0
  68.       $game_variables[variable_id] = character.x
  69.       $game_map.need_refresh = true
  70.     end
  71.     return character.x
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 特定の名前を含むイベントのY座標を取得
  75.   #--------------------------------------------------------------------------
  76.   def get_name_event_y(name = "",variable_id = 0)
  77.     event_id = 0
  78.     # 該当するイベントを検索
  79.     events   = $game_map.events.values.find_all { |e| e.x == x && e.y == y }
  80.     event_id = (events.max { |a, b| a.id <=> b.id }).id unless events.empty?
  81.     character = get_character(event_id)
  82.     # 変数に代入
  83.     if variable_id > 0
  84.       $game_variables[variable_id] = character.y
  85.     end
  86.     return character.y
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● スイッチの操作(カスタム)
  90.   #--------------------------------------------------------------------------
  91.   def operate_switches(operate,value,value2=0)
  92.     if value >= value2
  93.       #スイッチ単体操作
  94.       case operate
  95.       when 0
  96.         #operate = 0 #スイッチをOFF
  97.         $game_switches[value] = false
  98.       when 1
  99.         #operate = 1 #スイッチをON
  100.         $game_switches[value] = true
  101.       when 2
  102.         #operate = 2 #ON/OFFを逆転
  103.         $game_switches[value] ^= true #逆転
  104.       end
  105.     else
  106.       #スイッチ一括操作
  107.       case operate
  108.       when 0
  109.         #operate = 0 #スイッチをOFF
  110.         for i in value .. value2   # 一括操作ループ
  111.           $game_switches[i] = false
  112.         end
  113.       when 1
  114.         #operate = 1 #スイッチをON
  115.         for i in value .. value2   # 一括操作ループ
  116.           $game_switches[i] = true
  117.         end
  118.       when 2
  119.         #operate = 2 #ON/OFFを逆転
  120.         for i in value .. value2   # 一括操作ループ
  121.           $game_switches[i] ^= true #逆転
  122.         end
  123.       end
  124.     end
  125.     $game_map.need_refresh = true
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● スイッチの操作
  129.   #指定IDのスイッチをON
  130.   #--------------------------------------------------------------------------
  131.   def on_switche(switche_id)
  132.     if switche_id != nil
  133.       $game_switches[switche_id] = true
  134.     end
  135.     $game_map.need_refresh = true
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● スイッチの操作
  139.   #指定IDのスイッチをOFF
  140.   #--------------------------------------------------------------------------
  141.   def off_switche(switche_id)
  142.     if switche_id != nil
  143.       $game_switches[switche_id] = false
  144.     end
  145.     $game_map.need_refresh = true
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● スイッチの操作
  149.   #指定IDのスイッチのON/OFF逆転
  150.   #--------------------------------------------------------------------------
  151.   def change_switche(switche_id)
  152.     if switche_id != nil
  153.       $game_switches[switche_id] ^= true #スイッチの逆転
  154.     end
  155.     $game_map.need_refresh = true
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● スイッチの一括操作
  159.   #指定IDのスイッチをON
  160.   #--------------------------------------------------------------------------
  161.   def on_multi_switches(value,value2)
  162.     if value > value2
  163.       sw_id = value2
  164.       sw_id2 = value
  165.     else
  166.       sw_id = value
  167.       sw_id2 = value2
  168.     end
  169.     for i in sw_id .. sw_id2
  170.       $game_switches[i] = true
  171.     end
  172.     $game_map.need_refresh = true
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● スイッチの一括操作
  176.   #指定IDのスイッチをOFF
  177.   #--------------------------------------------------------------------------
  178.   def off_multi_switches(value,value2)
  179.     if value > value2
  180.       sw_id = value2
  181.       sw_id2 = value
  182.     else
  183.       sw_id = value
  184.       sw_id2 = value2
  185.     end
  186.     for i in sw_id .. sw_id2
  187.       $game_switches[i] = false
  188.     end
  189.     $game_map.need_refresh = true
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● スイッチの一括操作
  193.   #指定IDのスイッチのON/OFF逆転
  194.   #--------------------------------------------------------------------------
  195.   def change_multi_switches(value,value2)
  196.     if value > value2
  197.       sw_id = value2
  198.       sw_id2 = value
  199.     else
  200.       sw_id = value
  201.       sw_id2 = value2
  202.     end
  203.     for i in sw_id .. sw_id2
  204.       $game_switches[i] ^= true
  205.     end
  206.     $game_map.need_refresh = true
  207.     return true
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 先頭のアクターのIDを取得
  211.   #--------------------------------------------------------------------------
  212.   def get_top_actor_id(variable_id = 0)
  213.     actor = $game_party.members[0]
  214.     # 変数に代入
  215.     if variable_id > 0
  216.       $game_variables[variable_id] = actor.id
  217.     end
  218.     return actor.id
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● 先頭のアクターの武器IDを取得
  222.   #--------------------------------------------------------------------------
  223.   def get_top_actor_weapon_id(variable_id = 0)
  224.     actor = $game_party.members[0]
  225.     # 変数に代入
  226.     if variable_id > 0
  227.       $game_variables[variable_id] = actor.weapon_id
  228.     end
  229.     return actor.weapon_id
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 先頭のアクターの名前を取得
  233.   #アクターの名前は普通は文字列です。変数の操作で代入を除く数の増減などの
  234.   #操作を行うとエラーになるので気をつけましょう。
  235.   #--------------------------------------------------------------------------
  236.   def get_top_actor_name(variable_id = 0)
  237.     actor = $game_party.members[0]
  238.     # 変数に代入
  239.     if variable_id > 0
  240.       $game_variables[variable_id] = actor.name
  241.     end
  242.     return actor.name
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 先頭のアクターのHPを取得
  246.   #--------------------------------------------------------------------------
  247.   def get_top_actor_hp(variable_id = 0)
  248.     actor = $game_party.members[0]
  249.     # 変数に代入
  250.     if variable_id > 0
  251.       $game_variables[variable_id] = actor.hp
  252.     end
  253.     return actor.hp
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # ● 先頭のアクターの最大HPを取得
  257.   #--------------------------------------------------------------------------
  258.   def get_top_actor_maxhp(variable_id = 0)
  259.     actor = $game_party.members[0]
  260.     # 変数に代入
  261.     if variable_id > 0
  262.       $game_variables[variable_id] = actor.maxhp
  263.     end
  264.     return actor.maxhp
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● 先頭のアクターのHPの割合(百分率)を取得
  268.   #--------------------------------------------------------------------------
  269.   def get_top_actor_hp_ratio(variable_id = 0)
  270.     actor = $game_party.members[0]
  271.     if actor.maxhp != 0
  272.       hp_ratio =  100 * actor.hp / actor.maxhp
  273.     else
  274.       hp_ratio = 0
  275.     end
  276.     # 変数に代入
  277.     if variable_id > 0
  278.       $game_variables[variable_id] = hp_ratio
  279.     end
  280.     return hp_ratio
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ● 先頭のアクターのMPを取得
  284.   #--------------------------------------------------------------------------
  285.   def get_top_actor_mp(variable_id = 0)
  286.     actor = $game_party.members[0]
  287.     # 変数に代入
  288.     if variable_id > 0
  289.       $game_variables[variable_id] = actor.mp
  290.     end
  291.     return actor.mp
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 先頭のアクターの最大MPを取得
  295.   #--------------------------------------------------------------------------
  296.   def get_top_actor_maxmp(variable_id = 0)
  297.     actor = $game_party.members[0]
  298.     # 変数に代入
  299.     if variable_id > 0
  300.       $game_variables[variable_id] = actor.maxmp
  301.     end
  302.     return actor.maxmp
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 先頭のアクターの攻撃力を取得
  306.   #--------------------------------------------------------------------------
  307.   def get_top_actor_atk(variable_id = 0)
  308.     actor = $game_party.members[0]
  309.     # 変数に代入
  310.     if variable_id > 0
  311.       $game_variables[variable_id] = actor.atk
  312.     end
  313.     return actor.atk
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 先頭のアクターの防御力を取得
  317.   #--------------------------------------------------------------------------
  318.   def get_top_actor_def(variable_id = 0)
  319.     actor = $game_party.members[0]
  320.     # 変数に代入
  321.     if variable_id > 0
  322.       $game_variables[variable_id] = actor.def
  323.     end
  324.     return actor.def
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● アイテムの所持数取得
  328.   #--------------------------------------------------------------------------
  329.   def get_item_number(item_id,variable_id = 0)
  330.     if item_id == nil
  331.       print("アイテムIDを指定してください!IDは直接または変数で指定出来ます!")
  332.       exit
  333.     end
  334.     if item_id > $data_items.size
  335.       print("アイテムIDがデータベースで指定した範囲を超えました!")
  336.       exit
  337.     end
  338.     if variable_id > 0
  339.       #変数に代入
  340.       $game_variables[variable_id] = $game_party.item_number($data_items[item_id])
  341.     end
  342.     return $game_party.item_number($data_items[item_id])
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # ● 武器の所持数取得
  346.   #--------------------------------------------------------------------------
  347.   def get_weapon_number(weapon_id,variable_id = 0)
  348.     if weapon_id == nil
  349.       print("武器IDを指定してください!IDは直接または変数で指定出来ます!")
  350.       exit
  351.     end
  352.     if weapon_id > $data_weapons.size
  353.       print("武器IDがデータベースで指定した範囲を超えました!")
  354.       exit
  355.     end
  356.     if variable_id > 0
  357.       #変数に代入
  358.       $game_variables[variable_id] = $game_party.item_number($data_weapons[weapon_id])
  359.     end
  360.     return $game_party.item_number($data_weapons[weapon_id])
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 防具の所持数取得
  364.   #--------------------------------------------------------------------------
  365.   def get_armor_number(armor_id,variable_id = 0)
  366.     if armor_id == nil
  367.       print("防具IDを指定してください!IDは直接または変数で指定出来ます!")
  368.       exit
  369.     end
  370.     if armor_id > $data_armors.size
  371.       print("防具IDがデータベースで指定した範囲を超えました!")
  372.       exit
  373.     end
  374.     if variable_id > 0
  375.       #変数に代入
  376.       $game_variables[variable_id] = $game_party.item_number($data_armors[armor_id])
  377.     end
  378.     return $game_party.item_number($data_armors[armor_id])
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● アイテムボックス内のアイテムの所持数取得
  382.   #--------------------------------------------------------------------------
  383.   def get_item_number_in_box(item_id,variable_id = 0)
  384.     if item_id == nil
  385.       print("アイテムIDを指定してください!IDは直接または変数で指定出来ます!")
  386.       exit
  387.     end
  388.     if item_id > $data_items.size
  389.       print("アイテムIDがデータベースで指定した範囲を超えました!")
  390.       exit
  391.     end
  392.     if variable_id > 0
  393.       #変数に代入
  394.       $game_variables[variable_id] = $game_party.keeping_item_number($data_items[item_id])
  395.     end
  396.     return $game_party.keeping_item_number($data_items[item_id])
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● アイテムボックス内の武器の所持数取得
  400.   #--------------------------------------------------------------------------
  401.   def get_weapon_number_in_box(weapon_id,variable_id = 0)
  402.     if weapon_id == nil
  403.       print("武器IDを指定してください!IDは直接または変数で指定出来ます!")
  404.       exit
  405.     end
  406.     if weapon_id > $data_weapons.size
  407.       print("武器IDがデータベースで指定した範囲を超えました!")
  408.       exit
  409.     end
  410.     if variable_id > 0
  411.       #変数に代入
  412.       $game_variables[variable_id] = $game_party.keeping_item_number($data_weapons[weapon_id])
  413.     end
  414.     return $game_party.keeping_item_number($data_weapons[weapon_id])
  415.   end
  416.   #--------------------------------------------------------------------------
  417.   # ● アイテムボックス内の防具の所持数取得
  418.   #--------------------------------------------------------------------------
  419.   def get_armor_number_in_box(armor_id,variable_id = 0)
  420.     if armor_id == nil
  421.       print("防具IDを指定してください!IDは直接または変数で指定出来ます!")
  422.       exit
  423.     end
  424.     if armor_id > $data_armors.size
  425.       print("防具IDがデータベースで指定した範囲を超えました!")
  426.       exit
  427.     end
  428.     if variable_id > 0
  429.       #変数に代入
  430.       $game_variables[variable_id] = $game_party.keeping_item_number($data_armors[armor_id])
  431.     end
  432.     return $game_party.keeping_item_number($data_armors[armor_id])
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # ● プレイ時間の取得
  436.   #--------------------------------------------------------------------------
  437.   def get_playtime(variable_id1=0,variable_id2=0 ,variable_id3=0)
  438.     total_sec = Graphics.frame_count / Graphics.frame_rate
  439.     # 変数に代入
  440.     if variable_id1 > 0
  441.       #時間
  442.       $game_variables[variable_id1] = total_sec / 60 / 60
  443.     end
  444.     if variable_id2 > 0
  445.       #分
  446.       $game_variables[variable_id2] = total_sec / 60 % 60
  447.     end
  448.     if variable_id3 > 0
  449.       #秒
  450.       $game_variables[variable_id3] = total_sec % 60
  451.     end
  452.     return total_sec
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ● タイマーの操作
  456.   #変数指定可能
  457.   #--------------------------------------------------------------------------
  458.   def set_timer(sec = 0)
  459.     if min > 0  # 始動
  460.       $game_system.timer = sec * Graphics.frame_rate
  461.       $game_system.timer_working = true
  462.     end
  463.     if min == 0  # 停止
  464.       $game_system.timer_working = false
  465.     end
  466.     return true
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # ● タイマー表示
  470.   #--------------------------------------------------------------------------
  471.   def timer_appear#タイマーの表示
  472.     $game_system.timer_hide = false #表示
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # ● タイマー非表示
  476.   #--------------------------------------------------------------------------
  477.   def timer_hide#タイマーの非表示
  478.     $game_system.timer_hide = true #非表示
  479.   end
  480.   #--------------------------------------------------------------------------
  481.   # ● タイマーの一時停止
  482.   #--------------------------------------------------------------------------
  483.   def stop_timer#タイマー一時停止
  484.     $game_system.timer_stop
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● タイマーの再スタート
  488.   #--------------------------------------------------------------------------
  489.   def restart_timer#タイマー再始動
  490.     $game_system.timer_start
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   #■マップ画面でプレイヤーの操作強制無効 RGSS2 DAIpage■と連動
  494.   #--------------------------------------------------------------------------
  495.   # ● プレイヤーロックのON/OFF
  496.   #--------------------------------------------------------------------------
  497.   def player_lock_on_off
  498.     $game_player.player_lock
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ● プレイヤーロックのON
  502.   #--------------------------------------------------------------------------
  503.   def player_lock_on#プレイヤーロック開始
  504.     $game_player.player_lock_on#プレイヤーロック開始
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ● プレイヤーロックのOFF
  508.   #--------------------------------------------------------------------------
  509.   def player_lock_off#プレイヤーロック終了
  510.     $game_player.player_lock_off#プレイヤーロック終了
  511.   end
  512. end
复制代码
第十四个:
  1. #==============================================================================
  2. # ■ Game_Interpreter(分割定義)
  3. #------------------------------------------------------------------------------
  4. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  5. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  6. #==============================================================================
  7. class Game_Interpreter
  8. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  9. #                  フロー制御               =
  10. #□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
  11. #============================================================================
  12. # ◆ 条件分岐:スクリプトで使用 ◆
  13. #============================================================================
  14.   #--------------------------------------------------------------------------
  15.   # ● 先頭のアクターIDが~~であるか?
  16.   #--------------------------------------------------------------------------
  17.   def top_actor_id?(actor_id)
  18.     actor = $game_party.members[0]
  19.     if actor != nil
  20.       if actor.id == actor_id
  21.         return true
  22.       else
  23.         return false
  24.       end
  25.     end
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 先頭のアクターの名前が~~であるか?
  29.   #--------------------------------------------------------------------------
  30.   def top_actor_name?(actor_name)
  31.     actor = $game_party.members[0]
  32.     if actor != nil
  33.       if actor.name == actor_name
  34.         return true
  35.       else
  36.         return false
  37.       end
  38.     end
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 先頭のアクターがスキル~~を習得しているか?
  42.   #--------------------------------------------------------------------------
  43.   def top_actor_skill_learn?(actor_skill)
  44.     actor = $game_party.members[0]
  45.     if actor != nil
  46.       if actor.skill_learn?($data_skills[actor_skill])
  47.         return true
  48.       else
  49.         return false
  50.       end
  51.     end
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 先頭のアクターが武器~~を装備しているか?
  55.   #--------------------------------------------------------------------------
  56.   def top_actor_weapon_include?(actor_weapon)
  57.     actor = $game_party.members[0]
  58.     if actor != nil
  59.       if actor.weapons.include?($data_weapons[actor_weapon])
  60.         return true
  61.       else
  62.         return false
  63.       end
  64.     end
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 先頭のアクターが防具~~を装備しているか?
  68.   #--------------------------------------------------------------------------
  69.   def top_actor_armor_include?(actor_armor)
  70.     actor = $game_party.members[0]
  71.     if actor != nil
  72.       if actor.armors.include?($data_armors[actor_armor])
  73.         return true
  74.       else
  75.         return false
  76.       end
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 先頭のアクターのステートに~~が含まれるか?
  81.   #--------------------------------------------------------------------------
  82.   def top_actor_state?(state)
  83.     actor = $game_party.members[0]
  84.     if actor != nil
  85.       if actor.state?(state)
  86.         return true
  87.       else
  88.         return false
  89.       end
  90.     end
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 指定IDのアイテムを持っているか?
  94.   #--------------------------------------------------------------------------
  95.   def has_item?(item_id)
  96.     if item_id != nil
  97.       if $game_party.has_item?($data_items[item_id])
  98.         return true
  99.       else
  100.         return false
  101.       end
  102.     end
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 指定IDのアイテムがアイテムボックスの中にあるか?
  106.   #--------------------------------------------------------------------------
  107.   def has_item_in_box?(item_id)
  108.     if item_id != nil
  109.       if $game_party.keeping_has_item?($data_items[item_id])
  110.         return true
  111.       else
  112.         return false
  113.       end
  114.     end
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 指定IDの武器がアイテムボックスの中にあるか?
  118.   #--------------------------------------------------------------------------
  119.   def has_weapon_in_box?(item_id)
  120.     if item_id != nil
  121.       if $game_party.keeping_has_item?($data_weapons[item_id])
  122.         return true
  123.       else
  124.         return false
  125.       end
  126.     end
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 指定IDの防具がアイテムボックスの中にあるか?
  130.   #--------------------------------------------------------------------------
  131.   def has_armor_in_box?(item_id)
  132.     if item_id != nil
  133.       if $game_party.keeping_has_item?($data_armors[item_id])
  134.         return true
  135.       else
  136.         return false
  137.       end
  138.     end
  139.   end
  140. end
复制代码

Lv1.梦旅人

梦石
0
星屑
50
在线时间
151 小时
注册时间
2012-3-17
帖子
493
2
发表于 2012-3-27 12:40:24 | 只看该作者
我表示很长.....只看见了弹药两个字,让我想起了传说中的 重装机兵 怀念啊 一会玩玩去

重点不是在于你想不想.而是在于你做不做

《折翼的天使》测试版本1.10已发布欢迎提交改造意见和BUG/4月3日
花自飘零水自流,
一种相思,两处闲愁.此轻无计可消除,
才下眉头,却上心头
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
108
在线时间
1006 小时
注册时间
2008-11-9
帖子
1658
3
发表于 2012-3-27 12:41:49 | 只看该作者
好长啊·····LZ我还是建议你把这些代码分别用代码框框起来= =
回复 支持 反对

使用道具 举报

Lv1.梦旅人

Mr.Gandum

梦石
0
星屑
226
在线时间
2070 小时
注册时间
2007-1-31
帖子
3039

贵宾

4
发表于 2012-3-27 16:43:59 | 只看该作者
如果你有诚意,请至少用代码框包住。

点评

应该怎么用代码框,我是新手  发表于 2012-3-27 20:11
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
43
在线时间
233 小时
注册时间
2012-3-4
帖子
986
5
发表于 2012-3-27 20:49:48 | 只看该作者
好像是机战类
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
108
在线时间
1006 小时
注册时间
2008-11-9
帖子
1658
6
发表于 2012-3-27 21:00:57 | 只看该作者


又是一个不知道代码框的新人呢(摇头),↑就是这个啦,在高级回复/编辑模式里可以看到~

点评

谢谢啦  发表于 2012-3-28 17:43
回复 支持 反对

使用道具 举报

Lv1.梦旅人

星君

梦石
0
星屑
83
在线时间
2980 小时
注册时间
2011-10-9
帖子
2317

贵宾短篇七萝莉正太组冠军

7
发表于 2012-3-27 21:02:00 | 只看该作者
这个是野比大雄的生化危机自定义菜单
于是解决了,版主把此帖开水了吧(雾)

回复 支持 反对

使用道具 举报

Lv1.梦旅人

追从自然的旅行者
奇特空·煦

梦石
0
星屑
107
在线时间
1387 小时
注册时间
2010-12-31
帖子
4944

开拓者贵宾

8
发表于 2012-3-27 22:10:00 | 只看该作者
我很奇怪,你连脚本是干啥的都不知道为什么要拿给我们看是干啥的
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1702
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

9
发表于 2012-3-28 15:09:48 | 只看该作者
代码框,代码框……
否则论坛会出BUG啊魂淡!~!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-25 11:17

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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