Hey guys, so I am looking for a reloading algorithm. Something where...
X = Current Ammo (Maximum of 30) Y = Ammo left
So when you activate the reload sequence...
if X=24 and Y=60, then X=30 and Y=54
if X=15 and Y=4, then X=19 and Y=0
if X=19 and Y=15, then X=30 and Y=4
I have been trying and trying to get this working and to no avail. All of the solutions I made work, but they require a ton of if/else statements and I know there is a much more simple way of doing this. So, anyone have any ideas?
var ammo_reload = minv(
ammo_left, // Maximum is ammo_left, so we can't reload bullets we don't have
30 - ammo_current); // Calculate missing ammo in weapon
ammo_left -= ammo_reload;
ammo_current += ammmo_reload;
Perfect! I never even knew about minv! After seeing how its used I could use this to reduce the amount of code I have. Thanks MasterQ32, With your permission would I be able to add this to a contribution I am making? Essentially, its a big contribution with code snippets and other useful things for beginning and advanced programmers alike. With credit going to you of course.