Stamina Depletion
-
Im currently trying to develop a stamina UI, problem is, sometimes it doesnt match the player stamina. For example, if you sprint, jump and repeat these like 4 times you would ran out of stamina even though the bar would not even be at half. Any ideas on whats happening or how the stamina regen or spending works?
-
dergyrt
I gave this a go and ran into the same issue you did.
After probably 15 different iterations, this was the formula i used that best matched up for my sprint status bar!if(self hasperk("specialty_longersprint")) { self.maxsprintcount = 7.0; } else{ self.maxsprintcount = 3.5; } if(self issprinting() && self.sprintcount > 0) { self.sprintcount = self.sprintcount - .1; wait .05; } else if(self.sprintcount < .5) { self.sprintcount = self.sprintcount + .05; wait .05; } else if(self.sprintcount < self.maxsprintcount) { self.sprintcount = self.sprintcount + .1; wait .05; } self.sprint_bar updatebar(self.sprintcount / self.maxsprintcount);
-
dont think so, that has the same problem, here is my implementation of your formula with a textbox (to verify accuracy):
updateStamina() { self endon("disconnect"); if(self hasPerk("specialty_longersprint")) { self.maxsprintcount = 7.0; } else { self.maxsprintcount = 3.5; } self.sprintcount = self.maxsprintcount; for(;;) { if(self isSprinting() && self.sprintcount > 0) { self.sprintcount = self.sprintcount - 0.1; } else if(self.sprintcount < 0.5) { self.sprintcount = self.sprintcount + 0.05; } else if(self.sprintcount < self.maxsprintcount) { self.sprintcount = self.sprintcount + 0.1; } self.sprintcount = max(0, min(self.sprintcount, self.maxsprintcount)); staminaPercentage = int((self.sprintcount / self.maxsprintcount) * 100); if(isDefined(self.staminaText)) { self.staminaText setText("Stamina: " + staminaPercentage + "%"); if(staminaPercentage <= 25) { self.staminaText.color = (200, 0, 0); } else { self.staminaText.color = (0, 200, 0); } } wait 0.05; } }
-
dergyrt you don't think so what?
This works great for me with very little deviation from what i find is the actual sprint. it's a bar graph for me (you can implement it however you like)
Edit: oh i see, you are saying it doesn't match up for you... got it. yeah i've found it to be 90% accurate which in the absence of anything else / official, works great for my use. Let me know if you get something closer