CrowMakerVX

ShopSuey1.3

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