Change Low HP music with script

Watulio

Villager
Member
Joined
Dec 10, 2015
Messages
10
Reaction score
0
First Language
Spanish
Primarily Uses
I'm using this script for low HP music and it's great http://pastebin.com/raw/Zyg9egcj


But I was trying to add a new function to change the low hp music whenever I wanted, but it doesn't seem to work.


Here's what I have. I put it between the last 2 defs


#--------------------------------------------------------------------------
  # * Change 
  #--------------------------------------------------------------------------
    def lowhp_change(newmusic)
      @current_death_bgm  = RPG::BGM.new(*DP3_PartyDyingBGM::newmusic)
    end


Any ideas?


Code not in format because currently is glitched when you put it inside a code box
 

Watulio

Villager
Member
Joined
Dec 10, 2015
Messages
10
Reaction score
0
First Language
Spanish
Primarily Uses
Never mind I found how. I will post my solution Here in case you need it. Won't put it in code box because it's still wonky. Hopefully this is not confused as self bumping.


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Party Dying Battle BGM
#             Version: 1.0
#             Author: DiamondandPlatinum3
#             Date: September 5, 2012
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script allows you to play an in-danger BGM when your party HP or 
#    singular actor hp is below a certain point.
#    Similar to Pokemon Black and White when your lead pokemon is in danger
#    of fainting.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#------------------------------------------------------------------------------
#  Instructions:
#  
#     -  All you have to do is go into the editable region and change the 
#        appropriate settings to suit your needs. 
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module DP3_PartyDyingBGM
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#                                                        -= 
#                 Editable Region        ////            ==
#                                                        =-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



  # BGM, Volume, Pitch
  # if you want the Battle BGM to play at a different volume or pitch
  # Set the DyingBGM Filename value to nil


                    #   Filename,           Volume   Pitch ]
  DyingBGM        = [ "Wingless",    100,     100  ]


  # Should the check be for the total party hp or for single actors
  # true = Entire Party, false = singular actor
  EntirePartyHP   = true


  # This is the Percentage of Total Health (or below) that your party or actor
  # must have left in order for the Dying BGM to play, this is a perentage out of
  # 100.
  # Play around with it to achieve your desired amount
  HP_Percentage   = 33



  # Do you want to see a messagebox teling you when your breaking point
  # will be?
  # This is for debug purposes, set it to false after finished.
  PrintBreakingPoint = false


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
end # of Editable Region
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#---------------------------------------------------------
# No touchie past here unless you know what you are 
# doing. Failure to heed this warning could cause your 
# computer to yell and scream at you. 
#
# Edit at your own risk.
#--------------------------------------------------------



class Game_Troop < Game_Unit
  def getTroop
    @troop_id
  end
  
end



class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  attr_accessor :current_death_bgm
  
  alias playpartydyingbgm_start start
  def start
    playpartydyingbgm_start
    @partytotalhp       = checkpartytotalhp
    @current_battle_bgm = RPG::BGM.last
    @current_death_bgm  = RPG::BGM.new(*DP3_PartyDyingBGM::DyingBGM)
    @playing_death_bgm  = false
    case $game_troop.getTroop 
    when 1 then @current_death_bgm = RPG::BGM.new("bane", DP3_PartyDyingBGM::DyingBGM[1],DP3_PartyDyingBGM::DyingBGM[2])
    when 8 then  @current_death_bgm = RPG::BGM.new("AiwolowHP", DP3_PartyDyingBGM::DyingBGM[1],DP3_PartyDyingBGM::DyingBGM[2])
  
      end
    
  
   
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias playpartydyingbgm_update update
  def update
    
    #////////////////////////////////////////////
    if checkifindanger
      playdyingbgm
    else
      partydyingbgm_replaybattletheme
    end
     #////////////////////////////////////////////
    playpartydyingbgm_update
  end
  #--------------------------------------------------------------------------
  # * Check if in danger
  #--------------------------------------------------------------------------
  def checkifindanger
    return checkpartyremaininghp if DP3_PartyDyingBGM::EntirePartyHP
    return checkactorremaininghp
  end
  #--------------------------------------------------------------------------
  # * Check Party Total HP
  #--------------------------------------------------------------------------
  def checkpartytotalhp
    partytotalhp = 0
    $game_party.battle_members.each do |actor|
      partytotalhp += actor.mhp
      msgbox_p(actor.name + "'s Breaking Point is: " + ((actor.mhp * (DP3_PartyDyingBGM::HP_Percentage.to_f * 0.01)).to_i).to_s) if DP3_PartyDyingBGM::printBreakingPoint
    end
    msgbox_p("Entire Party Breaking Point is: " + ((partytotalhp * (DP3_PartyDyingBGM::HP_Percentage.to_f * 0.01)).to_i).to_s) if DP3_PartyDyingBGM::printBreakingPoint
    return partytotalhp
  end
  #--------------------------------------------------------------------------
  # * Check Party Remaining HP
  #--------------------------------------------------------------------------
  def checkpartyremaininghp
    partycurrenthp = 0
    $game_party.battle_members.each do |actor|
      partycurrenthp += actor.hp
    end
    return (partycurrenthp < (@partytotalhp * (DP3_PartyDyingBGM::HP_Percentage.to_f * 0.01)).to_i)
  end
  #--------------------------------------------------------------------------
  # * Check Actor Remaining HP
  #--------------------------------------------------------------------------
  def checkactorremaininghp
    $game_party.battle_members.each do |actor|
      return true if ((actor.hp < (actor.mhp * (DP3_PartyDyingBGM::HP_Percentage.to_f * 0.01)).to_i) && actor.hp != 0)
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Play "Dying BGM"
  #--------------------------------------------------------------------------
  def playdyingbgm
    if !@playing_death_bgm
      @current_battle_bgm = RPG::BGM.last
      @playing_death_bgm = true
      
      if samenormalanddyingbgm?
        switchtodyingbgmparams
      else
        @current_death_bgm.play(@current_death_bgm.pos)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Same Normal and Dying BGM?
  #--------------------------------------------------------------------------
  def samenormalanddyingbgm?
    return true unless DP3_PartyDyingBGM::DyingBGM[0]
    return @current_battle_bgm.name == @current_death_bgm.name
  end
  #--------------------------------------------------------------------------
  # * Switch to Dying BGM Params
  #--------------------------------------------------------------------------
  def switchtodyingbgmparams
    RPG::BGM.new(@current_battle_bgm.name, 
                 DP3_PartyDyingBGM::DyingBGM[1], 
                 DP3_PartyDyingBGM::DyingBGM[2]).play(@current_battle_bgm.pos)
  end


 
   
  #--------------------------------------------------------------------------
  # * Replay Battle BGM
  #--------------------------------------------------------------------------
  def partydyingbgm_replaybattletheme
    if @playing_death_bgm
      @playing_death_bgm = false
      @current_death_bgm = RPG::BGM.last
      @current_battle_bgm.play(samenormalanddyingbgm? ? @current_death_bgm.pos : @current_battle_bgm.pos)
    end
  end
  
end
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top