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.

Help needed for script

Anonymous

Guest

I have this DerVVulfman "limit break" i just would like to have a lil andjustment. to make it that when the character reaches Limit break it adds a state so it has an animation. what i mean is that i would like to have a Full Limit break state added when the limit breaks are available

Code:
#==============================================================================
# *** Limit Break (DVV's)                                          (01-07-2006)
# *** Version 1.1
#------------------------------------------------------------------------------
# by DerVVulfman
# 
#   This system is a revamped & rewritten system that disables 'element-tagged'
#   skills until the hero's limitbreak bar is filled.   Once the skill is used,
#   the skill becomes disabled again.   Works with and without the RTAB system.
#   
#   One feature  that was sadly lacking in all other systems  was the inability
#   to fill the limitbreak bar with item damage.   Previous systems only looked
#   to damage inflicted through attacks and skill use.   Items such as grenades
#   were entirely overlooked.
#
#   It is still designed  'menu-less'  so there would be  no conflicts with any
#   custom menu scripts.  However,  with a little work, making a menu system to
#   change an actor's limit break fill-type (Attack/Defend/Guard) can be accom-
#   plished fairly easily... for the script literate.  :)
#
#   It still requires Cogwheel's HP/SP/EXP Gauge script to draw the Limit Break
#   bar, unless a suitable Bar Drawing script is available.   However,  without 
#   the bar drawing script, you will not get an error.   You just won't see the
#   bars on the screen.   Previous scripts  either had  their own 'cheaper' bar
#   rendering system, or had 'REQUIRED' scripts that without 'em... crashed.
#
#==============================================================================

#==============================================================================
#                         * Configuration Section *
#==============================================================================

  # Name of the Limit Break element 
  LB_NAME   = "Limit Break"


  # Starting/Default Limit Break Setting
  LB_START  = 0   # 0 = Attack          |  1 = Critical      |  2 = Damaged
                  # 3 = Killed an enemy |  4 = Killed a Boss |  5 = Hero Died
                  # 6 = Victory         |  7 = Escape/Flee   |  8 = Defending
                  # 9 = Lone Combatant  | 10 = Any Action    | 11 = Crit. Health
  

  # Enemy Bosses (by ID)
  # Related to the LB_Rate, it determines if points garnered through 'killing'
  # an ememy gives regular 'enemy' points or 'boss' points to your LB gauge.
  LB_BOSSES = [17]   # Set to enemy 17 (Skeleton)
  
 
  # Limit Break Max Value
  LB_MAX    = 1000
  
  # Limit Break Fill Rates
  # For flat rates & max value settings, the max value should not exceed LB_MAX.
  LB_RATE   = [  10,   50,  200,  # Hero Attacks the Enemy    (rate, min., max.)
                 25,   25, 1000,  # Hero delivers a CRITICAL! (rate, min., max.)
                 30,    1, 1000,  # Hero takes Damage         (rate, min., max.)
                500,  750,  900,  # Fatalaties:  Enemy, Boss or Self (flat rate)
                200,  200,  100,  # Victory, Escape & Defending      (flat rate)
                160,   40,  160]  # Loner, Action & Crit. Health     (flat rate)
                
  
  # Flexible positioning system.  Default position appears under the STATUS txt.
  LB_MENU_ON    = true            # If on, shows the limitbreak bar in the menu.
  LB_MENU_POS   = [ 0,   0, 204]  # Positioning in the menu:  X, Y, & bar width.
  LB_BATTLE_POS = [ 0,  64, 120]  # Positioning in the battle menu.  Same setup.
  LB_RTAB_POS   = [ 4,  78, 120]  # Position if using RTAB system.   Same setup.
  LB_RTAB_VAR   = [ 160, 0]       # Variable distances between hero's LB gauges.
  

  # SE played when Limit Break filled
  LB_RING   = "082-Monster04"
  

  #----------------------------------------------------------------------------
  # Do not edit below unless you know what you're doing. The following code is
  # for automatic systems in the script. Values are edited or passed elsewhere.
  #----------------------------------------------------------------------------

  # Stores the battler id for item users (needed for non-RTAB systems)
  $item_user = nil
  # Obtain the Limit Break 'id' from the system
  $data_system = load_data("Data/System.rxdata")
  $lb_element_id = $data_system.elements.index(LB_NAME)
  
#==============================================================================
#                       * Configuration Section End *
#==============================================================================
  

  
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------  
  attr_accessor :base_damage
  #--------------------------------------------------------------------------
  # * Applying Normal Attack Effects (Edited)
  #     attacker : battler
  #--------------------------------------------------------------------------
  alias lb_attack_effect attack_effect
  def attack_effect(attacker)
    # Attach base damage to battler (for self.base_damage)
    @base_damage = nil
    # Execute the original process
    result = lb_attack_effect(attacker)
    # Set current damage (rtab or not)
    current_dmg = self.damage
    if $rtab_detected; current_dmg = self.damage[attacker]; end
    # Set crit flag (rtab or not)
    current_crit = self.critical
    if $rtab_detected; current_crit = self.critical[attacker]; end
    # Calculate basic damage
    if @base_damage == nil
      @base_damage = 
      [attacker.atk - self.pdef / 2, 0].max * (20 + attacker.str) / 20
    end
    # When actual physical damage is applied
    if result && current_dmg.is_a?(Numeric) && self.base_damage > 0
      # When HERO attacking the enemy (and tagged for 'Attack')
      if attacker.is_a?(Game_Actor) && self.is_a?(Game_Enemy) && attacker.lb_type == 0 
        # Limit Break growth calculation
        lb_calc = current_dmg * LB_RATE[0] * 10 / self.base_damage
        # Adjust Limit Break growth between min & max values
        lb_add = [[lb_calc, LB_RATE[1]].max, LB_RATE[2]].min
        # OD gauge increase
        attacker.limitbreak += lb_add
      end
      # If the HERO made a critical hit on the Enemy
      if attacker.is_a?(Game_Actor) && self.is_a?(Game_Enemy) && attacker.lb_type == 1 
        if current_crit
          # Limit Break growth calculation
          lb_calc = current_dmg * LB_RATE[3] * 10 / self.base_damage
          # Adjust Limit Break growth between min & max values
          lb_add = [[lb_calc, LB_RATE[4]].max, LB_RATE[5]].min
          # OD gauge increase
          attacker.limitbreak += lb_add  
        end
      end
      # When HERO is damaged by the enemy (and tagged for 'Damaged')
      if attacker.is_a?(Game_Enemy) && self.is_a?(Game_Actor) && self.lb_type == 2 
        lb_calc = current_dmg * LB_RATE[6] * 10 / self.maxhp
        # Adjust Limit Break growth between min & max values
        lb_add = [[lb_calc, LB_RATE[7]].max, LB_RATE[8]].min
        self.limitbreak += lb_add
      end
      # IF a battler has died
      if self.dead?
        # Regular killing move check.
        if attacker.is_a?(Game_Actor) && attacker.lb_type == 3
          attacker.limitbreak += LB_RATE[9]  
        # Killed a boss enemy  
        elsif attacker.is_a?(Game_Actor) && attacker.lb_type == 4 &&
          LB_BOSSES.include?(self.id)
          attacker.limitbreak += LB_RATE[10]  
        end
        # Hero dies
        if self.is_a?(Game_Actor) && self.lb_type == 5
          self.limitbreak += LB_RATE[11]  
        end        
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : the one using skills (battler)
  #     skill : skill
  #--------------------------------------------------------------------------  
  alias lb_skill_effect skill_effect  
  def skill_effect(user, skill)
    # Attach base damage to battler (for self.base_damage)
    @base_damage = nil
    # Execute the original process
    result = lb_skill_effect(user, skill)
    # Set current damage (rtab or not)
    current_dmg = self.damage
    if $rtab_detected; current_dmg = self.damage[user]; end
    # Recalculate the base (unadjusted) damage
    if @base_damage == nil
      # Calculate power
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # Calculate rate
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # Calculate basic damage
      @base_damage = power * rate / 20
    end
    # When actual physical damage is applied
    if result && current_dmg.is_a?(Numeric) && self.base_damage > 0
      # When HERO attacking the enemy (and tagged for 'Attack')
      if user.is_a?(Game_Actor) && self.is_a?(Game_Enemy) && user.lb_type == 0
        # Limit Break growth calculation
        lb_calc = current_dmg * LB_RATE[0] * 10 / self.base_damage
        # Adjust Limit Break growth between min & max values
        lb_add = [[lb_calc, LB_RATE[1]].max, LB_RATE[2]].min
        # OD gauge increase
        user.limitbreak += lb_add
      end
      # When HERO is damaged by the enemy (and tagged for 'Damaged')
      if user.is_a?(Game_Enemy) && self.is_a?(Game_Actor) && self.lb_type == 2
        lb_calc = current_dmg * LB_RATE[6] * 10 / self.maxhp
        # Adjust Limit Break growth between min & max values
        lb_add = [[lb_calc, LB_RATE[7]].max, LB_RATE[8]].min
        self.limitbreak += lb_add
      end
      # IF a battler has died
      if self.dead?
        # Regular killing move check.
        if user.is_a?(Game_Actor) && user.lb_type == 3
          user.limitbreak += LB_RATE[9]  
        # Killed a boss enemy  
        elsif user.is_a?(Game_Actor) && user.lb_type == 4 &&
          LB_BOSSES.include?(self.id)
          user.limitbreak += LB_RATE[10]  
        end
        # Hero dies
        if self.is_a?(Game_Actor) && self.lb_type == 5
          self.limitbreak += LB_RATE[11]  
        end        
      end
    end
    # When limitbreak skill is used
    if user.is_a?(Game_Actor) && skill.element_set.include?($lb_element_id)
      # Reset gauge
      user.limitbreak = 0
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Application of Item Effects
  #     item : item
  #--------------------------------------------------------------------------
  alias lb_item_effect item_effect  
  def item_effect(item, battler = @active_battler)
    # Attach base damage to battler (for self.base_damage)
    @base_damage = nil
    # Set 'user' to the current battler (and ensure if RTAB)
    user = $item_user
    if $rtab_detected; user = battler; end
    # Execute the original process
    result = lb_item_effect(item)
    # Set current damage (rtab or not)
    current_dmg = self.damage
    if $rtab_detected; current_dmg = self.damage[user]; end
    # Recalculate the base (unadjusted) damage
    if @base_damage == nil
      #Calculate power
      power = maxhp * item.recover_hp_rate / 100 + item.recover_hp
      if power < 0
        power += self.pdef * item.pdef_f / 20
        power = [power, 0].min
      end
      # Set damage value and reverse item power amount
      @base_damage = -power
    end
    # When actual physical damage is applied
    if result && current_dmg.is_a?(Numeric) && self.base_damage > 0
      # When HERO attacking the enemy (and tagged for 'Attack')
      if user.is_a?(Game_Actor) && self.is_a?(Game_Enemy) && user.lb_type == 0
        # Limit Break growth calculation
        lb_calc = current_dmg * LB_RATE[0] * 10 / self.base_damage
        # Adjust Limit Break growth between min & max values
        lb_add = [[lb_calc, LB_RATE[1]].max, LB_RATE[2]].min
        # OD gauge increase
        user.limitbreak += lb_add
      end
      # When HERO is damaged by the enemy (and tagged for 'Damaged')
      if user.is_a?(Game_Enemy) && self.is_a?(Game_Actor) && self.lb_type == 2
        lb_calc = current_dmg * LB_RATE[6] * 10 / self.maxhp
        # Adjust Limit Break growth between min & max values
        lb_add = [[lb_calc, LB_RATE[7]].max, LB_RATE[8]].min
        self.limitbreak += lb_add
      end
      # IF a battler has died
      if self.dead?
        # Regular killing move check.
        if user.is_a?(Game_Actor) && user.lb_type == 3
          user.limitbreak += LB_RATE[9]  
        # Killed a boss enemy  
        elsif user.is_a?(Game_Actor) && user.lb_type == 4 &&
          LB_BOSSES.include?(self.id)
          user.limitbreak += LB_RATE[10]  
        end
        # Hero dies
        if self.is_a?(Game_Actor) && self.lb_type == 5
          self.limitbreak += LB_RATE[11]  
        end        
      end
    end
    return result
  end
end



#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler 
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :limitbreak               # Limitbreak value
  attr_accessor :lb_type                  # Limitbreak action type
  attr_accessor :limitbreak_ring          # Limit Break Ring Checker
  #--------------------------------------------------------------------------
  # * Setup
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  alias lb_setup setup
  def setup(actor_id)
    # Perform the original call
    lb_setup(actor_id)
    @limitbreak = 0           # Reset Limit Break gauge to zero
    @lb_type = LB_START       # Set the Limit Break type to 'config' settings.
    @limitbreak_ring = false  # Turn the 'ring' off
  end
  #--------------------------------------------------------------------------
  # * Determine if Skill can be Used
  #     skill_id : skill ID
  #--------------------------------------------------------------------------
  alias lb_skill_can_use? skill_can_use?
  def skill_can_use?(skill_id)
    # Get result from original call
    result = lb_skill_can_use?(skill_id)
    # Return if already disabled
    return if result == false
    # Obtain skill from database
    skill = $data_skills[skill_id]
    # Only perform if skill
    if skill != nil
      # Only perform if includes the Element
      if skill.element_set.include?($lb_element_id)
        # If the limitbreak bar is filled, skill is available
        if self.limitbreak == LB_MAX
          result = true
        # Otherwise, it isn't
        else
          result = false
        end
      end
    end
    return result & super
  end 
  #--------------------------------------------------------------------------
  # * Adjust the limitbreak value (permits addition & keeps within range)
  #--------------------------------------------------------------------------
  def limitbreak=(limitbreak)
    @limitbreak = limitbreak
    @limitbreak = LB_MAX if @limitbreak > LB_MAX 
    @limitbreak = 0 if @limitbreak < 0
  end
  #--------------------------------------------------------------------------
  # * Acquire Limit Break value (nil values won't cause errors now)
  #--------------------------------------------------------------------------
  def limitbreak
    # Return 0 if nil (prevent errors)
    @limitbreak = 0 if @limitbreak == nil
    return @limitbreak
  end
end



#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================
class Window_Base
  #--------------------------------------------------------------------------
  # Draw Actor Name
  #--------------------------------------------------------------------------
  alias lb_draw_actor_name draw_actor_name
  def draw_actor_name(actor, x, y)
    # Set/reset the x, y and width of the Limit Break bar.    
    ox = $game_temp.in_battle ? LB_BATTLE_POS[0] : LB_MENU_POS[0]
    oy = $game_temp.in_battle ? LB_BATTLE_POS[1] : LB_MENU_POS[1]
    ow = $game_temp.in_battle ? LB_BATTLE_POS[2] : LB_MENU_POS[2]
    # To menu... or not to menu
    if LB_MENU_ON && !$game_temp.in_battle
      draw_actor_lb(actor, x + ox, y + oy + 32, ow)
    elsif $game_temp.in_battle
      unless $rtab_detected
        draw_actor_lb(actor, x + ox, y + oy + 32, ow)
      end
    end
    lb_draw_actor_name(actor, x, y)
  end  
  #--------------------------------------------------------------------------
  # * Draw Overdrive Meter
  #--------------------------------------------------------------------------
  def draw_actor_lb(actor, x, y, width = 144)
    if defined?(gauge_rect)
      rate = actor.limitbreak.to_f / LB_MAX
      plus_x = 0
      rate_x = 0
      plus_y = 25
      plus_width = 0
      rate_width = 100
      height = 10
      align1 = 1
      align2 = 2
      align3 = 0
      grade1 = 1
      grade2 = 0
      color1 = Color.new(0, 0, 0, 192)
      color2 = Color.new(255, 255, 192, 192)
      color3 = Color.new(0, 0, 0, 192)
      color4 = Color.new(64, 0, 0, 192)
      color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
      color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
      lb = (width + plus_width) * actor.limitbreak * rate_width / 100 / LB_MAX
      gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
        width, plus_width + width * rate_width / 100,
        height, lb, align1, align2, align3,
        color1, color2, color3, color4, color5, color6, grade1, grade2)
    end      
  end
end



#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
#  This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Base
  
  alias lb_init initialize
  def initialize
    lb_init
    if defined?(at_refresh)
      $rtab_detected = true
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Full Limit Break Gauge SE
  #--------------------------------------------------------------------------
  def full_lb_se
    if LB_RING != nil
      if LB_RING != ""
        Audio.se_play("Audio/SE/" + LB_RING, 80, 100)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame renewal
  #--------------------------------------------------------------------------
  alias lb_refresh refresh
  def refresh(number = 0)
    # Call the original def
    if $rtab_detected
      lb_refresh(number)
    else
      lb_refresh
    end
    # This block is needed only if RTAB in use
    if $rtab_detected
      # Ensure bitmap available for bar drawing
      if self.contents == nil
        self.contents = Bitmap.new(width - 32, height - 32)
      end
      # Search through actors & draw bar if applicable
      if number == 0
        for i in 0...$game_party.actors.size
          draw_actor_lb($game_party.actors[i], LB_RTAB_POS[0], LB_RTAB_POS[1],  LB_RTAB_POS[2])
        end
      else
        if $game_party.actors[number].is_a?(Game_Actor)
          draw_actor_lb($game_party.actors[number], LB_RTAB_POS[0], LB_RTAB_POS[1], LB_RTAB_POS[2])
        end
      end
    end
    # Go through the Actors
    $game_party.actors.each { |actor|
      # Only perform if the actor exists
      next unless actor.exist?
      # When the Limit Break gauge is set to zero,
      # Reset the Limit Break Ringer to false
      if actor.limitbreak == 0
        actor.limitbreak_ring = false
      end
      # When the Overdrive Ringer hasn't rung
      if actor.limitbreak_ring == false
        # But, if the Overdrive Bar is filled
        if actor.limitbreak == LB_MAX
          # Play the Overdrive Sound Effect
          full_lb_se
          # And Set the Overdrive Ringer to true
          actor.limitbreak_ring = true
        end
      end
      }        
  end
end



#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Battle Ends
  #     result : results (0:win 1:lose 2:escape)
  #--------------------------------------------------------------------------
  alias lb_battle_end battle_end
  def battle_end(result)
    # Branch on Battle condition
    case result
    when 0 # Victory
      $game_party.actors.each { |actor|
      next unless actor.exist?
      # For each actor who won & set to Victory
      if actor.lb_type == 6
        actor.limitbreak += LB_RATE[12]
      end
      }
    when 1 # Escape
      $game_party.actors.each { |actor|
      next unless actor.exist?
      # For each actor who ran & set to Escape
      if actor.lb_type == 7
        actor.limitbreak += LB_RATE[13]
      end
      }
    end
    # Defeat
    lb_battle_end(result)
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 2 : start action)
  #--------------------------------------------------------------------------
  alias lb_adddate_p4_s2 update_phase4_step2
  def update_phase4_step2(battler = @active_battler)
    # Perform only if actor
    if battler.is_a?(Game_Actor)
      # Reset adding value
      lb_add = 0
      # Branch on LimitBreak type
      case battler.lb_type
      when 8 # When Defending
        if battler.current_action.kind = 0
          if battler.current_action.basic == 1
            lb_add = LB_RATE[14]
            print lb_add
          end
        end
      when 9 # When it's a lone battler
        if $game_party.actors.size == 1
          lb_add = LB_RATE[15]
        end
      when 10 # When performing ANY acton
        lb_add = LB_RATE[16]
      when 11 # If in CRITICAL
        if battler.hp <= @active_battler.maxhp / 4
          lb_add = LB_RATE[17]
        end
      end
      # Add values to limitbreak
      battler.limitbreak += lb_add
    end
    # Perform the original call
    if $rtab_detected; lb_adddate_p4_s2(battler); else; lb_adddate_p4_s2; end
  end
  #--------------------------------------------------------------------------
  # * Make Item Action Results
  #--------------------------------------------------------------------------  
  alias lb_miar make_item_action_result 
  def make_item_action_result(battler = @active_battler)
    $item_user = battler
    # Perform the original call
    if $rtab_detected; lb_miar(battler); else; lb_miar; end
  end  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 4 : animation for target)
  #--------------------------------------------------------------------------  
  alias lb_update_p4_s4 update_phase4_step4 
  def update_phase4_step4(battler = @active_battler)
     if $rtab_detected
      @status_window.update
      @status_window.refresh
     end
    # Perform the original call
    if $rtab_detected; lb_update_p4_s4(battler); else lb_update_p4_s4 ; end    
  end
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