Advertisement
roninator2

Spell Charge System Base

Nov 17th, 2024 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 61.43 KB | Gaming | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Spell Charge System Base               ║  Version: 1.02     ║
  3. # ║ Author: Roninator2                            ║                    ║
  4. # ╠═══════════════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                                     ║   Date Created     ║
  6. # ║                                               ╠════════════════════╣
  7. # ║  Set system to use Spell Charges              ║    06 Feb 2024     ║
  8. # ╚═══════════════════════════════════════════════╩════════════════════╝
  9. # ╔════════════════════════════════════════════════════════════════════╗
  10. # ║ Requires: nil                                                      ║
  11. # ╚════════════════════════════════════════════════════════════════════╝
  12. # ╔════════════════════════════════════════════════════════════════════╗
  13. # ║ Brief Description:                                                 ║
  14. # ║ Recreates the spell charge system like Final Fantasy 1             ║
  15. # ╚════════════════════════════════════════════════════════════════════╝
  16. # ╔════════════════════════════════════════════════════════════════════╗
  17. # ║ Instructions:                                                      ║
  18. # ║   Configure settings Below                                         ║
  19. # ║   Configure Actors and Classes for FF1 style play                  ║
  20. # ║     i.e. fighters don't use skills or spells.                      ║
  21. # ║   Specify how many charges each class has at what levels           ║
  22. # ║                                                                    ║
  23. # ║ Addional instructions are found below                              ║
  24. # ║                                                                    ║
  25. # ╚════════════════════════════════════════════════════════════════════╝
  26. # ╔════════════════════════════════════════════════════════════════════╗
  27. # ║ Updates:                                                           ║
  28. # ║ 1.00 - 06 Feb 2024 - Script finished                               ║
  29. # ║ 1.01 - 12 Feb 2024 - Cleaned up code                               ║
  30. # ║ 1.02 - 29 Jul 2024 - Fixed Bug                                     ║
  31. # ╚════════════════════════════════════════════════════════════════════╝
  32. # ╔════════════════════════════════════════════════════════════════════╗
  33. # ║ Credits and Thanks:                                                ║
  34. # ║   Roninator2                                                       ║
  35. # ║                                                                    ║
  36. # ╚════════════════════════════════════════════════════════════════════╝
  37. # ╔════════════════════════════════════════════════════════════════════╗
  38. # ║ Terms of use:                                                      ║
  39. # ║  Follow the original Authors terms of use where applicable         ║
  40. # ║    - When not made by me (Roninator2)                              ║
  41. # ║  Free for all uses in RPG Maker except nudity                      ║
  42. # ║  Anyone using this script in their project before these terms      ║
  43. # ║  were changed are allowed to use this script even if it conflicts  ║
  44. # ║  with these new terms. New terms effective 03 Apr 2024             ║
  45. # ║  No part of this code can be used with AI programs or tools        ║
  46. # ║  Credit must be given                                              ║
  47. # ╚════════════════════════════════════════════════════════════════════╝
  48.  
  49. #==============================================================================
  50. # ** Vocab
  51. #==============================================================================
  52. module Vocab
  53.  
  54.   # Spell Screen
  55.   Spell         = "Magic"
  56.   Drop_spell    = "Remove Spell"
  57.   Use_Spell     = "Use Spell"
  58.   Exit_Spell    = "Exit"
  59.   Confirm_Drop  = "Are you sure?"
  60.   Cancel_Drop   = "Return"
  61.  
  62. end
  63.  
  64. #==============================================================================
  65. # ** Spell Charge
  66. #==============================================================================
  67. module Spell_Charge
  68.   # specify to use the chart below or the note tags further down
  69.   USE_CHART = true
  70.  
  71.   # Chart used to specify what spell charges each class will have and
  72.   # how many charges at the actors level
  73.   CHART = {
  74.            :C1 => { # class 1 - Fighter
  75.                  # spell level
  76.                         # levels 1 2 3 4 5... to 28
  77.                         # levels 29 30 31 32.. to 50
  78.                 :L1 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  79.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  80.                 :L2 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  81.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  82.                 :L3 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  83.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  84.                 :L4 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  85.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  86.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  87.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  88.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  89.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  90.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  91.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  92.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  93.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  94.                 },
  95.            :C2 => { # class 2 - Thief
  96.                 :L1 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  97.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  98.                 :L2 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  99.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  100.                 :L3 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  101.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  102.                 :L4 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  103.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  104.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  105.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  106.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  107.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  108.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  109.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  110.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  111.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  112.                 },
  113.            :C3 => { # class 3 - Monk
  114.                 :L1 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  115.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  116.                 :L2 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  117.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  118.                 :L3 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  119.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  120.                 :L4 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  121.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  122.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  123.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  124.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  125.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  126.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  127.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  128.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  129.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  130.                 },
  131.            :C4 => { # class 4 - Red Mage
  132.                 :L1 => [2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,7,7,8,9,9,9,9,9,9,9,
  133.                         9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9],
  134.                 :L2 => [0,1,2,2,3,3,3,4,4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,8,
  135.                         8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9],
  136.                 :L3 => [0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,7,7,
  137.                         7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9],
  138.                 :L4 => [0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,5,5,5,5,5,6,6,6,6,6,
  139.                         6,6,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9],
  140.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,
  141.                         5,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9],
  142.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,
  143.                         5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8],
  144.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,
  145.                         3,3,3,3,4,4,5,5,5,6,6,6,6,6,6,7,7,7,7,7,8,8],
  146.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  147.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  148.                 },
  149.            :C5 => { # class 5 - White Mage
  150.                 :L1 => [2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,
  151.                         9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9],
  152.                 :L2 => [0,1,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,8,
  153.                         8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9],
  154.                 :L3 => [0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,7,7,
  155.                         7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9],
  156.                 :L4 => [0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,
  157.                         7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9],
  158.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,
  159.                         6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9],
  160.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,5,5,5,5,
  161.                         5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9],
  162.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,
  163.                         5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9],
  164.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,
  165.                         3,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,9]
  166.                 },
  167.            :C6 => { # class 6 - Black Mage
  168.                 :L1 => [2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,
  169.                         9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9],
  170.                 :L2 => [0,1,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,8,
  171.                         8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9],
  172.                 :L3 => [0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,7,7,
  173.                         7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9],
  174.                 :L4 => [0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,
  175.                         7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9],
  176.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,
  177.                         6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9],
  178.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,5,5,5,5,
  179.                         5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9],
  180.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,
  181.                         5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9],
  182.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,
  183.                         3,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,9]
  184.                 },
  185.            :C7 => { # class 7 - Knight
  186.                 :L1 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,
  187.                         3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4],
  188.                 :L2 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,
  189.                         2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4],
  190.                 :L3 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,
  191.                         1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4],
  192.                 :L4 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  193.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  194.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  195.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  196.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  197.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  198.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  199.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  200.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  201.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  202.                 },
  203.            :C8 => { # class 8 - Ninja
  204.                 :L1 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,
  205.                         3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4],
  206.                 :L2 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,
  207.                         2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4],
  208.                 :L3 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,
  209.                         1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4],
  210.                 :L4 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  211.                         0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4],
  212.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  213.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  214.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  215.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  216.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  217.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  218.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  219.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  220.                 },
  221.            :C9 => { # class 9 - Master
  222.                 :L1 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  223.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  224.                 :L2 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  225.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  226.                 :L3 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  227.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  228.                 :L4 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  229.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  230.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  231.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  232.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  233.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  234.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  235.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  236.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  237.                         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  238.                 },
  239.            :C10 => { # class 10 - Red Wizard
  240.                 :L1 => [2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,
  241.                         9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9],
  242.                 :L2 => [0,1,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,8,
  243.                         8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9],
  244.                 :L3 => [0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,7,7,
  245.                         7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9],
  246.                 :L4 => [0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,
  247.                         7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9],
  248.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,
  249.                         6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9],
  250.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,5,5,5,5,
  251.                         5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9],
  252.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,
  253.                         5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9],
  254.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,
  255.                         3,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,9]
  256.                 },
  257.            :C11 => { # class 11 - White Wizard
  258.                 :L1 => [2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,
  259.                         9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9],
  260.                 :L2 => [0,1,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,8,
  261.                         8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9],
  262.                 :L3 => [0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,7,7,
  263.                         7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9],
  264.                 :L4 => [0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,
  265.                         7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9],
  266.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,
  267.                         6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9],
  268.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,5,5,5,5,
  269.                         5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9],
  270.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,
  271.                         5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9],
  272.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,
  273.                         3,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,9]
  274.                 },
  275.            :C12 => { # class 12 - Black Wizard
  276.                 :L1 => [2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,
  277.                         9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9],
  278.                 :L2 => [0,1,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,8,
  279.                         8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9],
  280.                 :L3 => [0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,7,7,
  281.                         7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9],
  282.                 :L4 => [0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,
  283.                         7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9],
  284.                 :L5 => [0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,
  285.                         6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9],
  286.                 :L6 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,5,5,5,5,
  287.                         5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9],
  288.                 :L7 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,4,4,4,
  289.                         5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9],
  290.                 :L8 => [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,
  291.                         3,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,9]
  292.                 },
  293.         }
  294. #==============================================================================
  295. # ** Spell Options
  296. #==============================================================================
  297.   module Options
  298.    
  299.     # Recover Spell uses on leveling up
  300.     RECOVER_SPELLS_ON_LEVEL_UP = false
  301.    
  302.     # Recover Spell uses on leveling up
  303.     SHOW_SPELLS_ON_ALL = false
  304.    
  305.     # Specify if your game will use this magic system
  306.     # and the default skill system. true or false
  307.     INCLUDE_SKILLS = false
  308.    
  309.     # the below options are for the regex system
  310.    
  311.     # maximum number of spells you can use per tier i.e. 9 for FF1
  312.     # this is the heart of the spell charge system
  313.     # 9 means you can use that tier's spells 9 times
  314.     MAX_SPELLS = 9 # global for all magic users
  315.    
  316.     # maximum number of tiers that each magic user will have
  317.     MAX_TIERS = 8 # global for all magic users
  318.    
  319.     # maximum number of spells that can be learned for each tier. i.e. 3 for FF1
  320.     MAX_PER_LEVEL = 3 # global for all magic users
  321.    
  322.   end
  323.  
  324. #==============================================================================
  325. # ** Regex Method
  326. #==============================================================================
  327.   module Regex
  328.    
  329.     # ╔══════════════════════════════════════════════════════════╗
  330.     # ║ Instructions:                                            ║
  331.     # ║                                                          ║
  332.     # ║ Note tags                                                ║
  333.     # ║   Skills                                                 ║
  334.     # ║     <spell level: 1>                                     ║
  335.     # ║       Will make the skill as a level 1 skill             ║
  336.     # ║                                                          ║
  337.     # ║   Class                                                  ║
  338.     # ║    <spell gain: spell level, starting actor level,       ║
  339.     # ║                gain amount, every # levels>              ║
  340.     # ║      <spell gain: 1, 1, 1, 3>                            ║
  341.     # ║        Will mark the actor as learning 1 additional      ║
  342.     # ║        level one spell charge every 3 levels             ║
  343.     # ║        starting from level 1                             ║
  344.     # ║                                                          ║
  345.     # ║    <spell bonus: spell level, amount>                    ║
  346.     # ║      <spell bonus: 1, 2>                                 ║
  347.     # ║      <spell bonus: 2, 1>                                 ║
  348.     # ║      You do not need to use a tag for no bonus added     ║
  349.     # ║      Will mark the actor as starting with 2 uses         ║
  350.     # ║      of the level 1 spells                               ║
  351.     # ║    This is a bonus to the spell gain.                    ║
  352.     # ║    At level one the player will get 3 spell uses for     ║
  353.     # ║    level 1 as shown.                                     ║
  354.     # ║      <spell start: 1, 2> + <spell gain: 1, 1, 1, 3>      ║
  355.     # ║                       ▲                       ▲          ║
  356.     # ║    Spell level 1 will have 2 + 1 uses                    ║
  357.     # ║                                                          ║
  358.     # ╚══════════════════════════════════════════════════════════╝
  359.     # Skill notetag
  360.     # <spell tier: 1> # for Ff1 there are 8 spell tiers (levels)
  361.     SPELL_LEVEL = /<spell[ -_]level:[ -_](\d+)>/i
  362.    
  363.     # How fast new spell uses are earned
  364.     # NOTE - Place on class or actor
  365.     # <spell gain: spell tier, actor level, gain amount, every # levels>
  366.     # <spell gain:      1,           1,           1,          4>
  367.     # <spell gain: 1, 1, 1, 4>
  368.     SPELL_GAIN = /<spell[ -_]gain:[ -_](\d+),[ -_](\d+),[ -_](\d+),[ -_](\d+)>/i
  369.    
  370.     # How many uses to have when starting a new game
  371.     # NOTE - Place on class or actor
  372.     # <spell bonus: spell level, amount>
  373.     # <spell bonus:      1,        2>
  374.     # <spell bonus: 1, 2>
  375.     SPELL_BONUS = /<spell[ -_]bonus:[ ](\d+),[ -_](\d+)>/i
  376.     # This must go below the spell gain note tag
  377.    
  378.   end
  379.  
  380. #==============================================================================
  381. # ** Spell Settings
  382. #==============================================================================
  383.   module Spell
  384.     # ╔══════════════════════════════════════════════════════════╗
  385.     # ║ Instructions:                                            ║
  386.     # ║                                                          ║
  387.     # ║ Note tags                                                ║
  388.     # ║   Skills                                                 ║
  389.     # ║     <spell level: 1>                                     ║
  390.     # ║       Will make the skill a level 1 spell                ║
  391.     # ║                                                          ║
  392.     # ║     <spell user: true>                                   ║
  393.     # ║       Will mark the class as able to use spells          ║
  394.     # ║                                                          ║
  395.     # ║     <class learn: class id, class id...>                 ║
  396.     # ║       will specify what classes can learn the spell      ║
  397.     # ║                                                          ║
  398.     # ╚══════════════════════════════════════════════════════════╝
  399.    
  400.     # Skill notetag
  401.     # <spell user: true> # specify if the class can use spells
  402.     # combines with SHOW_SPELLS_ON_ALL. if a magic user, spell count is shown
  403.     SPELL_USER = /<spell[ -_]user:[ -_](\w*)>/i
  404.    
  405.     # Skill notetag
  406.     # <class learn: 4, 5, 7, 10, 11> # specify what classes can learn the skill
  407.     CLASS_LEARN = /<class[ -_]learn:([ -_](\d+)(?:|(,[ -_])(\d+))*)>/i
  408.    
  409.     # Skill notetag
  410.     # <spell level: 1> # spell tier (level)
  411.     SPELL_LEVEL = /<spell[ -_]level:[ -_](\d+)>/i
  412.    
  413.   end
  414. end
  415. # ╔══════════════════════════════════════════════════════════╗
  416. # ║              End of Editable section                     ║
  417. # ╚══════════════════════════════════════════════════════════╝
  418.  
  419.  
  420.  
  421. #==============================================================================
  422. # * DataManager
  423. #==============================================================================
  424. module DataManager
  425.   #--------------------------------------------------------------------------
  426.   # alias method: load_database
  427.   #--------------------------------------------------------------------------
  428.   class <<self; alias load_database_spellclass load_database; end
  429.   def self.load_database
  430.     load_database_spellclass
  431.     initialize_spellclass
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # new method: initialize_spellgroup
  435.   #--------------------------------------------------------------------------
  436.   def self.initialize_spellclass
  437.     groups = [$data_classes, $data_skills]
  438.     for group in groups
  439.       for obj in group
  440.         next if obj.nil?
  441.           obj.initialize_spellclass
  442.       end
  443.     end
  444.   end
  445. end
  446.  
  447. #==============================================================================
  448. # * RPG::BaseItem
  449. #==============================================================================
  450. class RPG::Skill < RPG::UsableItem
  451.   attr_accessor :spell_tier
  452.   attr_accessor :spell_cost
  453.   attr_accessor :spell_level
  454.   attr_accessor :class_learn
  455.   #--------------------------------------------------------------------------
  456.   # new method: initialize_spellgroup
  457.   #--------------------------------------------------------------------------
  458.   def initialize_spellclass
  459.     @spell_tier = 0
  460.     @spell_cost = 0
  461.     @spell_level = 0
  462.     @class_learn = []
  463.     self.note.split(/[\r\n]+/).each { |line|
  464.       case line
  465.       when Spell_Charge::Regex::SPELL_LEVEL
  466.         @spell_tier = $1.to_i
  467.       when Spell_Charge::Spell::SPELL_COST
  468.         @spell_cost = $1.to_i
  469.       when Spell_Charge::Spell::SPELL_LEVEL
  470.         @spell_level = $1.to_i
  471.       when Spell_Charge::Spell::CLASS_LEARN
  472.         @class_learn = $1.split(/,\s*/).collect {|item| item.to_i }
  473.       end
  474.     }
  475.   end
  476. end
  477.  
  478. #==============================================================================
  479. # ** Game_BattlerBase
  480. #==============================================================================
  481. class Game_BattlerBase
  482.   #--------------------------------------------------------------------------
  483.   # * Determine Skill/Item Usability
  484.   #--------------------------------------------------------------------------
  485.   def skill_purchase?(item)
  486.     return true if item.class_learn.include?(self.class_id)
  487.     return false
  488.   end
  489. end
  490.  
  491. #==============================================================================
  492. # * Game_Battler
  493. #==============================================================================
  494. class Game_Battler < Game_BattlerBase
  495.   #--------------------------------------------------------------------------
  496.   # * Determine if Cost of Using Skill Can Be Paid
  497.   #--------------------------------------------------------------------------
  498.   def skill_cost_payable?(skill)
  499.     if self.is_a?(Game_Actor)
  500.       case skill.spell_tier
  501.       when 1..Spell_Charge::Options::MAX_TIERS
  502.         return true if self.spell_count[skill.spell_tier] > 0
  503.         return false if self.spell_count[skill.spell_tier] <= 0
  504.       else
  505.         tp >= skill_tp_cost(skill) && mp >= skill_mp_cost(skill)
  506.       end
  507.     else
  508.       tp >= skill_tp_cost(skill) && mp >= skill_mp_cost(skill)
  509.     end
  510.   end
  511.   #--------------------------------------------------------------------------
  512.   # * Pay Cost of Using Skill
  513.   #--------------------------------------------------------------------------
  514.   def pay_skill_cost(skill)
  515.     if self.is_a?(Game_Actor)
  516.       case skill.spell_tier
  517.       when 1..Spell_Charge::Options::MAX_TIERS
  518.         self.spell_count[skill.spell_tier] -= 1
  519.       else
  520.         self.mp -= skill_mp_cost(skill)
  521.         self.tp -= skill_tp_cost(skill)
  522.       end
  523.     else
  524.       self.mp -= skill_mp_cost(skill)
  525.       self.tp -= skill_tp_cost(skill)
  526.     end
  527.   end
  528. end
  529.  
  530. #==============================================================================
  531. # * RPG::Class
  532. #==============================================================================
  533. class RPG::Class < RPG::BaseItem
  534.   attr_accessor :spell_gain
  535.   attr_accessor :spell_bonus
  536.   attr_reader :spell_user
  537.   #--------------------------------------------------------------------------
  538.   # new method: initialize_spellgroup
  539.   #--------------------------------------------------------------------------
  540.   def initialize_spellclass
  541.     @spell_gain = []
  542.     @spell_bonus = []
  543.     @spell_user = false
  544.     self.note.split(/[\r\n]+/).each { |line|
  545.       case line
  546.       when Spell_Charge::Regex::SPELL_GAIN
  547.         @spell_gain[$1.to_i] = [$2.to_i, $3.to_i, $4.to_i]
  548.       when Spell_Charge::Regex::SPELL_BONUS
  549.         @spell_bonus[$1.to_i] = $2.to_i
  550.       when Spell_Charge::Spell::SPELL_USER
  551.         @spell_user = $1.downcase == "true" ? true : false
  552.       end
  553.     }
  554.   end
  555. end
  556.  
  557. #==============================================================================
  558. # ** Game_Actor
  559. #==============================================================================
  560. class Game_Actor < Game_Battler
  561.   #--------------------------------------------------------------------------
  562.   # * Public Instance Variables
  563.   #--------------------------------------------------------------------------
  564.   attr_reader :spell_gain
  565.   attr_accessor :spell_count
  566.   attr_accessor :spell_list
  567.   attr_accessor :spell_max_count
  568.   #--------------------------------------------------------------------------
  569.   # * Setup
  570.   #--------------------------------------------------------------------------
  571.   alias r2_actor_spells_setup   setup
  572.   def setup(actor_id)
  573.     @spell_max_count = []
  574.     @spell_count = []
  575.     @spell_list = {}
  576.     r2_actor_spells_setup(actor_id)
  577.     setup_spells
  578.   end
  579.   #--------------------------------------------------------------------------
  580.   # * Add Actor Spell Counts
  581.   #--------------------------------------------------------------------------
  582.   def setup_spells
  583.     if Spell_Charge::USE_CHART
  584.       chart_spells
  585.       @spell_gain = nil
  586.     else
  587.       add_new_spell_count
  588.     end
  589.   end
  590.   #--------------------------------------------------------------------------
  591.   # * Learn Spell
  592.   #--------------------------------------------------------------------------
  593.   def learn_spell(skill_id)
  594.     spell = $data_skills[skill_id]
  595.     return unless spell_learn?(spell)
  596.     lvl = spell.spell_level
  597.     if @spell_list[lvl].nil?
  598.       @spell_list[lvl] = []
  599.     end
  600.     tier = @spell_list[lvl].size
  601.     @spell_list[lvl].push(skill_id) if tier != Spell_Charge::Options::MAX_PER_LEVEL
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # * Determine if Spell Is Already Learned
  605.   #--------------------------------------------------------------------------
  606.   def spell_learn?(spell)
  607.     can_learn = spell.class_learn
  608.     return false if !can_learn.include?(self.class_id)
  609.     if @spell_list[spell.spell_level].nil?
  610.       return true if spell.is_a?(RPG::Skill)
  611.     else
  612.       return true if spell.is_a?(RPG::Skill) &&
  613.       !@spell_list[spell.spell_level].include?(spell.id)
  614.     end
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # * Recover All
  618.   #--------------------------------------------------------------------------
  619.   alias :r2_recover_all_spells  :recover_all
  620.   def recover_all
  621.     r2_recover_all_spells
  622.     restore_spells(true)
  623.   end
  624.   #--------------------------------------------------------------------------
  625.   # * Level Up
  626.   #--------------------------------------------------------------------------
  627.   alias :r2_level_up_recover_spells   :level_up
  628.   def level_up
  629.     r2_level_up_recover_spells
  630.     restore_spells(false)
  631.   end
  632.   #--------------------------------------------------------------------------
  633.   # * Restore spells
  634.   #--------------------------------------------------------------------------
  635.   def restore_spells(restore)
  636.     return if actor.nil?
  637.     current_count = []
  638.     current_count = Marshal.load( Marshal.dump(@spell_count) )
  639.     if Spell_Charge::USE_CHART
  640.       chart_spells
  641.     else
  642.       add_new_spell_count
  643.     end
  644.     @spell_count = Marshal.load( Marshal.dump(current_count) ) if !Spell_Charge::Options::RECOVER_SPELLS_ON_LEVEL_UP
  645.     @spell_count = Marshal.load( Marshal.dump(@spell_max_count) ) if restore
  646.   end
  647.   #--------------------------------------------------------------------------
  648.   # * Chart spells
  649.   #--------------------------------------------------------------------------
  650.   def chart_spells
  651.     sp_cls = "C#{self.class_id}".to_sym
  652.     chart_list = Spell_Charge::CHART[sp_cls]
  653.     i = 1
  654.     chart_list.each do |key, value|
  655.       @spell_count[i] = value[self.level - 1]
  656.       @spell_max_count[i] = value[self.level - 1]
  657.       i += 1
  658.     end
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # * Change Maximum spell count for using note tags
  662.   #--------------------------------------------------------------------------
  663.   def add_new_spell_count
  664.     gain = $data_classes[self.class_id].spell_gain
  665.     bonus = $data_classes[self.class_id].spell_bonus
  666.     (Spell_Charge::Options::MAX_TIERS + 1).times { |ch| bonus[ch] = 0 if bonus[ch].nil? }
  667.     gain.each_with_index do |data, i|
  668.       next if data.nil?
  669.       @spell_max_count[i] = 0 if @spell_count[i] == nil
  670.       next if data[0] > self.level
  671.       # do math
  672.       gnamt = 0
  673.       gnamt = ((self.level - data[0]) / data[2]).to_i if self.level > data[0]
  674.       addsp = gnamt * data[1]
  675.       addsp += 1 if self.level >= data[0]
  676.       amt = (bonus[i] + addsp)
  677.       amt = Spell_Charge::Options::MAX_SPELLS if amt >= Spell_Charge::Options::MAX_SPELLS
  678.       @spell_max_count[i] = amt
  679.     end
  680.   end
  681. end
  682.  
  683. #==============================================================================
  684. # ** Window_MenuStatus
  685. #==============================================================================
  686. class Window_MenuStatus < Window_Selectable
  687.   #--------------------------------------------------------------------------
  688.   # * Draw Spell Charges
  689.   #--------------------------------------------------------------------------
  690.   def draw_spell_charge(actor, x, y, width = 124)
  691.     if Spell_Charge::Options::SHOW_SPELLS_ON_ALL
  692.       change_color(system_color)
  693.       draw_text(x, y, 60, line_height, "Spells")
  694.       change_color(normal_color)
  695.       cls_id = actor.class_id
  696.       spells = ""
  697.       actor.spell_count.each_with_index do |sp, i|
  698.         next if i == 0
  699.         spells += sp.to_s
  700.         spells += "/" if i != actor.spell_count.size - 1
  701.       end
  702.       draw_text(x+60, y, 170, line_height, spells)
  703.     else
  704.       return unless actor.class.spell_user
  705.       change_color(system_color)
  706.       draw_text(x, y, 60, line_height, "Spells")
  707.       change_color(normal_color)
  708.       cls_id = actor.class_id
  709.       spells = ""
  710.       actor.spell_count.each_with_index do |sp, i|
  711.         next if i == 0
  712.         spells += sp.to_s
  713.         spells += "/" if i != actor.spell_count.size - 1
  714.       end
  715.       draw_text(x+60, y, 170, line_height, spells)
  716.     end
  717.   end
  718.   #--------------------------------------------------------------------------
  719.   # * Draw Simple Status
  720.   #--------------------------------------------------------------------------
  721.   def draw_actor_simple_status(actor, x, y)
  722.     draw_actor_name(actor, x, y)
  723.     draw_actor_level(actor, x, y + line_height * 1)
  724.     draw_actor_icons(actor, x, y + line_height * 2)
  725.     draw_actor_class(actor, x + 120, y)
  726.     draw_actor_hp(actor, x + 120, y + line_height * 1, 210)
  727.     draw_spell_charge(actor, x + 120, y + line_height * 2)
  728.   end
  729. end
  730.  
  731. #==============================================================================
  732. # ** Window_Spell_List
  733. #==============================================================================
  734.  
  735. class Window_Spell_List < Window_Selectable
  736.   #--------------------------------------------------------------------------
  737.   # * Object Initialization
  738.   #--------------------------------------------------------------------------
  739.   def initialize(x, y, width, height)
  740.     super
  741.     @actor = nil
  742.     @data = []
  743.     @drop = false
  744.   end
  745.   #--------------------------------------------------------------------------
  746.   # * Set Actor
  747.   #--------------------------------------------------------------------------
  748.   def actor=(actor)
  749.     return if @actor == actor
  750.     @actor = actor
  751.     refresh
  752.     self.oy = 0
  753.   end
  754.   #--------------------------------------------------------------------------
  755.   # * Get Digit Count
  756.   #--------------------------------------------------------------------------
  757.   def col_max
  758.     @actor ? Spell_Charge::Options::MAX_PER_LEVEL : 3
  759.   end
  760.   #--------------------------------------------------------------------------
  761.   # * Get Number of Items
  762.   #--------------------------------------------------------------------------
  763.   def item_max
  764.     if Spell_Charge::USE_CHART
  765.       @data ? col_max * Spell_Charge::Options::MAX_TIERS : 0
  766.     else
  767.       @data ? col_max * (@actor.spell_count.size - 1) : 0
  768.     end
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # * Get Item Width
  772.   #--------------------------------------------------------------------------
  773.   def item_width
  774.     (width - 100 - standard_padding * 2 + spacing) / col_max - spacing - 10
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # * Get Skill
  778.   #--------------------------------------------------------------------------
  779.   def item
  780.     return nil if @index < 0
  781.     lvl = (@index / 3).to_i
  782.     ind = @index % 3
  783.     item = @data[lvl][ind] if @data[lvl] != nil
  784.     spell = $data_skills[item] if item != nil
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # * Get Row Count
  788.   #--------------------------------------------------------------------------
  789.   def row_max
  790.     @actor ? @actor.spell_count.size - 1 : Spell_Charge::Options::MAX_TIERS
  791.   end
  792.   #--------------------------------------------------------------------------
  793.   # * Get Activation State of Selection Item
  794.   #--------------------------------------------------------------------------
  795.   def current_item_enabled?
  796.     return false if @index < 0
  797.     lvl = (@index / 3).to_i
  798.     ind = @index % 3
  799.     item = @data[lvl][ind] if @data[lvl] != nil
  800.     spell = $data_skills[item] if item != nil
  801.     return false if spell.nil?
  802.     enable?(spell)
  803.   end
  804.   #--------------------------------------------------------------------------
  805.   # * Include in Skill List?
  806.   #--------------------------------------------------------------------------
  807.   def include?(item)
  808.     return true
  809.   end
  810.   #--------------------------------------------------------------------------
  811.   # * Display Skill in Active State?
  812.   #--------------------------------------------------------------------------
  813.   def enable?(item)
  814.     return true if @drop
  815.     @actor && @actor.usable?(item)
  816.   end
  817.   #--------------------------------------------------------------------------
  818.   # * remove spell from actor list
  819.   #--------------------------------------------------------------------------
  820.   def drop_spell
  821.     lvl = (@index / 3).to_i
  822.     ind = @index % 3
  823.     @actor.spell_list[lvl].delete_at(ind)
  824.     refresh
  825.   end
  826.   #--------------------------------------------------------------------------
  827.   # * Display Skill in Active State?
  828.   #--------------------------------------------------------------------------
  829.   def all_select
  830.     @drop = true
  831.   end
  832.   #--------------------------------------------------------------------------
  833.   # * Display Skill in Active State?
  834.   #--------------------------------------------------------------------------
  835.   def no_select
  836.     @drop = false
  837.   end
  838.   #--------------------------------------------------------------------------
  839.   # * Create Skill List
  840.   #--------------------------------------------------------------------------
  841.   def make_item_list
  842.     @data = @actor ? @actor.spell_list : []
  843.   end
  844.   #--------------------------------------------------------------------------
  845.   # * Restore Previous Selection Position
  846.   #--------------------------------------------------------------------------
  847.   def select_last
  848.     select(@data.index(@actor.last_skill.object) || 0)
  849.   end
  850.   #--------------------------------------------------------------------------
  851.   # * Draw skill levels
  852.   #--------------------------------------------------------------------------
  853.   def draw_spell_tier(i)
  854.     spells = @actor.spell_list[i]
  855.     return if spells == nil
  856.     Spell_Charge::Options::MAX_PER_LEVEL.times do |s|
  857.       num = spells[s]
  858.       next if num.nil?
  859.       spell = $data_skills[num]
  860.       rect = spell_rect(i, s)
  861.       rect.width -= 4
  862.       rect.x += 60
  863.       draw_item_name(spell, rect.x, rect.y, enable?(spell))
  864.     end
  865.   end
  866.   #--------------------------------------------------------------------------
  867.   # * Draw Item Name
  868.   #     enabled : Enabled flag. When false, draw semi-transparently.
  869.   #--------------------------------------------------------------------------
  870.   def draw_item_name(item, x, y, enabled = true, width = 172)
  871.     return unless item
  872.     draw_icon(item.icon_index, x, y, enabled)
  873.     change_color(normal_color, enabled)
  874.     draw_text(x + 24, y, width, line_height, item.name, 1)
  875.   end
  876.   #--------------------------------------------------------------------------
  877.   # * Get Rectangle for Drawing Items
  878.   #--------------------------------------------------------------------------
  879.   def spell_rect(i, s)
  880.     rect = Rect.new
  881.     rect.width = item_width
  882.     rect.height = item_height
  883.     rect.x = s % col_max * (item_width + spacing)
  884.     rect.y = i / row_max * item_height
  885.     rect
  886.   end
  887.   #--------------------------------------------------------------------------
  888.   # * Draw spell
  889.   #--------------------------------------------------------------------------
  890.   def draw_spell_levels(size)
  891.     y = 0
  892.     size.times do |i|
  893.       text = "LEVEL: #{i+1}"
  894.       draw_text(0, y, 100, 24, text)
  895.       y += 24
  896.     end
  897.   end
  898.   #--------------------------------------------------------------------------
  899.   # * Draw skill count per level
  900.   #--------------------------------------------------------------------------
  901.   def draw_spell_count(size)
  902.     y = 0
  903.     change_color(normal_color)
  904.     size.times do |i|
  905.       text = "#{@actor.spell_count[i+1]}"
  906.       draw_text(Graphics.width - 45, y, 40, 24, text)
  907.       y += 24
  908.     end
  909.   end
  910.   #--------------------------------------------------------------------------
  911.   # * Draw All Items
  912.   #--------------------------------------------------------------------------
  913.   def draw_all_items
  914.     size = @actor.spell_count.size - 1
  915.     draw_spell_levels(size)
  916.     @actor ? size.times { |i| draw_spell_tier(i) } : nil
  917.     draw_spell_count(size)
  918.   end
  919.   #--------------------------------------------------------------------------
  920.   # * Update Help Text
  921.   #--------------------------------------------------------------------------
  922.   def update_help
  923.     return if @index < 0
  924.     lvl = (@index / 3).to_i
  925.     ind = @index % 3
  926.     item = @data[lvl][ind] if @data[lvl] != nil
  927.     spell = $data_skills[item] if item != nil
  928.     @help_window.set_item(spell)
  929.   end
  930.   #--------------------------------------------------------------------------
  931.   # * Refresh
  932.   #--------------------------------------------------------------------------
  933.   def refresh
  934.     make_item_list
  935.     create_contents
  936.     draw_all_items
  937.   end
  938.   #--------------------------------------------------------------------------
  939.   # * Update Cursor
  940.   #--------------------------------------------------------------------------
  941.   def update_cursor
  942.     if @cursor_all
  943.       cursor_rect.set(0, 0, contents.width, row_max * item_height)
  944.       self.top_row = 0
  945.     elsif @index < 0
  946.       cursor_rect.empty
  947.     else
  948.       ensure_cursor_visible
  949.       cursor_rect.set(item_rect(@index))
  950.       cursor_rect.x += 100
  951.     end
  952.   end
  953. end
  954.  
  955.  
  956. #==============================================================================
  957. # ** Window_MenuCommand
  958. #==============================================================================
  959.  
  960. class Window_MenuCommand < Window_Command
  961.   #--------------------------------------------------------------------------
  962.   # * Add Main Commands to List
  963.   #--------------------------------------------------------------------------
  964.   def add_main_commands
  965.     add_command(Vocab::item,   :item,   main_commands_enabled)
  966.     add_command(Vocab::Spell,  :spell,  main_commands_enabled)
  967.     add_command(Vocab::skill,  :skill,  main_commands_enabled) if Spell_Charge::Options::INCLUDE_SKILLS
  968.     add_command(Vocab::equip,  :equip,  main_commands_enabled)
  969.     add_command(Vocab::status, :status, main_commands_enabled)
  970.   end
  971. end
  972.  
  973. #==============================================================================
  974. # ** Scene_Menu
  975. #==============================================================================
  976. class Scene_Menu < Scene_MenuBase
  977.   #--------------------------------------------------------------------------
  978.   # * Create Command Window
  979.   #--------------------------------------------------------------------------
  980.   alias :r2_scene_spell_command   :create_command_window
  981.   def create_command_window
  982.     r2_scene_spell_command
  983.     @command_window.set_handler(:spell,     method(:command_personal))
  984.   end
  985.   #--------------------------------------------------------------------------
  986.   # * [OK] Personal Command
  987.   #--------------------------------------------------------------------------
  988.   alias :r2_personal_ok_spell_scene   :on_personal_ok
  989.   def on_personal_ok
  990.     r2_personal_ok_spell_scene
  991.     case @command_window.current_symbol
  992.     when :spell
  993.       SceneManager.call(Scene_Spell)
  994.     end
  995.   end
  996. end
  997.  
  998. #==============================================================================
  999. # ** Window_SpellCommand
  1000. #==============================================================================
  1001.  
  1002. class Window_SpellCommand < Window_Command
  1003.   #--------------------------------------------------------------------------
  1004.   # * Object Initialization
  1005.   #--------------------------------------------------------------------------
  1006.   def initialize(x, y)
  1007.     super(x, y)
  1008.     @actor = nil
  1009.   end
  1010.   #--------------------------------------------------------------------------
  1011.   # * Get Window Width
  1012.   #--------------------------------------------------------------------------
  1013.   def window_width
  1014.     return 160
  1015.   end
  1016.   #--------------------------------------------------------------------------
  1017.   # * Set Actor
  1018.   #--------------------------------------------------------------------------
  1019.   def actor=(actor)
  1020.     return if @actor == actor
  1021.     @actor = actor
  1022.     refresh
  1023.     select(0)
  1024.   end
  1025.   #--------------------------------------------------------------------------
  1026.   # * Get Number of Lines to Show
  1027.   #--------------------------------------------------------------------------
  1028.   def visible_line_number
  1029.     return 4
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # * Create Command List
  1033.   #--------------------------------------------------------------------------
  1034.   def make_command_list
  1035.     return unless @actor
  1036.     add_command(Vocab::Use_Spell,   :use)
  1037.     add_command(Vocab::Drop_spell,  :drop)
  1038.     add_command(Vocab::Exit_Spell,  :cancel)
  1039.   end
  1040. end
  1041.  
  1042. #==============================================================================
  1043. # ** Window_SpellStatus
  1044. #==============================================================================
  1045.  
  1046. class Window_SpellStatus < Window_Base
  1047.   #--------------------------------------------------------------------------
  1048.   # * Object Initialization
  1049.   #--------------------------------------------------------------------------
  1050.   def initialize(x, y)
  1051.     super(x, y, window_width, fitting_height(4))
  1052.     @actor = nil
  1053.   end
  1054.   #--------------------------------------------------------------------------
  1055.   # * Get Window Width
  1056.   #--------------------------------------------------------------------------
  1057.   def window_width
  1058.     Graphics.width - 160
  1059.   end
  1060.   #--------------------------------------------------------------------------
  1061.   # * Actor Settings
  1062.   #--------------------------------------------------------------------------
  1063.   def actor=(actor)
  1064.     return if @actor == actor
  1065.     @actor = actor
  1066.     refresh
  1067.   end
  1068.   #--------------------------------------------------------------------------
  1069.   # * Refresh
  1070.   #--------------------------------------------------------------------------
  1071.   def refresh
  1072.     contents.clear
  1073.     return unless @actor
  1074.     draw_actor_face(@actor, 0, 0)
  1075.     draw_actor_simple_status(@actor, 108, line_height / 2)
  1076.   end
  1077.   #--------------------------------------------------------------------------
  1078.   # * Draw Spell Charges
  1079.   #--------------------------------------------------------------------------
  1080.   def draw_spell_charge(actor, x, y, width = 124)
  1081.     if Spell_Charge::Options::SHOW_SPELLS_ON_ALL
  1082.       change_color(system_color)
  1083.       draw_text(x, y, 60, line_height, "Spells")
  1084.       change_color(normal_color)
  1085.       cls_id = actor.class_id
  1086.       spells = ""
  1087.       actor.spell_count.each_with_index do |sp, i|
  1088.         next if i == 0
  1089.         spells += sp.to_s
  1090.         spells += "/" if i != actor.spell_count.size - 1
  1091.       end
  1092.       draw_text(x+60, y, 170, line_height, spells)
  1093.     else
  1094.       return unless actor.class.spell_user
  1095.       change_color(system_color)
  1096.       draw_text(x, y, 60, line_height, "Spells")
  1097.       change_color(normal_color)
  1098.       cls_id = actor.class_id
  1099.       spells = ""
  1100.       actor.spell_count.each_with_index do |sp, i|
  1101.         next if i == 0
  1102.         spells += sp.to_s
  1103.         spells += "/" if i != actor.spell_count.size - 1
  1104.       end
  1105.       draw_text(x+60, y, 170, line_height, spells)
  1106.     end
  1107.   end
  1108.   #--------------------------------------------------------------------------
  1109.   # * Draw Simple Status
  1110.   #--------------------------------------------------------------------------
  1111.   def draw_actor_simple_status(actor, x, y)
  1112.     draw_actor_name(actor, x, y)
  1113.     draw_actor_level(actor, x, y + line_height * 1)
  1114.     draw_actor_icons(actor, x, y + line_height * 2)
  1115.     draw_actor_class(actor, x + 120, y)
  1116.     draw_actor_hp(actor, x + 120, y + line_height * 1, 210)
  1117.     draw_spell_charge(actor, x + 120, y + line_height * 2)
  1118.   end
  1119. end
  1120.  
  1121. #==============================================================================
  1122. # ** Window Confirm Drop Spell
  1123. #==============================================================================
  1124. class Window_Confirm_Drop_Spell < Window_Command
  1125.   def initialize
  1126.     super(0, 0)
  1127.     self.back_opacity = 255
  1128.     move_window
  1129.   end
  1130.  
  1131.   def window_width
  1132.     return 200
  1133.   end
  1134.  
  1135.   def move_window
  1136.     self.x = (Graphics.width - width) / 2
  1137.     self.y = Graphics.height / 2
  1138.   end
  1139.  
  1140.   def update_help
  1141.   end
  1142.  
  1143.   def make_command_list
  1144.     add_command(Vocab::Confirm_Drop, :on_drop_ok)
  1145.     add_command(Vocab::Cancel_Drop, :on_drop_cancel)
  1146.   end
  1147.  
  1148.   def alignment
  1149.     return 1
  1150.   end
  1151. end
  1152.  
  1153. #==============================================================================
  1154. # ** Scene_Skill
  1155. #==============================================================================
  1156.  
  1157. class Scene_Spell < Scene_ItemBase
  1158.   #--------------------------------------------------------------------------
  1159.   # * Start Processing
  1160.   #--------------------------------------------------------------------------
  1161.   def start
  1162.     super
  1163.     create_help_window
  1164.     create_command_window
  1165.     create_status_window
  1166.     create_item_window
  1167.     create_confirm_window
  1168.   end
  1169.   #--------------------------------------------------------------------------
  1170.   # * Create Command Window
  1171.   #--------------------------------------------------------------------------
  1172.   def create_command_window
  1173.     wy = @help_window.height
  1174.     @command_window = Window_SpellCommand.new(0, wy)
  1175.     @command_window.viewport = @viewport
  1176.     @command_window.help_window = @help_window
  1177.     @command_window.actor = @actor
  1178.     @command_window.set_handler(:use,    method(:command_use))
  1179.     @command_window.set_handler(:drop,    method(:command_drop))
  1180.     @command_window.set_handler(:cancel,   method(:return_scene))
  1181.     @command_window.set_handler(:pagedown, method(:next_actor))
  1182.     @command_window.set_handler(:pageup,   method(:prev_actor))
  1183.   end
  1184.   #--------------------------------------------------------------------------
  1185.   # * Create Status Window
  1186.   #--------------------------------------------------------------------------
  1187.   def create_status_window
  1188.     y = @help_window.height
  1189.     @status_window = Window_SpellStatus.new(@command_window.width, y)
  1190.     @status_window.viewport = @viewport
  1191.     @status_window.actor = @actor
  1192.   end
  1193.   #--------------------------------------------------------------------------
  1194.   # * Create Item Window
  1195.   #--------------------------------------------------------------------------
  1196.   def create_item_window
  1197.     wx = 0
  1198.     wy = @status_window.y + @status_window.height
  1199.     ww = Graphics.width
  1200.     wh = Graphics.height - wy
  1201.     @item_window = Window_Spell_List.new(wx, wy, ww, wh)
  1202.     @item_window.actor = @actor
  1203.     @item_window.viewport = @viewport
  1204.     @item_window.help_window = @help_window
  1205.     @item_window.set_handler(:ok,     method(:on_item_ok))
  1206.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  1207.   end
  1208.   #--------------------------------------------------------------------------
  1209.   # * Create Confirm Window
  1210.   #--------------------------------------------------------------------------
  1211.   def create_confirm_window
  1212.     @confirm_window = Window_Confirm_Drop_Spell.new
  1213.     @confirm_window.z = 201
  1214.     @confirm_window.hide.deactivate
  1215.     @confirm_window.set_handler(:ok,     method(:on_drop_ok))
  1216.     @confirm_window.set_handler(:cancel, method(:on_drop_cancel))
  1217.   end
  1218.   #--------------------------------------------------------------------------
  1219.   # * Get Skill's User
  1220.   #--------------------------------------------------------------------------
  1221.   def user
  1222.     @actor
  1223.   end
  1224.   #--------------------------------------------------------------------------
  1225.   # * [Skill] Command
  1226.   #--------------------------------------------------------------------------
  1227.   def command_use
  1228.     @item_window.activate
  1229.     @item_window.select(0)
  1230.   end
  1231.   #--------------------------------------------------------------------------
  1232.   # * [Skill] Command
  1233.   #--------------------------------------------------------------------------
  1234.   def command_drop
  1235.     @item_window.activate
  1236.     @item_window.all_select
  1237.     @item_window.select(0)
  1238.   end
  1239.   #--------------------------------------------------------------------------
  1240.   # * Item [OK]
  1241.   #--------------------------------------------------------------------------
  1242.   def on_item_ok
  1243.     @actor.last_skill.object = item
  1244.     case @command_window.index
  1245.     when 0
  1246.       determine_item
  1247.     when 1
  1248.       @confirm_window.show
  1249.       @confirm_window.activate
  1250.       @confirm_window.select(0)
  1251.     end
  1252.   end
  1253.   #--------------------------------------------------------------------------
  1254.   # * Item [Cancel]
  1255.   #--------------------------------------------------------------------------
  1256.   def on_item_cancel
  1257.     @item_window.unselect
  1258.     @command_window.activate
  1259.   end
  1260.   #--------------------------------------------------------------------------
  1261.   # * spell [OK]
  1262.   #--------------------------------------------------------------------------
  1263.   def on_drop_ok
  1264.     if @confirm_window.index == 1
  1265.       on_drop_cancel
  1266.       return
  1267.     end
  1268.     @item_window.no_select
  1269.     @item_window.drop_spell
  1270.     @confirm_window.deactivate
  1271.     @confirm_window.hide
  1272.     @item_window.refresh
  1273.     @item_window.activate
  1274.     check_drop
  1275.   end
  1276.   #--------------------------------------------------------------------------
  1277.   # * spell [Cancel]
  1278.   #--------------------------------------------------------------------------
  1279.   def on_drop_cancel
  1280.     @item_window.no_select
  1281.     @confirm_window.deactivate
  1282.     @confirm_window.hide
  1283.     @item_window.refresh
  1284.     @item_window.activate
  1285.     check_drop
  1286.   end
  1287.   #--------------------------------------------------------------------------
  1288.   # * Reset Drop Selection
  1289.   #--------------------------------------------------------------------------
  1290.   def check_drop
  1291.     if @command_window.index == 1
  1292.       command_drop
  1293.     end
  1294.   end
  1295.   #--------------------------------------------------------------------------
  1296.   # * Play SE When Using Item
  1297.   #--------------------------------------------------------------------------
  1298.   def play_se_for_item
  1299.     Sound.play_use_skill
  1300.   end
  1301.   #--------------------------------------------------------------------------
  1302.   # * Use Item
  1303.   #--------------------------------------------------------------------------
  1304.   def use_item
  1305.     super
  1306.     @status_window.refresh
  1307.     @item_window.refresh
  1308.   end
  1309.   #--------------------------------------------------------------------------
  1310.   # * Change Actors
  1311.   #--------------------------------------------------------------------------
  1312.   def on_actor_change
  1313.     @command_window.actor = @actor
  1314.     @status_window.actor = @actor
  1315.     @item_window.actor = @actor
  1316.     @command_window.activate
  1317.   end
  1318. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement