Advertisement
diamondandplatinum3

Party Dying Battle BGM ~ RGSS3

Sep 4th, 2012
861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.98 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Party Dying Battle BGM
  3. #             Version: 1.0
  4. #             Author: DiamondandPlatinum3
  5. #             Date: September 5, 2012
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #
  9. #    This script allows you to play an in-danger BGM when your party HP or
  10. #    singular actor hp is below a certain point.
  11. #    Similar to Pokemon Black and White when your lead pokemon is in danger
  12. #    of fainting.
  13. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. #------------------------------------------------------------------------------
  15. #  Instructions:
  16. #  
  17. #     -  All you have to do is go into the editable region and change the
  18. #        appropriate settings to suit your needs.
  19. #
  20. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. module DP3_PartyDyingBGM
  22. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  23. #                                                        -=
  24. #                 Editable Region        ////            ==
  25. #                                                        =-
  26. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  27.  
  28.  
  29.   # BGM, Volume, Pitch
  30.   # if you want the Battle BGM to play at a different volume or pitch
  31.   # Set the DyingBGM Filename value to nil
  32.  
  33.                     #   Filename,           Volume   Pitch ]
  34.   DyingBGM        = [ "Dying Battle BGM",    100,     100  ]
  35.  
  36.  
  37.  
  38.   # Should the check be for the total party hp or for single actors
  39.   # true = Entire Party, false = singular actor
  40.   EntirePartyHP   = false
  41.  
  42.  
  43.  
  44.   # This is the Percentage of Total Health (or below) that your party or actor
  45.   # must have left in order for the Dying BGM to play, this is a perentage out of
  46.   # 100.
  47.   # Play around with it to achieve your desired amount
  48.   HP_Percentage   = 25
  49.    
  50.  
  51.  
  52.   # Do you want to see a messagebox teling you when your breaking point
  53.   # will be?
  54.   # This is for debug purposes, set it to false after finished.
  55.   PrintBreakingPoint = false
  56.  
  57.  
  58.  
  59. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60. end # of Editable Region
  61. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  62. #---------------------------------------------------------
  63. # No touchie past here unless you know what you are
  64. # doing. Failure to heed this warning could cause your
  65. # computer to yell and scream at you.
  66. #
  67. # Edit at your own risk.
  68. #--------------------------------------------------------
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. class Scene_Battle < Scene_Base
  80.   #--------------------------------------------------------------------------
  81.   # * Start Processing
  82.   #--------------------------------------------------------------------------
  83.   alias playpartydyingbgm_start start
  84.   def start
  85.     playpartydyingbgm_start
  86.     @partytotalhp       = checkpartytotalhp
  87.     @current_battle_bgm = RPG::BGM.last
  88.     @current_death_bgm  = RPG::BGM.new(*DP3_PartyDyingBGM::DyingBGM)
  89.     @playing_death_bgm  = false
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # * Frame Update
  93.   #--------------------------------------------------------------------------
  94.   alias playpartydyingbgm_update update
  95.   def update
  96.     #////////////////////////////////////////////
  97.     if checkifindanger
  98.       playdyingbgm
  99.     else
  100.       partydyingbgm_replaybattletheme
  101.     end
  102.      #////////////////////////////////////////////
  103.     playpartydyingbgm_update
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # * Check if in danger
  107.   #--------------------------------------------------------------------------
  108.   def checkifindanger
  109.     return checkpartyremaininghp if DP3_PartyDyingBGM::EntirePartyHP
  110.     return checkactorremaininghp
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Check Party Total HP
  114.   #--------------------------------------------------------------------------
  115.   def checkpartytotalhp
  116.     partytotalhp = 0
  117.     $game_party.battle_members.each do |actor|
  118.       partytotalhp += actor.mhp
  119.       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
  120.     end
  121.     msgbox_p("Entire Party Breaking Point is: " + ((partytotalhp * (DP3_PartyDyingBGM::HP_Percentage.to_f * 0.01)).to_i).to_s) if DP3_PartyDyingBGM::PrintBreakingPoint
  122.     return partytotalhp
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # * Check Party Remaining HP
  126.   #--------------------------------------------------------------------------
  127.   def checkpartyremaininghp
  128.     partycurrenthp = 0
  129.     $game_party.battle_members.each do |actor|
  130.       partycurrenthp += actor.hp
  131.     end
  132.     return (partycurrenthp < (@partytotalhp * (DP3_PartyDyingBGM::HP_Percentage.to_f * 0.01)).to_i)
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Check Actor Remaining HP
  136.   #--------------------------------------------------------------------------
  137.   def checkactorremaininghp
  138.     $game_party.battle_members.each do |actor|
  139.       return true if ((actor.hp < (actor.mhp * (DP3_PartyDyingBGM::HP_Percentage.to_f * 0.01)).to_i) && actor.hp != 0)
  140.     end
  141.     return false
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Play "Dying BGM"
  145.   #--------------------------------------------------------------------------
  146.   def playdyingbgm
  147.     if !@playing_death_bgm
  148.       @current_battle_bgm = RPG::BGM.last
  149.       @playing_death_bgm = true
  150.      
  151.       if samenormalanddyingbgm?
  152.         switchtodyingbgmparams
  153.       else
  154.         @current_death_bgm.play(@current_death_bgm.pos)
  155.       end
  156.     end
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * Same Normal and Dying BGM?
  160.   #--------------------------------------------------------------------------
  161.   def samenormalanddyingbgm?
  162.     return true unless DP3_PartyDyingBGM::DyingBGM[0]
  163.     return @current_battle_bgm.name == @current_death_bgm.name
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # * Switch to Dying BGM Params
  167.   #--------------------------------------------------------------------------
  168.   def switchtodyingbgmparams
  169.     RPG::BGM.new(@current_battle_bgm.name,
  170.                  DP3_PartyDyingBGM::DyingBGM[1],
  171.                  DP3_PartyDyingBGM::DyingBGM[2]).play(@current_battle_bgm.pos)
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # * Replay Battle BGM
  175.   #--------------------------------------------------------------------------
  176.   def partydyingbgm_replaybattletheme
  177.     if @playing_death_bgm
  178.       @playing_death_bgm = false
  179.       @current_death_bgm = RPG::BGM.last
  180.       @current_battle_bgm.play(samenormalanddyingbgm? ? @current_death_bgm.pos : @current_battle_bgm.pos)
  181.     end
  182.   end
  183. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement