updated code for damage and random damage generator with proper index number and comments