Tough Barbarians

Pembroke

Tribune
Joined
Jul 1, 2002
Messages
622
I tried to make the barbarians a bit more dangerous and created a small mod that has an SQL file containing:

Code:
UPDATE HandicapInfos SET BarbarianBonus=0;
UPDATE HandicapInfos SET AIBarbarianBonus=0;

i.e. remove the bonus against barbarians from the player and the AI both and for all difficulty levels.

There's an "OnModActivated" action of type "UpdateDatabase" defined in the mod and tied to the above SQL file. The mod contains nothing else.

However, when I enable the mod in the game I still get the "+40% vs. barbarians" info text in the battle calculator which is the Prince level original bonus in the CIV5HandicapInfos.xml so it seems my mod had no effect.

What am I missing? (Have BNW if that matters)
 
I use this code in a private mod of mine and it works fine:-

Code:
UPDATE HandicapInfos Set BarbarianBonus = Round(BarbarianBonus / 2, 0);
UPDATE HandicapInfos Set AIBarbarianBonus = Round(AIBarbarianBonus / 2, 0);
Only difference I can see is you are using SET not Set, not even sure that makes a dif.
 
I tried your version but the result was the same: battle calculator still says "bonus vs. barbarians +40%". Did "clean" and "rebuild" and I enable the mod in the game settings but no change. I don't understand. SQL should not be case-sensitive but tried anyway "Set" and "SET" but no help.

Do you get in your mod the right result from the battle calculator? Just wondering whether it's now that the mod doesn't work or that the battle calculator doesn't notice it. Are you running it in BNW like I am? Though HandicapInfos' BarbarianBonus definition seem to be structurally the same in the new expansion so shouldn't matter.

Very strange. Is there anywhere a log or something that would tell me what changes a mod does to the database? Or where I could see the in-game database content?
 
stopwatch.log will tell you if the game core is trying to load your xml/sql file

If there's no listing in there for your file, the mod is mot active, you're not starting the game from the setup AFTER the mods menu, or you don't have an OnModActivated->UpdateDatabase entry for the file.

If the XML/SQL has errors, they will be in database.log

(This assumes you have logging enabled, if not, read the "How to enable logging" thread in the Tutorials sub-forum)
 
Thanks. Enabled logging in config.ini and started the game with first ToughBarbarians disabled and then enabled. Looked then at the stopwatch.log and database.log files from both runs. Stripping away the numbers in brackets that I assume are just time values diff found only the following differences between the files:

stopwatch.log with ToughBarbarians mod enabled contained one additional row:
Code:
> , 					Update Database - ToughBarbarians.sql,

database.log with ToughBarbarians mod had a different number in SQLite Memory Statistics than without:

Code:
<Malloc:		6216360		13770712
----
>Malloc:		6216432		13770712

I assume the stopwatch.log row means that my Mod was loaded and run, yes? And that the difference in the database.log about the memory usage has no relevance whatsoever as far as the working of mods is concerned? The database.log contained no errors about the SQL statements in my mod or even about the HandicapInfos table. The SQL statements in ToughBarbarians.sql were:

Code:
UPDATE HandicapInfos Set BarbarianBonus = Round(BarbarianBonus / 2, 0);
UPDATE HandicapInfos Set AIBarbarianBonus = Round(AIBarbarianBonus / 2, 0);

Any suggestions as to what other things I could look up?
 
SqliteSpy (http://www.yunqa.de/delphi/doku.php/products/sqlitespy/index) or some other SQLite database browser (there is a FirFox plug-in but as I don't use it, can't link to it) and look in the db directly - C:\Users\{username}\Documents\My Games\Sid Meier's Civilization 5\cache\Civ5DebugDatabase.db
 
Thank you! That SQLLite Manger Firefox plugin is just the tool I needed!

However, now I'm even more baffled...

I enabled my mod and played a game until I found a barbarian so I could look what the combat calculator showed. I did this twice, first running the mod variant from Horem that halves the bonuses, and then my original variant that set the bonuses to zero.

In both cases the combat calculator showed the "Bonus vs. Barbarians +40%" info.

After quitting the game, in both cases I checked the Civ5DebugDatabase.db in the cache dir. The timestamp of the file was updated as expected as the game created the database dump from the game runs. Looking at the HandicapInfos table in the SQLLite manager I found that in the first game run the HANDICAP_PRINCE had BarbarianBonus=20 (i.e. 40/20=20 as you'd expect from the SQL in the Horem's mod variant). In the second run it was BarbarianBonus=0, again as expected from my SQL update statement.

So, what on Earth?? :confused:

It looks like the database gets updated quite correctly by my mod but it appears to have no effect. How can that be? Is the combat calculator now wrong? Or do the barbarian bonuses come from some other setting or are even ignored or hardcoded or something? I'm running the Brave New World extension. Did they perhaps change how the barbarian bonuses work and how they are parametrized in it?
 
Ok, I investigated this further and it seems this is now on one hand a minor cosmetic combat calculator bug and on the other hand some weird calculation that I can't figure out where it comes from...

My mod loads fine and it indeed does have an effect. I ran the game with three different mod configs:
1) Unmodded
2) With the Horem's mod that divides the barb bonuses by 2
3) With my mod that sets the barb bonuses to zero

In each mod config I played the game to capture three different scenarios with my warrior attacking a barbarian brute. The barb was always on open terrain and without any supporting barb units i.e. the barb has no bonuses on his side. The scenarios for my unit were:
a) No promotions, no flanking i.e. supposedly no bonuses.
b) Open terrain promotion +15%, no flanking
c) No promotions, flanking bonus +10%

In every one of the 3*3=9 cases the combat calculator showed in the info screen the standard text for the bonus vs. barbarians and always with the value "+40%". However, the strength values the combat calculator showed did vary between the three different configs! So, I think there's certainly now a bug in the combat calculator that regardless of the actual bonus value the game uses, it still always shows the barbarian bonus as "+40%" even though it's not the true value. So, the bug is only that the info text as a text is wrong and does not react to the barbarian bonus setting although the combat calculator does react to it.

But I still don't quite understand the strength values I got from the combat calculator. The combat calculator showed "8" as the strength of the barbarian brute in all cases which is correct. However, the results for the strength of my warrior were:

Case a: No promotions, no flanking
1a) BarbBonus=+40%: 13.2
2a) BarbBonus=+20%: 11.6
3a) BarbBonus=+0%: 10.0

Case b: Promotion +15%, no flanking
1b) BarbBonus=+40%: 14.4
2b) BarbBonus=+20%: 12.8
3b) BarbBonus=+0%: 11.2

Case c: No promotions, flanking +10%
1c) BarbBonus=+40%: 14.0
2c) BarbBonus=+20%: 12.4
3c) BarbBonus=+0%: 10.8

Now, both the warrior and the brute are strength 8. So, could someone explain me the above numbers from the combat calculator? In the scenario a (no promotions, no flanking) I think that I should have got:

1a) 8+0.4*8 = 11.2
2a) 8+0.2*8 = 9.6
3a) 8+0 = 8

for the three different mod configurations. Similarly, the values from cases b and c should have been:

1b) 8+0.4*8+0.15*8 = 12.4
2b) 8+0.2*8+0.15*8 = 10.8
3b) 8+0*8+0.15*8 = 9.2

1c) 8+0.4*8+0.1*8 = 12.0
2c) 8+0.2*8+0.1*8 = 10.4
3c) 8+0*8+0.1*8 = 8.8

But they weren't. So, what's going on here? Calculating backwards from the results I did got it looks as if there was some invisible +25% bonus modifier in each case. If you assume that such a bonus exists then the results from the combat calculator would indeed all match perfectly i.e.:

1a) 8 + 0.25*8 + 0.4*8 = 13.2
2a) 8 + 0.25*8 + 0.2*8 = 11.6
3a) 8 + 0.25*8 + 0*8 = 10.0

1b) 8 + 0.25*8 + 0.4*8 + 0.15*8 = 14.4
2b) 8 + 0.25*8 + 0.2*8 + 0.15*8 = 12.8
3b) 8 + 0.25*8 + 0*8 + 0.15*8 = 11.2

1c) 8 + 0.25*8 + 0.4*8 + 0.1*8 = 14.0
2c) 8 + 0.25*8 + 0.2*8 + 0.1*8 = 12.4
3c) 8 + 0.25*8 + 0*8 + 0.1*8 = 10.8

As a theory, it explains the results but what is this hidden invisible +25% bonus?? Is it defined somewhere in the game data?
 
You (and the AI) have an automatic 25% bonus vs barbarians if raging barbarians is on. This does not show up in any tooltip and is hardcoded in the DLL (no define or anything for it).


As for the tooltip showing the wrong bonus the only thing I can think of is if they somehow forgot to update GameInfo.HandicapInfos for lua when loading mods. Maybe there's some other answer, but that's the only one I can think of. The value IS being updated in the DLL and the database, but GameInfo.HandicapInfos return the wrong value. I tried changing a couple other values in that file, HappinessDefault and ProductionFreeUnitsPerCity, and GameInfo.HandicapInfos also returns the wrong values for them.
 
You (and the AI) have an automatic 25% bonus vs barbarians if raging barbarians is on.

Thank you! I didn't know that. I always play with raging barbs so didn't even think it might be an issue.

Good to know where the value comes from even if you can't mod it. And being a flat +25% for everyone it's just a shift in strength values so not really a problem.

they forgot to update GameInfo.HandicapInfos for lua when loading mods

Do you mean that any lua scripts, that refer to HandicapInfos parameters always get unmodded basic game values regardless of mods? Isn't that quite a serious bug for the modders as DLL code and lua scripts would disagree about them? I guess not all values are used in scripts but you would have to check and grep all scripts you use, both basic game and any mods you enable, for possible conflicts. If so, they definitely should fix this in a patch...
 
Yes, this will create an issue every time GameInfo.HandicapInfos is used and the value(s) checked has been modded. I haven't tried it but I think this means you can't create custom handicaps, because you won't be able to select them (without modifying the screen for doing so). It will also create issues with modding some other values, but most of the values you can safely mod as it takes them directly from the DLL or it's not used in lua at all.

I'll make a post in the bugs forum. *edit* Made a post there.
 
Back
Top Bottom