CrowMakerVX

RecruitShops1.1

Jan 1st, 2013
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 55.13 KB | None | 0 0
  1. ################################################################################
  2.  
  3. #                            RECRUIT SHOPS
  4. #                             By: Ixfuru
  5. #                             version 1.1
  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_TYPE_COLOR = 15
  549.   RECRUIT_PRICE_COLOR = 14 #Color of text for recruit's price
  550.  
  551.   RECRUIT_GOLD_ICON = 205 #Icon from Iconset used to display price of recruit
  552.  
  553.   PARAMETER_TAG_COLOR = 7 #Color of parameter tags (abbreviations)
  554.   RECRUIT_PARAMETER_COLOR = 29 #Color of recruit's parameter values
  555.  
  556.   USE_SHOP_BGM = true #if 'true', the Background music you select below will play
  557.                       #while you are browsing in the Recruit Shop Scene.
  558.   SHOP_BGM = "Scene7" #The background music which will play if the above is true
  559.  
  560.  
  561. end
  562. ################################################################################
  563. #                       END OF CUSTOMIZATION:
  564. #          Don't alter below unless you know what you are doing!
  565. ################################################################################
  566.  
  567. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  568. ################################################################################
  569. #                          Game Temp Class
  570. ################################################################################
  571. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  572. class Game_Temp
  573.  
  574.   attr_accessor :recshop_id
  575.  
  576.   alias recshops_gt_initialize initialize unless $@
  577.   def initialize
  578.     recshops_gt_initialize
  579.     @recshop_id = 0
  580.   end
  581.  
  582. end
  583.  
  584. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  585. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  586. #                          Game Actor Class
  587. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  588. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  589. class Game_Actor < Game_Battler
  590.  
  591.   include RecShops
  592.  
  593.   attr_accessor :is_random
  594.   attr_accessor :is_set
  595.   attr_accessor :type
  596.   attr_accessor :price
  597.   attr_accessor :taken
  598.  
  599.   alias rs_ga_setup setup unless $@
  600.   def setup(actor_id)
  601.     rs_ga_setup(actor_id)
  602.     @type = nil
  603.     @is_set = false
  604.     get_is_random
  605.     set_recruit_price
  606.     nonrand = UNRANDOM_TYPES.keys
  607.     unless @is_random
  608.       if nonrand.include?(actor_id)
  609.         @type = UNRANDOM_TYPES[actor_id]
  610.       else
  611.         @type = 0
  612.         @is_set = true
  613.       end
  614.     end
  615.   end
  616.  
  617.   def get_is_random
  618.     if RANDOM_RECRUITS.include?(self.id)
  619.       @is_random = true
  620.     else
  621.       @is_random = false
  622.     end
  623.   end
  624.  
  625.   # Method can be used in conditional branch
  626.   def is_random?
  627.     if @is_random
  628.       return true
  629.     else
  630.       return false
  631.     end
  632.   end
  633.  
  634.   # Method can be used in conditional branch.
  635.   def is_male?
  636.     if @type == 0
  637.       return true
  638.     else
  639.       return false
  640.     end
  641.   end
  642.  
  643.   # Method can be used in conditional branch.
  644.   def is_female?
  645.     if @type == 1
  646.       return true
  647.     else
  648.       return false
  649.     end
  650.   end
  651.  
  652.   # Method can be used in conditional branch.
  653.   def is_beast?
  654.     if @type == 2
  655.       return true
  656.     else
  657.       return false
  658.     end
  659.   end
  660.  
  661.   #Method generates a random recruit, accepts argument for beast type inclusion
  662.   def produce_random_recruit(level, using_beasts = false)
  663.     set_recruit_type(using_beasts) #passes whether or not to use beasts
  664.     set_recruit_class(@type)               #passes type of recruit
  665.     set_recruit_level(level)
  666.     set_recruit_name(@type)
  667.     set_recruit_character(@type)
  668.     @is_set = true
  669.   end
  670.  
  671.   #Method chooses an appropriate type
  672.   def set_recruit_type(beast)
  673.     if beast
  674.       @type = rand(2)
  675.     else
  676.       @type = rand(1)  #either male or female
  677.     end
  678.   end
  679.  
  680.   #Method chooses appropriate class, accepts argument of recruit type
  681.   def set_recruit_class(type)
  682.     if type < 2                       #if type is human
  683.       pos = RANDOM_RECRUIT_POOLS["Human_Classes"]             #get possible human classes
  684.     elsif type == 2                   #if type is beast
  685.       pos = RANDOM_RECRUIT_POOLS["Beast_Classes"]             #get possible beast classes
  686.     end
  687.     @class_id = pos[rand(pos.size - 1)]  #choose a class
  688.     for i in 0..4                     # Remove equippable items
  689.       change_equip(i, nil)
  690.     end
  691.   end
  692.  
  693.   #Method chooses appropriate name, accepts argument of recruit type
  694.   def set_recruit_name(type)
  695.     case type
  696.     when 0
  697.       pos = RANDOM_RECRUIT_POOLS["Male_Names"]
  698.     when 1
  699.       pos = RANDOM_RECRUIT_POOLS["Female_Names"]
  700.     when 2
  701.       pos = RANDOM_RECRUIT_POOLS["Beast_Names"]
  702.     end
  703.     @name = pos[rand(pos.size - 1)]
  704.   end
  705.  
  706.   #Method chooses appropriate character and face set, accepts argument of type
  707.   def set_recruit_character(type)
  708.     case type
  709.     when 0
  710.       pos = RANDOM_RECRUIT_POOLS["Male_Characters"]
  711.     when 1
  712.       pos = RANDOM_RECRUIT_POOLS["Female_Characters"]
  713.     when 2
  714.       pos = RANDOM_RECRUIT_POOLS["Beast_Characters"]
  715.     end
  716.     set = pos[rand(pos.size - 1)]
  717.     @character_name = set[0]
  718.     @character_index = set[1]
  719.     @face_name = set[0]
  720.     @face_index = set[1]
  721.   end
  722.  
  723.   #Method chooses an appropriate level
  724.   def set_recruit_level(top_lv)
  725.     lv = rand(top_lv)
  726.     self.change_level(lv, false)
  727.   end
  728.    
  729.  
  730.   #Method can be called from script call
  731.   def regenerate_random(top_level)
  732.     unpos = UNRANDOM_TYPES.keys   #only if actor is a random
  733.     unless unpos.include?(@id)
  734.       if @type == 2
  735.         produce_random_recruit(top_level)
  736.       else
  737.         produce_random_recruit(top_level, false)
  738.       end
  739.     end
  740.   end
  741.  
  742.   #Method sets price of actors (recruits)
  743.   def set_recruit_price
  744.     if PRICE_PER_CLASS_LEVEL.include?(@class_id)
  745.       @price = PRICE_PER_CLASS_LEVEL[@class_id]
  746.       @price *= @level
  747.     else
  748.       @price = GENERIC_PRICING
  749.       @price *= @level
  750.     end
  751.   end
  752.  
  753.   #Method makes a new actor 'taken'
  754.   def make_taken
  755.     @taken = true
  756.   end
  757.  
  758.   #Method makes new actor untaken, enabling resale of actor
  759.   def make_untaken
  760.     @taken = false
  761.   end
  762.  
  763.   #Method makes actor 'unset', allowing them to be regenerated by shops
  764.   def unset_actor
  765.     if RANDOM_RECRUITS.include?(self.id) && @is_set
  766.       @is_set = false
  767.     end
  768.   end
  769.  
  770. end
  771.  
  772. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  773. ################################################################################
  774. #                          GAME PARTY CLASS
  775. ################################################################################
  776. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  777. class Game_Party < Game_Unit
  778.  
  779.   include RecShops
  780.  
  781.   # This is an OVERWRITTEN METHOD, this implements the 'taken' variable to
  782.   # actors in the initial party.
  783.   def setup_starting_members
  784.     @actors = []
  785.     for i in $data_system.party_members
  786.       @actors.push(i)
  787.       $game_actors[i].make_taken
  788.     end
  789.   end
  790.  
  791.   #This is an OVERWRITTEN METHOD, this causes added actors to have a 'true'
  792.   # taken variable value.
  793.   def add_actor(actor_id)
  794.     if @actors.size < MAX_MEMBERS and not @actors.include?(actor_id)
  795.       @actors.push(actor_id)
  796.       $game_player.refresh
  797.       $game_actors[actor_id].make_taken
  798.     end
  799.   end
  800.  
  801.   #Aliased method of removing actor from party
  802.   alias recshops_gp_remove_actor remove_actor unless $@
  803.   def remove_actor(actor_id)
  804.     recshops_gp_remove_actor(actor_id)
  805.     $game_actors[actor_id].make_untaken
  806.   end
  807.  
  808.   #Method used to determine if party is full (returns a boolean)
  809.   def party_is_full
  810.     if @actors.size < MAX_MEMBERS
  811.       return false
  812.     else
  813.       return true
  814.     end
  815.   end
  816.  
  817.   #Method can be called from conditional branch
  818.   def has_males?(amount)
  819.     mm = 0
  820.     for actor in members
  821.       if actor.type == 0   #if actor is a male
  822.         mm += 1
  823.       end
  824.     end
  825.     if mm >= amount    # if there is an adequate amount of males
  826.       return true
  827.     else
  828.       return false
  829.     end
  830.   end
  831.  
  832.   #Method can be called from conditional branch
  833.   def has_females?(amount)
  834.     fm = 0
  835.     for actor in members
  836.       if actor.type == 1 # if actor is a female
  837.         fm += 1
  838.       end
  839.     end
  840.     if fm >= amount  # if there is an adequate amount of females
  841.       return true
  842.     else
  843.       return false
  844.     end
  845.   end
  846.  
  847.   #Method can be called from conditional branch
  848.   def has_beasts?(amount)
  849.     bm = 0
  850.     for actor in members
  851.       if actor.type == 2  #if member is a beast
  852.         bm += 1
  853.       end
  854.     end
  855.     if bm >= amount  # if there is an adequate amount of beasts
  856.       return true
  857.     else
  858.       return false
  859.     end
  860.   end
  861.  
  862.   #Method can be called from conditional branch
  863.   def leader_is_male?
  864.     if members[0].type == 0  #if leader is male
  865.       return true
  866.     else
  867.       return false
  868.     end
  869.   end
  870.  
  871.   #Method can be called from conditional branch
  872.   def leader_is_female?
  873.     if members[0].type == 1 #if leader is female
  874.       return true
  875.     else
  876.       return false
  877.     end
  878.   end
  879.  
  880.   #Method can be called from conditional branch
  881.   def leader_is_beast?
  882.     if members[0].type == 2 #if leader is beast
  883.       return true
  884.     else
  885.       return false
  886.     end
  887.   end
  888.  
  889.   #Method can be called from script call
  890.   def member_regenerate(position)
  891.     impos = UNRANDOM_TYPES.keys
  892.     unless impos.include?(members[position].id)
  893.       if members[position].type == 2
  894.         members[position].produce_random_recruit(true)
  895.       else
  896.         members[position].produce_random_recruit
  897.       end
  898.     end
  899.   end
  900.  
  901. end
  902.  
  903. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  904. ################################################################################
  905. #                           WINDOW BASE CLASS
  906. ################################################################################
  907. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  908. class Window_Base < Window
  909.  
  910.   include RecShops
  911.  
  912.   def draw_recruit_price(recruit_id, x, y)
  913.     price = $game_actors[recruit_id].price
  914.         if $game_party.gold >= price
  915.       enabled = true
  916.     else
  917.       enabled = false
  918.     end
  919.     draw_icon(RECRUIT_GOLD_ICON, x, y, enabled)
  920.     self.contents.font.color = text_color(RECRUIT_PRICE_COLOR)
  921.     self.contents.font.color.alpha = enabled ? 255 : 128
  922.     self.contents.draw_text(x + 30, y, self.width, WLH, price.to_s)
  923.   end
  924.  
  925. end
  926.  
  927. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  928. ################################################################################
  929. #                           WINDOW GOLD CLASS
  930. ################################################################################
  931. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  932. class Window_Gold < Window_Base
  933.  
  934.   include RecShops
  935.  
  936.   alias recshop_wg_initialize initialize unless $@
  937.   def initialize(x, y)
  938.     if $scene.is_a?(Scene_Recruit)
  939.       super(x, y, 162, 80)
  940.       self.windowskin = Cache.system(SHOPSKIN)
  941.       refresh
  942.     else
  943.       recshop_wg_initialize(x, y)
  944.     end
  945.   end
  946.  
  947.   alias recshop_wg_refresh refresh unless $@
  948.   def refresh
  949.     if $scene.is_a?(Scene_Recruit)
  950.       self.contents.clear
  951.       draw_currency_value($game_party.gold, 4, 15, 120)
  952.     else
  953.       recshop_wg_refresh
  954.     end
  955.   end
  956.  
  957. end
  958.  
  959.      
  960. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  961. ################################################################################
  962. #                         WINDOW RECRUIT SHOP NAME CLASS
  963. ################################################################################
  964. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  965. class Window_RecruitShopName < Window_Base
  966.  
  967.   include RecShops
  968.  
  969.   def initialize(id)
  970.     super(285, 0, 260, 80)
  971.     @id = id
  972.     self.windowskin = Cache.system(SHOPSKIN)
  973.     refresh
  974.   end
  975.  
  976.   def refresh
  977.     self.contents.font.color = text_color(SHOP_NAME_COLOR)
  978.     self.contents.font.bold = true
  979.     self.contents.draw_text(-13, 10, self.width, WLH, RECRUIT_SHOPS[@id]["shop_name"], 1)
  980.     self.contents.font.bold = false
  981.   end
  982.  
  983. end
  984.  
  985. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  986. ################################################################################
  987. #                         WINDOW RECRUIT SELLER CLASS
  988. ################################################################################
  989. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  990. class Window_RecruitShopSeller < Window_Base
  991.  
  992.   include RecShops
  993.  
  994.   attr_accessor :text_value
  995.  
  996.   def initialize(id)
  997.     super(285, 81, 260, 226)
  998.     @id = id
  999.     self.windowskin = Cache.system(SHOPSKIN)
  1000.     @face = RECRUIT_SHOPS[@id]["seller_face"][0]
  1001.     @facedex = RECRUIT_SHOPS[@id]["seller_face"][1]
  1002.     @seller_name = RECRUIT_SHOPS[@id]["seller_name"]
  1003.     @text_value = 0
  1004.     refresh
  1005.   end
  1006.  
  1007.   def refresh
  1008.     self.contents.clear
  1009.     draw_face(@face, @facedex, 30, 0, size = 96)
  1010.     self.contents.font.color = text_color(SELLER_NAME_COLOR)
  1011.     self.contents.draw_text(130, 40, self.width, WLH, @seller_name)
  1012.     update_seller_text
  1013.   end
  1014.  
  1015.   def update_seller_text
  1016.     self.contents.font.color = normal_color
  1017.     case @text_value
  1018.     when 0
  1019.       srg = SELLER_RANDOM_GREETING
  1020.       self.contents.draw_paragraph(0, 110, 220, self.height, srg[rand(srg.size - 1)])
  1021.     when 1
  1022.       srv = SELLER_RANDOM_VIEWING
  1023.       self.contents.draw_paragraph(0, 110, 220, self.height, srv[rand(srv.size - 1)])
  1024.     when 2
  1025.       srs = SELLER_RANDOM_SELLING
  1026.       self.contents.draw_paragraph(0, 110, 220, self.height, srs[rand(srs.size - 1)])
  1027.     when 3
  1028.       srl = SELLER_RANDOM_LEAVING
  1029.       self.contents.draw_paragraph(0, 110, 220, self.height, srl[rand(srl.size - 1)])
  1030.     when 4
  1031.       srsf = SELLER_RANDOM_SHORTFUNDS
  1032.       self.contents.draw_paragraph(0, 110, 220, self.height, srsf[rand(srsf.size - 1)])
  1033.     when 5
  1034.       srpf = SELLER_RANDOM_PARTYFULL
  1035.       self.contents.draw_paragraph(0, 110, 220, self.height, srpf[rand(srpf.size - 1)])
  1036.     when 6
  1037.       srse = SELLER_RANDOM_SHOPEMPTY
  1038.       self.contents.draw_paragraph(0, 110, 220, self.height, srse[rand(srse.size - 1)])
  1039.     end
  1040.   end
  1041.  
  1042. end
  1043.  
  1044. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1045. ################################################################################
  1046. #                        WINDOW RECRUIT COMMANDS CLASS
  1047. ################################################################################
  1048. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1049. class Window_RecruitCommands < Window_Selectable
  1050.  
  1051.   include RecShops
  1052.  
  1053.   def initialize
  1054.     super(0, 0, 120, 80)
  1055.     self.windowskin = Cache.system(SHOPSKIN)
  1056.     @id = id
  1057.     @c1 = SHOP_COMMAND_SHOP
  1058.     @c2 = SHOP_COMMAND_LEAVE
  1059.     @commands = [@c1, @c2]
  1060.     @item_max = @commands.size
  1061.     refresh
  1062.     self.index = 0
  1063.   end
  1064.  
  1065.   def refresh
  1066.     self.contents.clear
  1067.     for i in 0...@item_max
  1068.       draw_items(i)
  1069.     end
  1070.   end
  1071.  
  1072.   def draw_items(index)
  1073.     rect = item_rect(index)
  1074.     rect.x += 4
  1075.     rect.width -= 8
  1076.     self.contents.font.color = text_color(SHOP_COMMAND_COLOR)
  1077.     self.contents.draw_text(rect, @commands[index], 1)
  1078.   end
  1079.  
  1080. end
  1081.  
  1082. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1083. ################################################################################
  1084. #                     WINDOW RECRUIT CONFIRM PURCHASE CLASS
  1085. ################################################################################
  1086. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1087. class Window_RecruitConfirmPurchase < Window_Selectable
  1088.  
  1089.   include RecShops
  1090.  
  1091.   def initialize(name)
  1092.     super(120, 180, 160, 90)
  1093.     self.windowskin = Cache.system(SHOPSKIN)
  1094.     @c1 = "Recruit " + name + "?"
  1095.     @c2 = "Cancel"
  1096.     @commands = [@c1, @c2]
  1097.     @item_max = @commands.size
  1098.     refresh
  1099.     self.index = 0
  1100.   end
  1101.  
  1102.   def refresh
  1103.     self.contents.clear
  1104.     for i in 0...@item_max
  1105.       draw_items(i)
  1106.     end
  1107.   end
  1108.  
  1109.   def draw_items(index)
  1110.     rect = item_rect(index)
  1111.     rect.x += 4
  1112.     rect.width -= 8
  1113.     self.contents.font.color = text_color(SHOP_COMMAND_COLOR)
  1114.     self.contents.draw_text(rect, @commands[index], 1)
  1115.   end
  1116.  
  1117. end
  1118.  
  1119. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1120. ################################################################################
  1121. #                        WINDOW RECRUITS CLASS
  1122. ################################################################################
  1123. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1124. class Window_Recruits < Window_Selectable
  1125.  
  1126.   include RecShops
  1127.  
  1128.   attr_accessor :shopvar
  1129.   attr_accessor :recruit_ids
  1130.   attr_accessor :price
  1131.  
  1132.   def initialize(x, y, width, height)
  1133.     super(x, y, width, height)
  1134.     self.windowskin = Cache.system(SHOPSKIN)
  1135.     @shop_id = $game_temp.recshop_id
  1136.     get_shop_variable
  1137.     get_recruit_ids
  1138.     get_random_recruits
  1139.     get_commands
  1140.     @item_max = @commands.size
  1141.     refresh
  1142.   end
  1143.  
  1144.   def get_shop_variable
  1145.     if RECRUIT_SHOPS[@shop_id]["use_variable"][0]
  1146.       var = RECRUIT_SHOPS[@shop_id]["use_variable"][1]
  1147.       @shopvar = $game_variables[var]
  1148.     else
  1149.       @shopvar = 0
  1150.     end
  1151.   end
  1152.  
  1153.   def get_recruit_ids
  1154.     @recruit_ids = RECRUIT_SHOPS[@shop_id]["recruits"][@shopvar]
  1155.     for i in @recruit_ids
  1156.       if $game_actors[i].taken
  1157.         @recruit_ids.delete(i)
  1158.       end
  1159.     end
  1160.   end
  1161.  
  1162.   def get_random_recruits
  1163.     top_lv = RECRUIT_SHOPS[@shop_id]["use_random"][0]
  1164.     beasts = RECRUIT_SHOPS[@shop_id]["use_random"][1]
  1165.     for i in @recruit_ids
  1166.       if $game_actors[i].is_random
  1167.         unless $game_actors[i].is_set
  1168.           $game_actors[i].produce_random_recruit(top_lv, beasts)
  1169.           $game_actors[i].set_recruit_price
  1170.         end
  1171.       end
  1172.     end
  1173.   end
  1174.  
  1175.   def get_commands
  1176.     @commands = []
  1177.     for i in @recruit_ids
  1178.       @commands.push($game_actors[i].name)
  1179.     end
  1180.   end
  1181.  
  1182.   def refresh
  1183.     self.contents.clear
  1184.     create_contents
  1185.     for i in 0...@item_max
  1186.       draw_items(i)
  1187.     end
  1188.   end
  1189.  
  1190.   def draw_items(index, enabled = true)
  1191.     rect = item_rect(index)
  1192.     rect.x += 4
  1193.     rect.width -= 8
  1194.     self.contents.clear_rect(rect)
  1195.     get_recruit_price(index)
  1196.     if $game_party.gold >= @price
  1197.       enabled = true
  1198.     else
  1199.       enabled = false
  1200.     end
  1201.     self.contents.font.color = text_color(RECRUIT_NAME_COLOR)
  1202.     self.contents.font.color.alpha = enabled ? 255 : 128
  1203.     self.contents.draw_text(rect, @commands[index])
  1204.     draw_recruit_price(@recruit_ids[index], rect.x + 160, rect.y)
  1205.   end
  1206.  
  1207.   def get_recruit_price(index)
  1208.     recruit = $game_actors[@recruit_ids[index]]
  1209.     @price = recruit.price
  1210.   end
  1211.  
  1212.   def reset_after_purchase
  1213.     get_shop_variable
  1214.     get_recruit_ids
  1215.     get_random_recruits
  1216.     get_commands
  1217.     @item_max = @commands.size
  1218.   end
  1219.  
  1220.  
  1221. end
  1222.  
  1223. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1224. ################################################################################
  1225. #                       WINDOW RECRUIT PREVIEW CLASS
  1226. ################################################################################
  1227. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1228. class Window_RecruitPreview < Window_Base
  1229.  
  1230.   include RecShops
  1231.  
  1232.   attr_accessor :shopvar
  1233.   attr_accessor :display_id
  1234.  
  1235.   def initialize(shop_id, shopvar, display_id)
  1236.     super(0, 307, 284, 110)
  1237.     self.windowskin = Cache.system(SHOPSKIN)
  1238.     @shop_id = shop_id
  1239.     @shopvar = shopvar
  1240.     @display_id = display_id
  1241.     refresh
  1242.   end
  1243.  
  1244.   def refresh
  1245.     self.contents.clear
  1246.     create_contents
  1247.     recruit_id = RECRUIT_SHOPS[@shop_id]["recruits"][@shopvar][@display_id]
  1248.     recruit = $game_actors[recruit_id]
  1249.     types = RANDOM_RECRUIT_POOLS["Type"]
  1250.     draw_actor_face(recruit, 0, 0, 96)
  1251.     draw_actor_graphic(recruit, 235, 44)
  1252.     self.contents.font.color = text_color(RECRUIT_LEVEL_COLOR)
  1253.     self.contents.draw_text(105, 0, self.width, WLH, "LV " + recruit.level.to_s)
  1254.     self.contents.font.color = text_color(RECRUIT_CLASS_COLOR)
  1255.     self.contents.draw_text(105, WLH, self.width, WLH, recruit.class.name)
  1256.     self.contents.font.color = text_color(RECRUIT_TYPE_COLOR)
  1257.     type_x = WLH * 2
  1258.     self.contents.draw_text(105, type_x, self.width, WLH, types[recruit.type])
  1259.   end
  1260.  
  1261. end
  1262.  
  1263. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1264. ################################################################################
  1265. #                        WINDOW RECRUIT PARAMETERS CLASS
  1266. ################################################################################
  1267. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1268. class Window_RecruitParameters < Window_Base
  1269.  
  1270.   include RecShops
  1271.  
  1272.   attr_accessor :shopvar
  1273.   attr_accessor :display_id
  1274.  
  1275.   def initialize(shop_id, shopvar, display_id)
  1276.     super(285, 307, 260, 110)
  1277.     self.windowskin = Cache.system(SHOPSKIN)
  1278.     @shop_id = shop_id
  1279.     @shopvar = shopvar
  1280.     @display_id = display_id
  1281.     refresh
  1282.   end
  1283.  
  1284.   def refresh
  1285.     self.contents.clear
  1286.     create_contents
  1287.     recruit_id = RECRUIT_SHOPS[@shop_id]["recruits"][@shopvar][@display_id]
  1288.     recruit = $game_actors[recruit_id]
  1289.     self.contents.font.color = text_color(PARAMETER_TAG_COLOR)
  1290.     self.contents.draw_text(25, 20, self.width, WLH, Vocab::atk)
  1291.     self.contents.draw_text(25, 20 + WLH, self.width, WLH, Vocab::def)
  1292.     self.contents.draw_text(125, 20, self.width, WLH, Vocab::spi)
  1293.     self.contents.draw_text(125, 20 + WLH, self.width, WLH, Vocab::agi)
  1294.     self.contents.font.color = text_color(RECRUIT_PARAMETER_COLOR)
  1295.     self.contents.draw_text(65, 20, self.width, WLH, recruit.atk)
  1296.     self.contents.draw_text(65, 20 + WLH, self.width, WLH, recruit.def)
  1297.     self.contents.draw_text(165, 20, self.width, WLH, recruit.spi)
  1298.     self.contents.draw_text(165, 20 + WLH, self.width, WLH, recruit.agi)
  1299.   end
  1300.  
  1301. end
  1302.  
  1303.  
  1304. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1305. ################################################################################
  1306. #                           SCENE RECRUIT CLASS
  1307. ################################################################################
  1308. #0000000000000000000000000000000000000000000000000000000000000000000000000000000
  1309. class Scene_Recruit < Scene_Base
  1310.  
  1311.   include RecShops
  1312.  
  1313.   def initialize(shop_id)
  1314.     @shop_id = shop_id
  1315.   end
  1316.  
  1317.   def start
  1318.     super
  1319.     if USE_SHOP_BGM
  1320.       RPG::BGM.new(SHOP_BGM).play
  1321.     end
  1322.     @confirming = false
  1323.     $game_temp.recshop_id = @shop_id
  1324.     @win_commands = Window_RecruitCommands.new
  1325.     @win_gold = Window_Gold.new(121, 0)
  1326.     @win_shopname = Window_RecruitShopName.new(@shop_id)
  1327.     @win_seller = Window_RecruitShopSeller.new(@shop_id)
  1328.     @win_recruits = Window_Recruits.new(0, 81, 284, 226)
  1329.     @shop_available = false
  1330.     unless @win_recruits.recruit_ids.empty?
  1331.       @win_preview = Window_RecruitPreview.new(@shop_id, @win_recruits.shopvar, @win_recruits.index)
  1332.       @win_parameters = Window_RecruitParameters.new(@shop_id, @win_recruits.shopvar, @win_recruits.index)
  1333.       get_current_recruit
  1334.       @shop_available = true
  1335.     end
  1336.     @win_commands.active = true
  1337.   end
  1338.  
  1339.   def update
  1340.     if @win_commands.active
  1341.       @win_commands.update
  1342.       if Input.trigger?(Input::C)
  1343.         case @win_commands.index
  1344.         when 0
  1345.           unless @win_recruits.recruit_ids.empty?
  1346.             RPG::SE.new(SHOP_SE_SELECT, 100, 80).play
  1347.             make_recruits_active
  1348.           else
  1349.             Sound.play_buzzer
  1350.             update_seller_text(6)
  1351.           end
  1352.         when 1
  1353.           RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1354.           update_seller_text(3)
  1355.           Graphics.wait(60)
  1356.           $scene = Scene_Map.new
  1357.         end
  1358.       elsif Input.trigger?(Input::B)
  1359.         RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1360.         update_seller_text(3)
  1361.         Graphics.wait(60)
  1362.         $scene = Scene_Map.new
  1363.       end
  1364.     elsif @win_recruits.active
  1365.       @win_recruits.update
  1366.       get_current_recruit
  1367.       alter_preview_display
  1368.       alter_parameter_display
  1369.       if Input.trigger?(Input::C)
  1370.         if buyable?
  1371.           RPG::SE.new(SHOP_SE_SELECT, 100, 80).play
  1372.           open_confirm_window
  1373.         else
  1374.           Sound.play_buzzer
  1375.           update_seller_text(4)
  1376.           Graphics.wait(140)
  1377.           update_seller_text(1)
  1378.         end
  1379.       elsif Input.trigger?(Input::B)
  1380.         RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1381.         make_commands_active
  1382.       end
  1383.     elsif @confirming
  1384.       @win_confirm.update
  1385.       if Input.trigger?(Input::C)
  1386.         case @win_confirm.index
  1387.         when 0
  1388.           if $game_party.party_is_full
  1389.             Sound.play_buzzer
  1390.             update_seller_text(5)
  1391.             Graphics.wait(140)
  1392.             make_recruits_active
  1393.           else
  1394.             RPG::SE.new(SHOP_SE_PURCHASE, 100, 80).play
  1395.             $game_party.add_actor(@current_recruit_id)
  1396.             $game_party.lose_gold($game_actors[@current_recruit_id].price)
  1397.             update_seller_text(2)
  1398.             @win_recruits.reset_after_purchase
  1399.             Graphics.wait(40)
  1400.             @win_recruits.refresh
  1401.             @win_gold.refresh
  1402.             make_recruits_active
  1403.           end
  1404.         when 1
  1405.           RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1406.           make_recruits_active
  1407.         end
  1408.       elsif Input.trigger?(Input::B)
  1409.         RPG::SE.new(SHOP_SE_BACK, 100, 80).play
  1410.         make_recruits_active
  1411.       end
  1412.     end
  1413.   end
  1414.  
  1415.   def make_recruits_active
  1416.     if @confirming
  1417.       update_seller_text(1)
  1418.       @win_confirm.dispose
  1419.       @confirming = false
  1420.       unless @win_recruits.recruit_ids.empty?
  1421.         @win_recruits.index = 0
  1422.         @win_recruits.active = true
  1423.       else
  1424.         @win_recruits.index = -1
  1425.         @win_commands.active = true
  1426.       end
  1427.     else
  1428.       unless @win_recruits.recruit_ids.empty?
  1429.         update_seller_text(1)
  1430.         @win_commands.active = false
  1431.         @win_recruits.index = 0
  1432.         @win_recruits.active = true
  1433.       end
  1434.     end
  1435.   end
  1436.  
  1437.   def update_seller_text(value)
  1438.     @win_seller.text_value = value
  1439.     @win_seller.refresh
  1440.   end
  1441.  
  1442.   def make_commands_active
  1443.     @win_commands.active = true
  1444.     update_seller_text(0)
  1445.     @win_recruits.active = false
  1446.   end
  1447.  
  1448.   def alter_preview_display
  1449.     @win_preview.display_id = @win_recruits.index
  1450.     @win_preview.refresh
  1451.   end
  1452.  
  1453.   def alter_parameter_display
  1454.     @win_parameters.display_id = @win_recruits.index
  1455.     @win_parameters.refresh
  1456.   end
  1457.  
  1458.   def buyable?
  1459.     if $game_party.gold >= $game_actors[@current_recruit_id].price
  1460.       return true
  1461.     else
  1462.       return false
  1463.     end
  1464.   end
  1465.  
  1466.   def open_confirm_window
  1467.     @confirming = true
  1468.     recruit = $game_actors[@current_recruit_id]
  1469.     @win_confirm = Window_RecruitConfirmPurchase.new(recruit.name)
  1470.     @win_recruits.active = false
  1471.     @win_confirm.active = true
  1472.   end
  1473.  
  1474.   def get_current_recruit
  1475.     recruits = RECRUIT_SHOPS[@shop_id]["recruits"][@win_recruits.shopvar]
  1476.     @current_recruit_id = recruits[@win_recruits.index]
  1477.   end
  1478.  
  1479.   def terminate
  1480.     if @win_recruits.recruit_ids.empty? && @shop_available
  1481.       @win_preview.dispose
  1482.       @win_parameters.dispose
  1483.     elsif @win_recruits.recruit_ids.size >= 1
  1484.       @win_preview.dispose
  1485.       @win_parameters.dispose
  1486.     end
  1487.     @win_seller.dispose
  1488.     @win_shopname.dispose
  1489.     @win_gold.dispose
  1490.     @win_recruits.dispose
  1491.     @win_commands.dispose
  1492.     RPG::BGM.fade(3 * 1000)
  1493.   end
  1494.  
  1495. end
Advertisement
Add Comment
Please, Sign In to add comment