[Mini MOD _ MOD Comp] Alignment Options

I just started thinking that it would be good if the mod (or, after the next patch, the main game) addressed Colonies too. Adding another game option that makes sure colonies are of the same alignment as the civ from which they broke away (when possible) would be good. When that can't be done (or as a less extreme option), it might be good to block evil civs from releasing good colonies, and vice versa (neutral civs could still liberate or be liberated by civs of any alignment)

This seems easy to do in CvPlayer::getSplitEmpireLeaders. Make 3 pass instead of one for leaders . 1rst time same alignment with the player then if nothing found, alignment neutral then anything.

This is my take on your code in CvGame::init:

It works pretty well. Its just to implement the 3 random alignment options of course and simplify it down as much as possible.

Again this is just a brilliant plan. Ive been wanting to do this for 2 years and could never find a way to do it, your design is brillant.

Perhaps these changes can be good :

Spoiler :
Code:
	int iRndCiv = GC.getInfoTypeForString("CIVILIZATION_RANDOM");
	int iRndLeaderGood = GC.getInfoTypeForString("LEADER_RANDOM_GOOD");
	int iRndLeaderNeutral = GC.getInfoTypeForString("LEADER_RANDOM_NEUTRAL");
	int iRndLeaderEvil = GC.getInfoTypeForString("LEADER_RANDOM_EVIL");
	int iAlignment;
	int iBestLeader = -1;
	int iBestCiv = -1;
	int iBestValue = -1;
	int iValue = 0;
	[COLOR="Red"]int iNumLeader = 0;[/COLOR]

	for (int iPlayer = 0; iPlayer < MAX_CIV_PLAYERS; iPlayer++)
	{
		if (GC.getInitCore().getCiv((PlayerTypes)iPlayer) == iRndCiv)
		{
			if (GC.getInitCore().getLeader((PlayerTypes)iPlayer) == iRndLeaderGood)
			{
				iAlignment = ALIGNMENT_GOOD;
			}
			if (GC.getInitCore().getLeader((PlayerTypes)iPlayer) == iRndLeaderNeutral)
			{
				iAlignment = ALIGNMENT_NEUTRAL;
			}
			if (GC.getInitCore().getLeader((PlayerTypes)iPlayer) == iRndLeaderEvil)
			{
				iAlignment = ALIGNMENT_EVIL;
			}
			for (int iCiv = 0; iCiv < GC.getNumCivilizationInfos(); iCiv++)
			{
				if (GC.getCivilizationInfo((CivilizationTypes)iCiv).isAIPlayable())
				{
					for (int iLeader = 0; iLeader < GC.getNumLeaderHeadInfos(); iLeader++)
					{
						if (GC.getCivilizationInfo((CivilizationTypes)iCiv).isLeaders(iLeader))
						{
							if (GC.getLeaderHeadInfo((LeaderHeadTypes)iLeader).getAlignment() == iAlignment)
							{
								[COLOR="Red"]iNumLeader = std::min(4, GC.getCivilizationInfo((CivilizationTypes)iCiv).getNumLeaders());[/COLOR]
								iValue = 40000 + GC.getGameINLINE().getSorenRandNum(1000, "Random Leader")[COLOR="Red"] - (iNumLeader * 75)[/COLOR];
								for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++)
								{
									if (GC.getInitCore().getLeader((PlayerTypes)iI) == iLeader)
									{
										[COLOR="Red"]iValue -= 10000;[/COLOR]
									}
									if (GC.getInitCore().getCiv((PlayerTypes)iI) == iCiv)
									{
										[COLOR="Red"]iValue -= 2000;[/COLOR]
									}
								}
								if (iValue > iBestValue)
								{
									iBestCiv = iCiv;
									iBestLeader = iLeader;
									iBestValue = iValue;
								}
							}
						}
					}
				}
			}
			GC.getInitCore().setCiv((PlayerTypes)iPlayer, (CivilizationTypes)iBestCiv);
			GC.getInitCore().setLeader((PlayerTypes)iPlayer, (LeaderHeadTypes)iBestLeader);
			iBestCiv = -1;
			iBestLeader = -1;
			iBestValue = -1;
		}
	}

_ Let a little less chances for civ that have more leader available to appear at each game.
_ Be sure another civ will be selected if possible. (250 seems not enough toward 1000)
_ tweak if the game is forced to choose a same leader

Since i can't play without the equalize options and MP options especially. I will continue to work on the mini-MOD and try to achieve to pass the function to python.

Tcho !

IMPORTANT EDIT :
_ You have forgotten to take in count the option unrestricted leaders. You can simply set NO_CIVILIZATION instead of the leader civ, but that requires to disable the civ temporaly for the default civ implementation. (done in the mini MOD)

_ You need also to select yourself all random leaders for the option unrestricted leaders. If not a random leader can be selected and also hyborem, basium ou kourt.

_Hope you have taken a look at the random personality option. You also need to prevenet the random leader in this function. It doesn't check at any time if the leader civ is playable.
 
Here is the final form of the code as it appears in patch "c". I cleaned it up a bit, took out all the references to the good, neutral and evil leader, etc.

You are correct that it won't handle unrestricted leaders (all random leaders picked will be with their origional civs). I dont know if thats a stopped eiother way. The player would be able to select the leader/civ he wants, but all the randon ones would be normal. Not a huge deal, but its a fair point and I may add support for that.

This code (and the prior) will never pick Hyborem/Basium/Koun, so thats not a concern.

As you said this won't support random personalities either. But to be honest Im thinking about pulling that function from FfH anyway. We work so hard to build personalities for these leaders, I dont think allowing a game option to switch them aqround makes much sence in FfH.

Code:
    int iRndCiv = GC.getDefineINT("RANDOM_CIVILIZATION");
    if (iRndCiv != -1)
    {
        int iAlignment;
        int iBestLeader = -1;
        int iBestCiv = -1;
        int iBestValue = -1;
        int iValue = 0;

        for (int iPlayer = 0; iPlayer < MAX_CIV_PLAYERS; iPlayer++)
        {
            if (GC.getInitCore().getCiv((PlayerTypes)iPlayer) == iRndCiv)
            {
                iAlignment = GC.getLeaderHeadInfo((LeaderHeadTypes)GC.getInitCore().getLeader((PlayerTypes)iPlayer)).getAlignment();
                for (int iCiv = 0; iCiv < GC.getNumCivilizationInfos(); iCiv++)
                {
                    if (GC.getCivilizationInfo((CivilizationTypes)iCiv).isAIPlayable())
                    {
                        for (int iLeader = 0; iLeader < GC.getNumLeaderHeadInfos(); iLeader++)
                        {
                            if (GC.getCivilizationInfo((CivilizationTypes)iCiv).isLeaders(iLeader))
                            {
                                if (GC.getLeaderHeadInfo((LeaderHeadTypes)iLeader).getAlignment() == iAlignment)
                                {
                                    iValue = 40000 + GC.getGameINLINE().getSorenRandNum(1000, "Random Leader");
                                    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++)
                                    {
                                        if (GC.getInitCore().getLeader((PlayerTypes)iI) == iLeader)
                                        {
                                            iValue -= 1000;
                                        }
                                        if (GC.getInitCore().getCiv((PlayerTypes)iI) == iCiv)
                                        {
                                            iValue -= 250;
                                        }
                                    }
                                    if (iValue > iBestValue)
                                    {
                                        iBestCiv = iCiv;
                                        iBestLeader = iLeader;
                                        iBestValue = iValue;
                                    }
                                }
                            }
                        }
                    }
                }
                GC.getInitCore().setCiv((PlayerTypes)iPlayer, (CivilizationTypes)iBestCiv);
                GC.getInitCore().setLeader((PlayerTypes)iPlayer, (LeaderHeadTypes)iBestLeader);
                iBestCiv = -1;
                iBestLeader = -1;
                iBestValue = -1;
            }
		}
	}
 
The player would be able to select the leader/civ he wants, but all the randon ones would be normal. Not a huge deal, but its a fair point and I may add support for that.
I don't see this as a problem at all.

I've actually asked several times for an option that lets you manually assign leaders to non-standard civs but keeps all the random leaders with their default civ. I'd like to play around with Cardith of the Khazad, Tebyrn of the Amurites, Dain of the Sidar, Falamar of the Calabim, etc, but keep all the really unthematic/weak ones (Varn of the Sheaim, Charadon of the Amurites, Sabathiel of the Doviello, Einion of the Clan, etc) from ever appearing.

Random personalities is a little annoying too. Especially since they aren't really random, but switched around with other leaders. You can usually use favorite wonders to tell them apart. (Not really related, but I'm still hoping you'll add a "Hated Wonders" tag for each leader. Some wonders just seem like they would really get on the nerves of certain leaders. Basium should hate the Stigmata on the Unborn , Hyborem should hate the Mercurian Gate, Sandalphon should hate Mokka's Cauldron or The Tower of Necrmancy, Varn should hate Nox Noctis, Alexis should hate Dies Diei, Flauros or Alexis should hate the Shrine of Sirona or Dies Diei (probably one each), etc.)


Now that these random options have been added, is there any chance you could go ahead and add the ability for players (with at least a basic knowledge of XML) to create a list of favorite civs/leaders to be randomly chosen between?
 
Here is the final form of the code as it appears in patch "c". I cleaned it up a bit, took out all the references to the good, neutral and evil leader, etc.

Thank you , I've dowloaded the patchc sdk.

You are correct that it won't handle unrestricted leaders (all random leaders picked will be with their origional civs). I dont know if thats a stopped eiother way. The player would be able to select the leader/civ he wants, but all the randon ones would be normal. Not a huge deal, but its a fair point and I may add support for that.

The problem begin here . There is two solutions : you manage to choose all leader and civ for all players in the function or you disable the random civ the time the civ IV process handle his choices.

Issues :

_ when you loop over the civ , you don't skip the random civ (the Random civ is aiplayable so !?)

_ About the value , you should take the value defined below (-10000 same leader, -2000 same civ ... and if you want a little tone for civ that have more leaders to prevent these civ to appear "at every game" with small number of players -> the tweak with num leader civ).
I've done a test yesterday selecting only 6 random good leaders . There is 6 good civ so i should have the 6 different good civs but got 2 player with the same civ. Let's say the 2 last are chosen (213 random for the first of the different civ ,743 for the second which already another player have the same civ ... and you get a player with a same civ of another one instead of getting the last good civ)

_ For the regular "random leader" , you have the choice to select them yourself . Or to disable the random civ during the civ impl like in the mini MOD. If not ,the regular selection count the random civ as a regular civ playable and AIplayable.

This code (and the prior) will never pick Hyborem/Basium/Koun, so thats not a concern.

_ the problem about Hyborem/Basium/Koun and the random leader is for the option "unrestricted leaders" . With this option the regular civIV choice doesn't check if the leader CIV is playable or AIPlayable . So you have to select all the leader when this option is ON (even the random ones and even if you disable the civ). When this option is ON , Hyborem/Basium/Koun may appear (just launch a game with 35 leaders , you should have one at least). A simple loop over leaders can do it.

For this option , when you assign the leaders , you can put "if isOption(LEAD_ANY_CIV)" -> setCiv(NO_CIVLIZATION) instead of the regular one in your funtion. You have the choice to select all the civ yourself , or disable the random civ and let the default civ impl.

As you said this won't support random personalities either. But to be honest Im thinking about pulling that function from FfH anyway. We work so hard to build personalities for these leaders, I dont think allowing a game option to switch them aqround makes much sence in FfH.

You're right , I never use this option. But i've implemented it just in case since it's in the menu.

I will try to finish the export of the function to python today to make things easier to do. I don't think I will update the mini MOD for patch c. Looks like a patch d should arrive soon !? :)

Do not hesitate to PM me if I'm not clear , so we can chat on the channel.

Tcho !

EDIT : I think it would be good to disable th random civ during the game also. For an example , the colonies can select the random civ and leaders. But for now sice i will pass the function to python, i've stop disabling the civ (set playable and aiplayable to false) and just return false or true when the game is final initialized or not.

EDIT 2 : I don't understand from where the hyborem appear in the regular game (just see it in the bug thread) and never got this issue

EDIT 3 : another issue i've forgotten is that you can select a minor civ. And also there is no check playable <-> human and AIplayable <-> AI player
 
I'm thinking it would be a good idea to just have the bPlayable and bAIPlayable tags for both civs and leaders. Some people have been requesting this recently anyway.

(Before Shadow leaders had these tags instead of civs. It would be better to have both)
 
I'm thinking it would be a good idea to just have the bPlayable and bAIPlayable tags for both civs and leaders. Some people have been requesting this recently anyway.

What other tags are you talking about ?

Edit : sorry, i've not understood. the problems is that the choice of leaders made by civ will not take that in count and there is a lot of stuff in the sdk to change to adapt this 2 new tags .
 
Heres an updated one that seems to resolve the good/neutral/evil picking problem.

Code:
    int iRndCiv = GC.getDefineINT("RANDOM_CIVILIZATION");
    if (iRndCiv != -1)
    {
        int iAlignment = 0;
        int iBestLeader = -1;
        int iBestCiv = -1;
        int iBestValue = -1;
        int iValue = 0;

        for (int iPlayer = 0; iPlayer < MAX_CIV_PLAYERS; iPlayer++)
        {
			if ((GC.getInitCore().getSlotStatus((PlayerTypes)iPlayer) == SS_COMPUTER) || (GC.getInitCore().getSlotStatus((PlayerTypes)iPlayer) == SS_TAKEN))
			{
			    iAlignment = 0;
				if (GC.getInitCore().getCiv((PlayerTypes)iPlayer) == NO_CIVILIZATION)
				{
                    GC.getInitCore().setCiv((PlayerTypes)iPlayer, (CivilizationTypes)iRndCiv);
                    iAlignment = -1;
				}
                if (GC.getInitCore().getCiv((PlayerTypes)iPlayer) == iRndCiv)
                {
                    if (iAlignment != -1)
                    {
                        iAlignment = GC.getLeaderHeadInfo((LeaderHeadTypes)GC.getInitCore().getLeader((PlayerTypes)iPlayer)).getAlignment();
                    }
                    for (int iCiv = 0; iCiv < GC.getNumCivilizationInfos(); iCiv++)
                    {
                        if (GC.getCivilizationInfo((CivilizationTypes)iCiv).isAIPlayable())
                        {
                            for (int iLeader = 0; iLeader < GC.getNumLeaderHeadInfos(); iLeader++)
                            {
                                if (GC.getCivilizationInfo((CivilizationTypes)iCiv).isLeaders(iLeader))
                                {
                                    if (iAlignment == -1 || GC.getLeaderHeadInfo((LeaderHeadTypes)iLeader).getAlignment() == iAlignment)
                                    {
                                        iValue = 40000 + GC.getGameINLINE().getSorenRandNum(1000, "Random Leader");
                                        for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++)
                                        {
                                            if (GC.getInitCore().getLeader((PlayerTypes)iI) == iLeader)
                                            {
                                                iValue -= 1000;
                                            }
                                            if (GC.getInitCore().getCiv((PlayerTypes)iI) == iCiv)
                                            {
                                                iValue -= 250;
                                            }
                                        }
                                        if (iValue > iBestValue)
                                        {
                                            iBestCiv = iCiv;
                                            iBestLeader = iLeader;
                                            iBestValue = iValue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    GC.getInitCore().setCiv((PlayerTypes)iPlayer, (CivilizationTypes)iBestCiv);
                    GC.getInitCore().setLeader((PlayerTypes)iPlayer, (LeaderHeadTypes)iBestLeader);
                    iBestCiv = -1;
                    iBestLeader = -1;
                    iBestValue = -1;
                }
            }
		}
	}
 
The reason Hyborem & Loki are showing up for people who have the Random ____ Leaders ingame is that they don't have UU version "NONE" for any of the world/Unique units, so are capable of building anything. Though how they pulled off multiple copies of Hyborem is kinda bizarre.
 
Update 0.32d in the first post .

Tcho !
 
Update for patch 0.32e. The function is still not exposed to python (So the selection can still don't match all options in some complicated selection).

Tcho !
 
In religion war, I got a forbidden religion tech from the eyes and ear wonder.

EDIT: It was with patch d
 
In religion war, I got a forbidden religion tech from the eyes and ear wonder.

EDIT: It was with patch d

Thank you , i've not taken that in count. I'll removed them in the next version since it's a big advantage to get some disciples without open borders (edit: lol ^^ what a nonsense) . I want to pass the function to python first but have no time for the moment.

Tcho !
 
Any chance to have this gem for a "i" patch?

I rewrite the function in python. I don't know when i will finish it . Perhaps today or tomorrow since you want it ( i spend my free time in another script but will let it apart for a few hours ).

Tcho !
 
Perhaps today or tomorrow since you want it

Errr, if it's just for me then it's no rush :coffee: . I'm currently playing a huge map marathon game that's gonna take a while to finish - which probably ain't gonna happen if you release your mod "too" soon - and my attempts to finish the game at least once will fail ... again :lol: .
 
Errr, if it's just for me then it's no rush :coffee: . I'm currently playing a huge map marathon game that's gonna take a while to finish - which probably ain't gonna happen if you release your mod "too" soon - and my attempts to finish the game at least once will fail ... again :lol: .

Don't worry , I've already begun. That's not a big deal by beginning to do that instead of the other script. :)

Tcho !
 
The mini-MOD is updated for patch 0.32i .

All the function has been rewritten in python :twitch::dubious: (I've lost half of my brain :lol:). The choices are more accurate and it will be easier to update the function with python later if needed.

I've not been able to make a network MP test , but that should be OK. Tell me if you get an OOS right at the beginning of the game with the mini-MOD (I will not be able to check that until a few weeks).

Tcho !
 
I've forgotten to specify what was interesting with the new implementation :):

For both random leader and civ : The function choose the civ first instead of the leader. This result that there is equal chance for all civilizations to appear. With the default process, a civilization with more leaders have more chance to appear.

For the option "unrestricted leaders" : If you let random (any) for both civ and leader, the function choose a matching civ and leader like if the option is OFF. But if only the civ or the leader is random, it's taken at random.

Tcho !
 
You are my hero ... or maybe my nemesis :lol: .

I've started a new game and everything seems to be fine ... ok, I'm a noob - what's OOS?
 
Top Bottom