Okay, now I know that this math is correct, but for whatever reason I CAN NOT get this stupid thing to work for me! (I'm using MMF1.5) I figure the tons of math gurus on here might know what I'm doing incorrectly.
What I want: To display a counter (that has 101 frames of animation to look like a "life bar", from value 0 to 100). But instead of showing raw HP, I want it to show the percentage of life left on the enemy.
I have this for the calculation:
set EnemyLifeBar Value to Int((Health("enemy") / MaxHealth("enemy")) * 100) + 1
So say an enemy had 8 of its maximum 10 HP left, 8 / 10 = .8 * 100 = 80%
So it would show the bar at 80% full.
The "+1" is so the animation frame matches up correctly, so frame #1 is when the enemy has 0 life, and frame 101 is when it's at 100% health.
I've run this on the calculator with numerous values and it all works perfectly. The problem is that whenever I change the value of the enemy's health, the counter sets itself to 1. ALL THE TIME. I also have a string label that constantly displays the current monster HP so I know that the value doesn't get set to zero by accident (which would make the bar show up as empty.) I've tried changing its starting value so that it starts out with less than maximum HP, and the counter sets itself to zero. I've tried taking the "Int" part of the equation out (I don't know why, I just had to try everything) but also no dice. The counter's values are set to 0 minimum, 101 maximum, and I have all the frames for it drawn and loaded already. In fact, if you set the counter's value to the enemy's HP it works great- only it shows the actual HP instead of the overall health percentage like I want it to. (So that a rabbit with 2 or its max 4 HP should display a health bar half full instead of a tiny "2 out of 100" sliver of life on the bar.)
I don't want to compromise my game and just have it display the actual HP, especially since this would limit my monsters to a maximum of 100 HP for the whole game! Is it just a wanky MMF bug?
Edited by the Author.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Okay, it works but what was weird is that by adding the .0 to the calculation didn't make it work- I had to add the .0s to the Alt Variables themselves.
Thanks again Radix, what a difference it makes
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
I dont understand the advantage of doing this... but currently in a game I'm working on, the enemies have health and a max health value. When you hit an enemy, the enemy health counter is set to those values... so it should automatically show a percentage, right?
Yep, it's an animation counter. BUT it's not one of those default crappy health bars. I had to actually draw ONE HUNDRED (and one) STINKIN' FRAMES to make a decent-looking health bar. And to top it off, there are different colored variations of these bars throughout my game that I had to go through all the frames. (There's red, blue, purple, green, yellow, brown, and grey!) It was a big, big pain in the ass, but at least they're all completed now.
You can sort of see the bar in the inventory screenshot of my Equin 3 preview, but that's a REALLY old screenshot so don't worry the whole thing looks much better now.
Phizzy said: Which doesn't really make sense
Yep, that pretty much sums up my coding style in MMF at least, lol. The end result is the goal, even if the road there is full of crazy, crazy, twists and turns that don't need to be.
Edited by the Author.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
I don't think so. Sure, it's still technically a bar, but instead of the default skinny solid bar I now have colored bars with different shades to them. Not to mention a border around each one.
This was nothing compared to the pain in the ass that all the drawing / copying / pasting to different backgrounds per animation frames that I did for Equin Adventures. That was probably the most taxing and tedious thing in programming that I've ever done.
Here's why:
3 frames of animation for walking w/ regular sword for 4 directions on the grass(12)
3 frames of animation for a regular sword attack in 4 directions the grass (12)
3 frames of animation for getting hit for 4 directions on the grass (12)
3 frames of animation for walking with a shield & reg sword for 4 directions on grass (12)
3 frames of animation for walking with a shield & shadow sword for 4 directions on grass (12)
3 frames of animation for attacking w/ regular sword with a shield for 4 directions on grass (12)
3 frames of animation for walking with the shadow sword for 4 directions on grass (12)
3 frames of animation for attacking w/ shadow sword for 4 directions on grass (12)
3 frames of animation for attacking w/ shadow sword and shield for 4 directions on grass (12)
4 frames of animation (frontal) for dying while on the grass (4)
1 frame of animation (frontal) for blocking with the shield (1)
Ready for the kicker? Each of the above had to be done for grass, dirt, wood floors, and snow! For the inside areas the shadow sword also had a glow around it, so it wasn't a simple cut / paste for those ones. The walking animation for different swords was done so that the player could see the different sword slung on Equin's back.
So that's 113 pictures x 4 backgrounds = 452 pictures. For the main character alone!
I didn't learn about bitblt until Equin Village, otherwise it would have saved me a couple of weeks at least.
So I don't stress the life bar too much lol.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!