Author Topic: Weaver's School of Combat III: All About Speed (Pursuit Phase)  (Read 782 times)


  • Full Member
  • ***
  • Posts: 249
  • Karma: +53/-42
    • View Profile
The first thing that comes to my mind when combat demysterified is concerned is the good old question 'How do I kill a Noble?'. This is the mythical unit in combat that survives dozens and dozens, maybe even a hundred, battles, and they never seem to die or get captured. In fact, I had a situation once when I attacked a heavily fortified town, and all my soldiers died, but my Noble was alive and kicking- and many later in the Imperium would wish that he had not survived that battle. But this kind of scenario conditions us to believe that Nobles are special, and have their own set of stats, or special rules-- and that is wrong.

A Noble is a unit like every other soldier. He is the penultimate unit, in fact. Yes, that is right, not ultimate, penultimate. Meaning second best. (You would however need a broadsword / plate / war horse, guy with 1000 experience but because this is unlikely, from now on, we will call Nobles 'the most powerful unit' and consider it 'ultimate'. I mean really, do you have a guy with 1000 experience around?).

It is all about speed.

When it comes right down to it, the stat 'speed' does NOT exist. But it is implied in the interactions that happen during the hunt phase. The hunt phase is basically the only phase where your chances of scoring a desirable result against the most powerful unit are not abysmal. By breaking down what it takes to kill a Noble, I will explain to you the concept of attack, defense, and equipment. Because, remember, Nobles are not special units with imaginary defense and attack ratings. No, they have equipment, just like any other soldier. The only difference is their experience. The rules that apply to Nobles apply to soldiers, and vice versa. Why Nobles for this lesson though? Because of the disparity of power between mortals and first ones (due to experience) and that Nobles in combat forces us to understand all the nuts and bolts of the combat system. Including experience.

Every piece of equipment in the game has a melee rating, a ranged rating, and a defense rating. Granted, two of these will usually be 0, save in the case of horses- and the only equipment with special rules is actually the horse. Technically, it is the bows as well, but I will explain later. The explanation will be in the Hunt Phase section of this class, where the rules are noticeable.

For a list of equipment use this link: This link will stay updated as the game updates. You are interested in the numbers after the (stat) '=>'.

Now, a Noble has a sword, plate mail and a war horse, and they have 1000 experience. Now, the way experience plays into this is like so:

private function ExperienceBonus($power) {
$bonus = sqrt($this->getExperience()*5);
return min($power/2, $bonus);

The important variable here is the parameter $power. When the code runs to set up the attack and defense values, it passes the total defense or attack, as the $power to the experiencebonus function. IE, if you have a platemail, it will pass 80 through. If you have a platemail and shield, it will pass 100.

Next it multiplies the experience of the unit by 5, and takes the square root, in this case, of 5000. It's only 70. Our noble has a total defense rating of plate + warhorse = 110. The last line of code determines whether we use the 70, or half of the power, whichever is LOWER. 110 / 2 = 55 -> min(55, 70) = 55. Thus, 110 + 55 = 165. Our Noble has a defense rating of 165.

What about his attack? We said he has a sword, and a war horse, thus: 45 + 25 = 70 -> min(70/2, 70) = 35 -> total attack: 105.

Now here is the important thing to note. The weapon with the largest attack rating is the longbow, at 80, and that still only applies to half of the Noble's total defense value. The melee weapons don't get even close. We are starting to understand why killing Nobles is a problem, aren't we? Our best contenders for this job are a Longbow, and a combination of war horse and broadsword (75). Currently, at the time of writing this, longbows and javelins add their bonuses together, but this will be fixed very soon, so I would suggest NOT building useless units. But the first shot total ranged attack power of longbow and javelin is 145.

But surely, we can break him, if Nobles are soldiers, they will flee when outnumbered, right? ... no. In the last class we looked through the modifiers, visual sizes, how equipment works into things. Nobles have another special feature. Nobles have 75 starting base morale. Their visual size is 5.

1 Noble against 1 LInf, will appear as 5 times larger or 'scarier' as I like to think of it. We already know the math at 4 to 1. Blue side gets double of their morale, and red side gets half of their morale. So let's assume it is double in this case. The morale of a single Noble in this scenario is: ( 75 + equipment ( 105 + 165) ) * 2; 345 * 2 = 690. Breaking a Noble is not gonna happen. Even the base value, without the modifier, is 345. This mean you would need an army of 600, to have a decent chance to break a Noble enough to make him flee the battle in a timely fashion, without relying on the Melee Phase modifiers, if you can inflict 80% casualties on the enemy, while sustaining only 50% yourself- resulting in a morale drop of 600 * 0.8 - 600 * 0.5 = 480 - 300 = 180. 345 - 180 = 165. The next round could break him, because his morale will be almost halved in the melee phase, and additional casualties could bring this number below 50, making him a rout check failable target. IE 165 * 0.5 = 83 (inflicting a net total of 33+ casualties, can route the Noble IF he doesn't kill anyone).

But this is good. This means that our target of this exercise is not going to run away until we have had a decent chance of killing him. So how does his defense and melee power work? Even though his defense is really high, he is not immortal. The mechanics of M&F combat work like this:

if (rand(0,$attack) > rand(0,$defense)) {
// defense penetrated
$result = $this->resolveDamage($soldier, $target, $attack, 'melee');

It rolls a random number between 0 and attack (melee in this case) and if it is larger than a random number between 0 and defense, the armor is penetrated. To get a killing shot, instead of a wounding one, you need to do this roll once more. If you win, target is dead, if you fail, target is wounded and out of the fight.

So yes, technically, even a spear with 20 attack can demolish a Noble if they are EXTREMELY unlucky. In the School of War we will discuss several strategies of winning a war, and one of them will be Noble killing. However, when you are faced with the facts as they are presented here, the conclusion is obvious. Nobles are extremely difficult to kill.  But as is the case with blackjack, and as is the case with dice, chance is not all about luck. The biggest hazard to a Noble's health, in a large army, is the Pursuit Phase, by thinning out the enemy ranks, and forcing the few surviving members (including a Noble) to fend off pursuers they are in the direct line of fire. If you can create the scenario where a Noble has to stare down 3 attackers with at least 80 attack power, the chances of the Noble becoming a casualty is in the neighborhood of 70%. Or is it?

if ($soldier->RangedPower() > $soldier->MeleePower()) {
$hitchance = 10+round($soldier->RangedPower()/2);
$power = $soldier->RangedPower()*0.75;
} else {
// chance of catching up with a fleeing enemy
if ($soldier->getEquipment() && in_array($soldier->getEquipment()->getName(), array('horse', 'war horse'))) {
$hitchance = 50;
} else {
$hitchance = 30;
$hitchance = max(5, $hitchance - $soldier->DefensePower()/5); // heavy armour cannot hunt so well
$power = $soldier->MeleePower()*0.75;
if ($target->getEquipment() && in_array($target->getEquipment()->getName(), array('horse', 'war horse'))) {
$hitmod = 0.5;
} else {
$hitmod = 1.0;

If a Noble's defense rating made your eyes tear up as the prospect of actually killing them slowly evaporated, this will make you cry your heart out.

Let's go step by step:

If a soldier has ranged power higher than melee power, he will use his ranged power modifier, and the ranged-related branch of the code. Their hit chance, for let's assume a longbow would be: 10 + 80/2 = 50. Their ranged power is also only 75%, so 60 in this case.

Now, if they do not have a ranged weapon, they have to use a different method. If they have a horse, their hit chance is 50, if they do not, their hit chance is 30. That's pretty brutal. But it does not end there. In the case of infantry or cavalry, armor impedes them at a rate of 1 per 5 defense. So, if our infantry had a shield and plate, for 100 defense, their hit chance would be 30 - 100/5 = 10.

On top of that, if your target is mounted, like a Noble, they apply a hitmod penalty that we will see in a bit.

Ever wonder why your heavy infantry can't seem to catch anyone to kill them in the Pursuit Phase? Now you know. But no, we are not even close to done yet.

$evade = min(75, round($target->getExperience()/10 + 5*sqrt($target->getExperience())) ); // 5 = 12% / 20 = 24% / 50 = 40% / 100 = 60%
if (rand(0,100) < $hitchance * $hitmod && rand(0,100) > $evade)

And that is the real cherry on top. Your target also has an evade chance. Our Noble has an evade chance of min(75, 258)... so 75. And then the real meat of the 'do I catch up or not' happens. If your hitchance * hitmod is greater than a random roll between 0 and 100, AND another random roll from 0 to 100 is greater than the enemy's evade chance, you get to make an attack.

But, as long as we have 100 soldiers, let's assume archers, with a hit chance of 50, their chance of hitting a noble is around 15%. Surely, 15 of them will hit, and with a power rating of 60, their chance of breaking the armor is 33%, and scoring a kill is 16%.... 15 times. Those are good odds.

Well, yes and no. The odds are good, but it is impossible to get 15 shots on the same target because of this piece of code:

« Last Edit: May 31, 2016, 05:34:11 PM by Weaver »


  • Full Member
  • ***
  • Posts: 249
  • Karma: +53/-42
    • View Profile
Re: Weaver's School of Combat III: All About Speed (Pursuit Phase)
« Reply #1 on: May 31, 2016, 05:30:45 PM »
We saw the $attack variable in the previous class, and we have not thought about it ever since. The $attack variable is basically a measure of 'crowdedness'. When someone's $attack is high, it basically means he is being simultaneously engaged by a LOT of opponents, and finding room to attack him is becoming exceedingly difficult. When every duel is started, the code will pick out an enemy using a function called 'GetRandomSoldier', and here is the code for this function:

private function getRandomSoldier($group, $retry = 0) {
$max = $group->count();
$index = rand(1, $max);
$target = $group->first();
for ($i=1;$i<$index-2;$i++) {
$target = $group->next();
if ($target && rand(10,25) <= $target->getAttacks()) {
// too crowded around the target, can't attack it
if ($retry<3) {
// retry to find another target
return $this->getRandomSoldier($group, $retry+1);
} else {
$target->setMorale($target->getMorale()-1); // overkill morale effect
return null;
return $target;

We are really only interested in the piece of code that goes rand(10, 25) <= $attacks. This means, that if a random roll of 10 to 25 is lower than the target's $attack variable, the target will be considered too crowded. The average of that roll is 18- which means, on average, you will be able to get 18/4 attacks off on any unit, before they become considered too crowded. But if you have a thousand men, it is quite possible you will be able to get off 25/4 attacks on a unit. In other words, 4 to 6 attacks.

Luckily, this part of code ONLY fires if you catch up with the Noble. If he evades, his attack will not be increased. So you have 4 to 6 chances of scoring a hit, and hopefully a kill. And we realized earlier that the chance, with 60 attack power, is 33%. That is not bad. So, 16% chance of scoring a kill?

... No.

private function resolveDamage(Soldier $soldier, Soldier $target, $power, $phase) {
// this checks for penetration again AND low-damage weapons have lower lethality AND wounded targets die more easily
if (rand(0,$power) > rand(0,max(1,$target->DefensePower() - $target->getWounded(true)))) {
// penetrated again = kill
switch ($phase) {
case 'ranged': $surrender = 60; break;
case 'hunt':   $surrender = 85; break;
case 'melee'
default:         $surrender = 75; break;
// nobles can surrender and be captured instead of dying - if their attacker belongs to a noble
if ($target->isNoble() && !$target->getCharacter()->isNPC() && rand(0,100) < $surrender && $soldier->getCharacter()) {
$this->log(10, "captured\n");

That is how damage works. Notice that in the case of the 'Hunt' phase, the $surrender variable is at 85. When a Noble is 'Killed', they have a chance of becoming captives instead of being killed. Compared to that, the ranged phase surrender threshold is only 60.

Now we came full circle. From believing that the hunt phase is the best place to score a kill on a Noble, to realizing that it is potentially the safest a Noble can be in. But we learned a lot of important details of how combat works, how experience affects the flow of combat, and the relative power of equipment. Nobles, though they share the same rules as other soldiers, are extremely powerful due to their massive experience. As such, we will no longer consider Nobles a real viable target for 1 on 1 combat, and instead focus on the bread and butter of armies. The soldiers themselves.

For comparison, a mounted broadsword unit has a 80% chance of penetrating a mounted plate armor wearer. A spear has only 20% against the same.

It is not just the case in the Pursuit Phase, but also in war, and economy and rulership. It is all about speed. A unit can be decked out in plate, and it will never inflict damage where it needs to be inflicted- if the entire army of your opponent routs, that means they will be ready to fight, without a scratch, the next time you engage them. The same is the case in war, having a large army is all good and nice, but if it moves too slowly, the war will be over before you get them there. The same is the case for economy and rulership. Having a strong philosophy and understanding of war and combat will not only improve your chances in combat, but will overall improve your understand of economy and proper rulership.

Stay tuned for more.
« Last Edit: May 31, 2016, 05:41:36 PM by Weaver »


  • Head Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 6320
  • Karma: +102/-15
    • View Profile
    • Might & Fealty
Re: Weaver's School of Combat III: All About Speed (Pursuit Phase)
« Reply #2 on: June 01, 2016, 01:39:34 AM »
Wonderful, keep it coming.

You put a lot of time and effort into reading and understanding the battle code, and so far I've not found one case where you misunderstood or missed something important.


  • Full Member
  • ***
  • Posts: 249
  • Karma: +53/-42
    • View Profile
Re: Weaver's School of Combat III: All About Speed (Pursuit Phase)
« Reply #3 on: June 01, 2016, 02:08:50 AM »
I hope so! I did have to put together a C++ reimplementation of it and run a genetic deep learning algorithm for a lot of equipment related things, and find possible tweaks and fixes to the balance- but mostly because I wanted to make sure I got everything right regarding mechanics. In case myself and De-Legro decide to change stuff, we can't have potential new additions to the code break the entire thing.