In a large scale war, I’m not so sure. A fire-and-forget weapon with a 40km range is expensive and might be a scarce resource. Bullets are much cheaper, and if the AI can fly itself close enough to shoot you, it can do so inexpensively.
And this is not to mention that a 40km range weapon requires targeting that works at 40km.