View Full Version : [Mini MOD _ MOD Comp] Alignment Options


Sto
Mar 27, 2008, 06:07 PM
Alignment Options is a mini playable MOD MOD . The Mod choose random leaders in function of the options chosen .

It adds 3 SG Options and 2 MP options (in the SG menu to be available for hotseat games) :

_ Religion war (The players cannot convert any more with a religion which makes change their alignment or research the associated technology. These religions are not spread automatically any more in the cities. Only the elves can convert with the religion Fellowship of the Leaves.)
_ equilibrate the alignments
_ teams have the same alignment

_ equilibrate human alignments
_ all humans get the same alignment

3 new leaders added (random good or neutral, random good or evil, random neutral or evil)


Install Instructions :

_ Download the MOD Comp and unzip it ( for FFH2 0.32l ) (http://forums.civfanatics.com/downloads.php?do=file&id=8889)
_ copy the FFH2 folder and rename it like you want "FFH 2 032 AO" for an example
_ copy the folder "Assets" (located in the unzipped folder) into the new MOD folder ("FFH 2 032 AO"). You should replace some files .
_ Load the mod to play.

Notes :

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.

With the default selection and some complicated selection. You can have 2 times the same civ with another one that would fit but not selected. This can't happen with the mini-MOD.

The selection takes in count the civ playable for human players and the civ AIplayable for AI players. The default one don't take that in count (This is not a big problem except if you have customized the civs to keep AIs or Humans non randomly selectable for some civ).

Notes for Modders :

There is a file change log in the folder and the source files if you want to merge it in another MOD MOD .


Tcho !

07/05/2008 : Update for patch 0.32l

xienwolf
Mar 27, 2008, 07:16 PM
People have been nearly begging for this for at least a year :) You are awesome Sto :)

(And yes, this is totally going in my sig!)

Sto
Mar 27, 2008, 07:48 PM
People have been nearly begging for this for at least a year :) You are awesome Sto :)

(And yes, this is totally going in my sig!)

Thank you :). This is my first creation with the SDK ( i learn C++ ) . And i really wanted to be able to randomize the alignment selection too . This was on the top of my to do list and i'm really happy to have done it .

Tcho !

xienwolf
Mar 27, 2008, 07:53 PM
A thought just occured: You said that you hardcoded the leaders and Civs.... So shouldn't you make it disable the option "Unrestricted Leaders?" There may be some nasty consequences of someone trying to use that function with this modcomp.

Sto
Mar 27, 2008, 07:56 PM
A thought just occured: You said that you hardcoded the leaders and Civs.... So shouldn't you make it disable the option "Unrestricted Leaders?" There may be some nasty consequences of someone trying to use that function with this modcomp.

The option "Unrestricted Leaders" is taken in count in the implementation . Also if you choose a civ but not the leader , this is taken in count in the implementation .I've tried to take care of all possible cases . But i will probably upgrade the function while playing and making some tests ... and learn C++ :D

edit : Also , i don't think that disabling the unrestricted leader will make the initilization of the xml attributes , so the problem is the same .

Bitwise
Mar 28, 2008, 08:14 AM
I can't wait to try this. Nice work.

Victorvanwavere
Mar 28, 2008, 11:20 AM
Awesome!!,

I hope Kael will conceder adding this to the official mod.

Thx Sto.

Demus
Mar 28, 2008, 11:29 AM
Also if you choose a civ but not the leader , this is taken in count in the implementation .I've tried to take care of all possible cases .

I don't know much about modding, so i don't know how this check is handled, and i've yet to test it, but be careful with the Ljos: their leaders have different alignments! Could cause some nasty hick-ups if you're checking by civ instead of leader.

Sto
Mar 28, 2008, 12:00 PM
Awesome!!,

I hope Kael will conceder adding this to the official mod.

Thx Sto.

For the moment this is impossible i think because of the number of options . And especially because the MiniMod is not dynamical (i'm working on that) .


I don't know much about modding, so i don't know how this check is handled, and i've yet to test it, but be careful with the Ljos: their leaders have different alignments! Could cause some nasty hick-ups if you're checking by civ instead of leader.

Don't worry I check possible leader alignment of the civ . If for an example you choose to play a random leader in a team with the Ljos ( good or neutral ) and you want that the team get the same alignment . your leader is chosen first ( all humans are chosen first ) , you will have an alignment good or neutral . And then the Ljos will get the matching leader . Let's also suppose a silly case , you have chosen an AI in another team with the good Ljos leader . You will get a neutral leader , the Ljos in your team will get the neutral Ljos leader .

I've not fully tested all possibilities , but the way it is modded makes that it should not create a wrong selection ( instead of trying to get a good selection ) . If the implementation can't achieve to select a leader for a player , it skip and let random for this player . Then go to the next player (and in this case this is probably because there is no possibility for the requirement and the civ random selection will not match with what you asked) .

Tcho !

Sto
Mar 28, 2008, 06:43 PM
I've removed the hardCode of the leader civs . In fact this was just an error of a variable declaration :rolleyes: . So the dll is compatible with every MOD MOD (if there is no Dll in) , you have just to merge the xml .

Tcho !

Sto
Mar 28, 2008, 10:52 PM
A new option added i will like to play with the other options : religion war .

The players cannot convert any more with a religion which makes change their alignment or research the associated technology. These religions are not spread automatically any more in the cities. Only the elves can convert with the religion Fellowship of the Leaves.

Tcho ! :)

Demus
Mar 29, 2008, 05:06 AM
sounds awesome :). But you can still send missionaries out to a civ with a different alignment? Or won't you be able to spread CoE (for example) to a good civ at all. Are just the players blocked from switching, or the AI civs aswell?

Jean Elcard
Mar 29, 2008, 05:50 AM
Really nice. A wish came true, without conflicting with my own lazyness.

Sto
Mar 29, 2008, 09:09 AM
sounds awesome :). But you can still send missionaries out to a civ with a different alignment? Or won't you be able to spread CoE (for example) to a good civ at all. Are just the players blocked from switching, or the AI civs aswell?

Yes you can still send missionaries to an ally with an alignment that cannot adopt anymore this religion ( with this option ON ). But this religion will just stop spreading in this civ but not in yours .
For an example you have RoK , the RoK religion will still spread in the (good , neutral) cities but not in the evil ones . You can send disciple to spread the religion . But the player will not be able to adopt the RoK religion . the evil civ can't research anymore the RoK tech . I've not seen how CoE is spread with the last version (i've played only two guick games) , but if this like 0.30 , CoE will not spread to good civ and if none of your units can spread it , a good civ will not be able to have CoE (except by conquering a CoE city ). This effect is applied to all civilization (AI and Human) .

But this option is made to force civs ( a little ) to group by alignments and increase the war games . I will not try this option with some starting teams that have different alignments , however the players can still group with others ( that will just be less frequent between civ with different alignment)

We will do our first game tonight , so i will be able to tell more about the consequences in a few days .

Really nice. A wish came true, without conflicting with my own lazyness.

Thank you , we plan to do our first MP game tonight , with two allied evil human against 3 ai teams of 2 good players with religion war ... should be challenging .

Tcho !

Edit : i wil concentrate now in the map script , and try to add an option that makes group the civs by alignment ( however impossible to add as a game option ). This should be nice with this option .

Sto
Mar 30, 2008, 01:26 PM
Some MP tests have been done ... NP

About the religious war option . We have played 12h , MP game human team (got the svartalfar and my friend the calabim ) , we settle at the opposite of a big pangaea with 3 teams of 2 good leaders . After 200 turns , half of the AI run ROK and the others the order . We were attacked 3 times ... now every AI have entered the over council . Our defenses are ready :) waiting for the hordes .

Edit : each AI teams have open borders obviously . They spread each religion in all the cities (RoK , FoL and order . Empyrean begin to be spread ...)

Tarquelne
Apr 01, 2008, 07:33 AM
I like the Religion War option!

Though... could you make it so that a civ can change religions as part of a peace settlement? So a civ won't change from Good to Evil, say, on it's own, but it can if forced?

Sto
Apr 01, 2008, 07:55 AM
I like the Religion War option!

Though... could you make it so that a civ can change religions as part of a peace settlement? So a civ won't change from Good to Evil, say, on it's own, but it can if forced?

You mean for vassal , or by diplomacy ? I will try to check that , but this seems not so easy to do at the first look .

Tcho !

Tarquelne
Apr 01, 2008, 08:38 AM
You mean for vassal , or by diplomacy ? I will try to check that , but this seems not so easy to do at the first look .

Certainly by vassal. And by diplomacy, but you could probably only get enough err... "leverage" at the end of a war.

Thanks for checking! I was thinking it sounded difficult.

But hmm... if you use the leaderheads file to give leaders high (50+?) negative modifiers for religions that are of other alignments, then just making switching possible again might work.

The other changes you made will keep a religion from spreading inappropriately. It'd take some effort with Disciple units, and probably diplomatic efforts to get an open border. So you should rarely see a civ change to a non-alignment religion because it wants to. (And never without effort on someone's part.) But, if it's possible, a civ might switch if it's that or lose several more cities in a war.

"Convert or die!" Heh heh heh. :)

Sto
Apr 01, 2008, 09:19 AM
Thanks for checking! I was thinking it sounded difficult.

Yes , for me it sounds difficult for the moment :) . The option result in 3 peaces of code in the SDK that say "no , you can't" if the option is ON .

But hmm... if you use the leaderheads file to give leaders high (50+?) negative modifiers for religions that are of other alignments, then just making switching possible again might work.

The other changes you made will keep a religion from spreading inappropriately. It'd take some effort with Disciple units, and probably diplomatic efforts to get an open border. So you should rarely see a civ change to a non-alignment religion because it wants to. (And never without effort on someone's part.) But, if it's possible, a civ might switch if it's that or lose several more cities in a war.

I can't do that by xml , simply because this not becomes an option anymore . But i will take your advises and learn how diplomacy work in the SDK . I will try to intercept the religion AI modifier and make some tests to change the function by modifying these values when the option is ON . But this will take some times , i think . I'm on another mod for the moment ... and not ready to learn how diplomacy works :crazyeye:.

I will begin to test a game with your XML changes ,to check if this is enough .

Tcho !

Edit :
For vassals , this should not be too hard to do , just check if the civ that have the vassal has a state religion and allow in this case the civ to convert , research the religion .
With the recent SG game i've done , i've noticed also that i need to change to AI modifiers toward alignments . Because if you become too powerfull , or take a little advantage , lots of AI wants to makes open borders with you (regardless of your alignment) .

Tarquelne
Apr 01, 2008, 09:49 AM
Super! Thanks for telling me about it. I'm glad that vassals should be do-able. And I'm really looking forward to trying your mod even without any further changes. Anything else is just gravy. Well, _more_ gravy. :)

I suspect I'm going to be breaking my "only play FFH2 multiplayer" rule pretty soon... (Silly LAN partners with their "papers" and their "jobs". They've got no sense of proportion - We haven't tried a single .31 game yet! ;))

Mailbox
Apr 02, 2008, 06:38 PM
This is absolutely awesome, too bad the main mod doesn't have it.

Sto
Apr 10, 2008, 01:59 PM
Files updated for patch e .

Tcho !

Corlis
May 20, 2008, 03:08 PM
This is absolutely awesome, too bad the main mod doesn't have it.Oh heck yes, it beats playing a good leader and then getting stuck a whole bunch of other good leaders, where all I really wanted was a good rollicking holy war!

If I could make a suggestion, it would be nice if we could select the alignment of our opponents via the leader selection drop-down menus instead. What I mean is that just between the "Random" option and the actual leaders in the drop-down, you'd also have the options "Random - Any Good", "Random - Any Neutral", and "Random - Any Evil". Thus you could set the first, second, and third AIs to be Evil so you get a challenge, but keep the fourth AI Good or Neutral so you have a potential ally. Of course, maybe this is impossible, I really don't know, so it's just a thought.

Anyhow, thanks for all your work on this!

Demus
May 20, 2008, 03:51 PM
heh, i haven't even got the vanilla FFH linked to my desktop anymore, it's eighter FF or FFH: AO. I love the holy war option on this, expecially when used in combination with varied world.

Sto
May 20, 2008, 04:26 PM
Super! Thanks for telling me about it. I'm glad that vassals should be do-able. And I'm really looking forward to trying your mod even without any further changes. Anything else is just gravy. Well, _more_ gravy. :)

I've still not checking that. But i will do that after the map script (http://forums.civfanatics.com/showpost.php?p=6479814&postcount=252), when all options will be finished. Especially ffh options (lair, unique improvements, cultural linked positions)

Oh heck yes, it beats playing a good leader and then getting stuck a whole bunch of other good leaders, where all I really wanted was a good rollicking holy war!

If I could make a suggestion, it would be nice if we could select the alignment of our opponents via the leader selection drop-down menus instead. What I mean is that just between the "Random" option and the actual leaders in the drop-down, you'd also have the options "Random - Any Good", "Random - Any Neutral", and "Random - Any Evil". Thus you could set the first, second, and third AIs to be Evil so you get a challenge, but keep the fourth AI Good or Neutral so you have a potential ally. Of course, maybe this is impossible, I really don't know, so it's just a thought.

Anyhow, thanks for all your work on this!

This is a good idea. I will think about that (try to add six phantom leaders). I still don't know if this is possible, that will requires some work and tests ... and also to redesign the options . That should be not so hard, but that depend on civilization initialization (the part that is not in the sdk).

heh, i haven't even got the vanilla FFH linked to my desktop anymore, it's eighter FF or FFH: AO. I love the holy war option on this, expecially when used in combination with varied world.

For the 0.32 , i will try to compile also a version for Fall Further (because this is the most played MOD that require a dll (if not mistaken), other MODs are easy to merge). But I've still not played a game with it. I usually don't play very much SG games and I've added a lot of stuff in my personal MP version (python _ SDK) that take a lot of time to combine with other patch and MODMOD ... like birds selected first, most of wonder national , timed settler at the beginning of the game, alternative armaguedon events ,a lots of python and xml "details" we like to change to balance the game for conquest games only.

Tcho !

Sto
May 20, 2008, 04:52 PM
Thus you could set the first, second, and third AIs to be Evil so you get a challenge, but keep the fourth AI Good or Neutral so you have a potential ally. Of course, maybe this is impossible, I really don't know, so it's just a thought.

Anyhow, thanks for all your work on this!

I was just thinking there is a way to play like that I use sometimes. Instead of launching a SG game, set up a hotseat game with 2 human , 3 AI. Select the options to have human good or neutral (varied world or not as you wish), AI evil . Then at the start of the game, simply retire the human player you want to be your ally (be carefull , i think you need to construct the city to prevent a WOC and don't move all the player units or you will loose a turn).

Tcho !

Edit : There is something else to notice very important : when you are the last player in an hotseat game , the event aren't noticed anymore on the top of the screen . You need to check the event log window every turn. They are printed in.

Demus
May 26, 2008, 11:42 AM
will this still work with 0.32?

Sto
May 26, 2008, 11:53 AM
will this still work with 0.32?

No the current version doesn't work with 0.32. By now, I rewrite the function. I wanted to do that today but I've not finished . All is ready, I need to do the main function now. Because of Decus, i can't compile the last version, this should have make some bugs (the last version doesn't take in count a leader available with multiple civ). So I've decided to change a lot the way of the mini MOD. I've created a random civ and 6 random leaders (random good, random good or neutral, ...), Like Corlis suggestion. And I've also move the 2 MP options to SG options to make them available in HotSeat games. I will give it a shot tonight i think. But the function get more complicated with this. I also need to check some options and change some other to prevent this leaders and civ to appear during the game. The result should be great instead of having all AI no good etc ...

Tcho !

xienwolf
May 26, 2008, 01:08 PM
It will be a touch tricky deciding how to use Decius. On turn 1 he is offered an option to select his alignment, so he is technically not aligned at all and can mess up your selection schema. Though only having 1 wildcard shouldn't cause any major complaints.

MagisterCultuum
May 26, 2008, 01:12 PM
Before the event, he is neutral. Although he could slip though as good or evil in a game where you waned him to be neutral, I don;t think it is that big of a deal. It woule be more of a problem in a modmod using broader alignments (I don't think the event would work)

Sto
May 26, 2008, 01:26 PM
It will be a touch tricky deciding how to use Decius. On turn 1 he is offered an option to select his alignment, so he is technically not aligned at all and can mess up your selection schema. Though only having 1 wildcard shouldn't cause any major complaints.

Before the event, he is neutral. Although he could slip though as good or evil in a game where you waned him to be neutral, I don;t think it is that big of a deal. It woule be more of a problem in a modmod using broader alignments (I don't think the event would work)

Thank you for the info. I didn't know , I've not played a 0.32 game yet. I think I will let Decus neutral and don't disable the event. Perhaps if someone want Decus to be forced neutral, I will add an option. But for now , i have a big headache and still don't know how I will structure the function :cry:.

I want to add also a new event (optional) that add a player during the game, if the alignment balance is too much on a side. That will be also to test a lots of stuff to make the random leader and civ unavailable during the game. But I need to finish this main function first.

Tcho !

Sto
May 27, 2008, 03:51 PM
The version for 0.32a is out.

There are only 5 options (religious war, varied world, team same alignment, humans different alignment, humans same alignment). 6 "random leaders" have been added to randomly choose alignment. They are available in "custom game" or "play now" menu (I love the play now menu :love:) or even for a scenario .

The 2 MP options has been moved to the SG options, so they are available for HotSeat games.

A little fix included : Hyborem, Basium and Kourt can't be selected at random anymore if you let random with the option "unrestricted leaders".

Yeah , I can play now :)

Tcho !

PS : the next time , I will try to export this function to python to make the changes and selections more simple and accurate. This way anyone will be able to make its own changes.

Corlis
May 27, 2008, 07:50 PM
Awesome!

I was wondering how Decius could possibly be handled, and I guess there isn't really any easy way to do it. Ah well, thanks for your work on this!

Sto
May 28, 2008, 04:41 AM
Awesome!

I was wondering how Decius could possibly be handled, and I guess there isn't really any easy way to do it. Ah well, thanks for your work on this!

I've let Decus neutral (like in the xml). There is no special choice for him. I don't think this is a major issue. The biggest problem was to consider a leader that is available for more than one civilization.

Tcho !

Kael
May 28, 2008, 02:42 PM
Reactions:

Sto made a modmod, neat
What in the world?
How in the world!?!
...Oh my god this is awesome!

Very cool Sto, do you mind if I integrate this in patch "b"?

MagisterCultuum
May 28, 2008, 03:46 PM
I think you should take his silence as "I would be much more upset if you do not add it to the main mod!" :D :p

I haven't actually had time to play this modmod yet, but it is something that I (among others) have been requesting for quite some time. I was planning to integrate it in my modmod (along with xienwolf's xml modcomp, broader alignments, etc), but I'd rather you do all the work for me. (Well, maybe not all the work. Not that I'd mind if you added those other mods too, but since Vehem added them to Fall Further I can rip off his .dll just as easily)



You may want to consider implementing FFHBUG too. Unfortunately, the mouseover bug that vanilla FfH had (inherited from PLE) is stil present. Also, renaming the mod causes problems.

Sto
May 28, 2008, 04:16 PM
Reactions:

Sto made a modmod, neat
What in the world?
How in the world!?!
...Oh my god this is awesome!

Very cool Sto, do you mind if I integrate this in patch "b"?

Yes, sure that will be pretty cool :).
Some things to notice if you want to integrate it with patch b or for future. Like you can see ,if you have taken a look at the main function in CvGame::init , I'm still not very good with C++, but everything is tested and functional. The problem I've got was to define a list of numCiv or numLeader lenght. That's not a big issue i've put 100 and 300.
The main problem is that I can't do some quality test in C++ (too boring and hard to manage list and arguments with C++). It result that the function will ever found a solution if possible, but not the better in some cases , ie :

_ The civ with more leaders have more chance to appear.
_ Because of some combinations, sometimes all leaders can't match all conditions. In some few cases, even if that would have been possible. Especially when there are a lot of players.

I will try to rewrite the mini MOD and export this function to python. I think that will be better to do some quality and make the changes more accurate. Anyway that's great if you integer the mini MOD to FFH :). I'll tell you if i achieve to export the function to python.

Tcho !

Sto
May 28, 2008, 04:26 PM
I've forgotten a little thing to fix i wanted to integer with patch b : in CvGame::init : line 1124

//leader assignment
if (iBestLeader != -1)
{
if (!isLAC)
{
if (!bCivSelected)
{
nCivAssigned[iBestCiv] += 1;
}
GC.getInitCore().setCiv((PlayerTypes)iPlayer, (CivilizationTypes)iBestCiv);


If not that can prevent a civ to have a second leader if the civ is selected by the player but not the leader (when there is lots of player and a lot of same alignment requested). Since this is not a big issue , i wanted to fix it with patch b.

Tcho !

MagisterCultuum
May 28, 2008, 07:43 PM
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 last part is unrelated to the main point of the modmod, but it would probably be found in the same part of the code so I'll mention it anyway: could you remove the "Two cities on the same seperate continent" requirement from colony liberation? I've never liked or understood this requirement, and think it is even worse in FfH. (The Lanun should really be able to liberate their landlocked cities and keep the coast, for example.) I tried removing this requirement myself (making so you can liberate any individual city, but only single cities, as colonies. Other cities could then be gifted/liberated to the colony.) about 6 months ago (based on this (http://forums.civfanatics.com/showpost.php?p=6099438&postcount=6)), but it didn't work (no colonies could ever be liberated). Oh, and you should really be allowed to just gift a city to your vassal (with do diplomatic bonus, the same way as to any other civ) instead of being limited to liberating cities to them.

Kael
May 28, 2008, 07:55 PM
This is my take on your code in CvGame::init:


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;

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).i sAIPlayable())
{
for (int iLeader = 0; iLeader < GC.getNumLeaderHeadInfos(); iLeader++)
{
if (GC.getCivilizationInfo((CivilizationTypes)iCiv).i sLeaders(iLeader))
{
if (GC.getLeaderHeadInfo((LeaderHeadTypes)iLeader).ge tAlignment() == 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;
}
}


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.

Sto
May 28, 2008, 08:43 PM
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 :

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;
int iNumLeader = 0;

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).i sAIPlayable())
{
for (int iLeader = 0; iLeader < GC.getNumLeaderHeadInfos(); iLeader++)
{
if (GC.getCivilizationInfo((CivilizationTypes)iCiv).i sLeaders(iLeader))
{
if (GC.getLeaderHeadInfo((LeaderHeadTypes)iLeader).ge tAlignment() == iAlignment)
{
iNumLeader = std::min(4, GC.getCivilizationInfo((CivilizationTypes)iCiv).ge tNumLeaders());
iValue = 40000 + GC.getGameINLINE().getSorenRandNum(1000, "Random Leader") - (iNumLeader * 75);
for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
if (GC.getInitCore().getLeader((PlayerTypes)iI) == iLeader)
{
iValue -= 10000;
}
if (GC.getInitCore().getCiv((PlayerTypes)iI) == iCiv)
{
iValue -= 2000;
}
}
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.

Kael
May 29, 2008, 08:36 PM
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.


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.getInitCo re().getLeader((PlayerTypes)iPlayer)).getAlignment ();
for (int iCiv = 0; iCiv < GC.getNumCivilizationInfos(); iCiv++)
{
if (GC.getCivilizationInfo((CivilizationTypes)iCiv).i sAIPlayable())
{
for (int iLeader = 0; iLeader < GC.getNumLeaderHeadInfos(); iLeader++)
{
if (GC.getCivilizationInfo((CivilizationTypes)iCiv).i sLeaders(iLeader))
{
if (GC.getLeaderHeadInfo((LeaderHeadTypes)iLeader).ge tAlignment() == 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;
}
}
}

MagisterCultuum
May 29, 2008, 08:47 PM
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?

xienwolf
May 29, 2008, 09:21 PM
If you got a relation penalty for having the Infernal Grimoire, you'd just have a unit pick it up... boom, no problem.

Sto
May 30, 2008, 03:20 AM
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

MagisterCultuum
May 30, 2008, 03:28 AM
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)

Sto
May 30, 2008, 03:30 AM
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 .

Kael
May 30, 2008, 07:49 AM
Heres an updated one that seems to resolve the good/neutral/evil picking problem.


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)iPla yer) == SS_COMPUTER) || (GC.getInitCore().getSlotStatus((PlayerTypes)iPlay er) == 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.getInitCo re().getLeader((PlayerTypes)iPlayer)).getAlignment ();
}
for (int iCiv = 0; iCiv < GC.getNumCivilizationInfos(); iCiv++)
{
if (GC.getCivilizationInfo((CivilizationTypes)iCiv).i sAIPlayable())
{
for (int iLeader = 0; iLeader < GC.getNumLeaderHeadInfos(); iLeader++)
{
if (GC.getCivilizationInfo((CivilizationTypes)iCiv).i sLeaders(iLeader))
{
if (iAlignment == -1 || GC.getLeaderHeadInfo((LeaderHeadTypes)iLeader).get Alignment() == 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;
}
}
}
}

xienwolf
May 30, 2008, 07:54 AM
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.

Sto
May 30, 2008, 01:43 PM
Update 0.32d in the first post .

Tcho !

Sto
Jun 08, 2008, 06:54 AM
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 !

pimparel
Jun 08, 2008, 07:01 AM
In religion war, I got a forbidden religion tech from the eyes and ear wonder.

EDIT: It was with patch d

Sto
Jun 08, 2008, 07:33 AM
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 !

xalien
Jul 01, 2008, 02:28 AM
Any chance to have this gem for a "i" patch?

Sto
Jul 01, 2008, 04:43 AM
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 !

xalien
Jul 01, 2008, 06:06 AM
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: .

Sto
Jul 01, 2008, 06:10 AM
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 !

Sto
Jul 01, 2008, 11:20 AM
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 !

Sto
Jul 01, 2008, 01:03 PM
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 !

xalien
Jul 01, 2008, 01:27 PM
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?

Sto
Jul 01, 2008, 01:35 PM
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?

When you play a network MP game. If the statement of the game is different for two players (all machines run the code), the game show an Out Of Synchronization error. So the players have to reload the game to continue playing.

Tcho !

MagisterCultuum
Jul 01, 2008, 01:43 PM
what's OOS?

Out of Sync error - a bug that only occurs in multiplayer games, caused when some sort of information isn't conveyed to all the players' computers. It causes games to diverge.

Demus
Jul 01, 2008, 03:57 PM
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.

how will this work for the good elven queen (i recon the civ gets picked as being a "neutral" civ, but with the possibility of a good leader)? Could offset the balance, expecially on a map with a few leaders (duel, tiny or small).
I take it decius is left out of the equation? Or is he handled as neutral?

Still loving this modmod by the way, keep it up!

Sto
Jul 01, 2008, 04:05 PM
how will this work for the good elven queen (i recon the civ gets picked as being a "neutral" civ, but with the possibility of a good leader)?

I pick civ that have an available leader of the alignment(s) required for the player. So there is no problem with that.

I take it decius is left out of the equation? Or is he handled as neutral?

Decius count as neutral for the moment. I will check how the alignment is chosen for the AI with Decius (forgot that).

Tcho !

Sto
Jul 01, 2008, 04:46 PM
I've checked the AI alignment of Decius. This is random. So there is 2 solutions :

_ I let Decius as neutral in the function. I can't make him no alignment so it will never be chosen.

_ I can force Decius to be good for bannor, neutral for malakim and evil for the calabim when the AI handle the alignment choice event. But that will still make a difference if Decius is selected with an human player.

I can't think about a good solution with Decius. Do you think about a good solution ?

Tcho !

Sto
Jul 05, 2008, 04:30 AM
Update for version 0.32j.

Tcho !

EDIT : I've tried to integer the Kael Assimilation MOD. But I've got a CtD when trying to make a queue in my first city ... so that should not so easy to merge with FFH.

Sto
Jul 05, 2008, 10:53 AM
Update for patch 0.32l.

Tcho !

Sto
Jul 06, 2008, 11:35 AM
Some Multiplayer tests have been done --> No Problemo with the new python function.

Tcho !

xalien
Jul 08, 2008, 05:57 AM
I got Decius while playing with "i" version. He's evil ... Banor. He likes me for being evil and treating my people well at the same time. He's very unhappy about me using entropy and death mana. Very weird civ.

Sto
Jul 08, 2008, 07:41 AM
I got Decius while playing with "i" version. He's evil ... Banor. He likes me for being evil and treating my people well at the same time. He's very unhappy about me using entropy and death mana. Very weird civ.

I don't know what to do with Decius ( see posts below ). I've decided to let him count as neutral in the implementation. Even if I force the alignment of Decus for AI player ,the problem with still keep with Human player. So ... if you have a good idea.

Tcho !

xalien
Jul 08, 2008, 07:57 AM
I've read those posts but I didn't quite understand what is the problem with him:

_ I can force Decius to be good for bannor, neutral for malakim and evil for the calabim when the AI handle the alignment choice event. But that will still make a difference if Decius is selected with an human player.

What is the alignment choice event and what exactly would go wrong if he gets picked up by the human player?

Sto
Jul 08, 2008, 08:03 AM
The alignment of Decius is chosen by the player when the game start, and randomly for AI with an event. Even if I do like described below, the human Decius can break a selection. And i like the way decius can be good, neutral or evil with these civs (and even don't want to break these possibilities).

The thing i can do is perhaps to choose the alignment of decius for AI during the leader choice and force it after when the event comes !?

Tcho !

MagisterCultuum
Jul 08, 2008, 08:11 AM
You could also make it so that he isn't included in the random_good, random_neutral, or random_evil lists, right? that way you could still get him if you choose him or if you just choose random, but are still guaranteed leaders of the alignment you want.

Sto
Jul 08, 2008, 08:14 AM
You could also make it so that he isn't included in the random_good, random_neutral, or random_evil lists, right? that way you could still get him if you choose him or if you just choose random, but are still guaranteed leaders of the alignment you want.

No, i can't do that. random is like random good, neutral or evil in my impl. That's because of the options to equalize alignments and grant same alignments for teams.

Sto
Jul 12, 2008, 07:32 AM
I think i will do that for Decius :

if one of option to equalize alignment is ON (varied world, equalize team && team game, (singularity or plurality) && MP game). The alignment of Decius will be forced whatever you choose in the event.

Any comment for this choice ? (If not , i will do that for the next version)

Tcho !