# [WTP] Quick questions

#### Honor

##### Immortal
Does anyone have any suggestions on how to deal with pirates? It seems like they can spawn up to 4 Pirate Frigates by 1600, meanwhile I am lucky if i can afford more than one Corvette. And this Corvette can only do a 30% victory against a pirate ship, so if he fails he's dead...
I usually get a bunch of Galleons and West Indiamen and largely ignore them until later.

#### Evil Beejeebers

##### Warlord
Does anyone have any suggestions on how to deal with pirates? It seems like they can spawn up to 4 Pirate Frigates by 1600, meanwhile I am lucky if i can afford more than one Corvette. And this Corvette can only do a 30% victory against a pirate ship, so if he fails he's dead...

I plan for pirates right from turn one, I try for an early frigate and accept that I will lose it for 10 turns.

#### bogwart

##### Chieftain
How is City happiness atually calculated?
I thought it would decline equally after adding more colonists into colony.
In this test game it even increases after adding the sixth colonist, and drops again after (with a steep fall from 7 to 4 after the 17th).

#### raystuttgart

##### Civ4Col Modder
Supporter
I thought it would decline equally after adding more colonists into colony.
Do not expect my algorithms to be linear.
(They almost never are. I like to challenge players a bit to figure out how it works.)

In this test game it even increases after adding the sixth colonist
This may be because you have hit a threshold that triggered an additional happiness bonus.

-------

Actually my algorithms are usually so complicated and consider so many variables that even I cannot fully predict them.
(Directly after coding the algorithm I usually still can, but half a year later, I would also have to study it again due to all the variables and thresholds included.)

The only thing I can tell you is "trends", like e.g.
• Food --> Good
• Bells --> Good
• Open Borders --> Good
• ...
• ...
-------

All my algorithms are either:
A) Non-Deterministic (Chance-based)
B) Non-Linear (Thresholds or Self-Enhancing or Self-Balancing)
C) A mixture of those

Happiness is just: B)
• There are many variables influencing each other
• Thresholds that trigger different gradients / behaviours
So, some effects are only triggered if you hit a certain threshold.
(Below that threshold there will not be any effect.)

---------

There are in total 14 "sub-algorithms" (each with a formula of its own) that Happiness / Unhappiness uses.
Also they may have side effects with each other. Thus potentially self enhancing or self balancing.
(As I said, do not expect my stuff to be "linear" or that easy to explain / calculate.)
Spoiler :

The Good Effects:
iTotalCityHappiness += getBaseRawYieldProduced(YIELD_HAPPINESS); // this is e.g. Buildings or Professions
iTotalCityHappiness += getHappinessFromCrosses();
iTotalCityHappiness += getHappinessFromBells();
iTotalCityHappiness += getHappinessFromHealth();
iTotalCityHappiness += getHappinessFromCulture();
iTotalCityHappiness += getHappinessFromEducation();
iTotalCityHappiness += getHappinessFromDomesticDemandsFulfilled();
iTotalCityHappiness += getHappinessFromTreaties();

iTotalCityUnHappiness += getBaseRawYieldProduced(YIELD_UNHAPPINESS); // this is e.g. Buildings or Professions
iTotalCityUnHappiness += getUnhappinessFromPopulation();
iTotalCityUnHappiness += getUnhappinessFromSlavery();
iTotalCityUnHappiness += getUnhappinessFromWars();
iTotalCityUnHappiness += getUnhappinessFromMissingDefense();
iTotalCityUnHappiness += getUnhappinessFromTaxRate();

----

But there are also "thresholds" in these "sub-algorithms" as I tried to explain.
(Once you hit them the algorithm / curve may "jump" or change its gradient.)

Here is a simple case where the population component of "Unhappiness" is not calculated if the village is to small.
Spoiler :

Code:
``````// specific computation methods for factors of Unhappiness
int CvCity::getUnhappinessFromPopulation() const
{
int iUnHapPop = 0;
int iPopulation = getPopulation();
int iMinPopForHappiness = GC.getMIN_POP_NEG_HAPPINESS();

// small help for AI
if(!isHuman())
{
iMinPopForHappiness = iMinPopForHappiness*2;
}

iUnHapPop = iPopulation - iMinPopForHappiness;

// to prevent negative Unhappiness in case we have less pop than min value for neg pop
if (iUnHapPop > 0)
{
return iUnHapPop;
}

return 0;
}``````

---

By the way:
There are also rounding issues with integers.

e.g. as Integers
• 2/3 = 0
• 3/3 = 1
So the adding just 1 more colonists may acually make a big difference.
(Because you overcome the rounding cliff and a 0 may become a 1.)

Last edited:

#### bogwart

##### Chieftain
Wow! Thanks for the detailed answer Ray.
Gives a little hint how much work you put in this mod..

#### mangamancer

##### Chieftain
I want to eliminate other European factions quickly by preventing their respawning and not having to wait x turns to declare war,
which file do I need to mod?

#### Ramstormp

##### Warlord
I want to eliminate other European factions quickly by preventing their respawning and not having to wait x turns to declare war,
which file do I need to mod?
..\Assets\Python\CvDiplomacy.py lines 51 and 52 are commented out for some reason. Removing the #s might get you where you want.

[UPDATE]
Also in Assets\XML\globalDefinesAlt.xml there is KI_RESPAWN_OFF_MIN_TURN that you can lower the value on

Last edited:

#### devolution

##### Prince
In the file mentioned above you can also reduce COLONIAL_FORCED_PEACE_TURNS (default is 20 turns) to allow war to be declared immediately after starting a new game. Remember that you will have to start a new game after changing any of these variables!

Thank you.

#### mangamancer

##### Chieftain
This probably got asked a number of time already, but I don't want to dig through 36 pages.
what are the main factors I should be looking out for to not have the REF grow too much in this version?
Liberty bells?
Number of people in my empire? Number of combat units?
Number of resources that can be used to equip military units?
Sum of strength of units in my empire? Combat units only or civilians also counted?
Amount of money I have?

#### raystuttgart

##### Civ4Col Modder
Supporter
@mangamancer

To simplify it:
• Military Strength (incl. Weapons on Wagon Trains).
• Revolutionary Rate (e.g. Liberty Bells).
• Kings Attitude (keep him happy).
• Taxes (i.e. giving the King money)
• Population (because they are Units that could be manned as troops)
• Mapsize (as a factor - because bigger Maps make it harder for the King)
The settings for the algorithm are in GlobalDefinesAlt.xml and can be adjusted to your personal taste.
Just search "NBMOD_REF_" and you should find all settings of the algorithm.

It is a "weighted algorithm" that has different factors / settings for a lot of stuff.
(It is one of the most complex algorithms in the game actually - it was written in TAC already by NetBandit.)

Last edited:

#### bogwart

##### Chieftain
Military Strength (incl. Weapons on Wagon Trains)
So it is not true that you can 'hide' your guns, horses etc. in wagon trains?
I think this was a trick I've read here and there.

#### raystuttgart

##### Civ4Col Modder
Supporter
So it is not true that you can 'hide' your guns, horses etc. in wagon trains?
In Vanilla and some very old mods you can use that trick. (Because they use primitive "Vanilla REF algorithm".)
But it is not possible to hide them for TAC / RaR / WTP. (Because they use more advanced "NetBandit REF algorithm".)

Summary:
No, not true. We closed that exploit more than 10 years ago in TAC already.
You cannot hide Weapons / Horses / Cannons / Blades from the algorithm.
(But you could configure the algorithm by GlobalDefinesAlt.xml to ignore them if you want.)

Last edited:

#### mangamancer

##### Chieftain
Thank you.
So I can have hundreds of cart filled with ore right?

Last edited:

#### raystuttgart

##### Civ4Col Modder
Supporter
So I can have hundreds of cart filled with ore right?
Yeah you could do that if you want to. That would not influence REF at all.
Also the amount of gold itself does not influence REF either.

#### tsheaven

##### Chieftain
Hi together,
I'm new here. Thx alot for this great mod. I recently took the game out of the shelf and played 2 rounds of TAC before I realized there are even newer and bigger mods. So many new things, its amazing.
Anyway there is one old feature that I didnt manage to work again and one new concept that I can't figure out. I'm using the german version, be tolerant with my made-up translations if they are incorrect

1. Traderoutes: Espacially with even higher production and so many more trade goods I really need to work out the automization. In tac I just assigned the route with the symbol on the wagon or ship and chose a good with source and destination and the confirmation at the top.
This works here as well, with one problem. The vehicle doesn't start. It just goes in the waiting mode, in the city screen it has the traderoute symbol, but doesn't start.
If I then manually transfer any good which was in my list from the colony to the vehicle it immediatly fills up the rest and starts as intended. After arriving at the destination it unloads but does not return back and sleeps again.
I tried basically all combinations with the gouvernor in both colonies with the import/export options, also auto-trading, nothing works/ has the exakt same problems.
Maybe there is one thing that prevents the transport - the storage capacity of the destination city has exceeded, but thats basically allways going to happen with my first harbour/tollhouse city.

2. Monastery (or is it cloister?): I can't get this to work. No matter if I put it inside the colony tiles or outside. Working on the tile or sending a missionary, nothing happens or changes. No change in crosses or any converted natives..
Thx in advance and keep up the great work!

#### XSamatan

##### Warlord
2. Monastery (or is it cloister?): I can't get this to work. No matter if I put it inside the colony tiles or outside. Working on the tile or sending a missionary, nothing happens or changes. No change in crosses or any converted natives..
Thx in advance and keep up the great work!

Try to place the monastery inside native territory near to their large cities. The more native unites roaming around the higher the chance of converting.

Regards
XSamatan

#### Mr. ZorG

##### Prince
hi)
2. Monastery (or is it cloister?): I can't get this to work.
they should be built on the "paths" along which the natives often walk (even beyond your cultural boundaries) and place a missionary there. but not every native passing by will become a convert (this does not happen often). if you have a good relationship with the tribe, they will bring gifts more often. and if the relationship is bad, then the raid parties passing by will calm down.

1. Traderoutes: Espacially with even higher production and so many more trade goods I really need to work out the automization...
...This works here as well, with one problem.
I haven't played TAC and vanilla, so I don't know how trade routes were set up there. but somewhere here on the forum, I described how to set up trade routes for the current release.
if you don't find it, I'll try again.

Replies
100
Views
7K
Replies
0
Views
685
Replies
7
Views
1K
Replies
45
Views
2K
Replies
9
Views
793