Advertisement
roninator2

Kid Friendly Basic Quest - Battle Spell

Dec 13th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.59 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Battle Spell            ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   FFMQ Style Battle Spell Window    ║    12 Mar 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║                                                          ║
  12. # ║  none                                                    ║
  13. # ╚══════════════════════════════════════════════════════════╝
  14. # ╔══════════════════════════════════════════════════════════╗
  15. # ║ Terms of use:                                            ║
  16. # ║ Free for all uses in RPG Maker - Except nudity           ║
  17. # ╚══════════════════════════════════════════════════════════╝
  18.  
  19. #==============================================================================
  20. # ** Window_SkillList
  21. #==============================================================================
  22. class KFBQ_BattleSpellList < Window_ItemList
  23.   #--------------------------------------------------------------------------
  24.   # * Object Initialization
  25.   #--------------------------------------------------------------------------
  26.   def initialize(x, y, width, height)
  27.     super
  28.     self.z = 400
  29.     self.back_opacity = 0
  30.     @actor = nil
  31.     @data = []
  32.     self.unselect
  33.     self.deactivate
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # * Set Actor
  37.   #--------------------------------------------------------------------------
  38.   def actor=(actor)
  39.     return if @actor == actor
  40.     @actor = actor
  41.     refresh
  42.     self.oy = 0
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # * Get Digit Count
  46.   #--------------------------------------------------------------------------
  47.   def col_max
  48.     return 4
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # * Get Item Height
  52.   #--------------------------------------------------------------------------
  53.   def item_height
  54.     return 60
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # * Get Skill
  58.   #--------------------------------------------------------------------------
  59.   def item
  60.     @data && index >= 0 ? @data[index] : nil
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Get Number of Items
  64.   #--------------------------------------------------------------------------
  65.   def item_max
  66.     @data ? @data.size : 1
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Get Activation State of Selection Item
  70.   #--------------------------------------------------------------------------
  71.   def current_item_enabled?
  72.     return true
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * Include in Skill List?
  76.   #--------------------------------------------------------------------------
  77.   def include?(item)
  78.     return true
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # * Display Skill in Active State?
  82.   #--------------------------------------------------------------------------
  83.   def enable?(item)
  84.     return true
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # * Restore Previous Selection Position
  88.   #--------------------------------------------------------------------------
  89.   def select_last
  90.     select(0)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # * Draw Item
  94.   #--------------------------------------------------------------------------
  95.   def draw_item(index)
  96.     skill = @data[index]
  97.     if skill
  98.       rect = item_rect(index)
  99.       rect.width -= 4
  100.       pos = index % 3
  101.       case pos
  102.       when 0
  103.         ox = 45
  104.       when 1
  105.         ox = 55
  106.       when 2
  107.         ox = 65
  108.       end
  109.       draw_icon(skill.icon_index, rect.x + ox, rect.y, enable?(skill))
  110.     end
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Update Help Text
  114.   #--------------------------------------------------------------------------
  115.   def update_help
  116.     @help_window.set_item(item)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Refresh
  120.   #--------------------------------------------------------------------------
  121.   def refresh
  122.     make_item_list
  123.     create_contents
  124.     draw_all_items
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Item Rect
  128.   #--------------------------------------------------------------------------
  129.   def item_rect(index)
  130.     rect = Rect.new
  131.     rect.width = 60
  132.     rect.height = 60
  133.     rect.x = index % col_max * (60)
  134.     rect.y = index / col_max * (60)
  135.     rect
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Set Cursor Position
  139.   #--------------------------------------------------------------------------
  140.   def index=(index)
  141.     @index = index
  142.     update_cursor
  143.     call_update_help
  144.   end
  145. end
  146.  
  147. #==============================================================================
  148. # ** Window_BattleSkill
  149. #==============================================================================
  150. class KFBQ_BattleSpell < KFBQ_BattleSpellList
  151.   #--------------------------------------------------------------------------
  152.   # * Object Initialization
  153.   #     info_viewport : Viewport for displaying information
  154.   #--------------------------------------------------------------------------
  155.   def initialize(help_window, info_viewport)
  156.     super(250, 280, 280, 100)
  157.     self.visible = false
  158.     self.tone.set(Color.new(0,0,0))
  159.     self.opacity = 255
  160.     self.back_opacity = 255
  161.     self.contents_opacity = 255
  162.     @datawhite = []
  163.     @datablack = []
  164.     @datawizard = []
  165.     @data = []
  166.     @spellgroup = 1
  167.     @help_window = help_window
  168.     @info_viewport = info_viewport
  169.     update_padding
  170.     select(0)
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # * Set Actor
  174.   #--------------------------------------------------------------------------
  175.   def actor=(actor)
  176.     @actor = actor
  177.     @spell_type.actor = @actor
  178.     refresh
  179.     self.oy = 0
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # * Set Help Window
  183.   #--------------------------------------------------------------------------
  184.   def help_window=(help_window)
  185.     @help_window = help_window
  186.     call_update_help
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Set Row text
  190.   #--------------------------------------------------------------------------
  191.   def type_window=(type_window)
  192.     @spell_type = type_window
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Refresh
  196.   #--------------------------------------------------------------------------
  197.   def refresh
  198.     create_contents
  199.     make_item_list
  200.     draw_all_items
  201.     call_update_help
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # * Get Number of Items
  205.   #--------------------------------------------------------------------------
  206.   def item_max
  207.     case @spellgroup
  208.     when 1
  209.       if @datawhite.empty? || @datawhite.nil?
  210.         return 1
  211.       else
  212.         @datawhite.size
  213.       end
  214.     when 2
  215.       if @datablack.empty? || @datablack.nil?
  216.         return 1
  217.       else
  218.         @datablack.size
  219.       end
  220.     when 3
  221.       if @datawizard.empty? || @datawizard.nil?
  222.         return 1
  223.       else
  224.         @datawizard.size
  225.       end
  226.     else
  227.       return 1
  228.     end
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Get Digit Count
  232.   #--------------------------------------------------------------------------
  233.   def col_max
  234.     return 4
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Item Rect
  238.   #--------------------------------------------------------------------------
  239.   def item_rect(index)
  240.     rect = Rect.new
  241.     rect.width = 60
  242.     rect.height = 60
  243.     rect.x = index % col_max * (60)
  244.     rect.y = index / col_max * (60)
  245.     rect
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # * Create Skill List
  249.   #--------------------------------------------------------------------------
  250.   def make_item_list
  251.     @datawhite = []
  252.     @datablack = []
  253.     @datawizard = []
  254.     for i in 3..$data_skills.size - 1
  255.       spell = $data_skills[i]
  256.       if !spell.kfbq_exclude? and @actor.skills.include?(spell)
  257.         case spell.stype_id
  258.         when 1;  @datawhite << spell
  259.         when 2;  @datablack << spell
  260.         when 3;  @datawizard << spell
  261.         end
  262.       end
  263.     end
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # * Draw Item
  267.   #--------------------------------------------------------------------------
  268.   def draw_item(index)
  269.     case @spellgroup
  270.     when 1
  271.       @data = @datawhite
  272.       @spell_type.update_type = 1
  273.     when 2
  274.       @data = @datablack
  275.       @spell_type.update_type = 2
  276.     when 3
  277.       @data = @datawizard
  278.       @spell_type.update_type = 3
  279.     end
  280.     skill = @data[index]
  281.     pos = index % 4
  282.     case pos
  283.     when 0
  284.       ox = 25
  285.     when 1
  286.       ox = 35
  287.     when 2
  288.       ox = 45
  289.     when 3
  290.       ox = 55
  291.     end
  292.     if skill
  293.       rect = item_rect(index)
  294.       rect.width -= 4
  295.       draw_icon(skill.icon_index, rect.x + 15, rect.y, enable?(skill))
  296.     end
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # * Move Cursor Down
  300.   #--------------------------------------------------------------------------
  301.   def cursor_down(wrap = false)
  302.     case @spellgroup
  303.     when 1
  304.       @spellgroup = 2
  305.       @spell_type.update_type = 2
  306.       select(0)
  307.     when 2
  308.       @spellgroup = 3
  309.       @spell_type.update_type = 3
  310.       select(0)
  311.     when 3
  312.       @spellgroup = 1
  313.       @spell_type.update_type = 1
  314.       select(0)
  315.     end
  316.     refresh
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # * Move Cursor Up
  320.   #--------------------------------------------------------------------------
  321.   def cursor_up(wrap = false)
  322.     case @spellgroup
  323.     when 1
  324.       @spellgroup = 3
  325.       @spell_type.update_type = 3
  326.       select(0)
  327.     when 2
  328.       @spellgroup = 1
  329.       @spell_type.update_type = 1
  330.       select(0)
  331.     when 3
  332.       @spellgroup = 2
  333.       @spell_type.update_type = 2
  334.       select(0)
  335.     end
  336.     refresh
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # * Update Cursor
  340.   #--------------------------------------------------------------------------
  341.   def update_cursor
  342.     ensure_cursor_visible
  343.     cursor_rect.set(item_rect(@index))
  344.     cursor_rect.x += 13
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # * Select Last
  348.   #--------------------------------------------------------------------------
  349.   def select_last
  350.     select(0)
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # * Row Max
  354.   #--------------------------------------------------------------------------
  355.   def row_max
  356.     [(item_max + col_max - 1) / col_max, 1].max
  357.   end
  358. end
  359.  
  360. #==============================================================================
  361. # ** Window_Spell_Command
  362. #==============================================================================
  363. class KFBQ_Spell_Command < Window_Base
  364.   #--------------------------------------------------------------------------
  365.   # * Iniatilize
  366.   #--------------------------------------------------------------------------
  367.   def initialize
  368.     super(40, 280, 200, fitting_height(1))
  369.     self.tone.set(Color.new(-255,-255,-255))
  370.     self.opacity = 255
  371.     self.arrows_visible = false
  372.     self.pause = false
  373.     self.back_opacity = 255
  374.     self.contents_opacity = 255
  375.     refresh
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # * Dispose
  379.   #--------------------------------------------------------------------------
  380.   def dispose
  381.     contents.dispose unless disposed?
  382.     super unless disposed?
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # * Refresh
  386.   #--------------------------------------------------------------------------
  387.   def refresh
  388.     contents.clear
  389.     name = "Spell"
  390.     draw_text(0, 0, 180, line_height, name, 1)
  391.   end
  392. end
  393.  
  394. #==============================================================================
  395. # ** Window_Spell_Type
  396. #==============================================================================
  397. class KFBQ_Spell_Type < Window_Base
  398.   #--------------------------------------------------------------------------
  399.   # * Iniatilize
  400.   #--------------------------------------------------------------------------
  401.   def initialize(type)
  402.     super(250, 340, 300, fitting_height(1))
  403.     self.tone.set(Color.new(0,0,0))
  404.     self.opacity = 0
  405.     self.arrows_visible = false
  406.     self.pause = false
  407.     self.back_opacity = 0
  408.     self.contents_opacity = 255
  409.     self.z = 500
  410.     @type = type
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # * Set Actor
  414.   #--------------------------------------------------------------------------
  415.   def actor=(actor)
  416.     @actor = actor
  417.     refresh
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # * Dispose
  421.   #--------------------------------------------------------------------------
  422.   def update_type=(type)
  423.     @type = type
  424.     refresh
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # * Dispose
  428.   #--------------------------------------------------------------------------
  429.   def dispose
  430.     contents.dispose unless disposed?
  431.     super unless disposed?
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # * Refresh
  435.   #--------------------------------------------------------------------------
  436.   def refresh
  437.     contents.clear
  438.     case @type
  439.     when 1
  440.       draw_text(0, 0, 80, line_height, "WHITE", 0)
  441.       draw_text(90, 0, 80, line_height, "MAGIC", 1)
  442.       draw_text(170, 0, 60, line_height, "LEFT", 1)
  443.       draw_text(230, 0, 30, line_height, @actor.whitespells, 2)
  444.     when 2
  445.       draw_text(0, 0, 80, line_height, "BLACK", 0)
  446.       draw_text(90, 0, 80, line_height, "MAGIC", 1)
  447.       draw_text(170, 0, 60, line_height, "LEFT", 1)
  448.       draw_text(230, 0, 30, line_height, @actor.blackspells, 2)
  449.     when 3
  450.       draw_text(0, 0, 100, line_height, "WIZARD", 0)
  451.       draw_text(90, 0, 80, line_height, "MAGIC", 1)
  452.       draw_text(170, 0, 60, line_height, "LEFT", 1)
  453.       draw_text(230, 0, 30, line_height, @actor.wizardspells, 2)
  454.     end
  455.   end
  456. end
  457.  
  458. #==============================================================================
  459. # ** Window_Spell_Row
  460. #==============================================================================
  461. class KFBQ_Spell_Arrow < Window_Base
  462.   #--------------------------------------------------------------------------
  463.   # * Iniatilize
  464.   #--------------------------------------------------------------------------
  465.   def initialize
  466.     super(255, 295, 50, fitting_height(4))
  467.     self.tone.set(Color.new(0,0,0))
  468.     self.opacity = 0
  469.     self.arrows_visible = false
  470.     self.pause = false
  471.     self.back_opacity = 0
  472.     self.contents_opacity = 255
  473.     self.z = 500
  474.     refresh
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   # * Calculate Height of Window Contents
  478.   #--------------------------------------------------------------------------
  479.   def standard_padding
  480.     return 0
  481.   end
  482.   #--------------------------------------------------------------------------
  483.   # * Dispose
  484.   #--------------------------------------------------------------------------
  485.   def dispose
  486.     contents.dispose unless disposed?
  487.     super unless disposed?
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # * Refresh
  491.   #--------------------------------------------------------------------------
  492.   def refresh
  493.     contents.clear
  494.     bitmap1 = Cache.system("Spell_Arrows")
  495.     rect1 = Rect.new(0, 0, bitmap1.width, bitmap1.height)
  496.     contents.blt(0, 0, bitmap1, rect1, 255)
  497.   end
  498. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement