1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Emigration

Discussion in 'Civ5 - Mod Components' started by killmeplease, Oct 6, 2010.

  1. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    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](citythen
        local bUseWeight 
    true;

        for 
    j in GameInfo.Emigration_Weight_Policy_Requirements() do
          if 
    weight.Type == j.WeightType then
            
    if (j.ExcludesWeight and hasPolicyName(pPlayerj.PolicyType)) then
              bUseWeight 
    false;
            elseif (
    not j.ExcludesWeight and not hasPolicyName(pPlayerj.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(playerpolicyName)
      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.
     

    Attached Files:

  2. Putmalk

    Putmalk Deity

    Joined:
    Sep 26, 2010
    Messages:
    2,623
    Location:
    New York
    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?
     
  3. killmeplease

    killmeplease Mk Z on Steam

    Joined:
    Nov 22, 2007
    Messages:
    2,794
    Location:
    Samara
    i'm surprised how few culture related functions we have. very majority of cultureBlaBla stuff just does not work.

    Nope, these are only two.
     
  4. Lilltiger

    Lilltiger Chieftain

    Joined:
    Oct 16, 2010
    Messages:
    29
    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.
     
  5. Kanin

    Kanin Chieftain

    Joined:
    Mar 17, 2007
    Messages:
    28
    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.
     
  6. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    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
     
  7. Derax

    Derax Chieftain

    Joined:
    Aug 6, 2007
    Messages:
    68
    Very nice :)
     
  8. poncratias

    poncratias Prince

    Joined:
    Feb 9, 2010
    Messages:
    336
    when can we expect an update?
     
  9. Putmalk

    Putmalk Deity

    Joined:
    Sep 26, 2010
    Messages:
    2,623
    Location:
    New York
    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.
     
  10. FcZenitFan

    FcZenitFan Chieftain

    Joined:
    Oct 16, 2010
    Messages:
    2
    Location:
    Michigan, USA
    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.
     
  11. Putmalk

    Putmalk Deity

    Joined:
    Sep 26, 2010
    Messages:
    2,623
    Location:
    New York
    I dunno, it seemed to be happening every turn, if I was at like...3 unhappiness.
     
  12. }{ELL/\/()

    }{ELL/\/() Warlord

    Joined:
    Nov 17, 2001
    Messages:
    102
    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.
     
  13. killmeplease

    killmeplease Mk Z on Steam

    Joined:
    Nov 22, 2007
    Messages:
    2,794
    Location:
    Samara
    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.
     
  14. Marshall Thomas

    Marshall Thomas King

    Joined:
    Dec 11, 2005
    Messages:
    700
    Great news about v2. This is my favorite CiV mod. What else is new in v2? Thanks in advance.
     
  15. killmeplease

    killmeplease Mk Z on Steam

    Joined:
    Nov 22, 2007
    Messages:
    2,794
    Location:
    Samara
    - 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
     
  16. skodkim

    skodkim Deity

    Joined:
    Jan 16, 2004
    Messages:
    2,275
    Location:
    Denmark
    That sounds so cool :goodjob:

    \Skodkim
     
  17. Baleur

    Baleur Prince

    Joined:
    Jul 9, 2010
    Messages:
    526
    Location:
    Qingdao, China
    Oooh yess. Keep them locked in, keep them working! :D:mad::D
     
  18. Panda_Power

    Panda_Power Warlord

    Joined:
    Jun 9, 2010
    Messages:
    280
    Location:
    Shanghai, China
    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?
     
  19. Marshall Thomas

    Marshall Thomas King

    Joined:
    Dec 11, 2005
    Messages:
    700
    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.
     
  20. Panda_Power

    Panda_Power Warlord

    Joined:
    Jun 9, 2010
    Messages:
    280
    Location:
    Shanghai, China
    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!
     

Share This Page