Battle result(scripters tool)

I created this class so anyone can easily create a custom or more advanced
battle result window. This object gives you all the information need in a simplier
way and without a lot of trouble. It creates a array of party actors with:

-Array of learned skills ids of each actor
-Gained levels
-Actor referen ce
-Origin and ending exp and levels
-All the default info(gold,etc)

  1. #==============================================================================
  2. # Battle Result
  3. # By gerkrt/gerrtunk
  4. # Version: 1.0
  5. # License: GPL, credits
  6. # Date: 22/08/2011
  7. # IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
  8. # script check here: http://usuarios.multimania.es/kisap/english_list.html
  9. #==============================================================================
  10.  
  11. =begin
  12.  
  13. --------Introduction-----------
  14.  
  15. I created this class so anyone can easily create a custom or more advanced
  16. battle result window. This object gives you all the information need in a simplier
  17. way and without a lot of trouble. It creates a array of party actors with:
  18.  
  19. -Array of learned skills ids of each actor
  20. -Gained levels
  21. -Actor referen ce
  22. -Origin and ending exp and levels
  23. -All the default info(gold,etc)
  24.  
  25. ------Instructions-------------
  26.  
  27. You just need to give to it the initial levels of the party. For that, i put
  28. here the sample code i use in scene battle start_phase5
  29.  
  30.     initial_levels = []
  31.     for ac in $game_party.actors
  32.       initial_levels.push (ac.level)
  33.     end
  34.    
  35.     You only have to pass that array.
  36.    
  37.    
  38. =end
  39.  
  40.  
  41.  
  42. ResultActor = Struct.new( :actor, :origin_level,  :gained_skills,
  43.   :gained_levels)
  44.  
  45. class Battle_Result
  46.  
  47.   attr_reader :actors_data
  48.   attr_reader :exp
  49.   attr_reader :gold
  50.   attr_reader :treasures
  51.  
  52.   #--------------------------------------------------------------------------
  53.   # * Initialize
  54.   #--------------------------------------------------------------------------
  55.   def initialize(initial_levels, exp, gold, treasures)
  56.     @actors_initals_levels = initial_levels
  57.     @exp = exp
  58.     @gold = gold
  59.     @treasures = treasures
  60.     @actors_data = []
  61.     generate_data(initial_levels)
  62.  
  63.     #p @messages
  64.   end
  65.  
  66.  
  67.   #--------------------------------------------------------------------------
  68.   # * Generate data
  69.   # This method generates the object data.
  70.   #--------------------------------------------------------------------------
  71.   def generate_data(initial_levels)
  72.     i = 0
  73.     # Actors gain level
  74.     for actor in $game_party.actors
  75.       @actors_data.push (ResultActor.new(actor, initial_levels[i],  
  76.       [], 0))
  77.       count = 0
  78.       # Valid actor?
  79.       if actor.cant_get_exp? == false
  80.         difference = actor.level - @actors_initals_levels[i]
  81.         # Check diff so can gain levels or exp
  82.         if difference > 0
  83.          
  84.           # LEVEL UP.
  85.           @actors_data.last.gained_levels = difference
  86.          
  87.           # SKILL GAIN UP.
  88.           for lv in 0...difference
  89.             # If it have skills learning
  90.             for lea in $data_classes[actor.class_id].learnings
  91.               if lea.level ==  @actors_initals_levels[i] + lv
  92.                 @actors_data.last.gained_skills.push (lea.skill_id)
  93.               end
  94.             end
  95.           end
  96.         end
  97.       end
  98.       i += 1
  99.     end
  100.   end
  101.  
  102. end
  103.  
  104.  
  105.  
  106. module Wep
  107.   Scripts_list = [] unless defined? Scripts_list
  108.   Scripts_list.push ('Battle Result')
  109. end
Expand to see the code.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75412