CrowMakerVX

ShopSuey1.0

Feb 15th, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 115.76 KB | None | 0 0
  1. ################################################################################
  2. #                        SHOPSUEY 1.0
  3. #                         By: Ixfuru
  4. ################################################################################
  5. # This script creates an entirely new Shop System.  It bypasses nearly every
  6. # aspect and method of the old shop processing, which means that you can still
  7. # have some shops working in the old way if you so choose.  To access a new
  8. # shop, you need only to create an event, go to the third page of the event
  9. # commands and add a script call, by selecting Script and entering this line
  10. # of code in the box which is then provided:
  11. #
  12. #               $scene = Scene_Shopsuey.new(shop_id, shop_keeper_id)
  13. #
  14. # The values you give to replace shop_id and shop_keeper_id are found in the
  15. # settings, where you will set up each shop and shopkeeper.
  16. #
  17. # The script offers a number of features.  These features are all properties of
  18. # the two new classes the script creates.  $game_shops and $game_shopkeepers.
  19. #
  20. # Features linked to the shops are:
  21. #
  22. #                    changeable item selection
  23. #                    item selection based on barter types
  24. #                    item selection based on item type
  25. #                    no sell items
  26. #                    customizable shop background music
  27. #                    customizable shop names
  28. #                    banking
  29. #                    introduction of new shop items through selling
  30. #                    ...and several more
  31. #
  32. # Features linked to the shopkeepers are:
  33. #    
  34. #                   customizable shopkeeper names
  35. #                   shopkeeper graphics
  36. #                   limited shopkeeper gold
  37. #                   pricing adjustments based on actor parameters
  38. #                   customizable dialogue
  39. #
  40. # Other Features are:
  41. #                
  42. #                   new item pricing system
  43. #                   skill which allows selling at 100% of value
  44. #                   skill to always get the best deal
  45. #                   numerous script calls to use for accessing shops and keepers
  46. #
  47. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  48. #                           CONTENTS:
  49. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  50. #
  51. #                SECTION 1: ShopKeepers
  52. #                SECTION 2: Dialogue
  53. #                SECTION 3: Shops
  54. #                SECTION 4: BarterTypes
  55. #                SECTION 5: ShopInventories
  56. #                SECTION 6: ScriptCalls
  57. #                SECTION 7: NoteTags
  58. #                SECTION 8: MiscellaneousSettings
  59. #                SECTION 9: Pricing
  60. #                SECTION 10: Banking
  61. #
  62. #&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  63. # This script is free to use in NON-COMMERCIAL projects.  If you are going
  64. # commercial with your project, you must contact me via RpgmakerVX.net and
  65. # gain authorization.  Upon use either way, credit MUST be provided to Ixfuru.
  66. #&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  67. #
  68. # CONTROLS:
  69. #
  70. # Input in the shop scenes varies dependent upon what shopping phase you are in.  
  71. # However, the main controls are "C" to select the item from list or commands,
  72. # and "B" to go back a phase.  During the "Input" phases, you can use the
  73. # arrow keys to change the value of how many items, or how much money is
  74. # involved in a transaction from the bank.  UP and RIGHT will increase the value,
  75. # while DOWN and LEFT will decrease the value.  
  76. #
  77. # In the banking phase, you can use the "L" and "R" (which is Q and W on the
  78. # keyboard), to toggle the multplier when taking loans and paying them back.  
  79. # This will enable you to increase or decrease the value by more than one
  80. # number at a time.  You can use 1s, 10s, 50s and 100s.
  81. ################################################################################
  82.                    
  83. module Ixfuru
  84.  
  85.   module ShopKeep
  86.    
  87.     SHOPKEEPERS = {#<<<Don't delete this!
  88.    
  89.     #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  90.     # START CONFIGURING
  91.     #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  92.    
  93.     #===========================================================================
  94.     # SECTION 1:
  95.     # ShopKeepers
  96.     # The ShopKeepers hash contains arrays of shopkeepers found in the game.  
  97.     # Here, you will give them an id, and set up their appearances, both
  98.     # character graphic and face graphic.  You will also give them a name.
  99.     # You will give them a dialogue by referencing which dialogue_id
  100.     # they use when communicating with the player.  Set up the dialogues in the
  101.     # constant provided below in Section 2. Ther are also a number of options
  102.     # to set up in the array which involve pricing and shopkeeper gold.  Use
  103.     # the following formula to set the shopkeepers up.
  104.     #
  105.     # keeper_id => [name, char_set, char_index, face_set, face_index, gold,
  106.     #               gold_growth_increase, stat_price, price_stat_base,
  107.     #               price_modifier, dialogue]
  108.     #
  109.     # keeper_id: an integer 0 or greater
  110.     # char_set: the character sheet from which the shopkeeper is shown. File must
  111.     #           be in the Graphics\Characters folder of the project.
  112.     # char_index: the character index on the given char_set sheet to use.
  113.     # face_set: the face sheet from which the shopkeeper is shown.  File must be
  114.     #           in the Graphics\Faces folder of the project.
  115.     # face_index: the face index of the face sheet to use
  116.     # gold: amount of spendable gold the keeper has at onset of game.  In order
  117.     #        for this to be applicable, you have to have the USE_KEEPER_GOLD
  118.     #        constant in Section 3 set to true.
  119.     # gold_growth_increase: the amount of gold which is added to the keeper's gold supply
  120.     #            when a gold growth method call is made.  See section 6, to
  121.     #            learn more.  This makes it so the keeper will regain any gold
  122.     #            they may have lost in bartering with the player over a period
  123.     #            of time.
  124.     # stat_price: true or false; does the keeper modify his prices due to the
  125.     #             stats of the party members.(figured by averaging the stat of
  126.     #             each member.
  127.     # price_stat_base: if stat_price is true, this is the index of which parameter
  128.     #                  to base the price modification on.  Set this as a string.
  129.     #                  it will be converted to a symbol during processing.  This
  130.     #                  makes it possible to use a parameter other than the default
  131.     #                  parameters.  For example, to base the pricing on the ATK
  132.     #                  stat, place "atk" in the array.  So if you are using a
  133.     #                  script which has a new parameter called LUK, you would use
  134.     #                  "luk" in this position.
  135.     # price_modifier: if stat_price is true, this will be used to modify price for
  136.     #                 each point of the average stat.  Take a look at the
  137.     #                following example:
  138.     #                      
  139.     #                      price_stat_base: "spi"
  140.     #                   if the average spi of party members is 65, you would then
  141.     #                  be able to modify it by placing one of the following
  142.     #                 integers into the array for 'price_modifier'.
  143.     #    
  144.     #                        0 = adds the average to the price.
  145.     #                        1 = subtracts the average from the price.
  146.     #                        2 = multiplies the price by that much.
  147.     #                        3 = divides the price by that much.
  148.     #                        4 = modulus the price.  Takes the price, divides it
  149.     #                             by the stat, and whatever is left becomes the
  150.     #                            new price.
  151.     #                        5 = percentage the price.  This is very effective,
  152.     #                            as it takes the stat, multiplies it by the
  153.     #                            default price, and then divides it by 100.  
  154.     #                  
  155.     #                  Be careful when using the multiply and divide, as they
  156.     #                 can end up making items very cheap, or unreasonably high.
  157.     #                  By default, if this number is out of range, (less than 0
  158.     #                 or greater than 6, it will use option 5.
  159.     #===========================================================================
  160.    
  161.     0 => ["Antonio", "People1", 4, "People1", 4, 500, 100, true, "def", 5, 0],
  162.     1 => ["Felicia", "People2", 7, "People2", 7, 1000, 200, false, nil, nil, 1],
  163.    
  164.     }#<<<Don't delete this!
  165.    
  166.     DIALOGUES = {#<<<Don't delete this!
  167.     #===========================================================================
  168.     # SECTION 2
  169.     # Dialogue
  170.     # This hash contains the applicable text displayed as shopkeeper dialogue.
  171.     # You will use a hash to set up the id, and the displayable text displayed
  172.     # in the array.  Use the following formula to set it up:
  173.    
  174.     # dialogue_id => [greeting,
  175.     #                 services,
  176.     #                 start_buy,
  177.     #                 cant_afford,
  178.     #                 buy_thanks,
  179.     #                 start_sell,
  180.     #                 shop_dont_buy,
  181.     #                 sell_thanks,
  182.     #                 farewell,
  183.     #                 new_stock_item
  184.     #                 bank_start1,
  185.     #                 bank_start2,
  186.     #                 bank_take_loan,
  187.     #                 bank_cant_loan,
  188.     #                 bank_pay_loan,
  189.     #                 bank_loan_too_much,
  190.     #                 bank_overpay,
  191.     #                 bank_loan_taken,
  192.     #                 bank_paid_back,
  193.     #                 bank_paid_in_full,
  194.     #                 how_many_buy,
  195.     #                 how_many_sell,
  196.     #                 too_many_items
  197.     #                 no_loan_out],
  198.     #
  199.     # dialogue_id: Must be an integer 0 or greater, used to link the shop with
  200.     #              specific dialogue.
  201.     # greeting: Text first displayed when entering shop scene.
  202.     # services: A word from the shopkeeper about services they offer
  203.     # start_buy: invokes the shopper to take a look at products
  204.     # cant_afford: tells shopper they can't afford a specific item
  205.     # buy_thanks: tells the shopper thank you for buying
  206.     # start_sell: invokes the shopper to show their wares
  207.     # shop_dont_buy: tells shopper the shop doesn't buy a particulare item
  208.     # shop_low_funds: tells shopper shop doesn't have the money to buy.
  209.     # sell_thanks: thanks the shopper for allowing the shop to buy from them
  210.     # farewell: says goodbye to shopper
  211.     # new_stock_item: comments about a seller selling an unlisted item to the
  212.     #                 shop.
  213.     # bank_start1: comments when banking starts, with loan out
  214.     # bank_start2: comments when banking starts, no loan out
  215.     # bank_take_loan: asks how much to loan
  216.     # bank_cant_loan: tells shopper they cant have a loan
  217.     # bank_pay_loan: asks how much to pay back
  218.     # bank_loan_too_much: tells shopper the loan is too high
  219.     # bank_overpay: tells shopper they've paid back more than what was owed
  220.     # bank_loan_taken: explains results of loan
  221.     # bank_paid_back: thanks for the payback
  222.     # bank_paid_in_full: thanks, remarks on payback
  223.     # how_many_buy: asks how many you will buy
  224.     # how_many_sell: asks how many you will sell
  225.     # too_many_items: informs party they don't have that many of the sell item
  226.     # has_no_loan: tells party they have no current loan to pay back.
  227.     #===========================================================================
  228.    
  229.     0 => ["Hello Traveller.  Welcome to my shop.", # greetings
  230.           "I offer rations.  What'll it be?", #services
  231.           "Take a look then.", # start buy
  232.           "You can't afford that!", #can't afford
  233.           "I appreciate your business.", #buy thanks
  234.           "Well let me see what you have there.", # start sell
  235.           "Sorry, I can't buy that from you.",# shop don't buy
  236.           "I seem to be a bit strapped for cash.", #shop low funds
  237.           "I'm sure I can resell this at a reasonable price.", #sell thanks
  238.           "Safe travels, then.", #farewell
  239.           "Ah. A new item to add to my supply!", #new stock item
  240.           "Come to pay back your debt?", #bank start 1
  241.           "Are you here for a loan?", #bank start 2
  242.           "Be sure to pay this back as quickly as you can.", # takes loan
  243.           "Sorry, I can't loan you anything right now.", #No loan
  244.           "How much will you been needing?", # Ask value of loan
  245.           "That's too much.", # too much loan
  246.           "You overpaid.  Here's what's leftover!", #pay back too much
  247.           "Be sure to pay this back.", #loan taken
  248.           "Thanks for the reimbursement.", # paid back
  249.           "Looks like you've paid all the loan back.  Thanks.", #paid back in full
  250.           "How many will you buy?", #how many to buy
  251.           "How many will you sell?",#how many sell
  252.           "But you don't have that many!",#more items than party has
  253.           "You have no current loan."], #nothing to pay back
  254.          
  255.     1 => ["Greetings!",
  256.           "I have a small selection of weapons and armor.",
  257.           "Check 'em out.",
  258.           "That's too much for you.",
  259.           "Great, let me get that for you.",
  260.           "Hope you have what I'm looking for.",
  261.           "No.  I don't typically buy those.",
  262.           "I don't have enough to buy it.",
  263.           "This should look good on my shelves.",
  264.           "Very well.  See you soon I hope.",# See you later
  265.           "Great! I'm sure my shoppers will appreciate this!",#new stock item
  266.           "Come to pay back your debt?", #bank start 1
  267.           "Are you here for a loan?", #bank start 2
  268.           "Be sure to pay this back as quickly as you can.", # takes loan
  269.           "Sorry, I can't loan you anything right now.", #No loan
  270.           "How much will you been needing?", # Ask value of loan
  271.           "That's too much.", # too much loan
  272.           "You overpaid.  Here's what's leftover!", #pay back too much
  273.           "Be sure to pay this back.", #loan taken
  274.           "Thanks for the reimbursement.", # paid back
  275.           "Looks like you've paid all the loan back.  Thanks.", #paid back in full
  276.           "How many will you buy?", #how many to buy
  277.           "How many will you sell?",#how many sell
  278.           "But you don't have that many!",#more items than party has
  279.           "You have no current loan."], #nothing to pay back],
  280.    
  281.     }#<<<Don't delete this!
  282.    
  283.     NO_DIALOGUE = 0 # if no dialogue exists for the keeper, this dialogue from
  284.     #                    the hash will be used in its place.
  285.    
  286.     SHOPS = {#<<<Don't delete this!
  287.     #===========================================================================
  288.     # SECTION 3:
  289.     # Shops
  290.     # The Shops are set up with an id for referencing.  Then, an array is linked
  291.     # to the shop_id which contains information pertaining to that particular
  292.     # shop.  Information includes shop name and services offered. Use the
  293.     # following formula:
  294.     #
  295.     # shop_id => [shop_name, [services], [barter_types], iventory_list, [bgm]]
  296.     #
  297.     # shop_id: Must be an integer 0 or greater
  298.     # shop_name: Any string you wish to use for the displayable name of the shop
  299.     # shop_services: contains the ids of services offered.   This inner array
  300.     #                lists service ids which don't have to be in a specific order.
  301.     #                The service ids are listed below.
  302.     #                        
  303.     #                    0 => buy
  304.     #                    1 => sell
  305.     #                    2 => bank
  306.     #
  307.     #                 If you use the shop as ONLY a bank, you should place the
  308.     #                 placeholder of nil into the barter_types and inventory_list
  309.     #                positions.
  310.     #
  311.     # barter_types: in this inner array, store the ids of the item types you
  312.     #              wish for the shop to carry.  You can set up the barter types
  313.     #              in the BARTER_TYPES hash in Section 5, and use notetags to
  314.     #              reference the ids from there to denote each individual item.
  315.     #              You can place "equipment" instead of using the array if you
  316.     #              want the shop to buy all equipment types.  You can also use
  317.     #              "weapons", "armors" and "items" to bypass the use of filling
  318.     #              in the array or using notetags, and the shop will sell
  319.     #              those respective items without searching notes.  If you want
  320.     #              the shop to buy anything, just place "all" instead of the
  321.     #              array.  But using the array gives
  322.     #              you great command over individual items you want the shop
  323.     #              to be willing to buy.  If the shop is a bank and doesn't
  324.     #              have a real selectable inventory, just place "all" to hold
  325.     #              the place of the array.
  326.     #                        
  327.     # inventory_list: place the id of the SHOP_INVENTORIES you wish to provide
  328.     #              to the player at this shop.  You can set the inventories up
  329.     #              in Section 4.  Also, just use '0' in order to use a bank,
  330.     #              with no inventory.
  331.     #  
  332.     # bgm:  This array requires three values.   A string corresponding to the
  333.     #       filename of the background music you wish to play while in the shop,
  334.     #       a volume and a pitch.  So for example:
  335.     #                  ["Scene1", 80, 60]
  336.     #          This would play the music in the Audio\BGM folder called "Scene1".
  337.     #          It would play it at volume 80 and pitch 60.
  338.     #===========================================================================
  339.    
  340.     0 => ["The Hobbyist", [0, 1], [0, 1], 0, ["Scene7", 80, 100]],
  341.     1 => ["Felecia's Fine Crafts", [0, 1], [3, 4], 1, ["Dungeon6", 80, 100]],
  342.     2 => ["Bank of Ixfuru", [2], "all", 1, ["Dungeon5", 80, 100]],
  343.    
  344.     }#<<<Don't delete this!
  345.    
  346.     BARTER_TYPES = {#<<<Don't delete this!
  347.     #===========================================================================
  348.     # SECTION 4:
  349.     # BarterTypes
  350.     # This hash will hold the ids of given barter types.  That is, the kind of
  351.     # items which are sellable to a shop if the SHOPs hash contains these ids
  352.     # in specific shops.  The ids here are also used in notetags of
  353.     # items/weapons/armors in the database.  See Section 7 for details on this.
  354.     # The following is the formula to set up barter types:
  355.     #
  356.     #        barter_type_id => barter_type_name
  357.     #
  358.     # barter_type_id: an integer 0 or greater
  359.     # barter_type_name: the name used to describe the barter type.
  360.     #
  361.     #===========================================================================
  362.    
  363.     0 => "Rations",
  364.     1 => "Tools",
  365.     2 => "Books",
  366.    
  367.     }#Don't delete this!
  368.    
  369.     SHOP_INVENTORIES = {#<<<Don't delete this!
  370.     #===========================================================================
  371.     # SECTION 5:
  372.     # ShopIventories
  373.     # This hash holds the items which are for sale by default in the specific
  374.     # shops, if the SHOPS hash at their id, holds this specific inventory_id.
  375.     # Each inventory_id links to another inner hash which holds the items
  376.     # which the store sells.   Use this formula to use this part of the script.
  377.     #
  378.     # inventory_id => {item_type => [item_ids]},
  379.     #
  380.     # inventory_id: Must be an integer 0 or greater.  This value is referenced
  381.     #               by the SHOPS constant, and is used to call specific
  382.     #               inventory lists into use.
  383.     # item_type: These are the keys used for the inner hash.  They determine
  384.     #             exactly what kind of items are found in the inventory.  Not
  385.     #            all item_types have to be accounted for.  And keys must be either
  386.     #            0, 1 or 2.  0 for items, 1 for weapons, 2 for armors.
  387.     # item_ids: These values are stored inside an array and are linked to the
  388.     #            specific hash key (item_type) of the inner hash.  So if the
  389.     #            inner key is 1, then it would point to weapons, and then these
  390.     #           values would be the actual database ids of weapons.
  391.     #
  392.     # EXAMPLE>
  393.     #              13 => {0 => [54, 23, 8],
  394.     #                     1 => [12, 13, 17],
  395.     #                     2 => [10]},
  396.     #
  397.     #              This example inventory would be used whenever a shop's
  398.     #            inventory list was set to '13'.  By default, it would offer
  399.     #            items number 54, 23 and 8.  Weapons number 12, 13 and 17.
  400.     #            It would only offer a single armor, which is number 10 in the
  401.     #             database.
  402.     #===========================================================================
  403.    
  404.       0 => {0 => [1, 2, 3, 4, 5, 6, 7, 8]},  #only sells items
  405.      
  406.       1 => {1 => [1, 2, 3, 4, 5, 6],         #sells these weapons
  407.             2 => [1, 2, 3, 4, 5, 6, 7, 8]},   # sells these armors
  408.      
  409.       }#<<<Don't delete this!
  410.    
  411.     #===========================================================================
  412.     # SECTION 6:
  413.     # ScriptCalls
  414.     # There are several script calls which can be used to get the most out of the
  415.     # script.  They are listed below.
  416.     #
  417.     # 1) Calls the Shop Scene:
  418.     #                $scene = Scene_Shopkeep.new(keeper_id, shop_id)
  419.     #    
  420.     #          Pass the arguments with the ids given in the SHOPKEEPERS and
  421.     #            SHOPS constants, respectively.
  422.     #
  423.     # 2) Increases Gold at sellers gold growth rate:
  424.     #
  425.     #                $game_shopkeepers[keeper_id].gold_growth
  426.     #
  427.     # 3) Increases Gold of ALL shopkeepers by their respective growth rates:
  428.     #
  429.     #                $game_shops.gold_growth
  430.     #
  431.     # 4) Resets gold of a specific shopkeeper
  432.     #
  433.     #                 $game_shopkeepers[keeper_id].reset_gold
  434.     #
  435.     # 5) Resets gold of all shopkeepers to default
  436.     #
  437.     #               $game_shopkeepers.reset_gold
  438.     #
  439.     # 6) Checks to determine if a shop will buy a specific item; use in
  440.     #     a conditional branch.
  441.     #                
  442.     #                $game_shops[shop_id].barters_item?(item_id)
  443.     #
  444.     # 7) Resets inventory of a specific shop
  445.     #
  446.     #                $game_shops[shops_id].reset_inventory
  447.     #
  448.     # 8) Resets all shopkeeper inventories
  449.     #
  450.     #                $game_shopkeepers.reset_inventories
  451.     #
  452.     # 9) Checks to see if there is a loan out
  453.     #                $game_bank.loan_out
  454.     #
  455.     #===========================================================================
  456.    
  457.     #===========================================================================
  458.     # Section 7:
  459.     # NoteTags
  460.     # The following can be placed in the notes of items, weapons and armors to
  461.     # utilize shop features.  
  462.     #
  463.     # Use:
  464.     #
  465.     # <barter x>
  466.     #
  467.     # Where x equals the barter_type the item will be listed as.  It is possible
  468.     # to use multiple barter_types on the same item.  For instance, if you create
  469.     # a book, you can place it under books and tools.  Simply by using the id of
  470.     # these barter_types as the 'x'.
  471.     #
  472.     # Use:
  473.     #
  474.     # <unsellable>
  475.     #
  476.     # When this is in the notebox of an item, weapon or armor, the item will not
  477.     # be available for selling, regardless of the price value in the database.
  478.     # This enables you to list the value of rare treasures, without fear of them
  479.     # being sold.
  480.     #
  481.     # Use:
  482.     #
  483.     # <keep_price>
  484.     #
  485.     # When this is in the notebox of an item, weapon or armor, the item will
  486.     # maintain it's default price and bypass the new pricing methods when the
  487.     # USE_RENEWED_PRICING constant of Section 8 is true.
  488.     #
  489.     # Use:
  490.     #
  491.     # <dont_stock>
  492.     #
  493.     # When this is in the notebox of an item, the seller will not stock the item
  494.     # sold, even if it's a new item.
  495.     #===========================================================================
  496.    
  497.     #===========================================================================
  498.     # Section 8:
  499.     # MiscellaneousSettings
  500.     #===========================================================================
  501.     USE_KEEPER_GOLD = true              # makes shopkeepers have limited gold
  502.                                         # for which to buy items from the player.
  503.                                        
  504.     SELL_100_SKILL = 83                # if the LEADER of the party has the skill
  505.                                      #with this id, the party will get 100% of
  506.                                      # value when selling an item to a shop.
  507.                                      
  508.     BUY_FAIR_SKILL = 84              # if the LEADER of the party has the skill
  509.                                      # with this id, they will always get the
  510.                                      # best deal possible when buying from shops.
  511.                                      # this will avoid being ripped off by
  512.                                      # greedy shopkeepers.
  513.    
  514.     USE_RENEWED_PRICING = true       # if this is true, a new formula will be
  515.                                      # used to determine the price of items in
  516.                                      # shops.  This bypasses the price in the
  517.                                      # database completely, and figures a price
  518.                                      # based on what the item actually does.
  519.                                      # Even if this is true, you can bypass the
  520.                                      # method on certain items by placing notes
  521.                                      # which do so in their given notefields. More
  522.                                      # on this in Section 7.
  523.                                      # Also, Items which are priced at zero will
  524.                                      # still be unsellable if this is true.
  525.                                    
  526.     SHOPKEEPER_STYLE = 0            # When 0, will use face; when 1, use character
  527.    
  528.     # The following three constants hold the text which will be displayed in the
  529.     # commands for the shop scene.
  530.     BUY_COMMAND = "Buy"
  531.     SELL_COMMAND = "Sell"
  532.     BANK_COMMAND = "Banking"
  533.    
  534.     SHOP_NAME_COLOR = 26
  535.    
  536.     SHOPKEEPER_NAME_DISPLAY = 0   #if 0, show shopkeeper's name above graphic,
  537.                                   #if 1, show shopkeeper's name below graphic
  538.                                
  539.     # The following array holds the icon_index of each element in the database.
  540.     # If you have a custom IconSet, or are using custom elements, you will need
  541.     # to adjust the icons to match your specific requirements.  Just place the
  542.     # id of the element as the hash key and link it to the icon_index of the
  543.     # element like this:
  544.     #
  545.     # element_id => icon_index
  546.    
  547.     ELEMENT_ICON_IDS = {#<<<Don't delete this!
  548.    
  549.     1 => 110,
  550.     2 => 9,
  551.     3 => 4,
  552.     4 => 14,
  553.     5 => 16,
  554.     6 => 12,
  555.     7 => 129,
  556.     8 => 128,
  557.     9 => 104,
  558.     10 => 105,
  559.     11 => 106,
  560.     12 => 107,
  561.     13 => 108,
  562.     14 => 109,
  563.     15 => 189,
  564.     16 => 111,
  565.    
  566.     }#<<<Don't delete this!
  567.    
  568.     STATE_ICON_IDS = {#<<<Don't delete this!
  569.    
  570.     1 => 112,
  571.     2 => 113,
  572.     3 => 114,
  573.     4 => 115,
  574.     5 => 116,
  575.     6 => 117,
  576.     7 => 118,
  577.     8 => 119,
  578.     9 => 120,
  579.     10 => 121,
  580.     11 => 122,
  581.     12 => 123,
  582.     13 => 124,
  583.     14 => 125,
  584.     15 => 126,
  585.     16 => 127,
  586.    
  587.     }#<<<Don't delete this!
  588.    
  589.     SHOP_GOLD_ICON = 205
  590.     KEEPER_NAME_COLOR = 25
  591.     BUY_SE = "Shop"
  592.     SELL_SE = "Item1"
  593.     BANK_SE = "Chime2"
  594.    
  595.     #===========================================================================
  596.     # SECTION 9:
  597.     # PricingSystem
  598.     #
  599.     # The following group of constants are used in the new pricing system.  If
  600.     # you have bypassed this feature, you won't have to set any of this up.  
  601.     # This gives you complete control at how expensive things are in your
  602.     # project, without you having to mess with a single price in the database.
  603.     # Just remember, however, that certain aspects of the script, like the
  604.     # <keep_price> note tag may require you to set the price on that particular
  605.     # item.  And also keep in mind that even though the script changes 'prices',
  606.     # it does NOT affect the prices of items which are bought or sold
  607.     # through the default system.  Therefor, for anything which will be sold
  608.     # via the old shop processing, the changes you make here won't effect them.
  609.     # So, be careful, if you plan on still calling shops the old way and make
  610.     # sure you have a price set for each of the items you'll be selling that
  611.     # way.
  612.     #
  613.     # The jist of how the system works, is that it values an item based on
  614.     # what it actually does.  That is, the items many parameters you set up in
  615.     # the database.  You will be able to set the value for each one of these
  616.     # parameters and then when the prices are calculated, it will use the
  617.     # settings you provided.  If the parameter in question is one that
  618.     # is displayed as a numeric value (like atk, def, spi, agi), then the
  619.     # value you place will be multiplied by the amount of that parameter, and
  620.     # added to the price.  
  621.     #
  622.     # Look at this example:
  623.     #
  624.     # ATK_FACTOR = 10
  625.     # DEF_FACTOR = 10
  626.     # SPI_FACTOR = 10
  627.     # AGI_FACTOR = 10
  628.     #
  629.     # This example shows that for each point of the factors shown, 10 gold is
  630.     # added to the price of the item.  So if the value of agi in the database
  631.     # was given as 4, then 40 gold would have to be added to the price, as
  632.     # 4 * SPI_FACTOR = 10.
  633.     #
  634.     # For those parameters which don't offer a numeric value, such as States,
  635.     # Elements, Scope, etc., The system will add the factor you place directly.
  636.     # Therefor, those values are treated like a true/false.  If this parameter is
  637.     # checked, add the factor value.
  638.     #
  639.     #
  640.     #There are several item parameters (and by items
  641.     # I mean weapons and armors, too!) that this system doesn't take into
  642.     # account.  One of the main ones is 'CommonEvent'.  This is because, it
  643.     # is unable to determine just what occurs when you call a common event.  
  644.     # So it is highly recommended that you use the <keep_price> note tag on
  645.     # objects which will do this, and set the price of that item yourself.
  646.     #
  647.     # Because you can set up each and every applicable parameter, you will be
  648.     # able to create weapons which take most of their value from their ATK.  
  649.     # Or armors which take the majority of their value from DEF.  Tamper with
  650.     # the settings a little, and then call the shop to see if you like the
  651.     # results.  
  652.     #
  653.     #===========================================================================
  654.    
  655.     # Values that effect ITEMS #
  656.    
  657.     NO_VALUE = 20 # this will be the value of any item, which returns 0 when calculated
  658.    
  659.     # SCOPE FACTORS:
  660.     # The scope factors array holds the values for specific scope selection.
  661.     # Scope determines who is effected by use of the item.  Whether it be
  662.     # targets in combat, or heal targets from the menu.  So, you will need to
  663.     # pass the values inside the array, one for each possible scope parameter.
  664.     # There are 11 scope parameters in all.  When calculating the price, the
  665.     # system will return the value in the array in the position of the item's
  666.     # scope.   So it is important, that the values are set to this specific
  667.     # order.
  668.     #
  669.     # [None, OneEnemy, AllEnemies, OneEnemyDual, OneRandomEnemy, 2 RandomEnemies,
  670.     #  3 Random Enemies, OneAlly, AllAllies, OneAlly(dead), AllAllies(dead),
  671.     #  The User]
  672.     #
  673.     # Calculated as TRUTH VALUE.
  674.     SCOPE_FACTOR = [0, 50, 250, 100, 50, 100, 150, 50, 250, 50, 250, 25]
  675.    
  676.     # In battle, the Speed parameter is used to determine how long a specific
  677.     # item takes to use.  
  678.     #
  679.     # Calculated as PER POINT VALUE
  680.     SPEED_FACTOR = 1
  681.    
  682.     # The base damage value is used to determine initial damage done by an item.
  683.     # Calculated as PER POINT VALUE
  684.     BASE_DAMAGE_FACTOR = 1
  685.    
  686.     # Variance is used in determining base damage, as it gives the actual
  687.     # damage done a range within X amount of the Base Damage parameter.
  688.     # Calculated as PER POINT VALUE
  689.     VARIANCE = 1
  690.    
  691.     # The atk_f and spi_f parameters of an item are used to add to the damage
  692.     # once base_damage and variance are tallied.
  693.     # Calculated as PER POINT VALUE
  694.     ATK_F_FACTOR = 1
  695.     SPI_F_FACTOR = 1
  696.    
  697.     # Physical Attack parameters tell the system that the item is used much like
  698.     # a weapon or melee attack would be.  
  699.     # Calculated as TRUTH VALUE
  700.     PHYS_ATT_FACTOR = 0
  701.    
  702.     # Damage to Mp parameter says take the calculated damage and take it from
  703.     # the target's MP instead of HP.
  704.     # Calculated as TRUTH VALUE
  705.     DAM_TO_MP_FACTOR = 30
  706.    
  707.     # Absorb Damage parameter says take damage dealt to target and add it back
  708.     # in the form of heal to attacker
  709.     # Calculated as TRUTH VALUE
  710.     ABSORB_DAM_FACTOR = 100
  711.    
  712.     #Ignore Defense parameter says bypass any defense factor of the target
  713.     # when attacking with this item
  714.     # Calculated as TRUTH VALUE
  715.     IGNORE_DEF_FACTOR = 250
  716.    
  717.     # Hp Recovery is the value of healing to target's hp is done with item
  718.     # Calculated as POINT PER EVERY VALUE.  This means for every second value
  719.     # placed into the array, the price is increased by the first value
  720.     # in the array.  By default, it's 1 gold for every 20 HP.
  721.     HP_RECOVERY_FACTOR = [1, 20]
  722.    
  723.     # Mp Recovery is the value of healing to target's mp is done with item.
  724.     # Calculated as POINT PER EVERY VALUE, the same as HP.
  725.     MP_RECOVERY_FACTOR = [1, 20]
  726.    
  727.     #Parameter Type and Parameter Points parameters work in coalition.  This
  728.     # factor is figured as POINTS PER TRUTH VALUE, which means that a different
  729.     # POINTS PER VALUE calculation is made dependent upon which parameter type
  730.     # is adjusted by the item.  This item parameter basically adds
  731.     # PERMANENTLY to a given parameter:
  732.     #
  733.     # [None, MaxHP, MaxMP, Attack, Defense, Spirit, Agility]
  734.     #
  735.     PARAMETER_POINTS_FACTOR = [0, 100, 100, 500, 500, 500, 500]
  736.    
  737.     # Element effects are the effects that the element is charged with.  This
  738.     # factor is figured as POINTS PER SIZE VALUE.  Therefor, each element is
  739.     # worth a specific value.  The total value of the Item Element Factor is
  740.     # figured by adding this value once per every element the item is charged
  741.     # with.
  742.     ITEM_ELEMENT_FACTOR = 5
  743.    
  744.     # State values are different for each state.  This value is calculated
  745.     # through a POINTS PER TRUTH VALUE, therefor for each of the states found
  746.     # in the item's effects (both effects which add the state AND subtract the
  747.     # state), the item will receive the value which corresponds with that
  748.     # particular state.  It is important then, that the values in the array are
  749.     # set up in the exact order as they are found in the database.
  750.     # Leave the first value at 'nil' to account for the fact that there is no
  751.     # state with the ID of '0' in the database.
  752.     ITEM_STATE_FACTOR = [nil, 100, 50, 50, 50, 50, 25, 50, 10, 5, 5, 5, 5,
  753.     5, 5, 5, 5]
  754.    
  755.    
  756.     # FOR WEAPONS ONLY:
  757.    
  758.     # Hit parameter is used to determine the accuracy of the weapon
  759.     # Calculated as POINT PER VALUE
  760.     HIT_FACTOR = 1
  761.    
  762.     # Fast Attack is the parameter which is used to say, this weapon gets an
  763.     # early turn during the attacking phase.
  764.     # Calculated as TRUTH VALUE
  765.     FAST_ATTACK_FACTOR = 250
  766.    
  767.     # Dual attack says take the damage dealt by weapon and do it twice to the
  768.     # target.
  769.     # Calculated as TRUTH VALUE
  770.     DUAL_ATTACK_FACTOR = 500
  771.    
  772.     #Critical Bonus, means this weapon is capable of having a perfect strike
  773.     # which can yield a major bonus to damage dealt.
  774.     # Calculated as TRUTH VALUE
  775.     CRITICAL_BONUS_FACTOR = 100
  776.    
  777.     # FOR ARMORS ONLY:
  778.    
  779.     # Evade is the parameter of an armor which making the target who is wearing
  780.     # it harder to hit.  Calculated as POINT PER VALUE
  781.     EVADE_FACTOR = 25
  782.    
  783.     # Prevent Critical makes a critical attack on the wearer of the armor impossible
  784.     # Calculated as TRUTH VALUE
  785.     PREVENT_CRITICAL_FACTOR = 100
  786.    
  787.     # Half MP Cost makes MP drain from skill usage slower by halfing it's
  788.     # specific cost when using it.
  789.     # Calculated as TRUTH VALUE
  790.     HALF_MP_COST_FACTOR = 250
  791.    
  792.     # Double Exp parameter means the wearer of the armor is given twice the
  793.     # experience on battle victories than they would normally get.
  794.     # Calculated as TRUTH VALUE
  795.     DOUBLE_EXP_FACTOR = 1000
  796.    
  797.     # Auto HP Recover parameter means out of battle, the wearer's HP will
  798.     # slowly regenerate on their own.
  799.     # Calculated as TRUTH VALUE
  800.     AUTO_HP_RECOVER_FACTOR = 500
  801.    
  802.     # FOR ALL EQUIPMENTS
  803.    
  804.     # Parameter parameters changet the equipped actor's base parameters when
  805.     # the given equipment is equipped.  Since specific
  806.     # parameters are more crucial whether or not the item is a weapon or an
  807.     # armor, (i.e. You want a weapon with a bigger atk and armor with a better
  808.     # def), the system lists all parameter factors as two-element arrays:
  809.     #
  810.     # [weapon_factor, armor_factor]
  811.     #
  812.     # Calculated as POINT PER VALUE
  813.     ATK_FACTOR = [25, 10]
  814.     DEF_FACTOR = [10, 25]
  815.     SPI_FACTOR = [10, 10]
  816.     AGI_FACTOR = [10, 10]
  817.    
  818.     # Element Set parameter is an array of elements which the item doing the attacking
  819.     # or defending is charged with.  This value is calculated on a POINTS PER
  820.     # SIZE VALUE, which means for every element, add this amount.
  821.     ELEMENT_SET_FACTOR = 1000
  822.    
  823.     # State Set parameter is much like the Element Set factor, except when
  824.     # calculated, it's figured more like the SCOPE_FACTOR, where each
  825.     # specific state is given an individual value.  Calculated as a TRUTH
  826.     # VALUE for each state involved.  Therefor, it will be important to
  827.     # make sure you account for each of the states in the database and
  828.     # set the values in the array to match the order of the states therein.
  829.     #
  830.     # By Default, the states are as follows, if you changed them, you'll have
  831.     # to adjust to match the states in your project.
  832.     #
  833.     # [nil, incapacitated(dead), poison, darkness, silence, confusion, sleep, paralysis,
  834.     #  stun, atkup, defup, spiup, agiup, atkdown, defdown, spidown, agidown]
  835.     #
  836.     # Leave the 1st element of the array at 'nil' to account for the fact that
  837.     # there is no State ID 0.
  838.     #
  839.     STATE_SET_FACTOR = [nil, 1000, 500, 500, 500, 500, 250, 500, 100, 50, 50, 50, 50,
  840.     50, 50, 50, 50]
  841.    
  842.     #===========================================================================
  843.     # SECTION 10:
  844.     # Banking
  845.     #
  846.     # Bank Interest is figured as a percentage.  When payback amount is figured,
  847.     # the formula is as follows:
  848.     #
  849.     #         loan_amount + loan_amount * (interest_percentage / bank_rating)
  850.     #
  851.     # This constant will hold the starting interest percentage.  It should be a
  852.     # number greater than zero and less than 100. I advise never making this
  853.     # value less than 10
  854.     BANK_INTEREST = 50
  855.    
  856.    # The next value sets the Max Loan multipliler.   This value is multiplied
  857.    # by the party's bank rating to adjust how much gold is available for loan
  858.    # at any point in the game.  
  859.    MAX_LOAN_MULTIPLIER = 1000
  860.    
  861.     # This value stores the highest possible bank rating.   I would advise never
  862.     # making this value more than ten.
  863.     MAX_BANK_RATING = 10
  864.    
  865.     # This final bank constant is used to determine at what point, bank rating
  866.     # increases.  It will increase automatically based on the number of
  867.     # loans which have been paid back.  So this value is used to determine
  868.     # how many loans need paid back before the rating increases by 1. By default,
  869.     # the bank rating will grow by one after every 3 loans are paid back in full.
  870.     BANK_RATING_ADJUSTMENT = 3
  871.    
  872.     # Qualifying Loan Amount is the amount of gold one must borrow before it
  873.     # registers against bank paybacks and counts toward the bank rating
  874.     # adjustment.
  875.     QUALIFYING_LOAN_AMOUNT = 500
  876.          
  877.     #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  878.     #  STOP CONFIGURING
  879.     #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  880.    
  881.   end
  882.  
  883.   module Regexp
  884.    
  885.     BARTER_TYPE = /<(barter)[\s]*(\d+)/i
  886.     UNSELLABLE = /<(unsellable)>/i
  887.     KEEP_PRICE = /<(keep_price)>/i
  888.     DONT_STOCK = /<(dont_stock)>/i
  889.    
  890.   end
  891.  
  892. end
  893.  
  894. ################################################################################
  895. #*******************************************************************************
  896. #                            RPG::Item
  897. ################################################################################
  898. class RPG::Item
  899.  
  900.   def barter_type
  901.     self.note.split(/[\r\n]/).each { |line|
  902.     case line
  903.     when Ixfuru::Regexp::BARTER_TYPE
  904.       barter = $2.to_i
  905.       return barter
  906.     end
  907.     }
  908.     return nil
  909.   end
  910.  
  911.   def unsellable
  912.     self.note.split(/[\r\n]/).each { |line|
  913.     case line
  914.     when Ixfuru::Regexp::UNSELLABLE
  915.       return true
  916.     end
  917.     }
  918.     return false
  919.   end
  920.  
  921.   def keep_price
  922.     self.note.split(/[\r\n]/).each { |line|
  923.     case line
  924.     when Ixfuru::Regexp::KEEP_PRICE
  925.       return true
  926.     end
  927.     }
  928.     return false
  929.   end
  930.  
  931.   def dont_stock
  932.     self.note.split(/[\r\n]/).each { |line|
  933.     case line
  934.     when Ixfuru::Regexp::DONT_STOCK
  935.       return true
  936.     end
  937.     }
  938.     return false
  939.   end
  940.  
  941.   def suey_price(action, shopkeeper) #buying or selling
  942.     return @price if keep_price
  943.     return @price unless Ixfuru::ShopKeep::USE_RENEWED_PRICING
  944.     result = Ixfuru::ShopKeep::NO_VALUE
  945.     result += Ixfuru::ShopKeep::SCOPE_FACTOR[@scope]
  946.     result += Ixfuru::ShopKeep::SPEED_FACTOR * @speed
  947.     unless @base_damage < 0
  948.       result += Ixfuru::ShopKeep::BASE_DAMAGE_FACTOR * @base_damage
  949.     end
  950.     result += Ixfuru::ShopKeep::VARIANCE * @variance
  951.     result += Ixfuru::ShopKeep::ATK_F_FACTOR * @atk_f
  952.     result += Ixfuru::ShopKeep::SPI_F_FACTOR * @spi_f
  953.     if @physical_attack
  954.       result += Ixfuru::ShopKeep::PHYS_ATT_FACTOR
  955.     end
  956.     if @damage_to_mp
  957.       result += Ixfuru::ShopKeep::DAM_TO_MP_FACTOR
  958.     end
  959.     if @absorb_damage
  960.       result += Ixfuru::ShopKeep::ABSORB_DAM_FACTOR
  961.     end
  962.     if @ignore_defense
  963.       result += Ixfuru::ShopKeep::IGNORE_DEF_FACTOR
  964.     end
  965.     for i in 1..@element_set.size
  966.       if @element_set.include?($data_system.elements[i])
  967.         result += Ixfuru::ShopKeep::ITEM_ELEMENT_FACTOR
  968.       end
  969.     end
  970.     for i in 1..@plus_state_set.size
  971.       if @plus_state_set.include?($data_states[i])
  972.         result += Ixfuru::ShopKeep::ITEM_STATE_FACTOR[i]
  973.       end
  974.     end
  975.     for i in 1..@minus_state_set.size
  976.       if @minus_state_set.include?($data_states[i])
  977.         result += Ixfuru::ShopKeep::STATE_SET_FACTOR[i]
  978.       end
  979.     end
  980.     result += (@hp_recovery / Ixfuru::ShopKeep::HP_RECOVERY_FACTOR[1]) * Ixfuru::ShopKeep::HP_RECOVERY_FACTOR[0]
  981.     result += (@mp_recovery / Ixfuru::ShopKeep::MP_RECOVERY_FACTOR[1]) * Ixfuru::ShopKeep::MP_RECOVERY_FACTOR[0]
  982.     result += Ixfuru::ShopKeep::PARAMETER_POINTS_FACTOR[@parameter_type]
  983.     case action
  984.     when 0
  985.       if $game_party.members[0].skills.include?(Ixfuru::ShopKeep::BUY_FAIR_SKILL)
  986.         if result < 1
  987.           result = 1
  988.         end
  989.         return result
  990.       else
  991.         if shopkeeper.stat_price
  992.           result = shopkeeper.stat_price_adjustment
  993.           if result < 1
  994.             result = 1
  995.           end
  996.           return result
  997.         else
  998.           if result < 1
  999.             result = 1
  1000.           end
  1001.           return result
  1002.         end
  1003.       end
  1004.     when 1
  1005.       if $game_party.members[0].skills.include?(Ixfuru::ShopKeep::SELL_100_SKILL)
  1006.         if result < 1
  1007.           result = 1
  1008.         end
  1009.         return result
  1010.       else
  1011.         result / 2
  1012.         if result < 1
  1013.           result = 1
  1014.         end
  1015.         return result
  1016.       end
  1017.     end
  1018.   end
  1019.    
  1020. end
  1021.  
  1022. ################################################################################
  1023. #*******************************************************************************
  1024. #                             RPG::Weapon
  1025. ################################################################################
  1026. class RPG::Weapon
  1027.  
  1028.   def barter_type
  1029.     self.note.split(/[\r\n]/).each { |line|
  1030.     case line
  1031.     when Ixfuru::Regexp::BARTER_TYPE
  1032.       barter = $2.to_i
  1033.       return barter
  1034.     end
  1035.     }
  1036.     return nil
  1037.   end
  1038.  
  1039.   def unsellable
  1040.     self.note.split(/[\r\n]/).each { |line|
  1041.     case line
  1042.     when Ixfuru::Regexp::UNSELLABLE
  1043.       return true
  1044.     end
  1045.     }
  1046.     return false
  1047.   end
  1048.  
  1049.   def keep_price
  1050.     self.note.split(/[\r\n]/).each { |line|
  1051.     case line
  1052.     when Ixfuru::Regexp::KEEP_PRICE
  1053.       return true
  1054.     end
  1055.     }
  1056.     return false
  1057.   end
  1058.  
  1059.   def dont_stock
  1060.     self.note.split(/[\r\n]/).each { |line|
  1061.     case line
  1062.     when Ixfuru::Regexp::DONT_STOCK
  1063.       return true
  1064.     end
  1065.     }
  1066.     return false
  1067.   end
  1068.  
  1069.   def suey_price(action, shopkeeper)
  1070.     return @price if keep_price
  1071.     return @price unless Ixfuru::ShopKeep::USE_RENEWED_PRICING
  1072.     result = Ixfuru::ShopKeep::NO_VALUE
  1073.     for i in 1..@element_set.size
  1074.       if @element_set.include?($data_system.elements[i])
  1075.         result += Ixfuru::ShopKeep::ELEMENT_SET_FACTOR
  1076.       end
  1077.     end
  1078.     for i in 1..@state_set.size
  1079.       if @state_set.include?($data_states[i])
  1080.         result += Ixfuru::ShopKeep::STATE_SET_FACTOR[i]
  1081.       end
  1082.     end
  1083.     result += Ixfuru::ShopKeep::ATK_FACTOR[0] * @atk
  1084.     result += Ixfuru::ShopKeep::DEF_FACTOR[0] * @def
  1085.     result += Ixfuru::ShopKeep::SPI_FACTOR[0] * @spi
  1086.     result += Ixfuru::ShopKeep::AGI_FACTOR[0] * @agi
  1087.     result += Ixfuru::ShopKeep::HIT_FACTOR * @hit
  1088.     if @fast_attack
  1089.       result += Ixfuru::ShopKeep::FAST_ATTACK_FACTOR
  1090.     end
  1091.     if @dual_attack
  1092.       result += Ixfuru::ShopKeep::DUAL_ATTACK_FACTOR
  1093.     end
  1094.     if @critical_bonus
  1095.       result += Ixfuru::ShopKeep::CRITICAL_BONUS_FACTOR
  1096.     end
  1097.     case action
  1098.     when 0
  1099.       if $game_party.members[0].skills.include?(Ixfuru::ShopKeep::BUY_FAIR_SKILL)
  1100.         if result < 1
  1101.           result = 1
  1102.         end
  1103.         return result
  1104.       else
  1105.         if shopkeeper.stat_price
  1106.           result = shopkeeper.stat_price_adjustment
  1107.           if result < 1
  1108.             result = 1
  1109.           end
  1110.           return result
  1111.         else
  1112.           if result < 1
  1113.             result = 1
  1114.           end
  1115.           return result
  1116.         end
  1117.       end
  1118.     when 1
  1119.       if $game_party.members[0].skills.include?(Ixfuru::ShopKeep::SELL_100_SKILL)
  1120.         if result < 1
  1121.           result = 1
  1122.         end
  1123.         return result
  1124.       else
  1125.         result / 2
  1126.         if result < 1
  1127.           result = 1
  1128.         end
  1129.         return result
  1130.       end
  1131.     end
  1132.   end
  1133.    
  1134. end
  1135.  
  1136. ################################################################################
  1137. #*******************************************************************************
  1138. #                             RPG::Armor
  1139. ################################################################################
  1140. class RPG::Armor
  1141.  
  1142.   def barter_type
  1143.     self.note.split(/[\r\n]/).each { |line|
  1144.     case line
  1145.     when Ixfuru::Regexp::BARTER_TYPE
  1146.       barter = $2.to_i
  1147.       return barter
  1148.     end
  1149.     }
  1150.     return nil
  1151.   end
  1152.  
  1153.   def unsellable
  1154.     self.note.split(/[\r\n]/).each { |line|
  1155.     case line
  1156.     when Ixfuru::Regexp::UNSELLABLE
  1157.       return true
  1158.     end
  1159.     }
  1160.     return false
  1161.   end
  1162.  
  1163.   def keep_price
  1164.     self.note.split(/[\r\n]/).each { |line|
  1165.     case line
  1166.     when Ixfuru::Regexp::KEEP_PRICE
  1167.       return true
  1168.     end
  1169.     }
  1170.     return false
  1171.   end
  1172.  
  1173.   def dont_stock
  1174.     self.note.split(/[\r\n]/).each { |line|
  1175.     case line
  1176.     when Ixfuru::Regexp::DONT_STOCK
  1177.       return true
  1178.     end
  1179.     }
  1180.     return false
  1181.   end
  1182.  
  1183.   def suey_price(action, shopkeeper)
  1184.     return @price if keep_price
  1185.     return @price unless Ixfuru::ShopKeep::USE_RENEWED_PRICING
  1186.     result = Ixfuru::ShopKeep::NO_VALUE
  1187.     for i in 1..@element_set.size
  1188.       if @element_set.include?($data_system.elements[i])
  1189.         result += Ixfuru::ShopKeep::ELEMENT_SET_FACTOR
  1190.       end
  1191.     end
  1192.     for i in 1..@state_set.size
  1193.       if @state_set.include?($data_states[i])
  1194.         result += Ixfuru::ShopKeep::STATE_SET_FACTOR[i]
  1195.       end
  1196.     end
  1197.     result += Ixfuru::ShopKeep::ATK_FACTOR[0] * @atk
  1198.     result += Ixfuru::ShopKeep::DEF_FACTOR[0] * @def
  1199.     result += Ixfuru::ShopKeep::SPI_FACTOR[0] * @spi
  1200.     result += Ixfuru::ShopKeep::AGI_FACTOR[0] * @agi
  1201.     result += Ixfuru::ShopKeep::EVADE_FACTOR * @eva
  1202.     if @prevent_critical
  1203.       result += Ixfuru::ShopKeep::PREVENT_CRITICAL_FACTOR
  1204.     end
  1205.     if @half_mp_cost
  1206.       result += Ixfuru::ShopKeep::HALF_MP_COST_FACTOR
  1207.     end
  1208.     if @double_exp_gain
  1209.       result += Ixfuru::ShopKeep::DOUBLE_EXP_FACTOR
  1210.     end
  1211.     if @auto_hp_recover
  1212.       result += Ixfuru::ShopKeep::AUTO_HP_RECOVER
  1213.     end
  1214.     case action
  1215.     when 0
  1216.       if $game_party.members[0].skills.include?(Ixfuru::ShopKeep::BUY_FAIR_SKILL)
  1217.         if result < 1
  1218.           result = 1
  1219.         end
  1220.         return result
  1221.       else
  1222.         if shopkeeper.stat_price
  1223.           result = shopkeeper.stat_price_adjustment
  1224.           if result < 1
  1225.             result = 1
  1226.           end
  1227.           return result
  1228.         else
  1229.           if result < 1
  1230.             result = 1
  1231.           end
  1232.           return result
  1233.         end
  1234.       end
  1235.     when 1
  1236.       if $game_party.members[0].skills.include?(Ixfuru::ShopKeep::SELL_100_SKILL)
  1237.         if result < 1
  1238.           result = 1
  1239.         end
  1240.         return result
  1241.       else
  1242.         result / 2
  1243.         if result < 1
  1244.           result = 1
  1245.         end
  1246.         return result
  1247.       end
  1248.     end
  1249.   end
  1250.  
  1251. end
  1252.  
  1253. ################################################################################
  1254. #*******************************************************************************
  1255. #                           SCENE TITLE
  1256. ################################################################################
  1257. class Scene_Title < Scene_Base
  1258.  
  1259.   #--------------------------------------------------------------------------
  1260.   # * Create Game Objects (Aliased)
  1261.   #--------------------------------------------------------------------------
  1262.   alias ix_shops_sctitle_create_game_objects create_game_objects unless $@
  1263.   def create_game_objects
  1264.     ix_shops_sctitle_create_game_objects
  1265.     $game_shops         = Game_Shops.new
  1266.     $game_shopkeepers   = Game_Shopkeepers.new
  1267.     $game_bank          = Game_Bank.new
  1268.   end
  1269.  
  1270. end
  1271.  
  1272. ################################################################################
  1273. #*******************************************************************************
  1274. #                       SCENE FILE
  1275. ################################################################################
  1276. class Scene_File < Scene_Base
  1277.  
  1278.   #-----------------------------------------------------------------------------
  1279.   # Read Save Data (Aliased)
  1280.   #-----------------------------------------------------------------------------
  1281.   alias ix_shops_scfile_read_save_data read_save_data unless $@
  1282.   def read_save_data(file)
  1283.     $game_shops = Marshal.load(file)
  1284.     $game_shopkeepers = Marshal.load(file)
  1285.     $game_bank        = Marshal.load(file)
  1286.     ix_shops_scfile_read_save_data(file)
  1287.   end
  1288.  
  1289.   #-----------------------------------------------------------------------------
  1290.   # Write Save Data (Aliased)
  1291.   #-----------------------------------------------------------------------------
  1292.   alias ix_shops_scfile_write_save_data write_save_data unless $@
  1293.   def write_save_data(file)
  1294.     ix_shops_scfile_write_save_data(file)
  1295.     Marshal.dump($game_shops, file)
  1296.     Marshal.dump($game_shopkeepers, file)
  1297.     Marshal.dump($game_bank, file)
  1298.   end
  1299.  
  1300. end
  1301.  
  1302. ################################################################################
  1303. #*******************************************************************************
  1304. #                           GAME SHOP
  1305. ################################################################################
  1306. class Game_Shop
  1307.  
  1308.   attr_reader :shop_id
  1309.   attr_reader :name
  1310.   attr_reader :services
  1311.   attr_reader :barter_types
  1312.   attr_reader :inventory_list
  1313.   attr_reader :bgm
  1314.   attr_accessor :inventory
  1315.  
  1316.   #--------------------------------------------------------------------------
  1317.   # * Object Initialization
  1318.   #     shop_id : shop ID
  1319.   #--------------------------------------------------------------------------
  1320.   def initialize(shop_id)
  1321.     super()
  1322.     unless @shop_set
  1323.       @iventory_set = false
  1324.       setup(shop_id)
  1325.     end
  1326.   end
  1327.  
  1328.   #--------------------------------------------------------------------------
  1329.   # * Setup
  1330.   #     shop_id : shop ID
  1331.   #--------------------------------------------------------------------------
  1332.   def setup(shop_id)
  1333.     shop = Ixfuru::ShopKeep::SHOPS[shop_id]
  1334.     @shop_id = shop_id
  1335.     @name = shop[0]
  1336.     @services = shop[1]
  1337.     @barter_types = shop[2]
  1338.     @inventory_list = shop[3]
  1339.     @bgm = shop[4]
  1340.     @inventory = inventory
  1341.     @shop_set = true
  1342.   end
  1343.  
  1344.   #-----------------------------------------------------------------------------
  1345.   # Get Inventory
  1346.   #-----------------------------------------------------------------------------
  1347.   def inventory
  1348.     unless @inventory_set
  1349.       result = []
  1350.       for key in Ixfuru::ShopKeep::SHOP_INVENTORIES[@inventory_list].keys
  1351.         case key
  1352.         when 0 # items
  1353.           for item in Ixfuru::ShopKeep::SHOP_INVENTORIES[@inventory_list][key]
  1354.             result.push($data_items[item])
  1355.           end
  1356.         when 1 # weapons
  1357.           for weapon in Ixfuru::ShopKeep::SHOP_INVENTORIES[@inventory_list][key]
  1358.             result.push($data_weapons[weapon])
  1359.           end
  1360.         when 2 # armors
  1361.           for armor in Ixfuru::ShopKeep::SHOP_INVENTORIES[@inventory_list][key]
  1362.             result.push($data_armors[armor])
  1363.           end
  1364.         end
  1365.       end
  1366.       @inventory = result
  1367.       @inventory_set = true
  1368.       return @inventory
  1369.     end
  1370.     return @inventory
  1371.   end
  1372.  
  1373.   #-----------------------------------------------------------------------------
  1374.   # Barters Item:
  1375.   # By passing this method the argument of an item, you can see if the given shop
  1376.   # will purchase the item from the player.  This can be set up in a conditional
  1377.   # branch.
  1378.   #-----------------------------------------------------------------------------
  1379.   def barters_item?(item)
  1380.     return false if item.unsellable
  1381.     if @services.include?(1)
  1382.       return false if @barter_types == nil
  1383.       if @barter_types.is_a?(Array)
  1384.         if @barter_types.include?(item.barter_type)
  1385.           return true
  1386.         else
  1387.           return false
  1388.         end
  1389.       else
  1390.         if @barter_types == "all"
  1391.           return true
  1392.         elsif @barter_types == "items" && item.is_a?(RPG::Item)
  1393.           return true
  1394.         elsif @barter_types == "equipment"
  1395.           if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)
  1396.             return true
  1397.           else
  1398.             return false
  1399.           end
  1400.         elsif @barter_types == "weapons" && item.is_a?(RPG::Weapon)
  1401.           return true
  1402.         elsif @barter_types == "armors" && item.is_a?(RPG::Armor)
  1403.           return true
  1404.         end
  1405.       end
  1406.     else
  1407.       return false
  1408.     end
  1409.   end
  1410.  
  1411.   #-----------------------------------------------------------------------------
  1412.   # Reset Inventory
  1413.   #-----------------------------------------------------------------------------
  1414.   def reset_inventory
  1415.     @inventory_set = false
  1416.   end
  1417.  
  1418.   #-----------------------------------------------------------------------------
  1419.   # Services
  1420.   #-----------------------------------------------------------------------------
  1421.   def services
  1422.     result = []
  1423.     if !@services.empty?
  1424.       for i in 0...@services.size
  1425.         case @services[i]
  1426.         when 0 # buys
  1427.           result.push(Ixfuru::ShopKeep::BUY_COMMAND)
  1428.         when 1 # allows sell
  1429.           result.push(Ixfuru::ShopKeep::SELL_COMMAND)
  1430.         when 2 # banking permitted
  1431.           result.push(Ixfuru::ShopKeep::BANK_COMMAND)
  1432.         end
  1433.       end
  1434.       return result
  1435.     end
  1436.   end
  1437.  
  1438.   #-----------------------------------------------------------------------------
  1439.   # Add to Inventory
  1440.   #-----------------------------------------------------------------------------
  1441.   def add_to_inventory(item)
  1442.     unless @inventory.include?(item)
  1443.       @inventory.push(item)
  1444.     end
  1445.   end
  1446.  
  1447. end
  1448.  
  1449. ################################################################################
  1450. #*******************************************************************************
  1451. #                           GAME SHOPKEEPER
  1452. ################################################################################
  1453. class Game_Shopkeeper
  1454.  
  1455.   attr_reader :name
  1456.   attr_reader :char_set
  1457.   attr_reader :char_index
  1458.   attr_reader :face_set
  1459.   attr_reader :face_index
  1460.   attr_accessor :gold
  1461.   attr_reader :gold_growth_increase
  1462.   attr_reader :stat_price
  1463.   attr_reader :price_stat_base
  1464.   attr_reader :price_modifier
  1465.  
  1466.   def initialize(keeper_id)
  1467.     super()
  1468.     unless @keeper_set
  1469.       @gold_set = false
  1470.       setup(keeper_id)
  1471.     end
  1472.   end
  1473.  
  1474.   #-----------------------------------------------------------------------------
  1475.   # Setup:
  1476.   #
  1477.   # keeper_id => [name, char_set, char_index, face_set, face_index, gold,
  1478.   #               gold_growth_increase, stat_price, price_stat_base,
  1479.   #               price_modifier, dialogue]
  1480.   #
  1481.   #-----------------------------------------------------------------------------
  1482.  
  1483.   def setup(keeper_id)
  1484.     keeper = Ixfuru::ShopKeep::SHOPKEEPERS[keeper_id]
  1485.     @keeper_id = keeper_id
  1486.     @name = keeper[0]
  1487.     @char_set = keeper[1]
  1488.     @char_index = keeper[2]
  1489.     @face_set = keeper[3]
  1490.     @face_index = keeper[4]
  1491.     @gold_growth_increase = keeper[6]
  1492.     @state_price = keeper[7]
  1493.     @stat_price_base = keeper[8]
  1494.     @price_modifier = keeper[9]
  1495.     @gold = gold
  1496.     @keeper_set = true
  1497.   end
  1498.  
  1499.   #-----------------------------------------------------------------------------
  1500.   # Get Gold
  1501.   #-----------------------------------------------------------------------------
  1502.   def gold
  1503.     result = []
  1504.     unless @gold_set
  1505.       result = Ixfuru::ShopKeep::SHOPKEEPERS[@keeper_id][5]
  1506.       @gold_set = true
  1507.       return result
  1508.     end
  1509.     return @gold
  1510.   end
  1511.  
  1512.   #-----------------------------------------------------------------------------
  1513.   # Gold Growth
  1514.   #-----------------------------------------------------------------------------
  1515.   def gold_growth
  1516.     @gold += @gold_growth_increase
  1517.   end
  1518.  
  1519.   #-----------------------------------------------------------------------------
  1520.   # Reset Gold
  1521.   #-----------------------------------------------------------------------------
  1522.   def reset_gold
  1523.     @gold_set = false
  1524.   end
  1525.  
  1526.   #-----------------------------------------------------------------------------
  1527.   # Make Stat Price Adjustment:
  1528.   # This method receives the price as currently totalled, then adjusts it if
  1529.   # applicable with the shopkeepers adjustment settings, and then returns the
  1530.   # new value.
  1531.   #-----------------------------------------------------------------------------
  1532.   def stat_price_adjustment(price)
  1533.     return price unless @stat_price
  1534.     if @price_modifier >= 0 && @price_modifier < 6
  1535.       mod = @price_modifier
  1536.     else
  1537.       mod = 5
  1538.     end
  1539.     result = price
  1540.     parameter = @price_stat_base.to_sym
  1541.     tally = 0
  1542.     for member in $game_party.members.size
  1543.       tally += member.parameter
  1544.     end
  1545.     tally = tally / $game_party.members.size
  1546.     case mod
  1547.     when 0 # add
  1548.       result += tally
  1549.     when 1 #subtract
  1550.       result -= tally
  1551.       if result <= 0
  1552.         result = 1
  1553.       end
  1554.     when 2 #multiplies
  1555.       result *= tally
  1556.     when 3 #divides
  1557.       unless tally < 1
  1558.         result /= tally
  1559.       end
  1560.     when 4 # modulus
  1561.       unless tally < 1
  1562.         result %= tally
  1563.       end
  1564.       if result <= 0
  1565.         result = 1
  1566.       end
  1567.     when 5
  1568.       result = result * tally / 100
  1569.       if result <= 0
  1570.         result = 1
  1571.       end
  1572.     end
  1573.     return result
  1574.   end
  1575.  
  1576.   #-----------------------------------------------------------------------------
  1577.   # Get Dialogue:
  1578.   # This method takes the argument of shop phase and determines which dialogue
  1579.   # should be used and displayed.
  1580.   #-----------------------------------------------------------------------------
  1581.   def dialogue(shop_phase)
  1582.     if Ixfuru::ShopKeep::DIALOGUES[@keeper_id] != nil
  1583.       text = Ixfuru::ShopKeep::DIALOGUES[@keeper_id]
  1584.       return text[shop_phase]
  1585.     else
  1586.       text = Ixfuru::ShopKeep::DIALOGUES[NO_DIALOGUE]
  1587.       return text
  1588.     end
  1589.   end
  1590.  
  1591. end
  1592.  
  1593.  
  1594. ################################################################################
  1595. #*******************************************************************************
  1596. #                             GAME SHOPS
  1597. #
  1598. # The new class responsible for containing all the properties of each new shop,
  1599. # as contained in the ShopKeep module.  Scripters can access this class by
  1600. # using $game_shops.
  1601. ################################################################################
  1602. class Game_Shops
  1603.  
  1604.   #--------------------------------------------------------------------------
  1605.   # * Object Initialization
  1606.   #--------------------------------------------------------------------------
  1607.   def initialize
  1608.     @data = []
  1609.   end
  1610.   #--------------------------------------------------------------------------
  1611.   # * Get Shop
  1612.   #     shop_id : Shop ID
  1613.   #--------------------------------------------------------------------------
  1614.   def [](shop_id)
  1615.     if @data[shop_id] == nil #and $game_shops[shop_id] != nil
  1616.       @data[shop_id] = Game_Shop.new(shop_id)
  1617.     end
  1618.     return @data[shop_id]
  1619.   end
  1620.  
  1621.   #-----------------------------------------------------------------------------
  1622.   # Shops:
  1623.   # Used to get the collective group of shops.  Used in order to perform tasks
  1624.   # on every shop in the game
  1625.   #-----------------------------------------------------------------------------
  1626.   def shops
  1627.     result = []
  1628.     for i in 0...Ixfuru::ShopKeep::SHOPS.keys.size
  1629.       result.push(Ixfuru::ShopKeep::SHOPS.keys[i])
  1630.     end
  1631.     return result
  1632.   end
  1633.  
  1634.   #-----------------------------------------------------------------------------
  1635.   # Reset Inventories
  1636.   #-----------------------------------------------------------------------------
  1637.   def reset_inventories
  1638.     for shop in shops
  1639.       $game_shops[shop].reset_inventory
  1640.     end
  1641.   end
  1642.      
  1643. end
  1644.  
  1645. ################################################################################
  1646. #*******************************************************************************
  1647. #                           GAME SHOPKEEPERS
  1648. #
  1649. # The new class responsible for containing all the information for shopkeepers
  1650. # in the ShopKeep module.  Scripters can access the class by using
  1651. # $game_shopkeepers.
  1652. ################################################################################
  1653. class Game_Shopkeepers
  1654.  
  1655.   #--------------------------------------------------------------------------
  1656.   # * Object Initialization
  1657.   #--------------------------------------------------------------------------
  1658.   def initialize
  1659.     @data = []
  1660.   end
  1661.   #--------------------------------------------------------------------------
  1662.   # * Get ShopKeeper
  1663.   #     keeper_id : ShopKeeper ID
  1664.   #--------------------------------------------------------------------------
  1665.   def [](keeper_id)
  1666.     if @data[keeper_id] == nil #and $game_shopkeepers[keeper_id] != nil
  1667.       @data[keeper_id] = Game_Shopkeeper.new(keeper_id)
  1668.     end
  1669.     return @data[keeper_id]
  1670.   end
  1671.  
  1672.   #-----------------------------------------------------------------------------
  1673.   # Keepers:
  1674.   # Allows access to perform tasks on ALL the shopkeepers in the game.
  1675.   #-----------------------------------------------------------------------------
  1676.   def keepers
  1677.     result = []
  1678.     for i in 0...Ixfuru::ShopKeep::SHOPKEEPERS.keys.size
  1679.       result.push(Ixfuru::ShopKeep::SHOPKEEPERS.keys[i])
  1680.     end
  1681.     return result
  1682.   end
  1683.  
  1684.   #-----------------------------------------------------------------------------
  1685.   # Reset Gold
  1686.   #-----------------------------------------------------------------------------
  1687.   def reset_gold
  1688.     for keeper in keepers
  1689.       $game_shopkeepers[keeper].reset_gold
  1690.     end
  1691.   end
  1692.  
  1693.   #-----------------------------------------------------------------------------
  1694.   # Gold Growth
  1695.   #-----------------------------------------------------------------------------
  1696.   def gold_growth
  1697.     for keeper in keepers
  1698.       $game_shopkeepers[keeper].gold_growth
  1699.     end
  1700.   end
  1701.  
  1702. end
  1703.  
  1704. ################################################################################
  1705. #*******************************************************************************
  1706. #                        GAME BANK:
  1707. # This class is accessed by the call of global variable "$game_bank".
  1708. ################################################################################
  1709. class Game_Bank
  1710.  
  1711.   attr_accessor :current_loan
  1712.   attr_reader :max_loan_modifier
  1713.   attr_accessor :loan_out
  1714.   attr_accessor :bank_rating_adjuster
  1715.   attr_accessor :qualifying_loan
  1716.   attr_accessor :qualifying_loan_amount
  1717.   attr_accessor :loan_balance
  1718.  
  1719.   def initialize
  1720.     @max_loan_modifier = Ixfuru::ShopKeep::MAX_LOAN_MULTIPLIER
  1721.     @bank_rating_adjuster = [0]
  1722.     quick_adjust = Ixfuru::ShopKeep::BANK_RATING_ADJUSTMENT
  1723.     for i in 1...Ixfuru::ShopKeep::MAX_BANK_RATING
  1724.       @bank_rating_adjuster[i] = quick_adjust
  1725.       quick_adjust += quick_adjust
  1726.     end
  1727.     @bank_paybacks = 0
  1728.     @current_loan = 0
  1729.     @loan_balance = 0
  1730.     @loan_out = false
  1731.     @qualifying_loan = false
  1732.     @qualifying_loan_amount = Ixfuru::ShopKeep::QUALIFYING_LOAN_AMOUNT
  1733.   end
  1734.  
  1735.   #-----------------------------------------------------------------------------
  1736.   # Get Interest
  1737.   #-----------------------------------------------------------------------------
  1738.   def interest(loan_amount)
  1739.     return loan_amount * interest_rate / 100
  1740.   end
  1741.  
  1742.   #-----------------------------------------------------------------------------
  1743.   # Get Interest Rate
  1744.   #-----------------------------------------------------------------------------
  1745.   def interest_rate
  1746.     return Ixfuru::ShopKeep::BANK_INTEREST / bank_rating
  1747.   end
  1748.  
  1749.   #-----------------------------------------------------------------------------
  1750.   # Bank Rating
  1751.   #-----------------------------------------------------------------------------
  1752.   def bank_rating
  1753.     for i in 0...@bank_rating_adjuster.size
  1754.       if @bank_paybacks > @bank_rating_adjuster[i] && @bank_rating_adjuster[i + 1]
  1755.         rating = i
  1756.         return rating
  1757.       end
  1758.     end
  1759.     return 1
  1760.   end
  1761.  
  1762.   #-----------------------------------------------------------------------------
  1763.   # Get Max Loan
  1764.   #-----------------------------------------------------------------------------
  1765.   def max_loan
  1766.     if bank_rating > 0
  1767.       max = @max_loan_modifier * bank_rating
  1768.       return max
  1769.     else
  1770.       return Ixfuru::ShopKeep::QUALIFYING_LOAN_AMOUNT
  1771.     end
  1772.   end
  1773.  
  1774.   #-----------------------------------------------------------------------------
  1775.   # Can Loan
  1776.   #-----------------------------------------------------------------------------
  1777.   def can_loan?
  1778.     return false if @loan_out
  1779.     return true
  1780.   end
  1781.  
  1782.   #-----------------------------------------------------------------------------
  1783.   # Finish Payback
  1784.   #-----------------------------------------------------------------------------
  1785.   def finish_payback
  1786.     if @qualifying_loan
  1787.       @bank_paybacks += 1
  1788.       @qualifying_loan = false
  1789.     end
  1790.     @loan_out = false
  1791.   end
  1792.  
  1793.   #-----------------------------------------------------------------------------
  1794.   # Finish Loan
  1795.   #-----------------------------------------------------------------------------
  1796.   def finish_loan(amount_loaning)
  1797.     @current_loan = amount_loaning
  1798.     @loan_balance = amount_loaning
  1799.     @loan_out = true
  1800.     if amount_loaning >= @qualifying_loan_amount
  1801.       @qualifying_loan = true
  1802.     end
  1803.   end
  1804.  
  1805.  
  1806. end
  1807.  
  1808. ################################################################################
  1809. #*******************************************************************************
  1810. #                     WINDOW SHOP COMMANDS
  1811. ################################################################################
  1812. class Window_ShopCommands < Window_Selectable
  1813.  
  1814.   def initialize(shop_id)
  1815.     @shop = $game_shops[shop_id]
  1816.     @commands = []
  1817.     for service in @shop.services
  1818.       case service
  1819.       when Ixfuru::ShopKeep::BUY_COMMAND
  1820.         @commands.push(Ixfuru::ShopKeep::BUY_COMMAND)
  1821.       when Ixfuru::ShopKeep::SELL_COMMAND
  1822.         @commands.push(Ixfuru::ShopKeep::SELL_COMMAND)
  1823.       when Ixfuru::ShopKeep::BANK_COMMAND
  1824.         @commands.push(Ixfuru::ShopKeep::BANK_COMMAND)
  1825.       end
  1826.     end
  1827.     @commands.push("Exit")
  1828.     super(0, 0, 180, 32 + (@commands.size * WLH))
  1829.     @item_max = @commands.size
  1830.     refresh
  1831.     self.index = 0
  1832.   end
  1833.  
  1834.   def refresh
  1835.     self.contents.clear
  1836.     for i in 0...@item_max
  1837.       draw_items(i)
  1838.     end
  1839.   end
  1840.  
  1841.   def draw_items(index)
  1842.     rect = item_rect(index)
  1843.     rect.x += 4
  1844.     rect.width -= 8
  1845.     self.contents.draw_text(rect, @commands[index], 1)
  1846.   end
  1847.  
  1848. end
  1849.  
  1850. ################################################################################
  1851. #*******************************************************************************
  1852. #                     WINDOW SHOP NAME
  1853. ################################################################################
  1854. class Window_ShopName < Window_Base
  1855.  
  1856.   def initialize(shop_id)
  1857.     super(181, 0, 236, 64)
  1858.     @shop = $game_shops[shop_id]
  1859.     @name = @shop.name
  1860.     refresh
  1861.   end
  1862.  
  1863.   def refresh
  1864.     self.contents.clear
  1865.     self.contents.font.size = 24
  1866.     self.contents.font.color = text_color(Ixfuru::ShopKeep::SHOP_NAME_COLOR)
  1867.     self.contents.draw_text(-16, 0, self.width, WLH, @name, 1)
  1868.     self.contents.font.size = 20
  1869.     self.contents.font.color = normal_color
  1870.   end
  1871.  
  1872. end
  1873.  
  1874. ################################################################################
  1875. #*******************************************************************************
  1876. #                     WINDOW SHOP KIND
  1877. ################################################################################
  1878. class Window_ShopKind < Window_Base
  1879.  
  1880.   attr_accessor :shop_kind
  1881.  
  1882.   def initialize(shop_id)
  1883.     super(417, 0, 128, 80)
  1884.     @shop = $game_shops[shop_id]
  1885.     @shop_kind = 3
  1886.     refresh
  1887.   end
  1888.  
  1889.   def refresh
  1890.     self.contents.clear
  1891.     self.contents.font.size = 14
  1892.     self.contents.font.color = system_color
  1893.     @line_size = 18
  1894.     case @shop_kind
  1895.     when 0
  1896.       self.contents.draw_text(-16, 0, self.width, @line_size, "Buying", 1)
  1897.     when 1
  1898.       self.contents.draw_text(-16, 0, self.width, @line_size, "Selling", 1)
  1899.     when 2
  1900.       self.contents.draw_text(-16, 0, self.width, @line_size, "Banking", 1)
  1901.     when 3
  1902.       self.contents.draw_text(-16, 0, self.width, @line_size, "", 1)
  1903.     end
  1904.     self.contents.font.size = 20
  1905.     self.contents.font.color = normal_color
  1906.     draw_icon(Ixfuru::ShopKeep::SHOP_GOLD_ICON, 0, @line_size)
  1907.     self.contents.draw_text(30, @line_size, self.width, @line_size, $game_party.gold.to_i)
  1908.   end
  1909.  
  1910. end
  1911.  
  1912. ################################################################################
  1913. #*******************************************************************************
  1914. #                     WINDOW SHOPKEEPER
  1915. ################################################################################
  1916. class Window_ShopKeeper < Window_Base
  1917.  
  1918.   def initialize(keeper_id)
  1919.     super(417, 224, 128, 192)
  1920.     @shopkeeper = $game_shopkeepers[keeper_id]
  1921.     @keeper_style = Ixfuru::ShopKeep::SHOPKEEPER_STYLE
  1922.     @name_display = Ixfuru::ShopKeep::SHOPKEEPER_NAME_DISPLAY
  1923.     refresh
  1924.   end
  1925.  
  1926.   def refresh
  1927.     self.contents.clear
  1928.     self.contents.font.size = 14
  1929.     self.contents.font.color = text_color(Ixfuru::ShopKeep::KEEPER_NAME_COLOR)
  1930.     @line_size = 18
  1931.     case @name_display
  1932.     when 0
  1933.       case @keeper_style
  1934.       when 0
  1935.         draw_face(@shopkeeper.face_set, @shopkeeper.face_index, 0, 0)
  1936.       when 1
  1937.         draw_character(@shopkeeper.char_set, @shopkeeper.char_index, 0, 0)
  1938.       end
  1939.       self.contents.draw_text(-16, 97, self.width, @line_size, @shopkeeper.name, 1)
  1940.     when 1
  1941.       self.contents.draw_text(-16, 0, self.width, @line_size, @shopkeeper.name, 1)
  1942.       case @keeper_style
  1943.       when 0
  1944.         draw_face(@shopkeeper.face_set, @shopkeeper.face_index, 0, 25)
  1945.       when 1
  1946.         draw_character(@shopkeeper.char_set, @shopkeeper.char_index, 0, 25)
  1947.       end
  1948.     end
  1949.     self.contents.font.color = system_color
  1950.     if Ixfuru::ShopKeep::USE_KEEPER_GOLD
  1951.       self.contents.draw_text(0, 97 + @line_size, self.width, @line_size, Vocab::gold + ": ")
  1952.       self.contents.font.color = normal_color
  1953.       self.contents.draw_text(60, 97 + @line_size, self.width, @line_size, @shopkeeper.gold.to_s)
  1954.     end
  1955.     self.contents.font.size = 20
  1956.   end
  1957.  
  1958. end
  1959.  
  1960. ################################################################################
  1961. #*******************************************************************************
  1962. #                     WINDOW DIALOGUE
  1963. ################################################################################
  1964. class Window_ShopDialogue < Window_Base
  1965.  
  1966.   attr_accessor :shop_phase
  1967.  
  1968.   def initialize(keeper_id)
  1969.     super(0, 352, 416, 64)
  1970.     @shopkeeper = $game_shopkeepers[keeper_id]
  1971.     @shop_phase = 0
  1972.     refresh
  1973.   end
  1974.  
  1975.   def refresh
  1976.     self.contents.clear
  1977.     self.contents.font.size = 16
  1978.     @dialogue = @shopkeeper.dialogue(@shop_phase)
  1979.     self.contents.draw_text(-16, 0, self.width, WLH, @dialogue, 1)
  1980.     self.contents.font.size = 20
  1981.   end
  1982.  
  1983. end
  1984.  
  1985. ################################################################################
  1986. #*******************************************************************************
  1987. #                    WINDOW AMOUNT ADJUSTMENT
  1988. ################################################################################
  1989. class Window_AmountAdjustment < Window_Selectable
  1990.  
  1991.   attr_accessor :amount
  1992.   attr_accessor :item
  1993.  
  1994.   def initialize(item)
  1995.     super(0, 288, 259, 64)
  1996.     @item = item
  1997.     @item_max = 1
  1998.     @amount = 1
  1999.     refresh
  2000.     self.active = false
  2001.     self.visible = false
  2002.     self.index = 0
  2003.     self.z = 120
  2004.   end
  2005.  
  2006.   def refresh
  2007.     self.contents.clear
  2008.     if @amount < 1
  2009.       @amount = 1
  2010.     elsif @amount > 99
  2011.       @amount = 99
  2012.     end
  2013.     draw_item_name(@item, 0, 0)
  2014.     self.contents.draw_text(180, 0, self.width, WLH, " x " + @amount.to_s)
  2015.   end
  2016.  
  2017. end
  2018.  
  2019. ################################################################################
  2020. #*******************************************************************************
  2021. #                        SELL POSSESSION WINDOW
  2022. ################################################################################
  2023. class Window_SellPossession < Window_Base
  2024.  
  2025.   attr_accessor :item
  2026.  
  2027.   def initialize(item)
  2028.     super(0, 0, 180, 64)
  2029.     @item = item
  2030.     refresh
  2031.     self.visible = false
  2032.   end
  2033.  
  2034.   def refresh
  2035.     self.contents.clear
  2036.     @line_size = 20
  2037.     self.contents.font.size = 16
  2038.     self.contents.font.color = system_color
  2039.     self.contents.draw_text(0, 0, self.width, @line_size, "In Possession: ")
  2040.     self.contents.font.color = normal_color
  2041.     self.contents.draw_text(120, 0, self.width, @line_size, $game_party.item_number(@item).to_s)
  2042.   end
  2043.  
  2044. end
  2045.  
  2046. ################################################################################
  2047. #*******************************************************************************
  2048. #                       WINDOW BUY PRODUCTS
  2049. ################################################################################
  2050. class Window_BuyProducts < Window_Selectable
  2051.  
  2052.   attr_accessor :products
  2053.  
  2054.   def initialize(shop_id, keeper_id)
  2055.     super(0, 65, 259, 224)
  2056.     @shop = $game_shops[shop_id]
  2057.     @shopkeeper = $game_shopkeepers[keeper_id]
  2058.     refresh
  2059.     self.visible = false
  2060.     self.active = false
  2061.     self.index = 0
  2062.   end
  2063.  
  2064.   def refresh
  2065.     @products = @shop.inventory
  2066.     @item_max = @products.size
  2067.     create_contents
  2068.     for i in 0...@item_max
  2069.       draw_items(i)
  2070.     end
  2071.   end
  2072.  
  2073.   def draw_items(index)
  2074.     rect = item_rect(index)
  2075.     rect.x += 4
  2076.     rect.width -= 8
  2077.     if is_buyable?(@products[index])
  2078.       draw_item_name(@products[index], rect.x, rect.y)
  2079.     else
  2080.       draw_item_name(@products[index], rect.x, rect.y, false)
  2081.     end
  2082.     self.contents.font.color.alpha = is_buyable?(@products[index]) ? 255 : 128
  2083.     if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2084.       self.contents.draw_text(rect.x + 180, rect.y, self.width, WLH, (@products[index]).suey_price(0, @shopkeeper).to_s)
  2085.     else
  2086.       self.contents.draw_text(rect.x + 180, rect.y, self.width, WLH, (@products[index]).price.to_s)
  2087.     end
  2088.     self.contents.font.color.alpha = 255
  2089.   end
  2090.  
  2091.   def is_buyable?(item)
  2092.     if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2093.       return true if $game_party.gold >= item.suey_price(0, @shopkeeper)
  2094.     else
  2095.       return true if $game_party.gold >= item.price
  2096.     end
  2097.     return false
  2098.   end
  2099.  
  2100.  
  2101. end
  2102.    
  2103. ################################################################################
  2104. #*******************************************************************************
  2105. #                    WINDOW SELL PRODUCTS
  2106. ################################################################################
  2107. class Window_SellProducts < Window_Selectable
  2108.  
  2109.   attr_accessor :sellables
  2110.  
  2111.   def initialize(shop_id, keeper_id)
  2112.     super(0, 65, 259, 224)
  2113.     @shop = $game_shops[shop_id]
  2114.     @shopkeeper = $game_shopkeepers[keeper_id]
  2115.     refresh
  2116.     self.visible = false
  2117.     self.active = false
  2118.     self.index = 0
  2119.   end
  2120.  
  2121.   def refresh
  2122.     @sellables = $game_party.items
  2123.     @item_max = @sellables.size
  2124.     create_contents
  2125.     for i in 0...@item_max
  2126.       draw_items(i)
  2127.     end
  2128.   end
  2129.  
  2130.   def draw_items(index)
  2131.     rect = item_rect(index)
  2132.     rect.x += 4
  2133.     rect.width -=8
  2134.     if is_sellable?(@sellables[index])
  2135.       draw_item_name(@sellables[index], rect.x, rect.y)
  2136.     else
  2137.       draw_item_name(@sellables[index], rect.x, rect.y, false)
  2138.     end
  2139.     self.contents.font.color.alpha = is_sellable?(@sellables[index]) ? 255 : 128
  2140.     if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2141.       self.contents.draw_text(rect.x + 180, rect.y, self.width, WLH, (@sellables[index]).suey_price(1, @shopkeeper).to_s)
  2142.     else
  2143.       self.contents.draw_text(rect.x + 180, rect.y, self.width, WLH, ((@sellables[index]).price / 2).to_s)
  2144.     end
  2145.     self.contents.font.color.alpha = 255
  2146.   end
  2147.  
  2148.   def is_sellable?(item)
  2149.     return false if item.unsellable
  2150.     return false unless @shop.barters_item?(item)
  2151.     if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2152.       if Ixfuru::ShopKeep::USE_KEEPER_GOLD
  2153.         return true if @shopkeeper.gold >= item.suey_price(1, @shopkeeper)
  2154.         return false
  2155.       end
  2156.     else
  2157.       if Ixfuru::ShopKeep::USE_KEEPER_GOLD
  2158.         return true if @shopkeeper.gold >= item.suey_price(1, @shopkeeper)
  2159.         return false
  2160.       else
  2161.         return false if item.price == 0
  2162.         return true if @shopkeeper.gold >= item.price / 2
  2163.         return false
  2164.       end
  2165.     end
  2166.   end
  2167.  
  2168. end
  2169.  
  2170. ################################################################################
  2171. #*******************************************************************************
  2172. #                       WINDOW PRODUCT DESCRIPTION
  2173. ################################################################################
  2174. class Window_ProductDescription < Window_Base
  2175.  
  2176.   attr_accessor :item
  2177.  
  2178.   def initialize(item)
  2179.     super(262, 65, 154, 288)
  2180.     @item = item
  2181.     refresh
  2182.     self.visible = false
  2183.   end
  2184.  
  2185.   def refresh
  2186.     self.contents.clear
  2187.     draw_icon(@item.icon_index, 0, 0)
  2188.     self.contents.font.color = normal_color
  2189.     self.contents.draw_text(30, 0, self.width, WLH, @item.name)
  2190.     self.contents.font.size = 12
  2191.     @line_size = 16
  2192.     base_y = @line_size * 2
  2193.     if @item.is_a?(RPG::Item)
  2194.       draw_item_scope(@item, 0, base_y)
  2195.       draw_item_effect(@item, 0, base_y + @line_size)
  2196.       draw_item_properties(@item, 0, base_y + (@line_size * 2))
  2197.       draw_item_elements(@item, 0, base_y + (@line_size * 11))
  2198.       draw_item_states(@item, 0, base_y + (@line_size * 7), "minus")
  2199.       draw_item_states(@item, 0, base_y + (@line_size * 9), "add")
  2200.     elsif @item.is_a?(RPG::Weapon)
  2201.       draw_equip_parameters(@item, 0, base_y)
  2202.       draw_equip_properties(@item, 0, base_y + @line_size * 5)
  2203.       draw_item_elements(@item, 0, base_y + @line_size * 10)
  2204.       draw_equip_states(@item, 0, base_y + @line_size * 12)
  2205.     elsif @item.is_a?(RPG::Armor)
  2206.       draw_equip_parameters(@item, 0, base_y)
  2207.       draw_equip_properties(@item, 0, base_y + @line_size * 5)
  2208.       draw_item_elements(@item, 0, base_y + @line_size * 10)
  2209.       draw_equip_states(@item, 0, base_y + @line_size * 12)
  2210.     end
  2211.   end
  2212.  
  2213.   #-----------------------------------------------------------------------------
  2214.   # Draw Equip Properties
  2215.   #-----------------------------------------------------------------------------
  2216.   def draw_equip_properties(equip, x, y)
  2217.     self.contents.font.color = system_color
  2218.     self.contents.draw_text(-16, y, self.width, @line_size, "PROPERTIES", 1)
  2219.     self.contents.font.color = normal_color
  2220.     spacey = 0
  2221.     if equip.is_a?(RPG::Weapon)
  2222.       props = [equip.fast_attack, equip.dual_attack, equip.critical_bonus]
  2223.       for i in 0...props.size
  2224.         case i
  2225.         when 0
  2226.           if props[i]
  2227.             self.contents.draw_text(-16, @line_size + @line_size * spacey, self.width, @line_size, "FastAttack", 1)
  2228.             spacey += 1
  2229.           end
  2230.         when 1
  2231.           if props[i]
  2232.             self.contents.draw_text(-16, @line_size + @line_size * spacey, self.width, @line_size, "DualAttack", 1)
  2233.             spacey += 1
  2234.           end
  2235.         when 2
  2236.           if props[i]
  2237.             self.contents.draw_text(-16, @line_size + @line_size * spacey, self.width, @line_size, "CriticalBonus", 1)
  2238.             spacey += 1
  2239.           end
  2240.         end
  2241.       end
  2242.     elsif equip.is_a?(RPG::Armor)
  2243.       props = [equip.prevent_critical, equip.half_mp_cost, equip.double_exp_gain, equip.auto_hp_recover]
  2244.       for i in 0...props.size
  2245.         case i
  2246.         when 0
  2247.           if props[i]
  2248.             self.contents.draw_text(-16, @line_size + @line_size * spacey, self.width, @line_size, "PreventCritical", 1)
  2249.             spacey += 1
  2250.           end
  2251.         when 1
  2252.           if props[i]
  2253.             self.contents.draw_text(-16, @line_size + @line_size * spacey, self.width, @line_size, "Half" + Vocab::mp + "Cost", 1)
  2254.             spacey += 1
  2255.           end
  2256.         when 2
  2257.           if props[i]
  2258.             self.contents.draw_text(-16, @line_size + @line_size * spacey, self.width, @line_size, "DoubleExpGain", 1)
  2259.             spacey += 1
  2260.           end
  2261.         when 3
  2262.           if props[i]
  2263.             self.contents.draw_text(-16, @line_size + @line_size * spacey, self.width, @line_size, "Auto" + Vocab::hp + "Recover", 1)
  2264.             spacey += 1
  2265.           end
  2266.         end
  2267.       end
  2268.     end
  2269.   end
  2270.  
  2271.   #-----------------------------------------------------------------------------
  2272.   # Draw Equip Parameters
  2273.   #-----------------------------------------------------------------------------
  2274.   def draw_equip_parameters(equip, x,  y)
  2275.     self.contents.font.color = system_color
  2276.     spacex = 30
  2277.     self.contents.draw_text(x, y, self.width, @line_size, Vocab::atk)
  2278.     self.contents.draw_text(x, y + @line_size, self.width, @line_size, Vocab::def)
  2279.     self.contents.draw_text(x, y + @line_size * 2, self.width, @line_size, Vocab::spi)
  2280.     self.contents.draw_text(x, y + @line_size * 3, self.width, @line_size, Vocab::agi)
  2281.     self.contents.font.color = normal_color
  2282.     self.contents.draw_text(spacex, y, self.width, @line_size, equip.atk)
  2283.     self.contents.draw_text(spacex, y + @line_size, self.width, @line_size, equip.def)
  2284.     self.contents.draw_text(spacex, y + @line_size * 2, self.width, @line_size, equip.spi)
  2285.     self.contents.draw_text(spacex, y + @line_size * 3, self.width, @line_size, equip.agi)
  2286.   end
  2287.    
  2288.   #-----------------------------------------------------------------------------
  2289.   # Draw Item States
  2290.   #-----------------------------------------------------------------------------
  2291.   def draw_item_states(item, x, y, modifier)
  2292.     case modifier
  2293.     when "minus"
  2294.       self.contents.font.color = system_color
  2295.       self.contents.draw_text(-16, y, self.width, @line_size, "CURE STATES", 1)
  2296.       xspace = 0
  2297.       for state in item.minus_state_set
  2298.         draw_icon(Ixfuru::ShopKeep::STATE_ICON_IDS[state], x + xspace, y + @line_size)
  2299.         xspace += 24
  2300.       end
  2301.     when "add"
  2302.       self.contents.font.color = system_color
  2303.       self.contents.draw_text(-16, y, self.width, @line_size, "ADD STATES", 1)
  2304.       xspace = 0
  2305.       for state in item.plus_state_set
  2306.         draw_icon(Ixfuru::ShopKeep::STATE_ICON_IDS[state], x + xspace, y + @line_size)
  2307.       end
  2308.     end
  2309.   end
  2310.  
  2311.   #-----------------------------------------------------------------------------
  2312.   # Draw Item Elements
  2313.   #-----------------------------------------------------------------------------
  2314.   def draw_item_elements(item, x, y)
  2315.     self.contents.font.color = system_color
  2316.     self.contents.draw_text(-16, y, self.width, @line_size, "ELEMENTS", 1)
  2317.     xspace = 0
  2318.     for element in item.element_set
  2319.       draw_icon(Ixfuru::ShopKeep::ELEMENT_ICON_IDS[element], x + xspace, y + @line_size)
  2320.       xspace += 24
  2321.     end
  2322.     self.contents.font.color = normal_color
  2323.   end
  2324.      
  2325.   #-----------------------------------------------------------------------------
  2326.   # Draw Equip States
  2327.   #-----------------------------------------------------------------------------
  2328.   def draw_equip_states(equip, x, y)
  2329.     self.contents.font.color = system_color
  2330.     self.contents.draw_text(-16, y, self.width, @line_size, "STATES", 1)
  2331.     xspace = 0
  2332.     for state in equip.state_set
  2333.       draw_icon(Ixfuru::ShopKeep::STATE_ICON_IDS[state], x + xspace, y + @line_size)
  2334.       xspace += 24
  2335.     end
  2336.     self.contents.font.color = normal_color
  2337.   end
  2338.    
  2339.   #-----------------------------------------------------------------------------
  2340.   # Draw Item Properties
  2341.   #-----------------------------------------------------------------------------
  2342.   def draw_item_properties(item, x, y)
  2343.     self.contents.font.color = system_color
  2344.     self.contents.draw_text(-16, y, self.width, @line_size, "PROPERTIES", 1)
  2345.     self.contents.font.color = normal_color
  2346.     props = [item.physical_attack, item.absorb_damage, item.ignore_defense]
  2347.     curline = 1
  2348.     for i in 0...props.size
  2349.       case i
  2350.       when 0
  2351.         if props[i]
  2352.           self.contents.draw_text(-16, y + (@line_size * curline), self.width, @line_size, "PhysicalAttack", 1)
  2353.           cur_line += 1
  2354.         end
  2355.       when 1
  2356.         if props[i]
  2357.           self.contents.draw_text(-16, y + (@line_size * curline), self.width, @line_size, "AbsorbDamage", 1)
  2358.           cur_line += 1
  2359.         end
  2360.       when 2
  2361.         if props[i]
  2362.           self.contents.draw_text(-16, y + (@line_size * curline), self.width, @line_size, "IgnoreDefense", 1)
  2363.           cur_lin += 1
  2364.         end
  2365.       end
  2366.     end
  2367.   end
  2368.    
  2369.   #-----------------------------------------------------------------------------
  2370.   # Draw Item Effect
  2371.   #-----------------------------------------------------------------------------
  2372.   def draw_item_effect(item, x, y)
  2373.     self.contents.font.color = system_color
  2374.     self.contents.draw_text(x, y, self.width, @line_size, "EFFECT")
  2375.     self.contents.font.color = normal_color
  2376.     if item.hp_recovery > 0 && item.mp_recovery > 0
  2377.       self.contents.draw_text(x + 55, y, self.width, @line_size, "Heals" + Vocab::hp + "&" + Vocab::mp)
  2378.     elsif item.hp_recovery > 0
  2379.       self.contents.draw_text(x + 55, y, self.width, @line_size, "Heals" + Vocab::hp)
  2380.     elsif item.mp_recovery > 0
  2381.       self.contents.draw_text(x + 55, y, self.width, @line_size, "Heals" + Vocab::mp)
  2382.     elsif item.parameter_type > 0 && item.parameter_points > 0
  2383.       case item.parameter_type
  2384.       when 1
  2385.         self.contents.draw_text(x + 55, y, self.width, @line_size, "Adds" + Vocab::hp)
  2386.       when 2
  2387.         self.contents.draw_text(x + 55, y, self.width, @line_size, "Adds" + Vocab::mp)
  2388.       when 3
  2389.         self.contents.draw_text(x + 55, y, self.width, @line_size, "Adds" + Vocab::atk)
  2390.       when 4
  2391.         self.contents.draw_text(x + 55, y, self.width, @line_size, "Adds" + Vocab::def)
  2392.       when 5
  2393.         self.contents.draw_text(x + 55, y, self.width, @line_size, "Adds" + Vocab::spi)
  2394.       when 6
  2395.         self.contents.draw_text(x + 55, y, self.width, @line_size, "Adds" + Vocab::agi)
  2396.       end
  2397.     elsif item.base_damage > 0 && item.damage_to_mp
  2398.       self.contents.draw_text(x + 55, y, self.width, @line_size, "Attacks" + Vocab::mp)
  2399.     elsif item.base_damage > 0 && !item.damage_to_mp
  2400.       self.contents.draw_text(x + 55, y, self.width, @line_size, "Attacks" + Vocab::hp)
  2401.     end
  2402.   end
  2403.    
  2404.   #---------------------------------------------------------------------------
  2405.   # Draw Item Scope
  2406.   #---------------------------------------------------------------------------
  2407.   def draw_item_scope(item, x, y)
  2408.     self.contents.font.color = system_color
  2409.     self.contents.draw_text(x, y, self.width, @line_size, "SCOPE")
  2410.     self.contents.font.color = normal_color
  2411.     case item.scope
  2412.     when 0
  2413.       self.contents.draw_text(x + 55, y, self.width, @line_size, "None")
  2414.     when 1
  2415.       self.contents.draw_text(x + 55, y, self.width, @line_size, "OneEnemy")
  2416.     when 2
  2417.       self.contents.draw_text(x + 55, y, self.width, @line_size, "AllEnemies")
  2418.     when 3
  2419.       self.contents.draw_text(x + 55, y, self.width, @line_size, "EnemyDual")
  2420.     when 4
  2421.       self.contents.draw_text(x + 55, y, self.width, @line_size, "OneEnemy")
  2422.     when 5
  2423.       self.contents.draw_text(x + 55, y, self.width, @line_size, "2Enemies")
  2424.     when 6
  2425.       self.contents.draw_text(x + 55, y, self.width, @line_size, "3Enemies")
  2426.     when 7
  2427.       self.contents.draw_text(x + 55, y, self.width, @line_size, "OneAlly")
  2428.     when 8
  2429.       self.contents.draw_text(x + 55, y, self.width, @line_size, "AllAllies")
  2430.     when 9
  2431.       self.contents.draw_text(x + 55, y, self.width, @line_size, "DeadAlly")
  2432.     when 10
  2433.       self.contents.draw_text(x + 55, y, self.width, @line_size, "DeadAllies")
  2434.     when 11
  2435.       self.contents.draw_text(x + 55, y, self.width, @line_size, "UserOnly")
  2436.     end
  2437.   end
  2438.  
  2439. end
  2440.  
  2441. ################################################################################
  2442. #*******************************************************************************
  2443. #                       WINDOW BANK INFO
  2444. ################################################################################
  2445. class Window_BankInfo < Window_Base
  2446.  
  2447.   attr_accessor :current_loan
  2448.   attr_accessor :loan_balance
  2449.  
  2450.   def initialize
  2451.     super(0, 65, 416, 140)
  2452.     refresh
  2453.     self.visible = false
  2454.   end
  2455.  
  2456.   def refresh
  2457.     self.contents.clear
  2458.     @rating = $game_bank.bank_rating
  2459.     @max_loan = $game_bank.max_loan
  2460.     @current_loan = $game_bank.current_loan
  2461.     @loan_balance = $game_bank.loan_balance
  2462.     self.contents.font.color = system_color
  2463.     self.contents.draw_text(0, 0, self.width, WLH, "RATING:")
  2464.     self.contents.draw_text(0, WLH, self.width, WLH, "MAX LOAN:")
  2465.     self.contents.draw_text(0, WLH * 2, self.width, WLH, "CURRENT LOAN:")
  2466.     self.contents.draw_text(0, WLH * 3, self.width, WLH, "LOAN BALANCE:")
  2467.     self.contents.font.color = normal_color
  2468.     self.contents.draw_text(200, 0, self.width, WLH, @rating.to_s)
  2469.     self.contents.draw_text(200, WLH, self.width, WLH, @max_loan.to_s)
  2470.     self.contents.draw_text(200, WLH * 2, self.width, WLH, @current_loan.to_s)
  2471.     self.contents.draw_text(200, WLH * 3, self.width, WLH, @loan_balance.to_s)
  2472.   end
  2473.  
  2474. end    
  2475.  
  2476. ################################################################################
  2477. #*******************************************************************************
  2478. #                      WINDOW BANK ACTION
  2479. ################################################################################
  2480. class Window_BankAction < Window_Selectable
  2481.  
  2482.   def initialize
  2483.     super(0, 205, 416, 80)
  2484.     @commands = ["TAKE LOAN", "PAYBACK LOAN"]
  2485.     @item_max = @commands.size
  2486.     refresh
  2487.     self.index = 0
  2488.     self.active = false
  2489.     self.visible = false
  2490.   end
  2491.  
  2492.   def refresh
  2493.     self.contents.clear
  2494.     for i in 0...@item_max
  2495.       draw_items(i)
  2496.     end
  2497.   end
  2498.  
  2499.   def draw_items(index)
  2500.     rect = item_rect(index)
  2501.     rect.x += 4
  2502.     rect.width -= 8
  2503.     self.contents.draw_text(rect.x - 16, rect.y, self.width, WLH, @commands[index], 1)
  2504.   end
  2505.  
  2506. end
  2507.  
  2508. ################################################################################
  2509. #*******************************************************************************
  2510. #                        WINDOW BANK INPUT
  2511. ################################################################################
  2512. class Window_BankInput < Window_Selectable
  2513.  
  2514.   attr_accessor :action
  2515.   attr_accessor :amount
  2516.   attr_accessor :multiplier
  2517.  
  2518.   def initialize
  2519.     super(0, 286, 416, 64)
  2520.     @action = 0
  2521.     @amount = 0
  2522.     @multiplier = 1
  2523.     @item_max = 1
  2524.     refresh
  2525.     self.index = 0
  2526.     self.visible = false
  2527.     self.active = false
  2528.   end
  2529.  
  2530.   def refresh
  2531.     self.contents.clear
  2532.     for i in 0...@item_max
  2533.       draw_items(i)
  2534.     end
  2535.   end
  2536.  
  2537.   def draw_items(index)
  2538.     rect = item_rect(index)
  2539.     rect.x += 4
  2540.     rect.width -= 8
  2541.     case @action
  2542.     when 0
  2543.       self.contents.draw_text(rect.x, rect.y, self.width, WLH, "LOAN AMOUNT:  " + @amount.to_s)
  2544.     when 1
  2545.       self.contents.draw_text(rect.x, rect.y, self.width, WLH, "PAYBACK AMOUNT:  " + @amount.to_s)
  2546.     end
  2547.     self.contents.font.color = text_color(24)
  2548.     self.contents.draw_text(rect.x + 260, rect.y, self.width, WLH, "x " + @multiplier.to_s)
  2549.     self.contents.font.color = normal_color
  2550.   end
  2551.  
  2552. end
  2553.    
  2554. ################################################################################
  2555. #*******************************************************************************
  2556. #                      WINDOW BANK CONFIRM
  2557. ################################################################################
  2558. class Window_BankConfirm < Window_Selectable
  2559.  
  2560.   def initialize
  2561.     super(162, 164, 140, 80)
  2562.     @commands = ["Confirm", "Cancel"]
  2563.     @item_max = @commands.size
  2564.     refresh
  2565.     self.index = 0
  2566.     self.visible = false
  2567.     self.active = false
  2568.     self.z = 120
  2569.   end
  2570.  
  2571.   def refresh
  2572.     self.contents.clear
  2573.     for i in 0...@item_max
  2574.       draw_items(i)
  2575.     end
  2576.   end
  2577.  
  2578.   def draw_items(index)
  2579.     rect = item_rect(index)
  2580.     rect.x += 4
  2581.     rect.width -= 8
  2582.     self.contents.draw_text(rect, @commands[index])
  2583.   end
  2584.  
  2585. end
  2586.  
  2587.  
  2588.  
  2589. ################################################################################
  2590. #*******************************************************************************
  2591. #                        SCENE SHOPSUEY
  2592. ################################################################################
  2593. class Scene_Shopsuey < Scene_Base
  2594.  
  2595.   def initialize(shop_id, keeper_id)
  2596.     @shop = $game_shops[shop_id]
  2597.     @shopkeeper = $game_shopkeepers[keeper_id]
  2598.     @shop_id = shop_id
  2599.     @shopkeeper_id = keeper_id
  2600.     @introduced = false
  2601.     @buying = false
  2602.     @selling = false
  2603.     @loaning = false
  2604.     @paying = false
  2605.   end
  2606.  
  2607.   def start
  2608.     super
  2609.     @win_commands = Window_ShopCommands.new(@shop_id)
  2610.     @win_name = Window_ShopName.new(@shop_id)
  2611.     @win_kind = Window_ShopKind.new(@shop_id)
  2612.     @win_shopkeeper = Window_ShopKeeper.new(@shopkeeper_id)
  2613.     @win_dialogue = Window_ShopDialogue.new(@shopkeeper_id)
  2614.     @win_item_amount = Window_AmountAdjustment.new(@shop.inventory[0])
  2615.     @win_buy = Window_BuyProducts.new(@shop_id, @shopkeeper_id)
  2616.     @win_sell = Window_SellProducts.new(@shop_id, @shopkeeper_id)
  2617.     @win_description = Window_ProductDescription.new($data_items[1])
  2618.     @win_possession = Window_SellPossession.new($data_items[1])
  2619.     @win_bankinfo = Window_BankInfo.new
  2620.     @win_bankaction = Window_BankAction.new
  2621.     @win_bankinput = Window_BankInput.new
  2622.     @win_bankconfirm = Window_BankConfirm.new
  2623.     RPG::BGM.new(@shop.bgm[0], @shop.bgm[1], @shop.bgm[2]).play
  2624.   end
  2625.  
  2626.   #-----------------------------------------------------------------------------
  2627.   # Dialogue Introduction
  2628.   #-----------------------------------------------------------------------------
  2629.   def dialogue_introduction
  2630.     @win_dialogue.shop_phase = 0
  2631.     Graphics.wait(90)
  2632.     @win_dialogue.shop_phase = 1
  2633.     @win_dialogue.refresh
  2634.     @introduced = true
  2635.   end
  2636.  
  2637.   #-----------------------------------------------------------------------------
  2638.   # Frame Update
  2639.   #-----------------------------------------------------------------------------
  2640.   def update
  2641.     super
  2642.     if @win_commands.active
  2643.       update_commands
  2644.     elsif @win_item_amount.active
  2645.       update_item_amount
  2646.     elsif @win_buy.active
  2647.       update_buy
  2648.     elsif @win_sell.active
  2649.       update_sell
  2650.     elsif @win_bankaction.active
  2651.       update_bank_action
  2652.     elsif @win_bankinput.active
  2653.       update_bank_input
  2654.     elsif @win_bankconfirm.active
  2655.       update_bank_confirm
  2656.     end
  2657.   end
  2658.  
  2659.   #-----------------------------------------------------------------------------
  2660.   # Update Commands
  2661.   #-----------------------------------------------------------------------------
  2662.   def update_commands
  2663.     @win_commands.update
  2664.     unless @introduced
  2665.       dialogue_introduction
  2666.     end
  2667.     if Input.trigger?(Input::B)
  2668.       Sound.play_cancel
  2669.       alter_dialogue(9)
  2670.       Graphics.wait(90)
  2671.       $scene = Scene_Map.new
  2672.     elsif Input.trigger?(Input::C)
  2673.       Sound.play_decision
  2674.       determine_service(@win_commands.index)
  2675.     end
  2676.   end
  2677.  
  2678.   #-----------------------------------------------------------------------------
  2679.   # Determine Service
  2680.   #-----------------------------------------------------------------------------
  2681.   def determine_service(index)
  2682.     service = @shop.services[index]
  2683.     if service == Ixfuru::ShopKeep::BUY_COMMAND
  2684.       activate_buy
  2685.     elsif service == Ixfuru::ShopKeep::SELL_COMMAND
  2686.       if @win_sell.sellables.size > 0
  2687.         activate_sell
  2688.       else
  2689.         Sound.play_buzzer
  2690.       end
  2691.     elsif service == Ixfuru::ShopKeep::BANK_COMMAND
  2692.       activate_bank
  2693.     else
  2694.       leave_scene
  2695.     end
  2696.   end
  2697.  
  2698.   #-----------------------------------------------------------------------------
  2699.   # Leave Scene
  2700.   #-----------------------------------------------------------------------------
  2701.   def leave_scene
  2702.     Sound.play_cancel
  2703.     alter_dialogue(9)
  2704.     Graphics.wait(90)
  2705.     $scene = Scene_Map.new
  2706.   end
  2707.  
  2708.   #-----------------------------------------------------------------------------
  2709.   # Activate Buy
  2710.   #-----------------------------------------------------------------------------
  2711.   def activate_buy
  2712.     @win_commands.active = false
  2713.     @win_commands.visible = false
  2714.     @win_buy.visible = true
  2715.     @win_description.visible = true
  2716.     alter_dialogue(2)
  2717.     alter_kind(0)
  2718.     @win_buy.active = true
  2719.   end
  2720.  
  2721.   #-----------------------------------------------------------------------------
  2722.   # Activate Sell
  2723.   #-----------------------------------------------------------------------------
  2724.   def activate_sell
  2725.     @win_commands.active = false
  2726.     @win_commands.visible = false
  2727.     @win_sell.visible = true
  2728.     @win_description.visible = true
  2729.     @win_possession.item = @win_sell.sellables[@win_sell.index]
  2730.     @win_possession.refresh
  2731.     @win_possession.visible = true
  2732.     alter_dialogue(5)
  2733.     alter_kind(1)
  2734.     @win_sell.active = true
  2735.   end
  2736.  
  2737.   #-----------------------------------------------------------------------------
  2738.   # Update Buy
  2739.   #-----------------------------------------------------------------------------
  2740.   def update_buy
  2741.     @win_buy.update
  2742.     item = @win_buy.products[@win_buy.index]
  2743.     @win_description.item = item
  2744.     @win_description.refresh
  2745.     if Input.trigger?(Input::B)
  2746.       Sound.play_cancel
  2747.       back_to_commands(0)
  2748.     elsif Input.trigger?(Input::C)
  2749.       if @win_buy.is_buyable?(item)
  2750.         Sound.play_decision
  2751.         activate_item_amount(0)
  2752.       else
  2753.         Sound.play_buzzer
  2754.         alter_dialogue(3, true)
  2755.       end
  2756.     end
  2757.   end
  2758.    
  2759.   #-----------------------------------------------------------------------------
  2760.   # Activate Item Amount:
  2761.   # accepts argument (shop_phase) = 0 for buy; 1 for sell
  2762.   #-----------------------------------------------------------------------------
  2763.   def activate_item_amount(shop_phase)
  2764.     case shop_phase
  2765.     when 0 # when buying
  2766.       @win_buy.active = false
  2767.       @win_item_amount.item = @win_buy.products[@win_buy.index]
  2768.       @buying = true
  2769.       alter_dialogue(21)
  2770.     when 1 # when selling
  2771.       @win_sell.active = false
  2772.       @win_item_amount.item = @win_sell.sellables[@win_sell.index]
  2773.       alter_dialogue(22)
  2774.       @selling = true
  2775.     end
  2776.     @win_item_amount.amount = 1
  2777.     @win_item_amount.refresh
  2778.     @win_item_amount.visible = true
  2779.     @win_item_amount.active = true
  2780.   end
  2781.  
  2782.   #-----------------------------------------------------------------------------
  2783.   # Update Item Amount
  2784.   #-----------------------------------------------------------------------------
  2785.   def update_item_amount
  2786.     @win_item_amount.update
  2787.     gold_max = max_item_amount
  2788.     if Input.trigger?(Input::B)
  2789.       Sound.play_cancel
  2790.       if @buying
  2791.         back_to_buy
  2792.       elsif @selling
  2793.         back_to_sell
  2794.       end
  2795.       elsif Input.trigger?(Input::RIGHT) || Input.trigger?(Input::UP)
  2796.       Sound.play_cursor
  2797.       @win_item_amount.amount += 1
  2798.       @win_item_amount.refresh
  2799.     elsif Input.trigger?(Input::LEFT) || Input.trigger?(Input::DOWN)
  2800.       Sound.play_cursor
  2801.       @win_item_amount.amount -= 1
  2802.       @win_item_amount.refresh
  2803.     elsif Input.trigger?(Input::C)
  2804.       if @buying && @win_item_amount.amount <= gold_max
  2805.         RPG::SE.new(Ixfuru::ShopKeep::BUY_SE, 80, 100).play
  2806.         make_purchase
  2807.       elsif @buying && @win_item_amount.amount > gold_max
  2808.         Sound.play_buzzer
  2809.         alter_dialogue(3, true)
  2810.       elsif @selling
  2811.         if @win_item_amount.amount <= gold_max
  2812.           if $game_party.item_number(@win_item_amount.item) >= @win_item_amount.amount
  2813.             RPG::SE.new(Ixfuru::ShopKeep::SELL_SE, 80, 100).play
  2814.             make_sell
  2815.           else
  2816.             Sound.play_buzzer
  2817.             alter_dialogue(23, true)
  2818.           end
  2819.         else
  2820.           Sound.play_buzzer
  2821.           alter_dialogue(7, true)
  2822.         end
  2823.       end
  2824.     end
  2825.   end
  2826.  
  2827.   #-----------------------------------------------------------------------------
  2828.   # Make Sell
  2829.   #-----------------------------------------------------------------------------
  2830.   def make_sell
  2831.     item = @win_item_amount.item
  2832.     if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2833.       $game_party.gain_gold(item.suey_price(1, @shopkeeper) * @win_item_amount.amount)
  2834.     else
  2835.       $game_party.gain_gold(item.price * @win_item_amount.amount / 2)
  2836.     end
  2837.     if Ixfuru::ShopKeep::USE_KEEPER_GOLD
  2838.       if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2839.         @shopkeeper.gold -= item.suey_price(1, @shopkeeper) * @win_item_amount.amount
  2840.       else
  2841.         @shopkeeper.gold -= item.price * @win_item_amount.amount / 2
  2842.       end
  2843.     end
  2844.     alter_dialogue(8)
  2845.     if !@shop.inventory.include?(item) && !item.dont_stock
  2846.       @shop.add_to_inventory(item)
  2847.       alter_dialogue(10, true)
  2848.       @win_buy.refresh
  2849.     end
  2850.     $game_party.lose_item(item, @win_item_amount.amount, true)
  2851.     @win_item_amount.amount = 1
  2852.     @win_item_amount.refresh
  2853.     @win_kind.refresh
  2854.     @win_shopkeeper.refresh
  2855.     @win_sell.index = 0
  2856.     @win_sell.refresh
  2857.     back_to_sell
  2858.   end
  2859.  
  2860.  
  2861.   #-----------------------------------------------------------------------------
  2862.   # Make Purchase
  2863.   #-----------------------------------------------------------------------------
  2864.   def make_purchase
  2865.     item = @win_item_amount.item
  2866.     if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2867.       $game_party.lose_gold(item.suey_price(0, @shopkeeper) * @win_item_amount.amount)
  2868.     else
  2869.       $game_party.lose_gold(item.price * @win_item_amount.amount)
  2870.     end
  2871.     if Ixfuru::ShopKeep::USE_KEEPER_GOLD
  2872.       if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2873.         @shopkeeper.gold += item.suey_price(0, @shopkeeper) * @win_item_amount.amount
  2874.       else
  2875.         @shopkeeper.gold += item.price * @win_item_amount.amount
  2876.       end
  2877.     end
  2878.     alter_dialogue(4)
  2879.     $game_party.gain_item(item, @win_item_amount.amount, true)
  2880.     @win_item_amount.amount = 1
  2881.     @win_item_amount.refresh
  2882.     @win_kind.refresh
  2883.     @win_shopkeeper.refresh
  2884.     @win_buy.refresh
  2885.     back_to_buy
  2886.   end
  2887.  
  2888.   #-----------------------------------------------------------------------------
  2889.   # Get Max Item Amount
  2890.   #-----------------------------------------------------------------------------
  2891.   def max_item_amount
  2892.     if @buying
  2893.       gold = $game_party.gold
  2894.       if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2895.         max = gold / @win_item_amount.item.suey_price(0, @shopkeeper)
  2896.       else
  2897.         max = gold / @win_item_amount.item.price
  2898.       end
  2899.     elsif @selling
  2900.       if Ixfuru::ShopKeep::USE_KEEPER_GOLD
  2901.         gold = @shopkeeper.gold
  2902.         if Ixfuru::ShopKeep::USE_RENEWED_PRICING
  2903.           max = gold / @win_item_amount.item.suey_price(1, @shopkeeper)
  2904.         else
  2905.           max = gold / @win_item_amount.item.price
  2906.         end
  2907.       else
  2908.         max = 99
  2909.       end
  2910.     end
  2911.     return max
  2912.   end
  2913.  
  2914.   #-----------------------------------------------------------------------------
  2915.   # Back To Buy
  2916.   #-----------------------------------------------------------------------------
  2917.   def back_to_buy
  2918.     @win_item_amount.active = false
  2919.     @win_item_amount.visible = false
  2920.     alter_dialogue(2)
  2921.     @buying = false
  2922.     @win_buy.active = true
  2923.   end
  2924.  
  2925.  
  2926.   #-----------------------------------------------------------------------------
  2927.   # Update Sell
  2928.   #-----------------------------------------------------------------------------
  2929.   def update_sell
  2930.     @win_sell.update
  2931.     item = @win_sell.sellables[@win_sell.index]
  2932.     @win_description.item = item
  2933.     @win_description.refresh
  2934.     @win_possession.item = item
  2935.     @win_possession.refresh
  2936.     if Input.trigger?(Input::B)
  2937.       Sound.play_cancel
  2938.       back_to_commands(1)
  2939.     elsif Input.trigger?(Input::C)
  2940.       if @win_sell.is_sellable?(item)
  2941.         Sound.play_decision
  2942.         activate_item_amount(1)
  2943.       else
  2944.         Sound.play_buzzer
  2945.         alter_dialogue(6, true)
  2946.       end
  2947.     end
  2948.   end
  2949.  
  2950.   #-----------------------------------------------------------------------------
  2951.   # Back To Sell
  2952.   #-----------------------------------------------------------------------------
  2953.   def back_to_sell
  2954.     @win_item_amount.active = false
  2955.     @win_item_amount.visible = false
  2956.     alter_dialogue(5)
  2957.     @selling = false
  2958.     @win_sell.active = true
  2959.   end
  2960.  
  2961.   #-----------------------------------------------------------------------------
  2962.   # Activate Bank
  2963.   #-----------------------------------------------------------------------------
  2964.   def activate_bank
  2965.     @win_commands.active = false
  2966.     @win_commands.visible = false
  2967.     @win_bankinfo.visible = true
  2968.     @win_bankaction.visible = true
  2969.     @win_bankinput.visible = true
  2970.     alter_kind(2)
  2971.     if $game_bank.loan_out
  2972.       alter_dialogue(12)
  2973.     else
  2974.       alter_dialogue(11)
  2975.     end
  2976.     @win_bankaction.active = true
  2977.   end
  2978.  
  2979.   #-----------------------------------------------------------------------------
  2980.   # Update Bank Action
  2981.   #-----------------------------------------------------------------------------
  2982.   def update_bank_action
  2983.     @win_bankaction.update
  2984.     if Input.trigger?(Input::B)
  2985.       Sound.play_cancel
  2986.       back_to_commands(2)
  2987.     elsif Input.trigger?(Input::C)
  2988.       case @win_bankaction.index
  2989.       when 0
  2990.         if $game_bank.can_loan?
  2991.           Sound.play_decision
  2992.           alter_dialogue(13)
  2993.           activate_bank_input(0)
  2994.         else
  2995.           Sound.play_buzzer
  2996.           alter_dialogue(14, true)
  2997.         end
  2998.       when 1
  2999.         if $game_bank.loan_out == false
  3000.           Sound.play_buzzer
  3001.           alter_dialogue(24, true)
  3002.         else
  3003.           Sound.play_decision
  3004.           alter_dialogue(15)
  3005.           activate_bank_input(1)
  3006.         end
  3007.       end
  3008.     end
  3009.   end
  3010.  
  3011.   #-----------------------------------------------------------------------------
  3012.   # Activate Bank Input
  3013.   #-----------------------------------------------------------------------------
  3014.   def activate_bank_input(from)
  3015.     @win_bankaction.active = false
  3016.     @win_bankinput.action = from
  3017.     @win_bankinput.active = true
  3018.   end
  3019.  
  3020.   #-----------------------------------------------------------------------------
  3021.   # Update Bank Input
  3022.   #-----------------------------------------------------------------------------
  3023.   def update_bank_input
  3024.     @win_bankinput.update
  3025.     @win_bankinput.refresh
  3026.     max_loan = $game_bank.max_loan
  3027.     pay_max = $game_bank.loan_balance
  3028.     if Input.trigger?(Input::B)
  3029.       Sound.play_cancel
  3030.       back_to_bank_action(0)
  3031.     elsif Input.press?(Input::RIGHT) || Input.press?(Input::UP)
  3032.       Sound.play_cursor
  3033.       @win_bankinput.amount += @win_bankinput.multiplier
  3034.       case @win_bankinput.action
  3035.       when 0
  3036.         if @win_bankinput.amount > max_loan
  3037.           @win_bankinput.amount = max_loan
  3038.         end
  3039.       when 1
  3040.         if @win_bankinput.amount > pay_max
  3041.           @win_bankinput.amount = pay_max
  3042.         end
  3043.       end
  3044.     elsif Input.press?(Input::LEFT) || Input.press?(Input::DOWN)
  3045.       Sound.play_cursor
  3046.       @win_bankinput.amount -= @win_bankinput.multiplier
  3047.       if @win_bankinput.amount < 0
  3048.         @win_bankinput.amount = 0
  3049.       end
  3050.     elsif Input.trigger?(Input::R)
  3051.       Sound.play_load
  3052.       if @win_bankinput.multiplier == 100
  3053.         @win_bankinput.multiplier = 1
  3054.       elsif @win_bankinput.multiplier == 50
  3055.         @win_bankinput.multiplier = 100
  3056.       elsif @win_bankinput.multiplier == 10
  3057.         @win_bankinput.multiplier = 50
  3058.       elsif @win_bankinput.multiplier == 1
  3059.         @win_bankinput.multiplier = 10
  3060.       end
  3061.     elsif Input.trigger?(Input::L)
  3062.       Sound.play_load
  3063.       if @win_bankinput.multiplier == 100
  3064.         @win_bankinput.multiplier = 50
  3065.       elsif @win_bankinput.multiplier == 50
  3066.         @win_bankinput.multiplier = 10
  3067.       elsif @win_bankinput.multiplier == 10
  3068.         @win_bankinput.multiplier = 1
  3069.       elsif @win_bankinput.multiplier == 1
  3070.         @win_bankinput.multiplier = 100
  3071.       end
  3072.     elsif Input.trigger?(Input::C)
  3073.       Sound.play_decision
  3074.       activate_bank_confirm
  3075.     end
  3076.   end
  3077.  
  3078.   #-----------------------------------------------------------------------------
  3079.   # Activate Bank Confirm
  3080.   #-----------------------------------------------------------------------------
  3081.   def activate_bank_confirm
  3082.     @win_bankinput.active = false
  3083.     @win_bankconfirm.visible = true
  3084.     @win_bankconfirm.active =true
  3085.   end
  3086.  
  3087.   #-----------------------------------------------------------------------------
  3088.   # Update Bank Confirm
  3089.   #-----------------------------------------------------------------------------
  3090.   def update_bank_confirm
  3091.     @win_bankconfirm.update
  3092.     if Input.trigger?(Input::B)
  3093.       Sound.play_cancel
  3094.       back_to_bank_input
  3095.     elsif Input.trigger?(Input::C)
  3096.       case @win_bankconfirm.index
  3097.       when 0
  3098.         RPG::SE.new(Ixfuru::ShopKeep::BANK_SE, 80, 100).play
  3099.         case @win_bankinput.action
  3100.         when 0
  3101.           alter_dialogue(18)
  3102.           make_loan
  3103.         when 1
  3104.           alter_dialogue(19)
  3105.           make_payback
  3106.         end
  3107.       when 1
  3108.         Sound.play_cancel
  3109.         back_to_bank_input
  3110.       end
  3111.     end
  3112.   end
  3113.  
  3114.   #-----------------------------------------------------------------------------
  3115.   # Make Loan
  3116.   #-----------------------------------------------------------------------------
  3117.   def make_loan
  3118.     loan = @win_bankinput.amount
  3119.     $game_party.gain_gold(loan)
  3120.     loan += $game_bank.interest(loan)
  3121.     $game_bank.finish_loan(loan)
  3122.     @win_bankinfo.refresh
  3123.     alter_kind(2)
  3124.     back_to_bank_action(1)
  3125.   end
  3126.  
  3127.   #-----------------------------------------------------------------------------
  3128.   # Make Payback
  3129.   #-----------------------------------------------------------------------------
  3130.   def make_payback
  3131.     pay = @win_bankinput.amount
  3132.     $game_party.lose_gold(pay)
  3133.     if pay >= $game_bank.loan_balance
  3134.       $game_bank.finish_payback
  3135.     else
  3136.       $game_bank.loan_balance = @win_bankinfo.current_loan -= pay
  3137.     end
  3138.     @win_bankinfo.refresh
  3139.     alter_kind(2)
  3140.     back_to_bank_action(1)
  3141.   end
  3142.  
  3143.   #-----------------------------------------------------------------------------
  3144.   # Back To Commands
  3145.   #-----------------------------------------------------------------------------
  3146.   def back_to_commands(from)
  3147.     case from
  3148.     when 0 # from buying
  3149.       @win_buy.active = false
  3150.       @win_buy.visible = false
  3151.     when 1 # from selling
  3152.       @win_possession.visible = false
  3153.       @win_sell.active = false
  3154.       @win_sell.visible = false
  3155.     when 2  # from banking
  3156.       @win_bankaction.active = false
  3157.       @win_bankaction.visible = false
  3158.       @win_bankinfo.visible = false
  3159.       @win_bankinput.visible = false
  3160.     end
  3161.     @win_description.visible = false
  3162.     @win_item_amount.visible = false
  3163.     alter_dialogue(0)
  3164.     alter_kind(3)
  3165.     @win_commands.visible= true
  3166.     @win_commands.active = true
  3167.   end
  3168.  
  3169.   #-----------------------------------------------------------------------------
  3170.   # Alter Dialogue
  3171.   #-----------------------------------------------------------------------------
  3172.   def alter_dialogue(index, quick = false)
  3173.     back_text = @win_dialogue.shop_phase
  3174.     @win_dialogue.shop_phase = index
  3175.     @win_dialogue.refresh
  3176.     if quick
  3177.       Graphics.wait(90)
  3178.       @win_dialogue.shop_phase = back_text
  3179.       @win_dialogue.refresh
  3180.     end
  3181.   end
  3182.  
  3183.   #-----------------------------------------------------------------------------
  3184.   # Alter Kind
  3185.   #-----------------------------------------------------------------------------
  3186.   def alter_kind(action)
  3187.     @win_kind.shop_kind = action
  3188.     @win_kind.refresh
  3189.   end
  3190.  
  3191.   #-----------------------------------------------------------------------------
  3192.   # Back to Bank Action
  3193.   #-----------------------------------------------------------------------------
  3194.   def back_to_bank_action(from)
  3195.     case from
  3196.     when 0
  3197.       @win_bankinput.active = false
  3198.     when 1
  3199.       @win_bankconfirm.visible = false
  3200.       @win_bankconfirm.active = false
  3201.     end
  3202.     if $game_bank.loan_out
  3203.       alter_dialogue(12)
  3204.     else
  3205.       alter_dialogue(11)
  3206.     end
  3207.     @win_bankinput.amount = 0
  3208.     @win_bankinput.refresh
  3209.     @win_bankaction.active = true
  3210.   end
  3211.  
  3212.   #-----------------------------------------------------------------------------
  3213.   # Back to Bank Input
  3214.   #-----------------------------------------------------------------------------
  3215.   def back_to_bank_input
  3216.     @win_bankconfirm.active = false
  3217.     @win_bankconfirm.visible = false
  3218.     @win_bank_input.active = true
  3219.   end
  3220.  
  3221.   #-----------------------------------------------------------------------------
  3222.   # Terminate
  3223.   #-----------------------------------------------------------------------------
  3224.   def terminate
  3225.     @win_commands.dispose
  3226.     @win_name.dispose
  3227.     @win_kind.dispose
  3228.     @win_shopkeeper.dispose
  3229.     @win_description.dispose
  3230.     @win_item_amount.dispose
  3231.     @win_bankinfo.dispose
  3232.     @win_bankaction.dispose
  3233.     @win_bankinput.dispose
  3234.     @win_bankconfirm.dispose
  3235.     @win_dialogue.dispose
  3236.     @win_possession.dispose
  3237.   end
  3238.  
  3239. end
Advertisement
Add Comment
Please, Sign In to add comment