Emigration

Thalassicus, i've not included some stuff like modifiers for garrisoned units, occupied and puppeted cities, as i think there have to be more complex mechanics to introduce these. e.g. garrisoned unit lowering emigration has not much scence if player runs freedom policy (or liberty).

That makes perfect sense. Looking through the game's lua code, it seems player:HasPolicy(index) would be helpful. It doesn't take policies by name so it'd be passed through a new utility function. Hmm...

Basically, a table can be added for policy modifiers. If the lua code detects the player has any of the excluded policies, or doesn't have a required policy, it ignores the weight. What if the Military Cast policy is required to let garrisons reduce emigration? It's the policy that reduces unhappiness when units are garrisoned. Something like this...


PHP:
XML

<Emigration_Weight_Policy_Requirements>
  <Row>
    <WeightType>GetGarrisonedUnit</WeightType>
    <PolicyType>POLICY_FREEDOM</PolicyType>
    <ExcludesWeight>true</ExcludesWeight>
  </Row>
</Emigration_Weight_Policy_Requirements>

or

<Emigration_Weight_Policy_Requirements>
  <Row>
    <WeightType>GetGarrisonedUnit</WeightType>
    <PolicyType>POLICY_MILITARY_CASTE</PolicyType>
  </Row>
</Emigration_Weight_Policy_Requirements>

PHP:
cityWeight[cityID] = 1;

-- retrieve function and weight from jump table stored with XML
for weight in GameInfo.Emigration_Weights() do
  if weight.IsCityStatus and city[weight.Type](city) then
    local bUseWeight = true;

    for j in GameInfo.Emigration_Weight_Policy_Requirements() do
      if weight.Type == j.WeightType then
        if (j.ExcludesWeight and hasPolicyName(pPlayer, j.PolicyType)) then
          bUseWeight = false;
        elseif (not j.ExcludesWeight and not hasPolicyName(pPlayer, j.PolicyType)) then
          bUseWeight = false;
        end
      end
    end

    if bUseWeight then
      cityWeight[cityID] = cityWeight[cityID] * weight.Value;
    end
  end
end

-- factor in culture
cityWeight[cityID] = cityWeight[cityID] / (GameInfo.Emigration_Weights["Culture"].Value * math.log(city:GetJONSCultureThreshold() + 2));
totalWeight = totalWeight + cityWeight[cityID];
PHP:
function hasPolicyName(player, policyName)
  for policy in GameInfo.Policies() do
    if policy.Type == policyName then
      return player:HasPolicy(policy.ID);
    end
  end
  return false;
end

I've been thinking about culture modifiers for a while, it seems a logarithmic curve might work well. With the weight/log(threshold+2) done above, cities with no culture would be about 3 times as likely to lose emigrants as cities with a 500 culture-threshold. (Threshold is the culture required for the next border expansion. There doesn't appear to be a function to read a city's total culture, so this is an approximation.) With the original weight/threshold formula I tried these cities were 25 times as likely, which was probably too much.
 

Attachments

ok i'll correct messages.
there are no leading articles in Russian at all :rolleyes: also there are no "is", "am", "are" (e.g. "he is a doctor" = "he doctor"). so its quite hard to determine when to use an article and what an article to use as i'm completely unaccustomed with it.

Hehe, it's alright. I'll download this mod later today, and see if I can find...other, messages.

Did you add entries into the Civilopedia for this, by the way?
 
There doesn't appear to be a function to read a city's total culture, so this is an approximation.
i'm surprised how few culture related functions we have. very majority of cultureBlaBla stuff just does not work.

Did you add entries into the Civilopedia for this, by the way?
Nope, these are only two.
 
Is it possible to target the emigration according to era's?

In Ancient era they should emigrate to the closest city, because the limited travling posibilaties. And have a max limit of like 12 squares, if no city is avaible within that range the population will just be lost. Travling is hard in this era.

In Classical Era they should emigrate to the happest/most cultured empire within 20 squares or so. But there shouls also be a range penalty to the happyness/culture checks. Happyness is the most important of them.

Medieval Era, same as classical but increase the squares even further and lessen the range penalty.

Renaissance Era: In this era emigration changes quite a bit, now it will be very popular to emigrate to other continents, also all met civilazations is potentional targets. Civ's on other continents recive an quite large bonus to the culture/happyness checks. And culture is more important then happyness.

Industrial Era: Again the target of emigration changes, now empire production will be added to the checks and be the most important check, as having a jobb is more important then to be happy.

Modern Era: Emigration will now be balanced out, happyness/culture/production/science will all be concidered, and for each emigrant a random check will be made to determain wich of the traints will be worth the most.
 
Wonderful mod! Thanks for making it.

I recall a feature in civ2 (or maybe it was civ3) where one could gather slaves from AI civs, and walk them back to ones own cities and have them join the population. In city screens they appeared as heads labeled with former nationalities. If you went to war with their former nation, they created unhappines, and could even revolt. Over time, some of them naturalized and functioned like ordinary pop. It's possible I remember some of this wrong, it was many years ago. But still, maybe some of this could be worked into the Emigration mod, perhaps with single-city revolts. It would be neat if you could track where people emigrated from, and gain benefits/problems depending on your diplomacy toward their former home nations.
 
To avoid redundancy, these messages might fit well. The icons state emigrated / immigrated, but for the sentence itself, "left for" and "came to" are more common in English.

Code:
if (fromPlayer:IsHuman()) then
    LuaEvents.CustomNotification(fromCity:GetX(), fromCity:GetY(), 
        "An unhappy [ICON_CITIZEN] citizen from " .. getCityName(fromCity) .. " left for the " .. getPlayerName(toPlayer) .. ", seeking a better life", "Emigration");
elseif (toPlayer:IsHuman()) then
    LuaEvents.CustomNotification(toCity:GetX(), toCity:GetY(), 
        "A [ICON_CITIZEN] citizen from the " .. getPlayerName(fromPlayer) .. " came to " .. getCityName(toCity) .. ", seeking a better life", "Immigration");
end

I also made a small correction... under doEmigratePlayer, a check to see if all emigrants had moved:

Code:
                -- move emigrant
                if isValidPlayer(toPlayer) then
                    printDebug(" * Emigrate to " .. getPlayerName(toPlayer));
                    movePopulation(fromPlayer, fromCity, toPlayer);
                    iNumEmigrants = iNumEmigrants - 1;
                    [B][I]if iNumEmigrants == 0 then break end;[/I][/B]
                end
 
Hm. If you are unhappy, citizens emigrate every turn away from your empire? Why not...every 5 turns or something.

A social policy should be implemented (under autocracy I would assume) that would prevent emigration from taking place. Although, that may not be capable right now.
 
Is it every turn now? I'm waiting to install this mod until later versions. I think every turn is too harsh. Every 3-5 turns is better, I think.
 
Is it every turn now? I'm waiting to install this mod until later versions. I think every turn is too harsh. Every 3-5 turns is better, I think.

I dunno, it seemed to be happening every turn, if I was at like...3 unhappiness.
 
id like this implemented but make it occur only after a certain tech level is reached (id say Renaissance) . In feudal times the free movement of peoples wasnt allowed. They were tied to the land if not owned by the rulers.
 
v2 will be released in a few days!
there was a major delay because of bug fixing
.



Emigration is every turn but not all your unhappy people emigrate but a random number of them.

In v2 you also have to stay in unhappiness for several turn before people will start to leave your country.

id like this implemented but make it occur only after a certain tech level is reached (id say Renaissance) . In feudal times the free movement of peoples wasnt allowed. They were tied to the land if not owned by the rulers.
in feudal Russia some lucky serfs were escaping from their owners to Ukraine. In Europe serfs could escape by fleeing to a free town, remaining there for a year and a day.
 
v2 will be released in a few days!
there was a major delay because of bug fixing
.



Emigration is every turn but not all your unhappy people emigrate but a random number of them.

In v2 you also have to stay in unhappiness for several turn before people will start to leave your country.


in feudal Russia some lucky serfs were escaping from their owners to Ukraine. In Europe serfs could escape by fleeing to a free town, remaining there for a year and a day.
Great news about v2. This is my favorite CiV mod. What else is new in v2? Thanks in advance.
 
Great news about v2. This is my favorite CiV mod. What else is new in v2? Thanks in advance.
- people do not emigrate from razing and blockaded cities
- people do not immigrate into razing, starving, blockaded and rebellious cities
- if liberty/freedom is not adopted, garrisoned unit lowers emigration probability for a city
- if city's culture level is high, emigration from it is less likely
- emigration is more likely for starving cities
- notification texts fixed
 
- people do not emigrate from razing and blockaded cities
- people do not immigrate into razing, starving, blockaded and rebellious cities
- if liberty/freedom is not adopted, garrisoned unit lowers emigration probability for a city
- if city's culture level is high, emigration from it is less likely
- notification texts fixed

That sounds so cool :goodjob:

\Skodkim
 
I love the idea of this mod, but it just seems to me that the AI never goes into unhappiness, so all that happens is people leave your cities when you go unhappy and then they come back again when you're happy again! I'd love to see me receiving emigrants from other civs but I just can't compete with the AI when it comes to happiness!

Do others get emigrants from other civs?
 
I love the idea of this mod, but it just seems to me that the AI never goes into unhappiness, so all that happens is people leave your cities when you go unhappy and then they come back again when you're happy again! I'd love to see me receiving emigrants from other civs but I just can't compete with the AI when it comes to happiness!

Do others get emigrants from other civs?
I play on immortal, but I change the AI "unhappiness" to 135 in the handicaps XML file (under immortal). This improves several aspects of play, including the emigration mod; and I do occasionally get AI citizens. Though, even with this change, I lose more citizens to the AI than I gain. But I like it this way because it increases the challenge for the player.

The Emigration Mod does so much to balance the "happiness" mechanic, that I don't have time to write about it all just now. It just "fits" really well into CiV's scheme of things. It's such a perfect mod, that I'm sure the developers would have included it as a feature if they had thought of it.
 
I play on Prince, which I understand to be the most balanced, but I'm always at the bottom of the "civs that smile the most" table when it pops up. The civs at the top of the table are always around 40 to 50 happiness and I just don't understand how they can get so high and so quickly when they don't even have that many luxury resources!

Where is this handicaps xml file you mentioned? I'd like to take a look at it and try and change mine around.

I still see civs spamming cities and not building trade routes etc and just not playing the game properly, so I'd really like to bring their happiness into line so that they just can't get away with doing that!
 
Back
Top Bottom