How can I play a repeating sound when party HP low?

● ARCHIVED · READ-ONLY
Started by celebrus 15 posts View original ↗
  1. Hi all!

    I want to give the player a chance to heal before they die due to walking on lava or from poison damage. That's such a lame way to get a Game Over. Think Super Metroid (if you know the reference). When the party's HP is running below, say 20%, I'd like a warning bell to go off to remind the player to cure up. How could I set up a common event to achieve this?

    Thanks for the suggestions!
  2. For each character you would want:

    1 variable equal as the MaxHP

    1 variable equal as the current HP

    1 variable equal as the treshold, the point where your alarm sound should start to play

    You then set the treshold equal to the MaxHP variable and then divide it by a whatever number neccessary to end up with your treshold.

    2eoij2f.png

    Here i divided it by 5, so the treshold would be at 20%.

    If your HP is below 20% of your maxHP, you will then be able to do something, as in play the sound you want or flash the screen or you know what.

    I would suggest adding a 60 frames wait command, else you will have permanently overlapping soundeffects.

    Of course all of that would need to happen in a parallel process common event, just used the event above to show you what i mean.
  3. you could also turn off dieing from floor and trap damage
  4. Xaigoth said:
    you could also turn off dieing from floor and trap damage
    But have the traps knock back the player or something so they can't just walk passed it :3
  5. @Necromus, how would I set this so that no matter where a player is, it always runs when the HP is low?

    Thanks!
  6. The same way as above, note the last bit i wrote there.

    You need to run it in a paralell process event, a common event most likely.

    That way it will work everywhere.
  7. When a character is poisoned the screen flashes everytime poison damage occurs. There's also the balloon icons which appear above a character.

    I like the sound effects idea. Thought you might also be interested in a visual :)

    -A-
  8. I lost track of this thread. Sorry and thanks Necromus!

    If I may, I have one further question here: How can I make it so it's not tied to a particular party member's HP? I'd like to run the common event it if the PARTY has a total HP of less than 20%.

    Thanks!
  9. Just add the party members HP up.

    Assuming you only have 4 members in total:

    (Written in pseudo-code so you should get the idea)



    Code:
    maxHP = Member#1-MaxHP
    currentHP = Member#1-currentHP
    if Member#2 in Party # Conditional Branch
     maxHP += Member#2-MaxHP
     currentHP += Member#2-currentHP
    end
    # Same for Member#3 and Member#4
    
    treshold = maxHP
    treshold /= 5
    if currentHP < treshold
     # issue warning
    end
  10. @MagicMagor: Thanks for your reply! Unfortunately, I don't know how to dynamically grab member#X HP. The party is always made up of four or fewer members, but from a larger pool. When setting a variable to Game data, there are only options for specific actor HPs, without the option to choose by party member number. So, I'm still very unsure how to do this.
  11. Ok, than you need a little bit of scripting.



    Code:
    # Get maximum hp of first member
    $game_variables[1] = $game_party.leader.mhp
    # Get maximum hp of second member
    $game_variables[1] += $game_party.battle_members[1].mhp
    # Get maximum hp of third member
    $game_variables[1] += $game_party.battle_members[2].mhp
    # Get maximum hp of fourth member
    $game_variables[1] += $game_party.battle_members[3].mhp
    
    # Get current hp of first member
    $game_variables[2] = $game_party.leader.hp
    # Get current hp of second member
    $game_variables[2] += $game_party.battle_members[1].hp
    # Get current hp of third member
    $game_variables[2] += $game_party.battle_members[2].hp
    # Get current hp of fourth member
    $game_variables[2] += $game_party.battle_members[3].hp
    Of course the actual line to access a members maxhp/currentHP should only be executed if there is indeed a person at this point. This can be checked with:



    Code:
    # Check if there is at least a second member
    $game_party.battle_members.size >= 2
    # Check if there is at least a third member
    $game_party.battle_members.size >= 3
    # Check if there is at least a fourth member
    $game_party.battle_members.size >= 4
  12. @MagicMagor, now that I think about it, I'd be happy if the common event would execute when the party leader is below 20% of his/her MaxHP. That would eliminate the need to check for additional party members and streamline the script. So, let me see if I understand properly.

    Let's say I want the maximum HP of the party leader to be saved into variable 20. Then I would run this script:

    $game_variables[20] = $game_party.leader.mhp

    And if I want the current HP of the party leader to be saved to variable 21, then I would run this script:

    $game_variables[21] = $game_party.leader.hp

    Finally, I run the warning event on the conditional that:

    $game_party.leader.hp < $game_party.leader.mhp * 0.20

    Is that a correct understanding?

    Thanks!
  13. Yes, that's correct.
  14. I just tested it and it works. Thanks! All solved!
  15. Celebrus next time your topic is solved, report the topic and ask for it to be closed :)

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.