Advertisement
Guest User

Sideview Tankentai 1

a guest
Sep 23rd, 2017
561
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 [email protected]? && @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 [email protected]? && @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 && [email protected]?
  122. self.mirror = true
  123. self.mirror = false if @battler.action_mirror
  124. else
  125. self.mirror = false
  126. self.mirror = true if [email protected]? && @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 && [email protected]?
  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 [email protected]? && @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. self.bitmap = Cache.battler(@battler_name, @battler_hue)
  731. @width = bitmap.width
  732. @height = bitmap.height
  733. self.ox = @width / 2
  734. self.oy = @height * 2 / 3
  735. make_shadow
  736. end
  737. end
  738. self.opacity = 0 if @effect_duration == 0 && @battler.collapse_type != 1
  739. end
  740. end
  741. end
  742. #--------------------------------------------------------------------------
  743. # ● Action Processing
  744. #--------------------------------------------------------------------------
  745. def action
  746. return if @active_action == nil
  747. action = @active_action[0]
  748. # Invert battler sprite
  749. return mirroring if action == "Invert"
  750. # Rotate battler sprite
  751. return angling if action == "angle"
  752. # Zoom battler sprite
  753. return zooming if action == "zoom"
  754. # Afterimage effects ON
  755. return mirage_on if action == "Afterimage ON"
  756. # Afterimage effects OFF
  757. return mirage_off if action == "Afterimage OFF"
  758. # Display picture
  759. return picture if action == "pic"
  760. # Delete displayed picture
  761. return @picture.visible = false && @picture_time = 0 if action == "Clear image"
  762. # Change battler graphic
  763. return graphics_change if action == "change"
  764. # Display battle animations
  765. return battle_anime if action == "anime"
  766. # Animated balloon display
  767. return balloon_anime if action == "balloon"
  768. # Play BGM/BGS/SE
  769. return sound if action == "sound"
  770. # Game Switch operation
  771. return $game_switches[@active_action[1]] = @active_action[2] if action == "switch"
  772. # Game Variable operation
  773. return variable if action == "variable"
  774. # if battler has two weapons, execute next defined ANIME key
  775. return two_swords if action == "Two Wpn Only"
  776. # if battler has one weapon, execute next defined ANIME key
  777. return non_two_swords if action == "One Wpn Only"
  778. # Determine necessary conditions and continues sequence or not.
  779. return necessary if action == "nece"
  780. # Execute skill from within another skill.
  781. return derivating if action == "der"
  782. # Start individual processing of actions on target objects
  783. return individual_action if action == "Process Skill"
  784. # End individual processing of actions
  785. return individual_action_end if action == "Process Skill End"
  786. # 待機に移行しない場合
  787. return non_repeat if action == "Don't Wait"
  788. # Change Start Position of battlers
  789. return @battler.change_base_position(self.x, self.y) if action == "Start Pos Change"
  790. # Revert to original start position coordinates
  791. return @battler.base_position if action == "Start Pos Return"
  792. # Change target objects
  793. return change_target if action == "target"
  794. # Allow collapse of targets.
  795. return send_action(action) if action == "Can Collapse"
  796. # Cancel active action
  797. return send_action(action) if action == "Cancel Action"
  798. # Add state to target objects
  799. return state_on if action == "sta+"
  800. # Remove state from target objects
  801. return state_off if action == "sta-"
  802. # Change game frame rate
  803. return Graphics.frame_rate = @active_action[1] if action == "fps"
  804. # Float battler sprite from shadow
  805. return floating if action == "float"
  806. # Run string through eval() method
  807. return eval(@active_action[1]) if action == "script"
  808. # Force battler actions of non-active battlers
  809. return force_action if @active_action.size == 4
  810. # Reset battlers to start coordinates
  811. return reseting if @active_action.size == 5
  812. # Move battler sprites
  813. return moving if @active_action.size == 7
  814. # Determines battler frame animation
  815. return battler_anime if @active_action.size == 9
  816. # Move database animation on screen
  817. return moving_anime if @active_action.size == 11
  818. # "End"
  819. return anime_finish if action == "End"
  820. end
  821. #--------------------------------------------------------------------------
  822. # ● 反転実行
  823. #--------------------------------------------------------------------------
  824. def mirroring
  825. # すでに反転されていれば元に戻す
  826. if self.mirror
  827. self.mirror = false
  828. # 武器アニメも反映
  829. @weapon_R.mirroring if @anime_flug
  830. else
  831. self.mirror = true
  832. # 武器アニメも反映
  833. @weapon_R.mirroring if @anime_flug
  834. end
  835. end
  836. #--------------------------------------------------------------------------
  837. # ● 回転実行
  838. #--------------------------------------------------------------------------
  839. def angling
  840. # ジャンプを初期化
  841. jump_reset
  842. # 情報確認
  843. @angle_time = @active_action[1]
  844. start_angle = @active_action[2]
  845. end_angle = @active_action[3]
  846. @angle_reset = @active_action[4]
  847. # バックアタック時には逆に
  848. start_angle *= -1 if $back_attack
  849. end_angle *= -1 if $back_attack
  850. # エネミーは逆に
  851. start_angle *= -1 if @battler.is_a?(Game_Enemy)
  852. end_angle *= -1 if @battler.is_a?(Game_Enemy)
  853. # 時間が0以下なら即座に最終角度へ
  854. if @angle_time <= 0
  855. self.angle = end_angle
  856. return @angle_time = 0
  857. end
  858. # 回転時間から1フレームあたりの角度を出す
  859. @angling = (end_angle - start_angle) / @angle_time
  860. # 割り切れない余りを初期角度に
  861. @angle = (end_angle - start_angle) % @angle_time + start_angle
  862. end
  863. #--------------------------------------------------------------------------
  864. # ● 拡大縮小実行
  865. #--------------------------------------------------------------------------
  866. def zooming
  867. # ジャンプを初期化
  868. jump_reset
  869. # 情報確認
  870. @zoom_time = @active_action[1]
  871. zoom_x = @active_action[2] - 1
  872. zoom_y = @active_action[3] - 1
  873. @zoom_reset = @active_action[4]
  874. @zoom_x = @zoom_y = 1
  875. # 時間が0以下ならスキップ
  876. return @zoom_time = 0 if @zoom_time <= 0
  877. # 拡大時間から1フレームあたりの拡大率を出す
  878. @zooming_x = zoom_x / @zoom_time
  879. @zooming_y = zoom_y / @zoom_time
  880. end
  881. #--------------------------------------------------------------------------
  882. # ● 残像開始
  883. #--------------------------------------------------------------------------
  884. def mirage_on
  885. # 戦闘不能時には残像させない
  886. return if @battler.dead?
  887. @mirage0 = Sprite.new(self.viewport)
  888. @mirage1 = Sprite.new(self.viewport)
  889. @mirage2 = Sprite.new(self.viewport)
  890. @mirage_flug = true
  891. @mirage_count = 0
  892. end
  893. #--------------------------------------------------------------------------
  894. # ● 残像表示
  895. #--------------------------------------------------------------------------
  896. def mirage(body)
  897. body.bitmap = self.bitmap.dup
  898. body.x = self.x
  899. body.y = self.y
  900. body.ox = self.ox
  901. body.oy = self.oy
  902. body.z = self.z
  903. body.mirror = self.mirror
  904. body.angle = @angle
  905. body.opacity = 160
  906. body.zoom_x = self.zoom_x
  907. body.zoom_y = self.zoom_y
  908. body.src_rect.set(@sx, @sy, @width, @height) if @anime_flug
  909. body.src_rect.set(0, 0, @width, @height) unless @anime_flug
  910. end
  911. #--------------------------------------------------------------------------
  912. # ● 残像終了
  913. #--------------------------------------------------------------------------
  914. def mirage_off
  915. @mirage_flug = false
  916. @mirage0.dispose if @mirage0 != nil
  917. @mirage1.dispose if @mirage1 != nil
  918. @mirage2.dispose if @mirage2 != nil
  919. end
  920. #--------------------------------------------------------------------------
  921. # ● ピクチャ表示
  922. #--------------------------------------------------------------------------
  923. def picture
  924. # 移動開始位置を確認
  925. pic_x = @active_action[1]
  926. pic_y = @active_action[2]
  927. # 移動終了位置を確認
  928. pic_end_x = @active_action[3]
  929. pic_end_y = @active_action[4]
  930. @picture_time = @active_action[5]
  931. # 時間で割り、1フレーム当たりの移動速度を計算
  932. @moving_pic_x = (pic_end_x - pic_x)/ @picture_time
  933. @moving_pic_y = (pic_end_y - pic_y)/ @picture_time
  934. # 割り切れない場合最初に加算
  935. plus_x = (pic_end_x - pic_x)% @picture_time
  936. plus_y = (pic_end_y - pic_y)% @picture_time
  937. # ピクチャ表示
  938. @picture.bitmap = Cache.picture(@active_action[7])
  939. @picture.x = pic_x + plus_x
  940. @picture.y = pic_y + plus_y
  941. # Z座標調整
  942. @picture.z = 1
  943. @picture.z = 1000 if @active_action[6]
  944. @picture.visible = true
  945. end
  946. #--------------------------------------------------------------------------
  947. # ● グラフィックファイル変更
  948. #--------------------------------------------------------------------------
  949. def graphics_change
  950. # Limit method to actors only
  951. return if @battler.is_a?(Game_Enemy)
  952. # グラフィック変更
  953. @battler_name = @active_action[2]
  954. # 歩行グラフィックを利用するかどうかで転送元の矩形サイズの認識先を変える
  955. self.bitmap = Cache.character(@battler_name) if N01::WALK_ANIME
  956. self.bitmap = Cache.character(@battler_name + "_1") unless N01::WALK_ANIME
  957. # 転送元の矩形を取得
  958. @width = self.bitmap.width / @base_width
  959. @height = self.bitmap.height / @base_height
  960. # 戦闘後リセットする場合キャラチップ名を記憶
  961. @before_graphic = @battler.character_name if @active_action[1]
  962. @battler.graphic_change(@active_action[2])
  963. end
  964. #--------------------------------------------------------------------------
  965. # ● Show Battle Animation [判別,ID, target, mirror, wait, Weapon 2 flag]
  966. #--------------------------------------------------------------------------
  967. def battle_anime
  968. # return if enemy and processing animation for Weapon 2
  969. return if @active_action[5] && [email protected]?
  970. # return if trying to process Weapon 2 animation with no Weapon 2 equipped.
  971. return if @active_action[5] && @battler.weapons[1] == nil
  972. # return if actor has Weapon 2 equipped, but not Weapon 1
  973. if @battler.actor?
  974. return if !@active_action[5] && @battler.weapons[0] == nil && @battler.weapons[1] != nil
  975. end
  976. anime_id = @active_action[1]
  977. # 3.4a properly mirror animations if enemy is manually set to be mirroed
  978. if @battler.is_a?(Game_Enemy)
  979. mirror = false
  980. mirror = true if @battler.action_mirror
  981. end
  982. # Mirror animation when in back attack
  983. if $back_attack
  984. mirror = true if !@active_action[3] # 3.4a
  985. mirror = false if @active_action[3] || (@battler.is_a?(Game_Enemy) && @battler.action_mirror) # 3.4a
  986. end
  987. # 3.4c
  988. # Damage with no animation
  989. if anime_id == -3
  990. # No animation if anime ID is -3
  991. anime_id = 0
  992. # ダメージ表示のアニメなら、ダメージ計算を先に済ませるため処理を中断
  993. damage_action = [anime_id, mirror, true]
  994. return @battler.play = ["OBJ_ANIM",damage_action] if @battler.active
  995. end
  996. # For skill, item, and weapon animations
  997. if anime_id < 0
  998. # Branches from here depending on type of action
  999. if @battler.action.skill? && anime_id != -2
  1000. ### UNOFFICAL CODE v3.3b ###
  1001. anime_id = @battler.action.skill.animation_id unless @battler.action.skill.animation_id == -1
  1002. if @battler.action.skill.animation_id == -1
  1003. anime_id = N01::NO_WEAPON
  1004. if @battler.actor?
  1005. weapon_id = @battler.weapon_id
  1006. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1007. anime_id = @battler.atk_animation_id2 if @active_action[5]
  1008. else
  1009. weapon_id = @battler.weapon
  1010. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1011. end
  1012. end
  1013. elsif @battler.action.item? && anime_id != -2
  1014. anime_id = 0
  1015. anime_id = @battler.action.item.animation_id unless @battler.action.item.animation_id == -1
  1016. if @battler.action.item.animation_id == -1
  1017. anime_id = N01::NO_WEAPON
  1018. weapon_id = @battler.weapon_id
  1019. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1020. anime_id = @battler.atk_animation_id2 if @active_action[5]
  1021. end
  1022. ### UNOFFICIAL CODE v3.3b END ###
  1023. else
  1024. # Unarmed attack animation
  1025. anime_id = N01::NO_WEAPON
  1026. if @battler.actor?
  1027. weapon_id = @battler.weapon_id
  1028. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1029. # For Two Swords Style animation
  1030. anime_id = @battler.atk_animation_id2 if @active_action[5]
  1031. else
  1032. weapon_id = @battler.weapon
  1033. anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
  1034. end
  1035. end
  1036. # Set wait value, temporarily delays action sequence processing
  1037. @wait = $data_animations[anime_id].frame_max * 4 if $data_animations[anime_id] != nil && @active_action[4]
  1038. waitflug = true
  1039. # ダメージ表示のアニメなら、ダメージ計算を先に済ませるため処理を中断
  1040. damage_action = [anime_id, mirror, true]
  1041. return @battler.play = ["OBJ_ANIM",damage_action] if @battler.active && @active_action[1] != -4 # 3.4a
  1042. end
  1043. # アニメ実行
  1044. if @active_action[2] == 0 && $data_animations[anime_id] != nil
  1045. @battler.animation_id = anime_id
  1046. @battler.animation_mirror = mirror
  1047. elsif $data_animations[anime_id] != nil
  1048. for target in @target_battler
  1049. target.animation_id = anime_id
  1050. target.animation_mirror = mirror
  1051. end
  1052. end
  1053. # ウエイト設定
  1054. @wait = $data_animations[anime_id].frame_max * 4 if $data_animations[anime_id] != nil && @active_action[4] && !waitflug
  1055. end
  1056. #--------------------------------------------------------------------------
  1057. # ● ふきだしアニメ表示
  1058. #--------------------------------------------------------------------------
  1059. def balloon_anime
  1060. return if self.opacity == 0
  1061. if @balloon == nil
  1062. @balloon = Sprite.new
  1063. @balloon.bitmap = Cache.system(N01::BALLOON_GRAPHICS) # v3.3a
  1064. @balloon.ox = @width / 16
  1065. @balloon.oy = @balloon.height / 10 + @height / 3
  1066. end
  1067. @balloon_id = @active_action[1]
  1068. @balloon_loop = @active_action[2]
  1069. @balloon_duration = 64
  1070. @balloon_back = false
  1071. update_balloon
  1072. @balloon.visible = true
  1073. end
  1074. #--------------------------------------------------------------------------
  1075. # ● BGM/BGS/SE演奏
  1076. #--------------------------------------------------------------------------
  1077. def sound
  1078. # 情報を取得
  1079. pitch = @active_action[2]
  1080. vol = @active_action[3]
  1081. name = @active_action[4]
  1082. # 実行
  1083. case @active_action[1]
  1084. when "se"
  1085. Audio.se_play("Audio/SE/" + name, vol, pitch)
  1086. when "bgm"
  1087. # 名前指定のない場合、現在のBGMを変えないように
  1088. if @active_action[4] == ""
  1089. now_bgm = RPG::BGM.last
  1090. name = now_bgm.name
  1091. end
  1092. Audio.bgm_play("Audio/BGM/" + name, vol, pitch)
  1093. when "bgs"
  1094. # 名前指定のない場合、現在のBGSを変えないように
  1095. if @active_action[4] == ""
  1096. now_bgs = RPG::BGS.last
  1097. name = now_bgs.name
  1098. end
  1099. Audio.bgs_play("Audio/BGS/" + name, vol, pitch)
  1100. end
  1101. end
  1102. #--------------------------------------------------------------------------
  1103. # ● ゲーム変数操作
  1104. #--------------------------------------------------------------------------
  1105. def variable
  1106. # オペランドチェック
  1107. operand = @active_action[3]
  1108. # 変数操作で分岐
  1109. case @active_action[2]
  1110. when 0 # 代入
  1111. $game_variables[@active_action[1]] = operand
  1112. when 1 # 加算
  1113. $game_variables[@active_action[1]] += operand
  1114. when 2 # 減算
  1115. $game_variables[@active_action[1]] -= operand
  1116. when 3 # 乗算
  1117. $game_variables[@active_action[1]] *= operand
  1118. when 4 # 除算
  1119. $game_variables[@active_action[1]] /= operand
  1120. when 5 # 剰余
  1121. $game_variables[@active_action[1]] %= operand
  1122. end
  1123. end
  1124. #--------------------------------------------------------------------------
  1125. # ● 二刀限定
  1126. #--------------------------------------------------------------------------
  1127. def two_swords
  1128. # エネミーは処理させない
  1129. return @action.shift unless @battler.actor?
  1130. # 左(下部表示)に武器がなかったら次のアクションを除く
  1131. return @action.shift if @battler.weapons[1] == nil
  1132. # 行動配列の先頭からシフト
  1133. active = @action.shift
  1134. # 現在のアクションを決定
  1135. @active_action = N01::ANIME[active]
  1136. # ウエイト設定
  1137. @wait = active.to_i if @active_action == nil
  1138. # 単発アクション開始
  1139. action
  1140. end
  1141. #--------------------------------------------------------------------------
  1142. # ● 非二刀限定
  1143. #--------------------------------------------------------------------------
  1144. def non_two_swords
  1145. # エネミーは処理させない
  1146. return unless @battler.actor?
  1147. # 左(下部表示)に武器があったら次のアクションを除く
  1148. return @action.shift if @battler.weapons[1] != nil
  1149. # 行動配列の先頭からシフト
  1150. active = @action.shift
  1151. # 現在のアクションを決定
  1152. @active_action = N01::ANIME[active]
  1153. # ウエイト設定
  1154. @wait = active.to_i if @active_action == nil
  1155. # 単発アクション開始
  1156. action
  1157. end
  1158. #--------------------------------------------------------------------------
  1159. # ● アクション条件
  1160. #--------------------------------------------------------------------------
  1161. def necessary
  1162. nece1 = @active_action[3]
  1163. nece2 = @active_action[4]
  1164. # ターゲットチェック
  1165. case @active_action[1]
  1166. # 0自身 1ターゲット 2敵全体 3味方全体
  1167. when 0
  1168. target = [$game_party.members[@battler.index]] if @battler.is_a?(Game_Actor)
  1169. target = [$game_troop.members[@battler.index]] if @battler.is_a?(Game_Enemy)
  1170. when 1
  1171. target = @target_battler
  1172. when 2
  1173. target = $game_troop.members
  1174. when 3
  1175. target = $game_party.members
  1176. end
  1177. # ターゲットが空の場合は失敗とみなす
  1178. return start_action(@battler.recover_action) if target.size == 0
  1179. # 内容チェック
  1180. case @active_action[2]
  1181. # ステートID指定だった場合
  1182. when 0
  1183. # 補足が正で「ステートにかかっている」、負は「かかっていない」が条件に
  1184. state_on = true if nece2 > 0
  1185. # 条件人数を出す
  1186. state_member = nece2.abs
  1187. # 0は仲間数を出す
  1188. if nece2 == 0
  1189. state_member = $game_party.members.size if @battler.is_a?(Game_Actor)
  1190. state_member = $game_troop.members.size if @battler.is_a?(Game_Enemy)
  1191. end
  1192. # ターゲットのステートチェックし人数をカウント
  1193. for member in target
  1194. state_member -= 1 if member.state?(nece1)
  1195. end
  1196. # 条件が満たされていればアクション続行
  1197. if state_member == 0 && state_on
  1198. return
  1199. elsif state_member == nece2.abs
  1200. return if state_on == nil
  1201. end
  1202. # パラメータ指定だった場合
  1203. when 1
  1204. # 補足が正で「数値以上」、負は「数値以下」が条件に
  1205. num_over = true if nece2 > 0
  1206. # 参照数値
  1207. num = 0
  1208. # ターゲットのパラメータチェック
  1209. for member in target
  1210. # 参照パラメータで分岐
  1211. case nece1
  1212. when 0 # 現HP
  1213. num += member.hp
  1214. when 1 # 現MP
  1215. num += member.mp
  1216. when 2 # 攻撃力
  1217. num += member.atk
  1218. when 3 # 防御力
  1219. num += member.def
  1220. when 4 # 精神力
  1221. num += member.spi
  1222. when 5 # 敏捷性
  1223. num += member.agi
  1224. end
  1225. end
  1226. # 平均を出す
  1227. num = num / target.size
  1228. # 条件が満たされていればアクション続行
  1229. if num > nece2.abs && num_over
  1230. return
  1231. elsif num < nece2.abs
  1232. return if num_over == nil
  1233. end
  1234. # スイッチ指定だった場合
  1235. when 2
  1236. # 条件が満たされていればアクション続行
  1237. if $game_switches[nece1]
  1238. # 補足がtrueで「スイッチON」、falseは「スイッチOFF」が条件に
  1239. return if nece2
  1240. # スイッチがOFFの場合はON時とは逆に
  1241. else
  1242. return unless nece2
  1243. end
  1244. # 変数指定だった場合
  1245. when 3
  1246. # 補足が正で「数値以上」、負は「数値以下」が条件に
  1247. if nece2 > 0
  1248. return if $game_variables[nece1] > nece2
  1249. else
  1250. return unless $game_variables[nece1] > nece2.abs
  1251. end
  1252. # 習得スキル指定だった場合
  1253. when 4
  1254. # スキル条件人数を出す
  1255. skill_member = nece2.abs
  1256. for member in target
  1257. skill_member -= 1 if member.skill_learn?(nece1)
  1258. # 条件確認
  1259. return if skill_member == 0
  1260. end
  1261. end
  1262. # 条件を満たせなければ以降のアクションを中断
  1263. return @action = ["End"] if @non_repeat
  1264. # 防御中は不自然に見えないように座標復帰させない
  1265. action = @battler.recover_action
  1266. action = @battler.defence if @battler.guarding?
  1267. return start_action(action)
  1268. end
  1269. #--------------------------------------------------------------------------
  1270. # ● Derivating skills (link skills)
  1271. #--------------------------------------------------------------------------
  1272. def derivating # Redefined 1.1e
  1273. return if $game_party.all_dead? or $game_troop.all_dead?
  1274. skill = $data_skills[@active_action[3]] # retrive actual skill
  1275. # test for skill learning. If not learned and link is not set, stop here
  1276. return if @battler.actor? && [email protected]_learn?(skill) && !@active_action[2]
  1277. # this takes the actual skill object
  1278. return unless @battler.skill_can_use?(skill) # test if skill can be used
  1279. # skill fails if the random number is below the given chance
  1280. return if rand(100) > @active_action[1]
  1281. # sets the derivation
  1282. @battler.derivation = @active_action[3]
  1283. # sets the current action to ["End"]
  1284. @action = ["End"]
  1285. end
  1286. #--------------------------------------------------------------------------
  1287. # ● 個別処理開始
  1288. #--------------------------------------------------------------------------
  1289. def individual_action
  1290. # リピートフラグオン
  1291. @battler.individual = true
  1292. # リピートアクションを保持
  1293. @individual_act = @action.dup
  1294. # ターゲットを保持し、行動ターゲットをひとつずつ抜き出す
  1295. send_action(["Individual"])
  1296. @individual_targets = @target_battler.dup
  1297. @target_battler = [@individual_targets.shift]
  1298. end
  1299. #--------------------------------------------------------------------------
  1300. # ● 個別処理終了
  1301. #--------------------------------------------------------------------------
  1302. def individual_action_end
  1303. # ターゲットが残っていないなら行動終了
  1304. return @battler.individual = false if @individual_targets.size == 0
  1305. @action = @individual_act.dup
  1306. @target_battler = [@individual_targets.shift]
  1307. end
  1308. #--------------------------------------------------------------------------
  1309. # ● 待機に移行しない
  1310. #--------------------------------------------------------------------------
  1311. def non_repeat
  1312. @repeat_action = []
  1313. @non_repeat = true
  1314. anime_finish
  1315. end
  1316. #--------------------------------------------------------------------------
  1317. # ● ターゲット変更 action = [判別, 変更する対象, 変更先]
  1318. #--------------------------------------------------------------------------
  1319. def change_target
  1320. # 自身の変更したターゲットを元に戻す
  1321. return @target_battler = @now_targets.dup if @active_action[2] == 3
  1322. # 送るターゲット情報
  1323. target = [@battler] if @active_action[2] == 0
  1324. target = @target_battler.dup if @active_action[2] != 0
  1325. # 自身のターゲットを送った相手にする場合、現在のターゲットを記憶
  1326. if @active_action[2] == 2
  1327. @now_targets = @target_battler.dup
  1328. @target_battler = []
  1329. end
  1330. # 送るターゲットがインデックス指定の場合
  1331. if @active_action[1] >= 1000
  1332. members = $game_party.members if @battler.actor?
  1333. members = $game_troop.members unless @battler.actor?
  1334. index = @active_action[1] - 1000
  1335. if index < members.size
  1336. if members[index].exist? && @battler.index != index
  1337. # ターゲット変更
  1338. members[index].force_target = ["N01target_change", target]
  1339. # 自身のターゲットを送った相手にする場合
  1340. @target_battler = [members[index]] if @active_action[2] == 2
  1341. change = true
  1342. else
  1343. for member in members
  1344. next if @battler.index == member.index
  1345. next unless member.exist?
  1346. member.force_target = ["N01target_change", target]
  1347. @target_battler = [member] if @active_action[2] == 2
  1348. break change = true
  1349. end
  1350. end
  1351. end
  1352. # 送るターゲットがステートID指定だった場合
  1353. elsif @active_action[1] > 0
  1354. for member in $game_party.members + $game_troop.members
  1355. if member.state?(@active_action[1])
  1356. member.force_target = ["N01target_change", target]
  1357. @target_battler.push(member) if @active_action[2] == 2
  1358. change = true
  1359. end
  1360. end
  1361. # 送るターゲットが習得スキル指定だった場合
  1362. elsif @active_action[1] < 0
  1363. skill_id = @active_action[1].abs
  1364. for actor in $game_party.members
  1365. if actor.skill_id_learn?(skill_id)
  1366. actor.force_target = ["N01target_change", target]
  1367. @target_battler.push(target) if @active_action[2] == 2
  1368. change = true
  1369. end
  1370. end
  1371. # 送るターゲットがターゲットだった場合
  1372. else
  1373. for member in @target_battler
  1374. member.force_target = ["N01target_change", target]
  1375. @target_battler.push(member) if @active_action[2] == 2
  1376. change = true
  1377. end
  1378. end
  1379. # 条件を満たせなければ以降のアクションを中断
  1380. return if change
  1381. return @action = ["End"] if @non_repeat
  1382. return start_action(@battler.recover_action)
  1383. end
  1384. #--------------------------------------------------------------------------
  1385. # ● ステート付与
  1386. #--------------------------------------------------------------------------
  1387. def state_on
  1388. state_id = @active_action[2]
  1389. # 対象で分岐
  1390. case @active_action[1]
  1391. when 0
  1392. @battler.add_state(state_id) if rand(100) < @battler.state_probability(state_id)
  1393. when 1
  1394. if @target_battler != nil
  1395. for target in @target_battler
  1396. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1397. end
  1398. end
  1399. when 2
  1400. for target in $game_troop.members
  1401. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1402. end
  1403. when 3
  1404. for target in $game_party.members
  1405. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1406. end
  1407. when 4
  1408. for target in $game_party.members
  1409. if target.index != @battler.index
  1410. target.add_state(state_id) if rand(100) < target.state_probability(state_id)
  1411. end
  1412. end
  1413. end
  1414. end
  1415. #--------------------------------------------------------------------------
  1416. # ● ステート解除
  1417. #--------------------------------------------------------------------------
  1418. def state_off
  1419. state_id = @active_action[2]
  1420. # 対象で分岐
  1421. case @active_action[1]
  1422. when 0
  1423. @battler.remove_state(state_id)
  1424. when 1
  1425. if @target_battler != nil
  1426. for target in @target_battler
  1427. target.remove_state(state_id)
  1428. end
  1429. end
  1430. when 2
  1431. for target in $game_troop.members
  1432. target.remove_state(state_id)
  1433. end
  1434. when 3
  1435. for target in $game_party.members
  1436. target.remove_state(state_id)
  1437. end
  1438. when 4
  1439. for target in $game_party.members
  1440. if target.index != @battler.index
  1441. target.remove_state(state_id)
  1442. end
  1443. end
  1444. end
  1445. end
  1446. #--------------------------------------------------------------------------
  1447. # ● 浮遊実行
  1448. #--------------------------------------------------------------------------
  1449. def floating
  1450. # ジャンプを初期化
  1451. jump_reset
  1452. # 情報確認
  1453. @jump_plus = @active_action[1]
  1454. float_end = @active_action[2]
  1455. @float_time = @active_action[3]
  1456. # 1フレーム当たりの移動高度を計算
  1457. @float_up = (float_end - @jump_plus)/ @float_time
  1458. # 浮遊が完了するまで次のアクションに行かない
  1459. @wait = @float_time
  1460. # 浮遊アニメ設定を反映
  1461. if @anime_flug
  1462. move_anime = N01::ANIME[@active_action[4]]
  1463. # グラフィック指定がない場合はスキップ
  1464. if move_anime != nil
  1465. # 現在のアクションを上書き
  1466. @active_action = move_anime
  1467. # バトラーアニメ開始
  1468. battler_anime
  1469. # 浮遊が完了したら即アニメが終わるように
  1470. @anime_end = true
  1471. end
  1472. end
  1473. # 初期高度に浮遊
  1474. @battler.jump = @jump_plus
  1475. end
  1476. #--------------------------------------------------------------------------
  1477. # ● 強制アクション
  1478. #--------------------------------------------------------------------------
  1479. def force_action
  1480. # アクションが単発か通しか判別
  1481. kind = @active_action[0]
  1482. # 復帰の有無をチェック
  1483. rebirth = @active_action[2]
  1484. # 強制アクション内容を取得
  1485. play = @active_action[3]
  1486. # 上3つの情報をまとめて格納
  1487. action = [kind,rebirth,play]
  1488. # ターゲットがインデックス指定の場合
  1489. if @active_action[1] >= 1000
  1490. members = $game_party.members if @battler.actor?
  1491. members = $game_troop.members unless @battler.actor?
  1492. index = @active_action[1] - 1000
  1493. if index < members.size
  1494. if members[index].exist? && @battler.index != index
  1495. # バトラー情報に渡す
  1496. return members[index].force_action = action
  1497. else
  1498. for target in members
  1499. next if @battler.index == target.index
  1500. next unless target.exist?
  1501. force = true
  1502. break target.force_action = action
  1503. end
  1504. end
  1505. end
  1506. # 条件を満たせなければ以降のアクションを中断
  1507. return if force
  1508. return @action = ["End"] if @non_repeat
  1509. return start_action(@battler.recover_action)
  1510. # ターゲット指定の場合
  1511. elsif @active_action[1] == 0
  1512. for target in @target_battler
  1513. target.force_action = action if target != nil
  1514. end
  1515. # ステートID指定だった場合
  1516. elsif @active_action[1] > 0
  1517. for target in $game_party.members + $game_troop.members
  1518. target.force_action = action if target.state?(@active_action[1])
  1519. end
  1520. # 習得スキル指定だった場合
  1521. elsif @active_action[1] < 0
  1522. # エネミーは処理させない
  1523. return if @battler.is_a?(Game_Enemy)
  1524. for actor in $game_party.members
  1525. # 自分は除く
  1526. unless actor.id == @battler.id
  1527. # バトラー情報に渡す
  1528. actor.force_action = action if actor.skill_id_learn?(@active_action[1].abs)
  1529. end
  1530. end
  1531. end
  1532. end
  1533. #--------------------------------------------------------------------------
  1534. # ● 座標リセット実行
  1535. #--------------------------------------------------------------------------
  1536. def reseting
  1537. # ジャンプを初期化
  1538. jump_reset
  1539. # 回転を元に戻す
  1540. self.angle = 0
  1541. # 情報確認
  1542. @distanse_x = @move_x * -1
  1543. @distanse_y = @move_y * -1
  1544. @move_speed_x = @active_action[1]
  1545. @move_speed_y = @move_speed_x
  1546. @move_boost_x = @active_action[2]
  1547. @move_boost_y = @move_boost_x
  1548. @jump = @active_action[3]
  1549. # 移動計算
  1550. move_distance
  1551. # 移動アニメ設定を反映
  1552. if @anime_flug
  1553. move_anime = N01::ANIME[@active_action[4]]
  1554. # グラフィック指定がない場合はスキップ
  1555. if move_anime != nil
  1556. # 現在のアクションを上書き
  1557. @active_action = move_anime
  1558. # バトラーアニメ開始
  1559. battler_anime
  1560. end
  1561. # 移動が完了したら即アニメが終わるように
  1562. @anime_end = true
  1563. end
  1564. end
  1565. #--------------------------------------------------------------------------
  1566. # ● 移動実行
  1567. #--------------------------------------------------------------------------
  1568. def moving
  1569. # Initialize jump values
  1570. jump_reset
  1571. # X-coordinate destination
  1572. xx = @active_action[1]
  1573. # Invert xx when in back attack
  1574. xx *= -1 if $back_attack
  1575. # Verify target of moving battler
  1576. case @active_action[0]
  1577. when 0 # Self
  1578. @distanse_x = xx
  1579. @distanse_y = @active_action[2]
  1580. when 1 # Target
  1581. # ターゲットが決まってない場合、自身に変換
  1582. if @target_battler == nil
  1583. @distanse_x = xx
  1584. @distanse_y = @active_action[2]
  1585. else
  1586. # ターゲット対象をひとつずつチェック
  1587. target_x = 0
  1588. target_y = 0
  1589. time = 0
  1590. for i in 0...@target_battler.size
  1591. if @target_battler[i] != nil
  1592. time += 1
  1593. target_x += @target_battler[i].position_x
  1594. target_y += @target_battler[i].position_y
  1595. end
  1596. end
  1597. # ターゲットが空だった場合、自身に変換
  1598. if time == 0
  1599. @distanse_x = xx
  1600. @distanse_y = @active_action[2]
  1601. else
  1602. # 複数ターゲットの中心を計算
  1603. target_x = target_x / time
  1604. target_y = target_y / time
  1605. # 最終的な移動距離を算出
  1606. @distanse_y = target_y - self.y + @active_action[2]
  1607. # X座標はアクターとエネミーで逆計算
  1608. if @battler.is_a?(Game_Actor)
  1609. @distanse_x = target_x - self.x + xx
  1610. else
  1611. @distanse_x = self.x - target_x + xx
  1612. end
  1613. end
  1614. end
  1615. when 2 # Screen
  1616. # X座標はアクターとエネミーで逆計算
  1617. if @battler.is_a?(Game_Actor)
  1618. @distanse_x = xx - self.x
  1619. @distanse_x = Graphics.width + xx - self.x if $back_attack
  1620. else
  1621. @distanse_x = self.x - xx
  1622. @distanse_x = self.x - (Graphics.width + xx) if $back_attack
  1623. end
  1624. @distanse_y = @active_action[2] - self.y
  1625. when 3 # Start Position
  1626. # X座標はアクターとエネミーで逆計算
  1627. if @battler.is_a?(Game_Actor)
  1628. @distanse_x = xx + @battler.base_position_x - self.x
  1629. else
  1630. @distanse_x = xx + self.x - @battler.base_position_x
  1631. end
  1632. @distanse_y = @active_action[2] + @battler.base_position_y - @battler.position_y
  1633. when 4 # Head 3.4b
  1634. # ターゲットが決まってない場合、自身に変換
  1635. if @target_battler == nil
  1636. @distanse_x = xx
  1637. @distanse_y = @active_action[2]
  1638. else
  1639. # ターゲット対象をひとつずつチェック
  1640. target_x = 0
  1641. target_y = 0
  1642. time = 0
  1643. for i in 0...@target_battler.size
  1644. if @target_battler[i] != nil
  1645. time += 1
  1646. shift_y = @target_battler[i].graphics_height * 2 / 3
  1647. target_x += @target_battler[i].position_x
  1648. target_y += @target_battler[i].position_y - shift_y # 3.4b
  1649. end
  1650. end
  1651. # ターゲットが空だった場合、自身に変換
  1652. if time == 0
  1653. @distanse_x = xx
  1654. @distanse_y = @active_action[2]
  1655. else
  1656. # 複数ターゲットの中心を計算
  1657. target_x = target_x / time
  1658. target_y = target_y / time
  1659. # 最終的な移動距離を算出
  1660. @distanse_y = target_y - self.y + @active_action[2]
  1661. # X座標はアクターとエネミーで逆計算
  1662. if @battler.is_a?(Game_Actor)
  1663. @distanse_x = target_x - self.x + xx
  1664. else
  1665. @distanse_x = self.x - target_x + xx
  1666. end
  1667. end
  1668. end
  1669. when 5 # Feet 3.4b
  1670. # ターゲットが決まってない場合、自身に変換
  1671. if @target_battler == nil
  1672. @distanse_x = xx
  1673. @distanse_y = @active_action[2]
  1674. else
  1675. # ターゲット対象をひとつずつチェック
  1676. target_x = 0
  1677. target_y = 0
  1678. time = 0
  1679. for i in 0...@target_battler.size
  1680. if @target_battler[i] != nil
  1681. time += 1
  1682. shift_y = @target_battler[i].graphics_height / 3
  1683. target_x += @target_battler[i].position_x
  1684. target_y += @target_battler[i].position_y + shift_y # 3.4b
  1685. end
  1686. end
  1687. # ターゲットが空だった場合、自身に変換
  1688. if time == 0
  1689. @distanse_x = xx
  1690. @distanse_y = @active_action[2]
  1691. else
  1692. # 複数ターゲットの中心を計算
  1693. target_x = target_x / time
  1694. target_y = target_y / time
  1695. # 最終的な移動距離を算出
  1696. @distanse_y = target_y - self.y + @active_action[2]
  1697. # X座標はアクターとエネミーで逆計算
  1698. if @battler.is_a?(Game_Actor)
  1699. @distanse_x = target_x - self.x + xx
  1700. else
  1701. @distanse_x = self.x - target_x + xx
  1702. end
  1703. end
  1704. end
  1705. end
  1706. @move_speed_x = @active_action[3]
  1707. @move_speed_y = @active_action[3]
  1708. @move_boost_x = @active_action[4]
  1709. @move_boost_y = @active_action[4]
  1710. @jump = @active_action[5]
  1711. @jump_plus = 0
  1712. # 移動計算
  1713. move_distance
  1714. # 移動アニメ設定を反映
  1715. if @anime_flug
  1716. move_anime = N01::ANIME[@active_action[6]]
  1717. # グラフィック指定がない場合はスキップ
  1718. if move_anime != nil
  1719. # 現在のアクションを上書き
  1720. @active_action = move_anime
  1721. # バトラーアニメ開始
  1722. battler_anime
  1723. end
  1724. # 移動が完了したら即アニメが終わるように
  1725. @anime_end = true
  1726. end
  1727. end
  1728. #--------------------------------------------------------------------------
  1729. # ● 移動計算
  1730. #--------------------------------------------------------------------------
  1731. def move_distance
  1732. # 速度が0の場合、その場に留まる
  1733. if @move_speed_x == 0
  1734. @moving_x = 0
  1735. @moving_y = 0
  1736. else
  1737. # 1フレームあたりの移動距離を計算
  1738. @moving_x = @distanse_x / @move_speed_x
  1739. @moving_y = @distanse_y / @move_speed_y
  1740. # 余った距離はこの時点で移動し消化
  1741. over_x = @distanse_x % @move_speed_x
  1742. over_y = @distanse_y % @move_speed_y
  1743. @move_x += over_x
  1744. @move_y += over_y
  1745. @battler.move_x = @move_x
  1746. @battler.move_y = @move_y
  1747. @distanse_x -= over_x
  1748. @distanse_y -= over_y
  1749. end
  1750. # 移動があるかどうかの判定
  1751. if @distanse_x == 0
  1752. @move_speed_x = 0
  1753. end
  1754. if @distanse_y == 0
  1755. @move_speed_y = 0
  1756. end
  1757. # X座標移動計算
  1758. # 加減速による移動フレーム数の修正
  1759. boost_x = @moving_x
  1760. move_x = 0
  1761. # 加速がある場合
  1762. if @move_boost_x > 0 && @distanse_x != 0
  1763. # 加減速の正負を左右移動に合わせて変換
  1764. if @distanse_x == 0
  1765. @move_boost_x = 0
  1766. elsif @distanse_x < 0
  1767. @move_boost_x *= -1
  1768. end
  1769. # 距離の変化を事前計算
  1770. for i in 0...@move_speed_x
  1771. boost_x += @move_boost_x
  1772. move_x += boost_x
  1773. # オーバー距離を記録
  1774. over_distance = @distanse_x - move_x
  1775. # 右移動で距離オーバーする直前が何フレーム目だったか記録
  1776. if @distanse_x > 0 && over_distance < 0
  1777. @move_speed_x = i
  1778. break
  1779. # 左移動で距離オーバーする直前が何フレーム目だったか記録
  1780. elsif @distanse_x < 0 && over_distance > 0
  1781. @move_speed_x = i
  1782. break
  1783. end
  1784. end
  1785. # オーバー距離を一回前に戻す
  1786. before = over_distance + boost_x
  1787. # 余った距離を等速移動させるフレーム数を加算
  1788. @move_speed_plus_x = (before / @moving_x).abs
  1789. # それでも余った距離はこの時点で移動し消化
  1790. @move_x += before % @moving_x
  1791. @battler.move_x = @move_x
  1792. # 減速がある場合
  1793. elsif @move_boost_x < 0 && @distanse_x != 0
  1794. # 加減速の正負を左右移動に合わせて変換
  1795. if @distanse_x == 0
  1796. @move_boost_x = 0
  1797. elsif @distanse_x < 0
  1798. @move_boost_x *= -1
  1799. end
  1800. # 距離の変化を事前計算
  1801. for i in 0...@move_speed_x
  1802. boost_x += @move_boost_x
  1803. move_x += boost_x
  1804. # 足りない距離を記録
  1805. lost_distance = @distanse_x - move_x
  1806. before = lost_distance
  1807. # 右移動で速度が0になる直前が何フレーム目だったか記録
  1808. if @distanse_x > 0 && boost_x < 0
  1809. @move_speed_x = i - 1
  1810. # 足りない距離を一回前に戻す
  1811. before = lost_distance + boost_x
  1812. break
  1813. # 左移動で速度が0になる直前が何フレーム目だったか記録
  1814. elsif @distanse_x < 0 && boost_x > 0
  1815. @move_speed_x= i - 1
  1816. # 足りない距離を一回前に戻す
  1817. before = lost_distance + boost_x
  1818. break
  1819. end
  1820. end
  1821. # 足りない距離を等速移動させるフレーム数を加算
  1822. plus = before / @moving_x
  1823. @move_speed_plus_x = plus.abs
  1824. # それでも余った距離はこの時点で移動し消化
  1825. @move_x += before % @moving_x
  1826. @battler.move_x = @move_x
  1827. end
  1828. # Y座標移動計算
  1829. # 加減速による移動フレーム数の修正
  1830. boost_y = @moving_y
  1831. move_y = 0
  1832. # 加速がある場合
  1833. if @move_boost_y > 0 && @distanse_y != 0
  1834. # 加減速の正負を左右移動に合わせて変換
  1835. if @distanse_y == 0
  1836. @move_boost_y = 0
  1837. elsif @distanse_y < 0
  1838. @move_boost_y *= -1
  1839. end
  1840. # 距離の変化を事前計算
  1841. for i in 0...@move_speed_y
  1842. boost_y += @move_boost_y
  1843. move_y += boost_y
  1844. # オーバー距離を記録
  1845. over_distance = @distanse_y - move_y
  1846. # 右移動で距離オーバーする直前が何フレーム目だったか記録
  1847. if @distanse_y > 0 && over_distance < 0
  1848. @move_speed_y = i
  1849. break
  1850. # 左移動で距離オーバーする直前が何フレーム目だったか記録
  1851. elsif @distanse_y < 0 && over_distance > 0
  1852. @move_speed_y = i
  1853. break
  1854. end
  1855. end
  1856. # オーバー距離を一回前に戻す
  1857. before = over_distance + boost_y
  1858. # 余った距離を等速移動させるフレーム数を加算
  1859. @move_speed_plus_y = (before / @moving_y).abs
  1860. # それでも余った距離はこの時点で移動し消化
  1861. @move_y += before % @moving_y
  1862. @battler.move_y = @move_y
  1863. # 減速がある場合
  1864. elsif @move_boost_y < 0 && @distanse_y != 0
  1865. # 加減速の正負を左右移動に合わせて変換
  1866. if @distanse_y == 0
  1867. @move_boost_y = 0
  1868. elsif @distanse_y < 0
  1869. @move_boost_y *= -1
  1870. end
  1871. # 距離の変化を事前計算
  1872. for i in 0...@move_speed_y
  1873. boost_y += @move_boost_y
  1874. move_y += boost_y
  1875. # 足りない距離を記録
  1876. lost_distance = @distanse_y - move_y
  1877. before = lost_distance
  1878. # 右移動で速度が0になる直前が何フレーム目だったか記録
  1879. if @distanse_y > 0 && boost_y < 0
  1880. @move_speed_y = i
  1881. # 足りない距離を一回前に戻す
  1882. before = lost_distance + boost_y
  1883. break
  1884. # 左移動で速度が0になる直前が何フレーム目だったか記録
  1885. elsif @distanse_y < 0 && boost_y > 0
  1886. @move_speed_y = i
  1887. # 足りない距離を一回前に戻す
  1888. before = lost_distance + boost_y
  1889. break
  1890. end
  1891. end
  1892. # 足りない距離を等速移動させるフレーム数を加算
  1893. plus = before / @moving_y
  1894. @move_speed_plus_y = plus.abs
  1895. # それでも余った距離はこの時点で移動し消化
  1896. @move_y += before % @moving_y
  1897. @battler.move_y = @move_y
  1898. end
  1899. # 移動完了時間を算出
  1900. x = @move_speed_plus_x + @move_speed_x
  1901. y = @move_speed_plus_y + @move_speed_y
  1902. if x > y
  1903. end_time = x
  1904. else
  1905. end_time = y
  1906. end
  1907. # 移動が完了するまで次のアクションに行かない
  1908. @wait = end_time
  1909. # ジャンプ計算
  1910. if @jump != 0
  1911. # 移動がなくジャンプのみの場合
  1912. if @wait == 0
  1913. # 時間に計上
  1914. @wait = @active_action[3]
  1915. end
  1916. # 移動完了時間からジャンプ時間を算出
  1917. @jump_time = @wait / 2
  1918. # 割り切れない場合の余り時間
  1919. @jump_time_plus = @wait % 2
  1920. # ジャンプの正負を判別
  1921. @jump_sign = 0
  1922. @jump_sign2 = 0
  1923. if @jump < 0
  1924. @jump_sign = -1
  1925. @jump_sign2 = 1
  1926. @jump = @jump * -1
  1927. else
  1928. @jump_sign = 1
  1929. @jump_sign2 = -1
  1930. end
  1931. # ジャンプ初速度を決定
  1932. @jump_up = 2 ** @jump * @jump_sign
  1933. # ジャンプ時間の端数を微調整
  1934. if @jump_time == 0
  1935. @jump_up = 0
  1936. elsif @jump_time != 1
  1937. @jump_size = @jump_up * @jump_sign * @jump_sign2
  1938. else
  1939. @jump_size = @jump_up * 2 * @jump_sign * @jump_sign2
  1940. @jump_flug = true
  1941. end
  1942. end
  1943. end
  1944. #--------------------------------------------------------------------------
  1945. # ++ Battler Frame Animation Setup
  1946. #--------------------------------------------------------------------------
  1947. def battler_anime
  1948. # アニメ設定を反映
  1949. @anime_kind = @active_action[1]
  1950. @anime_speed = @active_action[2]
  1951. @anime_loop = @active_action[3]
  1952. # ウエイト時間があれば加算
  1953. @unloop_wait = @active_action[4]
  1954. @anime_end = true
  1955. @reverse = false
  1956. # 武器アクションがある場合だけ更新する
  1957. if @weapon_R != nil && @active_action[8] != ""
  1958. # 武器の設定をチェック
  1959. weapon_kind = N01::ANIME[@active_action[8]]
  1960. # エネミーと二刀ではないアクターの二刀フラグアニメ処理はキャンセル
  1961. two_swords_flug = weapon_kind[11]
  1962. return if two_swords_flug && [email protected]?
  1963. return if two_swords_flug && @battler.weapons[1] == nil && @battler.actor?
  1964. if @battler.actor? && @battler.weapons[0] == nil && !two_swords_flug
  1965. @weapon_R.action_reset
  1966. elsif @battler.actor? && @battler.weapons[1] == nil && two_swords_flug
  1967. @weapon_R.action_reset
  1968. elsif [email protected]? && @battler.weapon == 0
  1969. @weapon_R.action_reset
  1970. else
  1971. # 初期化
  1972. @weapon_R.action_reset
  1973. # アニメパターンが固定だった場合の武器位置を取得
  1974. if @active_action[5] != -1
  1975. @weapon_R.freeze(@active_action[5])
  1976. end
  1977. # 武器画像を設定
  1978. @weapon_R.weapon_graphics unless two_swords_flug
  1979. @weapon_R.weapon_graphics(true) if two_swords_flug
  1980. # 武器アクションを渡す
  1981. @weapon_R.weapon_action(@active_action[8],@anime_loop)
  1982. @weapon_action = true
  1983. # 最初の武器アクションを更新
  1984. @weapon_R.action
  1985. end
  1986. elsif @weapon_R != nil
  1987. @weapon_R.action_reset
  1988. end
  1989. @anime_end = false
  1990. # アニメパターンが固定だった場合
  1991. if @active_action[5] != -1 && @active_action[5] != -2
  1992. # フラグオン
  1993. @anime_freeze = true
  1994. # アニメが常に終了しているとみなす
  1995. @anime_end = true
  1996. # 片道逆転再生だった場合
  1997. elsif @active_action[5] == -2
  1998. @anime_freeze = false
  1999. # フラグオン
  2000. @reverse = true
  2001. # 最初のアニメパターンを更新
  2002. @pattern = @base_width - 1
  2003. # 武器アニメがある時だけフレーム更新
  2004. if @weapon_action && @weapon_R != nil
  2005. @weapon_R.action
  2006. @weapon_R.update
  2007. end
  2008. # 通常のアニメ更新の場合
  2009. else
  2010. @anime_freeze = false
  2011. # 最初のアニメパターンを更新
  2012. @pattern = 0
  2013. # 武器アニメがある時だけフレーム更新
  2014. if @weapon_action && @weapon_R != nil
  2015. @weapon_R.action
  2016. @weapon_R.update
  2017. end
  2018. end
  2019. @pattern_back = false
  2020. @frame = @anime_speed
  2021. @battler.move_z = @active_action[6]
  2022. # 影の有無
  2023. if @shadow != nil
  2024. @shadow.visible = true if @active_action[7]
  2025. @shadow.visible = false unless @active_action[7]
  2026. end
  2027. # ナンバリングから読み取るファイル名を分岐
  2028. if @active_action[0] == 0
  2029. file_name = @battler_name
  2030. else
  2031. file_name = @battler_name + "_" + @active_action[0].to_s
  2032. end
  2033. # アニメしないバトラーなら処理終了
  2034. return unless @anime_flug
  2035. @battler_hue = @battler.battler_hue ## blackmorning unofficial code; 3.3c
  2036. if @battler_hue != nil
  2037. self.bitmap = Cache.character(file_name, @battler_hue)
  2038. else
  2039. self.bitmap = Cache.character(file_name)
  2040. end ## end blackmorning unofficial code; 3.3c
  2041. # 転送元の矩形を設定
  2042. @sx = @pattern * @width
  2043. @sy = @anime_kind * @height
  2044. @sx = @active_action[5] * @width if @anime_freeze
  2045. self.src_rect.set(@sx, @sy, @width, @height)
  2046. end
  2047. #--------------------------------------------------------------------------
  2048. # ++ Moving Animations
  2049. #--------------------------------------------------------------------------
  2050. def moving_anime
  2051. # まだ前のアニメ飛ばしが残っているなら初期化
  2052. # If the previous animation exists, initialize actions
  2053. @move_anime.action_reset if @anime_moving
  2054. @anime_moving = true
  2055. # Mirror when in a surprise encounter
  2056. mirror = false
  2057. mirror = true if $back_attack
  2058. # Animation ID
  2059. id = @active_action[1]
  2060. # Object/Target
  2061. target = @active_action[2]
  2062. x = y = mem = 0
  2063. # If object is a single unit
  2064. if target == 0
  2065. # ターゲットが決まってない場合、自身に変換
  2066. # If target is not decided, change target to self
  2067. if @target_battler == nil
  2068. x = self.x
  2069. y = self.y
  2070. else
  2071. # ターゲットが空の場合、自身に変換
  2072. # If target is nil, change target to self
  2073. if @target_battler[0] == nil
  2074. x = self.x
  2075. y = self.y
  2076. else
  2077. # 最初に入っているターゲットに対象決定
  2078. # If target is confirmed, get position
  2079. x = @target_battler[0].position_x
  2080. y = @target_battler[0].position_y
  2081. end
  2082. end
  2083. # 対象が敵の中心の場合
  2084. # When the object/targets is a group of enemies
  2085. elsif target == 1
  2086. # 自身がアクターの場合はエネミーの中心を計算
  2087. # Calculate the center position of the party
  2088. if @battler.is_a?(Game_Actor)
  2089. for target in $game_troop.members
  2090. x += target.position_x
  2091. y += target.position_y
  2092. mem += 1
  2093. end
  2094. x = x / mem
  2095. y = y / mem
  2096. # 自身がエネミーの場合はアクターの中心を計算
  2097. # Calculate the center position of the enemy targets
  2098. else
  2099. for target in $game_party.members
  2100. x += target.position_x
  2101. y += target.position_y
  2102. mem += 1
  2103. end
  2104. x = x / mem
  2105. y = y / mem
  2106. end
  2107. # 対象が味方の中心の場合
  2108. # When the object/targets are a group of actors
  2109. elsif target == 2
  2110. # 自身がアクターの場合はアクターの中心を計算
  2111. # Calculate center of actor party
  2112. if @battler.is_a?(Game_Actor)
  2113. for target in $game_party.members
  2114. x += target.position_x
  2115. y += target.position_y
  2116. mem += 1
  2117. end
  2118. x = x / mem
  2119. y = y / mem
  2120. # 自身がエネミーの場合はエネミーの中心を計算
  2121. # Calculate cetner of enemy troop
  2122. else
  2123. for target in $game_troop.members
  2124. x += target.position_x
  2125. y += target.position_y
  2126. mem += 1
  2127. end
  2128. x = x / mem
  2129. y = y / mem
  2130. end
  2131. # Object is self
  2132. else
  2133. x = self.x
  2134. y = self.y
  2135. end
  2136. # 開始位置の微調整
  2137. # Adjust position of animation
  2138. plus_x = @active_action[6]
  2139. plus_y = @active_action[7]
  2140. # エネミーはX軸を逆に
  2141. # x-axis is reversed for enemies
  2142. plus_x *= -1 if @battler.is_a?(Game_Enemy)
  2143. # 最終的な移動距離を算出
  2144. # Calculate distance from source to target
  2145. distanse_x = x - self.x - plus_x
  2146. distanse_y = y - self.y - plus_y
  2147. # 飛ばしタイプ
  2148. # Get animation pass-through value
  2149. type = @active_action[3]
  2150. # Speed of animation
  2151. speed = @active_action[4]
  2152. # 軌道
  2153. # Orbit/arc
  2154. orbit = @active_action[5]
  2155. # 自身が開始位置なら
  2156. # If origin is self
  2157. if @active_action[8] == 0
  2158. @move_anime.base_x = self.x + plus_x
  2159. @move_anime.base_y = self.y + plus_y
  2160. # 対象が開始位置なら
  2161. # If origin is target
  2162. elsif @active_action[8] == 1
  2163. @move_anime.base_x = x + plus_x
  2164. @move_anime.base_y = y + plus_y
  2165. # 距離を反対に
  2166. distanse_y = distanse_y * -1
  2167. distanse_x = distanse_x * -1
  2168. # 動かさないなら
  2169. # If other origin
  2170. else
  2171. @move_anime.base_x = x
  2172. @move_anime.base_y = y
  2173. distanse_x = distanse_y = 0
  2174. end
  2175. # 武器アクションなしは武器表示しない
  2176. # Flying graphic is nothing
  2177. if @active_action[10] == ""
  2178. weapon = ""
  2179. # アニメなしエネミーは武器表示しない
  2180. # No flying graphic if not animated
  2181. # elsif @anime_flug != true # 3.4a
  2182. # weapon = ""
  2183. ## 武器アクションがある場合
  2184. # If there is a weapon action
  2185. else
  2186. # 飛ばす武器グラフィックが指定されているかチェック
  2187. # Check if weapon has a flying graphic
  2188. if @battler.is_a?(Game_Actor)
  2189. battler = $game_party.members[@battler.index]
  2190. weapon_id = battler.weapon_id
  2191. else
  2192. battler = $game_troop.members[@battler.index]
  2193. weapon_id = battler.weapon
  2194. end
  2195. # スキル画像利用か武器画像利用か判別
  2196. # Determine use of equipped weapon graphic or other graphic
  2197. weapon_act = N01::ANIME[@active_action[10]].dup if @active_action[10] != ""
  2198. # 3.4a
  2199. # Moved the priority of skill flying graphic
  2200. use_skill_item_graphic = false
  2201. # Set skill flying graphic, 3.4a
  2202. if weapon_act != nil && @battler.action.skill != nil
  2203. skill_flygraphic = $data_skills[@battler.action.skill.id].flying_graphic
  2204. # If skill has flying graphic
  2205. if skill_flygraphic.downcase == "icon"
  2206. icon_weapon = true
  2207. use_skill_item_graphic = true
  2208. weapon = @active_action[10]
  2209. weapon_name = $data_skills[@battler.action.skill.id].icon_index
  2210. elsif skill_flygraphic != ""
  2211. icon_weapon = false
  2212. use_skill_item_graphic = true
  2213. weapon = @active_action[10]
  2214. weapon_name = skill_flygraphic
  2215. end
  2216. # Set item flying graphic, 3.4a
  2217. elsif weapon_act != nil && @battler.action.item != nil
  2218. item_flygraphic = $data_items[@battler.action.item.id].flying_graphic
  2219. # if item has a flying graphic
  2220. if item_flygraphic.downcase == "icon"
  2221. icon_weapon = true
  2222. use_skill_item_graphic = true
  2223. weapon = @active_action[10]
  2224. weapon_name = $data_items[@battler.action.item.id].icon_index
  2225. elsif item_flygraphic != ""
  2226. icon_weapon = false
  2227. use_skill_item_graphic = true
  2228. weapon = @active_action[10]
  2229. weapon_name = item_flygraphic
  2230. end
  2231. end
  2232. # 武器画像利用で素手でなければ
  2233. # If user has a weapon, utilize graphics
  2234. if weapon_id != 0 && weapon_act.size == 3 && !use_skill_item_graphic # 3.4a
  2235. weapon_file = $data_weapons[weapon_id].flying_graphic
  2236. weapon_file = "" if weapon_file.downcase == "icon" # 3.4a
  2237. # If a flying graphic is not given, get weapon graphic
  2238. if weapon_file == ""
  2239. weapon_name = $data_weapons[weapon_id].graphic
  2240. icon_weapon = false
  2241. # さらに指定がなければアイコングラフィックを利用
  2242. # If weapon graphic is not found, get Iconset graphic.
  2243. if weapon_name == ""
  2244. weapon_name = $data_weapons[weapon_id].icon_index
  2245. icon_weapon = true
  2246. end
  2247. # 指定されていればそのグラフィック名を取得
  2248. # If there is a specified graphics
  2249. else
  2250. icon_weapon = false
  2251. weapon_name = weapon_file
  2252. end
  2253. # 武器アクション情報を取得
  2254. # Get weapon action
  2255. weapon = @active_action[10]
  2256. # 武器画像利用で素手なら表示しない
  2257. elsif weapon_act.size == 3 && !use_skill_item_graphic # 3.4a
  2258. weapon = ""
  2259. # # スキル画像利用
  2260. # elsif weapon_act != nil && @battler.action.skill != nil
  2261. # icon_weapon = false
  2262. # weapon_name = $data_skills[@battler.action.skill.id].flying_graphic
  2263. # weapon = @active_action[10]
  2264. end
  2265. end
  2266. # Z座標を決定
  2267. @move_anime.z = 1
  2268. @move_anime.z = 1000 if @active_action[9]
  2269. # 以上の情報を全てアニメ飛ばしスプライトに送る
  2270. @move_anime.anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,weapon_name,icon_weapon)
  2271. end
  2272. #--------------------------------------------------------------------------
  2273. # ● アクション終了
  2274. #--------------------------------------------------------------------------
  2275. def anime_finish
  2276. # 個別処理終了が省略された場合リピートさせる
  2277. return individual_action_end if @individual_targets.size != 0
  2278. # アクティブバトラーにアクション情報を格納
  2279. send_action(@active_action[0]) if @battler.active
  2280. # 残像があれば開放
  2281. mirage_off if @mirage_flug
  2282. # 待機アクションを繰り返す
  2283. start_action(@repeat_action) unless @non_repeat
  2284. end
  2285. #--------------------------------------------------------------------------
  2286. # ● No Collapse
  2287. #--------------------------------------------------------------------------
  2288. def collapse_action
  2289. @non_repeat = true
  2290. @effect_type = COLLAPSE
  2291. @collapse_type = @battler.collapse_type unless @battler.actor?
  2292. @battler_visible = false unless @battler.actor?
  2293. @effect_duration = N01::COLLAPSE_WAIT + 48 if @collapse_type == 2
  2294. @effect_duration = 401 if @collapse_type == 3
  2295. @effect_duration = 401 if @collapse_type == 4
  2296. end
  2297. #--------------------------------------------------------------------------
  2298. # ● Normal Collapse
  2299. #--------------------------------------------------------------------------
  2300. def normal_collapse
  2301. if @effect_duration == 47
  2302. Sound.play_enemy_collapse
  2303. self.blend_type = 1
  2304. self.color.set(255, 128, 128, 128)
  2305. end
  2306. self.opacity = 256 - (48 - @effect_duration) * 6 if @effect_duration <= 47
  2307. end
  2308. #--------------------------------------------------------------------------
  2309. # ● Boss Collapse
  2310. #--------------------------------------------------------------------------
  2311. def boss_collapse1
  2312. if @effect_duration == 320
  2313. Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2314. self.flash(Color.new(255, 255, 255), 60)
  2315. viewport.flash(Color.new(255, 255, 255), 20)
  2316. end
  2317. if @effect_duration == 280
  2318. Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2319. self.flash(Color.new(255, 255, 255), 60)
  2320. viewport.flash(Color.new(255, 255, 255), 20)
  2321. end # 3.4a removed battler reset out
  2322. if @effect_duration == 220
  2323. Audio.se_play("Audio/SE/Earth4", 100, 80)
  2324. self.blend_type = 1
  2325. self.color.set(255, 128, 128, 128)
  2326. self.wave_amp = 6
  2327. end
  2328. if @effect_duration < 220
  2329. self.src_rect.set(0, @effect_duration / 2 - 110, @width, @height)
  2330. self.x += 8 if @effect_duration % 4 == 0
  2331. self.x -= 8 if @effect_duration % 4 == 2
  2332. self.wave_amp += 1 if @effect_duration % 10 == 0
  2333. self.opacity = @effect_duration
  2334. return if @effect_duration < 50
  2335. Audio.se_play("Audio/SE/Earth4", 100, 50) if @effect_duration % 50 == 0
  2336. end
  2337. if @effect_duration == 0 # 3.4a
  2338. reset
  2339. end
  2340. end
  2341. end
  2342. #--------------------------------------------------------------------------
  2343. # ● Final Boss Collapse
  2344. #--------------------------------------------------------------------------
  2345. #def boss_collapse2
  2346. #if @effect_duration == 320
  2347. # Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2348. # self.flash(Color.new(255, 255, 255), 60)
  2349. # viewport.flash(Color.new(255, 255, 255), 20)
  2350. # end
  2351. # if @effect_duration == 280
  2352. # Audio.se_play("Audio/SE/Absorb1", 100, 80)
  2353. # self.flash(Color.new(255, 255, 255), 60)
  2354. # viewport.flash(Color.new(255, 255, 255), 20)
  2355. # end # 3.4a removed battler reset out
  2356. # if @effect_duration == 220
  2357. # Audio.se_play("Audio/SE/Earth4", 100, 80)
  2358. # self.blend_type = 1
  2359. #self.color.set(255, 24, 24, 196)
  2360. #self.wave_amp = 9
  2361. #end
  2362. #if @effect_duration < 220
  2363. # self.src_rect.set(0, @effect_duration / 2 - 110, @width, @height)
  2364. # self.x += 8 if @effect_duration % 4 == 0
  2365. # self.x -= 8 if @effect_duration % 4 == 2
  2366. # self.wave_amp += 1 if @effect_duration % 10 == 0
  2367. # self.opacity = @effect_duration
  2368. # return if @effect_duration < 90
  2369. # Audio.se_play("Audio/SE/Fire6", 100, 50) if @effect_duration % 90 == 0
  2370. # end
  2371. # if @effect_duration == 0 # 3.4a
  2372. # reset
  2373. #end
  2374. # end
  2375. #end
  2376.  
  2377. module Cache ## blackmorning unofficial Code 3.3c
  2378. #--------------------------------------------------------------------------
  2379. # * Get Character Graphic
  2380. # filename : Filename
  2381. #--------------------------------------------------------------------------
  2382. def self.character(filename, hue = 0)
  2383. load_bitmap("Graphics/Characters/", filename, hue)
  2384. end
  2385. end ## end unofficial Code 3.3c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement