Skip to content

Comment on A time-travelling door bug in Half Life 2parent

Comments

I’m surprised to hear the ammo calculation code would use floats.

The game has ammo pickups that refill 20% and 50% of whatever your max ammo is, so floats have to be involved in there somewhere.

Dividing by 5 or 2, respectively, are integers, if the game developers wanted them to be. More so because the actual units of ammo need to be integers if they are to render as full bullets each

Or more generalized "ammo += (maxAmmo * percentageToFill) / 100"

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.