Guest User

[RMXP RGSS] 8-Actor Party by cockroach

a guest
Jul 24th, 2016
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ** 8_Hero_Party - by cockroach
  3. #------------------------------------------------------------------------------
  4. #  This script is meant to permit 8 heroes in the party.
  5. #  The heroes will appear in every instance of the game and show up properly,
  6. #  but in many cases it may look crowded. (Specially in the default Battle System)
  7. #  This is why this goes best with another type of battle system.
  8. #  If anyone wants to use even more than 8 heroes, all necessary changes are in
  9. #  this script, and it is a very easy thing to alter.
  10. #
  11. #  All you need to do is adding heroes to the party normally, no custom script
  12. #  call is necessary.
  13. #
  14. #  (This very simple script is free for usage and edition, in any type of game.)
  15. #==============================================================================
  16. #==============================================================================
  17. # Alterations in Game_Actor
  18. #==============================================================================
  19. class Game_Actor
  20.     def screen_x
  21.         p_size = $game_party.actors.size
  22.         if p_size < 4
  23.           p_size = 4
  24.     end
  25.     # Return after calculating x-coordinate by order of members in party
  26.     if self.index != nil
  27.         return self.index * (640/p_size) + (320/p_size)
  28.     else
  29.         return 0
  30.     end  
  31.     end
  32. end
  33. #==============================================================================
  34. # Alterations in Game_Party
  35. #==============================================================================
  36. class Game_Party  
  37. #--------------------------------------------------------------------------  
  38. # * Add an Actor  
  39. # actor_id : actor ID  
  40. #--------------------------------------------------------------------------
  41. def add_actor(actor_id)
  42.     # Get actor
  43.     actor = $game_actors[actor_id]
  44.  
  45.     # If the party has less than 8 members and this actor is not in the party
  46.     if @actors.size < 8 and not @actors.include?(actor)
  47.      
  48.     # Add actor
  49.       @actors.push(actor)
  50.      
  51.     # Refresh player
  52.       $game_player.refresh
  53. end
  54. end
  55.  
  56. #--------------------------------------------------------------------------  
  57. # * Random Selection of Target Actor  
  58. # hp0 : limited to actors with 0 HP  
  59. #--------------------------------------------------------------------------
  60. def random_target_actor(hp0 = false)
  61. # Initialize roulette
  62. roulette = []
  63. # Loop
  64. for actor in @actors
  65. # If it fits the conditions
  66.   if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
  67. # Get actor class [position]
  68. position = ($data_classes[actor.class_id].position)/2
  69. # Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2
  70. n = 4 - position
  71. if n == 0
  72.   n = 1
  73. end
  74. # Add actor to roulette n times
  75. n.times do
  76.   roulette.push(actor)
  77. end
  78.   end
  79. end
  80.  
  81. # If roulette size is 0
  82. if roulette.size == 0
  83.   return nil
  84. end
  85.  
  86. # Spin the roulette, choose an actor
  87. return roulette[rand(roulette.size)]  end end #endend
  88. #==============================================================================
  89. # Alterations in Window_MenuStatus
  90. #==============================================================================
  91. class Window_MenuStatus < Window_Selectable  
  92. #--------------------------------------------------------------------------  
  93. # * Refresh  
  94. #--------------------------------------------------------------------------
  95. def refresh
  96. self.contents.clear
  97. @item_max = $game_party.actors.size
  98. for i in 0...$game_party.actors.size
  99.   x = 64
  100.   if @item_max > 5
  101. y = i * (455 / @item_max)
  102.   else
  103.  
  104. y = i * 76.5
  105.   end
  106.   actor = $game_party.actors[i]
  107.   draw_actor_graphic(actor, x - 40, y + 47)
  108.   draw_actor_name(actor, x, y - 9)
  109.   draw_actor_class(actor, x + 144, y - 9)
  110.   draw_actor_level(actor, x, y + 7)
  111.   draw_actor_state(actor, x + 90, y + 7)
  112.   draw_actor_exp(actor, x, y + 23)
  113.   draw_actor_hp(actor, x + 236, y + 7)
  114.   draw_actor_sp(actor, x + 236, y + 23)
  115. end  end  
  116. #--------------------------------------------------------------------------  
  117. # * Cursor Rectangle Update  
  118. #--------------------------------------------------------------------------
  119. def update_cursor_rect
  120. if @index < 0
  121.   self.cursor_rect.empty
  122. else
  123.   if @item_max > 5
  124.  
  125. y = @index * (455 / @item_max) - 3
  126.   else
  127.  
  128. y = @index * 76.5 - 3
  129.   end
  130.   self.cursor_rect.set(0, y, self.width - 32, 52)
  131. end  end end #endend
  132. #==============================================================================
  133. # Alterations in Window_Target
  134. #==============================================================================
  135. class Window_Target < Window_Selectable  
  136. #--------------------------------------------------------------------------  
  137. # * Refresh  
  138. #--------------------------------------------------------------------------  
  139. def refresh
  140. self.contents.clear
  141. for i in 0...$game_party.actors.size
  142.   x = 4
  143.   y = i * 55
  144.   actor = $game_party.actors[i]
  145.   draw_actor_name(actor, x, y)
  146.   draw_actor_class(actor, x + 144, y)
  147.   draw_actor_level(actor, x + 8, y + 16)
  148.   draw_actor_state(actor, x + 8, y + 32)
  149.   draw_actor_hp(actor, x + 152, y + 16)
  150.   draw_actor_sp(actor, x + 152, y + 32)
  151. end  end  
  152. #--------------------------------------------------------------------------  
  153. # * Cursor Rectangle Update  
  154. #--------------------------------------------------------------------------  
  155. def update_cursor_rect
  156.  
  157. # Cursor position -1 = all choices, -2 or lower = independent choice
  158.  
  159. # (meaning the user's own choice)
  160. if @index <= -2
  161.   self.cursor_rect.set(0, (@index + 10) * 55 + 6, self.width - 32, 48)
  162. elsif @index == -1
  163.   self.cursor_rect.set(0, 0, self.width - 32 + 6, @item_max * 58 - 20)
  164. else
  165.   self.cursor_rect.set(0, @index * 55 + 6, self.width - 32, 52)
  166. end  end end
  167. #==============================================================================
  168. # Alterations in Window_SaveFile
  169. #==============================================================================
  170. class Window_SaveFile < Window_Base  
  171. #--------------------------------------------------------------------------  
  172. # * Refresh  
  173. #--------------------------------------------------------------------------  
  174. def refresh
  175. self.contents.clear
  176.  
  177. # Draw file number
  178. self.contents.font.color = normal_color
  179. name = "File
  180. #{@file_index + 1}"
  181. self.contents.draw_text(4, 0, 600, 32, name)
  182. @name_width = contents.text_size(name).width
  183.  
  184. # If save file exists
  185. if @file_exist
  186.  
  187. # Draw character
  188.   for i in 0...@characters.size
  189.  
  190. bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
  191.  
  192. cw = bitmap.rect.width / 4
  193.  
  194. ch = bitmap.rect.height / 4
  195.  
  196. src_rect = Rect.new(0, 0, cw, ch)
  197.  
  198. x = 275 - @characters.size * 24 + i * 48 - cw / 2
  199.  
  200. self.contents.blt(x, 68 - ch, bitmap, src_rect)
  201.   end
  202.  
  203. # Draw play time
  204.   hour = @total_sec / 60 / 60
  205.   min = @total_sec / 60 % 60
  206.   sec = @total_sec % 60
  207.   time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  208.   self.contents.font.color = normal_color
  209.   self.contents.draw_text(4, 8, 600, 32, time_string, 2)
  210.  
  211. # Draw timestamp
  212.   self.contents.font.color = normal_color
  213.   time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  214.   self.contents.draw_text(4, 40, 600, 32, time_string, 2)
  215. end  end end
  216. #==============================================================================
  217. # Alterations in Window_ShopStatus
  218. #==============================================================================
  219. class Window_ShopStatus < Window_Base  
  220. #--------------------------------------------------------------------------  
  221. # * Refresh  
  222. #--------------------------------------------------------------------------  
  223. def refresh
  224. self.contents.clear
  225. if @item == nil
  226.   return
  227. end
  228. case @item
  229. when RPG::Item
  230.   number = $game_party.item_number(@item.id)
  231. when RPG::Weapon
  232.   number = $game_party.weapon_number(@item.id)
  233. when RPG::Armor
  234.   number = $game_party.armor_number(@item.id)
  235. end
  236. self.contents.font.color = system_color
  237. self.contents.draw_text(4, 0, 200, 24, "number in possession")
  238. self.contents.font.color = normal_color
  239. self.contents.draw_text(204, 0, 32, 24, number.to_s, 2)
  240. if @item.is_a?(RPG::Item)
  241.   return
  242. end
  243.  
  244. # Equipment adding information
  245. for i in 0...$game_party.actors.size
  246.  
  247. # Get actor
  248.   actor = $game_party.actors[i]
  249.   p_size = $game_party.actors.size
  250.  
  251. # If equippable, then set to normal text color. If not, set to
  252.  
  253. # invalid text color.
  254.   if actor.equippable?(@item)
  255.  
  256. self.contents.font.color = normal_color
  257.   else
  258.  
  259. self.contents.font.color = disabled_color
  260.   end
  261.  
  262. # Draw actor's name
  263.   if p_size > 5
  264.  
  265. y1 = i * (288 / p_size)
  266.   else
  267.  
  268. y1 = i * 48
  269.   end
  270.   self.contents.draw_text(4, 24 + y1, 120, 24, actor.name)
  271.  
  272. # Get current equipment
  273.   if @item.is_a?(RPG::Weapon)
  274.  
  275. item1 = $data_weapons[actor.weapon_id]
  276.   elsif @item.kind == 0
  277.  
  278. item1 = $data_armors[actor.armor1_id]
  279.   elsif @item.kind == 1
  280.  
  281. item1 = $data_armors[actor.armor2_id]
  282.   elsif @item.kind == 2
  283.  
  284. item1 = $data_armors[actor.armor3_id]
  285.   else
  286.  
  287. item1 = $data_armors[actor.armor4_id]
  288.   end
  289.  
  290. # If equippable
  291.   if actor.equippable?(@item)
  292.  
  293.  
  294. # If weapon
  295.  
  296. if @item.is_a?(RPG::Weapon)
  297.  
  298.   atk1 = item1 != nil ? item1.atk : 0
  299.  
  300.   atk2 = @item != nil ? @item.atk : 0
  301.  
  302.   change = atk2 - atk1
  303.  
  304. end
  305.  
  306.  
  307. # If armor
  308.  
  309. if @item.is_a?(RPG::Armor)
  310.  
  311.   pdef1 = item1 != nil ? item1.pdef : 0
  312.  
  313.   mdef1 = item1 != nil ? item1.mdef : 0
  314.  
  315.   pdef2 = @item != nil ? @item.pdef : 0
  316.  
  317.   mdef2 = @item != nil ? @item.mdef : 0
  318.  
  319.   change = pdef2 - pdef1 + mdef2 - mdef1
  320.  
  321. end
  322.  
  323.  
  324. # Draw parameter change values
  325.  
  326. self.contents.draw_text(124, 24 + y1, 112, 24,
  327.  
  328.   sprintf("%+d", change), 2)
  329.   end
  330.  
  331. # Draw item
  332.   if item1 != nil
  333.  
  334. x = 4
  335.  
  336. y = 8 + y1 + 32
  337.  
  338. bitmap = RPG::Cache.icon(item1.icon_name)
  339.  
  340. opacity = self.contents.font.color == normal_color ? 255 : 128
  341.  
  342. self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  343.  
  344. self.contents.draw_text(x + 28, y, 212, 24, item1.name)
  345.   end
  346. end  end end
  347. class Spriteset_Battle  
  348. #--------------------------------------------------------------------------  
  349. # * Object Initialization  
  350. #--------------------------------------------------------------------------  
  351. def initialize
  352.  
  353. # Make viewports
  354. @viewport1 = Viewport.new(0, 0, 640, 320)
  355. @viewport2 = Viewport.new(0, 0, 640, 480)
  356. @viewport3 = Viewport.new(0, 0, 640, 480)
  357. @viewport4 = Viewport.new(0, 0, 640, 480)
  358. @viewport2.z = 101
  359. @viewport3.z = 200
  360. @viewport4.z = 5000
  361.  
  362. # Make battleback sprite
  363. @battleback_sprite = Sprite.new(@viewport1)
  364.  
  365. # Make enemy sprites
  366. @enemy_sprites = []
  367. for enemy in $game_troop.enemies.reverse
  368.   @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  369. end
  370.  
  371. # Make actor sprites
  372. @actor_sprites = []
  373. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  374. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  375. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  376. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  377. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  378. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  379. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  380. @actor_sprites.push(Sprite_Battler.new(@viewport2))
  381.  
  382. # Make weather
  383. @weather = RPG::Weather.new(@viewport1)
  384.  
  385. # Make picture sprites
  386. @picture_sprites = []
  387. for i in 51..100
  388.   @picture_sprites.push(Sprite_Picture.new(@viewport3,
  389.  
  390. $game_screen.pictures[i]))
  391. end
  392.  
  393. # Make timer sprite
  394. @timer_sprite = Sprite_Timer.new
  395.  
  396. # Frame update
  397. update  end
  398. def update
  399.  
  400. # Update actor sprite contents (corresponds with actor switching)
  401. @actor_sprites[0].battler = $game_party.actors[0]
  402. @actor_sprites[1].battler = $game_party.actors[1]
  403. @actor_sprites[2].battler = $game_party.actors[2]
  404. @actor_sprites[3].battler = $game_party.actors[3]
  405. @actor_sprites[4].battler = $game_party.actors[4]
  406. @actor_sprites[5].battler = $game_party.actors[5]
  407. @actor_sprites[6].battler = $game_party.actors[6]
  408. @actor_sprites[7].battler = $game_party.actors[7]
  409.  
  410. # If battleback file name is different from current one
  411. if @battleback_name != $game_temp.battleback_name
  412.   @battleback_name = $game_temp.battleback_name
  413.   if @battleback_sprite.bitmap != nil
  414.  
  415. @battleback_sprite.bitmap.dispose
  416.   end
  417.   @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  418.   @battleback_sprite.src_rect.set(0, 0, 640, 320)
  419. end
  420.  
  421. # Update battler sprites
  422. for sprite in @enemy_sprites + @actor_sprites
  423.   sprite.update
  424. end
  425.  
  426. # Update weather graphic
  427. @weather.type = $game_screen.weather_type
  428. @weather.max = $game_screen.weather_max
  429. @weather.update
  430.  
  431. # Update picture sprites
  432. for sprite in @picture_sprites
  433.   sprite.update
  434. end
  435.  
  436. # Update timer sprite
  437. @timer_sprite.update
  438.  
  439. # Set screen color tone and shake position
  440. @viewport1.tone = $game_screen.tone
  441. @viewport1.ox = $game_screen.shake
  442.  
  443. # Set screen flash color
  444. @viewport4.color = $game_screen.flash_color
  445.  
  446. # Update viewports
  447. @viewport1.update
  448. @viewport2.update
  449. @viewport4.update  end end
  450. #==============================================================================
  451. # ** Window_BattleStatus
  452. #------------------------------------------------------------------------------
  453. #  This window displays the status of all party members on the battle screen.
  454. #==============================================================================
  455. class Window_Base < Window
  456. def shadow_color
  457.     return Color.new(0, 0, 0)
  458. end  
  459. #--------------------------------------------------------------------------  
  460. # * Draw Name  
  461. #actor : actor  
  462. #x: draw spot x-coordinate  
  463. #y: draw spot y-coordinate  
  464. #--------------------------------------------------------------------------  
  465. def draw_actor_name(actor, x, y, shadow = false)
  466. self.contents.font.color = normal_color
  467. if shadow
  468.   self.contents.font.color = shadow_color
  469. end
  470. self.contents.draw_text(x, y, 120, 32, actor.name)  end  
  471. #--------------------------------------------------------------------------  
  472. # * Draw State  
  473. #actor : actor  
  474. #x: draw spot x-coordinate  
  475. #y: draw spot y-coordinate  
  476. #width : draw spot width  
  477. #--------------------------------------------------------------------------  
  478. def draw_actor_state(actor, x, y, width = 120, shadow = false)
  479. text = make_battler_state_text(actor, width, true)
  480. self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
  481. if shadow
  482.   self.contents.font.color = shadow_color
  483. end
  484. self.contents.draw_text(x, y, width, 32, text)  end  
  485. #--------------------------------------------------------------------------  
  486. # * Draw HP  
  487. #actor : actor  
  488. #x: draw spot x-coordinate  
  489. # y : draw spot y-coordinate  
  490. # width : draw spot width  
  491. #--------------------------------------------------------------------------  
  492. def draw_actor_hp(actor, x, y, width = 144, height = 32, shadow = false)
  493.  
  494. # Draw "HP" text string
  495. self.contents.font.color = system_color
  496. if shadow
  497.   self.contents.font.color = shadow_color
  498. end
  499. self.contents.draw_text(x, y, 32, height, $data_system.words.hp)
  500.  
  501. # Calculate if there is draw space for MaxHP
  502. if width - 32 >= 108
  503.   hp_x = x + width - 108
  504.   flag = true
  505. elsif width - 32 >= 28
  506.   hp_x = x + width - 48
  507.   flag = false
  508. end
  509.  
  510. # Draw HP
  511. self.contents.font.color = actor.hp == 0 ? knockout_color :
  512.   actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  513. if shadow
  514.   self.contents.font.color = shadow_color
  515. end
  516. self.contents.draw_text(hp_x, y, 48, height, actor.hp.to_s, 2)
  517.  
  518. # Draw MaxHP
  519. if flag
  520.   self.contents.font.color = normal_color
  521.   if shadow
  522.  
  523. self.contents.font.color = shadow_color
  524.   end
  525.   self.contents.draw_text(hp_x + 48, y, 12, height, "/", 1)
  526.   self.contents.draw_text(hp_x + 60, y, 48, height, actor.maxhp.to_s)
  527. end  end  
  528. #--------------------------------------------------------------------------  
  529. # * Draw SP  
  530. # actor : actor  
  531. # x : draw spot x-coordinate  
  532. # y : draw spot y-coordinate  
  533. # width : draw spot width  
  534. #--------------------------------------------------------------------------  
  535. def draw_actor_sp(actor, x, y, width = 144, height = 32, shadow = false)
  536.  
  537. # Draw "SP" text string
  538. self.contents.font.color = system_color
  539. if shadow
  540.   self.contents.font.color = shadow_color
  541. end
  542. self.contents.draw_text(x, y, 32, height, $data_system.words.sp)
  543.  
  544. # Calculate if there is draw space for MaxHP
  545. if width - 32 >= 108
  546.   sp_x = x + width - 108
  547.   flag = true
  548. elsif width - 32 >= 28
  549.   sp_x = x + width - 48
  550.   flag = false
  551. end
  552.  
  553. # Draw SP
  554. self.contents.font.color = actor.sp == 0 ? knockout_color :
  555.   actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  556. if shadow
  557.   self.contents.font.color = shadow_color
  558. end
  559. self.contents.draw_text(sp_x, y, 48, height, actor.sp.to_s, 2)
  560.  
  561. # Draw MaxSP
  562. if flag
  563.   self.contents.font.color = normal_color
  564.   if shadow
  565.  
  566. self.contents.font.color = shadow_color
  567.   end
  568.   self.contents.draw_text(sp_x + 48, y, 12, height, "/", 1)
  569.   self.contents.draw_text(sp_x + 60, y, 48, height, actor.maxsp.to_s)
  570. end  end end
  571. class Window_BattleStatus < Window_Base  
  572. #--------------------------------------------------------------------------  
  573. # * Refresh  
  574. #--------------------------------------------------------------------------  
  575. def refresh
  576. self.contents.clear
  577. @item_max = $game_party.actors.size
  578. if @item_max > 7
  579.   self.contents.font.size = 16
  580.   self.contents.font.bold = true
  581. elsif @item_max > 6
  582.   self.contents.font.size = 18
  583.   self.contents.font.bold = true
  584. elsif @item_max > 4
  585.   self.contents.font.size = 20
  586.   self.contents.font.bold = true
  587. else
  588.   self.contents.font.size = 22
  589. end
  590. for i in 0...$game_party.actors.size
  591.   actor = $game_party.actors[i]
  592.   if @item_max > 6
  593.  
  594. actor_x = i * 610/@item_max + 0
  595.  
  596. text_x = 75
  597.  
  598. t_height = 32
  599.   elsif @item_max > 4
  600.  
  601. actor_x = i * 612/@item_max + 4
  602.  
  603. text_x = 95
  604.  
  605. t_height = 32
  606.   else
  607.  
  608. actor_x = i * 160 + 4
  609.  
  610. text_x = 120
  611.  
  612. t_height = 32
  613.   end
  614.  
  615.  
  616.  
  617. # Draw shade
  618.  
  619.  
  620. actor_x -= 2
  621.   draw_actor_name(actor, actor_x, 2, true)
  622.   draw_actor_hp(actor, actor_x, 34, text_x, t_height, true)
  623.   draw_actor_sp(actor, actor_x, 66, text_x, t_height, true)
  624.   if @level_up_flags[i]
  625.  
  626. self.contents.font.color = Color.new(0, 0, 0)
  627.  
  628. self.contents.draw_text(actor_x, 98, 120, t_height, "LEVEL UP!")
  629.   else
  630.  
  631. draw_actor_state(actor, actor_x, 98, 120, true)
  632.   end
  633.  
  634.  
  635. actor_x += 2
  636.   draw_actor_name(actor, actor_x, 0)
  637.   draw_actor_hp(actor, actor_x, 32, text_x, t_height)
  638.   draw_actor_sp(actor, actor_x, 64, text_x, t_height)
  639.   if @level_up_flags[i]
  640.  
  641. self.contents.font.color = normal_color
  642.  
  643. self.contents.draw_text(actor_x, 96, 120, t_height, "LEVEL UP!")
  644.   else
  645.  
  646. draw_actor_state(actor, actor_x, 96)
  647.   end
  648.  
  649. end  end end
  650. class Scene_Battle
  651. def phase3_setup_command_window
  652.  
  653. # Disable party command window
  654. @party_command_window.active = false
  655. @party_command_window.visible = false
  656.  
  657. # Enable actor command window
  658. @actor_command_window.active = true
  659. @actor_command_window.visible = true
  660.  
  661. p_size = $game_party.actors.size - 1
  662. step_x = 480/p_size
  663. if step_x > 160
  664.   step_x = 160
  665. end
  666. window_x = @actor_index * step_x
  667. if @actor_index == $game_party.actors.size - 1
  668.   window_x = 480
  669. end
  670.  
  671. # Set actor command window position
  672. @actor_command_window.x = window_x
  673.  
  674. # Set index to 0
  675. @actor_command_window.index = 0  end end
RAW Paste Data