Advertisement
CrowMakerVX

RecruitShops1.0

Dec 26th, 2012
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 54.90 KB | None | 0 0
  1. ################################################################################
  2.  
  3. #                            RECRUIT SHOPS
  4. #                             By: Ixfuru
  5. #                             version 1.0
  6. #                          December 26th, 2012
  7. #
  8. ################################################################################
  9.  
  10. # This script allows you to 'recruit' actors to the party by purchasing them at
  11. # shops.  The shops are a new scene, created by the script, which can be
  12. # accessed at anytime by using a script call.  This means going to the third
  13. # tab of an event and selecting 'Script'.  Then placing the following text into
  14. # the window:
  15. #               $scene = Scene_Recruit.new(shop_id)
  16. #
  17. # You'll have to set up the 'shop_id's below.  Once they are set up, just replace
  18. # the 'shop_id' part of the script call with the id of the shop you want to
  19. # access.
  20. #
  21. # This script has a great many customization options.  It is very versatile in
  22. # both the scene's appearance and that actors which can be recruited.
  23. #
  24. # The recruits (or actors) you acquire can be set up to be 'random'.  That is,
  25. # the pc will generate an actor from variables you set up in the module.
  26. #
  27. # To use the script, place it in the script editor, below Materials and above
  28. # Main.
  29. #
  30. # Please take your time and make sure you read the instructions for the 6 parts
  31. # of the script thoroughly.  If you have questions, just post them under this
  32. # scripts topic and I'll do my best to answer them, as well as adapt them to
  33. # compatibility with other scripts and fix them when necessary.
  34. #
  35. #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  36. #                     THINGS YOU WILL REQUIRE
  37. #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38. # You need to get ModernAlgebra's script "ParagraphFormatter 2.0".  You can find
  39. # it here:
  40. #            http://rmrk.net/index.php/topic,25129.0.html
  41. #
  42. # By taking it, you'll have to make sure and credit him or arrange permission
  43. # from him.  
  44. #
  45. #-------------------------------------------------------------------------------
  46. # Secondly, you can alter the windowskins of the shop scene by placing a new
  47. # windowskin graphic in the Graphics\System folder of your project, and then
  48. # setting the variable in SECTION 6.  If you attained this script via the
  49. # demo, you'll find that I have already placed a somewhat cheap windowskin that
  50. # I created in the folder for you.  It's not necessary for you to credit me for
  51. # using the windowskin.
  52. #
  53. #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  54. #
  55. # This AND every IXFURU script is the property of IXFURU.  You cannot
  56. # redistribute this script without his permission.  You may alter it and use it
  57. # for your own non-commercial projects at will provided that you give credit to
  58. # him for the creation.  Furthermore, if you choose to use this in a commercial
  59. # game, you'll be required to contact IXFURU and gain his permission.  He is
  60. # NOT in anyway obligated to allow this script to be used in this manner.  But
  61. # is open to discussion.
  62. #
  63. #===============================================================================
  64. #                          ADVANCED USE OF THE SCRIPT
  65. #===============================================================================
  66. # There are many script calls which can be used for this script.  They can be
  67. # used in conditional branches and other ways to get the most out of the script.
  68. # They are as follows:
  69. #
  70. # 1) $game_actors[actor_id].is_random?
  71. #     This can be used in a conditional branch to see if the actor is a randomly
  72. #     generated one.
  73. #
  74. # 2) $game_actors[actor_id].is_male?, .is_female?, .is_beast?
  75. #     These can be used in a conditional branch to state whether the actor is
  76. #   one of the three 'types' of recruits.  Male, Female or Beast (by default)
  77. #
  78. # 3) $game_actors[actor_id].regenerate_random(top_level)
  79. #      If the actor is random, this will regenerate them.  That is, will transform
  80. # them into a new actor altogether.  This script call will transform the
  81. # character, but will NOT change their 'type'.  
  82. #
  83. # 4)  $game_party.has_males?(amount), .has_females?(amount), .has_beasts?(amount)
  84. #     These script calls, to be used in a conditional branch, can check to see
  85. #  if there is 'amount' of the type of actors in your party.
  86. #
  87. # 5)  $game_party.leader_is_male?, .leader_is_female?, .leader_is_beast?
  88. #     These script calls, in a conditional branch, will check to see if the
  89. #   leader is of a certain 'type'.  For instance, it will return true for
  90. #   '.leader_is_beast?' if the leader is in fact a beast type.
  91. #
  92. # 6) $game_party.member_regenerate(position)
  93. #        If the member is a random actor, this will regenerate them, just as in
  94. #    the $game_actors script call.  However, this is based on position of
  95. #   party member rather than actual actor's id.
  96. #
  97. #===============================================================================
  98. module RecShops
  99.  
  100.   ##############################################################################
  101.   #                   CUSTOMIZATION  STARTS HERE
  102.   ##############################################################################
  103.  
  104.   #-----------------------------------------------------------------------------
  105.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  106.   #                     SECTION 1, Recruits
  107.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  108.   #-----------------------------------------------------------------------------
  109.   # This section allows you to create the possibilities of your random recruits.
  110.   # It will allow you to change the random pool of names and classes of those
  111.   # recruits which will be generated at runtime.  
  112.   #-----------------------------------------------------------------------------
  113.  
  114.   RANDOM_RECRUIT_POOLS = {#<<<Don't delete this!
  115.  
  116.   # For now, you MUST have three elements in the 'Type' array.  I may expand on
  117.   # this further someday.  Basically, this is just the text that will be displayed
  118.   # in any seen which shows a recruits, (or actor's) type.  I set this up as not
  119.   # only a way to retrieve the strings (or double quoted words in the array), but
  120.   # to design a way to check for type in game.  For now, unless you want to change
  121.   # what you call a male, female or beast, it would be best to skip this constant.
  122.   "Type" => ["male", "female", "beast"],
  123.  
  124.  
  125.   # In this array, add any class which your random recruits can be in.  You do
  126.   # this by placing the class's database id in the array.
  127.   "Human_Classes" => [1, 2, 3, 4, 5, 6, 7, 8],
  128.  
  129.   # This is the same as the human classes, but these are classes that beasts,
  130.   # or (third type from above) can be.
  131.   "Beast_Classes" => [9, 10, 11, 12],
  132.  
  133.   # The names arrays contain possible names for the generated recruits.  When a
  134.   # random recruit is created, the system will pull their names from these
  135.   # arrays, dependent upon which 'type' the random recruit is.
  136.   "Female_Names" => ["Hariett", "Joan", "Breidy", "Hannah", "Sola", "Lelle",
  137.                   "Bertrude", "Farrah", "Lindsey", "Chyann", "Ruby", "Scarlet",
  138.                   "Daye", "April", "Ciera"],
  139.                
  140.   "Male_Names" => ["Charlie", "Vinnie", "Joe", "Rudy", "Langford", "Hobbs", "Curly",
  141.                 "Stephen", "Hans", "Ray", "Louis", "Grady", "Baxter", "Ornswell",
  142.                 "Thadeus", "John", "Parker"],
  143.                
  144.   "Beast_Names" => ["Spot", "Dukker", "Flomp", "Gilly", "Roju", "Heip", "Swazle",
  145.                  "Gnasher", "Jet", "Trayne", "Harkence", "Guju", "Olm"],
  146.  
  147.   # The character arrays are the same as the names arrays, the system will
  148.   # create the character by giving them these character and face sets.  Place
  149.   # the filename of a character set in your Graphics\Characters folder in
  150.   # the 1st position of the array, and the index of the character from that
  151.   # file you wish to use in the 2nd position.  
  152.   #
  153.   #*****************************************************************************
  154.   #                    QUICK NOTE ON RANDOM CHARACTERS
  155.   #*****************************************************************************
  156.   # I may, in the future implement separating the character set from the face
  157.   # set.  But for now, you MUST have a matching faceset to the character set
  158.   # you provide herein.
  159.   #*****************************************************************************
  160.   "Female_Characters" => {  0 => ["Actor1", 1],
  161.                           1 => ["Actor1", 3],
  162.                           2 => ["Actor1", 4],
  163.                           3 => ["Actor1", 5],
  164.                           4 => ["Actor2", 0],
  165.                           5 => ["Actor2", 1],
  166.                           6 => ["Actor2", 3],
  167.                           7 => ["Actor2", 5],
  168.                           8 => ["Actor2", 7],
  169.                           9 => ["Actor3", 1],
  170.                           10 => ["Actor3", 3],
  171.                           11 => ["Actor3", 5],
  172.                           12 => ["Actor3", 7]},
  173.                          
  174.   "Male_Characters" => { 0 => ["Actor1", 0],
  175.                        1 => ["Actor1", 2],
  176.                        2 => ["Actor1", 6],
  177.                        3 => ["Actor1", 7],
  178.                        4 => ["Actor2", 2],
  179.                        5 => ["Actor2", 4],
  180.                        6 => ["Actor2", 6],
  181.                        7 => ["Actor3", 0],
  182.                        8 => ["Actor3", 2],
  183.                        9 => ["Actor3", 4],
  184.                        10 => ["Actor3", 6]},
  185.                        
  186.   "Beast_Characters" => { 0 => ["Animal", 0],
  187.                          1 => ["Animal", 1],
  188.                          2 => ["Animal", 2],
  189.                          3 => ["Animal", 3],
  190.                          4 => ["Animal", 4],
  191.                          5 => ["Animal", 5],
  192.                          6 => ["Animal", 6],
  193.                          7 => ["Animal", 7],
  194.                          8 => ["Monster", 3]}
  195.  
  196.  
  197.  
  198.   }#<<<Don't delete this!
  199.  
  200.   #-----------------------------------------------------------------------------
  201.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  202.   #                       SECTION 2, Random Recruits
  203.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  204.   #-----------------------------------------------------------------------------
  205.   # The following array holds the ids of actors who you want to set as 'random'
  206.   # recruits.  Only place those actor_ids in the array which you want the
  207.   # pc to generate when they first appear in a shop.
  208.   ##############################################################################
  209.   RANDOM_RECRUITS = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
  210.  
  211.   #-----------------------------------------------------------------------------
  212.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  213.   #                       SECTION 3, Pricing
  214.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  215.   #-----------------------------------------------------------------------------
  216.   # Pricing in this system is based on two factors, class and experience level.
  217.   # Price of recruits are figured by multiplying their experience level by the
  218.   # value of their class.
  219.   #
  220.   # The generic pricing value is a backup for if you forget to place the
  221.   # class's id in the PRICE_PER_CLASS_LEVEL hash.  This means that if a price
  222.   # for the class can't be found, the recruits price will be multiplied by the
  223.   # value you set here.
  224.   #-----------------------------------------------------------------------------
  225.   GENERIC_PRICING = 300
  226.   #-----------------------------------------------------------------------------
  227.   # In the next hash, you will give a price to each class.  This means that for
  228.   # every experience level the recruit is, their price will be multiplied by
  229.   # the amount given.
  230.   #
  231.   # Use this formula:
  232.   #
  233.   #       class_id => price_per_level,
  234.   #
  235.   # EXAMPLE:
  236.   #          
  237.   #           4 => 900,
  238.   #
  239.   # In the example above we value a recruit whose class is class number 4 in the
  240.   # database, at 900 gold.  This means that if you were to try and recruit an
  241.   # actor with a level of 6 in this class, it would cost you 5400 gold.  At level
  242.   # 2, it would cost 1800.
  243.   #-----------------------------------------------------------------------------
  244.  
  245.   PRICE_PER_CLASS_LEVEL = {#<<<Don't delete this!
  246.  
  247.   1 => 300,
  248.   2 => 300,
  249.   3 => 300,
  250.   4 => 300,
  251.   5 => 500,
  252.   6 => 500,
  253.   7 => 500,
  254.   8 => 500,
  255.   9 => 400,
  256.   10 => 400,
  257.   11 => 400,
  258.   12 => 400,
  259.  
  260.   }#<<<Don't delete this!
  261.  
  262.  
  263.  
  264.   #-----------------------------------------------------------------------------
  265.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  266.   #                      SECTION 4, Shops
  267.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  268.   #-----------------------------------------------------------------------------
  269.   # The following hash is used to set up recruits.  A recruit is just an actor
  270.   # from the database, but here you can set up the specific shops and the recruits
  271.   # available to that shop.  You can call these shops from the game by placing
  272.   # this script call inside a script command (3rd Tab of Events):
  273.   #                    $scene = Scene_Recruit.new(shop_id)
  274.   # The shop_id should be replaced with a key from the hash below.  That is, the
  275.   # number to the left of the '=>'.
  276.   #
  277.   # In the hash, use this formula:
  278.   #                 shop_id => {"shop_name" => string,
  279.   #                             "seller_face" => filename, index,
  280.   #                             "seller_name" => string,
  281.   #                             "use_variable" => [boolean, value],
  282.   #                             "use_random" => [value, boolean],
  283.   #                             "recruits" => variable_value => [recruit_ids]},
  284.   #
  285.   # This inner hash should retain its keys.  The only part you need to adjust
  286.   # will be the item right of the '=' sign.
  287.   #
  288.   # "shop_id":        Must be unique and in numerical order. (requires integer)
  289.   # "shop_name":      Any name, encompassed with ("") double quotes, you wish to
  290.   #                 name the shop. (requires string)
  291.   # "seller_face":    This array allows you to determine which face file is used
  292.   #                 for the given shop.  Just replace the filename part with
  293.   #                 a file from your Graphics\Faces folder.  And the index part
  294.   #                 with the index of which face on the file you wish to show.
  295.   # "seller_name":  This requires a string, like in the shop_name, which will
  296.   #                 be used as a display for the shopkeeper's name.
  297.   # "use_variable":  This array starts with a boolean (true or false), which is
  298.   #                 used to state whether the shop uses a variable in order to
  299.   #                 make different actors recruitable at different times.  If
  300.   #                 the boolean is true, you need to set the value following the
  301.   #                 boolean to a game variable to be used. If you set the boolean
  302.   #                 to false, then just place a '0' in the variable position.
  303.   # "use_random":    This is a two position array which will be used when
  304.   #                  generating random actors (recruits).  Replace the value,
  305.   #                 with a number to indicate the highest possible level the
  306.   #                 generated actor can be.  Then, replace the boolean with
  307.   #                 whether or not you want to include the 'beast' type in the
  308.   #                 generation.  When this is false, only males or females will
  309.   #                 be created.
  310.   # "recruits":     This hash will contain arrays of the recruits you want to
  311.   #                 be available in the shop.  If you set the '"use_variable"' to
  312.   #                 false, just use an array instead of a hash, use '0' as the
  313.   #                 variable_value.  
  314.   #
  315.   # Because I understand this script may be a little perplexing to those who are
  316.   # not quite scripters, I'll show a few examples here and try to explain them
  317.   # step by step.
  318.   #
  319.   # EXAMPLE 1:
  320.   #             12 => {"shop_name" => "Richard's Recruits",
  321.   #                    "seller_face" => ["People1", 4],
  322.   #                    "use_variable" => [false, 0],
  323.   #                    "use_random" => [3, false],
  324.   #                    "recruits" => {nil => [14, 10, 8, 7, 26, 4]}},
  325.   #
  326.   #  In Example 1, you see that the shop has an ID of 12.  This means, when you
  327.   # call the scene, you will place '12' as the argument for the scene, like
  328.   # this:
  329.   #           $scene = Scene_Recruit.new(12)
  330.   #
  331.   # We called this recruit shop "Richard's Recruits", therefor that's the name
  332.   # which will be displayed when you are in the Recruit Scene.
  333.   #
  334.   # We told the system to show the People1, index 4, for the seller's face.
  335.   #
  336.   # For "use_variable" we chose false, which basically tells us that this shop
  337.   # will ALWAYS have the same actors for recruit, and does not depend upon an
  338.   # in game variable's value to determine its recruit inventory.  We place the
  339.   # zero '0' in the second position, because we chose false in the 1st.
  340.   #
  341.   # In the use_random key, we have another two position array.
  342.   # We set the 1st  position of the array to '3' to signify, the level limit
  343.   # on randomly created recruits. Then we set the second position to 'false',
  344.   # stating that we don't want to generate 'beasts' in this shop.
  345.   #
  346.   # Finally, for the recruits hash, we just used a '0' for a hash key, signifying
  347.   # that these recruit_ids will never change, and therefor we don't need different
  348.   # recruits found when a variable holds a specific value.  Then, we merely filled
  349.   # the array with ids of actors in the database which we will find for recruitment
  350.   # in this recruit shop.  
  351.   #
  352.   # EXAMPLE 2:
  353.   #              9 => {"shop_name" => "The Scrapyard",
  354.   #                   "seller_face" => ["People3", 4]
  355.   #                   "use_variable" => [true, 7],
  356.   #                   "use_random" => [13, true],
  357.   #                   "recruits" => {0 => [14, 6, 3, 18, 121],
  358.   #                               1 => [5, 9, 23, 17, 6, 15, 4, 8],
  359.   #                               2 => [64, 54, 12, 7, 3]}},
  360.   #
  361.   # In Example 2, we used the ID of '9'.  This means, we will use the script
  362.   # call:      
  363.   #           $scene = Scene_Recruit.new(9)
  364.   #
  365.   # We named the shop 'The Scrapyard'.
  366.   #
  367.   # We set the seller's face to People3, index 4.
  368.   #
  369.   # For "use_variable", we placed 'true' in the first position of the array.  
  370.   # This means that we will base which recruits are available in this shop based
  371.   # on the game variable we provided.  In this case, the 7.  So, which recruits
  372.   # are available at this shop is dependent upon the value of variable 7.
  373.   #
  374.   # Next, in the use_random section, we start off by telling
  375.   # the system, via the '13' in the 1st position of the array that when
  376.   # generating random recruits for this shop, that we don't want any recruits
  377.   # whose experience level is above 13. Finally, the 'true' tells us, this
  378.   # shop has the ability to randomly generate beast-type recruits in the
  379.   # third position.
  380.   #
  381.   # Finally, we set up the recruits hash with three different keys (0, 1, 2).  
  382.   # These numbers represent the value of the in game variable (which is number
  383.   # 7 according to this example).  That means that when variable 7 has a value
  384.   # of 0, then those recruits listed after the '0 =>' will be found in the shop.
  385.   # When the value is 1, then those in the array of the '1' hashkey will be
  386.   # in the shop.  And the same applies for 2.  This is awesome, because it lets
  387.   # us change available recruits based on the value of an in game variable. And
  388.   # because, each shop has it's own unique variable, You can make a specific
  389.   # recruit 'travel' from shop to shop.  Showing up in one shop at
  390.   # one point, and at another some other time.  You can also make the same
  391.   # recruit available at both shops at the same time.  
  392.   #
  393.   # &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  394.   # &                AN IMPORTANT NOTE ON RANDOM RECRUITS
  395.   # &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  396.   # When an actor (recruit) is generated, he/she is flagged as such.  This means
  397.   # that the actor will retain this generated status for as long as they are
  398.   # available, unless they are 'unset'.  As a bonus, I placed the ability to
  399.   # script call the '$game_actors[actor_id].unset_actor' method.  This will
  400.   # make it so the given actor will be altered again upon visiting a random
  401.   # shop with his/her id found in the recruits.
  402.   #
  403.   # You should realize that because they retain their 'set' status unless
  404.   # manually unset, they will not be regenerated when they show up in a new
  405.   # shop at a later time.
  406.   # &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  407.   #-----------------------------------------------------------------------------
  408.  
  409.   RECRUIT_SHOPS = {#<<<Don't delete this!
  410.  
  411.   0 => {"shop_name" => "Littletown Services",#<<<Don't forget the commas!
  412.         "seller_face" => ["People3", 3],
  413.         "seller_name" => "Ribby Joe",
  414.         "use_variable" => [false, 0],
  415.         "use_random" => [0, false],
  416.         "recruits" => {0 => [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}},#<<Don't
  417.                                                               #forget to use the
  418.                                                               #double '}}' to end
  419.                                                               #the recruits!!
  420.        
  421.   1 => {"shop_name" => "Vik's Vagabonds",
  422.         "seller_face" => ["People3", 4],
  423.         "seller_name" => "Rogerson",
  424.         "use_variable" => [true, 1],
  425.         "use_random" => [0, false],
  426.         "recruits" => {0 => [6, 9, 12, 13, 15],
  427.                     1 => [6, 9, 12, 13, 14, 15, 16],
  428.                     2 => [7, 8, 10, 11, 14, 15, 16]}},#Here again, double '}}'
  429.                    
  430.   2 => {"shop_name" => "BunchOCruits",
  431.         "seller_face" => ["People1", 4],
  432.         "seller_name" => "Marco",
  433.         "use_variable" => [false, 0],
  434.         "use_random" => [11, true],
  435.         "recruits" => {0 => [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]}},
  436.        
  437.        
  438.   }#<<<<Don't delete this!
  439.  
  440.  
  441.   #-----------------------------------------------------------------------------
  442.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  443.   #                 SECTION 5, Unrandom Types
  444.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  445.   #-----------------------------------------------------------------------------
  446.   #
  447.   # Here you will declare, in the last hash, any actors which will be joining
  448.   # the party WITHOUT coming from a shop.  For example, the ones that start in
  449.   # your party.  Also, those you will be setting up for non-random shops should
  450.   # be included in this hash.
  451.   #
  452.   # This is important, because it allows your unrecruited and
  453.   # non-random actors to inherit the recruitable stat 'type', which you can then
  454.   # use in conditional branches throughout the game.  Use this formula to set
  455.   # it up:
  456.   #
  457.   #       actor_id => type
  458.   #
  459.   # By default, these types are 0 for male, 1 for female, 2 for beast.  You can
  460.   #-----------------------------------------------------------------------------
  461.   UNRANDOM_TYPES = {#<<<Don't delete this!
  462.  
  463.   1 => 0,
  464.   2 => 1,
  465.   3 => 0,
  466.   4 => 1,
  467.   5 => 0,
  468.   6 => 0,
  469.   7 => 1,
  470.   8 => 0,
  471.   9 => 0,
  472.   10 => 0,
  473.   11 => 1,
  474.   12 => 0,
  475.   13 => 1,
  476.   14 => 1,
  477.   15 => 1,
  478.   16 => 0,
  479.  
  480.   }#<<<Don't delete this!
  481.  
  482.   #-----------------------------------------------------------------------------
  483.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  484.   #                        SECTION 6, Extras
  485.   #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  486.   #-----------------------------------------------------------------------------
  487.   # In this section, you'll set up a number of constants which alter things like
  488.   # color of text, windowskins, etc.  All of which are provided to make the
  489.   # scene more customizable.  
  490.   #-----------------------------------------------------------------------------
  491.   SHOP_NAME_COLOR = 12  # Color of text in Shop's Name
  492.  
  493.   # SELLER TEXT DISPLAYS:
  494.   # These arrays hold various possible quotes the seller of the shop will tell
  495.   # you dependent upon what you are doing in the shop.  
  496.  
  497.   # This is the text shown as you enter the shop.
  498.   SELLER_RANDOM_GREETING = ["Searching for a recruit?  You've come to the right place",
  499.                             "Hello there, traveler.  How can I help you?",
  500.                             "Here for a new party member?  Glad to be of service.",
  501.                             "Looks like you could use some help.  Take a look."]
  502.                            
  503.   # This is the text shown while you are browsing.
  504.   SELLER_RANDOM_VIEWING = ["Take your time.", "I'm sure you'll find what you need.",
  505.                            "There's no better recruits anywhere."]
  506.                            
  507.   # This is the text shown when you purchase something.
  508.   SELLER_RANDOM_SELLING = ["You've made a wise purchase.", "Thank you.",
  509.                           "I'm sure this recruit will help you.",
  510.                           "That's the one I had in mind for you."]
  511.  
  512.   # This is the text shown when you leave.
  513.   SELLER_RANDOM_LEAVING = ["See you soon.", "Take it easy.", "Be careful out there.",
  514.                          "Come again."]
  515.                          
  516.   # This is the text shown when you don't have enough gold to purchase a recruit
  517.   SELLER_RANDOM_SHORTFUNDS = ["I would love to sell you this recruit.  But you are short on funds.",
  518.                               "Maybe when you have the correct amount of funds.", "Are you joking?",
  519.                               "Hmm...  Go and get more funds."]
  520.                          
  521.   # This is the text shown when you attempt to purchase recruit when party is full
  522.   SELLER_RANDOM_PARTYFULL = ["You can't buy this recruit when you have a full party.",
  523.                             "But your party is already full.",
  524.                             "Come back when you have room for this recruit."]
  525.                            
  526.   # This is the text shown when you are in an empty shop and choose "Shop"
  527.   SELLER_RANDOM_SHOPEMPTY = ["As you can see, I have nothing more to offer.",
  528.                             "I'd like to help.  But I have no recruits.",
  529.                             "Sorry.  There are no recruits available."]
  530.                            
  531.   SELLER_NAME_COLOR = 20 #Color of Seller's name
  532.                          
  533.   SHOP_COMMAND_SHOP = "Shop" # this is used for the command saying you want to buy
  534.   SHOP_COMMAND_LEAVE = "Exit" # this is used for the command saying you want to leave
  535.   SHOP_COMMAND_COLOR = 3 # this is the color of the shop commands
  536.  
  537.   # This is the windowskin you want to use for all the shop scenes.  Make sure
  538.   # you place it within your Graphics\System folder
  539.   SHOPSKIN = "RecShopSkin"
  540.  
  541.   SHOP_SE_SELECT = "Ice1" # Sound effect played when decision is made
  542.   SHOP_SE_BACK = "Cancel" # Sound effect played when cancelling or leaving
  543.   SHOP_SE_PURCHASE = "Saint9" # Sound effect played when purchase is made
  544.  
  545.   RECRUIT_NAME_COLOR = 10 #Color of text for recruit's name in preview window
  546.   RECRUIT_CLASS_COLOR = 25 #Color of text for recruit's class
  547.   RECRUIT_LEVEL_COLOR = 6 #Color of text for recruit's level
  548.   RECRUIT_PRICE_COLOR = 14 #Color of text for recruit's price
  549.  
  550.   RECRUIT_GOLD_ICON = 205 #Icon from Iconset used to display price of recruit
  551.  
  552.   PARAMETER_TAG_COLOR = 7 #Color of parameter tags (abbreviations)
  553.   RECRUIT_PARAMETER_COLOR = 29 #Color of recruit's parameter values
  554.  
  555.   USE_SHOP_BGM = true #if 'true', the Background music you select below will play
  556.                       #while you are browsing in the Recruit Shop Scene.
  557.   SHOP_BGM = "Scene7" #The background music which will play if the above is true
  558.  
  559.  
  560. end
  561. ################################################################################
  562. #                       END OF CUSTOMIZATION:
  563. #          Don't alter below unless you know what you are doing!
  564. ################################################################################
  565.  
  566. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  567. ################################################################################
  568. #                          Game Temp Class
  569. ################################################################################
  570. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  571. class Game_Temp
  572.  
  573.   attr_accessor :recshop_id
  574.  
  575.   alias recshops_gt_initialize initialize unless $@
  576.   def initialize
  577.     recshops_gt_initialize
  578.     @recshop_id = 0
  579.   end
  580.  
  581. end
  582.  
  583. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  584. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  585. #                          Game Actor Class
  586. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  587. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  588. class Game_Actor < Game_Battler
  589.  
  590.   include RecShops
  591.  
  592.   attr_accessor :is_random
  593.   attr_accessor :is_set
  594.   attr_accessor :type
  595.   attr_accessor :price
  596.   attr_accessor :taken
  597.  
  598.   alias rs_ga_setup setup unless $@
  599.   def setup(actor_id)
  600.     rs_ga_setup(actor_id)
  601.     @type = nil
  602.     @is_set = false
  603.     get_is_random
  604.     set_recruit_price
  605.     nonrand = UNRANDOM_TYPES.keys
  606.     unless @is_random
  607.       if nonrand.include?(actor_id)
  608.         @type = UNRANDOM_TYPES[actor_id]
  609.       else
  610.         @type = 0
  611.         @is_set = true
  612.       end
  613.     end
  614.   end
  615.  
  616.   def get_is_random
  617.     if RANDOM_RECRUITS.include?(self.id)
  618.       @is_random = true
  619.     else
  620.       @is_random = false
  621.     end
  622.   end
  623.  
  624.   # Method can be used in conditional branch
  625.   def is_random?
  626.     if @is_random
  627.       return true
  628.     else
  629.       return false
  630.     end
  631.   end
  632.  
  633.   # Method can be used in conditional branch.
  634.   def is_male?
  635.     if @type == 0
  636.       return true
  637.     else
  638.       return false
  639.     end
  640.   end
  641.  
  642.   # Method can be used in conditional branch.
  643.   def is_female?
  644.     if @type == 1
  645.       return true
  646.     else
  647.       return false
  648.     end
  649.   end
  650.  
  651.   # Method can be used in conditional branch.
  652.   def is_beast?
  653.     if @type == 2
  654.       return true
  655.     else
  656.       return false
  657.     end
  658.   end
  659.  
  660.   #Method generates a random recruit, accepts argument for beast type inclusion
  661.   def produce_random_recruit(level, using_beasts = false)
  662.     set_recruit_type(using_beasts) #passes whether or not to use beasts
  663.     set_recruit_class(@type)               #passes type of recruit
  664.     set_recruit_level(level)
  665.     set_recruit_name(@type)
  666.     set_recruit_character(@type)
  667.     @is_set = true
  668.   end
  669.  
  670.   #Method chooses an appropriate type
  671.   def set_recruit_type(beast)
  672.     if beast
  673.       @type = rand(2)
  674.     else
  675.       @type = rand(1)  #either male or female
  676.     end
  677.   end
  678.  
  679.   #Method chooses appropriate class, accepts argument of recruit type
  680.   def set_recruit_class(type)
  681.     if type < 2                       #if type is human
  682.       pos = RANDOM_RECRUIT_POOLS["Human_Classes"]             #get possible human classes
  683.     elsif type == 2                   #if type is beast
  684.       pos = RANDOM_RECRUIT_POOLS["Beast_Classes"]             #get possible beast classes
  685.     end
  686.     @class_id = pos[rand(pos.size - 1)]  #choose a class
  687.     for i in 0..4                     # Remove equippable items
  688.       change_equip(i, nil)
  689.     end
  690.   end
  691.  
  692.   #Method chooses appropriate name, accepts argument of recruit type
  693.   def set_recruit_name(type)
  694.     case type
  695.     when 0
  696.       pos = RANDOM_RECRUIT_POOLS["Male_Names"]
  697.     when 1
  698.       pos = RANDOM_RECRUIT_POOLS["Female_Names"]
  699.     when 2
  700.       pos = RANDOM_RECRUIT_POOLS["Beast_Names"]
  701.     end
  702.     @name = pos[rand(pos.size - 1)]
  703.   end
  704.  
  705.   #Method chooses appropriate character and face set, accepts argument of type
  706.   def set_recruit_character(type)
  707.     case type
  708.     when 0
  709.       pos = RANDOM_RECRUIT_POOLS["Male_Characters"]
  710.     when 1
  711.       pos = RANDOM_RECRUIT_POOLS["Female_Characters"]
  712.     when 2
  713.       pos = RANDOM_RECRUIT_POOLS["Beast_Characters"]
  714.     end
  715.     set = pos[rand(pos.size - 1)]
  716.     @character_name = set[0]
  717.     @character_index = set[1]
  718.     @face_name = set[0]
  719.     @face_index = set[1]
  720.   end
  721.  
  722.   #Method chooses an appropriate level
  723.   def set_recruit_level(top_lv)
  724.     lv = rand(top_lv)
  725.     self.change_level(lv, false)
  726.   end
  727.    
  728.  
  729.   #Method can be called from script call
  730.   def regenerate_random(top_level)
  731.     unpos = UNRANDOM_TYPES.keys   #only if actor is a random
  732.     unless unpos.include?(@id)
  733.       if @type == 2
  734.         produce_random_recruit(top_level)
  735.       else
  736.         produce_random_recruit(top_level, false)
  737.       end
  738.     end
  739.   end
  740.  
  741.   #Method sets price of actors (recruits)
  742.   def set_recruit_price
  743.     if PRICE_PER_CLASS_LEVEL.include?(@class_id)
  744.       @price = PRICE_PER_CLASS_LEVEL[@class_id]
  745.       @price *= @level
  746.     else
  747.       @price = GENERIC_PRICING
  748.       @price *= @level
  749.     end
  750.   end
  751.  
  752.   #Method makes a new actor 'taken'
  753.   def make_taken
  754.     @taken = true
  755.   end
  756.  
  757.   #Method makes new actor untaken, enabling resale of actor
  758.   def make_untaken
  759.     @taken = false
  760.   end
  761.  
  762.   #Method makes actor 'unset', allowing them to be regenerated by shops
  763.   def unset_actor
  764.     if RANDOM_RECRUITS.include?(self.id) && @is_set
  765.       @is_set = false
  766.     end
  767.   end
  768.  
  769. end
  770.  
  771. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  772. ################################################################################
  773. #                          GAME PARTY CLASS
  774. ################################################################################
  775. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  776. class Game_Party < Game_Unit
  777.  
  778.   include RecShops
  779.  
  780.   # This is an OVERWRITTEN METHOD, this implements the 'taken' variable to
  781.   # actors in the initial party.
  782.   def setup_starting_members
  783.     @actors = []
  784.     for i in $data_system.party_members
  785.       @actors.push(i)
  786.       $game_actors[i].make_taken
  787.     end
  788.   end
  789.  
  790.   #This is an OVERWRITTEN METHOD, this causes added actors to have a 'true'
  791.   # taken variable value.
  792.   def add_actor(actor_id)
  793.     if @actors.size < MAX_MEMBERS and not @actors.include?(actor_id)
  794.       @actors.push(actor_id)
  795.       $game_player.refresh
  796.       $game_actors[actor_id].make_taken
  797.     end
  798.   end
  799.  
  800.   #Aliased method of removing actor from party
  801.   alias recshops_gp_remove_actor remove_actor unless $@
  802.   def remove_actor(actor_id)
  803.     recshops_gp_remove_actor(actor_id)
  804.     $game_actors[actor_id].make_untaken
  805.   end
  806.  
  807.   #Method used to determine if party is full (returns a boolean)
  808.   def party_is_full
  809.     if @actors.size < MAX_MEMBERS
  810.       return false
  811.     else
  812.       return true
  813.     end
  814.   end
  815.  
  816.   #Method can be called from conditional branch
  817.   def has_males?(amount)
  818.     mm = 0
  819.     for actor in members
  820.       if actor.type == 0   #if actor is a male
  821.         mm += 1
  822.       end
  823.     end
  824.     if mm >= amount    # if there is an adequate amount of males
  825.       return true
  826.     else
  827.       return false
  828.     end
  829.   end
  830.  
  831.   #Method can be called from conditional branch
  832.   def has_females?(amount)
  833.     fm = 0
  834.     for actor in members
  835.       if actor.type == 1 # if actor is a female
  836.         fm += 1
  837.       end
  838.     end
  839.     if fm >= amount  # if there is an adequate amount of females
  840.       return true
  841.     else
  842.       return false
  843.     end
  844.   end
  845.  
  846.   #Method can be called from conditional branch
  847.   def has_beasts?(amount)
  848.     bm = 0
  849.     for actor in members
  850.       if actor.type == 2  #if member is a beast
  851.         bm += 1
  852.       end
  853.     end
  854.     if bm >= amount  # if there is an adequate amount of beasts
  855.       return true
  856.     else
  857.       return false
  858.     end
  859.   end
  860.  
  861.   #Method can be called from conditional branch
  862.   def leader_is_male?
  863.     if members[0].type == 0  #if leader is male
  864.       return true
  865.     else
  866.       return false
  867.     end
  868.   end
  869.  
  870.   #Method can be called from conditional branch
  871.   def leader_is_female?
  872.     if members[0].type == 1 #if leader is female
  873.       return true
  874.     else
  875.       return false
  876.     end
  877.   end
  878.  
  879.   #Method can be called from conditional branch
  880.   def leader_is_beast?
  881.     if members[0].type == 2 #if leader is beast
  882.       return true
  883.     else
  884.       return false
  885.     end
  886.   end
  887.  
  888.   #Method can be called from script call
  889.   def member_regenerate(position)
  890.     impos = UNRANDOM_TYPES.keys
  891.     unless impos.include?(members[position].id)
  892.       if members[position].type == 2
  893.         members[position].produce_random_recruit(true)
  894.       else
  895.         members[position].produce_random_recruit
  896.       end
  897.     end
  898.   end
  899.  
  900. end
  901.  
  902. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  903. ################################################################################
  904. #                           WINDOW BASE CLASS
  905. ################################################################################
  906. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  907. class Window_Base < Window
  908.  
  909.   include RecShops
  910.  
  911.   def draw_recruit_price(recruit_id, x, y)
  912.     price = $game_actors[recruit_id].price
  913.         if $game_party.gold >= price
  914.       enabled = true
  915.     else
  916.       enabled = false
  917.     end
  918.     draw_icon(RECRUIT_GOLD_ICON, x, y, enabled)
  919.     self.contents.font.color = text_color(RECRUIT_PRICE_COLOR)
  920.     self.contents.font.color.alpha = enabled ? 255 : 128
  921.     self.contents.draw_text(x + 30, y, self.width, WLH, price.to_s)
  922.   end
  923.  
  924. end
  925.  
  926. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  927. ################################################################################
  928. #                           WINDOW GOLD CLASS
  929. ################################################################################
  930. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  931. class Window_Gold < Window_Base
  932.  
  933.   include RecShops
  934.  
  935.   alias recshop_wg_initialize initialize unless $@
  936.   def initialize(x, y)
  937.     if $scene.is_a?(Scene_Recruit)
  938.       super(x, y, 162, 80)
  939.       self.windowskin = Cache.system(SHOPSKIN)
  940.       refresh
  941.     else
  942.       recshop_wg_initialize(x, y)
  943.     end
  944.   end
  945.  
  946.   alias recshop_wg_refresh refresh unless $@
  947.   def refresh
  948.     if $scene.is_a?(Scene_Recruit)
  949.       self.contents.clear
  950.       draw_currency_value($game_party.gold, 4, 15, 120)
  951.     else
  952.       recshop_wg_refresh
  953.     end
  954.   end
  955.  
  956. end
  957.  
  958.      
  959. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  960. ################################################################################
  961. #                         WINDOW RECRUIT SHOP NAME CLASS
  962. ################################################################################
  963. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  964. class Window_RecruitShopName < Window_Base
  965.  
  966.   include RecShops
  967.  
  968.   def initialize(id)
  969.     super(285, 0, 260, 80)
  970.     @id = id
  971.     self.windowskin = Cache.system(SHOPSKIN)
  972.     refresh
  973.   end
  974.  
  975.   def refresh
  976.     self.contents.font.color = text_color(SHOP_NAME_COLOR)
  977.     self.contents.font.bold = true
  978.     self.contents.draw_text(-13, 10, self.width, WLH, RECRUIT_SHOPS[@id]["shop_name"], 1)
  979.     self.contents.font.bold = false
  980.   end
  981.  
  982. end
  983.  
  984. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  985. ################################################################################
  986. #                         WINDOW RECRUIT SELLER CLASS
  987. ################################################################################
  988. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  989. class Window_RecruitShopSeller < Window_Base
  990.  
  991.   include RecShops
  992.  
  993.   attr_accessor :text_value
  994.  
  995.   def initialize(id)
  996.     super(285, 81, 260, 226)
  997.     @id = id
  998.     self.windowskin = Cache.system(SHOPSKIN)
  999.     @face = RECRUIT_SHOPS[@id]["seller_face"][0]
  1000.     @facedex = RECRUIT_SHOPS[@id]["seller_face"][1]
  1001.     @seller_name = RECRUIT_SHOPS[@id]["seller_name"]
  1002.     @text_value = 0
  1003.     refresh
  1004.   end
  1005.  
  1006.   def refresh
  1007.     self.contents.clear
  1008.     draw_face(@face, @facedex, 30, 0, size = 96)
  1009.     self.contents.font.color = text_color(SELLER_NAME_COLOR)
  1010.     self.contents.draw_text(130, 40, self.width, WLH, @seller_name)
  1011.     update_seller_text
  1012.   end
  1013.  
  1014.   def update_seller_text
  1015.     self.contents.font.color = normal_color
  1016.     case @text_value
  1017.     when 0
  1018.       srg = SELLER_RANDOM_GREETING
  1019.       self.contents.draw_paragraph(0, 110, 220, self.height, srg[rand(srg.size - 1)])
  1020.     when 1
  1021.       srv = SELLER_RANDOM_VIEWING
  1022.       self.contents.draw_paragraph(0, 110, 220, self.height, srv[rand(srv.size - 1)])
  1023.     when 2
  1024.       srs = SELLER_RANDOM_SELLING
  1025.       self.contents.draw_paragraph(0, 110, 220, self.height, srs[rand(srs.size - 1)])
  1026.     when 3
  1027.       srl = SELLER_RANDOM_LEAVING
  1028.       self.contents.draw_paragraph(0, 110, 220, self.height, srl[rand(srl.size - 1)])
  1029.     when 4
  1030.       srsf = SELLER_RANDOM_SHORTFUNDS
  1031.       self.contents.draw_paragraph(0, 110, 220, self.height, srsf[rand(srsf.size - 1)])
  1032.     when 5
  1033.       srpf = SELLER_RANDOM_PARTYFULL
  1034.       self.contents.draw_paragraph(0, 110, 220, self.height, srpf[rand(srpf.size - 1)])
  1035.     when 6
  1036.       srse = SELLER_RANDOM_SHOPEMPTY
  1037.       self.contents.draw_paragraph(0, 110, 220, self.height, srse[rand(srse.size - 1)])
  1038.     end
  1039.   end
  1040.  
  1041. end
  1042.  
  1043. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1044. ################################################################################
  1045. #                        WINDOW RECRUIT COMMANDS CLASS
  1046. ################################################################################
  1047. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1048. class Window_RecruitCommands < Window_Selectable
  1049.  
  1050.   include RecShops
  1051.  
  1052.   def initialize
  1053.     super(0, 0, 120, 80)
  1054.     self.windowskin = Cache.system(SHOPSKIN)
  1055.     @id = id
  1056.     @c1 = SHOP_COMMAND_SHOP
  1057.     @c2 = SHOP_COMMAND_LEAVE
  1058.     @commands = [@c1, @c2]
  1059.     @item_max = @commands.size
  1060.     refresh
  1061.     self.index = 0
  1062.   end
  1063.  
  1064.   def refresh
  1065.     self.contents.clear
  1066.     for i in 0...@item_max
  1067.       draw_items(i)
  1068.     end
  1069.   end
  1070.  
  1071.   def draw_items(index)
  1072.     rect = item_rect(index)
  1073.     rect.x += 4
  1074.     rect.width -= 8
  1075.     self.contents.font.color = text_color(SHOP_COMMAND_COLOR)
  1076.     self.contents.draw_text(rect, @commands[index], 1)
  1077.   end
  1078.  
  1079. end
  1080.  
  1081. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1082. ################################################################################
  1083. #                     WINDOW RECRUIT CONFIRM PURCHASE CLASS
  1084. ################################################################################
  1085. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1086. class Window_RecruitConfirmPurchase < Window_Selectable
  1087.  
  1088.   include RecShops
  1089.  
  1090.   def initialize(name)
  1091.     super(120, 180, 160, 90)
  1092.     self.windowskin = Cache.system(SHOPSKIN)
  1093.     @c1 = "Recruit " + name + "?"
  1094.     @c2 = "Cancel"
  1095.     @commands = [@c1, @c2]
  1096.     @item_max = @commands.size
  1097.     refresh
  1098.     self.index = 0
  1099.   end
  1100.  
  1101.   def refresh
  1102.     self.contents.clear
  1103.     for i in 0...@item_max
  1104.       draw_items(i)
  1105.     end
  1106.   end
  1107.  
  1108.   def draw_items(index)
  1109.     rect = item_rect(index)
  1110.     rect.x += 4
  1111.     rect.width -= 8
  1112.     self.contents.font.color = text_color(SHOP_COMMAND_COLOR)
  1113.     self.contents.draw_text(rect, @commands[index], 1)
  1114.   end
  1115.  
  1116. end
  1117.  
  1118. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1119. ################################################################################
  1120. #                        WINDOW RECRUITS CLASS
  1121. ################################################################################
  1122. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1123. class Window_Recruits < Window_Selectable
  1124.  
  1125.   include RecShops
  1126.  
  1127.   attr_accessor :shopvar
  1128.   attr_accessor :recruit_ids
  1129.   attr_accessor :price
  1130.  
  1131.   def initialize(x, y, width, height)
  1132.     super(x, y, width, height)
  1133.     self.windowskin = Cache.system(SHOPSKIN)
  1134.     @shop_id = $game_temp.recshop_id
  1135.     get_shop_variable
  1136.     get_recruit_ids
  1137.     get_random_recruits
  1138.     get_commands
  1139.     @item_max = @commands.size
  1140.     refresh
  1141.   end
  1142.  
  1143.   def get_shop_variable
  1144.     if RECRUIT_SHOPS[@shop_id]["use_variable"][0]
  1145.       var = RECRUIT_SHOPS[@shop_id]["use_variable"][1]
  1146.       @shopvar = $game_variables[var]
  1147.     else
  1148.       @shopvar = 0
  1149.     end
  1150.   end
  1151.  
  1152.   def get_recruit_ids
  1153.     @recruit_ids = RECRUIT_SHOPS[@shop_id]["recruits"][@shopvar]
  1154.     for i in @recruit_ids
  1155.       if $game_actors[i].taken
  1156.         @recruit_ids.delete(i)
  1157.       end
  1158.     end
  1159.   end
  1160.  
  1161.   def get_random_recruits
  1162.     top_lv = RECRUIT_SHOPS[@shop_id]["use_random"][0]
  1163.     beasts = RECRUIT_SHOPS[@shop_id]["use_random"][1]
  1164.     for i in @recruit_ids
  1165.       if $game_actors[i].is_random
  1166.         unless $game_actors[i].is_set
  1167.           $game_actors[i].produce_random_recruit(top_lv, beasts)
  1168.           $game_actors[i].set_recruit_price
  1169.         end
  1170.       end
  1171.     end
  1172.   end
  1173.  
  1174.   def get_commands
  1175.     @commands = []
  1176.     for i in @recruit_ids
  1177.       @commands.push($game_actors[i].name)
  1178.     end
  1179.   end
  1180.  
  1181.   def refresh
  1182.     self.contents.clear
  1183.     create_contents
  1184.     for i in 0...@item_max
  1185.       draw_items(i)
  1186.     end
  1187.   end
  1188.  
  1189.   def draw_items(index, enabled = true)
  1190.     rect = item_rect(index)
  1191.     rect.x += 4
  1192.     rect.width -= 8
  1193.     self.contents.clear_rect(rect)
  1194.     get_recruit_price(index)
  1195.     if $game_party.gold >= @price
  1196.       enabled = true
  1197.     else
  1198.       enabled = false
  1199.     end
  1200.     self.contents.font.color = text_color(RECRUIT_NAME_COLOR)
  1201.     self.contents.font.color.alpha = enabled ? 255 : 128
  1202.     self.contents.draw_text(rect, @commands[index])
  1203.     draw_recruit_price(@recruit_ids[index], rect.x + 160, rect.y)
  1204.   end
  1205.  
  1206.   def get_recruit_price(index)
  1207.     recruit = $game_actors[@recruit_ids[index]]
  1208.     @price = recruit.price
  1209.   end
  1210.  
  1211.   def reset_after_purchase
  1212.     get_shop_variable
  1213.     get_recruit_ids
  1214.     get_random_recruits
  1215.     get_commands
  1216.     @item_max = @commands.size
  1217.   end
  1218.  
  1219.  
  1220. end
  1221.  
  1222. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1223. ################################################################################
  1224. #                       WINDOW RECRUIT PREVIEW CLASS
  1225. ################################################################################
  1226. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1227. class Window_RecruitPreview < Window_Base
  1228.  
  1229.   include RecShops
  1230.  
  1231.   attr_accessor :shopvar
  1232.   attr_accessor :display_id
  1233.  
  1234.   def initialize(shop_id, shopvar, display_id)
  1235.     super(0, 307, 284, 110)
  1236.     self.windowskin = Cache.system(SHOPSKIN)
  1237.     @shop_id = shop_id
  1238.     @shopvar = shopvar
  1239.     @display_id = display_id
  1240.     refresh
  1241.   end
  1242.  
  1243.   def refresh
  1244.     self.contents.clear
  1245.     create_contents
  1246.     recruit_id = RECRUIT_SHOPS[@shop_id]["recruits"][@shopvar][@display_id]
  1247.     recruit = $game_actors[recruit_id]
  1248.     draw_actor_face(recruit, 0, 0, 96)
  1249.     draw_actor_graphic(recruit, 235, 44)
  1250.     self.contents.font.color = text_color(RECRUIT_LEVEL_COLOR)
  1251.     self.contents.draw_text(105, 0, self.width, WLH, "LV " + recruit.level.to_s)
  1252.     self.contents.font.color = text_color(RECRUIT_CLASS_COLOR)
  1253.     self.contents.draw_text(105, WLH, self.width, WLH, recruit.class.name)
  1254.   end
  1255.  
  1256. end
  1257.  
  1258. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1259. ################################################################################
  1260. #                        WINDOW RECRUIT PARAMETERS CLASS
  1261. ################################################################################
  1262. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1263. class Window_RecruitParameters < Window_Base
  1264.  
  1265.   include RecShops
  1266.  
  1267.   attr_accessor :shopvar
  1268.   attr_accessor :display_id
  1269.  
  1270.   def initialize(shop_id, shopvar, display_id)
  1271.     super(285, 307, 260, 110)
  1272.     self.windowskin = Cache.system(SHOPSKIN)
  1273.     @shop_id = shop_id
  1274.     @shopvar = shopvar
  1275.     @display_id = display_id
  1276.     refresh
  1277.   end
  1278.  
  1279.   def refresh
  1280.     self.contents.clear
  1281.     create_contents
  1282.     recruit_id = RECRUIT_SHOPS[@shop_id]["recruits"][@shopvar][@display_id]
  1283.     recruit = $game_actors[recruit_id]
  1284.     self.contents.font.color = text_color(PARAMETER_TAG_COLOR)
  1285.     self.contents.draw_text(25, 20, self.width, WLH, Vocab::atk)
  1286.     self.contents.draw_text(25, 20 + WLH, self.width, WLH, Vocab::def)
  1287.     self.contents.draw_text(125, 20, self.width, WLH, Vocab::spi)
  1288.     self.contents.draw_text(125, 20 + WLH, self.width, WLH, Vocab::agi)
  1289.     self.contents.font.color = text_color(RECRUIT_PARAMETER_COLOR)
  1290.     self.contents.draw_text(65, 20, self.width, WLH, recruit.atk)
  1291.     self.contents.draw_text(65, 20 + WLH, self.width, WLH, recruit.def)
  1292.     self.contents.draw_text(165, 20, self.width, WLH, recruit.spi)
  1293.     self.contents.draw_text(165, 20 + WLH, self.width, WLH, recruit.agi)
  1294.   end
  1295.  
  1296. end
  1297.  
  1298.  
  1299. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1300. ################################################################################
  1301. #                           SCENE RECRUIT CLASS
  1302. ################################################################################
  1303. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1304. class Scene_Recruit < Scene_Base
  1305.  
  1306.   include RecShops
  1307.  
  1308.   def initialize(shop_id)
  1309.     @shop_id = shop_id
  1310.   end
  1311.  
  1312.   def start
  1313.     super
  1314.     if USE_SHOP_BGM
  1315.       RPG::BGM.new(SHOP_BGM).play
  1316.     end
  1317.     @confirming = false
  1318.     $game_temp.recshop_id = @shop_id
  1319.     @win_commands = Window_RecruitCommands.new
  1320.     @win_gold = Window_Gold.new(121, 0)
  1321.     @win_shopname = Window_RecruitShopName.new(@shop_id)
  1322.     @win_seller = Window_RecruitShopSeller.new(@shop_id)
  1323.     @win_recruits = Window_Recruits.new(0, 81, 284, 226)
  1324.     @shop_available = false
  1325.     unless @win_recruits.recruit_ids.empty?
  1326.       @win_preview = Window_RecruitPreview.new(@shop_id, @win_recruits.shopvar, @win_recruits.index)
  1327.       @win_parameters = Window_RecruitParameters.new(@shop_id, @win_recruits.shopvar, @win_recruits.index)
  1328.       get_current_recruit
  1329.       @shop_available = true
  1330.     end
  1331.     @win_commands.active = true
  1332.   end
  1333.  
  1334.   def update
  1335.     if @win_commands.active
  1336.       @win_commands.update
  1337.       if Input.trigger?(Input::C)
  1338.         case @win_commands.index
  1339.         when 0
  1340.           unless @win_recruits.recruit_ids.empty?
  1341.             RPG::SE.new(SHOP_SE_SELECT, 100, 80).play
  1342.             make_recruits_active
  1343.           else
  1344.             Sound.play_buzzer
  1345.             update_seller_text(6)
  1346.           end
  1347.         when 1
  1348.           RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1349.           update_seller_text(3)
  1350.           Graphics.wait(60)
  1351.           $scene = Scene_Map.new
  1352.         end
  1353.       elsif Input.trigger?(Input::B)
  1354.         RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1355.         update_seller_text(3)
  1356.         Graphics.wait(60)
  1357.         $scene = Scene_Map.new
  1358.       end
  1359.     elsif @win_recruits.active
  1360.       @win_recruits.update
  1361.       get_current_recruit
  1362.       alter_preview_display
  1363.       alter_parameter_display
  1364.       if Input.trigger?(Input::C)
  1365.         if buyable?
  1366.           RPG::SE.new(SHOP_SE_SELECT, 100, 80).play
  1367.           open_confirm_window
  1368.         else
  1369.           Sound.play_buzzer
  1370.           update_seller_text(4)
  1371.           Graphics.wait(140)
  1372.           update_seller_text(1)
  1373.         end
  1374.       elsif Input.trigger?(Input::B)
  1375.         RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1376.         make_commands_active
  1377.       end
  1378.     elsif @confirming
  1379.       @win_confirm.update
  1380.       if Input.trigger?(Input::C)
  1381.         case @win_confirm.index
  1382.         when 0
  1383.           if $game_party.party_is_full
  1384.             Sound.play_buzzer
  1385.             update_seller_text(5)
  1386.             Graphics.wait(140)
  1387.             make_recruits_active
  1388.           else
  1389.             RPG::SE.new(SHOP_SE_PURCHASE, 100, 80).play
  1390.             $game_party.add_actor(@current_recruit_id)
  1391.             $game_party.lose_gold($game_actors[@current_recruit_id].price)
  1392.             update_seller_text(2)
  1393.             @win_recruits.reset_after_purchase
  1394.             Graphics.wait(40)
  1395.             @win_recruits.refresh
  1396.             @win_gold.refresh
  1397.             make_recruits_active
  1398.           end
  1399.         when 1
  1400.           RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1401.           make_recruits_active
  1402.         end
  1403.       elsif Input.trigger?(Input::B)
  1404.         RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1405.         make_recruits_active
  1406.       end
  1407.     end
  1408.   end
  1409.  
  1410.   def make_recruits_active
  1411.     if @confirming
  1412.       update_seller_text(1)
  1413.       @win_confirm.dispose
  1414.       @confirming = false
  1415.       unless @win_recruits.recruit_ids.empty?
  1416.         @win_recruits.index = 0
  1417.         @win_recruits.active = true
  1418.       else
  1419.         @win_recruits.index = -1
  1420.         @win_commands.active = true
  1421.       end
  1422.     else
  1423.       unless @win_recruits.recruit_ids.empty?
  1424.         update_seller_text(1)
  1425.         @win_commands.active = false
  1426.         @win_recruits.index = 0
  1427.         @win_recruits.active = true
  1428.       end
  1429.     end
  1430.   end
  1431.  
  1432.   def update_seller_text(value)
  1433.     @win_seller.text_value = value
  1434.     @win_seller.refresh
  1435.   end
  1436.  
  1437.   def make_commands_active
  1438.     @win_commands.active = true
  1439.     update_seller_text(0)
  1440.     @win_recruits.active = false
  1441.   end
  1442.  
  1443.   def alter_preview_display
  1444.     @win_preview.display_id = @win_recruits.index
  1445.     @win_preview.refresh
  1446.   end
  1447.  
  1448.   def alter_parameter_display
  1449.     @win_parameters.display_id = @win_recruits.index
  1450.     @win_parameters.refresh
  1451.   end
  1452.  
  1453.   def buyable?
  1454.     if $game_party.gold >= $game_actors[@current_recruit_id].price
  1455.       return true
  1456.     else
  1457.       return false
  1458.     end
  1459.   end
  1460.  
  1461.   def open_confirm_window
  1462.     @confirming = true
  1463.     recruit = $game_actors[@current_recruit_id]
  1464.     @win_confirm = Window_RecruitConfirmPurchase.new(recruit.name)
  1465.     @win_recruits.active = false
  1466.     @win_confirm.active = true
  1467.   end
  1468.  
  1469.   def get_current_recruit
  1470.     recruits = RECRUIT_SHOPS[@shop_id]["recruits"][@win_recruits.shopvar]
  1471.     @current_recruit_id = recruits[@win_recruits.index]
  1472.   end
  1473.  
  1474.   def terminate
  1475.     if @win_recruits.recruit_ids.empty? && @shop_available
  1476.       @win_preview.dispose
  1477.       @win_parameters.dispose
  1478.     elsif @win_recruits.recruit_ids.size >= 1
  1479.       @win_preview.dispose
  1480.       @win_parameters.dispose
  1481.     end
  1482.     @win_seller.dispose
  1483.     @win_shopname.dispose
  1484.     @win_gold.dispose
  1485.     @win_recruits.dispose
  1486.     @win_commands.dispose
  1487.     RPG::BGM.fade(3 * 1000)
  1488.   end
  1489.  
  1490. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement