Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

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)

Code:
#==============================================================================

# 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: [url=http://usuarios.multimania.es/kisap/english_list.html]http://usuarios.multimania.es/kisap/english_list.html[/url]

#==============================================================================

 

=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
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top