Health proportion - mathematic
#1

I already have created a bar which should present proportion of health. Player1 fights with Player2, they both have 100HP, in this case this algorithm works

Код:
475.3648 + (154.5352 * (100.0 / 100.0) * 0.5)
475.3648 - a position of textdraw when Player1 wins (Player2 has 0HP)
629.9 - a position of textdraw when Player2 wins (Player1 has 0HP)
154.5352 - difference of 629.9 and 475.3648

But this works only when players have same amount of health. I use the same method with custom healthbar and it works perfectly

Код:
PlayerTextDrawTextSize(playerid, HealthBar, 545.824340 + (58.67566 * (Player[playerid][p_health_amount] / 100.0)), 0.0);
Does anyone have an idea how to create a working algorithm for this?
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=537468
Reply
#3

This isn't what I am looking for. As title says, this is include for progress, not for proportions.
Reply
#4

If I understood correctly algorithm you are looking for is player1/player1+player2 * difference between start of the td to end of it.
This gives the scale point I.E if player1 has 20HP and player2 has 10HP, player1 is ahead by a margin of ~33%


Edit: I guess I read it wrong, I was assuming player1 would win at right end of the TD, change it to player2/player1+player2 * difference (150.0 sth^^)
Reply
#5

Thank you, your algorithm works very well, I really appreciate your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)