Advertisement
Vlue

Hero Roster

Mar 4th, 2014
1,942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.89 KB | None | 0 0
  1. #--# Hero Roster v 1.2a
  2. #
  3. # Just a simple scene that lets you see a list of all the actors in the game.
  4. #  Works based on whether they've been in your party or not, as well as
  5. #  manually through script calls.
  6. #
  7. # Usage: Plug and play.
  8. #    Script calls:
  9. #     SceneManager.call(Scene_Roster)          - calls the scene
  10. #     $game_actors[id].discovered = true/false - discovers or undiscovers
  11. #     $game_actors[actor_id].in_roster = true/false
  12. #
  13. #    Notetags:
  14. #     <NO ROSTER> - keeps an actor out of the roster
  15. #     <ROSTER ##> - Used to manually sort actors
  16. #
  17. #------#
  18. #-- Script by: V.M of D.T
  19. #
  20. #- Questions or comments can be:
  21. #    given by email: sumptuaryspade@live.ca
  22. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  23. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  24. #
  25. #--- Free to use in any project, commercial or non-commercial, with credit given
  26. #--Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  27.  
  28. module ROSTER
  29.   #Face to be displayed for unknown actors. Set to false to disable.
  30.   UNDISCOVERED_FACE = ["Monster1",7]
  31.   #Description text to be displayed for unknown actors
  32.   UNDISCOVERED_DESC = "You have not met this hero yet."
  33.   #Use basic status: (For compatibility with scripts that change status display)
  34.   USE_BASIC = false
  35.   #Shows empty slots in equipment array
  36.   SHOW_EMPTY_SLOTS = true
  37.   EMPTY_SLOT_ICON = 0
  38.   EMPTY_SLOT_TEXT = "--Empty--"
  39. end
  40.  
  41. class Scene_Roster < Scene_Base
  42.   def initialize
  43.     super
  44.     @list_window = Window_ActorList.new
  45.     @list_window.set_handler(:cancel, method(:close_scene))
  46.     @status_window = Window_RosterStatus.new(@list_window.current_actor)
  47.     @status_window.x = @list_window.width
  48.     @help_window = Window_Help.new
  49.   end
  50.   def update
  51.     super
  52.     @status_window.actor = @list_window.current_actor
  53.     if @list_window.current_actor.discovered
  54.       @help_window.set_text(@list_window.current_actor.description)
  55.     else
  56.       @help_window.set_text(ROSTER::UNDISCOVERED_DESC)
  57.     end
  58.   end
  59.   def close_scene
  60.     SceneManager.return
  61.   end
  62. end
  63.  
  64. class Window_ActorList < Window_Selectable
  65.   def initialize
  66.     super(0,72,176,Graphics.height-72)
  67.     activate
  68.     select(0)
  69.     refresh
  70.   end
  71.   def make_item_list
  72.     @data = $data_actors.select {|actor| actor.nil? ? false : $game_actors[actor.id].in_roster?}
  73.     @data.sort! {|a,b| a.roster_number - b.roster_number }
  74.   end
  75.   def draw_item(index)
  76.     actor = @data[index]
  77.     if actor
  78.       rect = item_rect(index)
  79.       rect.x += 4
  80.       if $game_actors[actor.id].discovered
  81.         change_color(normal_color)
  82.         draw_text(rect, actor.name)
  83.       else
  84.         change_color(normal_color, false)
  85.         draw_text(rect, "?????")
  86.       end
  87.     end
  88.   end
  89.   def refresh
  90.     make_item_list
  91.     create_contents
  92.     draw_all_items
  93.   end
  94.   def item_max
  95.     @data ? @data.size : 0
  96.   end
  97.   def current_actor
  98.     $game_actors[@data[@index].id]
  99.   end
  100. end
  101.  
  102. class Game_Actor
  103.   attr_accessor  :discovered
  104.   attr_accessor  :in_roster
  105.   def in_roster?
  106.     @in_roster = !actor.in_roster? if @in_roster.nil?
  107.     @in_roster
  108.   end
  109. end
  110.  
  111. class RPG::Actor
  112.   def in_roster?
  113.     self.note =~ /<NO ROSTER>/
  114.   end
  115.   def roster_number
  116.     self.note =~ /<ROSTER (\d+)>/ ? $1.to_i : 999
  117.   end
  118. end
  119.  
  120. class Game_Party
  121.   def setup_starting_members
  122.     @actors = $data_system.party_members.clone
  123.     @actors.each do |actor|
  124.       $game_actors[actor].discovered = true
  125.     end
  126.   end
  127.   def add_actor(actor_id)
  128.     @actors.push(actor_id) unless @actors.include?(actor_id)
  129.     $game_actors[actor_id].discovered = true
  130.     $game_player.refresh
  131.     $game_map.need_refresh = true
  132.   end
  133. end
  134.  
  135. class Window_RosterStatus < Window_Selectable
  136.   def initialize(actor)
  137.     super(0, 72, 368, Graphics.height-72)
  138.     @actor = actor
  139.     refresh
  140.   end
  141.   def actor=(actor)
  142.     return if @actor == actor
  143.     @actor = actor
  144.     refresh
  145.   end
  146.   def refresh
  147.     contents.clear
  148.     reset_font_settings
  149.     contents.font.size -= 4
  150.     if ROSTER::USE_BASIC
  151.       if @actor.discovered
  152.         draw_actor_face(@actor, 0, 0)
  153.       elsif ROSTER::UNDISCOVERED_FACE
  154.         face = ROSTER::UNDISCOVERED_FACE
  155.         draw_face(face[0], face[1], 0, 0, false)
  156.       end
  157.       draw_actor_simple_status(@actor, 96, line_height * 0)
  158.     else
  159.       draw_block1   (line_height * 0)
  160.       draw_horz_line(line_height * 1)
  161.       draw_block2   (line_height * 2)
  162.     end
  163.     draw_horz_line(line_height * 6)
  164.     draw_block3   (line_height * 7)
  165.     draw_horz_line(line_height * 13)
  166.     draw_block4   (line_height * 14)
  167.   end
  168.   def draw_block1(y)
  169.     draw_actor_name(@actor, 4, y)
  170.     draw_actor_class(@actor, contents.width / 3, y)
  171.     draw_actor_nickname(@actor, contents.width / 3 * 2, y)
  172.   end
  173.   def draw_block2(y)
  174.     if @actor.discovered
  175.       draw_actor_face(@actor, 8, y)
  176.     elsif ROSTER::UNDISCOVERED_FACE
  177.       face = ROSTER::UNDISCOVERED_FACE
  178.       draw_face(face[0], face[1], 8, y, false)
  179.     end
  180.     draw_basic_info(136, y)
  181.   end
  182.   def draw_block3(y)
  183.     draw_parameters(8, y)
  184.     draw_equipments(contents.width / 3, y) if @actor.discovered
  185.   end
  186.   def draw_actor_param(actor, x, y, param_id)
  187.     change_color(system_color)
  188.     draw_text(x, y, 120, line_height, Vocab::param(param_id))
  189.     change_color(normal_color)
  190.     if @actor.discovered
  191.       draw_text(x + 40, y, 36, line_height, actor.param(param_id), 2)
  192.     else
  193.       draw_text(x + 40, y, 36, line_height, "??", 2)
  194.     end
  195.   end
  196.   def draw_block4(y)
  197.   end
  198.   def draw_horz_line(y)
  199.     line_y = y + line_height / 2 - 1
  200.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  201.   end
  202.   def line_color
  203.     color = normal_color
  204.     color.alpha = 48
  205.     color
  206.   end
  207.   def draw_basic_info(x, y)
  208.     draw_actor_level(@actor, x, y + line_height * 0)
  209.     draw_actor_hp(@actor, x, y + line_height * 2)
  210.     draw_actor_mp(@actor, x, y + line_height * 3)
  211.   end
  212.   def draw_parameters(x, y)
  213.     6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  214.   end
  215.   def draw_equipments(x, y)
  216.     iter = 0
  217.     @actor.equips.each do |item|
  218.       change_color(normal_color,!item.nil?)
  219.       if item.nil? && ROSTER::SHOW_EMPTY_SLOTS
  220.         draw_icon(ROSTER::EMPTY_SLOT_ICON, x, y + line_height * iter,false)
  221.         draw_text(x+24,y+line_height*iter,172,24,ROSTER::EMPTY_SLOT_TEXT)
  222.       else
  223.         draw_item_name(item, x, y + line_height * iter) unless item.nil?
  224.       end
  225.       iter += 1
  226.     end
  227.   end
  228.   def draw_description(x, y)
  229.     draw_text_ex(x, y, @actor.description) if @actor.discovered
  230.   end
  231.   def draw_text_ex(x, y, text)
  232.     text = convert_escape_characters(text)
  233.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  234.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  235.   end
  236.   alias ros_draw_actor_name draw_actor_name
  237.   def draw_actor_name(a, x, y)
  238.     return ros_draw_actor_name(a,x,y) if @actor.discovered
  239.     draw_text(x,y,contents.width,line_height,"?????")
  240.   end
  241.   alias ros_draw_actor_class draw_actor_class
  242.   def draw_actor_class(a, x, y)
  243.     return ros_draw_actor_class(a,x,y) if @actor.discovered
  244.     draw_text(x,y,contents.width,line_height,"?????")
  245.   end
  246.   alias ros_draw_actor_nickname draw_actor_nickname
  247.   def draw_actor_nickname(a, x, y)
  248.     return ros_draw_actor_nickname(a,x,y) if @actor.discovered
  249.     draw_text(x,y,contents.width,line_height,"?????")
  250.   end
  251.   def draw_actor_level(actor, x, y)
  252.     change_color(system_color)
  253.     draw_text(x, y, 32, line_height, Vocab::level_a)
  254.     change_color(normal_color)
  255.     if @actor.discovered
  256.       draw_text(x + 32, y, 24, line_height, actor.level, 2)
  257.     else
  258.       draw_text(x + 32, y, 24, line_height, "??", 2)
  259.     end
  260.   end
  261.   def draw_actor_hp(actor, x, y, width = 124)
  262.     draw_gauge(x, y, width, 1, hp_gauge_color1, hp_gauge_color2)
  263.     change_color(system_color)
  264.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  265.     draw_current_and_max_values(x, y, width, actor.mhp, actor.mhp,
  266.       hp_color(actor), normal_color)
  267.   end
  268.   def draw_actor_mp(actor, x, y, width = 124)
  269.     draw_gauge(x, y, width, 1, mp_gauge_color1, mp_gauge_color2)
  270.     change_color(system_color)
  271.     draw_text(x, y, 30, line_height, Vocab::mp_a)
  272.     draw_current_and_max_values(x, y, width, actor.mmp, actor.mmp,
  273.       mp_color(actor), normal_color)
  274.   end
  275.   def draw_current_and_max_values(x, y, width, current, max, color1, color2)
  276.     change_color(color1)
  277.     xr = x + width
  278.     if @actor.discovered
  279.       draw_text(xr - 92, y, 42, line_height, current, 2)
  280.       change_color(color2)
  281.       draw_text(xr - 52, y, 12, line_height, "/", 2)
  282.       draw_text(xr - 42, y, 42, line_height, max, 2)
  283.     else
  284.       draw_text(xr - 92, y, 42, line_height, "??", 2)
  285.       change_color(color2)
  286.       draw_text(xr - 52, y, 12, line_height, "/", 2)
  287.       draw_text(xr - 42, y, 42, line_height, "??", 2)
  288.     end
  289.   end
  290. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement