CrowMakerVX

Shopsuey1.2

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