Health proportion - mathematic - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Health proportion - mathematic (
/showthread.php?tid=612318)
Health proportion - mathematic -
ball - 16.07.2016
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?
Re: Health proportion - mathematic -
AbyssMorgan - 16.07.2016
https://sampforum.blast.hk/showthread.php?tid=537468
Re: Health proportion - mathematic -
ball - 16.07.2016
This isn't what I am looking for. As title says, this is include for progress, not for proportions.
Re: Health proportion - mathematic -
PrO.GameR - 16.07.2016
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^^)
Re: Health proportion - mathematic -
ball - 16.07.2016
Thank you, your algorithm works very well, I really appreciate your help.