Change Civ ingame

ramzay1945

Knyaz
Joined
Oct 9, 2012
Messages
407
Location
USSR, Ivanovo
Somebody. Could you tell me the correct function for the following situation.
There is a civilization, such as Babylon. Babylon has its own flag, name, building, leader, etc.
As a result of some reason (number of cities, for example) Babylon turns into Iraq with its flag, name, leader, etc.
DynamicCivName is not suitable, since it does not change the civilization under
player
control, only the name changes.

for example
Cities = 6
Civilization type = Rome Republic
Leader = Gaius Marius

Cities > 6
Civilization type = Roman Empire
Leader = Augustus
 
RevolutionDCM and its descendants have a component called ChangePlayer where you can change any player's civ and leader. You may want to look at that code, ChangePlayer.py in python/Revolution/Development and CHANGE_PLAYER in the DLL source. RFC has a leader changing mechanic, I don't know how that is implemented.
I don't believe it's possible to do it with only python, if that's what you want.
 
No, I don't know how to edit DLL or Python
I would be very happy if someone would help me with this.

I know that the DynamicCivNames component only changes the names of civilizations in relation to a specific trigger.
In RevolutionDCM, obviously, there is a function of changing the civilization itself, but there are a lot of functions that I do not need.
I'm interested in the possibility of changing a civilization tied to the same triggers as changing the name of a civilization in DynamicCivNames.

In General, the function in DynamicCivNames looks like this:
Civilization type is Spain
Cities = 6, CivName = Spain
Cities = 7, CivName = Great Spain

I need something like this:
 
I see. Is your mod based on vanilla BtS or something else?

It seems @f1rpo recently fixed the ChangePlayer component in their Advanced Civ mod.
AdvCiv is fairly close to vanilla BtS and actively developed, I recommend you use it as a base. If you are willing to do that, I'll try to add the functionality you want.

If you don't want to base your mod on a mod that incorporates ChangePlayer, you'll have to ask somebody else.
 
It seems @f1rpo recently fixed the ChangePlayer component in their Advanced Civ mod.
This thread had reminded me to check if the ChangePlayer shortcuts still work. K-Mod also includes ChangePlayer and I think the K-Mod version also works correctly apart from the option of joining a different team – which I didn't fix either but just removed it.
How about the link here? I haven't tried running the installer, but the download seems to work.
 
This thread had reminded me to check if the ChangePlayer shortcuts still work. K-Mod also includes ChangePlayer and I think the K-Mod version also works correctly apart from the option of joining a different team – which I didn't fix either but just removed it.How about the link here? I haven't tried running the installer, but the download seems to work.
Thanks!
Yes, i download this mod. Dynamic nations and dynamic leaders is about what I need.
They don't change civilization, but they change the flag and the button.
This feature is tied to era.
But i can't extract this function and bind it to other triggers.
 
[...] But i can't extract this function and bind it to other triggers.
As for changing the trigger conditions: I've run the installer and took a quick look. I think the file that one would have to change is Assets\Python\Revolution\Gameready\DynamicCivNames.py. Perhaps it's enough to change some of the conditions dealing with getCurrentEra() or currentEra so that getNumCities() is used instead. You might be able to do that even if you have no experience with programming.

Extracting the Dynamic Civ Names/Nations feature into a standalone mod component or porting it into another mod wouldn't be easy. For starters, DynamicCivNames.py imports Python modules from the Revolution mod.

Edit: I'm attaching DynamicCivNames.py for reference.
 

Attachments

As for changing the trigger conditions: I've run the installer and took a quick look. I think the file that one would have to change is Assets\Python\Revolution\Gameready\DynamicCivNames.py. Perhaps it's enough to change some of the conditions dealing with getCurrentEra() or currentEra so that getNumCities() is used instead. You might be able to do that even if you have no experience with programming.

Extracting the Dynamic Civ Names/Nations feature into a standalone mod component or porting it into another mod wouldn't be easy. For starters, DynamicCivNames.py imports Python modules from the Revolution mod.

Edit: I'm attaching DynamicCivNames.py for reference.
There are also components that are not bound to RevDCM.
Like this one and this one.
It may be possible to make them except for the name change flag and the button?
 
The 1.4 MB component seems to require the Revolution DLL and I don't think it does more of what you want than the smaller (1.1 MB) component by platyping.

platy's component allows civ names to change based on the number of cities, but, as you wrote in the initial post, it doesn't change flags, buttons or leader names. There are some DLL changes that platy took from Revolution.

What do you need to merge it with?
 
The 1.4 MB component seems to require the Revolution DLL and I don't think it does more of what you want than the smaller (1.1 MB) component by platyping.

platy's component allows civ names to change based on the number of cities, but, as you wrote in the initial post, it doesn't change flags, buttons or leader names. There are some DLL changes that platy took from Revolution.

What do you need to merge it with?
Since I can not change the civilization, I would like to bind to this component a function to change the flag and button along with the name.
If that's at all possible, I will be very grateful.
 
Since I can not change the civilization, I would like to bind to this component a function to change the flag and button along with the name.
If that's at all possible, I will be very grateful.
As far as I can tell, changing the flag is not possible without modding the DLL.
 
Someone will have to change the DLL. If I were to do it (but I can't take on another small project), I'd copy the changeCiv function from ChangePlayer and then try to hack platy's CvPlayer::setCivName(szNewDesc,...) function so that it calls changeCiv if szNewDesc matches the name of a civ that isn't currently alive. Something like this:
Spoiler :
Code:
   for (int i = 0; i < GC.getNumCivilizationInfos(); i++)
   {
       CivilizationTypes eCiv = (CivilizationTypes)i;
       CvCivilizationInfo const& kCiv = GC.getCivilizationInfo(eCiv);
       if (std::wcscmp(kCiv.getDescription(), szNewDesc.c_str()) != 0)
           continue;

       bool bValid = true;
       for (int j = 0; j < MAX_PLAYERS; j++)
       {
           CvPlayer const& kPlayer = GET_PLAYER((PlayerTypes)j);
           if (kPlayer.isAlive() && kPlayer.getCivilizationType() == eCiv)
           {
               bValid = false;
               break;
           }
       }
       if (!bValid)
           continue;

       changeCiv(eCiv);
       break;
   }
 
I think it can all be done in python. It would be a bit tedious (what computers were built to do;)) but you could move all units and cities to the new civ and then make the player the owner of that civ. Not sure what that does to the leader though. Relations with other nations would also need to be considered.
 
Off the top of my head this is the pseudo code I would base the actual code on
Code:
Upgrade Nation (oldNation,newNation)

1. Define new Nation and leader

2. For all nations
      Get current relationship with old Nation
      Set new Nation relationship to this value
     
      Find trades with old nation
            if old nation supplying a bonus
                  remember so they can be set up after all the plots change
            else
                  transfer trades to new nation
     
      Find all Treaties with old nation
            Transfer to new nation
           
3. For all plots owned by the old nation
      If not a city
            Get cultural value for old nation
            Remove cultural value of old nation
            Set plot cultural value for new nation
      If City
            Get cultural value of city
            Give city to new nation
            Make sure city cultural value is same
            Remove any anarchy
            make sure capital of old nation is capital of new (palace)
      For all units on the plot owned by old nation
            Give unit to new nation
           
4. For all remaining units
      Give unit to new nation

5. For any trades involving bonuses from old nation (from 2)
      transfer trades to new nation

I think this covers everything and it can all be done in Python. It also suggests some other possibilities for this transition
  • a period of anarchy
  • not transferring trades and treaties after all it is possibly a new government so they should be renegotiated
  • move capital
  • ...
 
Back
Top Bottom