• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Proposal: Remove <PrereqCiv>

lfgr

Emperor
Joined
Feb 6, 2010
Messages
1,105
With regard to this tracker bug, and considering some modding I tried on it, I'd like to propose a change in the system special (non-"Unique") units and building work in FfH.

Special units and buildings should (IMO)
1. not appear in tech tree for other civilizations
2. be listed in pedia and help as "unit" rather than "unit (unitclass)"
3. not be captured (buildings)
4. not be gifted (units)
5. only be available to their civ and to tolerant leaders (except heroes)
6. be higher valued by AI

Any other things?

Proposal:
Remove the <PrereqCiv> tags in UnitInfos and BuildingInfos
All former "special" units are now UUs, same for Buildings
Each special unit/building gets either it's own class or a set of classes is reserved for that units/buildings, as there are currently the BUILDINGCLASS_CIV_BUILDINGX classes (I would prefer the first). These classes have NO_UNIT as default. UUs, UBs and heroes are listed in the Civilization's <Unit> or <Building> tags.

Solution for 1.: Should work that way automatically.
Solution for 2.: If we have BUILDINGCLASS_CIV_BUILDINGX etc., it could be just checked for this (but that would require hardcoding IDs into the DLL). Else, it could be checked if the Building/Unit's name is equal to the class' name.
Solution for 3.: <bNoCapture>
Solution for 4.: Should work that way automatically.
Solution for 5.: UU and UB will obviously work, but heroes would need either a check for World Units or a new Tag, like <bUnique>
Solution for 6.: Just check for all UUs/UBs (unit.getUnitClass().getDefaultUnit() != unit), not only for ones with <PrereqCiv>

Pros:
Two methods of special unit declaration aggregated to one, leading to:
  • More consistent XML (all UUs and UBs are listed in CivilizationInfos)
  • Less complexity for modding
Cons:
You can no longer declare a non-world unit to be not available to tolerant leaders (and you cannot a world unit to be available to tolerant leaders)
Maybe Freaks etc. were supposed not to be build by tolerant leaders :)... But I don't think so.

Especially the NO_UNIT default for classes my require some testing.

Below I gathered and commented the calls on getPrereqCiv() (in MNAI)
Code:
Uses of CvUnit::getPrereqCiv()
	DLL
		CvCityAI::AI_buildingValueThreshold(BuildingTypes eBuilding, int iFocusFlags, int iThreshold)
			Higher value for buildings allowing units with PrereqCiv==OwnerCiv
		CvPlayerAI::AI_techUnitValue( TechTypes eTech, int iPathLength, bool &bEnablesUnitWonder, bool bDebugLog )
			Higher value for techs allowing units with PrereqCiv == OwnerCiv
		CvUnit::canGift(bool bTestVisible, bool bTestTransport)
			Can only gift unit if PrereqCiv == ReceiverCiv (same for UUs)
		
		CvPlayer::canTrain(UnitTypes eUnit, bool bContinue, bool bTestVisible, bool bIgnoreCost)
			Can only train unit PrereqCiv == OwnerCiv (ADDED BY THOLAL)
		CvCity::canUpgrade(UnitTypes eUnit, bool bContinue, bool bTestVisible, bool bIgnoreCost, bool bIgnoreUpgrades)
			*Note: this method is called by CvCity::canTrain(), so also determines all unit training.
			Can only upgrade to unit PrereqCiv == OwnerCiv (same for UUs)
		
		CvGameTextMgr::parseCivInfos(CvWStringBuffer &szInfoText, CivilizationTypes eCivilization, bool bDawnOfMan, bool bLinks)
			(Non-Gameplay)
	Python
		BUG/UnitUtil.py: getTrainableUnits(playerOrID, knowableUnits, checkCities=True, military=None)
			Excludes units with PrereqCiv != OwnerCiv (same for UUs)
		
		Contrib/Sevopedia/...
		Screens/..
			(Non-Gameplay)

Uses of CvBuilding::getPrereqCiv()
	DLL
		CvPlayer::acquireCity(CvCity* pOldCity, bool bConquest, bool bTrade, bool bUpdatePlotGroups)
			Buildings with PrereqCiv != NewOwnerCiv can not be kept by other civilization (ADDED BY DENEV / Unofficial Bug Fix)
				*Note: UBs would be converted to the NewOwners Building info of the Building Class; But this can (and is) prevented with <bNeverCapture>
		CvCityAI::AI_buildingValueThreshold(BuildingTypes eBuilding, int iFocusFlags, int iThreshold)
			Buildings with PrereqCiv are valued higher for owner with same civ or if owner is tolerant (ADDED BY THOLAL)
		CvPlayerAI::AI_techBuildingValue( TechTypes eTech, int iPathLength, bool &bEnablesWonder, bool bDebugLog )
			Higher value for Buildings with PrereqCiv
		CvCity::canConstruct(BuildingTypes eBuilding, bool bContinue, bool bTestVisible, bool bIgnoreCost)
			Can only construct building if PrereqCiv == OwnerCiv (same for UBs)
		
		CvGameTextMgr::parseCivInfos(CvWStringBuffer &szInfoText, CivilizationTypes eCivilization, bool bDawnOfMan, bool bLinks)
			(Non-Gameplay)
	Python
		Revolution/RevBuildingsUtils.py: getBuildingsRevIdxLocal( pCity ), getBuildingsCivStabilityIndex( iPlayer )
			Buildings with PrereqCiv != OwnerCiv have no RevIdx effect
				I don't really understand this. Shouldn't these buildings are destroyed anyway? And why doesn't the code check for UBs?
		
		Contrib/Sevopedia/...
		Screens/..
			(Non-Gameplay)

By the way, does anybody know what the <UpgradeCiv> tag means?
 
Thank you. This should hopefully make the tech tree less confusing when trying to play new civs.
 
These classes have NO_UNIT as default.

I have seen mentioned on the forums that using NO_UNIT/NONE as default causes problems. I don't have any personal experience with this I just know I have seen it mentioned as a problem. IIRC the problem is that in the DLL the default unit is used for some calculations. If this is the only problem then I guess it could be fixed by modding the DLL. Hopefully, it is not a problem for buildings or was fixed because the "BUILDINGCLASS_CIV_BUILDING" classes already use NONE as the default.

If using NONE as default is not a problem then this proposal seems good to me. :)
 
I wonder if this will cause a side effect of changing what the Elohim can build in cities they take over?
 
@Red Key: Thanks, I'll check that.
@Kiech: the Elohim would be able to build e.g. Freaks like other UUs, except Heroes.

But, just to clarify: all gameplay changes could also be changed more or less easily without my proposal (and if Tholal rejects it I will try to fix it in another way).
I just wanted other people to check and comment it and Tholal to decide whether he wants to include it (it's a really major change that could possibly complicate merging other modcomps, but also could help modding, as I see it now).
 
With regard to this tracker bug, and considering some modding I tried on it, I'd like to propose a change in the system special (non-"Unique") units and building work in FfH.

Turns out the fix for that issue was pretty simple (tracking it down was a bit of a pain though).

I see what your idea is here, but I'm not sure that the overall gain is worth the effort. Suppressing display of civ-specific units in the tech help is probably a relatively easy fix. I created a bug report for it.
 
Back
Top Bottom