# taw's blog

## Monday, November 16, 2009

### Why everyone hates you in Medieval 2 Total War

Short answer - because of a really stupid bug in data files. If you want it fixed, download corrected file and put it in your C:\Program Files\SEGA\Medieval II Total War\data\ directory or similar. For the long version, read on.

### Reputation and standing

First, technicalities. The game keeps track of two important numbers - your reputation (also called global standing), which is global, and standing with a particular faction. Both are numbers between -1 (the worst possible) and +1 (the best possible).

Good behaviour increases your reputation, and your standing; while bad behaviour decreases it - as expected. There are two kinds of deeds - some actions are unconditionally good or bad - they simply add or subtract from your reputation/standing. If you do 5 good deeds and 4 bad deeds of this kind, it's pretty much the same as just doing 1 good deed.

The other kind use what the game calls "normalization". This "normalization" operation has two parameters - target value, and "divisor". It takes your current standing or reputation, and moves it by 1/divisor towards the target.

For example if your current standing is 0.6, then "normalizing towards +1 with divisor 10" will result in standing of 0.6 + (+1 - 0.6)/10, that is 0.64. If your initial standing was -0.8 instead, the result would be -0.8 + (+1 + 0.8)/10, or -0.62. In other words - if your reputation/standing is bad, good deeds improve it a lot, while bad deeds damage it little. And if your reputation/standing is good, good deeds improve it little, but bad deeds damage it a lot. In our example, the good deed had value of +0.04 for the well-reputed faction, but +0.18 for the ill-reputed one.

Normalization to some value with divisor 1 is equivalent to completely changing your reputation/standing - by our equation initial + (target - initial) / 1 = target. Doing both good and bad things of this kind will move your reputation towards neutral values around 0.0, even if one kind of deeds is more frequent than the other. It's all quite sensible in practice.

Obviously we want our relations with different factions to be high - factions that hate us will be more likely to start wars against us, disrespect treaties and so on. Even with enemies we would prefer higher standing, in case we want to sign peace treaty someday.

### What changes reputation

Most reputation changes are absolute.

First, your reputation normalizes to 0 with divisor of 200 anyway, which is extremely slow - it takes 140 turns to halve your good or bad reputation. Having an ally normalizes your reputation to +1 with divisor of 400, and being at war (except with rebels obviously) normalizes your reputation to -1 with divisor of 800. These are extremely small divisors, but if you have multiple allies, or multiple enemies they add up.

On top of that, some generic good and bad deeds:
• "Taking back" settlement, which you gave by diplomacy (but then do you ever give settlements by diplomacy?): -1.0
• Attacking an ally: -0.5
• Canceling alliance (also when forced by one of your allies attacking another - tough luck): -0.1
• Bribing settlement (it's virtually impossible in Medieval 2 Total War anyway, unlike in Rome Total War where you would be doing it all the time): -0.15
• Breaking treaty terms (I'm not sure what counts here): -0.15
• Military assistance to your ally in battle: +0.1
Treatment of prisoners is probably the most important source of reputation. If you put your prisoners up for ransom, it doesn't affect your reputation either way - this is the standard expected behaviour in Medieval warfare. What changes it is either releasing or executing prisoners.
• Releasing prisoners: +0.01; +0.025 for groups of over 80 soldiers; +0.025 if any family member was released.
• Executing prisoners: -0.01; -0.025 for groups of over 80 soldiers; -0.025 if any family member was executed.
I'll get back to this later in more detail.

And here we arrive at the bug. Treatment of civilians is supposed to affect your reputation:
• Occupying a settlement peacefully: +0.05
• Sacking a settlement: -0.02
• Exterminating population: -0.05
But due to a bug the first never happens. Here's the data file:
;------------------------------------------
Trigger 0103_occupy_settlement_increase_global
WhenToTest OccupySettlement

FactionStanding global 0.05
FactionStanding target_faction normalise 1.0 20
FactionStanding target_allies normalise 1.0 40
; FactionStanding target_enemies normalise -1.0 40

;------------------------------------------
;Trigger 0102_city_razed_decrease_global
; WhenToTest CitySacked

FactionStanding global -0.05
FactionStanding target_faction normalise -1.0 10
FactionStanding target_allies normalise -1.0 20
; FactionStanding target_enemies normalise 1.0 20
Semicolon means code is commented out and inactive. The first event describes what happens when settlement is peacefully occupied. The second is old sacking code, probably from Rome Total War times. It's supposed to be commented out, but only trigger was commented out, the effects were not. So the results are equivalent to:
;------------------------------------------
Trigger 0103_occupy_settlement_increase_global
WhenToTest OccupySettlement

FactionStanding target_faction normalise 1.0 20
FactionStanding target_faction normalise -1.0 10
FactionStanding target_allies normalise 1.0 40
FactionStanding target_allies normalise -1.0 20
So not only you don't get the promised reputation bonus, your standing with the target and their allies gets lower, instead of higher - they're actually happier when you sack their settlements than when you occupy them peacefully, what is nonsense! By the way, all websites about Medieval 2 Total War I've seen seem unaware of the bug, even though it's trivial to test.

Just see how different the game is with and without bug. If you take 6 neutral settlements, your reputation should rise to 0.3 (Reliable); with the bug it will stay at 0.0 (Mixed). This has huge effect on how others will treat you!

### Standing

Now that we know about your reputation, how about standing? There's extremely long list of rules related to the Pope, crusades and such, which I'll cover later. For normal factions it's much simpler. I'll spare you the numbers, but basically:
• Factions with high reputation get liked more, factions with low reputation get liked less. Thresholds are -0.4, -0.1, +0.1, +0.4.
• Depending on difficulty, your standing tends to drift towards +1.0 (very easy), 0.0 (medium), -0.5 (hard), and -1.0 fast (very hard).
• Factions which are strong get liked less, factions which are weak get liked more.
• There's small advantage to having the same religion.
• Your allies grow to like you more, and your enemies to like you less. Allies/enemies of your allies/enemies change their standing accordingly, by smaller factors. If this works correctly, you can see two big coalitions developing, and it often happens.
There are miscellaneous actions that increase or decrease your standing. In addition to the obvious acts of war, bribing, sabotage, and spying decreases your standing - spying much more than I thought - to -1.0 with divisor 20, and with divisor 80 for all allies. I'm not sure if it counts only when spy is caught, but it's far higher than I expected. Only 13 acts of spying will move perfect standing all the way to neutral.

What doesn't affect your standing is merchants buying each other out, your princesses marrying (and stealing) their generals, and your priests preaching on their territory. Marrying your princess to their faction heir is worth a lot - +0.2 instantly, and normalization to +1 with divisor 20 every turn.

Adding it all together - the way it's supposed to work is that increased standing due to high reputation should counteract decreased standing due to your size and difficulty level (at least on hard, maybe not so much on very hard). But because you don't get reputation points you deserve for peacefully occupying settlements, there's no balance, and everyone gets to hate you.

### The Pope

It's only vaguely related to the bug this post is about, but as I started talking about Medieval 2 Total War standing system, I can as well describe how it works with the pope.

First you get points for building religious building - from 0.02 for small churches and chapels, to 0.2 for huge cathedrals, and additional 0.2 for your first huge cathedral, and additional 0.2 if it's the first huge cathedral in the world - so you can get +0.6 with the pope for just one building, after first getting +0.52 for first cathedral in the world.

On the other hand destroying religious building for money makes the pope hate you, about 5x as much as building them. But as you never really destroy buildings anyway, you probably don't need to bother yourself with it too much.

Crusade get you huge bonuses with the Pope - but only arriving at target region, and taking the target settlement, not just joining. You get bonuses for every general, and every unit, but a lot more if you send your heir (+0.2) or your leader (+0.6) to the crusade.

Something I didn't know about before reading the code is that attacking Orthodox factions while on crusade (usually taking Constantinople on the way to Jerusalem or Antioch) gets pretty high penalties with the Pope. You'll get your papal standing back if you actually conquer your target, but if the crusade is just an excuse for sacking the Byzantine Empire the Pope will not be happy. As you probably already know, attacking non-excommunicated Catholic factions while on Crusade, or Islamic factions while on Jihad is prohibited by the rules.

Recruiting priests and doing papal missions get you points. Getting excommunicated loses you -1.0 points, obviously. Getting your cardinals promoted get you points (0.1 per cardinal), and there are even more points in elections - Pope from your country means +0.8, from allied country means +0.4, enemy country's Pope means -0.6, and voting for the winner pope is +0.2. Surprisingly I don't see any negative points for voting for the wrong candidate, even though in-game text insist on wrong vote being a major transgression.

You also lose points with the Pope for being at war with other Catholics. And look after heretics in your lands - if the Pope has to appoint an Inquisitor, it costs you immediate -0.2.

Now it's going to more or less even out - you will build churches and recruit priests anyway, especially if you're close to Islamic or Orthodox regions - what will score you major Pope points. And you'll lose points for inevitable wars with other Catholics. You're supposed to get extra points for good reputation, but as I said, you won't due to the bug.

### What to do with prisoners

There's one more thing I wanted to write about - treatment of prisoners. You naturally know that you shouldn't normally sack or massacre settlements, as these will be your subjects, but why do anything except execution with the prisoners? Let's do some game theory:
• Value of reputation gained or lost: A (by marginal view it's supposed to be the same either way, it's not exactly true, but let's keep it this way for simplicity)
• Value of money gained from ransom: B
• Cost of enemy getting units back: C
So payoffs are:
• Released: A-C
• Ransom accepted: B-C
• Ransom rejected: 0
• Executed: -A
It helps to know if the enemy is likely to accept the ransom or not. Usually the answer is clear - due to war they don't have any money, so they cannot pay you. In this case if A>C, you release prisoners, otherwise you ask for ransom and don't get it. A>C is the usual situation, you've just defeated their armies, so they probably weren't that good anyway. The biggest exception I can think of is when you're on your way to take a weakly defended settlement, and these armies would join the defenders and make your work much more difficult when released. Or when it's really late in game, you're at war with everyone, and you don't care about reputation anyway.

How about when you think the ransom will be accepted? First, decision between release and ransom. If A-C>B-C, release straight away. Unless you captured their leader (10000) or heir (5000), reputation will be almost always more valuable than money - mostly because for reputation purposes they're treated just like any other general, but for ransom purposes they're a lot more valuable. Except your enemies are quite unlikely to have that much money, so it's not a common occurrence.

How about executing them? It only makes sense when C>2A, and C>A+B. Reputation cost of execution is twice as high, as now you have to actually execute the prisoners, instead of just request ransom. Your loss due to release of troops is very rarely that high. Even tiny group of soldiers released or executed will make a difference of 0.02 reputation points, about as much as you need to counteract being at war with someone for 16 turns. If you act chivalrously wars improve your reputation instead of damaging them. Paradoxically the worst kind of war for your reputation is a prolonged war in which nothing happens.

This is all a lot less true once the bug is fixed. Due to the bug releasing prisoners is the only way to significantly improve your reputation, and you need that just to stay positive, as you'll lose it due to broken alliances, executions of prisoners, and sackings of settlements that will inevitably happen sometime during the game. Having allies and assisting them militarily just won't be enough - once big major start, getting allies will get really tough, especially if your reputation isn't very high (chicken and egg...), and assisting stupid bots requires way too much of effort.

But without the bug, you should have decent reputation from just straightforward conquest, unless you kill and sack on your way - and value of A gets a lot lower.

### To fix or not to fix

With minor bugs the question is clear - definitely fix them. But this bug is so big, and changes the game so much... Not only AI will like you more, AI will like each other more too. And acting chivalrous will be much more important - with buggy M2TW you really had to go out of your way to get decent reputation, but with the fix if you behave you'll reap diplomatic rewards.

Most likely the fix will make the game significantly easier - as long as you act chivalrous it will delay your wars and make your enemies much more likely to agree to cease fire. On the other hand it will make AI factions hate each other less too - so who knows, maybe they'll unite against you? At some point you'll be big enough to overwhelm your reputation-based bonus, so maybe it doesn't matter that much...

I'll try my next game with the fix, and tell you how it went. It's a really long post for a bug that's basically 3 missing semicolons.

Spunky said...

I can't find that file anywhere in my M2TW directory. O_o

taw said...

Spunky: M2TW keeps its files in packs like good old Quake (except it uses weird format instead of zip with different extension like Quake). If you want to look inside you need to unpack them first. You don't need the unpacker if you just want to override some files, or use some mod etc. - just saving this file in data\ directory should work.

Here are the instructions. Unpacker is included with M2TW since version 1.1.

Spunky said...

Thanks man, I'll try just dropping it in there. Can you give me the exact path? I'm just going to try the base data directory and see what happens for now.

taw said...

Base of data directory should work.

neon1300 said...
This comment has been removed by the author.
neon1300 said...

Hi taw,

Thank you for this precise article! It explains the question that has bothered me for a long time - "why it is so hard to get good reputation".

I got one more question about the codes in descr_faction_standing.txt. Since you completely commented out the code that is triggered when players sack a settlement, do we still get the -0.02 penalty when sacking a settlement? If yes, then which part of the codes give us the -0.02 penalty?

Thank you,
neon1300

taw said...

neon1300: You still get penalized for sacking, relevant trigger is this:

Trigger 0101_sack_settlement_decrease_global
WhenToTest SackSettlement

FactionStanding global -0.02
FactionStanding target_faction normalise -1.0 20
FactionStanding target_allies normalise -1.0 40

One I commented out was RTW leftover. (RTW had different logic, you enslaved sacked population, not got their money), M2TW sacking code is elsewhere and correct.

neon1300 said...

Hi taw, thanks for your reply :D. I was checking descr_faction_standing.txt yesterday, tried to figure out more about the factors that are related to global reputation. And I got some more questions (hope I am not bothering you too much >.<)....

1.
Trigger 0056_T_Nullified_Alliance
and
Trigger 0078c_DT_Break_Alliance_Neutral
What do these 2 triggers do?

2.
I always got an impression that if I attack other countries' troops frequently, I get bad global reputations gradually (even I always release the prisons). However, I could not find the relevant triggers in the file. So it was merely my illusion?

Thank you,
neon1300

taw said...

neon1300: I'm not sure what's the difference between nullifying an alliance and neutrally-breaking it.

Attacking enemy armies (0068_T_Battle_Engagement etc.) does not affect your global reputation, as long as you don't execute prisoners.

neon1300 said...

Thanks again, taw. :P

neon1300 said...

Hi Taw,
Sorry for bothering you again. I know its 0 when your reputation is neutral, I am wondering what is the max pos/neg reputation point you can reach in game? Is it 1 and -1? If it is true, then the punishment point from Trigger 0051_T_Stole_Back_Settlement is incredibly too huge?

Thanks,
Neon1300

taw said...

neon1300: Yes, max is -1 and +1. Stealing back settlement is supposedly for settlements you gave via diplomacy then stole back militarily, not for those that change ownership by wars and back.

neon1300 said...

/bow for taw

laurence said...

Surely a 10 to -10 would be better? its just seeing this it seems even the slightest mistake would turn your loving ally to a hateful enemy.

taw said...

laurence: It doesn't matter what's the scale, only how strong effect actions have. If you want actions to have less effect, tweak numbers in that file, it's easy.

The best you can hope for is making M2TW diplomacy only slightly less broken.

laurence said...

thanks mate, nice thinking. think i might increase and decrease some numbers now

osete13 said...

Hi taw can i ask you a question?
does this affect old save games?

taw said...

osete13: Old save games will work perfectly, but diplomatic effects of past actions are not recomputed - if they started hating you, they'll keep hating you after the patch. Only new actions will have diplomatic bonuses and penalties calculated correctly.

For best experience I recommend starting a new campaign.

osete13 said...

so if my faction were to be nice in now, then this changes would take effect. sorry for being noobish and

taw said...

osete13: The problem with m2tw is that diplomacy is self-reinforcing.

If you have bad reputation, others will start wars against you, and your reputation will go even lower.

If you have good reputation, you will have reliable allies, fewer wars, etc. so your reputation can stay high.

Best to start a new campaign.

Anonymous said...

Wait...so we make a txt file in our folder with the content from http://taw.chaosforge.org/m2tw_concentrated_vanilla/descr_faction_standing.txt

and we name it descr_faction_standing?

taw said...

If you run unpacker this file should already be there. Otherwise, I think putting it into data/ directory will override descr_faction_standing.txt in pack.

Anonymous said...

Ok, I just put it in the directory without unpacking anything. Thanks!

Anonymous said...

Even after unpacking, I can't seem to find the file in question at all.

Anonymous said...

Anonymous said...

Hey, what's the path to the descr_faction_standing.txt file (the original)?

Ty

Anonymous said...

Hey, what's the path to the descr_faction_standing.txt file (the original)?

Ty

taw said...

Anonymous: You need to run unpacker first (it's in Medieval II Total War\tools\unpacker).

After you unpacke you must detele Medieval II Total War\data\descr_geography_new.txt and Medieval II Total War\data\descr_geography_new.db files or the game will not run.

Full path is Medieval II Total War\data\descr_faction_standing.txt after unpacking.

Medieval II Total War directory itself is most likely in something like C:\Program Files (x86)\Steam\steamapps\common\Medieval II Total War if you have Steam version.

Anonymous said...

so do i just copy and paste that link a tthe top ?

taw said...

Anonymous: Follow instructions in my comment above. You need to use unpacker first, then replace the file in data/.

milo said...

How do you download the file? When I click on the link I go to a internet page.

taw said...

milo: File > Save as (descr_faction_standing.txt), and there you go.

Your browser can display text files, so it displays them instead of showing Save as dialog right away.