I don't know how hard it would be to code, but it would add to realism to give units with ranged weapons a limited amount of ammo. A Legionary would only have three pila, both because of weight and bulk. (That's how many they carried in real life.) An archer can carry more arrows in his quiver, and a slinger can also carry a fair number of projectiles. Once they've used up their ammo, they're no more than infantry, usually un-armored. Of course, after the combat they can re-arm, although that takes time.