Civics Dependency Mod

Asaf

Sleep Deprived
Joined
Mar 22, 2010
Messages
1,326
Download here.

This mod comp allows for a civic to have another civic as a prerequisite.
For example: If slavery is defined as vassalage's prerequisite, then you cannot switch to vassalage unless you also switch (or already switched) to slavery.
Appropriate changes were made to the UI to allow only 'legal' civic switches.

A new civic selection algorithm was written for the AI to enable it to switch multiple civics at once when needed so by the dependencies.

The attached XML files contain the example of slavery as a prereq civic for vassalage.

This Mod is based on BTS 3.19.

Notes for Modders:
Spoiler :

XML Changes

The civic infos schema was modified, and you can use the new <CivicPrereq> tag, like this:
Code:
	<CivicInfo>
			<CivicOptionType>CIVICOPTION_LEGAL</CivicOptionType>
			<Type>CIVIC_VASSALAGE</Type>
			<Description>TXT_KEY_CIVIC_VASSALAGE</Description>
			<Civilopedia>TXT_KEY_CIVIC_VASSALAGE_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_CIVIC_VASSALAGE_STRATEGY</Strategy>
			<Button>,Art/Interface/Buttons/Civics/Vassalage.dds,Art/Interface/Buttons/Civics_Civilizations_Religions_Atlas.dds,1,4</Button>
			<TechPrereq>TECH_FEUDALISM</TechPrereq>
			[B]<CivicPrereq>CIVIC_SLAVERY</CivicPrereq>[/B]
			<iAnarchyLength>1</iAnarchyLength>
			...

Python API changes:
(Existing changed methods usage was updated in existing Python code)

- Civic info has a new method: getCivicPrereq() which returns the prereq civic's type (-1 if none).
- CyPlayer::canDoCivics now receives a 2nd parameter - a boolean (bIgnoreDependency): If true, ignores any prereq for this civic, false will check if the prereq is already selected.
- CyPlayer::canRevolution was split to 2 methods:
- CyPlayer::canRevolutionAny() - same as canRevolution(0) was: checks whether revolution is at all possible
- CyPlayer::canRevolutionList(civics) - receives a python list of civics (each corresponds to a specific category) and returns true iff this switch is possible (taking into account dependencies as well).
- API for CyPlayer::revolution was fixed and now it receives a list of civics (same as canRevolutionList).

C++ code
All changes were marked with 'Civics Dependency' comments.
Take a look at the new civics selection algorithm in CvPlayerAI::AI_doCivics() if you're interested.



Credits:

* DannyDaemonic - the fast Makefile (1.0). Downloaded from: http://forums.civfanatics.com/showthread.php?t=370861
* Some code in CvPlayerAI.cpp was taken from Better BTS AI Mod
 
Found a bug in certain cases where the prereq civic could not be selected (for example because of a prereq civic).
Version 0.2 was uploaded to the same place.
 
hey asaf!

how aesome you pulled it off, great work!

i hope i wont have trouble in ,merging this into my mod - overlord2.

also, i gotta do some thinking on what civics will depend on what.

great work, thanks for this.

&#1505;&#1493;&#1508;&#1513; &#1504;&#1506;&#1497;&#1501; &#1488;&#1497;&#1513; &#1497;&#1511;&#1512;.
 
It sounds fantastic! :D:D

Thanks :D

hey asaf!

how aesome you pulled it off, great work!

i hope i wont have trouble in ,merging this into my mod - overlord2.

also, i gotta do some thinking on what civics will depend on what.

great work, thanks for this.

&#1505;&#1493;&#1508;&#1513; &#1504;&#1506;&#1497;&#1501; &#1488;&#1497;&#1513; &#1497;&#1511;&#1512;.

No problem.
If you have any questions on the merging - just ask :)
 
Interesting. Two concerns spring to mind... 1) You will have to be careful not to set prereq civics that are noticeably higher in the tech tree, or else you will have civics that probably cannot be used immediately once they are researched, which would be bad.

2) This has the potential to greatly reduce the value of wonders that unlock all civics in a category. They could be avoided in vanilla, but in my mod for example I have an unlocking wonder for all but one of my 7 civic categories and prereqs would be bound to interfere.

That being said, this is very promising. I'm particularly interested in using prereqs in effect as exclusions to block a combination like Pacifism and Military Training, though it might be better to set up exclusions as a separate mechanic, I dunno. I'll have to give this some more thought later.

p.s. -- Nitram, your avatar dog (or wolf, not sure) is so cute it's hypnotic.
 
I'm particularly interested in using prereqs in effect as exclusions to block a combination like Pacifism and Military Training, though it might be better to set up exclusions as a separate mechanic, I dunno. I'll have to give this some more thought later.

That is interesting. It will require modifications to the AI's civic selection algorithm.
That is also the reason I only did one prereq civic - to not complicate this algorithm too much.
If it's something you're likely to use - I might try adding that when I have the time.
(I enjoy tweaking the algorithm :mischief:)
 
It will require modifications to the AI's civic selection algorithm.

I know all about that... I worked on writing an improved version of it for BBAI last summer before non-Civ stuff claimed my attention, at which point Fuyu took care of it for me (and did a really good job as far as I know... I sorta just copied his code in blindly ;) (though I'm sure he did, cuz he's very good and I trust him)).

If I wind up using any sort of prereq system at all - and I may not - it will have to be based on Fuyu's version (available from his Better BUG AI download which is the unofficial successor to BBAI, at least for now). I'm in the middle of a big update to my mod at the moment and am already behind schedule with a lot left to do, so this may not make it in even if I do decide it's a good idea, but if it did I would need it soon, which means I'll probably just do it myself, but that's fine, it's still your idea. :)
 
hey asaf,

well, i almost merged it perfectly, but i had a problem with one sdk code - cvplayerai.cpp.

its because i merge the files into a revdcm code - that includes the latest better ai code, along with some other civic tweaks made by afforess.

i couldn't merge the large part you made in the middle of the file, for now i marked out all the revdcm part, i hope you can assist with the merge, im attaching the problematic file.

thanks in advance.

edit: i might have a problem with the python civic screen file, since im using one that includes a scroll bar, but that remains to be seen after you can help me and ill compile.
&#1493;&#1514;&#1493;&#1491;&#1492; &#1500;&#1488;&#1500; &#1513;&#1504;&#1490;&#1502;&#1512;&#1493; &#1492;&#1513;&#1512;&#1497;&#1508;&#1493;&#1514;!
 

Attachments

  • CvPlayerAI.zip
    126.7 KB · Views: 251
Where can I get the other source files with the RevDCM+Afforess code?
I can't really compile this file as a stand alone.

And you should probably also attach the CvPlayerAI.cpp without my changes. It'll help me see what was there without my code and what I need to change.

I probably won't get to it before Tuesday.

&#1489;&#1512;&#1493;&#1498; &#1492;&#1513;&#1501; :)

EDIT: I also noticed some of Fuyu's new code, which I don't know and should probably check.
It might not be able to coexist with my code...
 
Can someone adapt this for Warlords?

I don't imagine this being too difficult, but I have no idea which relevant changes were made to the code from Warlords to BTS, and I don't really work on the Warlords code base.

You could try this yourself, or maybe someone else would be willing to help you with this.
 
EDIT: I also noticed some of Fuyu's new code, which I don't know and should probably check.
It might not be able to coexist with my code...

No, it won't coexist. As I said, I'd need a version based on Fuyu's code. That's why I said it. ;)

Can someone adapt this for Warlords?

As far as I know, NO ONE maintains pre-BTS versions of ANYTHING any more. BTS is like $5-10 at this point dood, and it's a huge upgrade/improvement to the game. Asking modders to take significant extra time to support something that only a few people would use, that's completely inferior, and that you can fix on your end almost for free is not fair to the modders. ... Just saying.
 
hey buddy,

ok so heres two parts of my source code,
19 is without the civics dep' and 20 is with it.

for now the compile crashes at playerai.cpp.

i dont mind to disable the fuyus code for having your civic system.

hope youll find a solution :)

http://uploading.com/files/eac7c798/overlord2.3.9-19+20.exe/
 
I edited CvPlayerAI.cpp and now it compiles.
I had to comment out Fuyu's code in CvPlayerAI::AI_doCivics(). Hope it doesn't cause any problems.

Note that other changes I made for this mod require adding 'const' in a couple of places for compilation - in the functions added for 'BUG - Revolution Event' (last parameter should become const).

Let me know how that's working out.
 

Attachments

  • CvPlayerAI.7z
    102.5 KB · Views: 256
thank you my good friend!

i very much appreciate your help.

about the const - well - if you refer to other files, i guess i added it in, since i merged in all the changes i hope.

i will try to compile in a day or two and report.

i waited for this and halted my mods progress cause i really want this awesome code.


&#1504;.&#1489;
&#1512;&#1493;&#1510;&#1492; &#1500;&#1492;&#1493;&#1505;&#1497;&#1507; &#1488;&#1493;&#1514;&#1497; &#1489;&#1508;&#1497;&#1497;&#1505;&#1489;&#1493;&#1511; &#1488;&#1493; &#1502;&#1513;&#1492;&#1493;?
&#1488;&#1504;&#1497; &#1502;&#1499;&#1497;&#1512; &#1502;&#1506;&#1496; &#1497;&#1513;&#1512;&#1488;&#1500;&#1497;&#1501; &#1513;&#1488;&#1493;&#1492;&#1489;&#1497;&#1501; &#1505;&#1497;&#1489;,
&#1502;&#1497; &#1497;&#1493;&#1491;&#1506; &#1488;&#1493;&#1500;&#1497; &#1488;&#1508;&#1513;&#1512; &#1490;&#1501; &#1500;&#1506;&#1513;&#1493;&#1514; &#1488;&#1497;&#1494;&#1492; &#1502;&#1513;&#1495;&#1511; &#1499;&#1499;&#1492; &#1502;&#1514;&#1497;&#1513;&#1492;&#1493;.

:)
 
thank you my good friend!
about the const - well - if you refer to other files, i guess i added it in, since i merged in all the changes i hope.

These are functions that were not in the original SDK (as I said - added for 'BUG - Revolution Event'), so these changes do not appear in the merges.

&#1504;.&#1489;
&#1512;&#1493;&#1510;&#1492; &#1500;&#1492;&#1493;&#1505;&#1497;&#1507; &#1488;&#1493;&#1514;&#1497; &#1489;&#1508;&#1497;&#1497;&#1505;&#1489;&#1493;&#1511; &#1488;&#1493; &#1502;&#1513;&#1492;&#1493;?
&#1488;&#1504;&#1497; &#1502;&#1499;&#1497;&#1512; &#1502;&#1506;&#1496; &#1497;&#1513;&#1512;&#1488;&#1500;&#1497;&#1501; &#1513;&#1488;&#1493;&#1492;&#1489;&#1497;&#1501; &#1505;&#1497;&#1489;,
&#1502;&#1497; &#1497;&#1493;&#1491;&#1506; &#1488;&#1493;&#1500;&#1497; &#1488;&#1508;&#1513;&#1512; &#1490;&#1501; &#1500;&#1506;&#1513;&#1493;&#1514; &#1488;&#1497;&#1494;&#1492; &#1502;&#1513;&#1495;&#1511; &#1499;&#1499;&#1492; &#1502;&#1514;&#1497;&#1513;&#1492;&#1493;.
:)

&#1514;&#1493;&#1491;&#1492;, &#1488;&#1489;&#1500; &#1488;&#1504;&#1497; &#1500;&#1488; &#1495;&#1493;&#1489;&#1489; &#1508;&#1497;&#1497;&#1505;&#1489;&#1493;&#1511; &#1490;&#1491;&#1493;&#1500;...
 
Top Bottom