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.

Heart-Pumping Action!

This should be actually a simple script, but can some one make it so when one character's hp falls below 10% it plays a heartbeat? Also...if you could find a heartbeat sfx, thatd be great! Thanks in advance! :)
 
Lifted from their website:

A1 Free Sound Effects said:
Non Profit / Personal Use: Everyone can download and use the sound effects for FREE... any School, Church, Student, Teacher or Non Profit Corporation can use the sounds for free in any Home, Event or Classroom Project.

Commercial Use: Any Commercial use of the Sound Effects requires permission from A1 Free Sound Effects. We will grant you the right to use any of the sound effects with any purchase of Our Commercial CD.
 
Code:
class Scene_Battle
  alias low_health_se_play_update_phase4_step5 update_phase4_step5
  def update_phase4_step5
    low_health_se_play_update_phase4_step5
    for target  in @target_battlers
      if target.is_a?(Game_Actor) and target.hp <= target.maxhp / 10
        $game_system.se_play(RPG::AudioFile.new(file, volume, pitch))
      end
    end
  end
end

replace file with the filename (in "")
volume is the volume
pitch is the pitch

you may leave out volume and pitch if you want

untested but it should work
 
Sorry, to say, but i got the error on line 7..maybe its because i changed it to bgs? heres what line 7 currently is: $game_system.bgs_play(RPG::AudioFile.new(medical006, 100, 50))
 
Code:
class Game_Party
  def all_healthy?
    for actor in @actors
      return false if actor.hp <= actor.maxhp / 10
    end
    return true
  end
end

class Scene_Battle
  alias low_health_se_play_update_phase4_step5 update_phase4_step5
  def update_phase4_step5
    low_health_se_play_update_phase4_step5
    if $game_party.all_healthy?
      if $game_system.playing_bgs.name == FILENAME
        Audio.bgs_stop
      end
    else
      if $game_system.playing_bgs.name != FILENAME
        $game_system.bgs_play(RPG::AudioFile.new(file, volume, pitch))
      end
    end
  end
end

also replace FILENAME with the bgs sound effect you are playing
 
Ok, heres a fixed version

Code:
class Game_Party
  def all_healthy?
    for actor in @actors
      return false if actor.hp <= actor.maxhp / 10
    end
    return true
  end
end

class Scene_Battle
  alias low_health_se_play_update_phase4_step5 update_phase4_step5
  def update_phase4_step5
    low_health_se_play_update_phase4_step5
    if $game_party.all_healthy?
      if $game_system.playing_bgs != nil and $game_system.playing_bgs.name == FILENAME
        Audio.bgs_stop
      end
    else
      if $game_system.blaying_bgs == nil or $game_system.playing_bgs.name != FILENAME
        $game_system.bgs_play(RPG::AudioFile.new(file, volume, pitch))
      end
    end
  end
end
 
Ok, now it works...just one problem...the battle music is too loud. One last request. Can you make it so when heart beat is playing, to put the Battle BGM to 50%? If you dont want to, i understand.
 

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