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

Project1

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

[已经过期] CP制導入,防御时间BUG.

[复制链接]

Lv2.观梦者

梦石
0
星屑
253
在线时间
574 小时
注册时间
2006-8-25
帖子
969
跳转到指定楼层
1
发表于 2010-7-2 00:59:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 jhhuang 于 2010-7-2 19:57 编辑

全动画战斗系统(修改加强再加强版)By:叮当猫
▼▲▼ XRXS_BP 1. CP制導入 ver..23 ▼▲▼by 桜雅 在土, 和希
这两个都是大家熟悉到不能再熟悉的脚本来吧...
我同时使用了这两个脚本...当然= =我就知道一起用会有稀里叭啦的问题....可是还是抵挡不住内心想用的诱惑.
暂时来说最好的效果就是CP制战斗放在上面,全动画战斗放在下面.
动画显示的问题严重性还不是很大..还是暂时不说了.
防御方面出现了一个问题...
当敌人防御后,会有一段时间...(大概5~10回合吧,没详细测试过)保持防御状态...
之后才解除状态回到通常伤害数值和显示受伤动画.
自己防御试了一下,却不存在这个问题....只有敌人有这个问题.
# ● 防御中判定 [ 再定義 ]在188行~
下面给出两个脚本.
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # ————————————————————————————————————

  5. # ▼▲▼ XRXS_BP 1. CP制導入 ver..23 ▼▲▼
  6. # by 桜雅 在土, 和希

  7. #==============================================================================
  8. # □ 自定义设定
  9. #==============================================================================
  10. module XRXS_BP1
  11. #
  12. # 对齐方式。0:左 1:中央 2:右
  13. #
  14. ALIGN = 0
  15. #
  16. # 人数
  17. #
  18. MAX = 4
  19. end
  20. class Scene_Battle_CP
  21. #
  22. # 战斗速度
  23. #
  24. BATTLE_SPEED = 1.0
  25. #
  26. # 战斗开始的时候气槽百分比
  27. #
  28. START_CP_PERCENT = 0
  29. end

  30. class Scene_Battle

  31. # 效果音效,可以自己添加
  32. DATA_SYSTEM_COMMAND_UP_SE = ""

  33. # 各项数值功能消耗的CP值
  34. CP_COST_BASIC_ACTIONS = 0 # 基础共同
  35. CP_COST_SKILL_ACTION = 65535 # 技能
  36. CP_COST_ITEM_ACTION = 65535 # 物品
  37. CP_COST_BASIC_ATTACK = 65535 # 攻撃
  38. CP_COST_BASIC_GUARD = 65535 # 防御
  39. CP_COST_BASIC_NOTHING = 65535 # 不做任何事情
  40. CP_COST_BASIC_ESCAPE = 65535 # 逃跑
  41. end

  42. #==============================================================================
  43. # --- XRXS.命令窗口?命令追加機構 ---
  44. #------------------------------------------------------------------------------
  45. # Window_Commandクラスに add_command メソッドを追加します。
  46. #==============================================================================
  47. module XRXS_Window_Command_Add_Command
  48. #--------------------------------------------------------------------------
  49. # ○ 命令追加
  50. #--------------------------------------------------------------------------
  51. def add_command(command)
  52. # 初期化nil場合、無効化判別用の配列 @disabled の初期化
  53. #
  54. if @disabled == nil
  55. @disabled = []
  56. end
  57. if @commands.size != @disabled.size
  58. for i in [email protected]
  59. @disabled[i] = false
  60. end
  61. end
  62. #
  63. # 追加
  64. #
  65. @commands.push(command)
  66. @disabled.push(false)
  67. @item_max = @commands.size
  68. self.y -= 32
  69. self.height += 32
  70. self.contents.dispose
  71. self.contents = nil
  72. self.contents = Bitmap.new(self.width - 32, @item_max * 32)
  73. refresh
  74. for i in [email protected]
  75. if @disabled[i]
  76. disable_item(i)
  77. end
  78. end
  79. end
  80. #--------------------------------------------------------------------------
  81. # ○ 項目の無効化
  82. # index : 項目番号
  83. #--------------------------------------------------------------------------
  84. def disable_item(index)
  85. if @disabled == nil
  86. @disabled = []
  87. end
  88. @disabled[index] = true
  89. draw_item(index, disabled_color)
  90. end
  91. end
  92. class Window_Command < Window_Selectable
  93. #--------------------------------------------------------------------------
  94. # ○ 包括
  95. #--------------------------------------------------------------------------
  96. include XRXS_Window_Command_Add_Command
  97. #--------------------------------------------------------------------------
  98. # ● 項目の無効化
  99. # index : 項目番号
  100. #--------------------------------------------------------------------------
  101. def disable_item(index)
  102. super
  103. end
  104. end
  105. #==============================================================================
  106. # □ Scene_Battle_CP
  107. #==============================================================================
  108. class Scene_Battle_CP
  109. #--------------------------------------------------------------------------
  110. # ○ 定义实例变量
  111. #--------------------------------------------------------------------------
  112. attr_accessor :stop # CP加算停止
  113. #----------------------------------------------------------------------------
  114. # ○ 初始化对像
  115. #----------------------------------------------------------------------------
  116. def initialize
  117. @battlers = []
  118. @cancel = false
  119. @stop = false
  120. @agi_total = 0
  121. # 配列 count_battlers を初期化
  122. count_battlers = []
  123. # エネミーを配列 count_battlers に追加
  124. for enemy in $game_troop.enemies
  125. count_battlers.push(enemy)
  126. end
  127. # アクターを配列 count_battlers に追加
  128. for actor in $game_party.actors
  129. count_battlers.push(actor)
  130. end
  131. for battler in count_battlers
  132. @agi_total += battler.agi
  133. end
  134. for battler in count_battlers
  135. battler.cp = [[65535 * START_CP_PERCENT * (rand(15) + 85) * 4 * battler.agi / @agi_total / 10000, 0].max, 65535].min
  136. end
  137. end
  138. #----------------------------------------------------------------------------
  139. # ○ CP计数
  140. #----------------------------------------------------------------------------
  141. def update
  142. # ストップされているならリターン
  143. return if @stop
  144. #
  145. for battler in $game_party.actors + $game_troop.enemies
  146. # 行動出来なければ無視
  147. if battler.dead? == true
  148. battler.cp = 0
  149. next
  150. end
  151. battler.cp = [[battler.cp + BATTLE_SPEED * 4096 * battler.agi / @agi_total, 0].max, 65535].min
  152. end
  153. end
  154. #----------------------------------------------------------------------------
  155. # ○ CP计数の開始
  156. #----------------------------------------------------------------------------
  157. def stop
  158. @cancel = true
  159. if @cp_thread != nil then
  160. @cp_thread.join
  161. @cp_thread = nil
  162. end
  163. end
  164. end

  165. #==============================================================================
  166. # ■ Game_Battler
  167. #==============================================================================
  168. class Game_Battler
  169. attr_accessor :now_guarding # 現在防御中フラグ
  170. attr_accessor :cp # 現在CP
  171. attr_accessor :slip_state_update_ban # スリップ?ステート自動処理の禁止
  172. #--------------------------------------------------------------------------
  173. # ○ CP の変更
  174. #--------------------------------------------------------------------------
  175. def cp=(p)
  176. @cp = [[p, 0].max, 65535].min
  177. end
  178. #--------------------------------------------------------------------------
  179. # ● 防御中判定 [ 再定義 ]
  180. #--------------------------------------------------------------------------
  181. def guarding?
  182. return @now_guarding
  183. end
  184. #--------------------------------------------------------------------------
  185. # ● 命令输入可能判定
  186. #--------------------------------------------------------------------------
  187. alias xrxs_bp1_inputable? inputable?
  188. def inputable?
  189. bool = xrxs_bp1_inputable?
  190. return (bool and (@cp >= 65535))
  191. end
  192. #--------------------------------------------------------------------------
  193. # ● ステート [スリップダメージ] 判定
  194. #--------------------------------------------------------------------------
  195. alias xrxs_bp1_slip_damage? slip_damage?
  196. def slip_damage?
  197. return false if @slip_state_update_ban
  198. return xrxs_bp1_slip_damage?
  199. end
  200. #--------------------------------------------------------------------------
  201. # ● ステート自然解除 (ターンごとに呼び出し)
  202. #--------------------------------------------------------------------------
  203. alias xrxs_bp1_remove_states_auto remove_states_auto
  204. def remove_states_auto
  205. return if @slip_state_update_ban
  206. xrxs_bp1_remove_states_auto
  207. end
  208. end
  209. #==============================================================================
  210. # ■ Game_Actor
  211. #==============================================================================
  212. class Game_Actor < Game_Battler
  213. #--------------------------------------------------------------------------
  214. # ● 格局
  215. #--------------------------------------------------------------------------
  216. alias xrxs_bp1_setup setup
  217. def setup(actor_id)
  218. xrxs_bp1_setup(actor_id)
  219. @cp = 0
  220. @now_guarding = false
  221. @slip_state_update_ban = false
  222. end
  223. end
  224. #==============================================================================
  225. # ■ Game_Enemy
  226. #==============================================================================
  227. class Game_Enemy < Game_Battler
  228. #--------------------------------------------------------------------------
  229. # ● 初始化对像
  230. #--------------------------------------------------------------------------
  231. alias xrxs_bp1_initialize initialize
  232. def initialize(troop_id, member_index)
  233. xrxs_bp1_initialize(troop_id, member_index)
  234. @cp = 0
  235. @now_guarding = false
  236. @slip_state_update_ban = false
  237. end
  238. end

  239. class Window_All < Window_Base
  240.   def initialize
  241.     super(0,0,640,480)
  242.     self.opacity = 0
  243.     self.contents = Bitmap.new(width - 32, height - 32)
  244.     refresh
  245.   end
  246.   def refresh
  247.     self.contents.clear
  248.     for actor in $game_troop.enemies
  249.       next if !actor.exist?
  250.       draw_actor_cp_meter(actor, actor.screen_x-64, actor.screen_y-24, 60, 0)
  251.     end
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # ○ CPメーター の描画
  255.   #--------------------------------------------------------------------------
  256.   def draw_actor_cp_meter(actor, x, y, width = 156, type = 0)
  257.     self.contents.font.color = system_color
  258.     self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  259.     if actor.cp == nil
  260.       actor.cp = 0
  261.     end
  262.     w = width * [actor.cp,65535].min / 65535
  263.     self.contents.fill_rect(x, y+28, w,1, Color.new(255, 255, 128, 255))
  264.     self.contents.fill_rect(x, y+29, w,1, Color.new(255, 255, 0, 255))
  265.     self.contents.fill_rect(x, y+30, w,1, Color.new(192, 192, 0, 255))
  266.     self.contents.fill_rect(x, y+31, w,1, Color.new(128, 128, 0, 255))
  267.   end  
  268. end

  269. #==============================================================================
  270. # ■ Window_BattleStatus
  271. #==============================================================================
  272. class Window_BattleStatus < Window_Base
  273.   #--------------------------------------------------------------------------
  274.   # ○ 定义实例变量
  275.   #--------------------------------------------------------------------------
  276.   attr_accessor :update_cp_only # CPメーターのみの更新
  277.   #--------------------------------------------------------------------------
  278.   # ● 初期化对象
  279.   #--------------------------------------------------------------------------
  280.   alias xrxs_bp1_initialize initialize
  281.   def initialize
  282.     @update_cp_only = false
  283.     @wall = Window_All.new
  284.     xrxs_bp1_initialize
  285.   end
  286.   def dispose
  287.     super
  288.     @wall.dispose
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 刷新
  292.   #--------------------------------------------------------------------------
  293.   alias xrxs_bp1_refresh refresh
  294.   def refresh
  295.     unless @update_cp_only
  296.       xrxs_bp1_refresh
  297.     end
  298.     refresh_cp
  299.     @wall.refresh
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ○ 刷新(CPのみ)
  303.   #--------------------------------------------------------------------------
  304.   def refresh_cp
  305.     for i in 0...$game_party.actors.size
  306.     actor = $game_party.actors[i]
  307.     width = [self.width*3/4 / XRXS_BP1::MAX, 80].max
  308.     space = self.width / XRXS_BP1::MAX
  309.     case XRXS_BP1::ALIGN
  310.     when 0
  311.       actor_x = i * space + 4
  312.     when 1
  313.       actor_x = (space * ((XRXS_BP1::MAX - $game_party.actors.size)/2.0 + i)).floor
  314.     when 2
  315.       actor_x = (i + XRXS_BP1::MAX - $game_party.actors.size) * space + 4
  316.     end
  317.       actor_x += self.x
  318.       draw_actor_cp_meter(actor, actor_x, 96, width, 0)
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ○ CPメーター の描画
  323.   #--------------------------------------------------------------------------
  324.   def draw_actor_cp_meter(actor, x, y, width = 156, type = 0)
  325.     self.contents.font.color = system_color
  326.     self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  327.     if actor.cp == nil
  328.       actor.cp = 0
  329.     end
  330.     w = width * [actor.cp,65535].min / 65535
  331.     self.contents.fill_rect(x, y+28, w,1, Color.new(255, 255, 128, 255))
  332.     self.contents.fill_rect(x, y+29, w,1, Color.new(255, 255, 0, 255))
  333.     self.contents.fill_rect(x, y+30, w,1, Color.new(192, 192, 0, 255))
  334.     self.contents.fill_rect(x, y+31, w,1, Color.new(128, 128, 0, 255))
  335.   end
  336. end
  337. #==============================================================================
  338. # ■ Scene_Battle
  339. #==============================================================================
  340. class Scene_Battle
  341. #--------------------------------------------------------------------------
  342. # ● 帧更新
  343. #--------------------------------------------------------------------------
  344. alias xrxs_bp1_update update
  345. def update
  346. xrxs_bp1_update
  347. # CP更新
  348. @cp_thread.update
  349. end
  350. #--------------------------------------------------------------------------
  351. # ● 战斗終了
  352. # result : 結果 (0:勝利 1:敗北 2:逃走)
  353. #--------------------------------------------------------------------------
  354. alias xrxs_bp1_battle_end battle_end
  355. def battle_end(result)
  356. # CPカウントを停止する
  357. @cp_thread.stop
  358. # 呼び戻す
  359. xrxs_bp1_battle_end(result)
  360. end
  361. #--------------------------------------------------------------------------
  362. # ● プレバトルフェーズ開始
  363. #--------------------------------------------------------------------------
  364. alias xrxs_bp1_start_phase1 start_phase1
  365. def start_phase1
  366. @agi_total = 0
  367. # CP加算を開始する
  368. @cp_thread = Scene_Battle_CP.new
  369. # インデックスを計算
  370. @cp_escape_actor_command_index = @actor_command_window.height/32 - 1
  371. # アクターコマンドウィンドウに追加
  372. @actor_command_window.add_command("逃跑")
  373. if !$game_temp.battle_can_escape
  374. @actor_command_window.disable_item(@cp_escape_actor_command_index)
  375. end
  376. # 呼び戻す
  377. xrxs_bp1_start_phase1
  378. end
  379. #--------------------------------------------------------------------------
  380. # ● パーティコマンドフェーズ開始
  381. #--------------------------------------------------------------------------
  382. alias xrxs_bp1_start_phase2 start_phase2
  383. def start_phase2
  384. xrxs_bp1_start_phase2
  385. @party_command_window.active = false
  386. @party_command_window.visible = false
  387. # CP加算を再開する
  388. @cp_thread.stop = false
  389. # 次へ
  390. start_phase3
  391. end
  392. #--------------------------------------------------------------------------
  393. # ● アクターコマンドウィンドウのセットアップ
  394. #--------------------------------------------------------------------------
  395. alias xrxs_bp1_phase3_setup_command_window phase3_setup_command_window
  396. def phase3_setup_command_window
  397. # CPスレッドを一時停止する
  398. @cp_thread.stop = true
  399. # ウィンドウのCP更新
  400. @status_window.refresh_cp
  401. # @active_battlerの防御を解除
  402. @active_battler.now_guarding = false
  403. # 効果音の再生
  404. Audio.se_play(DATA_SYSTEM_COMMAND_UP_SE) if DATA_SYSTEM_COMMAND_UP_SE != ""
  405. # 呼び戻す
  406. xrxs_bp1_phase3_setup_command_window
  407. end
  408. #--------------------------------------------------------------------------
  409. # ● 帧更新 (アクターコマンドフェーズ : 基本命令)
  410. #--------------------------------------------------------------------------
  411. alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
  412. def update_phase3_basic_command
  413. # C ボタンが押された場合
  414. if Input.trigger?(Input::C)
  415. # アクターコマンドウィンドウのカーソル位置で分岐
  416. case @actor_command_window.index
  417. when @cp_escape_actor_command_index # 逃げる
  418. if $game_temp.battle_can_escape
  419. # 決定 SE を演奏
  420. $game_system.se_play($data_system.decision_se)
  421. # アクションを設定
  422. @active_battler.current_action.kind = 0
  423. @active_battler.current_action.basic = 4
  424. # 次のアクターのコマンド入力へ
  425. phase3_next_actor
  426. else
  427. # ブザー SE を演奏
  428. $game_system.se_play($data_system.buzzer_se)
  429. end
  430. return
  431. end
  432. end
  433. xrxs_bsp1_update_phase3_basic_command
  434. end
  435. #--------------------------------------------------------------------------
  436. # ● 主要阶段開始
  437. #--------------------------------------------------------------------------
  438. alias xrxs_bp1_start_phase4 start_phase4
  439. def start_phase4
  440. # 呼び戻す
  441. xrxs_bp1_start_phase4
  442. # CPスレッドを一時停止する
  443. unless @action_battlers.empty?
  444. @cp_thread.stop = true
  445. end
  446. end
  447. #--------------------------------------------------------------------------
  448. # ● 行動順序作成
  449. #--------------------------------------------------------------------------
  450. alias xrxs_bp1_make_action_orders make_action_orders
  451. def make_action_orders
  452. xrxs_bp1_make_action_orders
  453. # 全員のCPを確認
  454. exclude_battler = []
  455. for battler in @action_battlers
  456. # CPが不足している場合は @action_battlers から除外する
  457. if battler.cp < 65535
  458. exclude_battler.push(battler)
  459. end
  460. end
  461. @action_battlers -= exclude_battler
  462. end
  463. #--------------------------------------------------------------------------
  464. # ● 帧更新(主要阶段步骤1:准备动作)
  465. #--------------------------------------------------------------------------
  466. alias xrxs_bp1_update_phase4_step1 update_phase4_step1
  467. def update_phase4_step1
  468. # 初期化
  469. @phase4_act_continuation = 0
  470. # 勝敗判定
  471. if judge
  472. @cp_thread.stop
  473. # 勝利または敗北の場合 : メソッド終了
  474. return
  475. end
  476. # 未行動バトラー配列の先頭から取得
  477. @active_battler = @action_battlers[0]
  478. # ステータス更新をCPだけに限定。
  479. @status_window.update_cp_only = true
  480. # ステート更新を禁止。
  481. @active_battler.slip_state_update_ban = true if @active_battler != nil
  482. # 戻す
  483. xrxs_bp1_update_phase4_step1
  484. # @status_windowがリフレッシュされなかった場合は手動でリフレッシュ(CPのみ)
  485. if @phase4_step != 2
  486. # リフレッシュ
  487. @status_window.refresh
  488. # 軽量化:たったコレだけΣ(?w?
  489. Graphics.frame_reset
  490. end
  491. # 禁止を解除
  492. @status_window.update_cp_only = false
  493. @active_battler.slip_state_update_ban = false if @active_battler != nil
  494. end
  495. #--------------------------------------------------------------------------
  496. # ● 帧更新(主要阶段第2步:动作的开始)
  497. #--------------------------------------------------------------------------
  498. alias xrxs_bp1_update_phase4_step2 update_phase4_step2
  499. def update_phase4_step2
  500. # 強制アクションでなければ
  501. unless @active_battler.current_action.forcing
  502. # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合
  503. if @active_battler.restriction == 2 or @active_battler.restriction == 3
  504. # アクションに攻撃を設定
  505. @active_battler.current_action.kind = 0
  506. @active_battler.current_action.basic = 0
  507. end
  508. # 制約が [行動できない] の場合
  509. if @active_battler.restriction == 4
  510. # アクション強制対象のバトラーをクリア
  511. $game_temp.forcing_battler = nil
  512. if @phase4_act_continuation == 0 and @active_battler.cp >= 65535
  513. # ステート自然解除
  514. @active_battler.remove_states_auto
  515. # CP消費
  516. @active_battler.cp -= 65535
  517. # ステータスウィンドウをリフレッシュ
  518. @status_window.refresh
  519. end
  520. # ステップ 1 に移行
  521. @phase4_step = 1
  522. return
  523. end
  524. end
  525. # アクションの種別で分岐
  526. case @active_battler.current_action.kind
  527. when 0
  528. # 攻撃?防御?逃げる?何もしない時の共通消費CP
  529. @active_battler.cp -= CP_COST_BASIC_ACTIONS if @phase4_act_continuation == 0
  530. when 1
  531. # スキル使用時の消費CP
  532. @active_battler.cp -= CP_COST_SKILL_ACTION if @phase4_act_continuation == 0
  533. when 2
  534. # アイテム使用時の消費CP
  535. @active_battler.cp -= CP_COST_ITEM_ACTION if @phase4_act_continuation == 0
  536. end
  537. # ステート自然解除
  538. @active_battler.remove_states_auto
  539. # 呼び戻す
  540. xrxs_bp1_update_phase4_step2
  541. end
  542.   #--------------------------------------------------------------------------
  543.   # ● 基本动作 結果作成
  544.   #--------------------------------------------------------------------------
  545.   alias xrxs_bp1_make_basic_action_result make_basic_action_result
  546.   def make_basic_action_result
  547.     # 攻撃的場合
  548.     if @active_battler.current_action.basic == 0 and @phase4_act_continuation == 0
  549.       @active_battler.cp -= CP_COST_BASIC_ATTACK # 攻撃時のCP消費
  550.     end
  551.     # 防御的場合
  552.     if @active_battler.current_action.basic == 1 and @phase4_act_continuation == 0
  553.       @active_battler.cp -= CP_COST_BASIC_GUARD # 防御時のCP消費
  554.       # @active_battlerの防御をON
  555.       @active_battler.now_guarding = true
  556.     end
  557.     # 敌人逃跑的場合
  558.     if @active_battler.is_a?(Game_Enemy) and
  559.       @active_battler.current_action.basic == 2 and @phase4_act_continuation == 0
  560.       @active_battler.cp -= CP_COST_BASIC_ESCAPE # 逃走時のCP消費
  561.     end
  562.     # 什么也不做的場合
  563.     if @active_battler.current_action.basic == 3 and @phase4_act_continuation == 0
  564.       @active_battler.cp -= CP_COST_BASIC_NOTHING # 何もしない時のCP消費
  565.     end
  566.     # 逃跑的場合
  567.     if @active_battler.current_action.basic == 4 and @phase4_act_continuation == 0
  568.       @active_battler.cp -= CP_COST_BASIC_ESCAPE # 逃走時のCP消費
  569.       # 逃跑
  570.       if $game_temp.battle_can_escape == false
  571.         # ブザー SE を演奏
  572.         $game_system.se_play($data_system.buzzer_se)
  573.         return
  574.       end
  575.       # 逃走处理
  576.       update_phase2_escape
  577.       return
  578.     end
  579.     # 呼び戻す
  580.     xrxs_bp1_make_basic_action_result
  581.   end
  582.   #--------------------------------------------------------------------------
  583.   # ● 帧更新(主要阶段第6步:刷新)
  584.   #--------------------------------------------------------------------------
  585.   alias xrxs_bp1_update_phase4_step6 update_phase4_step6
  586.   def update_phase4_step6
  587.     # スリップダメージ
  588.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  589.       @active_battler.slip_damage_effect
  590.       @active_battler.damage_pop = true
  591.       # 窗口状态刷新
  592.       @status_window.refresh
  593.     end
  594.     # 呼び戻す
  595.     xrxs_bp1_update_phase4_step6
  596.   end
  597. end


  598. #==============================================================================
  599. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  600. #==============================================================================
复制代码

Lv2.观梦者

梦石
0
星屑
253
在线时间
574 小时
注册时间
2006-8-25
帖子
969
2
 楼主| 发表于 2010-7-2 01:55:29 | 只看该作者
本帖最后由 jhhuang 于 2010-7-2 01:59 编辑

灌水无罪,连帖有理.....开玩笑开玩笑....
不好意思,不知道是不是文本过长还是什么滴滴,无法一起发....故分开...
  1. #==============================================================================
  2. # ■ 全动画战斗系统(修改加强再加强版)
  3. #------------------------------------------------------------------------------
  4. #  By whbm
  5. #   应用脚本 彩虹神剑 By 66
  6. #==============================================================================
  7.     $fangyu = 0
  8. #新加部分 改进基础 叮当猫的全动画脚本
  9. #================
  10. module RPG
  11.   class Sprite < ::Sprite
  12.     @@_animations = []
  13.     @@_reference_count = {}
  14.    
  15.     def dispose
  16.       dispose_damage
  17.       dispose_animation
  18.       dispose_loop_animation
  19.        dispose_loop_animation1
  20.       super
  21.     end
  22.    
  23.    
  24.   
  25.    
  26.     def loop_animation1(animation)
  27.       return if animation == @_loop_animation1
  28.       dispose_loop_animation1
  29.       @_loop_animation1 = animation
  30.       return if @_loop_animation1 == nil
  31.       @_loop_animation1_index = 0
  32.       animation_name = @_loop_animation1.animation_name
  33.       animation_hue = @_loop_animation1.animation_hue
  34.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  35.       if @@_reference_count.include?(bitmap)
  36.         @@_reference_count[bitmap] += 1
  37.       else
  38.         @@_reference_count[bitmap] = 1
  39.       end
  40.       @_loop_animation1_sprites = []
  41.       for i in 0..15
  42.         sprite = ::Sprite.new(self.viewport)
  43.         sprite.bitmap = bitmap
  44.         sprite.visible = false
  45.         @_loop_animation1_sprites.push(sprite)
  46.       end
  47.       update_loop_animation1
  48.     end
  49.    
  50.    
  51.    

  52.     def dispose_loop_animation1
  53.       if @_loop_animation1_sprites != nil
  54.         sprite = @_loop_animation1_sprites[0]
  55.         if sprite != nil
  56.           @@_reference_count[sprite.bitmap] -= 1
  57.           if @@_reference_count[sprite.bitmap] == 0
  58.             sprite.bitmap.dispose
  59.           end
  60.         end
  61.         for sprite in @_loop_animation1_sprites
  62.           sprite.dispose
  63.         end
  64.         @_loop_animation1_sprites = nil
  65.         @_loop_animation1 = nil
  66.       end
  67.     end
  68.    
  69.    
  70.    
  71.    
  72.     def update_loop_animation1
  73.       frame_index = @_loop_animation1_index
  74.       cell_data = @_loop_animation1.frames[frame_index].cell_data
  75.       position = @_loop_animation1.position
  76.       animation_set_sprites(@_loop_animation1_sprites, cell_data, position)
  77.       for timing in @_loop_animation1.timings
  78.         if timing.frame == frame_index
  79.           animation_process_timing(timing, true)
  80.         end
  81.       end
  82.     end
  83.    
  84.   end
  85. end
  86. #===============
  87. #新加部分

  88. class Spriteset_Battle
  89.   #--------------------------------------------------------------------------
  90.   # ● 初始化变量
  91.   #--------------------------------------------------------------------------
  92.   def initialize
  93.     # 生成显示端口
  94.     @viewport1 = Viewport.new(0, 0, 640, 480)
  95.     @viewport2 = Viewport.new(0, 0, 640, 480)
  96.     @viewport3 = Viewport.new(0, 0, 640, 480)
  97.     @viewport4 = Viewport.new(0, 0, 640, 480)
  98.     @viewport2.z = 101
  99.     @viewport3.z = 200
  100.     @viewport4.z = 5000
  101.     # 生成战斗背景活动块
  102.     @battleback_sprite = Sprite.new(@viewport1)
  103.     # 生成敌人活动块
  104.     @enemy_sprites = []
  105.     for enemy in $game_troop.enemies.reverse
  106. #      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  107.       @enemy_sprites.push(Sprite_Battler.new(@viewport4, enemy))#敌人的显示高度
  108.     end
  109.     # 生成敌人活动块
  110.     @actor_sprites = []
  111.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  112.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  113.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  114.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  115.     # 生成天候
  116.     @weather = RPG::Weather.new(@viewport1)
  117.     # 生成图片活动块
  118.     @picture_sprites = []
  119.     for i in 51..100
  120.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  121.         $game_screen.pictures[i]))
  122.     end
  123.     # 生成计时器块
  124.     @timer_sprite = Sprite_Timer.new
  125.     # 刷新画面
  126.     update
  127.   end
  128.   #..........................................................................
  129.   #--------------------------------------------------------------------------
  130.   # ● 胜利图
  131.   #--------------------------------------------------------------------------
  132.   def win
  133.     for sprite in @actor_sprites
  134.       sprite.win
  135.     end
  136.   end
  137.   #..........................................................................
  138.   #--------------------------------------------------------------------------
  139.   # ● 刷新画面
  140.   #--------------------------------------------------------------------------
  141.   def update
  142.     # 刷新角色的活动块 (对应角色的替换)
  143.     @actor_sprites[0].battler = $game_party.actors[0]
  144.     @actor_sprites[1].battler = $game_party.actors[1]
  145.     @actor_sprites[2].battler = $game_party.actors[2]
  146.     @actor_sprites[3].battler = $game_party.actors[3]
  147.     # 战斗背景的文件名与现在情况有差异的情况下
  148.     if @battleback_name != $game_temp.battleback_name
  149.       @battleback_name = $game_temp.battleback_name
  150.       if @battleback_sprite.bitmap != nil
  151.         @battleback_sprite.bitmap.dispose
  152.       end
  153.       @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  154.       @battleback_sprite.src_rect.set(0, 0, 640, 480)
  155.     end
  156.     # 刷新战斗者的活动块
  157.     for sprite in @enemy_sprites + @actor_sprites
  158.       sprite.update
  159.     end
  160.     # 刷新天气图形
  161.     @weather.type = $game_screen.weather_type
  162.     @weather.max = $game_screen.weather_max
  163.     @weather.update
  164.     # 刷新图片活动块
  165.     for sprite in @picture_sprites
  166.       sprite.update
  167.     end
  168.     # 刷新计时器活动块
  169.     @timer_sprite.update
  170.     # 设置画面的色调与震动位置
  171.     @viewport1.tone = $game_screen.tone
  172.     @viewport1.ox = $game_screen.shake
  173.     # 设置画面的闪烁色
  174.     @viewport4.color = $game_screen.flash_color
  175.     # 刷新显示端口
  176.     @viewport1.update
  177.     @viewport2.update
  178.     @viewport4.update
  179.   end
  180. end
  181. class Arrow_Enemy < Arrow_Base
  182.   #--------------------------------------------------------------------------
  183.   # ● 获取光标指向的敌人
  184.   #--------------------------------------------------------------------------
  185.   def enemy
  186.     return $game_troop.enemies[@index]
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 刷新画面
  190.   #--------------------------------------------------------------------------
  191.   def update
  192.     super
  193.     # 如果指向不存在的敌人就离开
  194.     $game_troop.enemies.size.times do
  195.       break if self.enemy.exist?
  196.       @index += 1
  197.       @index %= $game_troop.enemies.size
  198.     end
  199.     # 光标右
  200.     if Input.repeat?(Input::RIGHT)
  201.       $game_system.se_play($data_system.cursor_se)
  202.       $game_troop.enemies.size.times do
  203.         @index += 1
  204.         @index %= $game_troop.enemies.size
  205.         break if self.enemy.exist?
  206.       end
  207.     end
  208.     # 光标左
  209.     if Input.repeat?(Input::LEFT)
  210.       $game_system.se_play($data_system.cursor_se)
  211.       $game_troop.enemies.size.times do
  212.         @index += $game_troop.enemies.size - 1
  213.         @index %= $game_troop.enemies.size
  214.         break if self.enemy.exist?
  215.       end
  216.     end
  217.     # 设置活动块坐标
  218.     if self.enemy != nil
  219.       self.x = self.enemy.screen_x + self.ox
  220.       self.y = self.enemy.screen_y + self.oy
  221.     end
  222.   end
  223. end
  224. class Arrow_Actor < Arrow_Base
  225.   #--------------------------------------------------------------------------
  226.   # ● 获取光标指向的角色
  227.   #--------------------------------------------------------------------------
  228.   def actor
  229.     return $game_party.actors[@index]
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 刷新画面
  233.   #--------------------------------------------------------------------------
  234.   def update
  235.     super
  236.     # 光标右
  237.     if Input.repeat?(Input::RIGHT)
  238.       $game_system.se_play($data_system.cursor_se)
  239.       @index += 1
  240.       @index %= $game_party.actors.size
  241.     end
  242.     # 光标左
  243.     if Input.repeat?(Input::LEFT)
  244.       $game_system.se_play($data_system.cursor_se)
  245.       @index += $game_party.actors.size - 1
  246.       @index %= $game_party.actors.size
  247.     end
  248.     # 设置活动块坐标
  249.     if self.actor != nil
  250.       self.x = self.actor.screen_x + self.ox
  251.       self.y = self.actor.screen_y + self.oy
  252.     end
  253.   end
  254. end
  255. class Scene_Battle
  256.   #--------------------------------------------------------------------------
  257.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  258.   #--------------------------------------------------------------------------
  259.   def update_phase4_step3
  260.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  261.     if @animation1_id == 0
  262.       @active_battler.white_flash = true
  263.     else
  264.     # 添加施法动画
  265. #     @active_battler.setup_battler_ani(@active_battler.battler_name.split(/★/)[8], 1)
  266.       @active_battler.animation_id = @animation1_id
  267.       @active_battler.animation_hit = true
  268.     end
  269.     # 对像方动画
  270.     for target in @target_battlers
  271.       target.animation_id = @animation2_id
  272.       target.animation_hit = (target.damage != "Miss")
  273.       ###########################################################
  274.       target.setup_battler_dead_ani(0)
  275.       ############################################################
  276.       #.......................................................................
  277.       if target.is_a?(Game_Actor)
  278.         ##############
  279.         if target.guarding?
  280.           $fangyu = 1
  281.         end
  282.         ##############
  283.         if target.current_action.kind == 0 and target.current_action.basic == 1
  284.            target.setup_battler_ani(target.battler_name.split(/★/)[2], 1)
  285.          #else
  286.            #target.current_action.kind == 0 and target.current_action.basic == 1
  287.           # target.setup_battler_ani(target.battler_name.split(/★/)[3], 0)
  288.            else
  289.          target.setup_battler_hurt_ani(0)
  290.         end
  291.       end
  292.       if target.is_a?(Game_Enemy)
  293.        if target.current_action.kind == 0 and target.current_action.basic == 1
  294.           target.setup_battler_ani(target.battler_name.split(/★/)[1])
  295.         else
  296.           target.setup_battler_hurt_ani(0)
  297.         end
  298.       end
  299.       #.......................................................................
  300.     end
  301.     # 对像方动画
  302.     for target in @target_battlers
  303.       target.animation_id = @animation2_id
  304.       target.animation_hit = (target.damage != "Miss")
  305.       #......................................................................
  306.     end
  307.     # 限制动画长度、最低 8 帧
  308.     @wait_count = 8
  309.     # 移至步骤 5
  310.     @phase4_step = 5
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 刷新画面 (主回合步骤 4 : 对像方动画) ★
  314.   #--------------------------------------------------------------------------
  315.   def update_phase4_step4
  316.     # 移至步骤 5
  317.     @phase4_step = 5
  318.   end
  319. end
  320. class Game_Actor < Game_Battler
  321.   #--------------------------------------------------------------------------
  322.   # ● 取得战斗画面的 X 坐标
  323.   #--------------------------------------------------------------------------
  324.   def screen_x
  325.     case self.index
  326.     when 0
  327.       return 448
  328.     when 1
  329.       return 490
  330.     when 2
  331.       return 490
  332.     when 3
  333.       return 490
  334.     else
  335.       return 1000
  336.     end
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● 取得战斗画面的 Y 坐标
  340.   #--------------------------------------------------------------------------
  341.   def screen_y
  342.     case self.index
  343.     when 0
  344.       return 320
  345.     when 1
  346.       return 340
  347.     when 2
  348.       return 260
  349.     when 3
  350.       return 320
  351.     else
  352.       return 1000
  353.     end
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 取得战斗画面的 Z 坐标
  357.   #--------------------------------------------------------------------------
  358.   def screen_z
  359.     # 返回计算后的队伍 Z 坐标的排列顺序
  360.     if self.index != nil
  361.       return 4 - self.index
  362.     else
  363.       return 0
  364.     end
  365.   end
  366. end
  367. class Scene_Battle
  368.   #..........................................................................
  369.   #--------------------------------------------------------------------------
  370.   # ● 返回phase
  371.   #--------------------------------------------------------------------------
  372.   def phase
  373.     return @phase
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 返回phase4_step
  377.   #--------------------------------------------------------------------------
  378.   def phase4_step
  379.     return @phase4_step
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 返回phase4_step
  383.   #--------------------------------------------------------------------------
  384.   def actor_command_active?
  385.     return @actor_command_window.active
  386.   end
  387.   #..........................................................................
  388. end
  389. class Game_Battler
  390.   #..........................................................................
  391.   #--------------------------------------------------------------------------
  392.   # ● 获取循环的动画 ID
  393.   #--------------------------------------------------------------------------  
  394.   def show_damage(value)
  395.     @show_damage_value = value
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 获取循环的动画 ID
  399.   #--------------------------------------------------------------------------
  400.   def show_damage_value
  401.     return @show_damage_value
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ● 获取循环的动画 ID
  405.   #--------------------------------------------------------------------------
  406.   def battler_ani
  407.     return @battler_ani
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● 获取循环的动画 ID
  411.   #--------------------------------------------------------------------------
  412.   def setup_battler_ani(battler_ani, once = 0)
  413.     @battler_ani = battler_ani
  414.     @once = once
  415.   end
  416.   #--------------------------------------------------------------------------
  417.   # ● 获取循环的动画 ID
  418.   #--------------------------------------------------------------------------
  419.   def setup_battler_hurt_ani(hurt)
  420.     @hurt = hurt
  421.   end  
  422.   #--------------------------------------------------------------------------
  423.   # ● 获取循环的动画 ID
  424.   #--------------------------------------------------------------------------
  425.   def setup_battler_dead_ani(over)
  426.     @over = over
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # ● 获取循环的动画 ID
  430.   #--------------------------------------------------------------------------
  431.   def battler_dead_ani
  432.     return @over
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # ● 获取循环的动画 ID
  436.   #--------------------------------------------------------------------------
  437.   def battler_ani_once
  438.     return @once
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # ● 获取循环的动画 ID
  442.   #--------------------------------------------------------------------------
  443.   def battler_hurt_ani
  444.     return @hurt
  445.   end
  446.   #..........................................................................
  447. end
  448. class Sprite_Battler < RPG::Sprite
  449.   #..........................................................................
  450.   #--------------------------------------------------------------------------
  451.   # ● 胜利图
  452.   #--------------------------------------------------------------------------
  453.   def win
  454.     if @battler_name != nil and not @battler.hidden and not @battler.dead?
  455.       @battler.setup_battler_ani(@battler_name.split(/★/)[6], 1)
  456.     end
  457.   end
  458.   #..........................................................................
  459.   #--------------------------------------------------------------------------
  460.   # ● 释放
  461.   #--------------------------------------------------------------------------
  462.   def dispose
  463.     if self.bitmap != nil
  464.       self.bitmap.dispose
  465.     end
  466.     super
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # ● 刷新画面
  470.   #--------------------------------------------------------------------------
  471.   def update
  472.     super
  473.     # 战斗者为 nil 的情况下
  474.     if @battler == nil
  475.       self.bitmap = nil
  476.       loop_animation(nil)
  477.        loop_animation1(nil)
  478.       return
  479.     end
  480.     # 文件名和色相与当前情况有差异的情况下
  481.     if @battler.battler_name != @battler_name or
  482.        @battler.battler_hue != @battler_hue
  483.       @battler_hue = @battler.battler_hue
  484.       # 获取、设置位图
  485.       @battler_name = @battler.battler_name
  486.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  487.       #.......................................................................
  488.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  489.       #.......................................................................
  490.       @width = bitmap.width
  491.       @height = bitmap.height
  492.       self.ox = @width / 2
  493.       self.oy = @height
  494.       # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  495.       if @battler.is_a?(Game_Enemy)
  496.         if @battler.dead? or @battler.hidden
  497.           self.opacity = 0
  498.         end
  499.       end
  500.     end
  501.     # 动画 ID 与当前的情况有差异的情况下
  502.     #.........................................................................
  503.     if @battler.battler_ani != @battler_ani
  504.       @battler_ani = @battler.battler_ani
  505.       loop_animation($data_animations[@battler_ani.to_i])
  506.       

  507.       
  508.      end
  509.    
  510.     #.........................................................................
  511.     # 应该被显示的角色的情况下
  512.     if @battler.is_a?(Game_Actor) and @battler_visible
  513.       # 不是主状态的时候稍稍降低点透明度
  514.       if $game_temp.battle_main_phase
  515.         self.opacity += 3 if self.opacity < 255
  516.       else
  517.         self.opacity -= 3 if self.opacity > 207
  518.       end
  519.     end
  520.     # 明灭
  521.     if @battler.blink
  522.       blink_on
  523.     else
  524.       blink_off
  525.     end
  526.     # 不可见的情况下
  527.     unless @battler_visible
  528.       # 出现 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  529.       if not @battler.hidden and not @battler.dead? and
  530.          (@battler.damage == nil or @battler.damage_pop)
  531.         if @battler.is_a?(Game_Enemy)
  532.           appear
  533.         else
  534.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  535.         end
  536.         @battler_visible = true
  537.       end
  538.     end
  539.     # 可见的情况下
  540.     if @battler_visible
  541.       # 逃跑
  542.       if @battler.hidden
  543.         $game_system.se_play($data_system.escape_se)
  544.         escape
  545.         @battler_visible = false
  546.       end
  547.       # 白色闪烁
  548.       if @battler.white_flash
  549.         whiten
  550.         @battler.white_flash = false
  551.       end
  552.       # 动画
  553.       if @battler.animation_id != 0
  554.         animation = $data_animations[@battler.animation_id]
  555.         animation(animation, @battler.animation_hit)
  556.         @battler.animation_id = 0
  557.       end
  558.       # 伤害
  559.       if @battler.damage_pop
  560.         damage(@battler.damage, @battler.critical)
  561.         @battler.damage = nil
  562.         @battler.critical = false
  563.         @battler.damage_pop = false
  564.       end
  565.       # korapusu
  566.       if @battler.damage == nil and @battler.dead?
  567.         #....................................................................
  568.         if @battler.is_a?(Game_Enemy)
  569.           $game_system.se_play($data_system.enemy_collapse_se)
  570.           #collapse
  571.         else
  572.           $game_system.se_play($data_system.actor_collapse_se)
  573.         end
  574.         #....................................................................
  575.         @battler_visible = false
  576.       end
  577.     end
  578.     # 设置活动块的坐标
  579.     self.x = @battler.screen_x
  580.     self.y = @battler.screen_y
  581.     self.z = @battler.screen_z
  582.   end
  583. end
  584. module RPG
  585.   class Sprite < ::Sprite
  586.     def damage(value, critical)
  587.       dispose_damage
  588.       if value.is_a?(Numeric)
  589.         damage_string = value.abs.to_s
  590.       else
  591.         damage_string = value.to_s
  592.       end
  593.       bitmap = Bitmap.new(160, 48)
  594.       bitmap.font.name = "Arial Black"
  595.       bitmap.font.size = 32
  596.       bitmap.font.color.set(0, 0, 0)
  597.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  598.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  599.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  600.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  601.       if value.is_a?(Numeric) and value < 0
  602.         bitmap.font.color.set(176, 255, 144)
  603.       else
  604.         bitmap.font.color.set(255, 255, 255)
  605.       end
  606.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  607.       if critical
  608.         bitmap.font.size = 20
  609.         bitmap.font.color.set(0, 0, 0)
  610.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  611.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  612.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  613.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  614.         bitmap.font.color.set(255, 255, 255)
  615.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  616.       end
  617.       @_damage_sprite = ::Sprite.new(self.viewport)
  618.       @_damage_sprite.bitmap = bitmap
  619.       @_damage_sprite.ox = 80
  620.       @_damage_sprite.oy = 20
  621.       @_damage_sprite.x = self.x
  622.       @_damage_sprite.x -= self.bitmap.width/2 if @battler.is_a?(Game_Actor)
  623.       @_damage_sprite.y = self.y - self.oy / 2
  624.       @_damage_sprite.z = 3000
  625.       @_damage_duration = 40
  626.     end
  627.   end
  628. end
  629. module RPG
  630. #--------------------------------------------------------------------------
  631. # ● 常量设定
  632. #--------------------------------------------------------------------------
  633. # 是否显示总伤害
  634. SHOW_TOTAL_DAMAGE = true
  635. # 角色受攻击时是否跳一下
  636. BATTLER_JUMP = false
  637. # 伤害美化字符串文件夹名(放在Pictures文件夹中的子文件夹)
  638. #STRING_DOCUMENTS = ""
  639. # 是否使用伤害美化效果
  640. USE_DAMAGE = true

  641. class Sprite < ::Sprite
  642.    #==========================================
  643.    # 修改说明:
  644.    # @flash_shake用来制作挨打时候跳跃
  645.    # @_damage    用来记录每次打击之后弹出数字
  646.    # @_total_damage 记录总伤害
  647.    # @_total_damage_duration 总伤害持续帧
  648.    #==========================================
  649.    #alias 66RPG_rainbow_initialize : initialize
  650.    def initialize(viewport = nil)
  651.      #66RPG_rainbow_initialize(viewport)
  652.      super(viewport)
  653.      @_whiten_duration = 0
  654.      @_appear_duration = 0
  655.      @_escape_duration = 0
  656.      @_collapse_duration = 0
  657.      @_damage_duration = 0
  658.      @_animation_duration = 0
  659.      @_blink = false
  660.      # 挨打时候跳跃
  661.      @flash_shake = 0
  662.      # 伤害记录数组
  663.      @_damage = []
  664.      # 总伤害数字
  665.      @_total_damage = 0
  666.      # 总伤害持续帧
  667.      @_total_damage_duration = 0
  668.      #.........................................................................
  669.      #记录已经发生的伤害的变量
  670.      @p_dam=0
  671.      @hits=0
  672.      ############ #小改动
  673.      #记录前一次攻击次数
  674.      @temp_hits=0
  675.      #判断是否为最后一次攻击
  676.      @last_hits=0
  677.      ############
  678.      #.........................................................................
  679.    end
  680.     def animation_set_sprites(sprites, cell_data, position)
  681.       for i in 0..15
  682.         sprite = sprites[i]
  683.         pattern = cell_data[i, 0]
  684.         if sprite == nil or pattern == nil or pattern == -1
  685.           sprite.visible = false if sprite != nil
  686.           next
  687.         end
  688.         sprite.visible = true
  689.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  690.         if position == 3
  691.           if self.viewport != nil
  692.             sprite.x = self.viewport.rect.width / 2
  693.             sprite.y = self.viewport.rect.height - 160
  694.           else
  695.             sprite.x = 320
  696.             sprite.y = 240
  697.           end
  698.         else
  699.           sprite.x = self.x - self.ox + self.src_rect.width / 2
  700.           sprite.y = self.y - self.oy + self.src_rect.height / 2
  701.           sprite.y -= self.src_rect.height / 4 if position == 0
  702.           sprite.y += self.src_rect.height / 4 if position == 2
  703.         end
  704.         sprite.x += cell_data[i, 1]
  705.         sprite.y += cell_data[i, 2]
  706.         sprite.z =1
  707.         sprite.ox = 96
  708.         sprite.oy = 96
  709.         sprite.zoom_x = cell_data[i, 3] / 100.0
  710.         sprite.zoom_y = cell_data[i, 3] / 100.0
  711.         sprite.angle = cell_data[i, 4]
  712.         sprite.mirror = (cell_data[i, 5] == 1)
  713.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  714.         sprite.blend_type = cell_data[i, 7]
  715.       end
  716.     end

  717.    #--------------------------------------------------------------------------
  718.    #美化的伤害处理
  719.    #--------------------------------------------------------------------------
  720.     def damage(value, critical)
  721.       
  722. if USE_DAMAGE == true then
  723.   
  724.       # 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看......
  725.       #dispose_damage
  726.       #清除hit数
  727.       dispose_hit
  728.       # 如果伤害值是数值
  729.       if value.is_a?(Numeric)
  730.         # 绝对值转为字符串
  731.         damage_string = value.abs.to_s
  732.       else
  733.         # 转为字符串
  734.         damage_string = value.to_s
  735.       end
  736.       # 初始化位图
  737.       bitmap = Bitmap.new(162, 64)
  738.       bitmap.font.name = ["华文行楷","黑体", "宋体"]
  739.       bitmap.font.size = 32
  740.       # 伤害值是数值的情况下
  741.       if value.is_a?(Numeric)
  742.         # 分割伤害值字符串
  743.         damage_array = damage_string.scan(/./)
  744.         damage_x = 81 - damage_string.size * 9
  745.         # 伤害值为负的情况下
  746.         if value < 0
  747.           # 调用回复数字表
  748.           rect_y = 32
  749.         else
  750.           # 调用伤害数字表
  751.           rect_y = 0
  752.         end
  753.         # 循环伤害值字符串
  754.         for char in damage_array
  755.           number = char.to_i
  756.           # 显示伤害数字
  757.           bitmap.blt(damage_x, 32, RPG::Cache.picture( "Damage"),#"Damagenew"),
  758.           Rect.new(number * 18, rect_y, 18, 32))
  759.           # 后移一位
  760.           damage_x += 18
  761.         end
  762.       # 伤害值不是数值的情况
  763.       else
  764.         # 如果伤害值不是 Miss
  765.         unless value == "Miss"
  766.           # 系统默认描画字符串
  767.           bitmap.font.color.set(0, 0, 0)
  768.           bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
  769.           bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
  770.           bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
  771.           bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
  772.           bitmap.font.color.set(255, 255, 255)
  773.           bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
  774.         # Miss 的情况下
  775.         else
  776.           # 显示未击中图画
  777.           bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
  778.         end
  779.       end
  780.       # 会心一击标志打开的情况
  781.       if critical
  782.         #会心一击伤害效果
  783. ###########################################################
  784.        $game_screen.start_flash(Color.new(255,255,255,255),5)
  785. ###########################################################
  786.         # 显示会心一击图画
  787.         bitmap.blt(36, 0, RPG::Cache.picture( "Damage"), Rect.new(0, 64, 90, 32))
  788.       end
  789.       
  790. else
  791.       
  792.      #.........................................................................
  793.      #清除hit数
  794.      dispose_hit
  795.      #.........................................................................
  796.      if value.is_a?(Numeric)
  797.        damage_string = value.abs.to_s
  798.      else
  799.        damage_string = value.to_s
  800.      end
  801.      bitmap = Bitmap.new(160, 48)
  802.      bitmap.font.name = "Arial Black"
  803.      bitmap.font.size = 32
  804.      bitmap.font.color.set(0, 0, 0)
  805.      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  806.      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  807.      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  808.      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  809.      #=======================================
  810.      # 修改:颜色
  811.      #=======================================
  812.      if value.is_a?(Numeric) and value < 0
  813.        bitmap.font.color.set(176, 255, 144)
  814.      else
  815.        bitmap.font.color.set(255, 55, 55)
  816.      end
  817.      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  818.      if critical
  819.        #会心一击伤害效果
  820. ###########################################################
  821.        $game_screen.start_flash(Color.new(255,255,255,255),5)
  822. ###########################################################
  823.        bitmap.font.size = 20
  824.        bitmap.font.color.set(0, 0, 0)
  825.        bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  826.        bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  827.        bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  828.        bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  829.        bitmap.font.color.set(255, 255, 255)
  830.        bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  831.      end
  832.      
  833. end
  834.    
  835.      # 伤害值定位     
  836.      @_damage_sprite = ::Sprite.new#(self.viewport)
  837.      @_damage_sprite.bitmap = bitmap
  838.      @_damage_sprite.ox = 80
  839.      @_damage_sprite.oy = 20
  840.      @_damage_sprite.x = self.x
  841.      @_damage_sprite.y = self.y - self.oy / 2
  842.      @_damage_sprite.z = 3000
  843.      @_damage_duration = 40
  844.      #=======================================
  845.      # 修改:推入新的伤害
  846.      #=======================================
  847.      @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  848.      # 总伤害处理
  849.      make_total_damage(value)
  850.      
  851.      
  852.      
  853.     end
  854.    #--------------------------------------------------------------------------
  855.    # ● 返回 @hits
  856.    #--------------------------------------------------------------------------
  857.    def get_hit
  858.      return @hits
  859.    end
  860.    #--------------------------------------------------------------------------
  861.    # ● hit数的美化描绘
  862.     # ● hit数的美化描绘
  863.    #--------------------------------------------------------------------------
  864.    #..........................................................................
  865.    def hit
  866.      # 如果伤害值是数值
  867.      # 转为字符串
  868.      value=@hits
  869.      hits_string = value.to_s
  870.      # 初始化位图
  871.      bitmap = Bitmap.new(320, 64)
  872.      bitmap.font.name = "Arial Black"
  873.      bitmap.font.size = 32
  874.      # 分割伤害值字符串
  875.      hits_array = hits_string.scan(/./)
  876.      hits_x = - 36.2#hits_string.size * 18.1 # 81 - hits_string.size * 18.1
  877.      rect_y = 0
  878.      # 循环伤害值字符串
  879.      for char in hits_array
  880.        # 后移一位
  881.        hits_x += 36.2
  882.        number = char.to_i
  883.        # 显示伤害数字
  884.        bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
  885.        Rect.new(number * 36.2, rect_y, 36.2, 50))
  886.      end
  887.      hits_x += 18.1
  888.      bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
  889.                 Rect.new(0, -21, 90, 50))
  890.      # 伤害值定位
  891.      @_hits_sprite = ::Sprite.new(self.viewport)
  892.      @_hits_sprite.bitmap = bitmap
  893.      @_hits_sprite.x = 560 - hits_string.size * 36.2
  894.      @_hits_sprite.y = 70
  895.      @_hits_sprite.z = 3000
  896.      @_hits_duration = 40
  897.    end
  898.    #.......................................................................................
  899.    #--------------------------------------------------------------------------
  900.    # ● 美化的总伤害处理
  901.    #--------------------------------------------------------------------------
  902.    def make_total_damage(value)
  903.      
  904. if USE_DAMAGE == true then     
  905.      
  906.      if value.is_a?(Numeric)# and SHOW_TOTAL_DAMAGE
  907.        @_total_damage += value
  908.         # 绝对值转为字符串
  909.         damage_string = @_total_damage.abs.to_s
  910.       else
  911.         return
  912.       end
  913. #####################################################小改动
  914.      if SHOW_TOTAL_DAMAGE
  915. #####################################################
  916.       # 初始化位图
  917.       bitmap = Bitmap.new(300, 150)
  918.       bitmap.font.name = "Arial Black"
  919.       bitmap.font.size = 30
  920.       # 伤害值是数值的情况下
  921.       if value.is_a?(Numeric)
  922.         # 分割伤害值字符串
  923.         damage_array = damage_string.scan(/./)
  924.         damage_x = 40 - damage_string.size * 9
  925.         # 伤害值为负的情况下
  926.         if value < 0
  927.           # 调用回复数字表
  928.           name=  "Number3"
  929.         else
  930.           # 调用伤害数字表
  931.           name=   "Number2"
  932.         end
  933.         # 循环伤害值字符串
  934.         for char in damage_array
  935.           number = char.to_i
  936.           # 显示伤害数字
  937.           bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
  938.           Rect.new(number * 30, 0, 30, 50))
  939.           # 后移一位
  940.           damage_x += 26
  941.         end
  942. #####################################################小改动
  943.      end
  944. #####################################################
  945.       end
  946.       
  947. else
  948.             
  949.    #--------------------------------------------------------------------------
  950.    # ● 总伤害处理
  951.    #--------------------------------------------------------------------------
  952.      if value.is_a?(Numeric)# and SHOW_TOTAL_DAMAGE
  953.        @_total_damage += value
  954.      else
  955.        return
  956.      end
  957. #####################################################小改动
  958.      if SHOW_TOTAL_DAMAGE
  959. #####################################################
  960.      bitmap = Bitmap.new(300, 150)
  961.      bitmap.font.name = "Arial Black"
  962.      bitmap.font.size = 48
  963.      bitmap.font.color.set(0, 0, 0)
  964.      bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
  965.      if @_total_damage < 0
  966.        bitmap.font.color.set(80, 255, 00)
  967.      else
  968.        bitmap.font.color.set(255, 140, 0)
  969.      end
  970.      bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
  971. #####################################################小改动
  972.      end
  973. #####################################################
  974. end

  975.      if @_total_damage_sprite.nil?
  976.        @_total_damage_sprite = ::Sprite.new#(self.viewport)
  977.        @_total_damage_sprite.ox = 80
  978.        @_total_damage_sprite.oy = 20
  979.        @_total_damage_sprite.z = 3000
  980.      end
  981.      @_total_damage_sprite.bitmap = bitmap
  982.      @_total_damage_sprite.zoom_x = 1.5
  983.      @_total_damage_sprite.zoom_y = 1.5
  984.      @_total_damage_sprite.x = self.x
  985.      @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  986.      @_total_damage_sprite.z = 3001
  987.      #.........................................................................
  988.      @_total_damage_duration = 40
  989.      #.........................................................................
  990.      #.........................................................................
  991.      #hit数描绘
  992.      @hits+=1
  993.      hit
  994.      #.........................................................................
  995.    end
  996.    def animation(animation, hit, battler_damage="", battler_critical=false)
  997.      dispose_animation      
  998.      #=======================================
  999.      # 修改:记录伤害和critical
  1000.      #=======================================
  1001.      @battler_damage = battler_damage
  1002.      @battler_critical = battler_critical
  1003.      @_animation = animation
  1004.      return if @_animation == nil
  1005.      @_animation_hit = hit
  1006.      @_animation_duration = @_animation.frame_max
  1007.      animation_name = @_animation.animation_name
  1008.      animation_hue = @_animation.animation_hue
  1009.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  1010.      #=======================================
  1011.      # 修改:计算总闪光权限值
  1012.      #=======================================
  1013.      for timing in @_animation.timings
  1014.        quanzhong = animation_process_timing(timing, @_animation_hit,true)
  1015.        @all_quanzhong += quanzhong
  1016.        # 记录最后一次闪光
  1017.        @_last_frame = timing.frame if quanzhong != 0
  1018.      end
  1019.      #.........................................................................
  1020.      @last_frame = @_last_frame
  1021.      #.........................................................................
  1022.      if @@_reference_count.include?(bitmap)
  1023.        @@_reference_count[bitmap] += 1
  1024.      else
  1025.        @@_reference_count[bitmap] = 1
  1026.      end
  1027.      #=======================================
  1028.      # 修改:行动方动画不显示伤害
  1029.      #=======================================
  1030.      if $scene.is_a?(Scene_Battle)
  1031.        if $scene.animation1_id == @battler.animation_id
  1032.          @battler_damage = ""
  1033.        end
  1034.      end
  1035.      @_animation_sprites = []
  1036.      if @_animation.position != 3 or not @@_animations.include?(animation)
  1037.        for i in 0..15
  1038.          sprite = ::Sprite.new(self.viewport)
  1039.          sprite.bitmap = bitmap
  1040.          sprite.visible = false
  1041.          @_animation_sprites.push(sprite)
  1042.        end
  1043.        unless @@_animations.include?(animation)
  1044.          @@_animations.push(animation)
  1045.        end
  1046.      end
  1047.      update_animation
  1048.    end
  1049.    #=======================================
  1050.    # 修改:更换清除伤害的算法,以防万一
  1051.    #       本内容在脚本中没有使用过
  1052.    #=======================================
  1053.    def dispose_damage
  1054.      for damage in @_damage.reverse
  1055.        damage[0].bitmap.dispose
  1056.        damage[0].dispose
  1057.        @_damage.delete(damage)
  1058.      end
  1059.      @_total_damage = 0
  1060.      @_last_frame = -1
  1061.      if @_total_damage_sprite != nil
  1062.        @_total_damage_duration = 0
  1063.        @_total_damage_sprite.bitmap.dispose
  1064.        @_total_damage_sprite.dispose
  1065.        @_total_damage_sprite = nil
  1066.      end
  1067.    end
  1068.    #=======================================
  1069.    # 清除hit数
  1070.    #=======================================
  1071.    #...........................................................................
  1072.    def dispose_hit
  1073.      if @_hits_sprite != nil
  1074.        @_hits_sprite.bitmap.dispose
  1075.        @_hits_sprite.dispose
  1076.        @_hits_sprite = nil
  1077.      end
  1078.    end
  1079.    #...........................................................................
  1080.    def dispose_animation
  1081.      #=======================================
  1082.      # 修改:清除记录的伤害,清除权重记录
  1083.      #=======================================
  1084.      @battler_damage = nil
  1085.      @battler_critical = nil
  1086.      @all_quanzhong = 1
  1087.      @_total_damage = 0
  1088.      @_last_frame = -1
  1089.      #.........................................................................
  1090.      @hits = 0
  1091.      #.........................................................................
  1092.      if @_animation_sprites != nil
  1093.        sprite = @_animation_sprites[0]
  1094.        if sprite != nil
  1095.          @@_reference_count[sprite.bitmap] -= 1
  1096.          if @@_reference_count[sprite.bitmap] == 0
  1097.            sprite.bitmap.dispose
  1098.          end
  1099.        end
  1100.        for sprite in @_animation_sprites
  1101.          sprite.dispose
  1102.        end
  1103.        @_animation_sprites = nil
  1104.        @_animation = nil
  1105.      end
  1106.    end
  1107.    def update
  1108.      super
  1109.      if @_whiten_duration > 0
  1110.        @_whiten_duration -= 1
  1111.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  1112.      end
  1113.      if @_appear_duration > 0
  1114.        @_appear_duration -= 1
  1115.        self.opacity = (16 - @_appear_duration) * 16
  1116.      end
  1117.      if @_escape_duration > 0
  1118.        @_escape_duration -= 1
  1119.        self.opacity = 256 - (32 - @_escape_duration) * 10
  1120.      end
  1121.      if @_collapse_duration > 0
  1122.        @_collapse_duration -= 1
  1123.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  1124.      end
  1125.      #=======================================
  1126.      # 修改:更新算法,更新弹出
  1127.      #=======================================
  1128.      if @_damage_duration > 0
  1129.        @_damage_duration -= 1
  1130.        for damage in @_damage
  1131.          damage[0].x = self.x + self.viewport.rect.x -
  1132.                        self.ox + self.src_rect.width / 2 +
  1133.                        (40 - damage[1]) * damage[3] / 10
  1134.          damage[0].y -= damage[4]+damage[1]/10
  1135.          damage[0].opacity = damage[1]*20
  1136.          damage[1] -= 1
  1137.          if damage[1]==0
  1138.            damage[0].bitmap.dispose
  1139.            damage[0].dispose
  1140.            @_damage.delete(damage)
  1141.            next
  1142.          end
  1143.        end
  1144.      end
  1145.      #=======================================
  1146.      # 添加:弹出总伤害
  1147.      #=======================================
  1148.      if @_total_damage_duration > 0
  1149.        @_total_damage_duration -= 1
  1150.        @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  1151.        if @_total_damage_sprite.zoom_x > 1.0
  1152.          @_total_damage_sprite.zoom_x -= 0.05
  1153.        end
  1154.        if @_total_damage_sprite.zoom_y > 1.0
  1155.          @_total_damage_sprite.zoom_y -= 0.05
  1156.        end
  1157.        @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  1158.        #......................................................................
  1159.        if @_total_damage_duration <= 7 and @_total_damage_duration > 0
  1160.          @_hits_sprite.opacity -= 32
  1161.          @_hits_sprite.x += 1
  1162.        end
  1163.        #......................................................................
  1164.        if @_total_damage_duration <= 0
  1165.          #.....................................................................
  1166.          dispose_hit
  1167. ##########################
  1168.          @_total_damage = 0
  1169. ##########################
  1170.          #.....................................................................
  1171.          @_total_damage = 0
  1172.          @_total_damage_duration = 0
  1173. #####################################################小改动
  1174.          if SHOW_TOTAL_DAMAGE
  1175.          @_total_damage_sprite.bitmap.dispose
  1176.          end
  1177. #####################################################
  1178.          @_total_damage_sprite.dispose
  1179.          @_total_damage_sprite = nil
  1180.        end
  1181.      end
  1182.      #=======================================
  1183.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  1184.        @_animation_duration -= 1
  1185.        update_animation
  1186.      end
  1187.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  1188.        update_loop_animation
  1189.        @_loop_animation_index += 1
  1190.        #......................................................................
  1191.        @loop_animation_once = 0
  1192.        @loop_animation_once = 1 if @once == 1 and @_loop_animation_index == @_loop_animation.frame_max
  1193.        #......................................................................
  1194.        @_loop_animation_index %= @_loop_animation.frame_max
  1195.      end
  1196.      
  1197.      if @_loop_animation1 != nil and (Graphics.frame_count % 2 == 0)
  1198.         update_loop_animation1
  1199.         @_loop_animation1_index += 1
  1200.         @_loop_animation1_index %= @_loop_animation1.frame_max
  1201.       end
  1202.       
  1203.      if @_blink
  1204.        @_blink_count = (@_blink_count + 1) % 32
  1205.        if @_blink_count < 16
  1206.          alpha = (16 - @_blink_count) * 6
  1207.        else
  1208.          alpha = (@_blink_count - 16) * 6
  1209.        end
  1210.        self.color.set(255, 255, 255, alpha)
  1211.      end
  1212.      @@_animations.clear
  1213.    end
  1214.    #..........................................................................
  1215.    def loop_animation_once
  1216.      return @_loop_animation_once
  1217.    end
  1218.    #..........................................................................
  1219.    def update_animation
  1220.      if @_animation_duration > 0
  1221.        frame_index = @_animation.frame_max - @_animation_duration
  1222.        @frame_index = frame_index
  1223.        cell_data = @_animation.frames[frame_index].cell_data
  1224.        position = @_animation.position
  1225.        animation_set_sprites(@_animation_sprites, cell_data, position)
  1226.        #=======================================
  1227.        # 修改:弹出伤害,权重计算
  1228.        #=======================================
  1229.        for timing in @_animation.timings
  1230.          if timing.frame == frame_index
  1231.            t = 1.0 * animation_process_timing(timing, @_animation_hit)            
  1232.            #p t,"当前权重", @all_quanzhong,"总权重"
  1233.            if @battler_damage.is_a?(Numeric) and t != 0
  1234.              t *= @battler_damage
  1235.              t /= @all_quanzhong
  1236.              t = t.to_i
  1237.              #在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中★★★★★★★★★★★★★★★★★★★★★★★★★★
  1238.              if frame_index != @_last_frame
  1239.              @p_dam+= t
  1240.              end
  1241.              #p @p_dam,"已发生伤害",@battler_damage,"总伤害"(调试用)★★★★★★★★★★★★★★★★★★★★★★★★★★
  1242.              #闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)★★★★★★★★★★★★★★★★★★★★★★★★★★
  1243.              if frame_index == @_last_frame
  1244.                t= @battler_damage-@p_dam
  1245.              end
  1246.              #p t,"当前伤害",@battler_damage,"总伤害"
  1247.              # 最后一次闪光的话,伤害修正
  1248.              if frame_index == @_last_frame
  1249.                @_total_damage = @battler_damage - t
  1250.                @p_dam=0      #已经发生的伤害归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  1251.             end
  1252.              #p t,@battler_damage,@all_quanzhong
  1253.              damage(t,@battler_critical)
  1254.             #连击次数归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  1255.             if frame_index == @_last_frame
  1256.                       ############ #小改动
  1257.                       @last_hits=1
  1258.                       @temp_hits=0
  1259.                       ############
  1260.                       @hits=0
  1261.             end
  1262.            # 防止重复播放miss
  1263.            elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  1264.              damage(@battler_damage,@battler_critical)
  1265.            end
  1266.          end
  1267.        end
  1268.      else
  1269.        dispose_animation
  1270.      end
  1271.    end
  1272.    #=======================================
  1273.    # 修改:敌人跳跃的功能 + 添加返回数值
  1274.    #=======================================
  1275.    def update_loop_animation
  1276.      frame_index = @_loop_animation_index
  1277.      cell_data = @_loop_animation.frames[frame_index].cell_data
  1278.      position = @_loop_animation.position
  1279.      #·改·
  1280.      if @wait_count.to_i <= 0
  1281.        @wait_count = 0
  1282.        animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  1283.      else
  1284.        @wait_count -= 1
  1285.        for sprite in @_loop_animation_sprites
  1286.          sprite.visible = false
  1287.        end
  1288.      end
  1289.      if @wait_flash.to_i <= 0
  1290.        @wait_flash = 0
  1291.      else
  1292.        @wait_flash -= 1
  1293.        for sprite in @_loop_animation_sprites
  1294.          sprite.blend_type = 1
  1295.        end
  1296.      end
  1297.      #·改·
  1298.      for timing in @_loop_animation.timings
  1299.        if timing.frame == frame_index
  1300.          animation_process_timing(timing, true)
  1301.        end
  1302.      end
  1303.    end
  1304.    #=======================================
  1305.    # 修改:敌人跳跃的功能 + 添加返回数值
  1306.    #=======================================
  1307.    def loop_animation(animation)
  1308.      return if animation == @_loop_animation
  1309.      dispose_loop_animation
  1310.   
  1311.      @_loop_animation = animation
  1312.      return if @_loop_animation == nil
  1313.      @_loop_animation_index = 0
  1314.      animation_name = @_loop_animation.animation_name
  1315.      animation_hue = @_loop_animation.animation_hue
  1316.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  1317.      if @@_reference_count.include?(bitmap)
  1318.        @@_reference_count[bitmap] += 1
  1319.      else
  1320.        @@_reference_count[bitmap] = 1
  1321.      end
  1322.      @_loop_animation_sprites = []
  1323.      for i in 0..15
  1324.        sprite = ::Sprite.new
  1325.        sprite.bitmap = bitmap
  1326.        sprite.visible = false
  1327.        @_loop_animation_sprites.push(sprite)
  1328.      end
  1329.      update_loop_animation
  1330.    end
  1331.    #=======================================
  1332.    # 修改:敌人跳跃的功能 + 添加返回数值
  1333.    #=======================================
  1334.     def animation_process_timing(timing, hit,dontflash=false)
  1335.       if (timing.condition == 0) or
  1336.          (timing.condition == 1 and hit == true) or
  1337.          (timing.condition == 2 and hit == false)
  1338.         unless dontflash
  1339.           if timing.se.name != ""
  1340.             se = timing.se
  1341.             Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  1342.           end
  1343.         end
  1344.         case timing.flash_scope
  1345.         when 1
  1346.           unless dontflash
  1347.             self.flash(timing.flash_color, timing.flash_duration * 2)
  1348.             #....................................................................
  1349.             @wait_flash = timing.flash_duration
  1350.             #....................................................................
  1351.             if @_total_damage >0
  1352.               @flash_shake_switch = true
  1353.               @flash_shake = 10
  1354.             end
  1355.           end
  1356.           return timing.flash_color.alpha * timing.flash_duration
  1357.         when 2
  1358.           unless dontflash
  1359.             if self.viewport != nil
  1360.               self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  1361.               return timing.flash_color.alpha * timing.flash_duration
  1362.             end
  1363.           end
  1364.         when 3
  1365.           unless dontflash
  1366.             self.flash(nil, timing.flash_duration * 2)
  1367.             #@_loop_animation_count = 1
  1368.             #·改·
  1369.             @wait_count = timing.flash_duration
  1370.             #·改·
  1371.           end
  1372.           return timing.flash_color.alpha * timing.flash_duration
  1373.         end
  1374.       end      
  1375.       return 0
  1376.     end   
  1377. end
  1378. end
  1379. #==============================================================================
  1380. # ■ Sprite_Battler
  1381. #==============================================================================
  1382. class Sprite_Battler < RPG::Sprite
  1383. #--------------------------------------------------------------------------
  1384. # ● 初始化对像
  1385. #    添加跳跃记录
  1386. #--------------------------------------------------------------------------
  1387. def initialize(viewport, battler = nil)
  1388.   super(viewport)
  1389.   @battler = battler
  1390.   @battler_visible = false
  1391.   @flash_shake_switch = true

  1392.   #........................................................................
  1393.   @once = 0
  1394.   @frame_index = -1
  1395.   @last_frame = 0
  1396.   #........................................................................
  1397. end
  1398. #--------------------------------------------------------------------------
  1399. # ● 刷新画面
  1400. #    增添跳跃功能
  1401. #--------------------------------------------------------------------------
  1402. def update
  1403.   super
  1404.   # 战斗者为 nil 的情况下
  1405.   if @battler == nil
  1406.     self.bitmap = nil
  1407.     loop_animation(nil)
  1408.    loop_animation1(nil)
  1409.     return
  1410.   end
  1411.   # 文件名和色相与当前情况有差异的情况下
  1412.   if @battler.battler_name != @battler_name or
  1413.      @battler.battler_hue != @battler_hue
  1414.     # 获取、设置位图
  1415.     @battler_name = @battler.battler_name
  1416.     @battler_hue = @battler.battler_hue
  1417.     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  1418.     #.......................................................................
  1419.     if not @battler.hidden and not @battler.dead?
  1420.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1421.     end
  1422.     #.......................................................................
  1423.     @width = bitmap.width
  1424.     @height = bitmap.height
  1425.     self.ox = @width / 2
  1426.     self.oy = @height
  1427.   end
  1428.   #.......................................................................
  1429.   update_actor_animation
  1430.   update_enemy_animation
  1431.   #.......................................................................
  1432.   # 动画 ID 与当前的情况有差异的情况下
  1433.   #.........................................................................
  1434.   if @battler.is_a?(Game_Enemy)
  1435.     if @once == 1 and @loop_animation_once == 1 and
  1436.        @battler.battler_dead_ani == 1
  1437.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[5])
  1438.     elsif @once == 1 and @loop_animation_once == 1 and $scene.phase != 5
  1439.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1440.     end
  1441.   end
  1442.   if @battler.is_a?(Game_Actor)
  1443.     ####################################################################
  1444.     if @once == 1 and @loop_animation_once == 1 and $scene.phase != 5 and
  1445.        @battler.battler_dead_ani == 1 and @battler.dead?
  1446.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[5])
  1447.     #######################################################################
  1448.     elsif @once == 1 and @loop_animation_once == 1 and $scene.phase != 5
  1449.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1450.       #################################################################
  1451.       $fangyu = 0
  1452.       @battler.setup_battler_dead_ani(0)
  1453.       ########################################################
  1454.     elsif @once == 1 and @loop_animation_once == 1 and $scene.phase == 5 and
  1455.           not @battler.dead?
  1456.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[7])
  1457.       ######################################################
  1458.       $fangyu = 0
  1459.       @battler.setup_battler_dead_ani(0)
  1460.       ######################################################
  1461.     end
  1462.   end
  1463.   
  1464. if @battler.damage == nil and
  1465.        @battler.state_animation_id != @state_animation_id
  1466.       @state_animation_id = @battler.state_animation_id
  1467.      # loop_animation($data_animations[@state_animation_id])
  1468.        loop_animation1($data_animations[@state_animation_id])
  1469.     end

  1470.    
  1471.   if @battler.battler_ani != @battler_ani
  1472.     @battler_ani = @battler.battler_ani
  1473.     @once = @battler.battler_ani_once
  1474.     loop_animation($data_animations[@battler_ani.to_i])
  1475.     # @battler.state_animation_id != @state_animation_id
  1476.       #@state_animation_id = @battler.state_animation_id
  1477.      # loop_animation($data_animations[@state_animation_id])
  1478.       # loop_animation1($data_animations[@state_animation_id])
  1479.      
  1480.    
  1481.   end
  1482.   #.........................................................................
  1483.   # 明灭
  1484.   if @battler.blink
  1485.     blink_on
  1486.   else
  1487.     blink_off
  1488.   end
  1489.   # 不可见的情况下
  1490.   unless @battler_visible
  1491.     # 出现
  1492.     if not @battler.hidden and not @battler.dead? and
  1493.        (@battler.damage == nil or @battler.damage_pop)
  1494.       #.......................................................................
  1495.       if @battler.is_a?(Game_Enemy)
  1496.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1497.         #appear
  1498.       else
  1499.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1500.       end
  1501.       #.......................................................................
  1502.       @battler_visible = true
  1503.     end
  1504.   end
  1505.   # 可见的情况下
  1506.   if @battler_visible
  1507.     # 逃跑
  1508.     if @battler.hidden
  1509.       $game_system.se_play($data_system.escape_se)
  1510.       escape
  1511.       @battler_visible = false
  1512.     end
  1513.     # 白色闪烁
  1514.     if @battler.white_flash
  1515.       whiten
  1516.       @battler.white_flash = false
  1517.     end
  1518.     # 动画
  1519.     if @battler.animation_id != 0
  1520.       animation = $data_animations[@battler.animation_id]
  1521.       animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
  1522.       # animation(animation, @battler.animation_hit)
  1523.       @battler.animation_id = 0
  1524.     end
  1525.     # 伤害
  1526.     if @battler.damage_pop
  1527.       @battler.damage = nil
  1528.       @battler.critical = false
  1529.       @battler.damage_pop = false
  1530.     end
  1531.     # korapusu
  1532.     if @battler.damage == nil and @battler.dead?
  1533.       if @battler.is_a?(Game_Enemy)
  1534.         if @battler.battler_dead_ani != 1
  1535.           #p "Battler Death Error"
  1536.           $game_system.se_play($data_system.enemy_collapse_se)
  1537.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1538.           @battler.setup_battler_dead_ani(1)
  1539.         end
  1540.         #.....................................................................
  1541.         collapse
  1542.         #.....................................................................
  1543.       else
  1544.         #.....................................................................
  1545.         if @battler.battler_dead_ani != 1
  1546.           #p "Battler Death Error"
  1547.           $game_system.se_play($data_system.enemy_collapse_se)
  1548.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1549.           @battler.setup_battler_dead_ani(1)
  1550.         end
  1551.         #.....................................................................
  1552.       end
  1553.       @battler_visible = false
  1554.     end
  1555.   end
  1556.   # 设置活动块的坐标
  1557.   if @flash_shake_switch == true
  1558.     self.x = @battler.screen_x
  1559.     self.y = @battler.screen_y
  1560.     self.z = @battler.screen_z
  1561.     @flash_shake_switch = false
  1562.   end
  1563.   if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
  1564.     if @battler.is_a?(Game_Enemy)
  1565.       case @flash_shake
  1566.       when 9..10
  1567.         self.x -=4
  1568.         self.y -=4
  1569.         self.z = @battler.screen_z
  1570.       when 6..8
  1571.         self.x -=2
  1572.         self.y -=2
  1573.         self.z = @battler.screen_z
  1574.       when 3..5
  1575.         self.x +=2
  1576.         self.y +=2
  1577.         self.z = @battler.screen_z
  1578.       when 1..2
  1579.         self.x +=4
  1580.         self.y +=4
  1581.         self.z = @battler.screen_z
  1582.       end
  1583.     end
  1584.     if @battler.is_a?(Game_Actor)
  1585.       case @flash_shake
  1586.       when 9..10
  1587.         self.x +=4
  1588.         self.y +=4
  1589.         self.z = @battler.screen_z
  1590.       when 6..8
  1591.         self.x +=2
  1592.         self.y +=2
  1593.         self.z = @battler.screen_z
  1594.       when 3..5
  1595.         self.x -=2
  1596.         self.y -=2
  1597.         self.z = @battler.screen_z
  1598.       when 1..2
  1599.         self.x -=4
  1600.         self.y -=4
  1601.         self.z = @battler.screen_z
  1602.       end
  1603.     end
  1604.    @flash_shake -= 1
  1605.   end
  1606. end
  1607. end

  1608. #==============================================================================
  1609. # ■ Scene_Battle
  1610. #------------------------------------------------------------------------------
  1611. #  处理战斗画面的类。
  1612. #==============================================================================

  1613. class Scene_Battle
  1614. #--------------------------------------------------------------------------
  1615. # ● 定义实例变量
  1616. #--------------------------------------------------------------------------
  1617. attr_reader   :animation1_id                    # 行动方动画ID
  1618. end
  1619. class Sprite_Battler < RPG::Sprite
  1620.   #--------------------------------------------------------------------------
  1621.   # ● 处理角色动作
  1622.   #--------------------------------------------------------------------------
  1623.   def update_actor_animation
  1624.     if @battler.is_a?(Game_Actor)
  1625.       if @battler.show_damage_value != nil
  1626.         self.damage(@battler.show_damage_value, false)
  1627.         @battler.show_damage(nil)
  1628.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1629.         @battler.setup_battler_hurt_ani(1)
  1630.       end
  1631.       if @battler.current_action.kind == 0 and @battler.current_action.basic == 1 and @battler.show_damage_value != nil
  1632.         # 防御的时候
  1633.         if @hits > @temp_hits and not @battler.dead?
  1634.           ############ #小改动
  1635.           @temp_hits+=1
  1636.           ############
  1637.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[2], 1)
  1638.           @battler.setup_battler_hurt_ani(1)
  1639.           #################################################################
  1640.         elsif @last_hits == 1 and not @battler.dead?
  1641.           ############ #小改动
  1642.           @last_hits = 0
  1643.           ############
  1644.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[2], 1)
  1645.           @battler.setup_battler_hurt_ani(1)
  1646.           #################################################################
  1647.         elsif @frame_index != -1 and @frame_index != @last_frame and not @battler.dead? and [email protected]_a?(Numeric)
  1648.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[2], 1)
  1649.           @battler.setup_battler_hurt_ani(1)
  1650.           #################################################################
  1651.         elsif @last_hits == 1 and not @battler.dead? and [email protected]_a?(Numeric)
  1652.           ############ #小改动
  1653.           @last_hits = 0
  1654.           ############
  1655.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[2], 1)
  1656.           @battler.setup_battler_hurt_ani(1)
  1657.           #################################################################
  1658.         end
  1659.       else
  1660.         # 单回合只有一次攻击
  1661.        if @last_hits == 1 and not @battler.dead? and @battler.damage.is_a?(Numeric) and @battler.damage > 0 and $fangyu != 1
  1662.           ############ #小改动
  1663.           @last_hits = 0
  1664.           ############
  1665.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1666.           @battler.setup_battler_hurt_ani(1)
  1667.           #################################################################
  1668.         # 单回合多次攻击
  1669.        elsif @hits > @temp_hits and @frame_index != @last_frame and not @battler.dead? and @battler.damage.is_a?(Numeric) and @battler.damage > 0 and $fangyu != 1
  1670.           ############ #小改动
  1671.           @temp_hits+=1
  1672.           ############
  1673.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1674.           @battler.setup_battler_hurt_ani(1)
  1675.         ########################################################################
  1676.         # 死亡之前攻击
  1677.        elsif @hits > @temp_hits and @frame_index != @last_frame and @battler.damage.is_a?(Numeric) and @battler.damage > 0 and $fangyu != 1 and @battler.dead? and @battler.battler_dead_ani != 1
  1678.           ############ #小改动
  1679.           @temp_hits+=1
  1680.           ############
  1681.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1682.           @battler.setup_battler_hurt_ani(1)
  1683.           #################################################################
  1684.         # 闪避的回合
  1685.        elsif !@battler_damage.is_a?(Numeric) and @last_hits == 1 and @frame_index == @last_frame
  1686.           @last_hits = 0
  1687.           #################################################################
  1688.         # 无伤害的攻击
  1689.         elsif @battler_damage.is_a?(Numeric) and @battler.damage == 0 and @last_hits == 1 and @frame_index == @last_frame
  1690.           @last_hits = 0
  1691.           #################################################################
  1692.         # 死亡判定
  1693.        elsif @last_hits == 1 and @frame_index == @last_frame and @battler.dead? and @battler.battler_dead_ani != 1
  1694. #          for actor in $game_party.actors
  1695. #默认的话  如果死亡  其他角色添加第六号状态
  1696. #《石焚刃暖》里 是狂暴状态
  1697. #            if @battler != actor
  1698. #              actor.add_state(6)
  1699. #            end
  1700. #          end
  1701.           @last_hits = 0
  1702.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1703.           @battler.setup_battler_dead_ani(1)
  1704.           #################################################################
  1705.         # 胜利判定
  1706.        elsif $scene.phase == 5 and @once == 0 and @battler_name != nil and not @battler.hidden and not @battler.dead? and $game_temp.battle_proc == nil
  1707.              @once = 1
  1708.              @battler.setup_battler_ani(@battler_name.split(/★/)[6], 1)
  1709.         end
  1710.       end
  1711.     end
  1712.   end
  1713.   #--------------------------------------------------------------------------
  1714.   # ● 处理敌人动作
  1715.   #--------------------------------------------------------------------------
  1716.   def update_enemy_animation
  1717.     if @battler.is_a?(Game_Enemy)
  1718.       if @battler.show_damage_value != nil
  1719.         self.damage(@battler.show_damage_value, false)
  1720.         @battler.show_damage(nil)
  1721.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1722.         @battler.setup_battler_hurt_ani(1)
  1723.       end
  1724.       if @battler.current_action.kind == 0 and @battler.current_action.basic == 1
  1725.       else
  1726.         # 单回合只有一次攻击
  1727.         if @last_hits == 1 and not @battler.dead? and @battler.damage.is_a?(Numeric) and @battler.damage > 0
  1728.           ############ #小改动
  1729.           @last_hits = 0
  1730.           ############
  1731.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1732.           @battler.setup_battler_hurt_ani(1)
  1733.           #################################################################
  1734.         # 单回合多次攻击
  1735.        elsif @hits > @temp_hits and @frame_index != @last_frame and not @battler.dead? and @battler.damage.is_a?(Numeric) and @battler.damage > 0
  1736.           ############ #小改动
  1737.           @temp_hits+=1
  1738.           ############
  1739.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1740.           @battler.setup_battler_hurt_ani(1)
  1741.           #################################################################
  1742.         # 死亡之前攻击
  1743.        elsif @hits > @temp_hits and @frame_index != @last_frame and @battler.damage.is_a?(Numeric) and @battler.damage > 0 and @battler.dead? and @battler.battler_dead_ani != 1
  1744.           ############ #小改动
  1745.           @temp_hits+=1
  1746.           ############
  1747.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1748.           @battler.setup_battler_hurt_ani(1)
  1749.           #################################################################
  1750.         # 无伤害的攻击
  1751.         elsif !@battler_damage.is_a?(Numeric) and @last_hits == 1 and @frame_index == @last_frame
  1752.           @last_hits = 0
  1753.           #################################################################
  1754.         # 闪避的回合
  1755.         elsif @battler_damage.is_a?(Numeric) and @battler.damage == 0 and @last_hits == 1 and @frame_index == @last_frame
  1756.           @last_hits = 0
  1757.           #################################################################
  1758.         # 死亡判定
  1759.         elsif @last_hits == 1 and @frame_index == @last_frame and @battler.dead? and @battler.battler_dead_ani != 1
  1760.           @last_hits = 0
  1761.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1762.           @battler.setup_battler_dead_ani(1)
  1763.           collapse
  1764.         end
  1765.       end
  1766.     end
  1767.   end
  1768. end
复制代码
估计是文体太长了....还是看不见,就不发了...全动画战斗估计影响不大...
全动画战斗.rar (9.43 KB, 下载次数: 47)
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-21 05:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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