RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Battle result(scripters tool)

Started by gerkrt, August 22, 2011, 11:15:20 PM

0 Members and 2 Guests are viewing this topic.

gerkrt


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)

#==============================================================================
# Battle Result
# By gerkrt/gerrtunk
# Version: 1.0
# License: GPL, credits
# Date: 22/08/2011
# IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
# script check here: http://usuarios.multimania.es/kisap/english_list.html
#==============================================================================

=begin

--------Introduction-----------

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)

------Instructions-------------

You just need to give to it the initial levels of the party. For that, i put
here the sample code i use in scene battle start_phase5

    initial_levels = []
    for ac in $game_party.actors
      initial_levels.push (ac.level)
    end
   
    You only have to pass that array.
   
   
=end



ResultActor = Struct.new( :actor, :origin_level,  :gained_skills,
  :gained_levels)

class Battle_Result
 
  attr_reader :actors_data
  attr_reader :exp
  attr_reader :gold
  attr_reader :treasures
 
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(initial_levels, exp, gold, treasures)
    @actors_initals_levels = initial_levels
    @exp = exp
    @gold = gold
    @treasures = treasures
    @actors_data = []
    generate_data(initial_levels)

    #p @messages
  end
 
 
  #--------------------------------------------------------------------------
  # * Generate data
  # This method generates the object data.
  #--------------------------------------------------------------------------
  def generate_data(initial_levels)
    i = 0
    # Actors gain level
    for actor in $game_party.actors
      @actors_data.push (ResultActor.new(actor, initial_levels[i], 
      [], 0))
      count = 0
      # Valid actor?
      if actor.cant_get_exp? == false
        difference = actor.level - @actors_initals_levels[i]
        # Check diff so can gain levels or exp
        if difference > 0
         
          # LEVEL UP.
          @actors_data.last.gained_levels = difference
         
          # SKILL GAIN UP.
          for lv in 0...difference
            # If it have skills learning
            for lea in $data_classes[actor.class_id].learnings
              if lea.level ==  @actors_initals_levels[i] + lv
                @actors_data.last.gained_skills.push (lea.skill_id)
              end
            end
          end
        end
      end
      i += 1
    end
  end

end



module Wep
  Scripts_list = [] unless defined? Scripts_list
  Scripts_list.push ('Battle Result')
end