Advertisement
Frysning

FuseSplit skils

Aug 17th, 2015
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RBScript 13.83 KB | None | 0 0
  1. =begin
  2.  
  3. ===============================================================================
  4. Frysning fuse/split skills.
  5. ===============================================================================
  6. With this script you can combine 2 skills in a new one and split that skill back
  7.  
  8. in the notetag of the skill use <fuse for combining a skill with an other.
  9. <fuse [2,80]>  means that this skill and skill 2 together will become skill 80
  10. You can add as much skill sets if you want.
  11. <fuse [[2,80],[3,81],[4,82]] > etc
  12.  
  13. For splitting a skill use:
  14. <split [1,2]> When this skill is splitted it will give back skill and 1 and 2.
  15. Split can only contain 2 skill!.
  16.  
  17. After combining 2 skills the player will lose them for that actor.
  18. Splitting them will forget the fused skill and give back the 2 base one's.
  19.  
  20. If you want to add to an event just use
  21. SceneManager.call(Scene_Fusion) for the fusion part.
  22. SceneManager.call(Scene_Split) for the split part.
  23.  
  24.  
  25. No credits needed, would be great though.
  26. If you got suggestions/bugs or anything.
  27.  
  28. Message on
  29.  
  30. http://www.rpgmakervxace.net/
  31. or
  32. pastebin
  33. or reddit
  34.  
  35. =end
  36.  
  37. #Fusion Start
  38. class Scene_Fusion < Scene_MenuBase
  39.   @actor_id
  40.  
  41.   def initialize
  42.     super
  43.     @main_window = Window_MenuStatus.new(0,0)
  44.     @main_window.activate()
  45.     @main_window.select(0)
  46.     @main_window.set_handler(:ok, method(:list_ok))
  47.     @main_window.set_handler(:cancel, method(:list_cancel))
  48.   end
  49.    
  50.   def update
  51.     super
  52.     if @combineList != nil
  53.       if @combineList.visible == true
  54.         if @detail == nil
  55.           @detail  = Window_SkillLearn.new
  56.         else
  57.           @detail.show
  58.         end
  59.         if @combineList.current_item != nil
  60.           @detail.setID(@combineList.current_item[:learnID])
  61.         end
  62.       end
  63.     end
  64.   end  
  65.      
  66.   def list_cancel
  67.     SceneManager.return
  68.   end
  69.  
  70.   def list_ok
  71.     @main_window.hide
  72.    
  73.     if @help_window == nil
  74.         @help_window = Window_Help.new(1)
  75.       else
  76.         @help_window.show
  77.     end  
  78.      
  79.     index =  @main_window.index
  80.     @help_window.set_text(  $game_party.members[index].name)
  81.    
  82.     if @skill_list == nil
  83.       @skill_list = Window_SkillListPlayer.new
  84.     else
  85.       @skill_list.show
  86.     end
  87.    
  88.     @actor_id = $game_party.members[index].id
  89.    
  90.     @skill_list.actorId(@actor_id)
  91.     @skill_list.activate()
  92.     @skill_list.select(0)
  93.     @skill_list.refresh
  94.     @skill_list.set_handler(:cancel, method(:skill_list_cancel))
  95.     @skill_list.set_handler(:ok, method(:skill_list_ok))
  96.   end
  97.  
  98.   def skill_list_cancel
  99.     @skill_list.hide
  100.     @help_window.hide
  101.    
  102.  
  103.     if @combineList != nil
  104.       @combineList.hide
  105.     end
  106.    
  107.     @main_window.show
  108.     @main_window.refresh
  109.     @main_window.activate()
  110.     @skill_list.select(0)
  111.   end
  112.  
  113.   def skill_list_ok
  114.  
  115.     #Getting the current note of the item for the skills
  116.     #that are fuseable
  117.     #We store that info in a tempory string.
  118.     if @skill_list.current_item.note =~ /<fuse (.*)>/i
  119.       tString = $1.split("],[")
  120.     end
  121.  
  122.     #We get the skills that the actor has and are combineble.
  123.     skills =  @skill_list.gData
  124.    
  125.     #make an empty array to store temporty data.
  126.     uArra=[]
  127.     #loop to the temporty array. to make a new array
  128.     #[n1,n2],[n1,n2]
  129.     tString.each do | item |
  130.             uArra.push(makeArray(item))
  131.     end  
  132.  
  133.     #We make a final skill array that stores the skills.
  134.     finalSkillArray = []
  135.    
  136.     #We loop through the tempory array.
  137.     #We loop trhought the skills of the actor.
  138.     #if the actor has the current skill and the skill is the array
  139.     #they both get added to the final list.
  140.     uArra.each do | is |
  141.       skills.each do | id, skills |
  142.         if is[0] == id.id.to_s
  143.             finalSkillArray.push(is)
  144.         end
  145.       end
  146.     end
  147.      
  148.     #we create the second window for the second skills
  149.     #if it does not excist
  150.     #if it excist we show it.
  151.     if@combineList == nil
  152.       @combineList =  Window_SkillListSecond.new
  153.     else
  154.       @combineList.show
  155.     end
  156.    
  157.     #we update the need list so we see which skills can fuse.
  158.     #we activate it and select the first entry.
  159.     @combineList.need_list(finalSkillArray)
  160.     @combineList.refresh
  161.     @combineList.activate()
  162.     @combineList.select(0)
  163.    
  164.     #we create the handlers for canceling or pressing ok.
  165.     @combineList.set_handler(:ok, method(:SkillListSecond_ok))
  166.     @combineList.set_handler(:cancel, method(:SkillListSecond_cancel))
  167.   end
  168.      
  169.  
  170.   def SkillListSecond_cancel
  171.     @detail.hide
  172.     @combineList.hide
  173.     @skill_list.activate()
  174.   end
  175.    
  176.   def SkillListSecond_ok
  177.     if @command_window == nil
  178.       @command_window =  Window_LearnSkill.new
  179.       @command_window.x = Graphics.width / 2 - @command_window.width / 2
  180.       @command_window.y = Graphics.height / 2 - @command_window.height / 2
  181.       @command_window.set_handler(:learn, method(:learn))
  182.       @command_window.set_handler(:cancel, method(:f_cancel))
  183.       @command_window.width = 300
  184.     else
  185.       @command_window.show
  186.     end
  187.    
  188.    if @combineList.current_item != nil
  189.       @command_window.Set(@combineList.current_item[:learnID])
  190.       @command_window.refresh
  191.       @command_window.select(0)
  192.       @command_window.activate
  193.       @command_window.open
  194.     end
  195.   end
  196.  
  197.   def learn
  198.     @command_window.close
  199.     $game_actors[@actor_id].learn_skill(@combineList.current_item[:learnID])
  200.     $game_actors[@actor_id].forget_skill(@combineList.current_item[:thisID])
  201.     $game_actors[@actor_id].forget_skill( @skill_list.current_item.id)
  202.    
  203.     @skill_list.refresh
  204.     @skill_list.activate()
  205.     @skill_list.select(0)
  206.     @combineList.hide
  207.     @detail.hide
  208.     @command_window.hide
  209.   end
  210.  
  211.  
  212.  def f_cancel
  213.     @command_window.close
  214.     @combineList.refresh
  215.     @combineList.activate
  216.   end
  217.  
  218.   def makeArray(stringf)
  219.     replacestring = stringf.gsub('[', '').gsub(']', '').gsub(' ', '')
  220.     replacestring.split(',')
  221.   end
  222.  
  223. end
  224.  
  225.  
  226. class Window_SkillListPlayer < Window_ItemList
  227.   def initialize
  228.     super(0,48,Graphics.width-Graphics.width/5*4,Graphics.height-48)
  229.   end
  230.  
  231.   def make_item_list
  232.     @data = []
  233.     actor =   $game_actors[@id]
  234.  
  235.     actor.skills.each do | feature |
  236.       if feature.note =~ /<fuse (.*)>/i
  237.         @data.push(feature)
  238.       end
  239.     end  
  240.  
  241.     @data.push(nil) if @data.empty?
  242.   end
  243.    
  244.   def gData
  245.     @data
  246.   end
  247.    
  248.   def draw_item(index)
  249.     contents.font.size = 18
  250.  
  251.     item = @data[index]
  252.     if item
  253.       rect = item_rect(index)
  254.       rect.width -= 4
  255.       text = item.name
  256.       draw_text(rect, text)
  257.     end
  258.   end
  259.  
  260.   def col_max; 1; end
  261.    
  262.   def current_item
  263.     @data[@index]
  264.   end
  265.  
  266.   def actorId(id)
  267.     @id = id
  268.   end
  269.  
  270.   def current_item_enabled?
  271.     true
  272.   end
  273. end
  274.  
  275.  
  276.  
  277. class Window_SkillListSecond < Window_ItemList
  278.   def initialize
  279.     super(Graphics.width-Graphics.width/5*4,48,Graphics.width-Graphics.width/5*4,Graphics.height-48)
  280.   end
  281.   def make_item_list
  282.  
  283.     @data = []
  284.     bigItem = {}
  285.  
  286.     @fArray.each do | item |
  287.      bigItem = { :thisID =>Integer(item[0]),
  288.                 :name => $data_skills[Integer(item[0])].name,
  289.                 :learnID => Integer(item[1])}
  290.      @data.push(bigItem)
  291.     end      
  292.       @data.push(nil) if @data.empty?
  293.     end
  294.    
  295.    
  296.   def draw_item(index)
  297.     contents.font.size = 18
  298.  
  299.     item = @data[index]
  300.     if item
  301.       rect = item_rect(index)
  302.       rect.width -= 4
  303.       text = item[:name]
  304.       draw_text(rect, text)
  305.     end
  306.   end
  307.  
  308.  
  309.   def need_list(data)
  310.     @fArray = data
  311.   end
  312.  
  313.   def col_max; 1; end
  314.   def current_item
  315.     @data[@index]
  316.   end
  317.   def current_item_enabled?
  318.     true
  319.   end
  320. end
  321.  
  322.  
  323.  
  324. class Window_SkillLearn < Window_Base
  325.   def initialize
  326.     super(Graphics.width/5*2,48,Graphics.width-Graphics.width/5*1,Graphics.height-48)
  327.   end
  328.  
  329.   def refresh
  330.     contents.clear
  331.     contents.font.size = 18
  332.     return unless @id
  333.     draw_text(0,0, contents.width, line_height,  $data_skills[@id].name)
  334.   end
  335.  
  336.   def setID(id)
  337.     @id =id
  338.     refresh
  339.   end
  340.  
  341. end
  342.  
  343. class Window_LearnSkill < Window_Command
  344.   def initialize
  345.     super(0,0)
  346.     self.openness = 0
  347.   end
  348.   def Set(skillid)
  349.     @id = skillid
  350.   end
  351.   def make_command_list
  352.   return unless @id
  353.       add_command("Learn Skill #{$data_skills[@id].name}", :learn)
  354.       add_command("Cancel", :cancel)
  355.  
  356.   end
  357.   def window_height
  358.     fitting_height(2)
  359.   end
  360. end
  361.  
  362.  
  363. #Split part of the script.
  364. class Scene_Split < Scene_MenuBase
  365.   @actor_id
  366.   def initialize
  367.     super
  368.     @main_window = Window_MenuStatus.new(0,0)
  369.     @main_window.activate()
  370.     @main_window.select(0)
  371.     @main_window.set_handler(:ok, method(:list_ok))
  372.     @main_window.set_handler(:cancel, method(:list_cancel))
  373.   end
  374.    
  375.   def update
  376.     super
  377.     if @skill_list != nil
  378.       if @skill_list.current_item != nil
  379.         if @skill_list.current_item.note =~ /<split (.*)>/i
  380.            @skillArray  = makeArray($1)
  381.            @descriptions.setID(@skillArray)
  382.         end
  383.       end
  384.     end
  385.   end
  386.      
  387.   def list_cancel
  388.     SceneManager.return
  389.   end
  390.  
  391.   def list_ok
  392.     @main_window.hide
  393.     if @help_window == nil
  394.       @help_window = Window_Help.new(1)
  395.     else
  396.       @help_window.show
  397.     end  
  398.      
  399.     index =  @main_window.index
  400.     @help_window.set_text(  $game_party.members[index].name)
  401.    
  402.    
  403.     if @skill_list == nil
  404.       @skill_list = Window_FusedListPlayer.new
  405.     else
  406.       @skill_list.show
  407.     end
  408.    
  409.     @actor_id = $game_party.members[index].id
  410.     @skill_list.actorId(@actor_id)
  411.     @skill_list.activate()
  412.     @skill_list.select(0)
  413.     @skill_list.refresh
  414.     @skill_list.set_handler(:cancel, method(:skill_list_cancel))
  415.     @skill_list.set_handler(:ok, method(:skill_list_ok))
  416.     @descriptions = Window_SkillForget.new
  417.    
  418.   end
  419.  
  420.   def skill_list_cancel
  421.     @skill_list.hide
  422.     @help_window.hide
  423.     @descriptions.hide
  424.     @main_window.show
  425.     @main_window.refresh
  426.     @main_window.activate()
  427.     @skill_list.select(0)
  428.   end
  429.  
  430.   def skill_list_ok
  431.     if @command_window == nil
  432.       @command_window =  Window_ForgetSkill.new
  433.       @command_window.x = Graphics.width / 2 - @command_window.width / 2
  434.       @command_window.y = Graphics.height / 2 - @command_window.height / 2
  435.       @command_window.set_handler(:forget, method(:forget_skills))
  436.       @command_window.set_handler(:cancel, method(:f_cancel))
  437.       @command_window.width = 300
  438.     else
  439.       @command_window.show
  440.     end
  441.       @command_window.Set(@skill_list.current_item.id)
  442.       @command_window.refresh
  443.       @command_window.select(0)
  444.       @command_window.activate
  445.       @command_window.open
  446.   end
  447.      
  448.   def forget_skills
  449.     @command_window.close
  450.    
  451.     $game_actors[@actor_id].forget_skill(@forgotid)
  452.     $game_actors[@actor_id].learn_skill(Integer(@skillArray[0]))
  453.     $game_actors[@actor_id].learn_skill(Integer(@skillArray[0]))
  454.    
  455.     @skill_list.refresh
  456.     @skill_list.activate()
  457.     @skill_list.select(0)
  458.     @descriptions.hide
  459.     @command_window.hide
  460.   end
  461.  
  462.  
  463.  def f_cancel
  464.     @command_window.close
  465.        @skill_list.refresh
  466.     @skill_list.activate()
  467.     @skill_list.select(0)
  468.   end
  469.  
  470.   def makeArray(stringf)
  471.     replacestring = stringf.gsub('[', '').gsub(']', '').gsub(' ', '')
  472.     replacestring.split(',')
  473.   end
  474.  
  475. end
  476.  
  477. class Window_FusedListPlayer < Window_ItemList
  478.   def initialize
  479.     super(0,48,Graphics.width-Graphics.width/5*4,Graphics.height-48)
  480.   end
  481.   def make_item_list
  482.  
  483.     @data = []
  484.     actor =   $game_actors[@id]
  485.    
  486.     actor.skills.each do | feature |
  487.             if feature.note =~ /<split (.*)>/i
  488.             @data.push(feature)
  489.            end
  490.          end        
  491.       @data.push(nil) if @data.empty?
  492.     end
  493.    
  494.    def gData
  495.      @data
  496.     end
  497.    
  498.   def draw_item(index)
  499.     contents.font.size = 18
  500.  
  501.     item = @data[index]
  502.     if item
  503.       rect = item_rect(index)
  504.       rect.width -= 4
  505.       text = item.name
  506.       draw_text(rect, text)
  507.     end
  508.   end
  509.   def col_max; 1; end
  510.   def current_item
  511.     @data[@index]
  512.   end
  513.   def actorId(id)
  514.     @id = id
  515.   end
  516.  
  517.   def current_item_enabled?
  518.     true
  519.   end
  520. end
  521.  
  522. class Window_SkillForget < Window_Base
  523.   def initialize
  524.  
  525.     super(Graphics.width/5*2,48,Graphics.width-Graphics.width/5*1,Graphics.height-48)
  526.   end
  527.  
  528.   def refresh
  529.     contents.clear
  530.     contents.font.size = 18
  531.     return unless @id
  532.    
  533.    
  534.     draw_text(0,0, contents.width, line_height,  $data_skills[@id].name)
  535.     draw_text(0,18, contents.width, line_height,  $data_skills[@id2].name)
  536.   end
  537.  
  538.   def setID(id)
  539.     @id =Integer(id[0])
  540.     @id2 = Integer(id[1])
  541.     refresh
  542.   end
  543.  
  544. end
  545.  
  546. class Window_ForgetSkill < Window_Command
  547.   def initialize
  548.     super(0,0)
  549.     self.openness = 0
  550.   end
  551.   def Set(skillid)
  552.     @id = skillid
  553.   end
  554.   def make_command_list
  555.   return unless @id
  556.       add_command("Forget Skill #{$data_skills[@id].name}", :forget)
  557.       add_command("Cancel", :cancel)
  558.  
  559.   end
  560.   def window_height
  561.     fitting_height(2)
  562.   end
  563. end
  564.  
  565.  
  566. #Delete this if you don't want to special colors.
  567. class Window_SkillList < Window_Selectable
  568.   def draw_item(index)
  569.     skill = @data[index]
  570.     if skill
  571.       rect = item_rect(index)
  572.       rect.width -= 4
  573.  
  574.       draw_item_nameThing(skill, rect.x, rect.y, enable?(skill))
  575.       draw_skill_cost(rect, skill)
  576.     end
  577.   end
  578.  
  579.   def draw_item_nameThing(item, x, y, enabled = true, width = 172)
  580.     return unless item
  581.     draw_icon(item.icon_index, x, y, enabled)
  582.     if item.note =~ /<split (.*)>/i then
  583.    
  584.          change_color(text_color(14), enabled)
  585.        elsif item.note =~ /<fuse (.*)>/i  then
  586.         change_color(text_color(3), enabled)
  587.     else
  588.    
  589.    change_color(normal_color, enabled)
  590.    end
  591.    draw_text(x + 24, y, width, line_height, item.name)
  592.   end
  593. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement