Function to calculate damage in AI mode.