Special thanks to Pyriel for checking the code. He was able to confirm most of of my work, and get me the last missing pieces to complete my research!
So here it is! After more than a year of banging my head against the wall, I present the damage formulae for the S1 military battles!!!!
Magic is [ Attack * 200 ]
No mystery there.
As for the rest, the formula is:
[ ( Adj.Attack * modifier ) + ( Rand / 537 ) - 30 ]
Rand is a random number between -32768 and +32767, which comes out to (-61 to +61).
So this means that there will be a (-91 to +31 added to the expected damage).
To calculate Adj.Attack, it's:
[ Unit Attack Power + ( # of troops / 3,000 ) ]
Which is pretty much what I figured, except it adds it as a bonus to attack, not a straight bonus to damage. Truncate the number instead of rounding.
Strategists increase the basic unit attack power before the number of troops is factored in.
Modifiers are:
NORMAL BATTLES
Charge gets x130 vs. Bow
Bow gets x120 vs. Magic
Charge gets x100 vs. Charge
Bow gets x90 vs. Bow
Bow gets x80 vs. Charge
TEO BATTLES
Armored Cavalry and Teo's Charge get x130 vs. everything (Teo Battle 1)
Armored Cavalry and Teo's Charge get x130 vs. Bow/Magic (Teo Battle 2)
Armored Cavalry and Teo's Charge get x40 vs. Charge (Teo Battle 2)
Charge/Bow/Magic do 0 damage vs. Armored Cavalry & Teo's Charge (Teo Battle 1)
Charge gets x130 vs. Armored Cavalry & Teo's Charge (Teo Battle 2)
Bow/Magic do 0 damage vs. Armored Cavalry & Teo's Charge (Teo Battle 2)
MILICH BATTLE 1
Poisonous Pollen kills a flat 80% of your soldiers
[u/OTHERS[/u]
Dragon Knights kill 25% of the enemy's current troops. They do more overall damage the earlier you use them because the enemy has more troops.
But, there is an exception during normal battles.
When the commands are Charge vs. Bow, the enemy uses the player's [Adj.Attack] instead of their own, regardless of who is using which attack type. So using a weaker unit will result in you taking fewer casualties than using a strong one in this case. I believe Teo does the same for both unit types, but I need to confirm that.
As an example, in Pannu Yakuta Round 1:
Kwanda has 9000 soldiers, the Liberation Army has 7015.
Kwanda's Attack ( ATK 25) vs. Charge (Atk 13)
( 25 + [ 9000 / 3000 ] ) * 100) = 2800
Kwanda did 2830 damage, so the random variable was +60 (60-30=30)
( 13 + [ 7015 / 3000 ] ) * 100 = 1500
Liberation Army did 1498 damage, so the random variable was +19 (19-30=-11)
After reloading state and using Bow (Atk 13) instead of Charge:
( 13 + [ 7015 / 3000 ] ) * 130 = 1950
Kwanda did 1980 damage, so the random variable was still 30. He used the player's Adj.Attack. He would have done 3670 if he had used his own.
( 13 + [ 7015 / 3000 ] ) * 80 = 1200
Liberation Army did 1189 damage, so the random variable was still -11.
MYSTERY SOLVED!!!!!!!