Ventwig

VTS-Equippable Skill Seals

Jun 23rd, 2014
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.86 KB | None | 0 0
  1. #============================================================================
  2. #VTS-Equippable Skill Seals
  3. #By Ventwig
  4. #Version 1 - Jun 21 2014
  5. #For RPGMaker VX Ace
  6. #=============================================================================
  7. # Description:
  8. # Equipping "seals" to actors allows them to learn new skills based on their
  9. # level. One primary seal and two secondary seals may be equipped.
  10. # Different combinations of primary-secondary seals will teach different skills.
  11. # Actors can equip the same seals, and skills will be removed after unequipping
  12. # its respective seal. Switches are used to lock/unlock seals.
  13. #===============================================================================
  14. # Instructions: Put in materials, above main.
  15. # Requires set-up to make seals teach skills
  16. # "Seal Skills" must all go under their own unique "skill type"
  17. # New skill types can be added under "Terms" in the database, and a skill
  18. # may be assigned a new skill type on its own database page.
  19. #==============================================================================
  20. # Please give Credit to Ventwig if you would like to use one of my scripts!
  21. # Use it commericial or non-commercial, and feel free to tell me if you're using
  22. # it commercially!
  23. # You may edit my scripts, just don't claim as your own!
  24. #===============================================================================
  25. #Customization Below!
  26. #===============================================================================
  27. module SEALS #Do not Touch
  28.  
  29.   #Seal Creation
  30.   #[Seal Name, Switch to Unlock, Help Text]
  31.   #Keep the "LIST[x] =" part in ascending order, and add more lines as needed
  32.   #The x in LIST[x] refers to the "seal id"
  33.   #Seal Name and Help Text in quotations
  34.   LIST = [] #Do not touch
  35.   LIST[0] = ["-Empty-",0,"No Seal Equipped."]
  36.   LIST[1] = ["Alpha",1,"Teaches various Slash Skills."]
  37.   LIST[2] = ["Beta",2,"The seal of fire."]
  38.   LIST[3] = ["Phi",3,"Contains the secrets of healing arts."]
  39.   LIST[4] = ["Tau",4,"Provides mana boosts."]
  40.  
  41.   #The Name of the menu command to call the seal window. In quotations.
  42.   #(Def: "Seal")
  43.   MENU_COMMAND = "Seal"
  44.  
  45.   #The skill type of all seal skills (its database ID)
  46.   #This is necessary for displaying all seal skills in the seal window
  47.   #(Def: 3)
  48.   SKILL_TYPE = 3
  49.  
  50.   #The Command to remove a currently equipped skill. In quotations.
  51.   #(Def: "Remove")
  52.   COMMAND_REMOVE = "Remove"
  53.   #The help text for the above command. In quotations
  54.   #(Def: "Unequip Seal")
  55.   REMOVE_TEXT = "Unequip Seal"
  56.   #The symbol before a seal name in the slot selection screen to specify
  57.   #the slot is a secondary slot. Can leave blank, if desire. In quotations.
  58.   #(Def: "-> ")
  59.   INDENT = "-> "
  60.  
  61.   #GO TO LINE 267 TO ASSIGN SKILLS TAUGHT FROM SEALS
  62.   #The actual line number varies based on how many different
  63.   #seals you added
  64. end
  65.  
  66. class Game_Actor < Game_Battler
  67.   attr_accessor :seal_primary
  68.   attr_accessor :seal_secondary
  69.   attr_accessor :seal_secondary2
  70.  
  71.   alias seal_actor_initialize initialize
  72.   def initialize(actor_id)
  73.     seal_actor_initialize(actor_id)
  74.     @seal_primary = 0
  75.     @seal_secondary = 0
  76.     @seal_secondary2 = 0
  77.   end
  78. end
  79.  
  80. class Window_SealActor < Window_Base
  81.   def initialize(actor)
  82.     @actor=actor
  83.     super(0,0,224,160)
  84.     create_actor_info
  85.   end
  86.   def create_actor_info
  87.     draw_actor_name(@actor,0,0)
  88.     draw_actor_level(@actor,100,0)
  89.     draw_actor_face(@actor,0,30, enabled = true)
  90.   end
  91.   def refresh
  92.     contents.clear
  93.     create_actor_info
  94.   end
  95. end
  96.  
  97. class Window_SealInfo < Window_Base
  98.   def initialize
  99.     super(224,0,320,60)
  100.     @text = ""
  101.     seal_words
  102.   end
  103.   def seal_words
  104.     draw_text(0,0,300,40,@text)
  105.   end
  106.   def refresh
  107.     contents.clear
  108.     seal_words
  109.   end
  110.   def change_text(text)
  111.     @text = text
  112.   end
  113. end
  114.  
  115. class Window_SealCommand < Window_Command
  116.   def initialize(actor)
  117.     @actor = actor
  118.     super(224,60)
  119.     self.height = 100
  120.   end
  121.   def col_max
  122.     return 1
  123.   end
  124.   def make_command_list
  125.     add_command(SEALS::LIST[@actor.seal_primary][0],   :primary)
  126.     add_command(SEALS::INDENT + SEALS::LIST[@actor.seal_secondary][0], :secondary)
  127.     add_command(SEALS::INDENT + SEALS::LIST[@actor.seal_secondary2][0], :secondary2)
  128.   end
  129. end
  130.  
  131. class Window_SealEquip < Window_Command
  132.   def initialize
  133.     super(384,60)
  134.     self.height = 100
  135.   end
  136.   def col_max
  137.     return 1
  138.   end
  139.   def make_command_list
  140.     add_command(SEALS::COMMAND_REMOVE, :remove)
  141.     for i in 1..SEALS::LIST.size-1
  142.       add_command(SEALS::LIST[i][0],    SEALS::LIST[i][0].to_sym)   if $game_switches[SEALS::LIST[i][1]]
  143.     end
  144.   end
  145. end
  146.  
  147.  
  148. class Window_SealSkillList < Window_SkillList
  149.   def col_max
  150.     return 3
  151.   end
  152.  
  153.   def enable?(item)
  154.     return true
  155.   end
  156.  
  157.   def draw_skill_cost(rect, skill)
  158.   end
  159.   def update_help
  160.   end
  161. end
  162.  
  163.  
  164. class Window_MenuCommand < Window_Command
  165.   alias seal_make_command_list make_command_list
  166.   def make_command_list
  167.     seal_make_command_list
  168.     add_seal_command
  169.   end
  170.   def add_seal_command
  171.     add_command(SEALS::MENU_COMMAND, :seals)
  172.   end
  173. end
  174.  
  175. class Scene_Menu < Scene_MenuBase
  176.   alias seal_command_window create_command_window
  177.   def create_command_window
  178.     seal_command_window
  179.     @command_window.set_handler(:seals,    method(:command_personal))
  180.   end
  181.   def command_seals
  182.     SceneManager.call(Scene_Seals)
  183.   end
  184.   alias seal_on_personal_ok on_personal_ok
  185.   def on_personal_ok
  186.     seal_on_personal_ok
  187.     case @command_window.current_symbol
  188.     when :seals
  189.       SceneManager.call(Scene_Seals)
  190.     end
  191.   end
  192. end
  193.  
  194. class Scene_Seals < Scene_MenuBase
  195.   def start
  196.     super
  197.     create_windows
  198.     create_seal_window
  199.     create_equip_window
  200.     activate_seal_window
  201.   end
  202.   def create_windows
  203.     @actor_window = Window_SealActor.new(@actor)
  204.     @info_window = Window_SealInfo.new
  205.     @skill_window = Window_SealSkillList.new(0,160,544,256)
  206.     @skill_window.stype_id = SEALS::SKILL_TYPE
  207.     @skill_window.actor = @actor
  208.   end
  209.   def create_seal_window
  210.     @seal_window = Window_SealCommand.new(@actor)
  211.     @seal_window.set_handler(:primary,    method(:command_change))
  212.     @seal_window.set_handler(:secondary, method(:command_change))
  213.     @seal_window.set_handler(:secondary2,    method(:command_change))
  214.   end
  215.   def create_equip_window
  216.     @equip_window = Window_SealEquip.new
  217.     @equip_window.set_handler(:remove,    method(:command_change2))
  218.     for i in 1..SEALS::LIST.size-1
  219.       @equip_window.set_handler(SEALS::LIST[i][0].to_sym, method(:command_change2))
  220.     end
  221.     activate_seal_window
  222.   end
  223.   def destroy_windows
  224.     @actor_window.dispose
  225.     @info_window.dispose
  226.     @skill_window.dispose
  227.     @seal_window.dispose
  228.     @equip_window.dispose
  229.   end
  230.   def command_change
  231.     case @seal_window.current_symbol
  232.     when :primary
  233.       @change = 1
  234.     when :secondary
  235.       @change = 2
  236.     when :secondary2
  237.       @change = 3
  238.     end
  239.     activate_equip_window
  240.   end
  241.   def command_change2
  242.     for i in 1..SEALS::LIST.size-1
  243.       case @equip_window.current_symbol
  244.         when SEALS::LIST[i][0].to_sym
  245.           @change2 = i
  246.       end
  247.     end
  248.    
  249.     case @equip_window.current_symbol
  250.       when :remove
  251.         @change2 = 0
  252.     end
  253.     change_seal
  254.   end
  255.   def change_seal
  256.     @actor.seal_primary = @change2       if @change == 1
  257.     @actor.seal_secondary = @change2     if @change == 2
  258.     @actor.seal_secondary2 = @change2    if @change == 3
  259.     puts @change2
  260.     change_skills
  261.     @seal_window.refresh
  262.     @skill_window.refresh
  263.     activate_seal_window
  264.   end
  265.   def change_skills
  266.     #==========================================================================
  267.     #ASSIGN SKILLS HERE!
  268.     #==========================================================================
  269.     #MAIN SKILLS
  270.     #Skills Taught by equipping one seal anywhere
  271.     #skill_main(skill id, minimum level, seal id)
  272.     #============
  273.     skill_main(5,1,1)
  274.     skill_main(13,1,2)
  275.     skill_main(10,1,3)
  276.     #============
  277.     #COMBINATION SKILLS
  278.     #Skills taught based on the primary seal and one secondary seal
  279.     #skill_comb(skill id, minimum level, seal id, seal id)
  280.     #============
  281.     skill_comb(8,1,1,2)
  282.     skill_comb(9,1,3,2)
  283.   end
  284.  
  285.   def skill_main(skill_id,level,seal_id)
  286.     if @actor.seal_primary == seal_id or @actor.seal_secondary == seal_id or @actor.seal_secondary2 == seal_id
  287.       if @actor.level >= level
  288.         @actor.learn_skill(skill_id)
  289.       else
  290.         @actor.forget_skill(skill_id)
  291.       end
  292.     else
  293.       @actor.forget_skill(skill_id)
  294.     end
  295.   end
  296.  
  297.   def skill_comb(skill_id,level,seal_id,seal_id2)
  298.     if @actor.seal_primary == seal_id
  299.       if @actor.seal_secondary == seal_id2 or @actor.seal_secondary2 == seal_id2
  300.         if @actor.level >= level
  301.           @actor.learn_skill(skill_id)
  302.         else
  303.           @actor.forget_skill(skill_id)
  304.         end
  305.       else
  306.         @actor.forget_skill(skill_id)
  307.       end
  308.     elsif @actor.seal_secondary == seal_id or @actor.seal_secondary2 == seal_id
  309.       if @actor.seal_primary == seal_id2
  310.         if @actor.level >= level
  311.           @actor.learn_skill(skill_id)
  312.         else
  313.           @actor.forget_skill(skill_id)
  314.         end
  315.       else
  316.         @actor.forget_skill(skill_id)
  317.       end
  318.     else
  319.       @actor.forget_skill(skill_id)
  320.     end
  321.   end
  322.    
  323.   def activate_equip_window
  324.     @seal_window.deactivate
  325.     @equip_window.activate
  326.   end
  327.   def activate_seal_window
  328.     @seal_window.activate
  329.     @equip_window.deactivate
  330.   end
  331.   def change_info_text
  332.     if @seal_window.active == true
  333.         case @seal_window.current_symbol
  334.           when :primary
  335.             i = @actor.seal_primary
  336.             @info_window.change_text(SEALS::LIST[i][2])
  337.           when :secondary
  338.             i = @actor.seal_secondary
  339.             @info_window.change_text(SEALS::LIST[i][2])
  340.           when :secondary2
  341.             i = @actor.seal_secondary2
  342.             @info_window.change_text(SEALS::LIST[i][2])
  343.         end
  344.       @info_window.refresh
  345.     end
  346.     if @equip_window.active == true
  347.       for i in 1..SEALS::LIST.size-1
  348.         case @equip_window.current_symbol
  349.           when SEALS::LIST[i][0].to_sym
  350.             @info_window.change_text(SEALS::LIST[i][2])
  351.         end
  352.       end
  353.       case @equip_window.current_symbol
  354.         when :remove
  355.           @info_window.change_text(SEALS::REMOVE_TEXT)
  356.       end
  357.       @info_window.refresh
  358.     end
  359.   end
  360.   def refresh_all
  361.     destroy_windows
  362.     create_windows
  363.     create_seal_window
  364.     create_equip_window
  365.     activate_seal_window
  366.   end
  367.   def update
  368.     super
  369.     if Input.trigger?(:B)
  370.       SceneManager.return if @seal_window.active
  371.       activate_seal_window if @equip_window.active
  372.     end
  373.     if Input.trigger?(:R)
  374.       next_actor
  375.       refresh_all
  376.     end
  377.     if Input.trigger?(:L)
  378.       prev_actor
  379.       refresh_all
  380.     end
  381.     change_info_text
  382.   end
  383. end
Advertisement
Add Comment
Please, Sign In to add comment