Advertisement
Guest User

Untitled

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