In my own Return From Exile, I used the following scene;
'Fifty Aqualish, half of one company were approaching where I hid in ambush with the other fifty. I nodded, and the ‘men’ with me opened fire. We were using training weapons, so while there was the noise of a lot of blasters cycling, the flashes of light simulating the blaster fire would set off sensors in uniforms below rather than kill anyone. If they hit, the uniform would stiffen, and the man would drop to the ground. What you are supposed to do is dive for cover, assess the situation, then attack, rolling up the enemy using fire and maneuver.
As I said, that is what you are supposed to do.
There are three types in a battle like this. The ones that dive for cover before they are hit, the ones that freeze for a fatal second or two, and the ones that charge screaming at the enemy.
I gave it five seconds. Then I tapped the siren, and everyone froze.
Droids rolled down. At each place where a man was, they placed a targeting sensor.
All one hundred of them now took positions up on that ridgeline. “All right, one magazine, lock and load!“ I ordered. Each man picked up a Corellian designed blaster. I signaled the droids, and suddenly we could see the men, not just a fifty, but a hundred advancing.
A hundred men poured fire into the battlefield. Down below, the targeting sensors modified the scene.
But what the men shooting saw was different depending on what the man had done. If he dived for cover, and it was something that would soak up blaster fire the target was just something the size of their head. If it was down, but not behind some cover, it was head and shoulders. If it was one of the frozen ones (And the droids had recorded who had frozen if only for a second) it was a man sized target. The charging idiots got targets half again normal size.
Once the last round had gone downrange, the holograms froze. Every hit had been indexed by a red splotch. I stood up, and motioned for them to follow me. I pointed at a figure crouched behind a rock face. “Cover is important in battle. Notice that this man is not injured, even with almost a thousand rounds fired.” I walked to another. This one had ducked behind a bush. The first bolt had blown the bush into splinters. Half a dozen more showed as red marks on the chest and head. “If it doesn’t stop enemy fire, it isn’t cover.”
I walked over to a figure that was normal sized. A rash of hits had ripped off both legs, an arm and the head. “If you want to be a target, fine, you’ll get your chance. But targets stay on the battlefield for graves registration to pick up and cart home. Your families get a nice letter that doesn’t end with ‘you were too damn stupid to duck.”
I had saved one of the berserkers for last. The system had automatically stopped them after the first hit, and this guy had gotten maybe three paces before he died. But a bigger target means more fire gets aimed at you. I looked at the target for a long time then turned to the Aqualish. They were acting like a bunch of naughty children. I almost expected toes digging in the dirt. “If you want to be a hero, be one. But do it in someone else’s unit'.
But you have left your army no other alternative.
Oddly enough, in a short ranged 'hasty' ambush, such as the US faced in Vietnam, the standard tactic is to rush the ambushers because each man even with an automatic weapon will get off only 3 to five shots before you're among them and can retaliate.
On the Defense you have your military commander, then the main character saying pretty much 'we're boned' where others can hear it. If the troops know the commander believes the battle is lost, they lose their morale. Remember my Alamo reference? If even one of those three men had shown that they felt they would lose, the garrison would have surrendered rather than fight.
Another quote from Napoleon states: 'An army's effectiveness depends on its size, training, experience, and morale, and morale is worth more than any of the other factors combined'. So five million troops with primitive weapons is not going to keep charging just because you order it.
At the Battle or Rourke's Drift http://en.wikipedia.org/wiki/Rorke%27s_Drift
following the Battle of Isandlwana the previous day. 4,000 Zulus attacked the 150 odd troops, 39 of whom were in hospital so you only had about thirty on each of the four defensive facings. Lieutenant Bromhead who actually commanded the force had intended to make it an open field engagement. But an engineering officer, Lieutenant Chard assumed command because of only two month's seniority, and instead ordered the men to build palisades of grain sacks.
If you have seen the movie Zulu. You have an idea of what happened. The garrison survived, though the battle actually ended at around 4 AM.
Two things; half of the men attacking Rourke's drift were unmarried men. A number of the troops who survived reported seeing warriors stabbing their spears into dead bodies. The reason this is relevant is that to be considered worthy of marriage, a Zulu man had to return from battle with blood on his spear.
The other thing, more Victoria Crosses were awarded for this battle than had been awarded in any previous battle. One of them, to Henry Hook caused a friend of mine from the Renaissance Faire to chuckle. You see, Hook as mentioned in the movie, had been given a field court punishment of 28 days field punishment, meaning he isn't paid for those 28 days. The battle occurred during his punishment. Legally, Under British Military Law, he could have sat back. Instead he did fight, and that (According to my friend) is why he was given the award.
RUNNING AN INVASION:
I have enumerated all of the problems your army would face above, but you have ignored everything that would have happened before deploying your force on the ground. It's like seeing the men planning D Day way back in 1942 and jumping right to the army marching off the beach.
I noticed in the original or the article that preceded this one that you had planned on using a droid army similar to the one used in the Clone Wars. They would be willing to attack as you have shown, after all as much as C3P0 acted human, most droids would notcare that they were going to be destroyed. So my last question is;
Were your troops either religious fanatics or mind controlled? If so, read my Family of Choice where the Mandalorians face such an army about ten years before the war of Exar Kun.
As to such an attack, read Gust Front by John Ringo, especially the battle of Fredricksburg, where 2.5 million aliens attack that city. The defensive force is nowhere near as heavy as you postulate, yet they are able to survive the day and night before dawn. In fact the battle of Richmond where 60,000 troops face the same aliens in equal numbers ends in a total rout of the attackers. In Ringo's book, the Posleen (alien attackers) have superior numbers and weapons, but only 1 in 400 is the equivalent of the average human being, with only 4 percent of their race is even remotely equal to a human imbecile. The remainder are well below what a human would call sentient, think of animals guided by nothing but instinct.