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

Revolutions

Discussion in 'Civ5 - Modpacks' started by Gedemon, Mar 21, 2012.

  1. Spirit7609

    Spirit7609 Chieftain

    Joined:
    Apr 10, 2008
    Messages:
    45
    Update:
    I overlooked something, it's not AcquireCity. :)
    Seems to be SetOccupied(false)

    Debug code:
    Spoiler :
    if city:IsOccupied() then
    Dprint ("in GiveCityToPlayer, calling SetOccupied" , bDebug)
    city:SetOccupied(false)
    Dprint ("in GiveCityToPlayer, called SetOccupied" , bDebug)
    end


    log:
    Spoiler :
    [2281929.694] RevolutionMain: ------------------
    [2281929.694] RevolutionMain: Check for Revolutions Outcome...
    [2281929.694] RevolutionMain: - Fes can make a choice...
    [2281929.694] RevolutionMain: - Minimum happiness value to join = 2
    [2281929.694] RevolutionMain: - checking CIVILIZATION_MOROCCO
    [2281929.694] RevolutionMain: - culture value = 1049, 'happiness' value = 3, joigning value = 1573.5
    [2281929.694] RevolutionMain: - checking SEPARATIST
    [2281929.694] RevolutionMain: - checking MINOR_CIV_BYBLOS
    [2281929.694] RevolutionMain: - # possible choice = 1
    [2281929.694] RevolutionMain: - rebel culture value = 1588
    [2281929.694] RevolutionMain: - separatist culture value = 195
    [2281929.694] RevolutionMain: - The revolutionnary comite has decided, the city will join : CIVILIZATION_MOROCCO
    [2281929.694] RevolutionMain: - changing culture value of CIVILIZATION_MOROCCO at 27,30
    [2281929.694] RevolutionMain: - changing culture value i = 1 culture.Value = 1049 value 1783 from 1049
    [2281929.694] RevolutionMain: - changed culture value of CIVILIZATION_MOROCCO at 27,30
    [2281929.694] RevolutionMain: - changing culture value of MINOR_CIV_BYBLOS at 27,30
    [2281929.694] RevolutionMain: - changing culture value i = 3 culture.Value = 1588 value -1588 from 1588
    [2281929.694] RevolutionMain: - changed culture value of MINOR_CIV_BYBLOS at 27,30
    [2281929.694] RevolutionMain: - changing culture value of SEPARATIST at 27,30
    [2281929.694] RevolutionMain: - changing culture value i = 2 culture.Value = 195 value -195 from 195
    [2281929.694] RevolutionMain: - changed culture value of SEPARATIST at 27,30
    [2281929.694] RevolutionMain: in GiveCityToPlayer, calling AcquireCity
    [2281929.709] RevolutionMain: in GiveCityToPlayer, called AcquireCity, city:GetResistanceTurns()=0
    [2281929.709] RevolutionMain: in GiveCityToPlayer, calling SetPuppet
    [2281929.709] RevolutionMain: in GiveCityToPlayer, called SetPuppet
    [2281929.709] RevolutionMain: in GiveCityToPlayer, calling SetOccupied


    Also, it was reproducable immedately.

    Just wondering.. The city is not a puppet and not occupied. When I conquer a city and make it a puppet, it's not occupied, right? In contrast to annexing the city in which case it is occupied until I build a courthouse. So, not a puppet and not occupied may be a combination which the game can't handle? But that's just guessing.

    I'll try and wrap it in another if city:IsPuppet() ..
    Maybe it works, but I don't know if it makes sense.

    edit: it works but I'm still unsure if it makes sense. I'll try and look if I can find Fes. :)

    Current log:
    Spoiler :
    [2283051.684] RevolutionMain: ------------------
    [2283051.684] RevolutionMain: Check for Revolutions Outcome...
    [2283051.684] RevolutionMain: - Fes can make a choice...
    [2283051.684] RevolutionMain: - Minimum happiness value to join = 2
    [2283051.684] RevolutionMain: - checking CIVILIZATION_MOROCCO
    [2283051.684] RevolutionMain: - culture value = 1049, 'happiness' value = 3, joigning value = 1573.5
    [2283051.684] RevolutionMain: - checking SEPARATIST
    [2283051.684] RevolutionMain: - checking MINOR_CIV_BYBLOS
    [2283051.684] RevolutionMain: - # possible choice = 1
    [2283051.700] RevolutionMain: - rebel culture value = 1588
    [2283051.700] RevolutionMain: - separatist culture value = 195
    [2283051.700] RevolutionMain: - The revolutionnary comite has decided, the city will join : CIVILIZATION_MOROCCO
    [2283051.700] RevolutionMain: - changing culture value of CIVILIZATION_MOROCCO at 27,30
    [2283051.700] RevolutionMain: - changing culture value i = 1 culture.Value = 1049 value 1783 from 1049
    [2283051.700] RevolutionMain: - changed culture value of CIVILIZATION_MOROCCO at 27,30
    [2283051.700] RevolutionMain: - changing culture value of MINOR_CIV_BYBLOS at 27,30
    [2283051.700] RevolutionMain: - changing culture value i = 3 culture.Value = 1588 value -1588 from 1588
    [2283051.700] RevolutionMain: - changed culture value of MINOR_CIV_BYBLOS at 27,30
    [2283051.700] RevolutionMain: - changing culture value of SEPARATIST at 27,30
    [2283051.700] RevolutionMain: - changing culture value i = 2 culture.Value = 195 value -195 from 195
    [2283051.700] RevolutionMain: - changed culture value of SEPARATIST at 27,30
    [2283051.700] RevolutionMain: in GiveCityToPlayer, calling AcquireCity
    [2283051.700] RevolutionMain: in GiveCityToPlayer, called AcquireCity, city:GetResistanceTurns()=0
    [2283051.700] RevolutionMain: in GiveCityToPlayer, calling SetPuppet
    [2283051.700] RevolutionMain: in GiveCityToPlayer, called SetPuppet
    [2283051.700] RevolutionMain: finished GiveCityToPlayer
     
  2. Spirit7609

    Spirit7609 Chieftain

    Joined:
    Apr 10, 2008
    Messages:
    45
    Got another one. :)
    This time it's ChangeResistanceTurns(-2):

    Spoiler :
    [2290196.499] RevolutionMain: ------------------
    [2290196.499] RevolutionMain: Checking Rebels spawning for Ahmad al-Mansur
    [2290196.499] RevolutionMain: - Marrakech at 5,47
    [2290196.499] RevolutionMain: - CIVILIZATION_MOROCCO has enought strength to rebel, check relation...
    [2290196.499] RevolutionMain: - Fes at 27,30
    [2290196.499] RevolutionMain: - SEPARATIST has enought strength to rebel, check relation...
    [2290196.499] RevolutionMain: - Bad relation with tile owner for SEPARATIST, check for rebellion spawning...
    [2290196.499] RevolutionMain: - spawning 9 unit(s)
    [2290196.499] RevolutionMain: - Spawning SEPARATIST Rebels against Ahmad al-Mansur
    [2290196.499] RevolutionMain: - Slot already open, use it...
    [2290196.499] RevolutionMain: - Max units for SEPARATIST rebels in Ahmad al-Mansur territory = 2
    [2290196.499] RevolutionMain: - Spawning rebel unit at 26,29
    [2290196.499] RevolutionMain: - Max units for SEPARATIST rebels in Ahmad al-Mansur territory = 2
    [2290196.514] RevolutionMain: - Max units for SEPARATIST rebels in Ahmad al-Mansur territory = 2
    [2290196.514] RevolutionMain: - Max units for SEPARATIST rebels in Ahmad al-Mansur territory = 2
    [2290196.514] RevolutionMain: - Max units for SEPARATIST rebels in Ahmad al-Mansur territory = 2
    [2290196.514] RevolutionMain: - Max units for SEPARATIST rebels in Ahmad al-Mansur territory = 2
    [2290196.514] RevolutionMain: - Max units for SEPARATIST rebels in Ahmad al-Mansur territory = 2
    [2290196.514] RevolutionMain: - generating revolution !!!
    [2290196.514] RevolutionMain: - Revolution started by SEPARATIST Rebels against Ahmad al-Mansur
    [2290196.514] RevolutionMain: - Slot already open, use it...
    [2290196.514] RevolutionMain: - returned from GetFreeSlotsAndRebelID
    [2290196.514] RevolutionMain: in GiveCityToPlayer, calling AcquireCity
    [2290196.530] RevolutionMain: in GiveCityToPlayer, called AcquireCity, city:GetResistanceTurns()=2
    [2290196.530] RevolutionMain: in GiveCityToPlayer, calling ChangeResistanceTurns(-2)


    Debug code is:
    Spoiler :
    if city:GetResistanceTurns() > 0 then
    Dprint ("in GiveCityToPlayer, calling ChangeResistanceTurns(-" .. city:GetResistanceTurns() .. ")" , bDebug)
    city:ChangeResistanceTurns(-city:GetResistanceTurns())
    Dprint ("in GiveCityToPlayer, called ChangeResistanceTurns" , bDebug)
    end


    In GiveCityToPlayer..
     
  3. anonemuss

    anonemuss Chieftain

    Joined:
    May 22, 2013
    Messages:
    15
    If I'm correct in reading the second issue, there's a problem with the turns of resistance becoming negative when the city's given to a player, right?

    I'm not sure if this is right, but if that's the case, then would changing:
    city:ChangeResistanceTurns(-city:GetResistanceTurns())
    into:
    city:SetResistanceTurns(0)
    fix the problem?
     
  4. Spirit7609

    Spirit7609 Chieftain

    Joined:
    Apr 10, 2008
    Messages:
    45
    I'm not sure, because city:GetResistanceTurns() is always positive since it passes an "if city:GetResistanceTurns() > 0" in the line before. So it's always negative when it gets passed to ChangeResistanceTurns.
    Also, it worked before with -10..

    But what concerns me more is that it's not reproducable. I can try it though. Also I will not know if it worked, right? :)
    I will change that line anyway and try if I can see anything.
     
  5. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    8,664
    Location:
    France
    That's difficult to track.

    And it doesn't crash here on my computer...

    The problem is not in one of the function, but maybe in the combination of them, and the time taken to perform everything (to slow or to fast...)
     
  6. Spirit7609

    Spirit7609 Chieftain

    Joined:
    Apr 10, 2008
    Messages:
    45
    I now understand what you meant, anonemuss. I guess it could work.
    What you do is basically subtract GetResistanceTurns from itself, right? SetResistanceTurns(0) should then do the same..

    But I don't get why GetResistanceTurns should change between its evaluation and passing the result to ChangeResistanceTurns, except when threading is involved. Is it?

    As for the game: no revolutions yet, so no results.
     
  7. heinous_hat

    heinous_hat Prince

    Joined:
    Sep 28, 2010
    Messages:
    592
    Location:
    under the weather
    @ Gedemon

    Any clue what might specifically cause this mod to malfunction when using LuaJIT as a replacement compiler?

    I like LuaJIT for what it does for map generation times with some custom scripts. I realize that with your mod, your own optimizations probably make much more of a difference at this point than an optimized compiler, but thought I'd give it the once over... if for no other reason than not having to swap out that dll between testing map scripts and actually playing. But I'm hardly either a Lua expert or familiar enough with your code to make it an easy task.

    I do have some minor coding background though and I started examining your routines for instances of deprecated function usage or syntax changes between Lua 5.0 and 5.1. Just wondering if you had given that any thought or had any suggestions.

    As far as behavior goes, the mod loads and doesn't cause any error (so far) but the topPanel is non-functional (displays "Cultural Relations!" but no data display). So I'm starting with RevolutionInfos.lua.
     
  8. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    8,664
    Location:
    France
    the incompatibility is in saveutils.

    but I don't remember the exact line, maybe it was posted in the corresponding thread.
     
  9. heinous_hat

    heinous_hat Prince

    Joined:
    Sep 28, 2010
    Messages:
    592
    Location:
    under the weather
    That led me right to it, thanks :). Lua.log had truncated the path and filename.

    The only error (I think) is just an invalid escape sequence in a few lines (528-531). Dropping the backslashes before the open and close brackets in the string fixes it. Both Revolutions and Cultural Diff are now working.
    Spoiler :
    function serialize( p )

    local r = ""; local t = type( p );
    if t == "function" or t == "userdata" or t == "thread" then
    print( "serialize(): Invalid type: "..t ); --error.
    elseif p ~= nil then
    if t ~= "table" then
    if p == nil or p == true or p == false
    or t == "number" then r = tostring( p );
    elseif t == "string" then
    if p:lower() == "true" or p:lower() == "false"
    or tonumber( p ) ~= nil then r = '"'..p..'"';
    else r = p;
    end
    end
    r = r:gsub( "{", "\[LCB\]" );
    r = r:gsub( "}", "\[RCB\]" );
    r = r:gsub( "=", "\[EQL\]" );
    r = r:gsub( ",", "\[COM\]" );

    else
    r = "{"; local b = false;
    for k,v in pairs( p ) do
    if b then r = r..","; end
    r = r..serialize( k ).."="..serialize( v );
    b = true;
    end
    r = r.."}"
    end
    end
    return r;
    end



    Fortunately, I eventually remembered there's more than one copy of saveutils :wallbash:
     
  10. Spirit7609

    Spirit7609 Chieftain

    Joined:
    Apr 10, 2008
    Messages:
    45
    I noticed it a bit late but there is no city:SetResistanceTurns :)
    It's strange somehow because ChangeRT(-GetRT) should set it to 0 as intended. I'll revert it in the code and see what happens, maybe it's just circumstances.

    Or maybe decrease the resistance turns with a loop changing turns by -1 for each iteration until it's 0.. That sounds just wrong in my head but I'm out of ideas :)

    Update: even with the change to ChangeResistanceTurns(-1) (would have been 3 iterations), my game crashes on the first call to ChangeResistanceTurns.
     
  11. PR0927

    PR0927 Warlord

    Joined:
    Aug 11, 2011
    Messages:
    142
    Constantly having rebellions, even though my happiness is decent and my culture is strong. What am I doing wrong? And how can I stop it? Other nations are suffering and constantly in internal war, along with several defecting cities.
     
  12. Ymir9

    Ymir9 Warlord

    Joined:
    Nov 15, 2006
    Messages:
    125
    Are all your cities properly hooked up to the capital?
     
  13. MacAttack

    MacAttack Just the tip

    Joined:
    Aug 3, 2009
    Messages:
    1,315
    Location:
    The Texan Empire
    Sounds like armies are not big enough early enough.
     
  14. PR0927

    PR0927 Warlord

    Joined:
    Aug 11, 2011
    Messages:
    142

    Yep, had the largest army, all cities connected to capital, and the highest happiness. Still struggled to have stability. All other civilizations were half-crippled in development and land seizure because of revolutions/rebellions.
     
  15. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    8,664
    Location:
    France
    Try to uncheck the "Raging Rebels" option is the custom setup screen for your next game if it was selected.
     
  16. pthieu1986

    pthieu1986 Warlord

    Joined:
    Nov 19, 2012
    Messages:
    241
    Hi enthusiastic Gedemon, is this mod compatible with BNW and the R.E.D mod?
     
  17. anonemuss

    anonemuss Chieftain

    Joined:
    May 22, 2013
    Messages:
    15
    Reading his previous posts, it seems the latest version is compatible with both.
     
  18. anonemuss

    anonemuss Chieftain

    Joined:
    May 22, 2013
    Messages:
    15
    In addition to what Gedemon said, if you still find it hard to keep stability, try changing some settings in the RevolutionDefines.lua file. Increasing values such as MIN_CULTURE_REBELS_SPAWN or decreasing values like MIN_RELATION_BEFORE_REBELLION will make it harder for rebels to spawn. These values are under "Revolution" in the file, and the file is most likely found under Documents\My Games\Civilization 5\MODS\Revolutions (v 9)\Lua.

    It may not be the standard way of fixing things, but it is the best way to tune the mod to your preferences. ^_^
     
  19. Ymir9

    Ymir9 Warlord

    Joined:
    Nov 15, 2006
    Messages:
    125
    I love this mod, but I've had a few issues (maybe they're features) with rebels spawning more rebels and falling back into rebellion after establishing independence. For instance, I had one instance of Arabian rebels successfully taking territory and declaring independence as a new city state, only to once again flip back into rebellion, declare war against Arabia again (for some reason), losing all the influence I accumulated with them while they were an independent city state, and getting renamed as the "Arabian rebels rebels".

    If this was a new rebellion against the previous rebel state I could understand, but why would the "rebels rebels" declare war on Arabia again? Are there any settings that might be causing this behavior? I have create new city states and raging rebels enabled.
     
  20. antiplaka

    antiplaka Chieftain

    Joined:
    Sep 16, 2013
    Messages:
    5
    When rebels declare war/peace on someone, rebel's name is not displayed in notification. It looks something like ' declares war on Russia'. Does anybody have this problem? BNW, no other mods besides Revolution Modpack. Tried on English and Russian languages.
     

Share This Page