Advertisement
Guest User

Sideview Tankentai 1

a guest
Sep 23rd, 2017
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 92.60 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Sprite_Battler for Sideview Ver3.4c
  3. #------------------------------------------------------------------------------
  4. # This sprite is used to display battlers. It observes a instance of the
  5. # Game_Battler class and automatically changes sprite conditions.
  6. #==============================================================================
  7. class Sprite_Battler < Sprite_Base
  8. #--------------------------------------------------------------------------
  9. # ● オブジェクト初期化
  10. #--------------------------------------------------------------------------
  11. def initialize(viewport, battler = nil)
  12. super(viewport)
  13. @battler = battler
  14. @battler_visible = false
  15. @effect_type = 0 # Effect type
  16. @effect_duration = 0 # Effect duration
  17. @move_x = 0 # X-coord movement
  18. @move_y = 0 # Y-coord movement
  19. @move_z = 0 # Z priority
  20. @distanse_x = 0 # X distance (to another point)
  21. @distanse_y = 0 # Y distance (to another point)
  22. @moving_x = 0 # X distance travelled per frame
  23. @moving_y = 0 # Y distance travelled per frame
  24. @move_speed_x = 0 # X movement speed
  25. @move_speed_y = 0 # Y movement speed
  26. @move_speed_plus_x = 0 # Added X speed during movement
  27. @move_speed_plus_y = 0 # Added Y speed during movement
  28. @move_boost_x = 0 # X acceleration
  29. @move_boost_y = 0 # Y acceleration
  30. @jump_time = 0 # Jump duration
  31. @jump_time_plus = 0 # Added jump duration
  32. @jump_up = 0 # Jump up
  33. @jump_down = 0 # Jump down
  34. @jump_size = 0 # jump height
  35. @float_time = 0 # Float time
  36. @float_up = 0 # Float movement per frame
  37. @jump_plus = 0 # Battler shadow position while jumping
  38. @angle = 0 # Angle of rotation (of battler sprite)
  39. @angling = 0 # Angle of rotation per frame
  40. @angle_time = 0 # Angle duration
  41. @angle_reset = 0 # Angle reset check
  42. @zoom_x = 0 # X zoom (of battler sprite)
  43. @zoom_y = 0 # Y zoom
  44. @zooming_x = 0 # X zoom adjusted per frame
  45. @zooming_y = 0 # Y zoom adjusted per frame
  46. @zoom_time = 0 # Duration of zoom
  47. @zoom_reset = 0 # Zoom reset check
  48. @target_battler = [] # Battler targets
  49. @now_targets = [] # Memorized/Stored targets
  50. @pattern = 0 # Row of battler file
  51. @pattern_back = false # Row loop flag
  52. @wait = 0 # Delay (before next operation)
  53. @unloop_wait = 0 # Delay end of a non-looped battler row
  54. @action = [] # Action
  55. @anime_kind = 0 # Vertical frame position of battler file
  56. @anime_speed = 0 # Battler frame update speed
  57. @frame = 0 # Frame update time that is removed
  58. @anime_loop = 0 # Loop type
  59. @anime_end = false # Did battler animation end?
  60. @anime_freeze = false # Fixed animation?
  61. @anime_freeze_kind = false # Fixed frame position?
  62. @anime_moving = false # Throwing animation?
  63. @base_width = N01::ANIME_PATTERN # Horizontal frames in battler file
  64. @base_height = N01::ANIME_KIND # Vertical frames in battler file
  65. @width = 0 # Pixel width of battler frame
  66. @height = 0 # Pixel height of battler frame
  67. @picture_time = 0 # Cut-in picture duration
  68. @individual_targets = [] # Preserve targets for individual processing
  69. @balloon_duration = 65 # Balloon duration
  70. @reverse = false # Mirror animation flag
  71. # end if battler does not exist
  72. return @battler_visible = false if @battler == nil
  73. # Animated battler flag
  74. @anime_flug = true if @battler.actor?
  75. @anime_flug = true if !@battler.actor? && @battler.anime_on
  76. end
  77. #--------------------------------------------------------------------------
  78. # ● バトラー作成
  79. #--------------------------------------------------------------------------
  80. def make_battler
  81. # 初期配置の取得
  82. @battler.base_position
  83. # 色相はバトラーとして認識
  84. @battler_hue = @battler.battler_hue
  85. # バトラーがアクターの場合、またはエネミーアニメがオンの場合
  86. if @anime_flug
  87. # メイン武器を用意
  88. @weapon_R = Sprite_Weapon.new(viewport,@battler)
  89. # 味方はキャラクター名、エネミーはバトラー名を取得
  90. @battler_name = @battler.character_name if @battler.actor?
  91. @battler_name = @battler.battler_name unless @battler.actor?
  92. # エネミー反転がオンの場合、画像を反転させる
  93. self.mirror = true if !@battler.actor? && @battler.action_mirror
  94. # 歩行グラフィックを利用するかどうかで転送元の矩形サイズの認識先を変える
  95. if @battler_hue != nil ## blackmorning unofficial code; 3.3c
  96. self.bitmap = Cache.character(@battler_name, @battler_hue) if N01::WALK_ANIME
  97. self.bitmap = Cache.character(@battler_name + "_1", @battler_hue) unless N01::WALK_ANIME
  98. else
  99. self.bitmap = Cache.character(@battler_name) if N01::WALK_ANIME
  100. self.bitmap = Cache.character(@battler_name + "_1") unless N01::WALK_ANIME
  101. end ## End blackmorning unofficial code; 3.3c
  102. # 転送元の矩形を取得
  103. @width = self.bitmap.width / @base_width
  104. @height = self.bitmap.height / @base_height
  105. # 矩形を設定
  106. @sx = @pattern * @width
  107. @sy = @anime_kind * @height
  108. # バトラー本体を描画
  109. self.src_rect.set(@sx, @sy, @width, @height)
  110. # アニメしないバトラーの場合
  111. else
  112. # ビットマップを取得、設定
  113. @battler_name = @battler.battler_name
  114. self.bitmap = Cache.battler(@battler_name, @battler_hue)
  115. @width = bitmap.width
  116. @height = bitmap.height
  117. end
  118. # バックアタック時には画像を反転させる
  119. if $back_attack && @battler.actor?
  120. self.mirror = true
  121. elsif $back_attack && !@battler.actor?
  122. self.mirror = true
  123. self.mirror = false if @battler.action_mirror
  124. else
  125. self.mirror = false
  126. self.mirror = true if !@battler.actor? && @battler.action_mirror
  127. end
  128. # 武器画像に反映
  129. @weapon_R.mirroring if self.mirror && @weapon_R != nil
  130. # 位置を初期化
  131. @battler.reset_coordinate
  132. # 原点を決定
  133. self.ox = @width / 2
  134. self.oy = @height * 2 / 3
  135. # スプライトの座標を設定
  136. update_move
  137. # アニメ飛ばし用スプライトを用意
  138. @move_anime = Sprite_MoveAnime.new(viewport,battler)
  139. # ピクチャ用スプライトを用意
  140. @picture = Sprite.new
  141. # ダメージスプライト作成
  142. @damage = Sprite_Damage.new(viewport,battler)
  143. end
  144. #--------------------------------------------------------------------------
  145. # ● 影作成
  146. #--------------------------------------------------------------------------
  147. def make_shadow
  148. @shadow.dispose if @shadow != nil
  149. @battler_hue = @battler.battler_hue
  150. @shadow = Sprite.new(viewport)
  151. @shadow.z = self.z - 4
  152. @shadow.visible = false
  153. # バトラーに当てられた影グラフィックを用意
  154. @shadow.bitmap = Cache.character(@battler.shadow)
  155. @shadow_height = @shadow.bitmap.height
  156. # 影位置の微調整用インスタンス
  157. @shadow_plus_x = @battler.shadow_plus[0] - @width / 2
  158. @shadow_plus_y = @battler.shadow_plus[1]
  159. # バトラー画像のサイズに合わせて影画像をリサイズ
  160. @shadow.zoom_x = @width * 1.0 / @shadow.bitmap.width
  161. # 更新
  162. update_shadow
  163. end
  164. #--------------------------------------------------------------------------
  165. # ● 解放
  166. #--------------------------------------------------------------------------
  167. def dispose
  168. self.bitmap.dispose if self.bitmap != nil
  169. @weapon_R.dispose if @weapon_R != nil
  170. @move_anime.dispose if @move_anime != nil
  171. @picture.dispose if @picture != nil
  172. @shadow.dispose if @shadow != nil
  173. @damage.dispose if @damage != nil
  174. @balloon.dispose if @balloon != nil
  175. mirage_off
  176. # 画像変更リセット
  177. @battler.graphic_change(@before_graphic) if @before_graphic != nil
  178. super
  179. end
  180. #--------------------------------------------------------------------------
  181. # ● Damage Action action = [animation ID, mirror flag, allow reaction]
  182. #--------------------------------------------------------------------------
  183. def damage_action(action)
  184. damage = @battler.hp_damage
  185. damage = @battler.mp_damage if @battler.mp_damage != 0
  186. # HPとMP両方同時にダメージがあるなら
  187. if @battler.hp_damage != 0 && @battler.mp_damage != 0
  188. @battler.double_damage = true
  189. damage = @battler.hp_damage
  190. end
  191. # 吸収攻撃でHP0の処理
  192. if action[0] == "absorb"
  193. absorb = true
  194. action[0] = nil
  195. end
  196. # ヒットしている時のみアニメ実行
  197. unless @battler.evaded || @battler.missed || action[0] == nil
  198. @battler.animation_id = action[0]
  199. @battler.animation_mirror = action[1]
  200. end
  201. # ダメージアクション実行
  202. start_action(@battler.damage_hit) if damage > 0 && action[2]
  203. # 攻撃が当たっていない場合は回避アクション実行
  204. if @battler.evaded || @battler.missed
  205. start_action(@battler.evasion) if action[2]
  206. Sound.play_evasion
  207. end
  208. @damage.damage_pop unless absorb || action[3] != nil
  209. end
  210. #--------------------------------------------------------------------------
  211. # ● ダメージ数値POP
  212. #--------------------------------------------------------------------------
  213. def damage_pop(damage)
  214. @damage.damage_pop(damage)
  215. end
  216. #--------------------------------------------------------------------------
  217. # ● 戦闘開始行動
  218. #--------------------------------------------------------------------------
  219. def first_action
  220. # 行動できるかチェックし、できなければそのステートのアクション開始
  221. action = @battler.first_action unless @battler.restriction >= 4
  222. action = $data_states[@battler.state_id].base_action if @battler.states[0] != nil && @battler.restriction >= 4
  223. start_action(action)
  224. # 影スプライトを用意
  225. make_shadow if N01::SHADOW
  226. end
  227. #--------------------------------------------------------------------------
  228. # ● Start Action
  229. #--------------------------------------------------------------------------
  230. def start_action(kind)
  231. # Initializes various operations
  232. reset
  233. # 現在取っている待機アクションを記憶
  234. stand_by
  235. begin
  236. @action = N01::ACTION[kind].dup
  237. rescue
  238. p ("An error has occurred.",
  239. "Action Sequence Key #{kind} does not exist.",
  240. "Define it first or make sure it is spelled correctly.")
  241. exit
  242. end
  243. # 新しいアクション内容の決定
  244. # 行動配列の先頭からシフト
  245. active = @action.shift
  246. # 自動で終了を付ける
  247. @action.push("End")
  248. # 現在のアクションを決定
  249. @active_action = N01::ANIME[active]
  250. # ウエイト設定
  251. @wait = active.to_i if @active_action == nil
  252. # 単発アクション開始
  253. action
  254. end
  255. #--------------------------------------------------------------------------
  256. # ● 強制単発アクション開始
  257. #--------------------------------------------------------------------------
  258. def start_one_action(kind,back)
  259. # 各種動作を初期化
  260. reset
  261. # 現在取っている待機アクションを記憶
  262. stand_by
  263. # 座標リセットアクションをセッティング
  264. @action = [back]
  265. # 自動で終了を付ける
  266. @action.push("End")
  267. # 現在のアクションを決定
  268. @active_action = N01::ANIME[kind]
  269. # 単発アクション開始
  270. action
  271. end
  272. #--------------------------------------------------------------------------
  273. # ● 次のアクションへ
  274. #--------------------------------------------------------------------------
  275. def next_action
  276. # ウェイト中の場合キャンセル
  277. return @wait -= 1 if @wait > 0
  278. # まだ全アニメセルが終了していない場合キャンセル
  279. return if @anime_end == false
  280. # 最後のアニメセル表示待ち
  281. return @unloop_wait -= 1 if @unloop_wait > 0
  282. # 行動配列の先頭からシフト
  283. active = @action.shift
  284. # 現在のアクションを決定
  285. @active_action = N01::ANIME[active]
  286. # ウエイト設定
  287. @wait = active.to_i if @active_action == nil
  288. # 単発アクション開始
  289. action
  290. end
  291. #--------------------------------------------------------------------------
  292. # ● 待機アクション
  293. #--------------------------------------------------------------------------
  294. def stand_by
  295. # Set battler normal wait action sequence
  296. @repeat_action = @battler.normal
  297. # Set battler 1/4th HP (pinch) action sequence
  298. @repeat_action = @battler.pinch if @battler.hp <= @battler.maxhp / 4
  299. # Set battler guard action sequence
  300. @repeat_action = @battler.defence if @battler.guarding?
  301. # end if battler has no states and not dead
  302. return if @battler.state_id == nil && !@battler.dead?
  303. for state in @battler.states.reverse
  304. # Next state if battler shouldn't run a state action sequence.
  305. next if state.extension.include?("NOSTATEANIME")
  306. # Next state if enemy shouldn't run a state action sequence.
  307. next if @battler.is_a?(Game_Enemy) && state.extension.include?("EXCEPTENEMY")
  308. # Set battler state affliction action sequence
  309. @repeat_action = state.base_action
  310. end
  311. # Set actor incapacitated action sequence
  312. dead_action = @battler.incapacitated
  313. @repeat_action = dead_action if (@battler.dead? && @anime_flug) && dead_action != ""
  314. end
  315. #--------------------------------------------------------------------------
  316. # ● Push Stand By (Interrupt Wait Action)
  317. #--------------------------------------------------------------------------
  318. def push_stand_by
  319. action = @battler.normal
  320. action = @battler.pinch if @battler.hp <= @battler.maxhp / 4
  321. action = @battler.defence if @battler.guarding?
  322. for state in @battler.states.reverse
  323. # Next state if battler shouldn't run a state action sequence.
  324. next if state.extension.include?("NOSTATEANIME")
  325. # Next state if enemy shouldn't run a state action sequence.
  326. next if @battler.is_a?(Game_Enemy) && state.extension.include?("EXCEPTENEMY")
  327. # Set battler state affliction action sequence
  328. action = state.base_action
  329. end
  330. dead_action = @battler.incapacitated
  331. action = dead_action if (@battler.dead? && @anime_flug) && dead_action != ""
  332. @repeat_action = action
  333. # Interrupt
  334. @action.delete("End")
  335. act = N01::ACTION[action].dup
  336. for i in 0...act.size
  337. @action.push(act[i])
  338. end
  339. @action.push("End")
  340. @anime_end = true
  341. end
  342. #--------------------------------------------------------------------------
  343. # ● 各種変化を初期化
  344. #--------------------------------------------------------------------------
  345. def reset
  346. self.zoom_x = self.zoom_y = 1
  347. self.oy = @height * 2 / 3
  348. @angle = self.angle = 0
  349. @anime_end = true
  350. @non_repeat = false
  351. @anime_freeze = false
  352. @unloop_wait = 0
  353. end
  354. #--------------------------------------------------------------------------
  355. # ● ジャンプを初期化
  356. #--------------------------------------------------------------------------
  357. def jump_reset
  358. @battler.jump = @jump_time = @jump_time_plus = @jump_up = @jump_down = 0
  359. @jump_size = @jump_plus = @float_time = @float_up = 0
  360. end
  361. #--------------------------------------------------------------------------
  362. # ● ターゲット情報を受け取る
  363. #--------------------------------------------------------------------------
  364. def get_target(target)
  365. # 個別処理中は中止(全域で自分が巻き込まれた時ターゲット情報が狂わないように)
  366. return if @battler.individual
  367. @target_battler = target
  368. end
  369. #--------------------------------------------------------------------------
  370. # ● アクション情報をバトラーに格納
  371. #--------------------------------------------------------------------------
  372. def send_action(action)
  373. @battler.play = 0
  374. @battler.play = action if @battler.active
  375. end
  376. #--------------------------------------------------------------------------
  377. # ● バトラー追加
  378. #--------------------------------------------------------------------------
  379. def battler_join
  380. if @battler.exist? && !@battler_visible
  381. # 戦闘不能からの復活なら処理をスキップ
  382. if @battler.revival && @anime_flug
  383. return @battler.revival = false
  384. elsif @battler.revival && !@anime_flug
  385. @battler.revival = false
  386. self.visible = true
  387. return
  388. end
  389. @anime_flug = true if @battler.actor?
  390. @anime_flug = true if !@battler.actor? && @battler.anime_on
  391. make_battler
  392. first_action
  393. end
  394. end
  395. #--------------------------------------------------------------------------
  396. # ● フレーム更新 ※再定義
  397. #--------------------------------------------------------------------------
  398. def update
  399. super
  400. # バトラーがいない場合スキップ
  401. return self.bitmap = nil if @battler == nil
  402. # バトラー追加
  403. battler_join
  404. # 次のアクションへ
  405. next_action
  406. # アニメパターン更新
  407. update_anime_pattern
  408. # ターゲット更新
  409. update_target
  410. # 強制アクション更新
  411. update_force_action
  412. # 座標更新
  413. update_move
  414. # 影更新
  415. update_shadow if @shadow != nil
  416. # 武器更新
  417. @weapon_R.update if @weapon_action
  418. # 浮遊更新
  419. update_float if @float_time > 0
  420. # 回転更新
  421. update_angle if @angle_time > 0
  422. # 拡大縮小更新
  423. update_zoom if @zoom_time > 0
  424. # 残像更新
  425. update_mirage if @mirage_flug
  426. # ピクチャ更新
  427. update_picture if @picture_time > 0
  428. # アニメ飛ばし更新
  429. update_move_anime if @anime_moving
  430. # ふきだしアニメ更新
  431. update_balloon if @balloon_duration <= 64
  432. # ダメージスプライト更新
  433. @damage.update if @damage != nil
  434. setup_new_effect
  435. update_effect
  436. update_battler_bitmap
  437. end
  438. #--------------------------------------------------------------------------
  439. # ● アニメパターン更新
  440. #--------------------------------------------------------------------------
  441. def update_anime_pattern
  442. # 更新時間がくるまでスキップ
  443. return @frame -= 1 if @frame != 0
  444. # 必要な時だけ武器アニメ更新
  445. @weapon_R.action if @weapon_action && @weapon_R != nil
  446. # アニメのコマが最後まで到達したらリピート方法をチェック
  447. if @pattern_back
  448. # 往復ループ
  449. if @anime_loop == 0
  450. # 逆転再生
  451. if @reverse
  452. @pattern += 1
  453. if @pattern == @base_width - 1
  454. @pattern_back = false
  455. @anime_end = true
  456. end
  457. # 通常再生
  458. else
  459. @pattern -= 1
  460. if @pattern == 0
  461. @pattern_back = false
  462. @anime_end = true
  463. end
  464. end
  465. # 片道ループもしくはループしない
  466. else
  467. @anime_end = true
  468. if @anime_loop == 1
  469. @pattern = 0 if !@reverse
  470. @pattern = @base_width - 1 if @reverse
  471. @pattern_back = false
  472. end
  473. end
  474. # アニメのコマを進める
  475. else
  476. if @reverse
  477. @pattern -= 1
  478. @pattern_back = true if @pattern == 0
  479. else
  480. @pattern += 1
  481. @pattern_back = true if @pattern == @base_width - 1
  482. end
  483. end
  484. # 更新時間を初期化
  485. @frame = @anime_speed
  486. # アニメ固定の場合は横矩形を固定
  487. return if @anime_freeze
  488. # 転送元の矩形を設定
  489. return unless @anime_flug
  490. @sx = @pattern * @width
  491. @sy = @anime_kind * @height
  492. self.src_rect.set(@sx, @sy, @width, @height)
  493. end
  494. #--------------------------------------------------------------------------
  495. # ● ターゲット更新 action = ["N01target_change",ターゲット情報]
  496. #--------------------------------------------------------------------------
  497. def update_target
  498. # ターゲットチェック
  499. return if @battler.force_target == 0
  500. # 個別処理中は中止(全域で自分が巻き込まれた時ターゲット情報が狂わないように)
  501. return if @battler.individual
  502. @target_battler = @battler.force_target[1]
  503. @battler.force_target = 0
  504. end
  505. #--------------------------------------------------------------------------
  506. # ● 強制アクション更新 action = [識別,復帰,実行するアクション]
  507. #--------------------------------------------------------------------------
  508. def update_force_action
  509. # 強制アクションチェック
  510. action = @battler.force_action
  511. return if action == 0
  512. @battler.force_action = 0
  513. # アクティブ中は割り込ませない
  514. return if @battler.active
  515. # コラプスならそのまま行動に直結
  516. return collapse_action if action[0] == "N01collapse"
  517. # 単発ならそのまま行動に直結
  518. return start_one_action(action[2],action[1]) if action[0] == "SINGLE"
  519. # 通しはアクションとして扱う
  520. start_action(action[2])
  521. # 座標復帰の有無
  522. return if action[1] == ""
  523. # 終了位置を入れ替えて復帰アクションを入れる
  524. @action.delete("End")
  525. @action.push(action[1])
  526. @action.push("End")
  527. end
  528. #--------------------------------------------------------------------------
  529. # ● 座標更新
  530. #--------------------------------------------------------------------------
  531. def update_move
  532. # 加減速で出る距離の増減を補完
  533. if @move_speed_plus_x > 0
  534. # 移動計算
  535. @move_x += @moving_x
  536. # 移動を実行
  537. @battler.move_x = @move_x
  538. @move_speed_plus_x -= 1
  539. elsif @move_speed_x > 0
  540. # 加速の場合
  541. if @move_boost_x != 0
  542. @moving_x += @move_boost_x
  543. end
  544. # 移動計算
  545. @move_x += @moving_x
  546. # 移動を実行
  547. @battler.move_x = @move_x
  548. @move_speed_x -= 1
  549. end
  550. # 加減速で出る距離の増減を補完
  551. if @move_speed_plus_y > 0
  552. # 移動計算
  553. @move_y += @moving_y
  554. # 移動を実行
  555. @battler.move_y = @move_y
  556. @move_speed_plus_y -= 1
  557. elsif @move_speed_y > 0
  558. # 加速の場合
  559. if @move_boost_y != 0
  560. @moving_y += @move_boost_y
  561. end
  562. # 移動計算
  563. @move_y += @moving_y
  564. # 移動を実行
  565. @battler.move_y = @move_y
  566. @move_speed_y -= 1
  567. end
  568. # ジャンプ上昇
  569. if @jump_up != 0
  570. # 移動計算
  571. @jump_plus += @jump_up
  572. # 移動を実行
  573. @battler.jump = @jump_plus
  574. @jump_up = @jump_up / 2
  575. @jump_time -= 1
  576. # ジャンプが頂点に達したら
  577. if @jump_time == 0 or @jump_up == @jump_sign
  578. @jump_down = @jump_up * 2 * @jump_sign * @jump_sign2
  579. @jump_time_plus += @jump_time * 2
  580. @jump_up = 0
  581. return
  582. end
  583. end
  584. # ジャンプ下降
  585. if @jump_down != 0
  586. if @jump_time_plus != 0
  587. @jump_time_plus -= 1
  588. elsif @jump_down != @jump_size
  589. # 移動計算
  590. @jump_plus += @jump_down
  591. # 移動を実行
  592. @battler.jump = @jump_plus
  593. @jump_down = @jump_down * 2
  594. if @jump_down == @jump_size
  595. if @jump_flug
  596. @jump_flug = false
  597. else
  598. # 移動計算
  599. @jump_plus += @jump_down
  600. # 移動を実行
  601. @battler.jump = @jump_plus
  602. @jump_down = @jump_size = 0
  603. end
  604. end
  605. end
  606. end
  607. # スプライトの座標を設定
  608. self.x = @battler.position_x
  609. self.y = @battler.position_y
  610. self.z = @battler.position_z
  611. end
  612. #--------------------------------------------------------------------------
  613. # ● 影更新
  614. #--------------------------------------------------------------------------
  615. def update_shadow
  616. @shadow.opacity = self.opacity
  617. @shadow.x = @battler.position_x + @shadow_plus_x
  618. @shadow.y = @battler.position_y + @shadow_plus_y - @jump_plus
  619. @shadow.z = @battler.position_z - 4
  620. end
  621. #--------------------------------------------------------------------------
  622. # ● 浮遊更新
  623. #--------------------------------------------------------------------------
  624. def update_float
  625. @float_time -= 1
  626. @jump_plus += @float_up
  627. @battler.jump = @jump_plus
  628. end
  629. #--------------------------------------------------------------------------
  630. # ● 回転更新
  631. #--------------------------------------------------------------------------
  632. def update_angle
  633. # 回転実行
  634. @angle += @angling
  635. self.angle = @angle
  636. @angle_time -= 1
  637. # 回転時間がなくなったら項目をリセット
  638. return @angle = 0 if @angle_time == 0
  639. # 復帰フラグがあれば角度を0に戻す
  640. self.angle = 0 if @angle_reset
  641. end
  642. #--------------------------------------------------------------------------
  643. # ● 拡大縮小更新
  644. #--------------------------------------------------------------------------
  645. def update_zoom
  646. # 拡大縮小実行
  647. @zoom_x += @zooming_x
  648. @zoom_y += @zooming_y
  649. self.zoom_x = @zoom_x
  650. self.zoom_y = @zoom_y
  651. @zoom_time -= 1
  652. # 拡大縮小時間がなくなったら項目をリセット
  653. return if @zoom_time != 0
  654. @zoom_x = @zoom_y = 0
  655. self.oy = @height * 2 / 3
  656. # 復帰フラグがあれば戻す
  657. self.zoom_x = self.zoom_y = 1 if @zoom_reset
  658. end
  659. #--------------------------------------------------------------------------
  660. # ● 残像更新
  661. #--------------------------------------------------------------------------
  662. def update_mirage
  663. # 残像は最大3つまで表示し、2フレームごとに更新
  664. mirage(@mirage0) if @mirage_count == 1
  665. mirage(@mirage1) if @mirage_count == 3
  666. mirage(@mirage2) if @mirage_count == 5
  667. @mirage_count += 1
  668. @mirage_count = 0 if @mirage_count == 6
  669. end
  670. #--------------------------------------------------------------------------
  671. # ● ピクチャ更新
  672. #--------------------------------------------------------------------------
  673. def update_picture
  674. @picture_time -= 1
  675. @picture.x += @moving_pic_x
  676. @picture.y += @moving_pic_y
  677. end
  678. #--------------------------------------------------------------------------
  679. # ● アニメ飛ばし更新
  680. #--------------------------------------------------------------------------
  681. def update_move_anime
  682. @move_anime.update
  683. @anime_moving = false if @move_anime.finish?
  684. @move_anime.action_reset if @move_anime.finish?
  685. end
  686. #--------------------------------------------------------------------------
  687. # ● 崩壊エフェクトの更新 ※再定義
  688. #--------------------------------------------------------------------------
  689. def update_collapse
  690. normal_collapse if @collapse_type == 2
  691. boss_collapse1 if @collapse_type == 3
  692. boss_collapse2 if @collapse_type == 4
  693. end
  694. #--------------------------------------------------------------------------
  695. # ● ふきだしアニメ更新
  696. #--------------------------------------------------------------------------
  697. def update_balloon
  698. @balloon_duration -= 1 if @balloon_duration > 0 && !@balloon_back
  699. @balloon_duration += 1 if @balloon_back
  700. if @balloon_duration == 64
  701. @balloon_back = false
  702. @balloon.visible = false
  703. elsif @balloon_duration == 0
  704. @balloon.visible = false if @balloon_loop == 0
  705. @balloon_back = true if @balloon_loop == 1
  706. end
  707. @balloon.x = self.x
  708. @balloon.y = self.y
  709. @balloon.z = 10
  710. @balloon.opacity = self.opacity
  711. sx = 7 * 32 if @balloon_duration < 12
  712. sx = (7 - (@balloon_duration - 12) / 8) * 32 unless @balloon_duration < 12
  713. @balloon.src_rect.set(sx, @balloon_id * 32, 32, 32)
  714. end
  715. #--------------------------------------------------------------------------
  716. # ++ Update Transfer Origin Bitmap
  717. #--------------------------------------------------------------------------
  718. def update_battler_bitmap
  719. if @battler.actor?
  720. if @battler.character_name != @battler_name or @battler.battler_hue != @battler_hue
  721. @battler_name = @battler.character_name
  722. @battler_hue = @battler.battler_hue
  723. end
  724. else
  725. if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue
  726. @battler_name = @battler.battler_name
  727. @battler_hue = @battler.battler_hue
  728. # 3.4a restored original bitmap update
  729. # Bitmap updates itself when enemy transforms
  730. if !@battler.anime_on
  731. self.bitmap = Cache.battler(@battler_name, @battler_hue)
  732. @width = bitmap.width
  733. @height = bitmap.height
  734. self.ox = @width / 2
  735. self.oy = @height * 2 / 3
  736. make_shadow
  737. end
  738. end
  739. if !@battler.exist?
  740. self.opacity = 0 if @effect_duration == 0 && @battler.collapse_type != 1
  741. end
  742. end
  743. end
  744. #--------------------------------------------------------------------------
  745. # ● Action Processing
  746. #--------------------------------------------------------------------------
  747. def action
  748. return if @active_action == nil
  749. action = @active_action[0]
  750. # Invert battler sprite
  751. return mirroring if action == "Invert"
  752. # Rotate battler sprite
  753. return angling if action == "angle"
  754. # Zoom battler sprite
  755. return zooming if action == "zoom"
  756. # Afterimage effects ON
  757. return mirage_on if action == "Afterimage ON"
  758. # Afterimage effects OFF
  759. return mirage_off if action == "Afterimage OFF"
  760. # Display picture
  761. return picture if action == "pic"
  762. # Delete displayed picture
  763. return @picture.visible = false && @picture_time = 0 if action == "Clear image"
  764. # Change battler graphic
  765. return graphics_change if action == "change"
  766. # Display battle animations
  767. return battle_anime if action == "anime"
  768. # Animated balloon display
  769. return balloon_anime if action == "balloon"
  770. # Play BGM/BGS/SE
  771. return sound if action == "sound"
  772. # Game Switch operation
  773. return $game_switches[@active_action[1]] = @active_action[2] if action == "switch"
  774. # Game Variable operation
  775. return variable if action == "variable"
  776. # if battler has two weapons, execute next defined ANIME key
  777. return two_swords if action == "Two Wpn Only"
  778. # if battler has one weapon, execute next defined ANIME key
  779. return non_two_swords if action == "One Wpn Only"
  780. # Determine necessary conditions and continues sequence or not.
  781. return necessary if action == "nece"
  782. # Execute skill from within another skill.
  783. return derivating if action == "der"
  784. # Start individual processing of actions on target objects
  785. return individual_action if action == "Process Skill"
  786. # End individual processing of actions
  787. return individual_action_end if action == "Process Skill End"
  788. # 待機に移行しない場合
  789. return non_repeat if action == "Don't Wait"
  790. # Change Start Position of battlers
  791. return @battler.change_base_position(self.x, self.y) if action == "Start Pos Change"
  792. # Revert to original start position coordinates
  793. return @battler.base_position if action == "Start Pos Return"
  794. # Change target objects
  795. return change_target if action == "target"
  796. # Allow collapse of targets.
  797. return send_action(action) if action == "Can Collapse"
  798. # Cancel active action
  799. return send_action(action) if action == "Cancel Action"
  800. # Add state to target objects
  801. return state_on if action == "sta+"
  802. # Remove state from target objects
  803. return state_off if action == "sta-"
  804. # Change game frame rate
  805. return Graphics.frame_rate = @active_action[1] if action == "fps"
  806. # Float battler sprite from shadow
  807. return floating if action == "float"
  808. # Run string through eval() method
  809. return eval(@active_action[1]) if action == "script"
  810. # Force battler actions of non-active battlers
  811. return force_action if @active_action.size == 4
  812. # Reset battlers to start coordinates
  813. return reseting if @active_action.size == 5
  814. # Move battler sprites
  815. return moving if @active_action.size == 7
  816. # Determines battler frame animation
  817. return battler_anime if @active_action.size == 9
  818. # Move database animation on screen
  819. return moving_anime if @active_action.size == 11
  820. # "End"
  821. return anime_finish if action == "End"
  822. end
  823. #--------------------------------------------------------------------------
  824. # ● 反転実行
  825. #--------------------------------------------------------------------------
  826. def mirroring
  827. # すでに反転されていれば元に戻す
  828. if self.mirror
  829. self.mirror = false
  830. # 武器アニメも反映
  831. @weapon_R.mirroring if @anime_flug
  832. else
  833. self.mirror = true
  834. # 武器アニメも反映
  835. @weapon_R.mirroring if @anime_flug
  836. end
  837. end
  838. #--------------------------------------------------------------------------
  839. # ● 回転実行
  840. #--------------------------------------------------------------------------
  841. def angling
  842. # ジャンプを初期化
  843. jump_reset
  844. # 情報確認
  845. @angle_time = @active_action[1]
  846. start_angle = @active_action[2]
  847. end_angle = @active_action[3]
  848. @angle_reset = @active_action[4]
  849. # バックアタック時には逆に
  850. start_angle *= -1 if $back_attack
  851. end_angle *= -1 if $back_attack
  852. # エネミーは逆に
  853. start_angle *= -1 if @battler.is_a?(Game_Enemy)
  854. end_angle *= -1 if @battler.is_a?(Game_Enemy)
  855. # 時間が0以下なら即座に最終角度へ
  856. if @angle_time <= 0
  857. self.angle = end_angle
  858. return @angle_time = 0
  859. end
  860. # 回転時間から1フレームあたりの角度を出す
  861. @angling = (end_angle - start_angle) / @angle_time
  862. # 割り切れない余りを初期角度に
  863. @angle = (end_angle - start_angle) % @angle_time + start_angle
  864. end
  865. #--------------------------------------------------------------------------
  866. # ● 拡大縮小実行
  867. #--------------------------------------------------------------------------
  868. def zooming
  869. # ジャンプを初期化
  870. jump_reset
  871. # 情報確認
  872. @zoom_time = @active_action[1]
  873. zoom_x = @active_action[2] - 1
  874. zoom_y = @active_action[3] - 1
  875. @zoom_reset = @active_action[4]
  876. @zoom_x = @zoom_y = 1
  877. # 時間が0以下ならスキップ
  878. return @zoom_time = 0 if @zoom_time <= 0
  879. # 拡大時間から1フレームあたりの拡大率を出す
  880. @zooming_x = zoom_x / @zoom_time
  881. @zooming_y = zoom_y / @zoom_time
  882. end
  883. #--------------------------------------------------------------------------
  884. # ● 残像開始
  885. #--------------------------------------------------------------------------
  886. def mirage_on
  887. # 戦闘不能時には残像させない
  888. return if @battler.dead?
  889. @mirage0 = Sprite.new(self.viewport)
  890. @mirage1 = Sprite.new(self.viewport)
  891. @mirage2 = Sprite.new(self.viewport)
  892. @mirage_flug = true
  893. @mirage_count = 0
  894. end
  895. #--------------------------------------------------------------------------
  896. # ● 残像表示
  897. #--------------------------------------------------------------------------
  898. def mirage(body)
  899. body.bitmap = self.bitmap.dup
  900. body.x = self.x
  901. body.y = self.y
  902. body.ox = self.ox
  903. body.oy = self.oy
  904. body.z = self.z
  905. body.mirror = self.mirror
  906. body.angle = @angle
  907. body.opacity = 160
  908. body.zoom_x = self.zoom_x
  909. body.zoom_y = self.zoom_y
  910. body.src_rect.set(@sx, @sy, @width, @height) if @anime_flug
  911. body.src_rect.set(0, 0, @width, @height) unless @anime_flug
  912. end
  913. #--------------------------------------------------------------------------
  914. # ● 残像終了
  915. #--------------------------------------------------------------------------
  916. def mirage_off
  917. @mirage_flug = false
  918. @mirage0.dispose if @mirage0 != nil
  919. @mirage1.dispose if @mirage1 != nil
  920. @mirage2.dispose if @mirage2 != nil
  921. end
  922. #--------------------------------------------------------------------------
  923. # ● ピクチャ表示
  924. #--------------------------------------------------------------------------
  925. def picture
  926. # 移動開始位置を確認
  927. pic_x = @active_action[1]
  928. pic_y = @active_action[2]
  929. # 移動終了位置を確認
  930. pic_end_x = @active_action[3]
  931. pic_end_y = @active_action[4]
  932. @picture_time = @active_action[5]
  933. # 時間で割り、1フレーム当たりの移動速度を計算
  934. @moving_pic_x = (pic_end_x - pic_x)/ @picture_time
  935. @moving_pic_y = (pic_end_y - pic_y)/ @picture_time
  936. # 割り切れない場合最初に加算
  937. plus_x = (pic_end_x - pic_x)% @picture_time
  938. plus_y = (pic_end_y - pic_y)% @picture_time
  939. # ピクチャ表示
  940. @picture.bitmap = Cache.picture(@active_action[7])
  941. @picture.x = pic_x + plus_x
  942. @picture.y = pic_y + plus_y
  943. # Z座標調整
  944. @picture.z = 1
  945. @picture.z = 1000 if @active_action[6]
  946. @picture.visible = true
  947. end
  948. #--------------------------------------------------------------------------
  949. # ● グラフィックファイル変更
  950. #--------------------------------------------------------------------------
  951. def graphics_change
  952. # Limit method to actors only
  953. return if @battler.is_a?(Game_Enemy)
  954. # グラフィック変更
  955. @battler_name = @active_action[2]
  956. # 歩行グラフィックを利用するかどうかで転送元の矩形サイズの認識先を変える
  957. self.bitmap = Cache.character(@battler_name) if N01::WALK_ANIME
  958. self.bitmap = Cache.character(@battler_name + "_1") unless N01::WALK_ANIME
  959. # 転送元の矩形を取得
  960. @width = self.bitmap.width / @base_width
  961. @height = self.bitmap.height / @base_height
  962. # 戦闘後リセットする場合キャラチップ名を記憶
  963. @before_graphic = @battler.character_name if @active_action[1]
  964. @battler.graphic_change(@active_action[2])
  965. end
  966. #--------------------------------------------------------------------------
  967. # ● Show Battle Animation [判別,ID, target, mirror, wait, Weapon 2 flag]
  968. #--------------------------------------------------------------------------
  969. def battle_anime
  970. # return if enemy and processing animation for Weapon 2
  971. return if @active_action[5] && !@battler.actor?
  972. # return if trying to process Weapon 2 animation with no Weapon 2 equipped.
  973. return if @active_action[5] && @battler.weapons[1] == nil
  974. # return if actor has Weapon 2 equipped, but not Weapon 1
  975. if @battler.actor?
  976. return if !@active_action[5] && @battler.weapons[0] == nil && @battler.weapons[1] != nil
  977. end
  978. anime_id = @active_action[1]
  979. # 3.4a properly mirror animations if enemy is manually set to be mirroed
  980. if @battler.is_a?(Game_Enemy)
  981. mirror = false
  982. mirror = true if @battler.action_mirror
  983. end
  984. # Mirror animation when in back attack
  985. if $back_attack
  986. mirror = true if !@active_action[3] # 3.4a
  987. mirror = false if @active_action[3] || (@battler.is_a?(Game_Enemy) && @battler.action_mirror) # 3.4a
  988. end
  989. # 3.4c
  990. # Damage with no animation
  991. if anime_id == -3
  992. # No animation if anime ID is -3
  993. anime_id = 0
  994. # ダメージ表示のアニメなら、ダメージ計算を先に済ませるため処理を中断
  995. damage_action = [anime_id, mirror, true]
  996. return @battler.play = ["OBJ_ANIM",damage_action] if @battler.active
  997. end
  998. # For skill, item, and weapon animations
  999. if anime_id < 0
  1000. # Branches from here depending on type of action
  1001. if @battler.action.skill? && anime_id != -2
  1002. ### UNOFFICAL CODE v3.3b ###
  1003. anime_id = @battler.action.skill.animation_id unless @battler.action.skill.animation_id == -1
  1004. if @battler.action.skill.animation_id == -1
  1005. anime_id = N01::NO_WEAPON
  1006. if @battler.actor?
  1007. weapon_id = @battler.weapon_id
  1008. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1009. anime_id = @battler.atk_animation_id2 if @active_action[5]
  1010. else
  1011. weapon_id = @battler.weapon
  1012. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1013. end
  1014. end
  1015. elsif @battler.action.item? && anime_id != -2
  1016. anime_id = 0
  1017. anime_id = @battler.action.item.animation_id unless @battler.action.item.animation_id == -1
  1018. if @battler.action.item.animation_id == -1
  1019. anime_id = N01::NO_WEAPON
  1020. weapon_id = @battler.weapon_id
  1021. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1022. anime_id = @battler.atk_animation_id2 if @active_action[5]
  1023. end
  1024. ### UNOFFICIAL CODE v3.3b END ###
  1025. else
  1026. # Unarmed attack animation
  1027. anime_id = N01::NO_WEAPON
  1028. if @battler.actor?
  1029. weapon_id = @battler.weapon_id
  1030. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1031. # For Two Swords Style animation
  1032. anime_id = @battler.atk_animation_id2 if @active_action[5]
  1033. else
  1034. weapon_id = @battler.weapon
  1035. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1036. end
  1037. end
  1038. # Set wait value, temporarily delays action sequence processing
  1039. @wait = $data_animations[anime_id].frame_max * 4 if $data_animations[anime_id] != nil && @active_action[4]
  1040. waitflug = true
  1041. # ダメージ表示のアニメなら、ダメージ計算を先に済ませるため処理を中断
  1042. damage_action = [anime_id, mirror, true]
  1043. return @battler.play = ["OBJ_ANIM",damage_action] if @battler.active && @active_action[1] != -4 # 3.4a
  1044. end
  1045. # アニメ実行
  1046. if @active_action[2] == 0 && $data_animations[anime_id] != nil
  1047. @battler.animation_id = anime_id
  1048. @battler.animation_mirror = mirror
  1049. elsif $data_animations[anime_id] != nil
  1050. for target in @target_battler
  1051. target.animation_id = anime_id
  1052. target.animation_mirror = mirror
  1053. end
  1054. end
  1055. # ウエイト設定
  1056. @wait = $data_animations[anime_id].frame_max * 4 if $data_animations[anime_id] != nil && @active_action[4] && !waitflug
  1057. end
  1058. #--------------------------------------------------------------------------
  1059. # ● ふきだしアニメ表示
  1060. #--------------------------------------------------------------------------
  1061. def balloon_anime
  1062. return if self.opacity == 0
  1063. if @balloon == nil
  1064. @balloon = Sprite.new
  1065. @balloon.bitmap = Cache.system(N01::BALLOON_GRAPHICS) # v3.3a
  1066. @balloon.ox = @width / 16
  1067. @balloon.oy = @balloon.height / 10 + @height / 3
  1068. end
  1069. @balloon_id = @active_action[1]
  1070. @balloon_loop = @active_action[2]
  1071. @balloon_duration = 64
  1072. @balloon_back = false
  1073. update_balloon
  1074. @balloon.visible = true
  1075. end
  1076. #--------------------------------------------------------------------------
  1077. # ● BGM/BGS/SE演奏
  1078. #--------------------------------------------------------------------------
  1079. def sound
  1080. # 情報を取得
  1081. pitch = @active_action[2]
  1082. vol = @active_action[3]
  1083. name = @active_action[4]
  1084. # 実行
  1085. case @active_action[1]
  1086. when "se"
  1087. Audio.se_play("Audio/SE/" + name, vol, pitch)
  1088. when "bgm"
  1089. # 名前指定のない場合、現在のBGMを変えないように
  1090. if @active_action[4] == ""
  1091. now_bgm = RPG::BGM.last
  1092. name = now_bgm.name
  1093. end
  1094. Audio.bgm_play("Audio/BGM/" + name, vol, pitch)
  1095. when "bgs"
  1096. # 名前指定のない場合、現在のBGSを変えないように
  1097. if @active_action[4] == ""
  1098. now_bgs = RPG::BGS.last
  1099. name = now_bgs.name
  1100. end
  1101. Audio.bgs_play("Audio/BGS/" + name, vol, pitch)
  1102. end
  1103. end
  1104. #--------------------------------------------------------------------------
  1105. # ● ゲーム変数操作
  1106. #--------------------------------------------------------------------------
  1107. def variable
  1108. # オペランドチェック
  1109. operand = @active_action[3]
  1110. # 変数操作で分岐
  1111. case @active_action[2]
  1112. when 0 # 代入
  1113. $game_variables[@active_action[1]] = operand
  1114. when 1 # 加算
  1115. $game_variables[@active_action[1]] += operand
  1116. when 2 # 減算
  1117. $game_variables[@active_action[1]] -= operand
  1118. when 3 # 乗算
  1119. $game_variables[@active_action[1]] *= operand
  1120. when 4 # 除算
  1121. $game_variables[@active_action[1]] /= operand
  1122. when 5 # 剰余
  1123. $game_variables[@active_action[1]] %= operand
  1124. end
  1125. end
  1126. #--------------------------------------------------------------------------
  1127. # ● 二刀限定
  1128. #--------------------------------------------------------------------------
  1129. def two_swords
  1130. # エネミーは処理させない
  1131. return @action.shift unless @battler.actor?
  1132. # 左(下部表示)に武器がなかったら次のアクションを除く
  1133. return @action.shift if @battler.weapons[1] == nil
  1134. # 行動配列の先頭からシフト
  1135. active = @action.shift
  1136. # 現在のアクションを決定
  1137. @active_action = N01::ANIME[active]
  1138. # ウエイト設定
  1139. @wait = active.to_i if @active_action == nil
  1140. # 単発アクション開始
  1141. action
  1142. end
  1143. #--------------------------------------------------------------------------
  1144. # ● 非二刀限定
  1145. #--------------------------------------------------------------------------
  1146. def non_two_swords
  1147. # エネミーは処理させない
  1148. return unless @battler.actor?
  1149. # 左(下部表示)に武器があったら次のアクションを除く
  1150. return @action.shift if @battler.weapons[1] != nil
  1151. # 行動配列の先頭からシフト
  1152. active = @action.shift
  1153. # 現在のアクションを決定
  1154. @active_action = N01::ANIME[active]
  1155. # ウエイト設定
  1156. @wait = active.to_i if @active_action == nil
  1157. # 単発アクション開始
  1158. action
  1159. end
  1160. #--------------------------------------------------------------------------
  1161. # ● アクション条件
  1162. #--------------------------------------------------------------------------
  1163. def necessary
  1164. nece1 = @active_action[3]
  1165. nece2 = @active_action[4]
  1166. # ターゲットチェック
  1167. case @active_action[1]
  1168. # 0自身 1ターゲット 2敵全体 3味方全体
  1169. when 0
  1170. target = [$game_party.members[@battler.index]] if @battler.is_a?(Game_Actor)
  1171. target = [$game_troop.members[@battler.index]] if @battler.is_a?(Game_Enemy)
  1172. when 1
  1173. target = @target_battler
  1174. when 2
  1175. target = $game_troop.members
  1176. when 3
  1177. target = $game_party.members
  1178. end
  1179. # ターゲットが空の場合は失敗とみなす
  1180. return start_action(@battler.recover_action) if target.size == 0
  1181. # 内容チェック
  1182. case @active_action[2]
  1183. # ステートID指定だった場合
  1184. when 0
  1185. # 補足が正で「ステートにかかっている」、負は「かかっていない」が条件に
  1186. state_on = true if nece2 > 0
  1187. # 条件人数を出す
  1188. state_member = nece2.abs
  1189. # 0は仲間数を出す
  1190. if nece2 == 0
  1191. state_member = $game_party.members.size if @battler.is_a?(Game_Actor)
  1192. state_member = $game_troop.members.size if @battler.is_a?(Game_Enemy)
  1193. end
  1194. # ターゲットのステートチェックし人数をカウント
  1195. for member in target
  1196. state_member -= 1 if member.state?(nece1)
  1197. end
  1198. # 条件が満たされていればアクション続行
  1199. if state_member == 0 && state_on
  1200. return
  1201. elsif state_member == nece2.abs
  1202. return if state_on == nil
  1203. end
  1204. # パラメータ指定だった場合
  1205. when 1
  1206. # 補足が正で「数値以上」、負は「数値以下」が条件に
  1207. num_over = true if nece2 > 0
  1208. # 参照数値
  1209. num = 0
  1210. # ターゲットのパラメータチェック
  1211. for member in target
  1212. # 参照パラメータで分岐
  1213. case nece1
  1214. when 0 # 現HP
  1215. num += member.hp
  1216. when 1 # 現MP
  1217. num += member.mp
  1218. when 2 # 攻撃力
  1219. num += member.atk
  1220. when 3 # 防御力
  1221. num += member.def
  1222. when 4 # 精神力
  1223. num += member.spi
  1224. when 5 # 敏捷性
  1225. num += member.agi
  1226. end
  1227. end
  1228. # 平均を出す
  1229. num = num / target.size
  1230. # 条件が満たされていればアクション続行
  1231. if num > nece2.abs && num_over
  1232. return
  1233. elsif num < nece2.abs
  1234. return if num_over == nil
  1235. end
  1236. # スイッチ指定だった場合
  1237. when 2
  1238. # 条件が満たされていればアクション続行
  1239. if $game_switches[nece1]
  1240. # 補足がtrueで「スイッチON」、falseは「スイッチOFF」が条件に
  1241. return if nece2
  1242. # スイッチがOFFの場合はON時とは逆に
  1243. else
  1244. return unless nece2
  1245. end
  1246. # 変数指定だった場合
  1247. when 3
  1248. # 補足が正で「数値以上」、負は「数値以下」が条件に
  1249. if nece2 > 0
  1250. return if $game_variables[nece1] > nece2
  1251. else
  1252. return unless $game_variables[nece1] > nece2.abs
  1253. end
  1254. # 習得スキル指定だった場合
  1255. when 4
  1256. # スキル条件人数を出す
  1257. skill_member = nece2.abs
  1258. for member in target
  1259. skill_member -= 1 if member.skill_learn?(nece1)
  1260. # 条件確認
  1261. return if skill_member == 0
  1262. end
  1263. end
  1264. # 条件を満たせなければ以降のアクションを中断
  1265. return @action = ["End"] if @non_repeat
  1266. # 防御中は不自然に見えないように座標復帰させない
  1267. action = @battler.recover_action
  1268. action = @battler.defence if @battler.guarding?
  1269. return start_action(action)
  1270. end
  1271. #--------------------------------------------------------------------------
  1272. # ● Derivating skills (link skills)
  1273. #--------------------------------------------------------------------------
  1274. def derivating # Redefined 1.1e
  1275. return if $game_party.all_dead? or $game_troop.all_dead?
  1276. skill = $data_skills[@active_action[3]] # retrive actual skill
  1277. # test for skill learning. If not learned and link is not set, stop here
  1278. return if @battler.actor? && !@battler.skill_learn?(skill) && !@active_action[2]
  1279. # this takes the actual skill object
  1280. return unless @battler.skill_can_use?(skill) # test if skill can be used
  1281. # skill fails if the random number is below the given chance
  1282. return if rand(100) > @active_action[1]
  1283. # sets the derivation
  1284. @battler.derivation = @active_action[3]
  1285. # sets the current action to ["End"]
  1286. @action = ["End"]
  1287. end
  1288. #--------------------------------------------------------------------------
  1289. # ● 個別処理開始
  1290. #--------------------------------------------------------------------------
  1291. def individual_action
  1292. # リピートフラグオン
  1293. @battler.individual = true
  1294. # リピートアクションを保持
  1295. @individual_act = @action.dup
  1296. # ターゲットを保持し、行動ターゲットをひとつずつ抜き出す
  1297. send_action(["Individual"])
  1298. @individual_targets = @target_battler.dup
  1299. @target_battler = [@individual_targets.shift]
  1300. end
  1301. #--------------------------------------------------------------------------
  1302. # ● 個別処理終了
  1303. #--------------------------------------------------------------------------
  1304. def individual_action_end
  1305. # ターゲットが残っていないなら行動終了
  1306. return @battler.individual = false if @individual_targets.size == 0
  1307. @action = @individual_act.dup
  1308. @target_battler = [@individual_targets.shift]
  1309. end
  1310. #--------------------------------------------------------------------------
  1311. # ● 待機に移行しない
  1312. #--------------------------------------------------------------------------
  1313. def non_repeat
  1314. @repeat_action = []
  1315. @non_repeat = true
  1316. anime_finish
  1317. end
  1318. #--------------------------------------------------------------------------
  1319. # ● ターゲット変更 action = [判別, 変更する対象, 変更先]
  1320. #--------------------------------------------------------------------------
  1321. def change_target
  1322. # 自身の変更したターゲットを元に戻す
  1323. return @target_battler = @now_targets.dup if @active_action[2] == 3
  1324. # 送るターゲット情報
  1325. target = [@battler] if @active_action[2] == 0
  1326. target = @target_battler.dup if @active_action[2] != 0
  1327. # 自身のターゲットを送った相手にする場合、現在のターゲットを記憶
  1328. if @active_action[2] == 2
  1329. @now_targets = @target_battler.dup
  1330. @target_battler = []
  1331. end
  1332. # 送るターゲットがインデックス指定の場合
  1333. if @active_action[1] >= 1000
  1334. members = $game_party.members if @battler.actor?
  1335. members = $game_troop.members unless @battler.actor?
  1336. index = @active_action[1] - 1000
  1337. if index < members.size
  1338. if members[index].exist? && @battler.index != index
  1339. # ターゲット変更
  1340. members[index].force_target = ["N01target_change", target]
  1341. # 自身のターゲットを送った相手にする場合
  1342. @target_battler = [members[index]] if @active_action[2] == 2
  1343. change = true
  1344. else
  1345. for member in members
  1346. next if @battler.index == member.index
  1347. next unless member.exist?
  1348. member.force_target = ["N01target_change", target]
  1349. @target_battler = [member] if @active_action[2] == 2
  1350. break change = true
  1351. end
  1352. end
  1353. end
  1354. # 送るターゲットがステートID指定だった場合
  1355. elsif @active_action[1] > 0
  1356. for member in $game_party.members + $game_troop.members
  1357. if member.state?(@active_action[1])
  1358. member.force_target = ["N01target_change", target]
  1359. @target_battler.push(member) if @active_action[2] == 2
  1360. change = true
  1361. end
  1362. end
  1363. # 送るターゲットが習得スキル指定だった場合
  1364. elsif @active_action[1] < 0
  1365. skill_id = @active_action[1].abs
  1366. for actor in $game_party.members
  1367. if actor.skill_id_learn?(skill_id)
  1368. actor.force_target = ["N01target_change", target]
  1369. @target_battler.push(target) if @active_action[2] == 2
  1370. change = true
  1371. end
  1372. end
  1373. # 送るターゲットがターゲットだった場合
  1374. else
  1375. for member in @target_battler
  1376. member.force_target = ["N01target_change", target]
  1377. @target_battler.push(member) if @active_action[2] == 2
  1378. change = true
  1379. end
  1380. end
  1381. # 条件を満たせなければ以降のアクションを中断
  1382. return if change
  1383. return @action = ["End"] if @non_repeat
  1384. return start_action(@battler.recover_action)
  1385. end
  1386. #--------------------------------------------------------------------------
  1387. # ● ステート付与
  1388. #--------------------------------------------------------------------------
  1389. def state_on
  1390. state_id = @active_action[2]
  1391. # 対象で分岐
  1392. case @active_action[1]
  1393. when 0
  1394. @battler.add_state(state_id) if rand(100) < @battler.state_probability(state_id)
  1395. when 1
  1396. if @target_battler != nil
  1397. for target in @target_battler
  1398. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1399. end
  1400. end
  1401. when 2
  1402. for target in $game_troop.members
  1403. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1404. end
  1405. when 3
  1406. for target in $game_party.members
  1407. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1408. end
  1409. when 4
  1410. for target in $game_party.members
  1411. if target.index != @battler.index
  1412. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1413. end
  1414. end
  1415. end
  1416. end
  1417. #--------------------------------------------------------------------------
  1418. # ● ステート解除
  1419. #--------------------------------------------------------------------------
  1420. def state_off
  1421. state_id = @active_action[2]
  1422. # 対象で分岐
  1423. case @active_action[1]
  1424. when 0
  1425. @battler.remove_state(state_id)
  1426. when 1
  1427. if @target_battler != nil
  1428. for target in @target_battler
  1429. target.remove_state(state_id)
  1430. end
  1431. end
  1432. when 2
  1433. for target in $game_troop.members
  1434. target.remove_state(state_id)
  1435. end
  1436. when 3
  1437. for target in $game_party.members
  1438. target.remove_state(state_id)
  1439. end
  1440. when 4
  1441. for target in $game_party.members
  1442. if target.index != @battler.index
  1443. target.remove_state(state_id)
  1444. end
  1445. end
  1446. end
  1447. end
  1448. #--------------------------------------------------------------------------
  1449. # ● 浮遊実行
  1450. #--------------------------------------------------------------------------
  1451. def floating
  1452. # ジャンプを初期化
  1453. jump_reset
  1454. # 情報確認
  1455. @jump_plus = @active_action[1]
  1456. float_end = @active_action[2]
  1457. @float_time = @active_action[3]
  1458. # 1フレーム当たりの移動高度を計算
  1459. @float_up = (float_end - @jump_plus)/ @float_time
  1460. # 浮遊が完了するまで次のアクションに行かない
  1461. @wait = @float_time
  1462. # 浮遊アニメ設定を反映
  1463. if @anime_flug
  1464. move_anime = N01::ANIME[@active_action[4]]
  1465. # グラフィック指定がない場合はスキップ
  1466. if move_anime != nil
  1467. # 現在のアクションを上書き
  1468. @active_action = move_anime
  1469. # バトラーアニメ開始
  1470. battler_anime
  1471. # 浮遊が完了したら即アニメが終わるように
  1472. @anime_end = true
  1473. end
  1474. end
  1475. # 初期高度に浮遊
  1476. @battler.jump = @jump_plus
  1477. end
  1478. #--------------------------------------------------------------------------
  1479. # ● 強制アクション
  1480. #--------------------------------------------------------------------------
  1481. def force_action
  1482. # アクションが単発か通しか判別
  1483. kind = @active_action[0]
  1484. # 復帰の有無をチェック
  1485. rebirth = @active_action[2]
  1486. # 強制アクション内容を取得
  1487. play = @active_action[3]
  1488. # 上3つの情報をまとめて格納
  1489. action = [kind,rebirth,play]
  1490. # ターゲットがインデックス指定の場合
  1491. if @active_action[1] >= 1000
  1492. members = $game_party.members if @battler.actor?
  1493. members = $game_troop.members unless @battler.actor?
  1494. index = @active_action[1] - 1000
  1495. if index < members.size
  1496. if members[index].exist? && @battler.index != index
  1497. # バトラー情報に渡す
  1498. return members[index].force_action = action
  1499. else
  1500. for target in members
  1501. next if @battler.index == target.index
  1502. next unless target.exist?
  1503. force = true
  1504. break target.force_action = action
  1505. end
  1506. end
  1507. end
  1508. # 条件を満たせなければ以降のアクションを中断
  1509. return if force
  1510. return @action = ["End"] if @non_repeat
  1511. return start_action(@battler.recover_action)
  1512. # ターゲット指定の場合
  1513. elsif @active_action[1] == 0
  1514. for target in @target_battler
  1515. target.force_action = action if target != nil
  1516. end
  1517. # ステートID指定だった場合
  1518. elsif @active_action[1] > 0
  1519. for target in $game_party.members + $game_troop.members
  1520. target.force_action = action if target.state?(@active_action[1])
  1521. end
  1522. # 習得スキル指定だった場合
  1523. elsif @active_action[1] < 0
  1524. # エネミーは処理させない
  1525. return if @battler.is_a?(Game_Enemy)
  1526. for actor in $game_party.members
  1527. # 自分は除く
  1528. unless actor.id == @battler.id
  1529. # バトラー情報に渡す
  1530. actor.force_action = action if actor.skill_id_learn?(@active_action[1].abs)
  1531. end
  1532. end
  1533. end
  1534. end
  1535. #--------------------------------------------------------------------------
  1536. # ● 座標リセット実行
  1537. #--------------------------------------------------------------------------
  1538. def reseting
  1539. # ジャンプを初期化
  1540. jump_reset
  1541. # 回転を元に戻す
  1542. self.angle = 0
  1543. # 情報確認
  1544. @distanse_x = @move_x * -1
  1545. @distanse_y = @move_y * -1
  1546. @move_speed_x = @active_action[1]
  1547. @move_speed_y = @move_speed_x
  1548. @move_boost_x = @active_action[2]
  1549. @move_boost_y = @move_boost_x
  1550. @jump = @active_action[3]
  1551. # 移動計算
  1552. move_distance
  1553. # 移動アニメ設定を反映
  1554. if @anime_flug
  1555. move_anime = N01::ANIME[@active_action[4]]
  1556. # グラフィック指定がない場合はスキップ
  1557. if move_anime != nil
  1558. # 現在のアクションを上書き
  1559. @active_action = move_anime
  1560. # バトラーアニメ開始
  1561. battler_anime
  1562. end
  1563. # 移動が完了したら即アニメが終わるように
  1564. @anime_end = true
  1565. end
  1566. end
  1567. #--------------------------------------------------------------------------
  1568. # ● 移動実行
  1569. #--------------------------------------------------------------------------
  1570. def moving
  1571. # Initialize jump values
  1572. jump_reset
  1573. # X-coordinate destination
  1574. xx = @active_action[1]
  1575. # Invert xx when in back attack
  1576. xx *= -1 if $back_attack
  1577. # Verify target of moving battler
  1578. case @active_action[0]
  1579. when 0 # Self
  1580. @distanse_x = xx
  1581. @distanse_y = @active_action[2]
  1582. when 1 # Target
  1583. # ターゲットが決まってない場合、自身に変換
  1584. if @target_battler == nil
  1585. @distanse_x = xx
  1586. @distanse_y = @active_action[2]
  1587. else
  1588. # ターゲット対象をひとつずつチェック
  1589. target_x = 0
  1590. target_y = 0
  1591. time = 0
  1592. for i in 0...@target_battler.size
  1593. if @target_battler[i] != nil
  1594. time += 1
  1595. target_x += @target_battler[i].position_x
  1596. target_y += @target_battler[i].position_y
  1597. end
  1598. end
  1599. # ターゲットが空だった場合、自身に変換
  1600. if time == 0
  1601. @distanse_x = xx
  1602. @distanse_y = @active_action[2]
  1603. else
  1604. # 複数ターゲットの中心を計算
  1605. target_x = target_x / time
  1606. target_y = target_y / time
  1607. # 最終的な移動距離を算出
  1608. @distanse_y = target_y - self.y + @active_action[2]
  1609. # X座標はアクターとエネミーで逆計算
  1610. if @battler.is_a?(Game_Actor)
  1611. @distanse_x = target_x - self.x + xx
  1612. else
  1613. @distanse_x = self.x - target_x + xx
  1614. end
  1615. end
  1616. end
  1617. when 2 # Screen
  1618. # X座標はアクターとエネミーで逆計算
  1619. if @battler.is_a?(Game_Actor)
  1620. @distanse_x = xx - self.x
  1621. @distanse_x = Graphics.width + xx - self.x if $back_attack
  1622. else
  1623. @distanse_x = self.x - xx
  1624. @distanse_x = self.x - (Graphics.width + xx) if $back_attack
  1625. end
  1626. @distanse_y = @active_action[2] - self.y
  1627. when 3 # Start Position
  1628. # X座標はアクターとエネミーで逆計算
  1629. if @battler.is_a?(Game_Actor)
  1630. @distanse_x = xx + @battler.base_position_x - self.x
  1631. else
  1632. @distanse_x = xx + self.x - @battler.base_position_x
  1633. end
  1634. @distanse_y = @active_action[2] + @battler.base_position_y - @battler.position_y
  1635. when 4 # Head 3.4b
  1636. # ターゲットが決まってない場合、自身に変換
  1637. if @target_battler == nil
  1638. @distanse_x = xx
  1639. @distanse_y = @active_action[2]
  1640. else
  1641. # ターゲット対象をひとつずつチェック
  1642. target_x = 0
  1643. target_y = 0
  1644. time = 0
  1645. for i in 0...@target_battler.size
  1646. if @target_battler[i] != nil
  1647. time += 1
  1648. shift_y = @target_battler[i].graphics_height * 2 / 3
  1649. target_x += @target_battler[i].position_x
  1650. target_y += @target_battler[i].position_y - shift_y # 3.4b
  1651. end
  1652. end
  1653. # ターゲットが空だった場合、自身に変換
  1654. if time == 0
  1655. @distanse_x = xx
  1656. @distanse_y = @active_action[2]
  1657. else
  1658. # 複数ターゲットの中心を計算
  1659. target_x = target_x / time
  1660. target_y = target_y / time
  1661. # 最終的な移動距離を算出
  1662. @distanse_y = target_y - self.y + @active_action[2]
  1663. # X座標はアクターとエネミーで逆計算
  1664. if @battler.is_a?(Game_Actor)
  1665. @distanse_x = target_x - self.x + xx
  1666. else
  1667. @distanse_x = self.x - target_x + xx
  1668. end
  1669. end
  1670. end
  1671. when 5 # Feet 3.4b
  1672. # ターゲットが決まってない場合、自身に変換
  1673. if @target_battler == nil
  1674. @distanse_x = xx
  1675. @distanse_y = @active_action[2]
  1676. else
  1677. # ターゲット対象をひとつずつチェック
  1678. target_x = 0
  1679. target_y = 0
  1680. time = 0
  1681. for i in 0...@target_battler.size
  1682. if @target_battler[i] != nil
  1683. time += 1
  1684. shift_y = @target_battler[i].graphics_height / 3
  1685. target_x += @target_battler[i].position_x
  1686. target_y += @target_battler[i].position_y + shift_y # 3.4b
  1687. end
  1688. end
  1689. # ターゲットが空だった場合、自身に変換
  1690. if time == 0
  1691. @distanse_x = xx
  1692. @distanse_y = @active_action[2]
  1693. else
  1694. # 複数ターゲットの中心を計算
  1695. target_x = target_x / time
  1696. target_y = target_y / time
  1697. # 最終的な移動距離を算出
  1698. @distanse_y = target_y - self.y + @active_action[2]
  1699. # X座標はアクターとエネミーで逆計算
  1700. if @battler.is_a?(Game_Actor)
  1701. @distanse_x = target_x - self.x + xx
  1702. else
  1703. @distanse_x = self.x - target_x + xx
  1704. end
  1705. end
  1706. end
  1707. end
  1708. @move_speed_x = @active_action[3]
  1709. @move_speed_y = @active_action[3]
  1710. @move_boost_x = @active_action[4]
  1711. @move_boost_y = @active_action[4]
  1712. @jump = @active_action[5]
  1713. @jump_plus = 0
  1714. # 移動計算
  1715. move_distance
  1716. # 移動アニメ設定を反映
  1717. if @anime_flug
  1718. move_anime = N01::ANIME[@active_action[6]]
  1719. # グラフィック指定がない場合はスキップ
  1720. if move_anime != nil
  1721. # 現在のアクションを上書き
  1722. @active_action = move_anime
  1723. # バトラーアニメ開始
  1724. battler_anime
  1725. end
  1726. # 移動が完了したら即アニメが終わるように
  1727. @anime_end = true
  1728. end
  1729. end
  1730. #--------------------------------------------------------------------------
  1731. # ● 移動計算
  1732. #--------------------------------------------------------------------------
  1733. def move_distance
  1734. # 速度が0の場合、その場に留まる
  1735. if @move_speed_x == 0
  1736. @moving_x = 0
  1737. @moving_y = 0
  1738. else
  1739. # 1フレームあたりの移動距離を計算
  1740. @moving_x = @distanse_x / @move_speed_x
  1741. @moving_y = @distanse_y / @move_speed_y
  1742. # 余った距離はこの時点で移動し消化
  1743. over_x = @distanse_x % @move_speed_x
  1744. over_y = @distanse_y % @move_speed_y
  1745. @move_x += over_x
  1746. @move_y += over_y
  1747. @battler.move_x = @move_x
  1748. @battler.move_y = @move_y
  1749. @distanse_x -= over_x
  1750. @distanse_y -= over_y
  1751. end
  1752. # 移動があるかどうかの判定
  1753. if @distanse_x == 0
  1754. @move_speed_x = 0
  1755. end
  1756. if @distanse_y == 0
  1757. @move_speed_y = 0
  1758. end
  1759. # X座標移動計算
  1760. # 加減速による移動フレーム数の修正
  1761. boost_x = @moving_x
  1762. move_x = 0
  1763. # 加速がある場合
  1764. if @move_boost_x > 0 && @distanse_x != 0
  1765. # 加減速の正負を左右移動に合わせて変換
  1766. if @distanse_x == 0
  1767. @move_boost_x = 0
  1768. elsif @distanse_x < 0
  1769. @move_boost_x *= -1
  1770. end
  1771. # 距離の変化を事前計算
  1772. for i in 0...@move_speed_x
  1773. boost_x += @move_boost_x
  1774. move_x += boost_x
  1775. # オーバー距離を記録
  1776. over_distance = @distanse_x - move_x
  1777. # 右移動で距離オーバーする直前が何フレーム目だったか記録
  1778. if @distanse_x > 0 && over_distance < 0
  1779. @move_speed_x = i
  1780. break
  1781. # 左移動で距離オーバーする直前が何フレーム目だったか記録
  1782. elsif @distanse_x < 0 && over_distance > 0
  1783. @move_speed_x = i
  1784. break
  1785. end
  1786. end
  1787. # オーバー距離を一回前に戻す
  1788. before = over_distance + boost_x
  1789. # 余った距離を等速移動させるフレーム数を加算
  1790. @move_speed_plus_x = (before / @moving_x).abs
  1791. # それでも余った距離はこの時点で移動し消化
  1792. @move_x += before % @moving_x
  1793. @battler.move_x = @move_x
  1794. # 減速がある場合
  1795. elsif @move_boost_x < 0 && @distanse_x != 0
  1796. # 加減速の正負を左右移動に合わせて変換
  1797. if @distanse_x == 0
  1798. @move_boost_x = 0
  1799. elsif @distanse_x < 0
  1800. @move_boost_x *= -1
  1801. end
  1802. # 距離の変化を事前計算
  1803. for i in 0...@move_speed_x
  1804. boost_x += @move_boost_x
  1805. move_x += boost_x
  1806. # 足りない距離を記録
  1807. lost_distance = @distanse_x - move_x
  1808. before = lost_distance
  1809. # 右移動で速度が0になる直前が何フレーム目だったか記録
  1810. if @distanse_x > 0 && boost_x < 0
  1811. @move_speed_x = i - 1
  1812. # 足りない距離を一回前に戻す
  1813. before = lost_distance + boost_x
  1814. break
  1815. # 左移動で速度が0になる直前が何フレーム目だったか記録
  1816. elsif @distanse_x < 0 && boost_x > 0
  1817. @move_speed_x= i - 1
  1818. # 足りない距離を一回前に戻す
  1819. before = lost_distance + boost_x
  1820. break
  1821. end
  1822. end
  1823. # 足りない距離を等速移動させるフレーム数を加算
  1824. plus = before / @moving_x
  1825. @move_speed_plus_x = plus.abs
  1826. # それでも余った距離はこの時点で移動し消化
  1827. @move_x += before % @moving_x
  1828. @battler.move_x = @move_x
  1829. end
  1830. # Y座標移動計算
  1831. # 加減速による移動フレーム数の修正
  1832. boost_y = @moving_y
  1833. move_y = 0
  1834. # 加速がある場合
  1835. if @move_boost_y > 0 && @distanse_y != 0
  1836. # 加減速の正負を左右移動に合わせて変換
  1837. if @distanse_y == 0
  1838. @move_boost_y = 0
  1839. elsif @distanse_y < 0
  1840. @move_boost_y *= -1
  1841. end
  1842. # 距離の変化を事前計算
  1843. for i in 0...@move_speed_y
  1844. boost_y += @move_boost_y
  1845. move_y += boost_y
  1846. # オーバー距離を記録
  1847. over_distance = @distanse_y - move_y
  1848. # 右移動で距離オーバーする直前が何フレーム目だったか記録
  1849. if @distanse_y > 0 && over_distance < 0
  1850. @move_speed_y = i
  1851. break
  1852. # 左移動で距離オーバーする直前が何フレーム目だったか記録
  1853. elsif @distanse_y < 0 && over_distance > 0
  1854. @move_speed_y = i
  1855. break
  1856. end
  1857. end
  1858. # オーバー距離を一回前に戻す
  1859. before = over_distance + boost_y
  1860. # 余った距離を等速移動させるフレーム数を加算
  1861. @move_speed_plus_y = (before / @moving_y).abs
  1862. # それでも余った距離はこの時点で移動し消化
  1863. @move_y += before % @moving_y
  1864. @battler.move_y = @move_y
  1865. # 減速がある場合
  1866. elsif @move_boost_y < 0 && @distanse_y != 0
  1867. # 加減速の正負を左右移動に合わせて変換
  1868. if @distanse_y == 0
  1869. @move_boost_y = 0
  1870. elsif @distanse_y < 0
  1871. @move_boost_y *= -1
  1872. end
  1873. # 距離の変化を事前計算
  1874. for i in 0...@move_speed_y
  1875. boost_y += @move_boost_y
  1876. move_y += boost_y
  1877. # 足りない距離を記録
  1878. lost_distance = @distanse_y - move_y
  1879. before = lost_distance
  1880. # 右移動で速度が0になる直前が何フレーム目だったか記録
  1881. if @distanse_y > 0 && boost_y < 0
  1882. @move_speed_y = i
  1883. # 足りない距離を一回前に戻す
  1884. before = lost_distance + boost_y
  1885. break
  1886. # 左移動で速度が0になる直前が何フレーム目だったか記録
  1887. elsif @distanse_y < 0 && boost_y > 0
  1888. @move_speed_y = i
  1889. # 足りない距離を一回前に戻す
  1890. before = lost_distance + boost_y
  1891. break
  1892. end
  1893. end
  1894. # 足りない距離を等速移動させるフレーム数を加算
  1895. plus = before / @moving_y
  1896. @move_speed_plus_y = plus.abs
  1897. # それでも余った距離はこの時点で移動し消化
  1898. @move_y += before % @moving_y
  1899. @battler.move_y = @move_y
  1900. end
  1901. # 移動完了時間を算出
  1902. x = @move_speed_plus_x + @move_speed_x
  1903. y = @move_speed_plus_y + @move_speed_y
  1904. if x > y
  1905. end_time = x
  1906. else
  1907. end_time = y
  1908. end
  1909. # 移動が完了するまで次のアクションに行かない
  1910. @wait = end_time
  1911. # ジャンプ計算
  1912. if @jump != 0
  1913. # 移動がなくジャンプのみの場合
  1914. if @wait == 0
  1915. # 時間に計上
  1916. @wait = @active_action[3]
  1917. end
  1918. # 移動完了時間からジャンプ時間を算出
  1919. @jump_time = @wait / 2
  1920. # 割り切れない場合の余り時間
  1921. @jump_time_plus = @wait % 2
  1922. # ジャンプの正負を判別
  1923. @jump_sign = 0
  1924. @jump_sign2 = 0
  1925. if @jump < 0
  1926. @jump_sign = -1
  1927. @jump_sign2 = 1
  1928. @jump = @jump * -1
  1929. else
  1930. @jump_sign = 1
  1931. @jump_sign2 = -1
  1932. end
  1933. # ジャンプ初速度を決定
  1934. @jump_up = 2 ** @jump * @jump_sign
  1935. # ジャンプ時間の端数を微調整
  1936. if @jump_time == 0
  1937. @jump_up = 0
  1938. elsif @jump_time != 1
  1939. @jump_size = @jump_up * @jump_sign * @jump_sign2
  1940. else
  1941. @jump_size = @jump_up * 2 * @jump_sign * @jump_sign2
  1942. @jump_flug = true
  1943. end
  1944. end
  1945. end
  1946. #--------------------------------------------------------------------------
  1947. # ++ Battler Frame Animation Setup
  1948. #--------------------------------------------------------------------------
  1949. def battler_anime
  1950. # アニメ設定を反映
  1951. @anime_kind = @active_action[1]
  1952. @anime_speed = @active_action[2]
  1953. @anime_loop = @active_action[3]
  1954. # ウエイト時間があれば加算
  1955. @unloop_wait = @active_action[4]
  1956. @anime_end = true
  1957. @reverse = false
  1958. # 武器アクションがある場合だけ更新する
  1959. if @weapon_R != nil && @active_action[8] != ""
  1960. # 武器の設定をチェック
  1961. weapon_kind = N01::ANIME[@active_action[8]]
  1962. # エネミーと二刀ではないアクターの二刀フラグアニメ処理はキャンセル
  1963. two_swords_flug = weapon_kind[11]
  1964. return if two_swords_flug && !@battler.actor?
  1965. return if two_swords_flug && @battler.weapons[1] == nil && @battler.actor?
  1966. if @battler.actor? && @battler.weapons[0] == nil && !two_swords_flug
  1967. @weapon_R.action_reset
  1968. elsif @battler.actor? && @battler.weapons[1] == nil && two_swords_flug
  1969. @weapon_R.action_reset
  1970. elsif !@battler.actor? && @battler.weapon == 0
  1971. @weapon_R.action_reset
  1972. else
  1973. # 初期化
  1974. @weapon_R.action_reset
  1975. # アニメパターンが固定だった場合の武器位置を取得
  1976. if @active_action[5] != -1
  1977. @weapon_R.freeze(@active_action[5])
  1978. end
  1979. # 武器画像を設定
  1980. @weapon_R.weapon_graphics unless two_swords_flug
  1981. @weapon_R.weapon_graphics(true) if two_swords_flug
  1982. # 武器アクションを渡す
  1983. @weapon_R.weapon_action(@active_action[8],@anime_loop)
  1984. @weapon_action = true
  1985. # 最初の武器アクションを更新
  1986. @weapon_R.action
  1987. end
  1988. elsif @weapon_R != nil
  1989. @weapon_R.action_reset
  1990. end
  1991. @anime_end = false
  1992. # アニメパターンが固定だった場合
  1993. if @active_action[5] != -1 && @active_action[5] != -2
  1994. # フラグオン
  1995. @anime_freeze = true
  1996. # アニメが常に終了しているとみなす
  1997. @anime_end = true
  1998. # 片道逆転再生だった場合
  1999. elsif @active_action[5] == -2
  2000. @anime_freeze = false
  2001. # フラグオン
  2002. @reverse = true
  2003. # 最初のアニメパターンを更新
  2004. @pattern = @base_width - 1
  2005. # 武器アニメがある時だけフレーム更新
  2006. if @weapon_action && @weapon_R != nil
  2007. @weapon_R.action
  2008. @weapon_R.update
  2009. end
  2010. # 通常のアニメ更新の場合
  2011. else
  2012. @anime_freeze = false
  2013. # 最初のアニメパターンを更新
  2014. @pattern = 0
  2015. # 武器アニメがある時だけフレーム更新
  2016. if @weapon_action && @weapon_R != nil
  2017. @weapon_R.action
  2018. @weapon_R.update
  2019. end
  2020. end
  2021. @pattern_back = false
  2022. @frame = @anime_speed
  2023. @battler.move_z = @active_action[6]
  2024. # 影の有無
  2025. if @shadow != nil
  2026. @shadow.visible = true if @active_action[7]
  2027. @shadow.visible = false unless @active_action[7]
  2028. end
  2029. # ナンバリングから読み取るファイル名を分岐
  2030. if @active_action[0] == 0
  2031. file_name = @battler_name
  2032. else
  2033. file_name = @battler_name + "_" + @active_action[0].to_s
  2034. end
  2035. # アニメしないバトラーなら処理終了
  2036. return unless @anime_flug
  2037. @battler_hue = @battler.battler_hue ## blackmorning unofficial code; 3.3c
  2038. if @battler_hue != nil
  2039. self.bitmap = Cache.character(file_name, @battler_hue)
  2040. else
  2041. self.bitmap = Cache.character(file_name)
  2042. end ## end blackmorning unofficial code; 3.3c
  2043. # 転送元の矩形を設定
  2044. @sx = @pattern * @width
  2045. @sy = @anime_kind * @height
  2046. @sx = @active_action[5] * @width if @anime_freeze
  2047. self.src_rect.set(@sx, @sy, @width, @height)
  2048. end
  2049. #--------------------------------------------------------------------------
  2050. # ++ Moving Animations
  2051. #--------------------------------------------------------------------------
  2052. def moving_anime
  2053. # まだ前のアニメ飛ばしが残っているなら初期化
  2054. # If the previous animation exists, initialize actions
  2055. @move_anime.action_reset if @anime_moving
  2056. @anime_moving = true
  2057. # Mirror when in a surprise encounter
  2058. mirror = false
  2059. mirror = true if $back_attack
  2060. # Animation ID
  2061. id = @active_action[1]
  2062. # Object/Target
  2063. target = @active_action[2]
  2064. x = y = mem = 0
  2065. # If object is a single unit
  2066. if target == 0
  2067. # ターゲットが決まってない場合、自身に変換
  2068. # If target is not decided, change target to self
  2069. if @target_battler == nil
  2070. x = self.x
  2071. y = self.y
  2072. else
  2073. # ターゲットが空の場合、自身に変換
  2074. # If target is nil, change target to self
  2075. if @target_battler[0] == nil
  2076. x = self.x
  2077. y = self.y
  2078. else
  2079. # 最初に入っているターゲットに対象決定
  2080. # If target is confirmed, get position
  2081. x = @target_battler[0].position_x
  2082. y = @target_battler[0].position_y
  2083. end
  2084. end
  2085. # 対象が敵の中心の場合
  2086. # When the object/targets is a group of enemies
  2087. elsif target == 1
  2088. # 自身がアクターの場合はエネミーの中心を計算
  2089. # Calculate the center position of the party
  2090. if @battler.is_a?(Game_Actor)
  2091. for target in $game_troop.members
  2092. x += target.position_x
  2093. y += target.position_y
  2094. mem += 1
  2095. end
  2096. x = x / mem
  2097. y = y / mem
  2098. # 自身がエネミーの場合はアクターの中心を計算
  2099. # Calculate the center position of the enemy targets
  2100. else
  2101. for target in $game_party.members
  2102. x += target.position_x
  2103. y += target.position_y
  2104. mem += 1
  2105. end
  2106. x = x / mem
  2107. y = y / mem
  2108. end
  2109. # 対象が味方の中心の場合
  2110. # When the object/targets are a group of actors
  2111. elsif target == 2
  2112. # 自身がアクターの場合はアクターの中心を計算
  2113. # Calculate center of actor party
  2114. if @battler.is_a?(Game_Actor)
  2115. for target in $game_party.members
  2116. x += target.position_x
  2117. y += target.position_y
  2118. mem += 1
  2119. end
  2120. x = x / mem
  2121. y = y / mem
  2122. # 自身がエネミーの場合はエネミーの中心を計算
  2123. # Calculate cetner of enemy troop
  2124. else
  2125. for target in $game_troop.members
  2126. x += target.position_x
  2127. y += target.position_y
  2128. mem += 1
  2129. end
  2130. x = x / mem
  2131. y = y / mem
  2132. end
  2133. # Object is self
  2134. else
  2135. x = self.x
  2136. y = self.y
  2137. end
  2138. # 開始位置の微調整
  2139. # Adjust position of animation
  2140. plus_x = @active_action[6]
  2141. plus_y = @active_action[7]
  2142. # エネミーはX軸を逆に
  2143. # x-axis is reversed for enemies
  2144. plus_x *= -1 if @battler.is_a?(Game_Enemy)
  2145. # 最終的な移動距離を算出
  2146. # Calculate distance from source to target
  2147. distanse_x = x - self.x - plus_x
  2148. distanse_y = y - self.y - plus_y
  2149. # 飛ばしタイプ
  2150. # Get animation pass-through value
  2151. type = @active_action[3]
  2152. # Speed of animation
  2153. speed = @active_action[4]
  2154. # 軌道
  2155. # Orbit/arc
  2156. orbit = @active_action[5]
  2157. # 自身が開始位置なら
  2158. # If origin is self
  2159. if @active_action[8] == 0
  2160. @move_anime.base_x = self.x + plus_x
  2161. @move_anime.base_y = self.y + plus_y
  2162. # 対象が開始位置なら
  2163. # If origin is target
  2164. elsif @active_action[8] == 1
  2165. @move_anime.base_x = x + plus_x
  2166. @move_anime.base_y = y + plus_y
  2167. # 距離を反対に
  2168. distanse_y = distanse_y * -1
  2169. distanse_x = distanse_x * -1
  2170. # 動かさないなら
  2171. # If other origin
  2172. else
  2173. @move_anime.base_x = x
  2174. @move_anime.base_y = y
  2175. distanse_x = distanse_y = 0
  2176. end
  2177. # 武器アクションなしは武器表示しない
  2178. # Flying graphic is nothing
  2179. if @active_action[10] == ""
  2180. weapon = ""
  2181. # アニメなしエネミーは武器表示しない
  2182. # No flying graphic if not animated
  2183. # elsif @anime_flug != true # 3.4a
  2184. # weapon = ""
  2185. ## 武器アクションがある場合
  2186. # If there is a weapon action
  2187. else
  2188. # 飛ばす武器グラフィックが指定されているかチェック
  2189. # Check if weapon has a flying graphic
  2190. if @battler.is_a?(Game_Actor)
  2191. battler = $game_party.members[@battler.index]
  2192. weapon_id = battler.weapon_id
  2193. else
  2194. battler = $game_troop.members[@battler.index]
  2195. weapon_id = battler.weapon
  2196. end
  2197. # スキル画像利用か武器画像利用か判別
  2198. # Determine use of equipped weapon graphic or other graphic
  2199. weapon_act = N01::ANIME[@active_action[10]].dup if @active_action[10] != ""
  2200. # 3.4a
  2201. # Moved the priority of skill flying graphic
  2202. use_skill_item_graphic = false
  2203. # Set skill flying graphic, 3.4a
  2204. if weapon_act != nil && @battler.action.skill != nil
  2205. skill_flygraphic = $data_skills[@battler.action.skill.id].flying_graphic
  2206. # If skill has flying graphic
  2207. if skill_flygraphic.downcase == "icon"
  2208. icon_weapon = true
  2209. use_skill_item_graphic = true
  2210. weapon = @active_action[10]
  2211. weapon_name = $data_skills[@battler.action.skill.id].icon_index
  2212. elsif skill_flygraphic != ""
  2213. icon_weapon = false
  2214. use_skill_item_graphic = true
  2215. weapon = @active_action[10]
  2216. weapon_name = skill_flygraphic
  2217. end
  2218. # Set item flying graphic, 3.4a
  2219. elsif weapon_act != nil && @battler.action.item != nil
  2220. item_flygraphic = $data_items[@battler.action.item.id].flying_graphic
  2221. # if item has a flying graphic
  2222. if item_flygraphic.downcase == "icon"
  2223. icon_weapon = true
  2224. use_skill_item_graphic = true
  2225. weapon = @active_action[10]
  2226. weapon_name = $data_items[@battler.action.item.id].icon_index
  2227. elsif item_flygraphic != ""
  2228. icon_weapon = false
  2229. use_skill_item_graphic = true
  2230. weapon = @active_action[10]
  2231. weapon_name = item_flygraphic
  2232. end
  2233. end
  2234. # 武器画像利用で素手でなければ
  2235. # If user has a weapon, utilize graphics
  2236. if weapon_id != 0 && weapon_act.size == 3 && !use_skill_item_graphic # 3.4a
  2237. weapon_file = $data_weapons[weapon_id].flying_graphic
  2238. weapon_file = "" if weapon_file.downcase == "icon" # 3.4a
  2239. # If a flying graphic is not given, get weapon graphic
  2240. if weapon_file == ""
  2241. weapon_name = $data_weapons[weapon_id].graphic
  2242. icon_weapon = false
  2243. # さらに指定がなければアイコングラフィックを利用
  2244. # If weapon graphic is not found, get Iconset graphic.
  2245. if weapon_name == ""
  2246. weapon_name = $data_weapons[weapon_id].icon_index
  2247. icon_weapon = true
  2248. end
  2249. # 指定されていればそのグラフィック名を取得
  2250. # If there is a specified graphics
  2251. else
  2252. icon_weapon = false
  2253. weapon_name = weapon_file
  2254. end
  2255. # 武器アクション情報を取得
  2256. # Get weapon action
  2257. weapon = @active_action[10]
  2258. # 武器画像利用で素手なら表示しない
  2259. elsif weapon_act.size == 3 && !use_skill_item_graphic # 3.4a
  2260. weapon = ""
  2261. # # スキル画像利用
  2262. # elsif weapon_act != nil && @battler.action.skill != nil
  2263. # icon_weapon = false
  2264. # weapon_name = $data_skills[@battler.action.skill.id].flying_graphic
  2265. # weapon = @active_action[10]
  2266. end
  2267. end
  2268. # Z座標を決定
  2269. @move_anime.z = 1
  2270. @move_anime.z = 1000 if @active_action[9]
  2271. # 以上の情報を全てアニメ飛ばしスプライトに送る
  2272. @move_anime.anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,weapon_name,icon_weapon)
  2273. end
  2274. #--------------------------------------------------------------------------
  2275. # ● アクション終了
  2276. #--------------------------------------------------------------------------
  2277. def anime_finish
  2278. # 個別処理終了が省略された場合リピートさせる
  2279. return individual_action_end if @individual_targets.size != 0
  2280. # アクティブバトラーにアクション情報を格納
  2281. send_action(@active_action[0]) if @battler.active
  2282. # 残像があれば開放
  2283. mirage_off if @mirage_flug
  2284. # 待機アクションを繰り返す
  2285. start_action(@repeat_action) unless @non_repeat
  2286. end
  2287. #--------------------------------------------------------------------------
  2288. # ● No Collapse
  2289. #--------------------------------------------------------------------------
  2290. def collapse_action
  2291. @non_repeat = true
  2292. @effect_type = COLLAPSE
  2293. @collapse_type = @battler.collapse_type unless @battler.actor?
  2294. @battler_visible = false unless @battler.actor?
  2295. @effect_duration = N01::COLLAPSE_WAIT + 48 if @collapse_type == 2
  2296. @effect_duration = 401 if @collapse_type == 3
  2297. @effect_duration = 401 if @collapse_type == 4
  2298. end
  2299. #--------------------------------------------------------------------------
  2300. # ● Normal Collapse
  2301. #--------------------------------------------------------------------------
  2302. def normal_collapse
  2303. if @effect_duration == 47
  2304. Sound.play_enemy_collapse
  2305. self.blend_type = 1
  2306. self.color.set(255, 128, 128, 128)
  2307. end
  2308. self.opacity = 256 - (48 - @effect_duration) * 6 if @effect_duration <= 47
  2309. end
  2310. #--------------------------------------------------------------------------
  2311. # ● Boss Collapse
  2312. #--------------------------------------------------------------------------
  2313. def boss_collapse1
  2314. if @effect_duration == 320
  2315. Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2316. self.flash(Color.new(255, 255, 255), 60)
  2317. viewport.flash(Color.new(255, 255, 255), 20)
  2318. end
  2319. if @effect_duration == 280
  2320. Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2321. self.flash(Color.new(255, 255, 255), 60)
  2322. viewport.flash(Color.new(255, 255, 255), 20)
  2323. end # 3.4a removed battler reset out
  2324. if @effect_duration == 220
  2325. Audio.se_play("Audio/SE/Earth4", 100, 80)
  2326. self.blend_type = 1
  2327. self.color.set(255, 128, 128, 128)
  2328. self.wave_amp = 6
  2329. end
  2330. if @effect_duration < 220
  2331. self.src_rect.set(0, @effect_duration / 2 - 110, @width, @height)
  2332. self.x += 8 if @effect_duration % 4 == 0
  2333. self.x -= 8 if @effect_duration % 4 == 2
  2334. self.wave_amp += 1 if @effect_duration % 10 == 0
  2335. self.opacity = @effect_duration
  2336. return if @effect_duration < 50
  2337. Audio.se_play("Audio/SE/Earth4", 100, 50) if @effect_duration % 50 == 0
  2338. end
  2339. if @effect_duration == 0 # 3.4a
  2340. reset
  2341. end
  2342. end
  2343. end
  2344. #--------------------------------------------------------------------------
  2345. # ● Final Boss Collapse
  2346. #--------------------------------------------------------------------------
  2347. #def boss_collapse2
  2348. #if @effect_duration == 320
  2349. # Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2350. # self.flash(Color.new(255, 255, 255), 60)
  2351. # viewport.flash(Color.new(255, 255, 255), 20)
  2352. # end
  2353. # if @effect_duration == 280
  2354. # Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2355. # self.flash(Color.new(255, 255, 255), 60)
  2356. # viewport.flash(Color.new(255, 255, 255), 20)
  2357. # end # 3.4a removed battler reset out
  2358. # if @effect_duration == 220
  2359. # Audio.se_play("Audio/SE/Earth4", 100, 80)
  2360. # self.blend_type = 1
  2361. #self.color.set(255, 24, 24, 196)
  2362. #self.wave_amp = 9
  2363. #end
  2364. #if @effect_duration < 220
  2365. # self.src_rect.set(0, @effect_duration / 2 - 110, @width, @height)
  2366. # self.x += 8 if @effect_duration % 4 == 0
  2367. # self.x -= 8 if @effect_duration % 4 == 2
  2368. # self.wave_amp += 1 if @effect_duration % 10 == 0
  2369. # self.opacity = @effect_duration
  2370. # return if @effect_duration < 90
  2371. # Audio.se_play("Audio/SE/Fire6", 100, 50) if @effect_duration % 90 == 0
  2372. # end
  2373. # if @effect_duration == 0 # 3.4a
  2374. # reset
  2375. #end
  2376. # end
  2377. #end
  2378.  
  2379. module Cache ## blackmorning unofficial Code 3.3c
  2380. #--------------------------------------------------------------------------
  2381. # * Get Character Graphic
  2382. # filename : Filename
  2383. #--------------------------------------------------------------------------
  2384. def self.character(filename, hue = 0)
  2385. load_bitmap("Graphics/Characters/", filename, hue)
  2386. end
  2387. end ## end unofficial Code 3.3c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement