Advertisement
Guest User

Untitled

a guest
Dec 8th, 2011
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.72 KB | None | 0 0
  1. #Monster Breeding System 1.1
  2. #  by nhojyer07
  3.  
  4. # 1.1 Fixed a major bug
  5.  
  6. $imported = {} if $imported == nil
  7. $imported["SowSMonsBreedSys"] = true
  8.  
  9. module SOWS_MBS
  10.   TYPE_ARRAY = [        # [ child, type 1, type 2]
  11.     [3, 1, 2],
  12.     [12, 10, 11]
  13.   ]
  14.   SPECIFIC_ARRAY = [    # [ child, monster 1, monster 2]
  15.     [6, 4, 5],
  16.     [9, 7, 8]
  17.   ]
  18. end
  19.  
  20. class Window_BreedHelp < Window_Base
  21.  
  22.   def initialize
  23.     super(0, 0, Graphics.width, WLH + 32)
  24.     refresh
  25.   end
  26.   def refresh(text = "")
  27.     self.contents.clear
  28.     self.contents.draw_text(0, 0, Graphics.width - 32, WLH, text)
  29.   end
  30. end
  31.  
  32. class Window_BreedStatus < Window_Base
  33.   def initialize
  34.     super(Graphics.width / 2, 56, Graphics.width / 2, Graphics.height - (2 * WLH + 32) - 56)
  35.     refresh
  36.   end
  37.  
  38.   def refresh(main = "None", sub = "None", result = "None")
  39.     self.contents.clear
  40.     self.contents.draw_text(0, 0, Graphics.width / 2 - 32, WLH, "Main:")
  41.     self.contents.draw_text(0, WLH, Graphics.width / 2 - 32, WLH, main, 2)
  42.     self.contents.draw_text(0, WLH * 3, Graphics.width / 2 - 32, WLH, "Sub:")
  43.     self.contents.draw_text(0, WLH * 4, Graphics.width / 2 - 32, WLH, sub, 2)
  44.     self.contents.draw_text(0, WLH * 7, Graphics.width / 2 - 32, WLH, "Result:")
  45.     self.contents.draw_text(0, WLH * 8, Graphics.width / 2 - 32, WLH, result, 2)
  46.   end
  47. end
  48.  
  49. class Window_ActorList < Window_Selectable  
  50.   attr_accessor :i
  51.  
  52.   def initialize
  53.     super(0, 56, Graphics.width / 2, Graphics.height / 2)
  54.     @i = 0
  55.     refresh
  56.     self.index = 0
  57.   end
  58.  
  59.   def refresh(main = -1, sub = -1)
  60.     self.contents.clear
  61.     @item_max = $game_party.members.size
  62.     for actor in $game_party.members
  63.       y = actor.index * WLH
  64.       if sub == -1
  65.         self.contents.font.color.alpha = main == actor.index ? 128 : 255
  66.       elsif sub > -1
  67.         self.contents.font.color.alpha = main == actor.index ? 128 : sub == actor.index ? 128 : 255
  68.       end
  69.       self.contents.draw_text(x, y, 108, WLH, actor.name)
  70.     end
  71.   end
  72. end
  73.  
  74. class Window_ActorStat < Window_Base
  75.   def initialize
  76.     super(0, 56 + Graphics.height / 2, Graphics.width / 2, Graphics.height / 2 - 56)
  77.     refresh($game_party.members[0])
  78.   end
  79.  
  80.   def refresh(actor)
  81.     self.contents.clear
  82.     draw_actor_face(actor, 2, 2, 92)
  83.     x = 104
  84.     y = WLH / 2
  85.     draw_actor_name(actor, x, y)
  86.     draw_actor_class(actor, x, y + WLH)
  87.   end
  88. end
  89.  
  90. class Scene_Breed < Scene_Base
  91.   include SOWS_MBS
  92.  
  93.   def start
  94.     super
  95.     create_menu_background
  96.     @help = Window_BreedHelp.new
  97.     @help.refresh("Choose the first monster.")
  98.     @actorlist = Window_ActorList.new
  99.     @actorstat = Window_ActorStat.new
  100.     @breedstat = Window_BreedStatus.new
  101.     @breedcomm = Window_Command.new(Graphics.width / 2, ["Combine","Cancel"])
  102.     @breedcomm.x = Graphics.width / 2
  103.     @breedcomm.y = Graphics.height - @breedcomm.height
  104.     @breedcomm.active = false
  105.     @index = @actorlist.index
  106.     @main = -1
  107.     @sub = -1
  108.     @counter = 0
  109.   end
  110.  
  111.   def update
  112.     super
  113.     update_menu_background
  114.     @help.update
  115.     @actorlist.update
  116.     @actorstat.update
  117.     @breedstat.update
  118.     @breedcomm.update
  119.     @win_msg.update if !@win_msg.nil?
  120.     if @actorlist.active
  121.       update_actor_selection
  122.     elsif @breedcomm.active
  123.       update_command_selection
  124.     end
  125.     if !@win_msg.nil?
  126.       if @counter == 180 # 3 secs
  127.         @win_msg.visible = false
  128.         @win_msg = nil
  129.         @actorlist.active = true
  130.         @help.refresh("Choose the first monster.")
  131.         @counter = 0
  132.       else
  133.         @counter += 1
  134.       end
  135.     end
  136.   end
  137.  
  138.   def terminate
  139.     super
  140.     dispose_menu_background
  141.     @help.dispose
  142.     @actorlist.dispose
  143.     @actorstat.dispose
  144.     @breedstat.dispose
  145.     @breedcomm.dispose
  146.     @win_msg.dispose if !@win_msg.nil?
  147.   end
  148.  
  149.   def return_scene
  150.     $scene = Scene_Map.new
  151.   end
  152.  
  153.   def update_actor_selection
  154.     if Input.trigger?(Input::B)
  155.       Sound.play_cancel
  156.       if @main == -1 and @sub == -1
  157.         return_scene
  158.       elsif @main > -1 and @sub > -1
  159.         @sub = -1
  160.         @breedstat.refresh($game_party.members[@main].name)
  161.         @actorlist.refresh(@main)
  162.         @help.refresh("Choose the second monster.")
  163.       elsif @main > -1 and @sub == -1
  164.         @main = -1
  165.         @breedstat.refresh
  166.         @actorlist.refresh
  167.         @help.refresh("Choose the first monster.")
  168.       end
  169.     elsif Input.trigger?(Input::C)
  170.       if @main == -1 and @sub == -1
  171.         Sound.play_decision
  172.         @main = @actorlist.index
  173.         @breedstat.refresh($game_party.members[@main].name)
  174.         @actorlist.refresh(@main)
  175.         @help.refresh("Choose the second monster.")
  176.       elsif @main > -1 and @sub == -1
  177.         if @main == @actorlist.index
  178.           Sound.play_buzzer
  179.         else
  180.           Sound.play_decision
  181.           @sub = @actorlist.index
  182.           @actorlist.refresh(@main, @sub)
  183.           @breedstat.refresh($game_party.members[@main].name, $game_party.members[@sub].name)
  184.           spec = false
  185.           for i in 0...SPECIFIC_ARRAY.length - 1
  186.             if $game_party.members[@main].id == SPECIFIC_ARRAY[i][1] and $game_party.members[@sub].id == SPECIFIC_ARRAY[i][2]
  187.               @breedstat.refresh($game_party.members[@main].name, $game_party.members[@sub].name, $data_actors[SPECIFIC_ARRAY[i][0]].name)
  188.               spec = true
  189.               break
  190.             end
  191.           end
  192.           if !spec
  193.             for i in 0...TYPE_ARRAY.length - 1
  194.               if $game_party.members[@main].class.id == TYPE_ARRAY[i][1] and $game_party.members[@sub].class.id == TYPE_ARRAY[i][2]
  195.                 @breedstat.refresh($game_party.members[@main].name, $game_party.members[@sub].name, $data_actors[TYPE_ARRAY[i][0]].name)
  196.                 p "meron"
  197.                 break
  198.               end
  199.             end
  200.           end
  201.           @help.refresh("Proceed?")
  202.           @actorlist.active = false
  203.           @breedcomm.active = true
  204.         end
  205.       end
  206.     end
  207.     if @index != @actorlist.index
  208.       @actorstat.refresh($game_party.members[@actorlist.index])
  209.       @index = @actorlist.index
  210.     end
  211.   end
  212.  
  213.   def update_command_selection
  214.     if Input.trigger?(Input::B)
  215.       comm_cancel
  216.     elsif Input.trigger?(Input::C)
  217.       if @breedcomm.index == 0
  218.         @breedcomm.active = false
  219.         check_breedlist
  220.       else
  221.         comm_cancel
  222.       end
  223.     end
  224.   end
  225.  
  226.   def comm_cancel
  227.     Sound.play_cancel
  228.     @breedcomm.index = 0
  229.     @breedcomm.active = false
  230.     @actorlist.active = true
  231.     @sub = -1
  232.     @actorlist.refresh(@main)
  233.     @breedstat.refresh($game_party.members[@main].name)
  234.     @help.refresh("Choose the second monster.")
  235.   end
  236.  
  237.   def check_breedlist
  238.     child_found = false
  239.     for i in 0...SPECIFIC_ARRAY.length - 1
  240.       if $game_party.members[@main].id == SPECIFIC_ARRAY[i][1] and $game_party.members[@sub].id == SPECIFIC_ARRAY[i][2]
  241.         @result = SPECIFIC_ARRAY[i][0]
  242.         string = "Breeding completed!"
  243.         @win_msg = Window_Base.new((Graphics.width - Graphics.width / 3 * 2) / 2, (Graphics.height - 24) / 2, Graphics.width / 3 * 2, 56)
  244.         @win_msg.contents.draw_text(0, 0, @win_msg.contents.width, 24, string, 1)
  245.        
  246.         $game_party.remove_actor(SPECIFIC_ARRAY[i][1])
  247.         $game_party.remove_actor(SPECIFIC_ARRAY[i][2])
  248.         $game_party.remove_actor(@result)
  249.         @actorlist.refresh
  250.         @actorlist.index = 0
  251.         @actorlist.active = false
  252.         @actorstat.refresh($game_party.members[0])
  253.         @breedstat.refresh
  254.         @main = @sub = -1
  255.         child_found = true
  256.         break
  257.       end
  258.     end
  259.     if !child_found
  260.       for i in 0...TYPE_ARRAY.length - 1
  261.         if $game_party.members[@main].class == $data_classes[TYPE_ARRAY[i][1]] and $game_party.members[@sub].class == $data_classes[TYPE_ARRAY[i][2]]
  262.           @result = TYPE_ARRAY[i][0]
  263.           string = "Breeding completed!"
  264.           @win_msg = Window_Base.new((Graphics.width - Graphics.width / 3 * 2) / 2, (Graphics.height - 24) / 2, Graphics.width / 3 * 2, 56)
  265.           @win_msg.contents.draw_text(0, 0, @win_msg.contents.width, 24, string, 1)
  266.          
  267.           $game_party.remove_actor(TYPE_ARRAY[i][1])
  268.           $game_party.remove_actor(TYPE_ARRAY[i][2])
  269.           $game_party.add_actor(@result)
  270.           @actorlist.refresh
  271.           @actorlist.index = 0
  272.           @actorlist.active = false
  273.           @actorstat.refresh($game_party.members[0])
  274.           @breedstat.refresh
  275.           @main = @sub = -1
  276.           child_found = true
  277.           break
  278.         end
  279.       end
  280.     end
  281.     if !child_found
  282.         string = "Breeding failed!"
  283.         @win_msg = Window_Base.new((Graphics.width - Graphics.width / 3 * 2) / 2, (Graphics.height - 24) / 2, Graphics.width / 3 * 2, 56)
  284.         @win_msg.contents.draw_text(0, 0, @win_msg.contents.width, 24, string, 1)
  285.         @actorlist.refresh
  286.         @actorlist.index = 0
  287.         @actorlist.active = false
  288.         @actorstat.refresh($game_party.members[0])
  289.         @breedstat.refresh
  290.         @main = @sub = -1
  291.  
  292.     end
  293.   end
  294. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement