Overwrite XML TAG

ComradeKristov

Warlord
Joined
Dec 30, 2009
Messages
170
Location
Chicago,Il
I've read there is a XML tag to overwrite original XML modularly. If there is such a TAG could someone show me an example of how to use it? I would really appriciate it.
 
I've read there is a XML tag to overwrite original XML modularly. If there is such a TAG could someone show me an example of how to use it? I would really appriciate it.

The tag is: <bForceOverwrite>.

An example of usage from the Better RoM module is:

Spoiler :
Code:
		<BuildingInfo>
			<BuildingClass>BUILDINGCLASS_FISHERMAN_HUT</BuildingClass>
			<Type>BUILDING_FISHERMAN_HUT</Type>
[B]			[U]<bForceOverwrite>1</bForceOverwrite>[/U][/B]
			<SpecialBuildingType>NONE</SpecialBuildingType>
			<Description>TXT_KEY_BUILDING_FISHERMAN_HUT</Description>
			<Civilopedia>TXT_KEY_BUILDING_FISHERMAN_HUT_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_FISHERMAN_HUT_STRATEGY</Strategy>
			<Advisor>ADVISOR_GROWTH</Advisor>
			<ArtDefineTag>ART_DEF_BUILDING_VIKING_TRADING_POST</ArtDefineTag>
			<MovieDefineTag>NONE</MovieDefineTag>
			<HolyCity>NONE</HolyCity>
			<ReligionType>NONE</ReligionType>
			<StateReligion>NONE</StateReligion>
			<bStateReligion>0</bStateReligion>
			<PrereqReligion>NONE</PrereqReligion>
			<PrereqCorporation>NONE</PrereqCorporation>
			<FoundsCorporation>NONE</FoundsCorporation>
			<GlobalReligionCommerce>NONE</GlobalReligionCommerce>
			<GlobalCorporationCommerce>NONE</GlobalCorporationCommerce>
			<VictoryPrereq>NONE</VictoryPrereq>
			<FreeStartEra>NONE</FreeStartEra>
			<MaxStartEra>NONE</MaxStartEra>
			<ObsoleteTech>NONE</ObsoleteTech>
			<PrereqTech>TECH_FISHING</PrereqTech>
			<TechTypes/>
			<Bonus>NONE</Bonus>
			<!--<PrereqVicinityBonuses>
				<VicinityBonus>BONUS_FISH</VicinityBonus>
				<VicinityBonus>BONUS_CRAB</VicinityBonus>
				<VicinityBonus>BONUS_WHALE</VicinityBonus>
				<VicinityBonus>BONUS_SHRIMP</VicinityBonus>
			</PrereqVicinityBonuses>-->
			<ProductionTraits>
				<ProductionTrait>
					<ProductionTraitType>TRAIT_SEAFARING</ProductionTraitType>
					<iProductionTrait>100</iProductionTrait>
				</ProductionTrait>
			</ProductionTraits>
			<HappinessTraits/>
			<NoBonus>NONE</NoBonus>
			<PowerBonus>NONE</PowerBonus>
			<FreeBonus>NONE</FreeBonus>
			<iNumFreeBonuses>0</iNumFreeBonuses>
			<FreeBuilding>NONE</FreeBuilding>
			<FreePromotion>NONE</FreePromotion>
			<CivicOption>NONE</CivicOption>
			<GreatPeopleUnitClass>NONE</GreatPeopleUnitClass>
			<iGreatPeopleRateChange>0</iGreatPeopleRateChange>
			<iHurryAngerModifier>0</iHurryAngerModifier>
			<bBorderObstacle>0</bBorderObstacle>
			<bTeamShare>0</bTeamShare>
			<bWater>1</bWater>
			<bRiver>0</bRiver>
			<bPower>0</bPower>
			<bDirtyPower>0</bDirtyPower>
			<bAreaCleanPower>0</bAreaCleanPower>
			<DiploVoteType>NONE</DiploVoteType>
			<bForceTeamVoteEligible>0</bForceTeamVoteEligible>
			<bCapital>0</bCapital>
			<bGovernmentCenter>0</bGovernmentCenter>
			<bGoldenAge>0</bGoldenAge>
			<bAllowsNukes>0</bAllowsNukes>
			<bMapCentering>0</bMapCentering>
			<bNoUnhappiness>0</bNoUnhappiness>
			<bNoUnhealthyPopulation>0</bNoUnhealthyPopulation>
			<bBuildingOnlyHealthy>0</bBuildingOnlyHealthy>
			<bNeverCapture>0</bNeverCapture>
			<bNukeImmune>0</bNukeImmune>
			<bPrereqReligion>0</bPrereqReligion>
			<bCenterInCity>0</bCenterInCity>
			<iAIWeight>100</iAIWeight>
			<iCost>45</iCost>
			<iHurryCostModifier>0</iHurryCostModifier>
			<iAdvancedStartCost>100</iAdvancedStartCost>
			<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
			<iMinAreaSize>10</iMinAreaSize>
			<iConquestProb>75</iConquestProb>
			<iCitiesPrereq>0</iCitiesPrereq>
			<iTeamsPrereq>0</iTeamsPrereq>
			<iLevelPrereq>0</iLevelPrereq>
			<iMinLatitude>0</iMinLatitude>
			<iMaxLatitude>90</iMaxLatitude>
			<iGreatPeopleRateModifier>0</iGreatPeopleRateModifier>
			<iGreatGeneralRateModifier>0</iGreatGeneralRateModifier>
			<iDomesticGreatGeneralRateModifier>0</iDomesticGreatGeneralRateModifier>
			<iGlobalGreatPeopleRateModifier>0</iGlobalGreatPeopleRateModifier>
			<iAnarchyModifier>0</iAnarchyModifier>
			<iGoldenAgeModifier>0</iGoldenAgeModifier>
			<iGlobalHurryModifier>0</iGlobalHurryModifier>
			<iExperience>0</iExperience>
			<iGlobalExperience>0</iGlobalExperience>
			<iFoodKept>0</iFoodKept>
			<iAirlift>0</iAirlift>
			<iAirModifier>0</iAirModifier>
			<iAirUnitCapacity>0</iAirUnitCapacity>
			<iNukeModifier>0</iNukeModifier>
			<iNukeExplosionRand>0</iNukeExplosionRand>
			<iFreeSpecialist>0</iFreeSpecialist>
			<iAreaFreeSpecialist>0</iAreaFreeSpecialist>
			<iGlobalFreeSpecialist>0</iGlobalFreeSpecialist>
			<iMaintenanceModifier>0</iMaintenanceModifier>
			<iWarWearinessModifier>0</iWarWearinessModifier>
			<iGlobalWarWearinessModifier>0</iGlobalWarWearinessModifier>
			<iEnemyWarWearinessModifier>0</iEnemyWarWearinessModifier>
			<iHealRateChange>0</iHealRateChange>
			<iHealth>0</iHealth>
			<iAreaHealth>0</iAreaHealth>
			<iGlobalHealth>0</iGlobalHealth>
			<iHappiness>0</iHappiness>
			<iAreaHappiness>0</iAreaHappiness>
			<iGlobalHappiness>0</iGlobalHappiness>
			<iStateReligionHappiness>0</iStateReligionHappiness>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iMilitaryProductionModifier>0</iMilitaryProductionModifier>
			<iSpaceProductionModifier>0</iSpaceProductionModifier>
			<iGlobalSpaceProductionModifier>0</iGlobalSpaceProductionModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iCoastalTradeRoutes>0</iCoastalTradeRoutes>
			<iGlobalTradeRoutes>0</iGlobalTradeRoutes>
			<iTradeRouteModifier>0</iTradeRouteModifier>
			<iForeignTradeRouteModifier>0</iForeignTradeRouteModifier>
			<iGlobalPopulationChange>0</iGlobalPopulationChange>
			<iFreeTechs>0</iFreeTechs>
			<iDefense>0</iDefense>
			<iBombardDefense>0</iBombardDefense>
			<iAllCityDefense>0</iAllCityDefense>
			<iEspionageDefense>0</iEspionageDefense>
			<iAsset>5</iAsset>
			<iPower>0</iPower>
			<fVisibilityPriority>1.0</fVisibilityPriority>
			<SeaPlotYieldChanges>
				<iYield>1</iYield>
				<iYield>0</iYield>
				<iYield>0</iYield>
			</SeaPlotYieldChanges>
			<RiverPlotYieldChanges/>
			<GlobalSeaPlotYieldChanges/>
			<YieldChanges/>
			<CommerceChanges/>
			<ObsoleteSafeCommerceChanges/>
			<CommerceChangeDoubleTimes/>
			<CommerceModifiers/>
			<GlobalCommerceModifiers/>
			<SpecialistExtraCommerces/>
			<StateReligionCommerces/>
			<CommerceHappinesses/>
			<ReligionChanges/>
			<SpecialistCounts/>
			<FreeSpecialistCounts/>
			<CommerceFlexibles/>
			<CommerceChangeOriginalOwners/>
			<ConstructSound>AS2D_BUILD_FISHING_HUT</ConstructSound>
			<BonusHealthChanges>
				<BonusHealthChange>
					<BonusType>BONUS_SALT</BonusType>
					<iHealthChange>1</iHealthChange>
				</BonusHealthChange>
			</BonusHealthChanges>
			<BonusHappinessChanges/>
			<BonusProductionModifiers/>
			<UnitCombatFreeExperiences/>
			<DomainFreeExperiences/>
			<DomainProductionModifiers/>
			<BuildingHappinessChanges/>
			<PrereqBuildingClasses/>
			<BuildingClassNeededs/>
			<SpecialistYieldChanges/>
			<BonusYieldModifiers/>
			<ImprovementFreeSpecialists/>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_PRODUCTION</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_GOLD</FlavorType>
					<iFlavor>2</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_GROWTH</FlavorType>
					<iFlavor>15</iFlavor>
				</Flavor>
			</Flavors>
			<HotKey/>
			<bAltDown>0</bAltDown>
			<bShiftDown>0</bShiftDown>
			<bCtrlDown>0</bCtrlDown>
			<iHotKeyPriority>0</iHotKeyPriority>
			<iDCMAirbombMission>2</iDCMAirbombMission>
		</BuildingInfo>

The use of the overwrite tag means that all this modularly-added information will overwrite any existing stuff in the default BuildingInfos.

Of course, you don't have to include everything. You could just use the tag along with one line, like maybe:

Code:
		<UnitInfo>
			<Class>UNITCLASS_FIGHTER</Class>		
			<Type>UNIT_spitfire</Type>
			<bForceOverwrite>1</bForceOverwrite>	
			<iBombRate>0</iBombRate>
		</UnitInfo>

To make spitfires unable to bombard plots/cities. Not that you'd want to nerf them so badly -- it's just an example!
 
Actually, It wouldn't work for me at all unless I used <bForceOverwrite> outside of a grouping of tags. So you would have to do it after </UnitInfos>. Doing it inside of that will result in an error.
 
You have to make sure you have the most recent Unit or Building Schema in place so that the forceoverwrite actually works correctly.
 
also i think i'll need a bForceOverwrite tag for civics. or did you already add one?
bForceOverwrite is a universal tag, it works on all objects. I haven't updated all the schema's though, so you may need to add it there if I haven't. (But I'm pretty sure I updated the GameInfo Schema).
to add the override tag to a schema open a arbitrary schema that includes it, find all occurrences of the tag, copy them over on the fitting places in your scheme file. note that the override tag needs to be placed as an element of the UnitInfo tag if you want to use it inside a unit
 
Does it work differently if I'm trying to overwrite the xml in a module file? Just running very similar code to what was listed in the thread for a minimalist approach caused the game to not load the buildings for me at all.
 
Does it work differently if I'm trying to overwrite the xml in a module file? Just running very similar code to what was listed in the thread for a minimalist approach caused the game to not load the buildings for me at all.

I'm getting the feeling very few people here understand what the bForceOverwrite tag actually does.

First off; it can only be used in modules. Putting it in the Main XML will have no effect on the game. The reason why will become clear in a moment.

When the game loads up, say, buildings, it loads the Main XML first. Then, it searches the modules folder, and loads buildings in the order of the MLF file. When it encounters a building in the modules folder that already had been created elsewhere, it simply appends the changed stats to it. This is the normal loading procedure developed by the WoC Team. The older method, the Firaxis style, is what bForceOverwrite enabled. In Regular, Non-WoC, BTS, when a game encounters a copy of a building that already exists, it deletes the old building stats and replaces it with the new. The game forgets the first building was even there. That's what bForceOverwrite does, but only for the specific buildings you enable it on.

The reason for WoC is the XML lists of items, like PrereqOrBuildings, only get appended when the game loads WoC style, which can cause nasty side-effects if you are trying to rewrite the building stats. That's where bForceOverwrite comes in. It will wipe EVERYTHING, all stats, clean, then load your new stats. Keep in mind, you must provide any old stats from the old entry that you want to keep with the new stats; as the old ones will be wiped out.
 
...The reason for WoC is the XML lists of items, like PrereqOrBuildings, only get appended when the game loads WoC style, which can cause nasty side-effects if you are trying to rewrite the building stats. That's where bForceOverwrite comes in. It will wipe EVERYTHING, all stats, clean, then load your new stats. Keep in mind, you must provide any old stats from the old entry that you want to keep with the new stats; as the old ones will be wiped out.

Hm, this probably means my earlier Spitfire example isn't valid...
 
So... Lets say I want to change a building's double-production speed trait.

If the trait is already organized and I want to change it to Industrious, I need to do what in order to make that change without either

A) making it double-speed with BOTH traits
B) breaking it

Is the only option to ForceOverwrite and copy all of the information?
 
As long as I know WHAT to do that's fine :lol: doing it the way supercheese had up in the spitfire example only shattered my game into many pieces.
 
Back
Top Bottom