I am trying to make a sound play when hp is lower than 25% by using events. Is there any script that i can call to check if the players hp is lower than 25%?
EDIT: I knew i made a similar topic so i didn't want to make a new post lol.
Anway i need to know how to check if the actors hp is greater than 95% but less than 100% I need to do this through the call script event.
hp = $game_party.actors[0].hp / $game_party.actors[0].max_hp * 100
The percentage. Well, I can't find 'hp' as an attribute or method in Game_Actors, but I hope this works...
That will make it always equal 0 or 100 XP
You gotta make one of those numbers a float such as adding a .to_f after the .hp
And it's .maxhp XP
hp = $game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp * 100
You can do it with events as well.
SBR's code should work if you add the float conversion Aqua suggested. Just don't store it in a variable, but check if in a a condition directly. Maybe like this:
$game_party.actors[0].hp.to_f / $game_party.actors[0].max_hp < 0.25
Quote from: Aqua on May 23, 2010, 10:33:05 am
That will make it always equal 0 or 100 XP
You gotta make one of those numbers a float such as adding a .to_f after the .hp
And it's .maxhp XP
hp = $game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp * 100
Ah, I see. So that's what .to_f means :^_^':. I knew it a long time ago, but forgot it. Sorry :P!
I tried it and it said:
(http://img269.imageshack.us/img269/619/errorta.png)
Sorry, oversaw it.
$game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp < 0.25
Quote from: Blizzard on May 23, 2010, 04:50:06 pm
Sorry, oversaw it.
$game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp < 0.25
Yeah, I just discovered that.
I gots a new question lol
I don't see how the hp could pass 100%, but let me just answer your question :P.
$game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp > 0.95
In a conditional branch as script. It's exactly the same code as Blizz provided, but I changed the 'smaller than' sign to a 'greater than' sign and I changed 0.25 (25%) to 0.95 (95%). If your HP IS able to pass 100%, use this piece of code:
$game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp > 0.95 && $game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp < 100
TYVM! Exactly what i needed lol i was gonna do it with like 100 conditional branches lol.
The hp doesnt go over 100% but what i wanted to do was make an evented hud. If they are at 100% it shows a pic 95-99% shows a different pic etc.
I already had the long version and it works but i wanted to shorten the event alot lol.
I kind of thought of adding && and then repeat and change the code, because of java, but I didn't know it would work the same in rgss lol.
ANYWAYS: THANKS!!
By the way i don't know if i should level u up or down lol.
Quote from: Zexion on July 30, 2010, 06:24:45 am
TYVM! Exactly what i needed lol i was gonna do it with like 100 conditional branches lol.
The hp doesnt go over 100% but what i wanted to do was make an evented hud. If they are at 100% it shows a pic 95-99% shows a different pic etc.
I already had the long version and it works but i wanted to shorten the event alot lol.
I kind of thought of adding && and then repeat and change the code, because of java, but I didn't know it would work the same in rgss lol.
ANYWAYS: THANKS!!
By the way i don't know if i should level up or down lol.
YW! Ah, now I see what you mean. *slaps himself*
Well, the problem is that it's almost impossible for people with a level lower than 10 to get a good level... You see: some noobs level people down... So... up? TY!