Advertisement
TheSixth

Claiming Time Addon for Venka's Crafting System by Sixth

Sep 4th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.12 KB | None | 0 0
  1. #==============================================================================
  2. # Claim Time Addon by Sixth (v.1.1)                            ----------------
  3. # - Make that green bar not-so-static!                         |   Updated:
  4. #                                                              |  22/09/2014
  5. # REQUIRES Venka's Multiple Crafting Script!                   ----------------
  6. #==============================================================================
  7. #------------------------------------------------------------------------------
  8. # Change Log:
  9. #------------------------------------------------------------------------------
  10. #  22/09/2014 - Noobishness kicked in again!
  11. #               Fixed the note-tags. It is now possible to make negative
  12. #               "bonuses" for real.
  13. #               Also re-made the percentage bonuses. They work differently now.
  14. #               Read the note-tag manual for more info.
  15. #               Added a maximum claiming time option too.
  16. #  21/09/2014 - Initial release.
  17. #------------------------------------------------------------------------------
  18. # Introduction:
  19. #------------------------------------------------------------------------------
  20. #  This script will allow you to change the claiming time for each recipes
  21. #  separately. The claiming time is the time when the player needs to press the
  22. #  button for getting the success reward. By default, it is set in the
  23. #  Customize Section of Venka's script with the 'Crafting_Buffer' setup option.
  24. #  However, that setup is a global setup and will affect all of your recipes.
  25. #  This is what you can change with this addon.
  26. #  The addon also makes it possible to scale the claiming time for the recipes
  27. #  dynamically according to the player's level in the used craft type.
  28. #  ...
  29. #  What? Not enough? >.>
  30. #  Alright, then how about some note-tags on your equips to manipulate the
  31. #  claiming time even more? Yeah, you bet you can do that too with this addon!
  32. #------------------------------------------------------------------------------
  33. # Usage Manual - New Recipe Setting:
  34. #------------------------------------------------------------------------------
  35. #  With this addon, a new option is available in the recipe settings.
  36. #  The new setting looks like this:
  37. #
  38. #   :claiming_time => n
  39. #
  40. #  Where 'n' is an integer number and stands for frame count, so putting 60 there
  41. #  means that the claiming time will be 1 second.
  42. #  Example: :claiming_time => 45
  43. #
  44. #  Adding this line in the recipe settings will overwrite the default time window
  45. #  for claiming the success rewards. Omitting this will simply take the default
  46. #  claiming time for the recipe.
  47. #  And this is not all of what the addon changes!
  48. #  By configuring the settings below, you can make craft level dependant
  49. #  claiming times as well! How awesome, right? :P
  50. #------------------------------------------------------------------------------
  51. # Usage Manual - Note-tags:
  52. #------------------------------------------------------------------------------
  53. #  There are 3 note-tags which you can use.
  54. #  One will directly add the specified value to the claiming time, another one
  55. #  will add a percentage value, and yet another one can disable the success time
  56. #  entirely!
  57. #  All of the note-tags are stack-able, so be careful with claiming time equip
  58. #  bonuses, because they can scale exponentially to a very high amount if you
  59. #  don't plan your equipment availability in your game ahead!
  60. #
  61. #  Ok, here are the note-tags!
  62. #
  63. #  To add a direct bonus to the claiming time, use this note-tag:
  64. #
  65. #   <claim_time_bonus +n>  Adds 'n' value.
  66. #   <claim_time_bonus -n>  Subtracts 'n' value.
  67. #
  68. #  Where 'n' is an integer number and stands for frame count (60 = 1 second).
  69. #  Example: <claim_time_bonus +10>  Adds 10 frame count to the claiming time.
  70. #  Example: <claim_time_bonus -15>  Subtracts 15 frame count from the claiming time.
  71. #
  72. #  To add a percentage multiplier to the claiming gauge, use this note-tag:
  73. #
  74. #   <claim_time_bonus_perc +n>  Adds 'n' percentage.
  75. #   <claim_time_bonus_perc -n>  Subtracts 'n' percentage.
  76. #
  77. #  Where 'n' is an integer number and stands for percentages, so putting +20 there
  78. #  means that the total accumulated bonus will get an additional 20% bonus time.
  79. #  Example: <claim_time_bonus_perc +25>  Adds 25% to the total claiming time.
  80. #  Example: <claim_time_bonus_perc -15>  Subtracts 15% from the total claiming time.
  81. #
  82. #  Again, all of the note-tags are stack-able, even the percentage ones!
  83. #  It is possible to stack an amount so high, that the player don't even need to
  84. #  press the button for getting the success rewards, he will get it anyway.
  85. #  To prevent this from happening, you can use the 'Max_Claim_Time' option to
  86. #  limit the maximum claiming time the player can accumulate.
  87. #  It is also possible to get negative amounts, but in that case, the claim time
  88. #  will just stick to 0, instead of going into negative numbers. This is to
  89. #  prevent some unexpected behaviours.
  90. #
  91. #  To disable the success claiming time completely, use the following note-tag:
  92. #  
  93. #   <claim_time_curse>
  94. #
  95. #  This note-tag will simply multiply the final total value of the claiming time
  96. #  with 0, effectively disabling the success time completely.
  97. #  This is good for making cursed items. Players, beware, mwhahaha! :D
  98. #
  99. #------------------------------------------------------------------------------
  100. # Instructions:
  101. #------------------------------------------------------------------------------
  102. #  Place this add on below Venka's Multiple Crafting Script.
  103. #  This addon is plug-and-play. Configure the settings below if needed.
  104. #------------------------------------------------------------------------------
  105. # Terms of use:
  106. #------------------------------------------------------------------------------
  107. #  You can do whatever you want with this addon as long as you give credit to me.
  108. #------------------------------------------------------------------------------
  109. $imported = {} if $imported.nil?
  110. $imported["ClaimTimeAddon"] = true
  111. ###############################################################################
  112. #
  113. # The "Big" Setup part - edit until you drop!
  114. #
  115. ###############################################################################
  116.  
  117. module Venka
  118.   module Crafting
  119.   #----------------------------------------------------------------------------
  120.   # Claim Time Settings
  121.   #----------------------------------------------------------------------------
  122.   # You can set up how the new :claim_time option for the recipes functions here.
  123.   #----------------------------------------------------------------------------
  124.   Lvl_Bonus = true    # Setting this to 'true' will enable the 'Lvl_Modifier'
  125.                       # option below, while 'false' will disable it.
  126.   Lvl_Modifier = 1.5  # The modifier of the claim time bonus for the recipes.
  127.                       # If 'Lvl_Bonus' is set to true, a bonus will be added
  128.                       # to the base claiming time. This bonus depends on the
  129.                       # level of your craft type multiplied with the amount
  130.                       # set up here.
  131.   Max_Claim_Time = 99 # This setting will limit the maximum amount of claiming
  132.                       # time the player can accumulate. If you set this to
  133.                       # 'nil', this option will be disabled and the player
  134.                       # can get unlimited amount of claiming time by stacking
  135.                       # bonuses. Else, set it to an integer number. This number
  136.                       # is in frames (60 = 1 sec).
  137.                      
  138.   #----------------------------------------------------------------------------
  139.   # Examples:
  140.   #----------------------------------------------------------------------------
  141.   # If you craft a Battle Axe (which is a "Smith" recipe by default), and the
  142.   # recipe for it is set up with a :claiming_time of 30, and the 'Lvl_Bonus' is
  143.   # enabled with a 'LvL_Modifier' set to 1.5 the final claiming time formula will
  144.   # be the following:
  145.   #
  146.   #   30 + (1.5 * 'smith_craft_level')
  147.   #
  148.   # So, if your "Smith" level is 12, the final claim time would be:
  149.   #
  150.   #   30 + (1.5 * 12) = 48
  151.   #   Final result = 48
  152.   #
  153.   # And with a "Smith" level of 30:
  154.   #
  155.   #   30 + (1.5 * 30) = 75
  156.   #   Final result = 75
  157.   #
  158.   # Now, if by any chance the player got an accessory equipped with a note-tag of
  159.   # <claim_time_bonus +60>, the last example formula would look like this:
  160.   #
  161.   #   30 + (1.5 * 30) + 60 = 135
  162.   #   Final result = 135
  163.   #
  164.   # And when the player equips an equipment with a note-tag of
  165.   # <claim_time_bonus_perc -20>, the last example formula would turn to:
  166.   #
  167.   #   (30 + (1.5 * 30) + 60) = 135
  168.   #   135 - (135 * 20%) = 108
  169.   #   Final result = 108
  170.   #
  171.   # And if the player was unfortunate enough to equip a cursed accessory with the
  172.   # note-tag of <claim_time_curse>, the formula will look like this:
  173.   #
  174.   #   (30 + (1.5 * 30) + 60) = 135
  175.   #   135 - (135 * 20%) = 108
  176.   #   108 * 0 = 0
  177.   #   Final result = 0
  178.   #
  179.   # Yes, this means that it is possible to completely remove the success time
  180.   # window with some quality cursed equips. :P
  181.   #
  182.   # So, the real formula with variables instead of example numbers:
  183.   #
  184.   #   :claiming_time + (Lvl_Modifier * craft_type.level) = base_claim_time
  185.   #   base_claim_time + <claim_time_bonus [+/-]X> = base_time_bonus
  186.   #   base_time_bonus + (base_time_bonus * <claim_time_bonus_perc [+/-]X%>) = claim_time_total
  187.   #
  188.   # If the 'Max_Claim_Time' option is enabled, the formula goes on with this:
  189.   #
  190.   #   claim_time_total = Max_Claim_Time if claim_time_total > Max_Claim_Time
  191.   #
  192.   # Or if the total value ended up being negative, the following happens:
  193.   #
  194.   #   claim_time_total = 0
  195.   #
  196.   # And finally, if the <claim_time_curse> note-tag is present, the
  197.   # claim_time_total is simply multiplied with 0 to disable the success claiming
  198.   # time entirely, so the player won't be able to get the success item.
  199.   #----------------------------------------------------------------------------
  200.  
  201.   end
  202. end
  203.  
  204. ###############################################################################
  205. #
  206. # End of the "Big" Setup part - editing below may lead to flying dragons!
  207. #
  208. ###############################################################################
  209.  
  210. class RPG::BaseItem
  211.  
  212.   def claim_time_bonus
  213.     @note =~ /<claim_time_bonus ([\+\-]\d+)>/i ? $1.to_i : 0
  214.   end
  215.  
  216.   def claim_time_bonus_p
  217.     @note =~ /<claim_time_bonus_perc ([\+\-]\d+)>/i ? $1.to_i : 0
  218.   end
  219.  
  220.   def claim_time_curse
  221.     @note =~ /<claim_time_curse>/i ? true : false
  222.   end
  223.  
  224. end
  225.  
  226. #==============================================================================
  227. # ■ Game_Party
  228. #==============================================================================
  229. class Game_Party
  230.   #----------------------------------------------------------------------------
  231.   # ♦ Public Instance Variables
  232.   #----------------------------------------------------------------------------
  233.   attr_accessor   :claim_time_equip_bonus,    :claim_time_equip_bonus_perc
  234.   attr_accessor   :claim_time_curse
  235.   #----------------------------------------------------------------------------
  236.   # ● new method: claim_time_equip_bonus
  237.   #----------------------------------------------------------------------------
  238.   def claim_time_equip_bonus
  239.     @claim_time_equip_bonus = 0
  240.     members.each do |actor|
  241.       actor.equips.each do |equip|
  242.         if equip != nil
  243.        #   equip.note =~ /<claim_time_bonus ([\+\-]\d+)>/
  244.        #   @claim_time_equip_bonus += ($~[1].to_i) if $~
  245.           @claim_time_equip_bonus += equip.claim_time_bonus
  246.         end
  247.       end
  248.     end
  249.     return @claim_time_equip_bonus
  250.   end
  251.   #----------------------------------------------------------------------------
  252.   # ● new method: claim_time_equip_bonus_perc
  253.   #----------------------------------------------------------------------------
  254.   def claim_time_equip_bonus_perc
  255.     @claim_time_equip_bonus_perc = 0
  256.     members.each do |actor|
  257.       actor.equips.each do |equip|
  258.         if equip != nil
  259.          # equip.note =~ /<claim_time_bonus_perc ([\+\-]\d+)>/
  260.          # @claim_time_equip_bonus_perc += ($~[1].to_i) if $~
  261.           @claim_time_equip_bonus_perc += equip.claim_time_bonus_p
  262.         end
  263.       end
  264.     end
  265.     return @claim_time_equip_bonus_perc
  266.   end
  267.   #----------------------------------------------------------------------------
  268.   # ● new method: claim_time_curse
  269.   #----------------------------------------------------------------------------
  270.   def claim_time_curse
  271.     @claim_time_curse = false
  272.     members.each do |actor|
  273.       actor.equips.each do |equip|
  274.         if equip != nil
  275.           if equip.note.include?("<claim_time_curse>")
  276.             @claim_time_curse = true
  277.             #@claim_time_curse = equip.claim_time_curse
  278.           end
  279.         end
  280.       end
  281.     end
  282.     return @claim_time_curse
  283.   end
  284. end
  285. #==============================================================================
  286. # ■ Game_Recipe
  287. #==============================================================================
  288. class Game_Recipe
  289.   #----------------------------------------------------------------------------
  290.   # ♦ Public Instance Variables
  291.   #----------------------------------------------------------------------------
  292.   attr_reader    :claiming_time
  293.   #----------------------------------------------------------------------------
  294.   # ● alias method: initialize
  295.   #----------------------------------------------------------------------------
  296.   alias sixth_initialize_claim1232 initialize
  297.   def initialize(recipe_id)
  298.     sixth_initialize_claim1232(recipe_id)
  299.     @claiming_time = @recipe[:claiming_time] ? @recipe[:claiming_time] : Venka::Crafting::Crafting_Buffer
  300.   end
  301. end
  302. #==============================================================================
  303. # ■ Crafting_Details_Window
  304. #==============================================================================
  305. class Crafting_Details_Window < Window_Command
  306.   #----------------------------------------------------------------------------
  307.   # ○ alias method: start_crafting
  308.   #----------------------------------------------------------------------------
  309.   alias sixth_start_crafting_claim1232 start_crafting
  310.   def start_crafting
  311.     sixth_start_crafting_claim1232
  312.     @bonus_eq = $game_party.claim_time_equip_bonus
  313.     @bonus_eq_perc = $game_party.claim_time_equip_bonus_perc
  314.     @bonus_mod = Venka::Crafting::Lvl_Bonus ? ($craft[@recipe.recipe_type].level * Venka::Crafting::Lvl_Modifier) : 0
  315.     @bonus_curse = $game_party.claim_time_curse
  316.     @claiming_time = @recipe.claiming_time + @bonus_mod.to_i
  317.     @claiming_time += @bonus_eq
  318.     @claiming_time += (@claiming_time * @bonus_eq_perc) * 0.01
  319.     @claiming_time *= 0 if @bonus_curse == true
  320.     @claiming_time = 0 if @claiming_time < 0
  321.     if Venka::Crafting::Max_Claim_Time != nil && @claiming_time > Venka::Crafting::Max_Claim_Time
  322.       @claiming_time = Venka::Crafting::Max_Claim_Time
  323.     end
  324.     @buffer = Venka::Crafting::Timer_Type == :timer ? 0 : @claiming_time
  325.     print "Claim Time Final: "; p @buffer # for debugging... why didn't I think about this sooner? -.-
  326.   end
  327. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement