Advertisement
Guest User

Untitled

a guest
Oct 25th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.82 KB | None | 0 0
  1. class Bitmap
  2. if not method_defined?('original_draw_text')
  3. alias original_draw_text draw_text
  4. def draw_text(*arg)
  5.  
  6. original_color = self.font.color.dup
  7. self.font.color = Color.new(0, 0, 0, 128)
  8.  
  9. if arg[0].is_a?(Rect)
  10. arg[0].x += 2
  11. arg[0].y += 2
  12. self.original_draw_text(*arg)
  13. arg[0].x -= 2
  14. arg[0].y -= 2
  15. else
  16. arg[0] += 2
  17. arg[1] += 2
  18. self.original_draw_text(*arg)
  19. arg[0] -= 2
  20. arg[1] -= 2
  21. end
  22.  
  23. self.font.color = original_color
  24. self.original_draw_text(*arg)
  25.  
  26. end
  27. end
  28. def gradation_rect(x, y, width, height, color1, color2, align = 0)
  29. if align == 0
  30. for i in x...x + width
  31. red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
  32. green = color1.green +
  33. (color2.green - color1.green) * (i - x) / (width - 1)
  34. blue = color1.blue +
  35. (color2.blue - color1.blue) * (i - x) / (width - 1)
  36. alpha = color1.alpha +
  37. (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  38. color = Color.new(red, green, blue, alpha)
  39. fill_rect(i, y, 1, height, color)
  40. end
  41. elsif align == 1
  42. for i in y...y + height
  43. red = color1.red +
  44. (color2.red - color1.red) * (i - y) / (height - 1)
  45. green = color1.green +
  46. (color2.green - color1.green) * (i - y) / (height - 1)
  47. blue = color1.blue +
  48. (color2.blue - color1.blue) * (i - y) / (height - 1)
  49. alpha = color1.alpha +
  50. (color2.alpha - color1.alpha) * (i - y) / (height - 1)
  51. color = Color.new(red, green, blue, alpha)
  52. fill_rect(x, i, width, 1, color)
  53. end
  54. elsif align == 2
  55. for i in x...x + width
  56. for j in y...y + height
  57. red = color1.red + (color2.red - color1.red) *
  58. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  59. green = color1.green + (color2.green - color1.green) *
  60. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  61. blue = color1.blue + (color2.blue - color1.blue) *
  62. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  63. alpha = color1.alpha + (color2.alpha - color1.alpha) *
  64. ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  65. color = Color.new(red, green, blue, alpha)
  66. set_pixel(i, j, color)
  67. end
  68. end
  69. elsif align == 3
  70. for i in x...x + width
  71. for j in y...y + height
  72. red = color1.red + (color2.red - color1.red) *
  73. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  74. green = color1.green + (color2.green - color1.green) *
  75. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  76. blue = color1.blue + (color2.blue - color1.blue) *
  77. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  78. alpha = color1.alpha + (color2.alpha - color1.alpha) *
  79. ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  80. color = Color.new(red, green, blue, alpha)
  81. set_pixel(i, j, color)
  82. end
  83. end
  84. end
  85. end
  86. end
  87.  
  88. module RPG
  89. class Sprite < ::Sprite
  90. def damage(value, critical)
  91. dispose_damage
  92. if value.is_a?(Numeric)
  93. damage_string = value.abs.to_s
  94. else
  95. damage_string = value.to_s
  96. end
  97. bitmap = Bitmap.new(160, 48)
  98. bitmap.font.name = "Arial Black"
  99. bitmap.font.size = 32
  100. bitmap.font.color.set(0, 0, 0)
  101. bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  102. bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  103. bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  104. bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  105. if value.is_a?(Numeric) and value < 0
  106. bitmap.font.color.set(176, 255, 144)
  107. else
  108. bitmap.font.color.set(255, 255, 255)
  109. end
  110. bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  111. if critical
  112. bitmap.font.size = 20
  113. bitmap.font.color.set(0, 0, 0)
  114. bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  115. bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  116. bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  117. bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  118. bitmap.font.color.set(255, 255, 255)
  119. bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  120. end
  121. @_damage_sprite = ::Sprite.new
  122. @_damage_sprite.bitmap = bitmap
  123. @_damage_sprite.ox = 80 + self.viewport.ox
  124. @_damage_sprite.oy = 20 + self.viewport.oy
  125. @_damage_sprite.x = self.x + self.viewport.rect.x
  126. @_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
  127. @_damage_sprite.z = 3000
  128. @_damage_duration = 40
  129. end
  130. def animation(animation, hit)
  131. dispose_animation
  132. @_animation = animation
  133. return if @_animation == nil
  134. @_animation_hit = hit
  135. @_animation_duration = @_animation.frame_max
  136. animation_name = @_animation.animation_name
  137. animation_hue = @_animation.animation_hue
  138. bitmap = RPG::Cache.animation(animation_name, animation_hue)
  139. if @@_reference_count.include?(bitmap)
  140. @@_reference_count[bitmap] += 1
  141. else
  142. @@_reference_count[bitmap] = 1
  143. end
  144. @_animation_sprites = []
  145. if @_animation.position != 3 or not @@_animations.include?(animation)
  146. for i in 0..15
  147. sprite = ::Sprite.new
  148. sprite.bitmap = bitmap
  149. sprite.visible = false
  150. @_animation_sprites.push(sprite)
  151. end
  152. unless @@_animations.include?(animation)
  153. @@_animations.push(animation)
  154. end
  155. end
  156. update_animation
  157. end
  158. def loop_animation(animation)
  159. return if animation == @_loop_animation
  160. dispose_loop_animation
  161. @_loop_animation = animation
  162. return if @_loop_animation == nil
  163. @_loop_animation_index = 0
  164. animation_name = @_loop_animation.animation_name
  165. animation_hue = @_loop_animation.animation_hue
  166. bitmap = RPG::Cache.animation(animation_name, animation_hue)
  167. if @@_reference_count.include?(bitmap)
  168. @@_reference_count[bitmap] += 1
  169. else
  170. @@_reference_count[bitmap] = 1
  171. end
  172. @_loop_animation_sprites = []
  173. for i in 0..15
  174. sprite = ::Sprite.new
  175. sprite.bitmap = bitmap
  176. sprite.visible = false
  177. @_loop_animation_sprites.push(sprite)
  178. end
  179. update_loop_animation
  180. end
  181. def animation_set_sprites(sprites, cell_data, position)
  182. for i in 0..15
  183. sprite = sprites[i]
  184. pattern = cell_data[i, 0]
  185. if sprite == nil or pattern == nil or pattern == -1
  186. sprite.visible = false if sprite != nil
  187. next
  188. end
  189. sprite.visible = true
  190. sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  191. if position == 3
  192. if self.viewport != nil
  193. sprite.x = self.viewport.rect.width / 2
  194. sprite.y = self.viewport.rect.height - 160
  195. else
  196. sprite.x = 320
  197. sprite.y = 240
  198. end
  199. else
  200. sprite.x = self.x + self.viewport.rect.x -
  201. self.ox + self.src_rect.width / 2
  202. sprite.y = self.y + self.viewport.rect.y -
  203. self.oy + self.src_rect.height / 2
  204. sprite.y -= self.src_rect.height / 4 if position == 0
  205. sprite.y += self.src_rect.height / 4 if position == 2
  206. end
  207. sprite.x += cell_data[i, 1]
  208. sprite.y += cell_data[i, 2]
  209. sprite.z = 2000
  210. sprite.ox = 96
  211. sprite.oy = 96
  212. sprite.zoom_x = cell_data[i, 3] / 100.0
  213. sprite.zoom_y = cell_data[i, 3] / 100.0
  214. sprite.angle = cell_data[i, 4]
  215. sprite.mirror = (cell_data[i, 5] == 1)
  216. sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  217. sprite.blend_type = cell_data[i, 7]
  218. end
  219. end
  220. end
  221. end
  222.  
  223. class Game_Actor < Game_Battler
  224. def screen_x
  225. if self.index != nil
  226. n_split = [($game_party.actors.length * 0.5).ceil, 4].min
  227. case n_split
  228. when 1
  229. n_index = self.index * 2
  230. when 2
  231. if self.index < ($game_party.actors.length - 2)
  232. n_index = 0.5 + (2 * self.index)
  233. else
  234. if $game_party.actors.length == 3 then
  235. n_index = (self.index * 2) + 2
  236. elsif $game_party.actors.length == 4 then
  237. n_index = self.index * 2
  238. end
  239. end
  240. when 3
  241. n_index = self.index + (0.25 * (self.index + 1))
  242. if $game_party.actors.length == 5
  243. if self.index < 2
  244. n_index = self.index + (0.25 * (self.index + 1))
  245. else
  246. n_index = self.index + (0.25 * (self.index + 2)) + 1
  247. end
  248. end
  249. when 4
  250. n_index = self.index
  251. if $game_party.actors.length == 7
  252. if self.index < 3
  253. n_index = self.index
  254. else
  255. n_index = self.index + 1
  256. end
  257. end
  258. end
  259. return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) / 5) + 480 + ((n_index / 4).floor * 60)
  260. else
  261. return 0
  262. end
  263. end
  264. #--------------------------------------------------------------------------
  265. # ? ????? Y ?????
  266. #--------------------------------------------------------------------------
  267. def screen_y
  268. n_split = [($game_party.actors.length * 0.5).ceil, 4].min
  269. case n_split
  270. when 1
  271. n_index = self.index * 2
  272. when 2
  273. if self.index < ($game_party.actors.length - 2)
  274. n_index = 0.5 + (2 * self.index)
  275. else
  276. if $game_party.actors.length == 3 then
  277. n_index = (self.index * 2) + 2
  278. elsif $game_party.actors.length == 4 then
  279. n_index = self.index * 2
  280. end
  281. end
  282. when 3
  283. n_index = self.index + (0.25 * (self.index + 1))
  284. if $game_party.actors.length == 5
  285. if self.index < 2
  286. n_index = self.index + (0.25 * (self.index + 1))
  287. else
  288. n_index = self.index + (0.25 * (self.index + 2)) + 1
  289. end
  290. end
  291. when 4
  292. n_index = self.index
  293. if $game_party.actors.length == 7
  294. if self.index < 3
  295. n_index = self.index
  296. else
  297. n_index = self.index + 1
  298. end
  299. end
  300. end
  301. return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) * 1.6) + 270 - ((n_index / 4).floor * (110 - (4 * 20)))
  302. end
  303. #--------------------------------------------------------------------------
  304. # ? ????? Z ?????
  305. #--------------------------------------------------------------------------
  306. def screen_z
  307. # ??????????? Z ?????????
  308. if self.index != nil
  309. return self.index
  310. else
  311. return 0
  312. end
  313. end
  314. end
  315.  
  316. class Game_Enemy < Game_Battler
  317. def screen_x
  318. n_split = [($game_troop.enemies.length * 0.5).ceil, 4].min
  319. case n_split
  320. when 1
  321. n_index = self.index * 2
  322. when 2
  323. if self.index < ($game_troop.enemies.length - 2)
  324. n_index = 0.5 + (2 * self.index)
  325. else
  326. if $game_troop.enemies.length == 3 then
  327. n_index = (self.index * 2) + 2
  328. elsif $game_troop.enemies.length == 4 then
  329. n_index = self.index * 2
  330. end
  331. end
  332. when 3
  333. n_index = self.index + (0.25 * (self.index + 1))
  334. if $game_troop.enemies.length == 5
  335. if self.index < 2
  336. n_index = self.index + (0.25 * (self.index + 1))
  337. else
  338. n_index = self.index + (0.25 * (self.index + 2)) + 2
  339. end
  340. end
  341. when 4
  342. n_index = self.index
  343. if $game_troop.enemies.length == 7
  344. if self.index < 3
  345. n_index = self.index
  346. else
  347. n_index = self.index + 1
  348. end
  349. end
  350. end
  351. return (n_index - ((n_index / 4).floor) * 4) * ((-160 / (4)) / 5) + 160 - ((n_index / 4).floor * 60)
  352. end
  353. #--------------------------------------------------------------------------
  354. # ? ????? Y ?????
  355. #--------------------------------------------------------------------------
  356. def screen_y
  357. n_split = [($game_troop.enemies.length * 0.5).ceil, 4].min
  358. case n_split
  359. when 1
  360. n_index = self.index * 2
  361. when 2
  362. if self.index < ($game_troop.enemies.length - 2)
  363. n_index = 0.5 + (2 * self.index)
  364. else
  365. if $game_troop.enemies.length == 3 then
  366. n_index = (self.index * 2) + 2
  367. elsif $game_troop.enemies.length == 4 then
  368. n_index = self.index * 2
  369. end
  370. end
  371. when 3
  372. n_index = self.index + (0.25 * (self.index + 1))
  373. if $game_troop.enemies.length == 5
  374. if self.index < 2
  375. n_index = self.index + (0.25 * (self.index + 1))
  376. else
  377. n_index = self.index + (0.25 * (self.index + 2)) + 1
  378. end
  379. end
  380. when 4
  381. n_index = self.index
  382. if $game_troop.enemies.length == 7
  383. if self.index < 3
  384. n_index = self.index
  385. else
  386. n_index = self.index + 1
  387. end
  388. end
  389. end
  390. return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) * 1.6) + 270 - ((n_index / 4).floor * (110 - (4 * 20)))
  391. end
  392.  
  393. def screen_z
  394. return @member_index + 1
  395. end
  396. end
  397.  
  398. class Sprite_Battler < RPG::Sprite
  399.  
  400. attr_accessor :battler # ????
  401. attr_accessor :moving # Is the sprite moving?
  402. attr_reader :index
  403. attr_accessor :target_index
  404. attr_accessor :direction
  405. attr_accessor :pattern
  406.  
  407. def initialize(viewport, battler = nil)
  408. super(viewport)
  409. change
  410. @old = Graphics.frame_count # For the delay method
  411. @goingup = true # Increasing animation? (if @rm2k_mode is true)
  412. @once = false # Is the animation only played once?
  413. @animated = true # Used to stop animation when @once is true
  414. self.opacity = 0
  415. @index = 0
  416. @pattern_b = 0
  417. @counter_b = 0
  418. @trans_sprite = Sprite.new
  419. @trans_sprite.opacity = 0
  420. @bar_hp_sprite = Sprite.new
  421. @bar_hp_sprite.bitmap = Bitmap.new(64, 10)
  422. @bar_sp_sprite = Sprite.new
  423. @bar_sp_sprite.bitmap = Bitmap.new(64, 10)
  424. @color1 = Color.new(0, 0, 0, 192)
  425. @color2 = Color.new(255, 255, 192, 192)
  426. @color3 = Color.new(0, 0, 0, 192)
  427. @color4 = Color.new(64, 0, 0, 192)
  428. @old_hp = -1
  429. @old_sp = -1
  430. @battler = battler
  431. @battler_visible = false
  432. @first = true
  433. @pattern = 0
  434. if $target_index == nil
  435. $target_index = 0
  436. end
  437. @battler.is_a?(Game_Enemy) ? enemy_pose(0, 1) : pose(0, 1)
  438. end
  439.  
  440. def dispose
  441. if self.bitmap != nil
  442. self.bitmap.dispose
  443. end
  444. if @trans_sprite.bitmap != nil
  445. @trans_sprite.bitmap.dispose
  446. end
  447. @trans_sprite.dispose
  448. @bar_hp_sprite.bitmap.dispose
  449. @bar_hp_sprite.dispose
  450. @bar_sp_sprite.bitmap.dispose
  451. @bar_sp_sprite.dispose
  452. super
  453. end
  454.  
  455. def change(frames = 0, delay = 0, offx = 0, offy = 0, startf = 0, once = false)
  456. @frames = frames
  457. @delay = delay
  458. @offset_x, @offset_y = offx, offy
  459. @current_frame = startf
  460. @once = once
  461. @goingup = true
  462. @animated = true
  463. end
  464.  
  465. def update
  466. bar_check = true if @_damage_duration == 1
  467. super
  468. @trans_sprite.blend_type = self.blend_type
  469. @trans_sprite.color = self.color
  470. if @_collapse_duration > 0
  471. @trans_sprite.opacity = self.opacity
  472. else
  473. @trans_sprite.opacity = [self.opacity, 160].min
  474. end
  475. if (@_damage_duration == 0 and bar_check == true) or @first == true
  476. @first = false if @first == true
  477. bar_check = false
  478. @bar_must_change = true
  479. end
  480. @bar_hp_sprite.opacity = self.opacity
  481. @bar_sp_sprite.opacity = self.opacity
  482. # ????? nil ???
  483. if @battler == nil
  484. self.bitmap = nil
  485. @trans_sprite.bitmap = nil
  486. loop_animation(nil)
  487. return
  488. end
  489. # ????????????????????
  490. if @battler.battler_name != @battler_name or
  491. @battler.battler_hue != @battler_hue
  492. # ????????????
  493. @battler_name = @battler.battler_name
  494. @battler_hue = @battler.battler_hue
  495. if @battler.is_a?(Game_Actor)
  496. @battler_name = @battler.character_name
  497. @battler_hue = @battler.character_hue
  498. @direction = 4
  499. else
  500. @direction = 6
  501. end
  502. self.bitmap = RPG::Cache.character(@battler_name, @battler_hue)
  503. @width = bitmap.width / 4
  504. @height = bitmap.height / 4
  505. @frame_width = @width
  506. @frame_height = @height
  507. self.ox = @width / 2
  508. self.oy = @height
  509. @pattern = @current_frame
  510. @direction = @offset_y
  511. sx = @pattern * @width
  512. sy = (@direction - 2) / 2 * @height
  513. self.src_rect.set(sx, sy, @width, @height)
  514. @current_frame = (@current_frame + 1) unless @frames == 0
  515. @animated = false if @current_frame == @frames and @once
  516. @current_frame %= @frames
  517. @trans_sprite.bitmap = self.bitmap
  518. @trans_sprite.ox = self.ox
  519. @trans_sprite.oy = self.oy
  520. @trans_sprite.src_rect.set(sx, sy, @width, @height)
  521. # ?????????????????? 0 ???
  522. if @battler.dead? or @battler.hidden
  523. self.opacity = 0
  524. @trans_sprite.opacity = 0
  525. @bar_hp_sprite.opacity = 0
  526. @bar_sp_sprite.opacity = 0
  527. end
  528. self.x = @battler.screen_x
  529. self.y = @battler.screen_y
  530. self.z = @battler.screen_z
  531. end
  532. change_sp_bar if @old_sp != @battler.sp
  533. if delay(@delay) and @animated
  534. @pattern = @current_frame
  535. @direction = @offset_y
  536. sx = @pattern * @width
  537. sy = (@direction - 2) / 2 * @height
  538. self.src_rect.set(sx, sy, @width, @height)
  539. @current_frame = (@current_frame + 1) unless @frames == 0
  540. @animated = false if @current_frame == @frames and @once
  541. @current_frame %= @frames
  542. @trans_sprite.ox = self.ox
  543. @trans_sprite.oy = self.oy
  544. @trans_sprite.src_rect.set(sx, sy, @width, @height)
  545. end
  546. # ??????? ID ????????????
  547. if @battler.damage == nil and
  548. @battler.state_animation_id != @state_animation_id
  549. @state_animation_id = @battler.state_animation_id
  550. loop_animation($data_animations[@state_animation_id])
  551. end
  552. # ??????????????
  553. #if @battler.is_a?(Game_Actor) and @battler_visible
  554. # ???????????????????????
  555. #if $game_temp.battle_main_phase
  556. #self.opacity += 3 if self.opacity < 255
  557. #else
  558. #self.opacity -= 3 if self.opacity > 207
  559. #end
  560. #end
  561. # ??
  562. if @battler.blink
  563. blink_on
  564. else
  565. blink_off
  566. end
  567. # ??????
  568. unless @battler_visible
  569. # ??
  570. if not @battler.hidden and not @battler.dead? and
  571. (@battler.damage == nil or @battler.damage_pop)
  572. appear
  573. @battler_visible = true
  574. end
  575. end
  576. # ?????
  577. if @battler_visible
  578. # ??
  579. if @battler.hidden
  580. $game_system.se_play($data_system.escape_se)
  581. escape
  582. @trans_sprite.opacity = 0
  583. @battler_visible = false
  584. end
  585. # ??????
  586. if @battler.white_flash
  587. whiten
  588. @battler.white_flash = false
  589. end
  590. # ???????
  591. if @battler.animation_id != 0
  592. animation = $data_animations[@battler.animation_id]
  593. animation(animation, @battler.animation_hit)
  594. @battler.animation_id = 0
  595. end
  596. # ????
  597. if @battler.damage_pop
  598. damage(@battler.damage, @battler.critical)
  599. @battler.damage = nil
  600. @battler.critical = false
  601. @battler.damage_pop = false
  602. end
  603. if @bar_must_change == true
  604. @bar_must_change = false
  605. if @old_hp != @battler.hp
  606. change_hp_bar
  607. end
  608. if @battler.damage == nil and @battler.dead?
  609. if @battler.is_a?(Game_Enemy)
  610. $game_system.se_play($data_system.enemy_collapse_se)
  611. else
  612. $game_system.se_play($data_system.actor_collapse_se)
  613. end
  614. collapse
  615. @battler_visible = false
  616. end
  617. end
  618. end
  619. # ???????????
  620. @trans_sprite.x = self.x
  621. @trans_sprite.y = self.y
  622. @trans_sprite.z = self.z
  623. @bar_hp_sprite.x = @battler.screen_x - 32
  624. @bar_hp_sprite.y = @battler.screen_y - (@height +18) if @height != nil
  625. @bar_hp_sprite.z = 100
  626. @bar_sp_sprite.x = @battler.screen_x - 32
  627. @bar_sp_sprite.y = @battler.screen_y - (@height + 8) if @height != nil
  628. @bar_sp_sprite.z = 100
  629. end
  630.  
  631. #--------------------------------------------------------------------------
  632. # - Move the sprite
  633. # x : X coordinate of the destination point
  634. # y : Y coordinate of the destination point
  635. # speed : Speed of movement (0 = delayed, 1+ = faster)
  636. # delay : Movement delay if speed is at 0
  637. #--------------------------------------------------------------------------
  638. def move(x, y, speed = 1, delay = 0)
  639. @destx = x
  640. @desty = y
  641. @move_speed = speed
  642. @move_delay = delay
  643. @move_old = Graphics.frame_count
  644. @moving = true
  645. end
  646.  
  647. #--------------------------------------------------------------------------
  648. # - Move sprite to destx and desty
  649. #--------------------------------------------------------------------------
  650. def update_move
  651. return unless @moving
  652. movinc = @move_speed == 0 ? 1 : @move_speed
  653. if Graphics.frame_count - @move_old > @move_delay or @move_speed != 0
  654. self.x += movinc if self.x < @destx
  655. self.x -= movinc if self.x > @destx
  656. self.y += movinc if self.y < @desty
  657. self.y -= movinc if self.y > @desty
  658. @move_old = Graphics.frame_count
  659. end
  660. if @move_speed > 1 # Check if sprite can't reach that point
  661. self.x = @destx if (@destx - self.x).abs % @move_speed != 0 and
  662. (@destx - self.x).abs <= @move_speed
  663. self.y = @desty if (@desty - self.y).abs % @move_speed != 0 and
  664. (@desty - self.y).abs <= @move_speed
  665. end
  666. if self.x == @destx and self.y == @desty
  667. @moving = false
  668. end
  669. end
  670.  
  671. #--------------------------------------------------------------------------
  672. # - Pause animation, but still updates movement
  673. # frames : Number of frames
  674. #--------------------------------------------------------------------------
  675. def delay(frames)
  676. update_move
  677. if (Graphics.frame_count - @old >= frames)
  678. @old = Graphics.frame_count
  679. return true
  680. end
  681. return false
  682. end
  683.  
  684. def change_hp_bar
  685. j = false
  686. @old_hp = @battler.hp if @old_hp == -1
  687. i = @old_hp
  688. loop do
  689. i -= 10
  690. if i < @battler.hp
  691. i = @battler.hp
  692. j = true
  693. end
  694. rate = i.to_f / @battler.maxhp
  695. @color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
  696. @color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
  697. @bar_hp_sprite.bitmap.clear
  698. @bar_hp_sprite.bitmap.fill_rect(0, 0, 64, 10, @color1)
  699. @bar_hp_sprite.bitmap.fill_rect(1, 1, 62, 8, @color2)
  700. @bar_hp_sprite.bitmap.gradation_rect(2, 2, 60, 6, @color3, @color4, 1)
  701. #@bar_hp_sprite.bitmap.fill_rect(2, 2, 60, 6, @color3)
  702. @bar_hp_sprite.bitmap.gradation_rect(2, 2, 64 * rate - 4, 6, @color5, @color6, 2)
  703. #@bar_hp_sprite.bitmap.fill_rect(2, 2, 64 * rate - 4, 6, @color5)
  704. @bar_hp_sprite.opacity = self.opacity
  705. Graphics.update
  706. if j == true
  707. j = false
  708. break
  709. end
  710. end
  711. @old_hp = @battler.hp
  712. end
  713.  
  714. def change_sp_bar
  715. j = false
  716. @old_sp = @battler.sp if @old_sp == -1
  717. i = @old_sp
  718. loop do
  719. i -= 10
  720. if i < @battler.sp
  721. i = @battler.sp
  722. j = true
  723. end
  724. rate = i.to_f / @battler.maxsp
  725. @color7 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
  726. @color8 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  727. @bar_sp_sprite.bitmap.clear
  728. @bar_sp_sprite.bitmap.fill_rect(0, 0, 64, 10, @color1)
  729. @bar_sp_sprite.bitmap.fill_rect(1, 1, 62, 8, @color2)
  730. @bar_sp_sprite.bitmap.gradation_rect(2, 2, 60, 6, @color3, @color4, 1)
  731. #@bar_hp_sprite.bitmap.fill_rect(2, 2, 60, 6, @color3)
  732. @bar_sp_sprite.bitmap.gradation_rect(2, 2, 64 * rate - 4, 6, @color7, @color8, 0)
  733. #@bar_hp_sprite.bitmap.fill_rect(2, 2, 64 * rate - 4, 6, @color5)
  734. @bar_sp_sprite.opacity = self.opacity
  735. Graphics.update
  736. if j == true
  737. j = false
  738. break
  739. end
  740. end
  741. @old_sp = @battler.sp
  742. end
  743.  
  744. def enemy #
  745. $target_index += $game_troop.enemies.size
  746. $target_index %= $game_troop.enemies.size
  747. return $game_troop.enemies[$target_index] #
  748. end #
  749.  
  750. def actor #
  751. $target_index += $game_party.actors.size
  752. $target_index %= $game_party.actors.size
  753. return $game_party.actors[$target_index] #
  754. end
  755.  
  756. def index=(index)
  757. @index = index
  758. update
  759. end
  760.  
  761. def pose(number, frames = 4)
  762. case number
  763. when 0
  764. change(frames, 4, 0, 4, 0)
  765. when 1
  766. change(frames, 4, 0, 4)
  767. when 2
  768. change(frames, 4, 0, 6)
  769. else
  770. change(frames, 4, 0, 0, 0)
  771. end
  772. end
  773.  
  774. def enemy_pose(number ,enemy_frames = 4)
  775. case number
  776. when 0
  777. change(enemy_frames, 4, 0, 6, 0)
  778. when 1
  779. change(enemy_frames, 4, 0, 4)
  780. when 2
  781. change(enemy_frames, 4, 0, 6)
  782. else
  783. change(enemy_frames, 4, 0, 0, 0)
  784. end
  785. end
  786.  
  787. def default_pose
  788. pose(0, 1)
  789. end
  790. end
  791.  
  792. class Spriteset_Battle
  793. #--------------------------------------------------------------------------
  794. # ? ??????????
  795. #--------------------------------------------------------------------------
  796. attr_reader :viewport1 # ????????????
  797. attr_reader :viewport2 # ????????????
  798. attr_accessor :actor_sprites
  799. attr_accessor :enemy_sprites
  800. #--------------------------------------------------------------------------
  801. # ? ?????????
  802. #--------------------------------------------------------------------------
  803. def initialize
  804. # ?????????
  805. @viewport1 = Viewport.new(0, 0, 640, 480)
  806. @viewport2 = Viewport.new(0, 0, 640, 480)
  807. @viewport3 = Viewport.new(0, 0, 640, 480)
  808. @viewport4 = Viewport.new(0, 0, 640, 480)
  809. @viewport2.z = 101
  810. @viewport3.z = 200
  811. @viewport4.z = 5000
  812. if $game_temp.battleback_name == ""
  813. @battleback_sprite = nil
  814. @tilemap = Tilemap.new(@viewport1)
  815. @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  816. for i in 0..6
  817. autotile_name = $game_map.autotile_names[i]
  818. @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  819. end
  820. @tilemap.map_data = $game_map.data
  821. @tilemap.priorities = $game_map.priorities
  822. else
  823. # ??????????????
  824. @tilemap = nil
  825. @battleback_sprite = Sprite.new(@viewport1)
  826. end
  827. # ????????????
  828. @enemy_sprites = []
  829. for enemy in $game_troop.enemies#.reverse
  830. @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  831. end
  832. # ????????????
  833. @actor_sprites = []
  834. for j in 0..7
  835. # &#402;A&#402;N&#402;^&#65533;[&#402;X&#402;v&#402;&#8240;&#402;C&#402;g&#8218;đ&#8217;Ç&#8240;Á
  836. @actor_sprites.push(Sprite_Battler.new(@viewport1, $game_party.actors[j]))
  837. end
  838. # ?????
  839. @weather = RPG::Weather.new(@viewport1)
  840. # ????????????
  841. @picture_sprites = []
  842. for i in 51..100
  843. @picture_sprites.push(Sprite_Picture.new(@viewport3,
  844. $game_screen.pictures[i]))
  845. end
  846. # ????????????
  847. @timer_sprite = Sprite_Timer.new
  848. # ??????
  849. update
  850. end
  851. #--------------------------------------------------------------------------
  852. # ? ??
  853. #--------------------------------------------------------------------------
  854. def dispose
  855. if @tilemap != nil
  856. # ?????????
  857. @tilemap.tileset.dispose
  858. for i in 0..6
  859. @tilemap.autotiles[i].dispose
  860. end
  861. @tilemap.dispose
  862. end
  863. # ??????????????
  864. if @battleback_sprite != nil
  865. # ??????????????????????
  866. if @battleback_sprite.bitmap != nil
  867. @battleback_sprite.bitmap.dispose
  868. end
  869. @battleback_sprite.dispose
  870. end
  871. # ??????????????????????
  872. for sprite in @enemy_sprites + @actor_sprites
  873. sprite.dispose
  874. end
  875. # ?????
  876. @weather.dispose
  877. # ????????????
  878. for sprite in @picture_sprites
  879. sprite.dispose
  880. end
  881. # ????????????
  882. @timer_sprite.dispose
  883. # ?????????
  884. @viewport1.dispose
  885. @viewport2.dispose
  886. @viewport3.dispose
  887. @viewport4.dispose
  888. end
  889. #--------------------------------------------------------------------------
  890. # ? ??????????
  891. #--------------------------------------------------------------------------
  892. def effect?
  893. # ??????????????? true ???
  894. for sprite in @enemy_sprites + @actor_sprites
  895. return true if sprite.effect?
  896. end
  897. return false
  898. end
  899. #--------------------------------------------------------------------------
  900. # ? ??????
  901. #--------------------------------------------------------------------------
  902. def update
  903. # ???????????????????????
  904. if @battleback_sprite != nil
  905. if @battleback_name != $game_temp.battleback_name
  906. @battleback_name = $game_temp.battleback_name
  907. if @battleback_sprite.bitmap != nil
  908. @battleback_sprite.bitmap.dispose
  909. end
  910. bg_bitmap = RPG::Cache.battleback(@battleback_name)
  911. bg_bitmap_stretch = Bitmap.new(640, 480)
  912. bg_bitmap_stretch.stretch_blt(Rect.new(0, 0, 640, 480), bg_bitmap, bg_bitmap.rect)
  913. @battleback_sprite.bitmap = bg_bitmap_stretch
  914. end
  915. end
  916. if @tilemap != nil
  917. @tilemap.ox = $game_map.display_x / 4
  918. @tilemap.oy = $game_map.display_y / 4
  919. @tilemap.update
  920. end
  921. # ????????????
  922. for sprite in @enemy_sprites + @actor_sprites
  923. sprite.update
  924. end
  925. # ???????????
  926. @weather.type = $game_screen.weather_type
  927. @weather.max = $game_screen.weather_max
  928. @weather.update
  929. # ????????????
  930. for sprite in @picture_sprites
  931. sprite.update
  932. end
  933. # ????????????
  934. @timer_sprite.update
  935. # ???????????????
  936. @viewport1.tone = $game_screen.tone
  937. @viewport1.ox = $game_screen.shake
  938. # ????????????
  939. @viewport4.color = $game_screen.flash_color
  940. # ?????????
  941. @viewport1.update
  942. @viewport2.update
  943. @viewport4.update
  944. end
  945. end
  946.  
  947. #==============================================================================
  948. # &#166; Window_Command
  949. #------------------------------------------------------------------------------
  950. # ?????????????????????
  951. #==============================================================================
  952.  
  953. class Window_Command < Window_Selectable
  954. #--------------------------------------------------------------------------
  955. # ? ?????????
  956. # width : ???????
  957. # commands : ??????????
  958. #--------------------------------------------------------------------------
  959. def initialize(width, commands, column_max = 1, style = 0, inf_scroll = 1)
  960. # ????????????????????
  961. super(0, 0, width, (commands.size * 1.0 / column_max).ceil * 32 + 32)
  962. @inf_scroll = inf_scroll
  963. @item_max = commands.size
  964. @commands = commands
  965. @column_max = column_max
  966. @style = style
  967. self.contents = Bitmap.new(width - 32, (@item_max * 1.0 / @column_max).ceil * 32)
  968. self.contents.font.name = "Tahoma"
  969. self.contents.font.size = 22
  970. refresh
  971. self.index = 0
  972. end
  973. #--------------------------------------------------------------------------
  974. # ? ??????
  975. #--------------------------------------------------------------------------
  976. def refresh
  977. self.contents.clear
  978. for i in 0...@item_max
  979. draw_item(i, normal_color)
  980. end
  981. end
  982. #--------------------------------------------------------------------------
  983. # ? ?????
  984. # index : ????
  985. # color : ???
  986. #--------------------------------------------------------------------------
  987. def draw_item(index, color)
  988. self.contents.font.color = color
  989. rect = Rect.new(index%@column_max * (self.width / @column_max) + 4, 32 * (index/@column_max), self.width / @column_max - 40, 32)
  990. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  991. self.contents.draw_text(rect, @commands[index], @style)
  992. end
  993. #--------------------------------------------------------------------------
  994. # ? ??????
  995. # index : ????
  996. #--------------------------------------------------------------------------
  997. def disable_item(index)
  998. draw_item(index, disabled_color)
  999. end
  1000.  
  1001. def update_help
  1002. @help_window.set_actor($game_party.actors[$scene.actor_index])
  1003. end
  1004. end
  1005.  
  1006. #==============================================================================
  1007. # &#166; Arrow_Enemy
  1008. #------------------------------------------------------------------------------
  1009. # ????????????????????????????? Arrow_Base ??
  1010. # ????????
  1011. #==============================================================================
  1012.  
  1013. class Arrow_Enemy < Arrow_Base
  1014. #--------------------------------------------------------------------------
  1015. # ? ?????????????????
  1016. #--------------------------------------------------------------------------
  1017. def enemy
  1018. return $game_troop.enemies[@index]
  1019. end
  1020. #--------------------------------------------------------------------------
  1021. # ? ??????
  1022. #--------------------------------------------------------------------------
  1023. def update
  1024. super
  1025. # ???????????????????
  1026. $game_troop.enemies.size.times do
  1027. break if self.enemy.exist?
  1028. @index += 1
  1029. @index %= $game_troop.enemies.size
  1030. end
  1031. # ?????
  1032. if Input.repeat?(Input::DOWN)
  1033. $game_system.se_play($data_system.cursor_se)
  1034. $game_troop.enemies.size.times do
  1035. @index += 1
  1036. @index %= $game_troop.enemies.size
  1037. break if self.enemy.exist?
  1038. end
  1039. end
  1040. # ?????
  1041. if Input.repeat?(Input::UP)
  1042. $game_system.se_play($data_system.cursor_se)
  1043. $game_troop.enemies.size.times do
  1044. @index += $game_troop.enemies.size - 1
  1045. @index %= $game_troop.enemies.size
  1046. break if self.enemy.exist?
  1047. end
  1048. end
  1049. if Input.repeat?(Input::RIGHT)
  1050. $game_system.se_play($data_system.cursor_se)
  1051. $game_troop.enemies.size.times do
  1052. @index += ((($game_troop.enemies.length) * 0.5).ceil)
  1053. @index %= $game_troop.enemies.size
  1054. break if self.enemy.exist?
  1055. end
  1056. end
  1057. if Input.repeat?(Input::LEFT)
  1058. $game_system.se_play($data_system.cursor_se)
  1059. $game_troop.enemies.size.times do
  1060. @index += $game_troop.enemies.size - ((($game_troop.enemies.length) * 0.5).ceil)
  1061. @index %= $game_troop.enemies.size
  1062. break if self.enemy.exist?
  1063. end
  1064. end
  1065. # ???????????
  1066. if self.enemy != nil
  1067. self.x = self.enemy.screen_x + 4
  1068. self.y = self.enemy.screen_y + 36
  1069. self.z = self.enemy.screen_z + 1
  1070. end
  1071. end
  1072. #--------------------------------------------------------------------------
  1073. # ? ?????????
  1074. #--------------------------------------------------------------------------
  1075. def update_help
  1076. # ????????????????????????
  1077. @help_window.set_enemy(self.enemy)
  1078. end
  1079. end
  1080.  
  1081. #==============================================================================
  1082. # &#166; Arrow_Actor
  1083. #------------------------------------------------------------------------------
  1084. # ????????????????????????????? Arrow_Base ??
  1085. # ????????
  1086. #==============================================================================
  1087.  
  1088. class Arrow_Actor < Arrow_Base
  1089. #--------------------------------------------------------------------------
  1090. # ? ?????????????????
  1091. #--------------------------------------------------------------------------
  1092. def actor
  1093. return $game_party.actors[@index]
  1094. end
  1095. #--------------------------------------------------------------------------
  1096. # ? ??????
  1097. #--------------------------------------------------------------------------
  1098. def update
  1099. super
  1100. # ?????
  1101. if Input.repeat?(Input::DOWN)
  1102. $game_system.se_play($data_system.cursor_se)
  1103. @index += 1
  1104. @index %= $game_party.actors.size
  1105. end
  1106. # ?????
  1107. if Input.repeat?(Input::UP)
  1108. $game_system.se_play($data_system.cursor_se)
  1109. @index += $game_party.actors.size - 1
  1110. @index %= $game_party.actors.size
  1111. end
  1112. if Input.repeat?(Input::RIGHT)
  1113. $game_system.se_play($data_system.cursor_se)
  1114. @index += ($game_party.actors.length * 0.5).ceil
  1115. @index %= $game_party.actors.size
  1116. end
  1117. # ?????
  1118. if Input.repeat?(Input::LEFT)
  1119. $game_system.se_play($data_system.cursor_se)
  1120. @index += $game_party.actors.size - (($game_party.actors.length * 0.5).ceil)
  1121. @index %= $game_party.actors.size
  1122. end
  1123. # ???????????
  1124. if self.actor != nil
  1125. self.x = self.actor.screen_x
  1126. self.y = self.actor.screen_y + 36
  1127. self.z = self.actor.screen_z + 1
  1128. end
  1129. end
  1130. #--------------------------------------------------------------------------
  1131. # ? ?????????
  1132. #--------------------------------------------------------------------------
  1133. def update_help
  1134. # ??????????????????????
  1135. @help_window.set_actor(self.actor)
  1136. end
  1137. end
  1138.  
  1139. class Scene_Battle
  1140. attr_accessor :actor_index
  1141. def main
  1142. # ???????????????
  1143. $game_temp.in_battle = true
  1144. $game_temp.battle_turn = 0
  1145. $game_temp.battle_event_flags.clear
  1146. $game_temp.battle_abort = false
  1147. $game_temp.battle_main_phase = false
  1148. $game_temp.battleback_name = $game_map.battleback_name
  1149. $game_temp.forcing_battler = nil
  1150. # ??????????????????
  1151. $game_system.battle_interpreter.setup(nil, 0)
  1152. # ???????
  1153. @troop_id = $game_temp.battle_troop_id
  1154. $game_troop.setup(@troop_id)
  1155. # ????????????????
  1156. s1 = $data_system.words.attack
  1157. s1 = $data_system.words.attack
  1158. s2 = $data_system.words.skill
  1159. s3 = $data_system.words.guard
  1160. s4 = $data_system.words.item
  1161. @actor_command_window = Window_Command.new(640, [s1, s2, s3, s4], 4)
  1162. @actor_command_window.y = 64
  1163. @actor_command_window.back_opacity = 160
  1164. @actor_command_window.active = false
  1165. @actor_command_window.visible = false
  1166. # ????????????
  1167. @party_command_window = Window_PartyCommand.new
  1168. @help_window = Window_Help.new
  1169. @help_window.back_opacity = 160
  1170. @help_window.visible = false
  1171. #@status_window = Window_BattleStatus.new
  1172. @message_window = Window_Message.new
  1173. # ???????????
  1174. @spriteset = Spriteset_Battle.new
  1175. # ????????????
  1176. @wait_count = 0
  1177. # ?????????
  1178. if $data_system.battle_transition == ""
  1179. Graphics.transition(20)
  1180. else
  1181. Graphics.transition(40, "Graphics/Transitions/" +
  1182. $data_system.battle_transition)
  1183. end
  1184. # ???????????
  1185. start_phase1
  1186. # ??????
  1187. loop do
  1188. # ????????
  1189. Graphics.update
  1190. # ???????
  1191. Input.update
  1192. # ??????
  1193. update
  1194. # ????????????????
  1195. if $scene != self
  1196. break
  1197. end
  1198. end
  1199. # ??????????
  1200. $game_map.refresh
  1201. # ?????????
  1202. Graphics.freeze
  1203. # ????????
  1204. @actor_command_window.dispose
  1205. @party_command_window.dispose
  1206. @help_window.dispose
  1207. #@status_window.dispose
  1208. @message_window.dispose
  1209. if @skill_window != nil
  1210. @skill_window.dispose
  1211. end
  1212. if @item_window != nil
  1213. @item_window.dispose
  1214. end
  1215. if @result_window != nil
  1216. @result_window.dispose
  1217. end
  1218. # ???????????
  1219. @spriteset.dispose
  1220. # ???????????????
  1221. if $scene.is_a?(Scene_Title)
  1222. # ??????????
  1223. Graphics.transition
  1224. Graphics.freeze
  1225. end
  1226. # ???????????????????????????
  1227. if $BTEST and not $scene.is_a?(Scene_Gameover)
  1228. $scene = nil
  1229. end
  1230. end
  1231.  
  1232. def update
  1233. # ?????????????
  1234. if $game_system.battle_interpreter.running?
  1235. # ?????????
  1236. $game_system.battle_interpreter.update
  1237. # ?????????????????????????
  1238. if $game_temp.forcing_battler == nil
  1239. # ?????????????????
  1240. unless $game_system.battle_interpreter.running?
  1241. # ??????????????????????????
  1242. unless judge
  1243. setup_battle_event
  1244. end
  1245. end
  1246. # ????????????????
  1247. if @phase != 5
  1248. # ?????????????????
  1249. #@status_window.refresh
  1250. end
  1251. end
  1252. end
  1253. # ???? (????)??????
  1254. $game_system.update
  1255. $game_screen.update
  1256. # ????? 0 ??????
  1257. if $game_system.timer_working and $game_system.timer == 0
  1258. # ?????
  1259. $game_temp.battle_abort = true
  1260. end
  1261. # ????????
  1262. @help_window.update
  1263. @party_command_window.update
  1264. @actor_command_window.update
  1265. #@status_window.update
  1266. @message_window.update
  1267. # ???????????
  1268. @spriteset.update
  1269. # ?????????????
  1270. if $game_temp.transition_processing
  1271. # ?????????????????
  1272. $game_temp.transition_processing = false
  1273. # ?????????
  1274. if $game_temp.transition_name == ""
  1275. Graphics.transition(20)
  1276. else
  1277. Graphics.transition(40, "Graphics/Transitions/" +
  1278. $game_temp.transition_name)
  1279. end
  1280. end
  1281. # ????????????????
  1282. if $game_temp.message_window_showing
  1283. return
  1284. end
  1285. # ???????????
  1286. if @spriteset.effect?
  1287. return
  1288. end
  1289. # ??????????
  1290. if $game_temp.gameover
  1291. # ??????????????
  1292. $scene = Scene_Gameover.new
  1293. return
  1294. end
  1295. # ???????????
  1296. if $game_temp.to_title
  1297. # ???????????
  1298. $scene = Scene_Title.new
  1299. return
  1300. end
  1301. # ????????
  1302. if $game_temp.battle_abort
  1303. # ??????? BGM ???
  1304. $game_system.bgm_play($game_temp.map_bgm)
  1305. # ?????
  1306. battle_end(1)
  1307. return
  1308. end
  1309. # ????????
  1310. if @wait_count > 0
  1311. # ????????????
  1312. @wait_count -= 1
  1313. return
  1314. end
  1315.  
  1316. # this one holds the battle while the player moves
  1317. for actor in @spriteset.actor_sprites
  1318. if actor.moving
  1319. return
  1320. end
  1321. end
  1322. # and this one is for the enemy...
  1323. for enemy in @spriteset.enemy_sprites
  1324. if enemy.moving# and $game_system.animated_enemy
  1325. return
  1326. end
  1327. end
  1328. # ???????????????????????
  1329. # ????????????????
  1330. if $game_temp.forcing_battler == nil and
  1331. $game_system.battle_interpreter.running?
  1332. return
  1333. end
  1334. # ??????????
  1335. case @phase
  1336. when 1 # ?????????
  1337. update_phase1
  1338. when 2 # ????????????
  1339. update_phase2
  1340. when 3 # ????????????
  1341. update_phase3
  1342. when 4 # ???????
  1343. update_phase4
  1344. when 5 # ???????????
  1345. update_phase5
  1346. end
  1347. end
  1348.  
  1349. def start_phase2
  1350. # ???? 2 ???
  1351. @phase = 2
  1352. # ?????????????
  1353. @actor_index = -1
  1354. @active_battler = nil
  1355. # ?????????????????
  1356. @party_command_window.active = true
  1357. @party_command_window.visible = true
  1358. # ?????????????????
  1359. @actor_command_window.active = false
  1360. @actor_command_window.visible = false
  1361. @help_window.visible = false
  1362. # ??????????????
  1363. $game_temp.battle_main_phase = false
  1364. # ????????????????
  1365. $game_party.clear_actions
  1366. # ????????????
  1367. unless $game_party.inputable?
  1368. # ?????????
  1369. start_phase4
  1370. end
  1371. end
  1372.  
  1373. def update_phase2_escape
  1374. # ??????????????
  1375. enemies_agi = 0
  1376. enemies_number = 0
  1377. for enemy in $game_troop.enemies
  1378. if enemy.exist?
  1379. enemies_agi += enemy.agi
  1380. enemies_number += 1
  1381. end
  1382. end
  1383. if enemies_number > 0
  1384. enemies_agi /= enemies_number
  1385. end
  1386. # ??????????????
  1387. actors_agi = 0
  1388. actors_number = 0
  1389. for actor in $game_party.actors
  1390. if actor.exist?
  1391. actors_agi += actor.agi
  1392. actors_number += 1
  1393. end
  1394. end
  1395. if actors_number > 0
  1396. actors_agi /= actors_number
  1397. end
  1398. # ??????
  1399. success = rand(100) < 50 * actors_agi / enemies_agi
  1400. # ???????
  1401. if success
  1402. # ?? SE ???
  1403. $game_system.se_play($data_system.escape_se)
  1404. for actor in $game_party.actors
  1405. @spriteset.actor_sprites[actor.index].pose(2)
  1406. @spriteset.actor_sprites[actor.index].move(660, actor.screen_y, 10)
  1407. end
  1408. check = escape_move
  1409. until check == false
  1410. @spriteset.update
  1411. Graphics.update
  1412. check = escape_move
  1413. end
  1414. # ??????? BGM ???
  1415. $game_system.bgm_play($game_temp.map_bgm)
  1416. # ?????
  1417. battle_end(1)
  1418. # ???????
  1419. else
  1420. # ????????????????
  1421. $game_party.clear_actions
  1422. # ?????????
  1423. start_phase4
  1424. end
  1425. end
  1426.  
  1427. def escape_move
  1428. for actor in @spriteset.actor_sprites
  1429. if actor.moving
  1430. return true
  1431. end
  1432. end
  1433. return false
  1434. end
  1435.  
  1436. def start_phase5
  1437. # ???? 5 ???
  1438. @phase = 5
  1439. # ????? ME ???
  1440. $game_system.me_play($game_system.battle_end_me)
  1441. # ??????? BGM ???
  1442. $game_system.bgm_play($game_temp.map_bgm)
  1443. # EXP???????????????
  1444. exp = 0
  1445. gold = 0
  1446. treasures = []
  1447. # ???
  1448. for enemy in $game_troop.enemies
  1449. # ??????????????
  1450. unless enemy.hidden
  1451. # ?? EXP????????
  1452. exp += enemy.exp
  1453. gold += enemy.gold
  1454. # ?????????
  1455. if rand(100) < enemy.treasure_prob
  1456. if enemy.item_id > 0
  1457. treasures.push($data_items[enemy.item_id])
  1458. end
  1459. if enemy.weapon_id > 0
  1460. treasures.push($data_weapons[enemy.weapon_id])
  1461. end
  1462. if enemy.armor_id > 0
  1463. treasures.push($data_armors[enemy.armor_id])
  1464. end
  1465. end
  1466. end
  1467. end
  1468. # ???????? 6 ??????
  1469. treasures = treasures[0..5]
  1470. # EXP ??
  1471. for i in 0...$game_party.actors.size
  1472. actor = $game_party.actors[i]
  1473. if actor.cant_get_exp? == false
  1474. last_level = actor.level
  1475. actor.exp += exp
  1476. if actor.level > last_level
  1477. #@status_window.level_up(i)
  1478. end
  1479. end
  1480. end
  1481. # ??????
  1482. $game_party.gain_gold(gold)
  1483. # ???????
  1484. for item in treasures
  1485. case item
  1486. when RPG::Item
  1487. $game_party.gain_item(item.id, 1)
  1488. when RPG::Weapon
  1489. $game_party.gain_weapon(item.id, 1)
  1490. when RPG::Armor
  1491. $game_party.gain_armor(item.id, 1)
  1492. end
  1493. end
  1494. # ???????????????
  1495. @result_window = Window_BattleResult.new(exp, gold, treasures)
  1496. # ???????????
  1497. @phase5_wait_count = 100
  1498. end
  1499.  
  1500. #--------------------------------------------------------------------------
  1501. # ? ?????? (???????????)
  1502. #--------------------------------------------------------------------------
  1503. def update_phase5
  1504. # ????????? 0 ???????
  1505. if @phase5_wait_count > 0
  1506. # ????????????
  1507. @phase5_wait_count -= 1
  1508. # ????????? 0 ??????
  1509. if @phase5_wait_count == 0
  1510. # ????????????
  1511. @result_window.visible = true
  1512. # ??????????????
  1513. $game_temp.battle_main_phase = false
  1514. # ?????????????????
  1515. #@status_window.refresh
  1516. end
  1517. return
  1518. end
  1519. # C ??????????
  1520. if Input.trigger?(Input::C)
  1521. # ?????
  1522. battle_end(0)
  1523. end
  1524. end
  1525.  
  1526. def phase3_setup_command_window
  1527. # ?????????????????
  1528. @party_command_window.active = false
  1529. @party_command_window.visible = false
  1530. # ?????????????????
  1531. @actor_command_window.active = true
  1532. @actor_command_window.visible = true
  1533. @help_window.visible = true
  1534. # ???????????????????
  1535. if @actor_command_window.help_window == nil
  1536. @actor_command_window.help_window = @help_window
  1537. end
  1538. @actor_command_window.update_help
  1539. #@actor_command_window.x = @actor_index * 160
  1540. # ??????? 0 ???
  1541. @actor_command_window.index = 0
  1542. end
  1543. def start_enemy_select
  1544. # ??????????
  1545. @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
  1546. # ?????????????
  1547. @enemy_arrow.help_window = @help_window
  1548. # ?????????????????
  1549. @actor_command_window.active = false
  1550. @actor_command_window.visible = false
  1551. end
  1552.  
  1553. def update_phase4
  1554. case @phase4_step
  1555. when 1
  1556. update_phase4_step1
  1557. when 2
  1558. update_phase4_step2
  1559. when 3
  1560. update_phase4_step3
  1561. when 4
  1562. update_phase4_step4
  1563. when 5
  1564. update_phase4_step5
  1565. when 6
  1566. update_phase4_step6
  1567. when 7
  1568. update_phase4_step7
  1569. end
  1570. end
  1571.  
  1572. def update_phase4_step1
  1573.  
  1574. # Change actor poses to default
  1575. #if @active_battler.is_a?(Game_Actor)
  1576. # @spriteset.actor_sprites[@active_battler.index].default_pose
  1577. #end
  1578. for i in 0...$game_party.actors.size
  1579. actor = $game_party.actors[i]
  1580. @spriteset.actor_sprites[i].default_pose
  1581. end
  1582.  
  1583. @help_window.visible = false
  1584. if judge
  1585. return
  1586. end
  1587. if $game_temp.forcing_battler == nil
  1588. setup_battle_event
  1589. if $game_system.battle_interpreter.running?
  1590. return
  1591. end
  1592. end
  1593. if $game_temp.forcing_battler != nil
  1594. @action_battlers.delete($game_temp.forcing_battler)
  1595. @action_battlers.unshift($game_temp.forcing_battler)
  1596. end
  1597. if @action_battlers.size == 0
  1598. start_phase2
  1599. return
  1600. end
  1601. @animation1_id = 0
  1602. @animation2_id = 0
  1603. @common_event_id = 0
  1604. @active_battler = @action_battlers.shift
  1605. if @active_battler.index == nil
  1606. return
  1607. end
  1608. if @active_battler.hp > 0 and @active_battler.slip_damage?
  1609. @active_battler.slip_damage_effect
  1610. @active_battler.damage_pop = true
  1611. end
  1612. @active_battler.remove_states_auto
  1613. #@status_window.refresh
  1614. @phase4_step = 2
  1615. end
  1616.  
  1617. def make_basic_action_result
  1618.  
  1619. if @active_battler.is_a?(Game_Actor)
  1620. $actor_on_top = true
  1621. elsif @active_battler.is_a?(Game_Enemy)
  1622. $actor_on_top = false
  1623. end
  1624. if @active_battler.current_action.basic == 0
  1625. @animation1_id = @active_battler.animation1_id
  1626. @animation2_id = @active_battler.animation2_id
  1627. if @active_battler.is_a?(Game_Enemy)
  1628. if @active_battler.restriction == 3
  1629. target = $game_troop.random_target_enemy
  1630. elsif @active_battler.restriction == 2
  1631. target = $game_party.random_target_actor
  1632. else
  1633. index = @active_battler.current_action.target_index
  1634. target = $game_party.smooth_target_actor(index)
  1635. end
  1636. #======== here is the setting for the movement & animation...
  1637. x = target.screen_x - 32
  1638. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(2)
  1639. @spriteset.enemy_sprites[@active_battler.index].move(x, target.screen_y, 10)
  1640. #========= here if you look at the RPG's movement settings you'll see
  1641. #========= that he takes the number 40 for the speed of the animation...
  1642. #========= i thing thats too fast so i settet it down to 10 so looks smoother...
  1643. end
  1644. if @active_battler.is_a?(Game_Actor)
  1645. weapon = $data_weapons[@active_battler.weapon_id]
  1646. range = false
  1647. if weapon != nil
  1648. for id in weapon.element_set
  1649. if $data_system.elements[23] == "Range"
  1650. range = true
  1651. break
  1652. end
  1653. end
  1654. end
  1655. if @active_battler.restriction == 3
  1656. target = $game_party.random_target_actor
  1657. elsif @active_battler.restriction == 2
  1658. target = $game_troop.random_target_enemy
  1659. else
  1660. index = @active_battler.current_action.target_index
  1661. target = $game_troop.smooth_target_enemy(index)
  1662. end
  1663. #======= the same thing for the player... ^-^
  1664. x = target.screen_x + 32
  1665. @spriteset.actor_sprites[@active_battler.index].pose(1)
  1666. @spriteset.actor_sprites[@active_battler.index].move(x * (range ? 2 : 1), target.screen_y, 10)
  1667. range = false
  1668. end
  1669. @target_battlers = [target]
  1670. for target in @target_battlers
  1671. target.attack_effect(@active_battler)
  1672. end
  1673. return
  1674. end
  1675. if @active_battler.current_action.basic == 1
  1676. if @active_battler.is_a?(Game_Actor)
  1677. @spriteset.actor_sprites[@active_battler.index].pose(0, 1) #defence
  1678. else
  1679. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1) #defence
  1680. end
  1681. @help_window.set_text($data_system.words.guard, 1)
  1682. return
  1683. end
  1684. if @active_battler.is_a?(Game_Enemy) and
  1685. @active_battler.current_action.basic == 2
  1686. @help_window.set_text("Escape", 1)
  1687. @active_battler.escape
  1688. return
  1689. end
  1690. if @active_battler.current_action.basic == 3
  1691. $game_temp.forcing_battler = nil
  1692. @phase4_step = 1
  1693. return
  1694. end
  1695.  
  1696. if @active_battler.current_action.basic == 4
  1697. if $game_temp.battle_can_escape == false
  1698. $game_system.se_play($data_system.buzzer_se)
  1699. return
  1700. end
  1701. $game_system.se_play($data_system.decision_se)
  1702. update_phase2_escape
  1703. return
  1704. end
  1705. end
  1706.  
  1707. def make_skill_action_result
  1708.  
  1709. @skill = $data_skills[@active_battler.current_action.skill_id]
  1710. unless @active_battler.current_action.forcing
  1711. unless @active_battler.skill_can_use?(@skill.id)
  1712. $game_temp.forcing_battler = nil
  1713. @phase4_step = 1
  1714. return
  1715. end
  1716. end
  1717. @active_battler.sp -= @skill.sp_cost
  1718. #@status_window.refresh
  1719. @help_window.set_text(@skill.name, 1)
  1720. @animation1_id = @skill.animation1_id
  1721. @animation2_id = @skill.animation2_id
  1722. if @active_battler.is_a?(Game_Enemy)
  1723. #@spriteset.enemy_sprites[@active_battler.index].change_sp_bar
  1724. x = @active_battler.screen_x + 48
  1725. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(2)
  1726. @spriteset.enemy_sprites[@active_battler.index].move(x, @active_battler.screen_y, 5)
  1727. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1728. end
  1729. if @active_battler.is_a?(Game_Actor)
  1730. #@spriteset.actor_sprites[@active_battler.index].change_sp_bar
  1731. x = @active_battler.screen_x - 48
  1732. @spriteset.actor_sprites[@active_battler.index].pose(1)
  1733. @spriteset.actor_sprites[@active_battler.index].move(x, @active_battler.screen_y, 5)
  1734. @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1735. end
  1736. @common_event_id = @skill.common_event_id
  1737. set_target_battlers(@skill.scope)
  1738. for target in @target_battlers
  1739. target.skill_effect(@active_battler, @skill)
  1740. end
  1741. end
  1742.  
  1743. def make_item_action_result
  1744.  
  1745. # sorry i didnt work on this...
  1746. # couse i dont have a sprite that uses items....
  1747. # so i just added the standby sprite here...
  1748. # when i get more time for this i'll try what i can do for this one... ^-^
  1749. # its the same as the ones above...
  1750. if @active_battler.is_a?(Game_Actor)
  1751. @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1752. else
  1753. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1754. end
  1755.  
  1756. @item = $data_items[@active_battler.current_action.item_id]
  1757. unless $game_party.item_can_use?(@item.id)
  1758. @phase4_step = 1
  1759. return
  1760. end
  1761. if @item.consumable
  1762. $game_party.lose_item(@item.id, 1)
  1763. end
  1764. @help_window.set_text(@item.name, 1)
  1765. @animation1_id = @item.animation1_id
  1766. @animation2_id = @item.animation2_id
  1767. @common_event_id = @item.common_event_id
  1768. index = @active_battler.current_action.target_index
  1769. target = $game_party.smooth_target_actor(index)
  1770. set_target_battlers(@item.scope)
  1771. for target in @target_battlers
  1772. target.item_effect(@item)
  1773. end
  1774. end
  1775.  
  1776. def update_phase4_step3
  1777. if @active_battler.current_action.kind == 0 and
  1778. @active_battler.current_action.basic == 0
  1779. # in this one... we have our weapon animations... for player and monster
  1780. if @active_battler.is_a?(Game_Actor)
  1781. @spriteset.actor_sprites[@active_battler.index].pose(0,1)
  1782. elsif @active_battler.is_a?(Game_Enemy)
  1783. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0,1)
  1784. end
  1785. end
  1786. if @animation1_id == 1
  1787. @active_battler.white_flash = true
  1788. else
  1789. @active_battler.animation_id = @animation1_id
  1790. @active_battler.animation_hit = true
  1791. end
  1792. @phase4_step = 4
  1793. end
  1794.  
  1795. def update_phase4_step4
  1796. # this here is for the hit animation...
  1797. for target in @target_battlers
  1798. target.animation_id = @animation2_id
  1799. target.animation_hit = (target.damage != "Miss")
  1800. end
  1801. @wait_count = 8
  1802. @phase4_step = 5
  1803. end
  1804.  
  1805. def update_phase4_step5
  1806. if @active_battler.hp > 0 and @active_battler.slip_damage?
  1807. @active_battler.slip_damage_effect
  1808. @active_battler.damage_pop = true
  1809. end
  1810. # ???????????
  1811. @help_window.visible = false
  1812. # ?????????????????
  1813. #@status_window.refresh
  1814. # ??????
  1815.  
  1816. if @active_battler.is_a?(Game_Actor)
  1817. @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1818. else
  1819. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1820. end
  1821. for target in @target_battlers
  1822. if target.damage != nil
  1823. target.damage_pop = true
  1824. if @active_battler.is_a?(Game_Actor)
  1825. @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1826. else
  1827. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1828. end
  1829. end
  1830. end
  1831. # ???? 6 ???
  1832. @phase4_step = 6
  1833. end
  1834.  
  1835. def update_phase4_step6
  1836.  
  1837. # here we are asking if the player is dead and is a player or an enemy...
  1838. # these lines are for the running back and standby animation....
  1839. if @active_battler.is_a?(Game_Actor)
  1840. if @active_battler.current_action.basic == 1
  1841. @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1842. else
  1843. @spriteset.actor_sprites[@active_battler.index].move(@active_battler.screen_x, @active_battler.screen_y, 20)
  1844. @spriteset.actor_sprites[@active_battler.index].pose(2)
  1845. end
  1846. else
  1847. if @active_battler.current_action.basic == 1
  1848. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1849. else
  1850. @spriteset.enemy_sprites[@active_battler.index].move(@active_battler.screen_x, @active_battler.screen_y, 20)
  1851. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(1)
  1852. end
  1853. end
  1854. for target in @target_battlers
  1855. if target.is_a?(Game_Actor)
  1856. @spriteset.actor_sprites[target.index].pose(0, 1)
  1857. else
  1858. @spriteset.enemy_sprites[target.index].enemy_pose(0, 1)
  1859. end
  1860. end
  1861. $game_temp.forcing_battler = nil
  1862. if @common_event_id > 0
  1863. common_event = $data_common_events[@common_event_id]
  1864. $game_system.battle_interpreter.setup(common_event.list, 0)
  1865. end
  1866. @phase4_step = 7
  1867. end
  1868.  
  1869. def update_phase4_step7
  1870.  
  1871. # here we are asking if the player is dead and is a player or an enemy...
  1872. # these lines are for the running back and standby animation....
  1873. if @active_battler.is_a?(Game_Actor)
  1874. @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1875. else
  1876. @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1877. end
  1878.  
  1879. $game_temp.forcing_battler = nil
  1880. if @common_event_id > 0
  1881. common_event = $data_common_events[@common_event_id]
  1882. $game_system.battle_interpreter.setup(common_event.list, 0)
  1883. end
  1884. @phase4_step = 1
  1885. end
  1886. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement