[MODCOMP] Building Civic Prereqs

Dom Pedro II said:
Agreed.. it is important though that if not removed, the buildings must at least become inactive... (i prefer inactive to removed anyway)

Because otherwise, my Secret Police HQ will continue to rain fear and terror down upon the populace of my Representative Democracy instead of my Police State :)

Exactly my point, too. In theory, if somebody wanted to use all the civic-specific buildings in all the game, all they'd have to do is have revolution after revolution... pretty soon their empire could utilize EVERY special civic building in the game... and that would really unbalance things.


zypher said:
Just my opinion, but if the building goes inactive or not should be controlled by an extra tag.

Something like
<PrereqCivic>CIVIC_ORGANIZED_RELIGION</PrereqCivic>
<DisableWithoutPrereq>1</DisableWithoutPrereq>

Something like this would be a great idea, even for the Civic-specific units mod. It looks simple enough to add...but I don't know a thing about C++ so it might be a bit of a pain to code though.
 
Ok, updated the mod to v0.2
 
Updated Warlords version to be compatible with the v2.0.8.0 patch.
 
just small note: checking for civic prereq is now in CvCity::canConstruct
more logical is do this in CvPlayer::canConstruct (already called from CvCity)
- here is all global conditions checked (like state religion prereq, tech prereq, obsolete buildings etc...). In CvCity is only city-related tests

BUG FOUND:
when you have also other conditions for obsolete building, this component create a bug:
let say that you have prereq civic for building and obsolete tech
1. you have active building (no obsolete tech researched, prereq. civic is active - getObsoleteBuildingCount() = 0)
2. you research obsolete tech -> your building become inactive, getObsoleteBuildingCount() = 1
3. you change civic, BUT because you already have building marked as obsoleted, counter is not increased:
(yes i know, removing this condition make a bug that building become obsolete from start because of player initialization, when all civics are processed)
Code:
Relevant code from CvPlayer::processCivic()
		if(bRequiresCivic && [B]!GET_TEAM(getTeam()).isObsoleteBuilding((BuildingTypes)iI)[/B])
		{
			GET_TEAM(getTeam()).changeObsoleteBuildingCount((BuildingTypes)iI, 1);
		}
4. when you switch back, counter is decreased, so building become active again - even if you have obsolete tech researched


SOLUTION:

1.for CvPlayer class create boolean variable (i name thi m_bNoInitial, initial value True), which is set in CvPlayer::init() when setting initial civics to False
Code:
[B]		m_bNoInitial = false;[/B]
		for (iI = 0; iI < GC.getNumCivicOptionInfos(); iI++)
		{
			setCivics(((CivicOptionTypes)iI), ((CivicTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationInitialCivics(iI))));
		}
[B]		m_bNoInitial = true;[/B]

2.processCivics condition is changed to:
Code:
if(bRequiresCivic && (m_bNoInitial || !GET_TEAM(getTeam()).isObsoleteBuilding((BuildingTypes)iI)))
if it is initial process, old condition is used, if it is in-game process, counter is increased

with this, all working as expected
 
Wow, this little thing will make it for the Roads and Lands mod,
where I planned to have Vassalage and Hereditary Rule
as prereq for the Stronghold (a bigger version of fort)

Thanks! :goodjob:
 
and another issue:
because m_bInactiveWithoutCivicPrereqs in CvInfos is not set to false by default (in XML load), then this can get any random value
and in CvPlayer::processCivics building can be passed to this code:
Code:
for(iJ = 0; iJ < GC.getNumCivicInfos(); iJ++)
		{
			if(GC.getBuildingInfo((BuildingTypes)iI).isPrereqCivic(iJ) && !isCivic((CivicTypes)iJ))
			{
				bRequiresCivic = true;
			}
		}
which for normal (ie non-civic prereq) building have bRequiresCivic set to False
this mean that in next code:
Code:
		else if(!bRequiresCivic && GET_TEAM(getTeam()).isObsoleteBuilding((BuildingTypes)iI))
		{
			GET_TEAM(getTeam()).changeObsoleteBuildingCount((BuildingTypes)iI, -1);
		}
each building without civic prereq, obsolete counter is lowered by one for each civic change !!! - so you can get ie monastery or walls later in game again available

so i suggest to set default value of bInactiveWithoutCivicPrereqs in XML load to false - then normal buildings is not checked in prereq. civic algorithm
pXML->GetChildXmlValByName(&m_bInactiveWithoutCivicPrereqs, "bInactiveWithoutCivicPrereqs"); change to
pXML->GetChildXmlValByName(&m_bInactiveWithoutCivicPrereqs, "bInactiveWithoutCivicPrereqs", false);
 
Lopez,

I have a suggestion with this, after toying around with it for the past week:

Just like you have <PreReqCivic> to enable certain buildings... could you also include something like <CivicDisable> to disable a certain building if a civic is chosen?

For example... say I create a new building, called a Work Camp. It uses BUILDINGCLASS_JAIL the same as the regular jail, so it would replace it. The Work Camp's <PreReqCivic> would be Police State, and would be disabled when you switch out of Police State.

However, when you go into the game, and switch to Police State the Jail still shows up, while the Work Camp doesn't.

If you could add another tag like <CivicDisable>, you could set the jail to be disabled when you select Police State, and in the mouse roll-over it could just say, "Disabled with Police State".

What do you think?
 
Added BtS v3.19 compatible version
 
There is only one thing that prevents me from using this mod: I need the capability to choose "OR and AND" for the civics. The OR would allow a building to be constructed with two or more civics under the same CivicOptionType group. For example: I want to be able to build the Slave Auction wonder, which requires either the Slavery or the Serfdom civic. This capability would elliminate a Python callback, that I'm using now, and greatly increase game speed performance. Any chance you could make the BTS update?
 
We have the OR ability in RoM - AND and C2C. Maybe you ask Afforess or Koshling if they could if they can convert it into stand alone. Afforess as mostly left for real life and Koshling is also a bit busy with real life at the moment, but it can't hurt to ask.
 
How to add "bInactiveWithoutCivicPrereqs" back? why doesn't it make sense? it seems an essential part to me? please Help me put it back! thanks!
 
Top Bottom