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.

How to Make a character transform automatically when meter

ovan35

Member

Alright I've been trying to modify Atoa and KGC's Overdrive script and create a Rage script.Basically what I wanted was to have a meter that filled up as the hero was hit.Once the meter reached the maximum she would transform to another, more powerful character.I am pretty new to RGSS but I have managed to make the meter only appear in under my main character.And I'm pretty sure that I could make the transformation a selectable skill but it's suppose to be a curse something outside of the character's control.So how would you make a skill activate on its own without being chosen by the player.Below is the beginning of the script with one of the major changes I tried to make.Code is a bit long so I apologize in advance.
Code:
 

 

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

# Add-On: Rage

# by Ovan35

# Based on KCG's Overdrive & Atoa's Overdrive system

#pretty much is Atoa's and KCG's system with a few changes as far as variables.All props to them

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

# This Add-On adds an Rage system to the game.

# It works like this:

# A new bar is created, and gets filled up by many different actions, easily

# defined by you. When full, you can use special skills that you couldn't before.

#Much like Atoa's system but I wanted to see if I can modify it for just one character to use it

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

 

module N01

 

  # IDs of the Rage skills.

  #in my case I want to have a transform skill that will change the main character

  #to a different character.

  Rage_Skills_ID = [127]

  

  # Name of the Rage bar graphic file. Must be on the Graphic/Windowskins folder

  #for my purposes the same ODMeter will suffice for now will change the meter

  #another time

  Rage_Meter = 'ODMeter'

  

  # Maximum value of the Rage Bar.Let's keep this the same as well 1000

  #This denotes what the Maximum Rage is to fill up your meter

  Max_Rage = 1000

  

  # Rage gain ratio, change these values as you wish

  #basically this is how much the meter will go up when the condition is met

  Rage_Gain_Rate = [ 150, 300, 100, 100, 200, 150, 100,  30,  50, 150, 100] 

  #              [   A,   B,   C,   D,   E,   F,   G,   H,   I,   J,   K] 

  # A = Gain on attacking, varies depending on the amount of damage dealt

  # B = Gain when attacked, varies depending on the amount of damage received

  # C = Gain when attack is dodged

  # D = Gain when an attack misses

  # E = Gain when a battle is won

  # F = Gain after fleeing a battle

  # G = Gain on the beginning of a dead ally's turn

  # H = Gain at the beginning of an alive ally's turn

  # I = Fixed Gain at the beginning of the turn

  # J = Gain at the beginning of the turn if the character is almost dead

  # K = Gain if the character kills the target while attacking

  

  #Since I only need the rage meter for one character there is no need to have

  #anyone else sharing the skill.I didn't want to risk the code not working so 

  #I kept everything here much the same.Only modifying names and variables

  #where needed.

  Attack_Rage_Plus = [1] # when attacking

  Damage_Rage_Plus = [1] # when being attacked

  Evade_OD_Plus  = []   # when dodge an attack

  Miss_OD_Plus   = []   # when miss an attack

  Win_OD_Plus    = []   # when a battle is won

  Escape_OD_Plus = []   # after a successful escape

  Dead_Rage_Plus   = [1]   # hero gets mad when his friends are dead

  Alive_OD_Plus  = [] # in the begin fo turn for each alive ally

  Turn_OD_Plus   = [] # fixed at the beginning of a turn

  Dying_Rage_Plus  = [1] # If he's hurt bad the meter goes up

  Kill_OD_Plus   = [] # if the character kills the target when attacks

  

  ------------------------------------------------------------------------------

                   #Demon Form Script

  ------------------------------------------------------------------------------

  

  

  #create a new action sequence

  new_action_sequence = {

  "TRANSFORM_DEMON" =>["JUMP_TO","WAIT(FIXED)","START_MAGIC_ANIM","32","TRANSFORM_DEMON",

  "WAIT(FIXED)","DEMONFORM_GRANT","32","JUMP_AWAY"],

  

  #Unites the new sequence to the system

#  ACTION.merge!(new_action_sequence)

#end

module RPG

  class Skill

    alias demonform_base_action base_action

    def base_action

      if @id == 126

        return "TRANSFORM_DEMON"

      end

      demonform_attack_base_action

    end

  end

  #was a extra end here

--------------------------------------------------------------------------------

                 #Demon form script end

--------------------------------------------------------------------------------

  # Rage Meter position on the Battle Status Window

  Rage_Battle_Style = 0

  # 0 = Horizontal Pattern, not centralized

  # 1 = Horizontal Pattern, centralized

  # 2 = Vertical bars

  # 3 = Custom Position

  

  # Readjustment of the Rage Meter's position on the Battle Status Window.  

  Rage_X_Position = 0   # X position of the Meters

  Rage_Y_Position = 112 # Y position of the Meters

  

  # Custom OD Bar position, only valid when Rage_Battle_Style = 3

  OD_Custom_Position = [[460,180],[480,210],[500,240],[520,270]]

  

  # Rage Meter position in main menu

  Menu_Style   = 1

  # 0 = Don't show

  # 1 = Above HP

  # 2 = Bellow name

  # 3 = Bellow level

  

#end

 

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

# ■ Atoa Module

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

$atoa_script['SBS Overdrive'] = true

 

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

# ■ Game_Actor

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

class Game_Actor < Game_Battler 

  #--------------------------------------------------------------------------

  include N01

  #--------------------------------------------------------------------------

  def max_rage

    return Max_Rage

  end

  #--------------------------------------------------------------------------

  def rage

    return @rage == nil ? @rage = 0 : @rage

  end

  #--------------------------------------------------------------------------

  def rage=(n)

    @rage = [[n.to_i, 0].max, self.max_rage].min

  end

  #--------------------------------------------------------------------------

  #I'm thinking this one will be the key to my solution.It control the 

  #maximum rage 

  def rage_full?

    return @rage == self.max_rage

  end

  #--------------------------------------------------------------------------

  def rage_update

    @rage = 0 if self.dead?

  end

end

 

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

# ■ Window_Base

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

class Window_Base < Window

  #--------------------------------------------------------------------------

  include N01

  #--------------------------------------------------------------------------

  def draw_actor_overdrive(actor, x, y)

    @skin = RPG::Cache.windowskin(Rage_Meter)

    @width  = @skin.width

    @height = @skin.height / 3

    src_rect = Rect.new(0, 0, @width, @height)

    self.contents.blt(x , y, @skin, src_rect)    

    @line   = (actor.rage == actor.max_rage ? 2 : 1)

    @amount = 100 * actor.rage / actor.max_rage

    src_rect2 = Rect.new(0, @line * @height, @width * @amount / 100, @height)

    self.contents.blt(x , y, @skin, src_rect2)

  end

end

 

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

# ■ Game_Battler

#I'm thinking here I will have to put my transform code.But I hecessitate to do 

  #it  because I'm not sure how well it will work.Right now I'm thinking a 

  #simple If statement might do it.But what command to change one character

  #to another?

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

class Game_Battler 

  #--------------------------------------------------------------------------

  include N01

  #--------------------------------------------------------------------------

  alias acbs_skill_can_use_od skill_can_use?

  def skill_can_use?(skill_id)

    skill = $data_skills[skill_id]

    if self.actor? && skill != nil && Rage_Skills_ID.include?(skill.id)

      return false unless self.rage_full?

    end

    acbs_skill_can_use_od(skill_id) 

  end  

  #-------------------------------------------------------------------------- 

  alias acbs_attack_effect_od attack_effect 

  def attack_effect(attacker) 

    effective = acbs_attack_effect_od(attacker)

    attack_od(attacker) if self.damage.is_a?(Numeric) 

    miss_od(attacker) if self.evaded or self.missed

    return effective

  end 

  #-------------------------------------------------------------------------- 

  alias perfect_acbs_attack_effect_od perfect_attack_effect 

  def perfect_attack_effect(attacker) 

    effective = perfect_acbs_attack_effect_od(attacker)

    attack_od(attacker) if self.damage.is_a?(Numeric) 

    miss_od(attacker) if self.evaded or self.missed

    return effective

  end 

  #-------------------------------------------------------------------------- 

  alias acbs_skill_effect_od skill_effect 

  def skill_effect(user, skill) 

    effective = acbs_skill_effect_od(user, skill) 

    attack_od(user) if self.damage.is_a?(Numeric) 

    miss_od(user) if self.evaded or self.missed

    return effective

  end

  #-------------------------------------------------------------------------- 

  alias perfect_acbs_skill_effect_od perfect_skill_effect 

  def perfect_skill_effect(user, skill) 

    effective = perfect_acbs_skill_effect_od(user, skill) 

    attack_od(user) if self.damage.is_a?(Numeric) 

    miss_od(user) if self.evaded or self.missed

    return effective

  end

  #-------------------------------------------------------------------------- 

  def attack_od(user)

    if user.actor? && !self.actor? && Attack_Rage_Plus.include?(user.id) && self.damage > 0 

      od_up = [self.damage * Rage_Gain_Rate[0] / (user.level + 10) / 50, 10].max

      user.rage += od_up

      user.rage += Rage_Gain_Rate[10] if self.hp <= 0 and Kill_OD_Plus.include?(user.id)

    elsif !user.actor? && self.actor? && Damage_Rage_Plus.include?(self.id) && self.damage > 0 

      od_up = [self.damage * Rage_Gain_Rate[1] / self.maxhp, 1].max 

      self.rage += od_up

    end

  end

  #-------------------------------------------------------------------------- 

  def miss_od(user)

    if user.actor? && !self.actor? && Miss_OD_Plus.include?(user.id)

      user.rage += Rage_Gain_Rate[3]

    elsif !user.actor? && self.actor? && Evade_OD_Plus.include?(self.id)

      self.rage+= Rage_Gain_Rate[2]

    end 

  end

--------------------------------------------------------------------------------

   #Now that my heroine is capale of transforming let's see if we can link it to

   #the rage meter

   def transformation(user)

     if user.actor? && !self.actor? && self.rage_full?

       "TRANSFORM_DEMON"

     end

   end

   

     

end 

 

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

# ■ Window_Skill

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

class Window_Skill < Window_Selectable

  #--------------------------------------------------------------------------

  def draw_item(index)

    skill = @data[index]

    if @actor.skill_can_use?(skill.id)

      self.contents.font.color = normal_color

      self.contents.font.color = crisis_color if Rage_Skills_ID.include?(skill.id)

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 2 * (288 + 32)

    y = index / 2 * 32

    rect = Rect.new(x, y, self.width / @column_max - 32, 32)

    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

    bitmap = RPG::Cache.icon(skill.icon_name)

    opacity = self.contents.font.color == disabled_color ? 128 : 255

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)

    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)

  end

end

 

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

# ■ Window_BattleStatus

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

class Window_BattleStatus < Window_Base 

  #-------------------------------------------------------------------------- 

  alias acbs_refresh_od refresh 

  def refresh 

    acbs_refresh_od

    #for i in 0...$game_party.actors.size

      actor = $game_party.actors[0] #was i when I first started

      case Rage_Battle_Style

      when 0

        meter_x = 0 * (624 / MAX_MEMBER) + Rage_X_Position

        meter_y = Rage_Y_Position

        #We only need 0 since we only want the main character to have the Rage system

      #when 1

       # meter_x = OD_X_Position + ((624 / MAX_MEMBER) * ((4 - $game_party.actors.size)/2.0 + i)).floor

        #meter_y = OD_Y_Position

      #when 2

       # meter_x = OD_X_Position

        #meter_y = i * 32 + OD_Y_Position

      #when 3

       # meter_x = OD_Custom_Position[i][0]

        #meter_y = OD_Custom_Position[i][1]

      end

      #draws the rage meter

      draw_actor_overdrive(actor, meter_x, meter_y)

    end

  end 

#end

 

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

# ■ Window_MenuStatus

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

class Window_MenuStatus < Window_Selectable

  #-------------------------------------------------------------------------- 

  alias acbs_refresh_od refresh 

  def refresh 

    acbs_refresh_od

    #for i in 0...$game_party.actors.size

      actor = $game_party.actors[0] #again originally this was i

      x = 64

      y = 0 * 116

      draw_actor_overdrive(actor, x + 236, y + 12) if Menu_Style == 1

      draw_actor_overdrive(actor, x + 4, y + 24) if Menu_Style == 2

      draw_actor_overdrive(actor, x + 4, y + 56) if Menu_Style == 3

    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