modern_algebra

Gold Drop Variance

Apr 22nd, 2011
155
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #    Gold Drop Variance
  3. #    Version: 1.0
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: April 22, 2011
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    Gold drops in RMVX are static by default, with every creature always
  10. #   dropping the exact same amount every time you kill them. This script allows
  11. #   you to change that by making them drop a random amount between values that
  12. #   you choose.
  13. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  14. #  Instructions:
  15. #
  16. #    Paste this script into its own slot in the Script Editor (F11), above Main
  17. #   and below other custom scripts.
  18. #
  19. #    To set this script up, go to line 42 and set the default variance. That is
  20. #   the default amount the gold drops could vary by when you kill a monster. If
  21. #   you want it so that the variance is different for specific monsters, then
  22. #   all you need to do is put the following code in those monster's note box:
  23. #
  24. #        \var_gold[x]
  25. #
  26. #   Where x is the integer you want the drop to vary by. That will set it so
  27. #   that the drop for that monster will vary between the normal drop and the
  28. #   normal drop + x. So, if it is 10 and the enemy is set to 20, then it will
  29. #   drop between 20 and 29 gold. You could also set it by percent with the code:
  30. #
  31. #        \var_gold[y%]
  32. #  
  33. #   Where y is the percent you want it to vary by. That will set it so the
  34. #   monster will drop between the normal drop and the normal drop + y%. So, if
  35. #   it is set to 25 and the enemy is set to 20, then it will drop between 20 and
  36. #   24 gold (since 25% of 20 is 5).
  37. #
  38. #   If you want to change the note box code, go to line 50.
  39. #==============================================================================
  40. #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  41. #    EDITABLE REGION
  42. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  43. #  MAGDV_DEFAULT_VARIANCE - This is the default amount gold drops will vary by.
  44. # If it is an integer, then it will vary between the set amount and this. If
  45. # you make it a float (20.0 rather than 20), then it will vary by that percent
  46. # of the set amount (ie. if the set amount is 160 and this value is set to 20.0,
  47. # then the amount dropped will be between 160 and 191. (since 20% of 160 is 32)
  48. # If you want some enemies to have a different variance, you just need to tag
  49. # it in their noteboxes (see lines 19 - 35).
  50. MAGDV_DEFAULT_VARIANCE = 20.0
  51. #  MAGDV_REGEXP - You shouldn't need to modify this; all this does is allow you
  52. # to change the notebox code which you can use to change the specific variance
  53. # for enemies. The default value is "VAR_GOLD", meaning the code \var_gold[x]
  54. # will be the notebox code. If you change it to "VG", for instance, the code
  55. # would be \vg[x]. It is up to you.
  56. MAGDV_REGEXP = "VAR_GOLD"
  57. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  58. #    END EDITABLE REGION
  59. #//////////////////////////////////////////////////////////////////////////////
  60.  
  61. $imported = {} if !$imported
  62. $imported["MAGoldDropVariance"] = true
  63.  
  64. #==============================================================================
  65. # ** RPG::Enemy
  66. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  67. #  Summary of Changes:
  68. #    aliased method - gold
  69. #==============================================================================
  70.  
  71. class RPG::Enemy
  72.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73.   # * Gold
  74.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75.   alias mlgb_luk_gld_9og1 gold unless self.method_defined? (:mlgb_luk_gld_9og1)
  76.   def gold (*args, &block)
  77.     gld = mlgb_luk_gld_9og1 (*args, &block) # Run Original Method
  78.     add = gold_variance
  79.     if add.is_a? (Float)
  80.       add = ((gld*add) / 100).to_i
  81.     end
  82.     return gld + (rand (add))
  83.   end
  84.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85.   # * Gold Variance
  86.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87.   def gold_variance
  88.     if !@gold_variance
  89.       @gold_variance = MAGDV_DEFAULT_VARIANCE
  90.       if self.note[/#{MAGDV_REGEXP}\[(\d+)(%?)\]/i] != nil
  91.         @gold_variance = $2.empty? ? $1.to_i : $1.to_f
  92.       end
  93.     end
  94.     return @gold_variance
  95.   end
  96. end
RAW Paste Data