Advertisement
MrTrivel

MrTS_Static_EXP

Jun 11th, 2014
1,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.84 KB | None | 0 0
  1. # )----------------------------------------------------------------------------(
  2. # )--     AUTHOR:     Mr Trivel                                              --(
  3. # )--     NAME:       Static Exp                                             --(
  4. # )--     CREATED:    2014-06-11                                             --(
  5. # )--     VERSION:    1.1a                                                   --(
  6. # )----------------------------------------------------------------------------(
  7. # )--                         VERSION HISTORY                                --(
  8. # )--  1.1a - Reserve Members now properly gain XP if specified.             --(
  9. # )--  1.1  - Fixed Overflow XP bug and a crash if party had atleast 1       --(
  10. # )--  inactive party member.                                                --(
  11. # )----------------------------------------------------------------------------(
  12. # )--                          DESCRIPTION                                   --(
  13. # )--  Every level will require same amount of XP. But enemies lower level   --(
  14. # )--  than actor will give less XP and higher level enemies will give more  --(
  15. # )--  XP.                                                                   --(
  16. # )----------------------------------------------------------------------------(
  17. # )--                          INSTRUCTIONS                                  --(
  18. # )--  EXP box in Enemy Database now denotes the Enemies level.              --(
  19. # )--  E.g.: An enemy with with EXP set to 3 will be used as a level 3 enemy.--(
  20. # )----------------------------------------------------------------------------(
  21. # )--                          LICENSE INFO                                  --(
  22. # )--    Free for non-commercial games if credit was given to Mr Trivel.     --(
  23. # )----------------------------------------------------------------------------(
  24.  
  25. module MrTS
  26.   module Static_Exp
  27.     # )-----------------------------------------(
  28.     # )--  How much XP per level actor needs  --(
  29.     # )-----------------------------------------(
  30.     NEXT_LEVEL_XP = 200
  31.    
  32.     # )-------------------------------------------(
  33.     # )--  Does XP overflow to the next level?  --(
  34.     # )--  E.g. If true and Actor is at 95 XP   --(
  35.     # )--  and it gets 10XP, he will level up   --(
  36.     # )--  and he will have 5 XP ready. If false--(
  37.     # )--  he will have 0 XP after level up.    --(
  38.     # )-------------------------------------------(
  39.     OVERFLOW_XP = true
  40.    
  41.     # )---------------------------------(
  42.     # )--  Base amout of XP rewarded  --(
  43.     # )---------------------------------(
  44.     XP_REWARDED = 15
  45.    
  46.     # )--------------------------------------------------------------(
  47.     # )--  XP Bonus for killing higher level enemy per it's level  --(
  48.     # )--------------------------------------------------------------(
  49.     XP_BONUS = 7
  50.    
  51.     # )------------------------------------------------------------(
  52.     # )--  XP Loss for killing lower level enemy per it's level  --(
  53.     # )------------------------------------------------------------(
  54.     XP_LOSS = 3
  55.   end
  56.  
  57.   module Vocab
  58.     # )----------------------(
  59.     # )--  XP Get message  --(
  60.     # )----------------------(
  61.     OBTAIN_EXP  = "%s has received %s EXP!" # actor name, total xp gotten
  62.   end
  63. end
  64.  
  65. # )------------------------(
  66. # )--  Class: Game_Actor --(
  67. # )------------------------(
  68. class Game_Actor < Game_Battler
  69.  
  70.   # )---------------------------------------(
  71.   # )--  Overwrite Method: exp_for_level  --(
  72.   # )---------------------------------------(
  73.   def exp_for_level(level)
  74.     0
  75.   end
  76.   # )----------------------------------------(
  77.   # )--  Overwrite Method: next_level_exp  --(
  78.   # )----------------------------------------(
  79.   def next_level_exp
  80.     MrTS::Static_Exp::NEXT_LEVEL_XP
  81.   end
  82.   # )----------------------------------(
  83.   # )--  Overwrite Method: level_up  --(
  84.   # )----------------------------------(
  85.   def level_up
  86.     @level += 1
  87.     @exp[@class_id] = MrTS::Static_Exp::OVERFLOW_XP ? @exp[class_id]-MrTS::Static_Exp::NEXT_LEVEL_XP : 0
  88.     self.class.learnings.each do |learning|
  89.       learn_skill(learning.skill_id) if learning.level == @level
  90.     end
  91.   end
  92. end
  93.  
  94. # )------------------------(
  95. # )--  Class: Game_Troop --(
  96. # )------------------------(
  97. class Game_Troop < Game_Unit
  98.   # )-----------------------------------(
  99.   # )--  Overwrite Method: exp_total  --(
  100.   # )-----------------------------------(
  101.   def exp_total
  102.     party_exp = []
  103.     loop = 0
  104.     $game_party.all_members.each do
  105.       party_exp[loop] = dead_members.inject(0) do |totalxp, enemy|
  106.         xp_reward = MrTS::Static_Exp::XP_REWARDED
  107.         xp_reward += MrTS::Static_Exp::XP_BONUS * (enemy.exp - $game_party.all_members[loop].level) if enemy.exp > $game_party.all_members[loop].level
  108.         xp_reward -= MrTS::Static_Exp::XP_LOSS  * ($game_party.all_members[loop].level - enemy.exp) if enemy.exp < $game_party.all_members[loop].level
  109.         xp_reward = 0 if xp_reward < 0
  110.         totalxp += xp_reward
  111.       end
  112.       loop += 1
  113.     end
  114.     return party_exp
  115.   end
  116. end
  117.  
  118.  
  119. module BattleManager
  120.   # )----------------------------------(
  121.   # )--  Overwrite Method: gain_exp  --(
  122.   # )----------------------------------(
  123.   def self.gain_exp
  124.     i = 0
  125.     $game_party.all_members.each do |actor|
  126.       actor.gain_exp($game_troop.exp_total[i])
  127.       i += 1
  128.     end
  129.     wait_for_message
  130.   end
  131.  
  132.   # )-------------------------------------(
  133.   # )--  Overwrite Method: display_exp  --(
  134.   # )-------------------------------------(
  135.   def self.display_exp
  136.     if $game_troop.exp_total.size > 0
  137.       i = 0
  138.       $game_party.members.each do |member|
  139.         if $game_troop.exp_total[i] > 0
  140.           text = sprintf(MrTS::Vocab::OBTAIN_EXP, member.name, $game_troop.exp_total[i])
  141.           $game_message.add('\.' + text)
  142.         end
  143.         i += 1
  144.       end
  145.     end
  146.   end
  147. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement