refactored melee_attack and ranged_attack