Advertisement
AngryPacman

PAC Skills Scene

Jul 29th, 2011
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.03 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Pacman Advanced Creative (PAC) Engine - Skills Scene
  4. # 7/5/2011
  5. # Type: Menu
  6. # Installation: Configuration.
  7. # Level: Average
  8. # With: Cozziekuns
  9. #
  10. #===============================================================================
  11. #
  12. # Description:
  13. # This skill inventory allows you to sort your items in the categories: All,
  14. # Damage, Healing and Status. You can even make your own categories, if that's
  15. # how you roll. This PAC format version makes several graphical improvements
  16. # in Pacman's preference.
  17. #
  18. #===============================================================================
  19. #
  20. # Instructions:
  21. # INSTALLATION
  22. # Paste above main, below materials and following PAC format if applicable.
  23. # Compatible with all PAC scripts, but not dependent on them. This should be
  24. # compatible with any script that doesn't mess around with the Skill Scene.
  25. # CONFIGURATION
  26. # Instructions on how to use the script begin at line 38. Follow them
  27. # religiously.
  28. #
  29. #===============================================================================
  30.  
  31. $imported = {} if $imported == nil
  32. $imported["PACSkills"] = true
  33.  
  34. module PAC
  35.   module MENU
  36.     CATEGORY_TEXT = "Currently Displayed:"
  37.    
  38. #===============================================================================
  39. # Extra Skill Categories
  40. # ------------------------------------------------------------------------------
  41. # Each item in the hash represents a certain category. For example, the first
  42. # hash we see here is:
  43. #
  44. #  0 => [21, "All", false],
  45. #
  46. # The syntax of this is:
  47. #
  48. # Category ID => [Icon Number, Text, Prime],
  49. #
  50. # Probably the most important part, the category ID is the number you want to
  51. # put into the notebox that the item contains. For example, if you wanted to
  52. # make the skill "Teleport" into the category 4, you would put:
  53. #
  54. # \category[4]
  55. #
  56. # into the notebox. Note that numbers 0, 1, 2, and 3 are special. They're prime
  57. # categories. Sound special right? Not really, this just means you have to have
  58. # them in the inventory for this script to work. I could've gotten rid of them,
  59. # but that would've just given more work on your part (and mine), so bear with
  60. # them, please. Icon Numbers and Text are pretty self explanatory.
  61. #
  62. # Last, but not least, is the "Prime" function. Setting this to "true" means
  63. # that anything in the prime category will not show up in the other categories.
  64. # You can set if you want it to show up in all.
  65. #===============================================================================
  66.     SKILL_CATEGORIES = {
  67.    
  68.       0 => [21, "All", false],
  69.       1 => [132, "Battle", false],
  70.       2 => [128, "Healing", false],
  71.       3 => [113, "Buffs", false],
  72.       4 => [80, "Special", true],
  73.     }
  74.    
  75.     SKILL_CATEGORY_WIDTH = 300 # How wide you want your text window.
  76.     ALL_CATEOGRY_PRIME = false # If you want prime key items to show up in the all window.
  77.     MAX_NUMBER = (544 - SKILL_CATEGORY_WIDTH) / 54 # The maximum number of icons that will fit.
  78.   end
  79. end
  80.  
  81. #==============================================================================
  82. # ** RPG::Skill
  83. #------------------------------------------------------------------------------
  84. #  The superclass of all skills.
  85. #==============================================================================
  86.  
  87. class RPG::Skill
  88.   #--------------------------------------------------------------------------
  89.   # * Cozziekuns Category Index
  90.   #--------------------------------------------------------------------------
  91.   def pac_skill_category_index
  92.     @pac_skill_category_index = 0
  93.     if self.note[/\\category\[(\d+)]/i] != nil
  94.       @pac_skill_category_index = $1.to_i
  95.     end
  96.     return @pac_skill_category_index
  97.   end
  98. end
  99.  
  100. #==============================================================================
  101. # ** Window_Skill
  102. #------------------------------------------------------------------------------
  103. #  This window displays a list of usable skills on the skill screen, etc.
  104. #==============================================================================
  105.  
  106. class Window_Skill < Window_Selectable
  107.   #--------------------------------------------------------------------------
  108.   # * Refresh
  109.   #--------------------------------------------------------------------------
  110.   def refresh(sort_index = 0)
  111.     @sort_index = sort_index
  112.     @data = []
  113.     for skill in @actor.skills
  114.       next unless include?(skill)
  115.       @data.push(skill)
  116.       if skill.id == @actor.last_skill_id
  117.         self.index = @data.size - 1
  118.       end
  119.     end
  120.     @item_max = @data.size
  121.     create_contents
  122.     for i in 0...@item_max
  123.       draw_item(i)
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Whether or not to include in skill list
  128.   #     skill : skill
  129.   #--------------------------------------------------------------------------
  130.   def include?(skill)
  131.     return case @sort_index
  132.     when 0
  133.       unless PAC::MENU::ALL_CATEOGRY_PRIME
  134.         if PAC::MENU::SKILL_CATEGORIES[skill.pac_skill_category_index][2]
  135.           return false
  136.         else
  137.           return true
  138.         end
  139.       else
  140.         return true
  141.       end
  142.     when 1
  143.       if PAC::MENU::SKILL_CATEGORIES[skill.pac_skill_category_index][2]
  144.         return false
  145.       else
  146.         return skill.base_damage > 0
  147.       end
  148.     when 2
  149.       if PAC::MENU::SKILL_CATEGORIES[skill.pac_skill_category_index][2]
  150.         return false
  151.       else
  152.         return skill.base_damage < 0
  153.       end
  154.     when 3
  155.       if PAC::MENU::SKILL_CATEGORIES[skill.pac_skill_category_index][2]
  156.         return false
  157.       elsif skill.plus_state_set.size != 0
  158.         return true
  159.       else
  160.         return skill.minus_state_set.size != 0
  161.       end
  162.     when 4..999
  163.       return skill.pac_skill_category_index == @sort_index
  164.     end
  165.   end
  166. end
  167.  
  168. #==============================================================================
  169. # ** Window_SkillCategory
  170. #------------------------------------------------------------------------------
  171. #  This window displays what type of skill is being displayed.
  172. #==============================================================================
  173.  
  174. class Window_SkillCategory < Window_Base
  175.   #--------------------------------------------------------------------------
  176.   # * Object Initialization
  177.   #     x : window X coordinate
  178.   #     y : window Y coordinate
  179.   #--------------------------------------------------------------------------
  180.   def initialize(x, y, width)
  181.     super(x, y, width, WLH + 32)
  182.     refresh
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # * Refresh
  186.   #--------------------------------------------------------------------------
  187.   def refresh(sort_index = 0)
  188.     @sort_index = sort_index
  189.     @skill_categories = PAC::MENU::SKILL_CATEGORIES
  190.     @skill_categories_width = PAC::MENU::SKILL_CATEGORY_WIDTH
  191.     @category_string = PAC::MENU::CATEGORY_TEXT
  192.     self.contents.clear
  193.     self.contents.font.color = system_color
  194.     self.contents.draw_text(4, 0, @skill_categories_width - 40, WLH, @category_string, 0)
  195.     self.contents.font.color = normal_color
  196.     for i in 0...@skill_categories.size
  197.       if @sort_index == i
  198.         self.contents.draw_text(4, 0, @skill_categories_width - 40, WLH, @skill_categories[i][1], 2)
  199.       end
  200.     end
  201.   end
  202. end
  203.  
  204. #==============================================================================
  205. # ** Window_SkillSort
  206. #------------------------------------------------------------------------------
  207. #  This window displays what type of skill is being displayed.
  208. #==============================================================================
  209.  
  210. class Window_SkillSort < Window_Base
  211.   #--------------------------------------------------------------------------
  212.   # * Object Initialization
  213.   #     x : window X coordinate
  214.   #     y : window Y coordinate
  215.   #--------------------------------------------------------------------------
  216.   def initialize(x, y, width)
  217.     super(x, y, width, WLH + 32)
  218.     @ox = 0
  219.     if PAC::MENU::MAX_NUMBER < PAC::MENU::SKILL_CATEGORIES.size
  220.       self.contents = Bitmap.new(self.width - 32 + ((PAC::MENU::SKILL_CATEGORIES.size - PAC::MENU::MAX_NUMBER) * 54), self.height - 32)
  221.     end
  222.     refresh
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # * Refresh
  226.   #--------------------------------------------------------------------------
  227.   def refresh(sort_index = 0)
  228.     @sort_index = sort_index
  229.     @item_categories = PAC::MENU::SKILL_CATEGORIES
  230.     @item_categories_width = PAC::MENU::SKILL_CATEGORY_WIDTH
  231.     self.contents.clear
  232.     for i in 0...@item_categories.size
  233.       @icon_x = 0 + (i * ((544 - @item_categories_width) / @item_categories.size))
  234.       if @item_categories.size < PAC::MENU::MAX_NUMBER
  235.         draw_item(i)
  236.       else
  237.         draw_items(i)
  238.       end
  239.       if @sort_index == i
  240.         if @item_categories.size < PAC::MENU::MAX_NUMBER
  241.           draw_icon(@item_categories[i][0], @icon_x, 0, true)
  242.         else
  243.           draw_icon(@item_categories[i][0], i * 54, 0, true)
  244.         end
  245.       end
  246.     end
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # * Draw Item
  250.   #     index : item number
  251.   #--------------------------------------------------------------------------
  252.   def draw_item(index)
  253.     icons_x = (544 - @item_categories_width) / @item_categories.size
  254.     draw_icon(@item_categories[index][0], index * icons_x, 0, false)
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # * Draw Items
  258.   #     index : item number
  259.   #--------------------------------------------------------------------------
  260.   def draw_items(index)
  261.     draw_icon(@item_categories[index][0], index * 54, 0, false)
  262.   end
  263. end
  264.  
  265. #==============================================================================
  266. # ** Window_PACSkillHelp
  267. #------------------------------------------------------------------------------
  268. #  This window shows skill and item explanations along with actor status and
  269. #  graphics fit for PAC scripts.
  270. #==============================================================================
  271.  
  272. class Window_PACSkillHelp < Window_Base
  273.   def initialize
  274.     super(0, 112, 544, WLH + 32)
  275.   end
  276.   def set_text(text, align = 0)
  277.     if text != @text or align != @align
  278.       self.contents.clear
  279.       self.contents.font.color = normal_color
  280.       self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
  281.       @text = text
  282.       @align = align
  283.     end
  284.   end
  285. end
  286.  
  287. #==============================================================================
  288. # ** Scene_Skill
  289. #------------------------------------------------------------------------------
  290. #  This class performs the skill screen processing.
  291. #==============================================================================
  292.  
  293. class Scene_Skill < Scene_Base
  294.   #--------------------------------------------------------------------------
  295.   # * Object Initialization
  296.   #     actor_index : actor index
  297.   #--------------------------------------------------------------------------
  298.   def initialize(actor_index = 0, equip_index = 0)
  299.     @actor_index = actor_index
  300.     @sort_index = 0
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Start processing
  304.   #--------------------------------------------------------------------------
  305.   def start
  306.     super
  307.     create_menu_background
  308.     @actor = $game_party.members[@actor_index]
  309.     @viewport = Viewport.new(0, 0, 544, 416)
  310.     @help_window = Window_PACSkillHelp.new
  311.     @help_window.viewport = @viewport
  312.     @status_window = Window_SkillStatus.new(0, 0, @actor)
  313.     @status_window.viewport = @viewport
  314.     @skill_window = Window_Skill.new(0, 168, 544, 248, @actor)
  315.     @skill_window.viewport = @viewport
  316.     @skill_window.help_window = @help_window
  317.     @category_width = PAC::MENU::SKILL_CATEGORY_WIDTH
  318.     @category_window = Window_SkillCategory.new(544 - @category_width, 56, @category_width)
  319.     @sort_window = Window_SkillSort.new(0, 56, 544 - @category_width)
  320.     @target_window = Window_MenuStatus.new(0, 0)
  321.     @skill_categories = PAC::MENU::SKILL_CATEGORIES
  322.     hide_target_window
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # * Termination Processing
  326.   #--------------------------------------------------------------------------
  327.   alias pac_skill_pss_ss_terminate terminate
  328.   def terminate
  329.     pac_skill_pss_ss_terminate
  330.     @category_window.dispose
  331.     @sort_window.dispose
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # * Frame Update
  335.   #--------------------------------------------------------------------------
  336.   def update
  337.     super
  338.     update_menu_background
  339.     @help_window.update
  340.     @status_window.update
  341.     @skill_window.update
  342.     @target_window.update
  343.     if @skill_window.active
  344.       update_skill_selection
  345.     elsif @target_window.active
  346.       update_target_selection
  347.     end
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # * Update Skill Selection
  351.   #--------------------------------------------------------------------------
  352.   def update_skill_selection
  353.     if Input.trigger?(Input::B)
  354.       Sound.play_cancel
  355.       return_scene
  356.     elsif Input.trigger?(Input::X)
  357.       @sort_index -= 1
  358.       @sort_index %= @skill_categories.size
  359.       if @sort_index + 1 == @skill_categories.size
  360.         @sort_window.ox += 54 * (@skill_categories.size - PAC::MENU::MAX_NUMBER)
  361.       else
  362.         if @skill_categories.size > PAC::MENU::MAX_NUMBER and @sort_index > PAC::MENU::MAX_NUMBER - 2
  363.           @sort_window.ox -= 54
  364.         end
  365.       end
  366.       @category_window.refresh(@sort_index)
  367.       @sort_window.refresh(@sort_index)
  368.       @skill_window.refresh(@sort_index)
  369.       @skill_window.index = 0
  370.       Sound.play_cursor
  371.     elsif Input.trigger?(Input::Y)
  372.       @sort_index += 1
  373.       @sort_index %= @skill_categories.size
  374.       if @sort_index != 0
  375.         if @skill_categories.size > PAC::MENU::MAX_NUMBER and @sort_index > PAC::MENU::MAX_NUMBER - 1
  376.           @sort_window.ox += 54
  377.         end
  378.       else
  379.         @sort_window.ox = 0
  380.       end
  381.       @category_window.refresh(@sort_index)
  382.       @sort_window.refresh(@sort_index)
  383.       @skill_window.refresh(@sort_index)
  384.       @skill_window.index = 0
  385.       Sound.play_cursor
  386.     elsif Input.trigger?(Input::R)
  387.       Sound.play_cursor
  388.       next_actor
  389.     elsif Input.trigger?(Input::L)
  390.       Sound.play_cursor
  391.       prev_actor
  392.     elsif Input.trigger?(Input::C)
  393.       @skill = @skill_window.skill
  394.       if @skill != nil
  395.         @actor.last_skill_id = @skill.id
  396.       end
  397.       if @actor.skill_can_use?(@skill)
  398.         Sound.play_decision
  399.         determine_skill
  400.       else
  401.         Sound.play_buzzer
  402.       end
  403.     end
  404.   end
  405. end
  406.  
  407. PAC::MENU::USE_SKILLS_BATTLE = false
  408.  
  409. class Scene_Battle < Scene_Base
  410.   if PAC::MENU::USE_SKILLS_BATTLE
  411.   #--------------------------------------------------------------------------
  412.   # * Start Skill Selection
  413.   #--------------------------------------------------------------------------
  414.   def start_skill_selection
  415.     @help_window = Window_Help.new
  416.     @skill_window = Window_Skill.new(0, 112, 544, 304, @active_battler)
  417.     @category_width = PAC::MENU::SKILL_CATEGORY_WIDTH
  418.     @category_window = Window_SkillCategory.new(544 - @category_width, 56, @category_width)
  419.     @sort_window = Window_SkillSort.new(0, 56, 544 - @category_width)
  420.     @skill_window.help_window = @help_window
  421.     @actor_command_window.active = false
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # * End Skill Selection
  425.   #--------------------------------------------------------------------------
  426.   def end_skill_selection
  427.     if @skill_window != nil
  428.       @skill_window.dispose
  429.       @skill_window = nil
  430.      
  431.       @category_window.dispose
  432.       @category_window = nil
  433.       @sort_window.dispose
  434.       @sort_window = nil
  435.      
  436.       @help_window.dispose
  437.       @help_window = nil
  438.     end
  439.     @actor_command_window.active = true
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # * Update Skill Selection
  443.   #--------------------------------------------------------------------------
  444.   def update_skill_selection
  445.     if Input.trigger?(Input::B)
  446.       Sound.play_cancel
  447.       end_skill_selection
  448.     elsif Input.trigger?(Input::X)
  449.       @sort_index -= 1
  450.       @sort_index %= @skill_categories.size
  451.       if @sort_index + 1 == @skill_categories.size
  452.         @sort_window.ox += 54 * (@skill_categories.size - PAC::MENU::MAX_NUMBER)
  453.       else
  454.         if @skill_categories.size > PAC::MENU::MAX_NUMBER and @sort_index > PAC::MENU::MAX_NUMBER - 2
  455.           @sort_window.ox -= 54
  456.         end
  457.       end
  458.       @category_window.refresh(@sort_index)
  459.       @sort_window.refresh(@sort_index)
  460.       @skill_window.refresh(@sort_index)
  461.       @skill_window.index = 0
  462.       Sound.play_cursor
  463.     elsif Input.trigger?(Input::Y)
  464.       @sort_index += 1
  465.       @sort_index %= @skill_categories.size
  466.       if @sort_index != 0
  467.         if @skill_categories.size > PAC::MENU::MAX_NUMBER and @sort_index > PAC::MENU::MAX_NUMBER - 1
  468.           @sort_window.ox += 54
  469.         end
  470.       else
  471.         @sort_window.ox = 0
  472.       end
  473.       @category_window.refresh(@sort_index)
  474.       @sort_window.refresh(@sort_index)
  475.       @skill_window.refresh(@sort_index)
  476.       @skill_window.index = 0
  477.       Sound.play_cursor
  478.     elsif Input.trigger?(Input::R)
  479.       Sound.play_cursor
  480.       next_actor
  481.     elsif Input.trigger?(Input::L)
  482.       Sound.play_cursor
  483.       prior_actor
  484.     elsif Input.trigger?(Input::C)
  485.       @skill = @skill_window.skill
  486.       if @actor.skill_can_use?(@skill)
  487.         Sound.play_decision
  488.         determine_skill
  489.       else
  490.         Sound.play_buzzer
  491.       end
  492.     end
  493.   end
  494. end
  495. end
  496.  
  497. #===============================================================================
  498. #
  499. # END OF SCRIPT
  500. #
  501. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement