Maybe I'm doing something wrong, but nothings happening

lolocoster

Chieftain
Joined
Jul 4, 2010
Messages
45
Making my first mod, just a little test to update a building and see if I can buff it. I pick the granary since that would be the easiest to test since its one of the first buildings you can build.

I read the guide and learn how to use <update> tags, built the mod with no problems. The I load it up in game, and nothing's changed :( why?

Spoiler :
4Md3D.png


Am I forgetting something?

If anyone wants to take a look at it and check it, its under "Granary Buff Test" on the browser

Code:
<GameData>
	<Buildings>
		<Update>
			<Set FoodKept="20"/>
			<Where Type="BUILDING_GRANARY"/>
		</Update>
		<Update>
			<Set Yield="4"/>
			<Where Type="BUILDING_GRANARY"/>
		</Update>
		<Update>
			<Set Cost="150"/>
			<Where Type="BUILDING_GRANARY"/>
		</Update>
		<Update>
			<Set GoldMaintenance="3"/>
			<Where Type="BUILDING_GRANARY"/>
		</Update>
	</Buildings>
	<Language_en_US>
		<Row Tag="TXT_KEY_BUILDING_GRANARY_HELP">
			<Text> 20% of[ICON_FOOD] is carried over after a new [ICON_CITIZEN] is born.</Text>
		</Row>
	</Language_en_US>
</GameData>
 
There's at least one error there: there's no "Yield" entry in the Buildings table. Yields are handled in their own table (Building_Yields), and to be safe you should really clean up the Where and Set commands you use to take advantage of the inherent AND functionality for each. Something like:

Code:
<Buildings>
    <Set FoodKept="20" Cost="150" GoldMaintenacne="3"/>
    <Where Type="BUILDING_GRANARY"/>
</Buildings>
<Building_Yields>
    <Set Yield="4"/>
    <Where BuildingType="BUILDING_GRANARY" YieldType="YIELD_FOOD"/>
</Building_Yields>
(I'm not at home so I can't verify I got all of that right. But the idea is that it sets all three Buildings variables on one line, which reduces the chances of a mistype screwing things up, and the Where command on the yield is more robust, so that it wouldn't screw things up if someone were to, say, add +1 production to a Granary in their own mod.)

(Note: Just because something builds without an error message doesn't mean it'll actually WORK.)

Also, you've shown the XML, but I can't check to see if you have OnModActivated set up correctly. Without that, it won't do anything even if the XML was correct.
 
Beat me to it.

Spoiler :
<GameData>
<Buildings>
<Update>
<Set GoldMaintenance="3" FoodKept="20" Cost="150"/>
<Where Type="BUILDING_GRANARY"/>
</Update>
</Buildings>
<Building_YieldChanges>
<Update>
<Set Yield="4"/>
<Where BuildingType="BUILDING_GRANARY" YieldType="YIELD_FOOD"/>
</Update>
</Building_YieldChanges>
<Language_en_US>
<Row>
<Tag>="TXT_KEY_BUILDING_GRANARY_HELP"</Tag>
<Text> 20% of[ICON_FOOD] is carried over after a new [ICON_CITIZEN] is born.</Text>
</Row>
</Language_en_US>


</GameData>
 
Right, what he said. Building_YieldChanges would be the table's name. (You can check this for yourself by looking at the vanilla game's building XML file in your Steam directory.)

In general the game works this way; things that are a 1:1 mapping go into the Unit/Building table, but anything that allows for even the POSSIBILITY of multiple entries has its own table. Units can require multiple resources, so that's its own table. Units can have multiple promotions, so that's its own table. And Buildings can have multiple Yields, so that's its own table as well; if you want to create a building that adds +2 food, +2 production, and +2 research, you can. (See also: Palace.)

There are a few notable exceptions to this. For instance, while technology prerequisites are their own table, so that a tech can rely on up to 4 previous techs, unit promotion prerequisites are hard-coded into the base promotions table (you'll see field names like PromotionPrereqOr1). But for the most part, if you can think of a reason you'd ever want to have multiple entries for a single unit of something, then it'll be a separate table.
 
Great, I'll test it out now with new code

Code:
<GameData>
	<Buildings>
		<Update>
			<Set FoodKept="20" Cost="150" GoldMaintenance="3"/>
			<Where Type="BUILDING_GRANARY"/>
		</Update>
	</Buildings>
	<Building_YieldChanges>
		<Update>
			<Set Yield="4"/>
			<Where BuildingType="BUILDING_GRANARY" YieldType="YIELD_FOOD"/>
		</Update>	
	</Building_YieldChanges>
	<Language_en_US>
		<Row>
			<Tag>="TXT_KEY_BUILDING_GRANARY_HELP"</Tag>
			<Text> 20% of[ICON_FOOD] is carried over after a new [ICON_CITIZEN] is born.</Text>
		</Row>
	</Language_en_US>
</GameData>

Also, Spatzimaus mentioned OnModActivated, heres what that screen looks like
Spoiler :
mwL1q.png
 
Also, Spatzimaus mentioned OnModActivated, heres what that screen looks like

Okay, this part is also wrong. You can't do UpdateDatabase on Lua files, those have to be set up in the Content tab, not the Actions tab. (InGameUIAddin for the first column, whatever you want for the next two, filename at the end.)

And while I'm not sure whether or not it can handle this, it's probably a bad idea to be using spaces in your filenames. A LOT of programming languages can't handle that sort of thing too well, so I wouldn't be surprised if that makes it a little flaky.
 
You guys are awesome! It works great! So great in fact, that I've become motivated to write my own building overhaul mod

I've reached the military academy, and I've decided to make it so it adds the promotions of Amphibious, DrillI and ShockI

Code:
<Buildings>
		<Update>
			<Set Cost="450" GoldMaintenace="5" TrainedFreePromotion="PROMOTION_AMPHIBIOUS" TrainedFreePromotion="PROMOTION_DRILL_1" TrainedFreePromotion="PROMOTION_SHOCK_1"/>
			<Where Type="BUILDING_MILITARY_ACADEMY"/>

But the last 2 promotions have the red lines underneath, and when I mouse over it, it says its because of Duplicate Attribute TrainedFreePromotion. So I'm guessing I can't add more than one promotion with my method of repeatedly listing the attribute

So my question is, is there a way to add more than one promotion to a single building?

Should it be

Code:
 TrainedFreePromotion="PROMOTION_AMPHIBIOUS PROMOTION_SHOCK_1 PROMOTION_DRILL_1"
or something like that?
 
I'm pretty sure that as of now, buildings can only handle giving 1 promotion in that manner.
 
So my question is, is there a way to add more than one promotion to a single building?

No.
Well, you can hack it through Lua I suppose; for each new unit, check to see if the city they were created in has a Military Academy, and if so, set those promotions manually. But that's REALLY messy.

What you can do, instead, is create a new promotion. Let's call it "Elite". Set CannotBeChosen="true" so that you can't select it during a level-up. Then, give that promotion all of the benefits associated with the three promotions you want, and give THAT to the new units through this building.
The only real headache would be whether it stacks with the others, and how the AI would handle that. (For instance, if the unit gets the amphibious ability from this promotion, would the AI know not to waste a promotion pick taking the normal Amphibious?)

Also, note a lot of problems with giving Drill and Shock. For one thing, this'd give the unit +25% in every fight, period. Besides just being a HUGE effect, there's a better way to do this (one of the things you can do with a promotion is a straight Combat mod, or mods when attacking or when defending if you want to specialize along that axis). Also, having Drill I and Shock I would unlock a whole slew of specialized promotions that much sooner, which isn't always a good thing. And finally, it wouldn't do anything for ranged units, naval units, or air units; only melee land units would get the benefit.

In my own mod, I've got several buildings that add promotions to units trained in a city; one adds +10% to a unit's strength, another makes the unit gain XP 25% faster and adds visibility, a third adds strength when fighting within your own territory and a final one adds when fighting OUTSIDE your territory. So there's a lot you can do without just giving existing promotions.
 
Can someone take a look at my code to see why its not working?
Code:
<GameData>
	<Buildings>
		<Update>
			<Set FoodKept="20" Cost="150" GoldMaintenance="3"/>
			<Where Type="BUILDING_GRANARY"/>
		</Update>
		<Update>
			<Set Happiness="1" Cost="75" GoldMaintenance="2" Culture="3"/>
			<Where Type="BUILDING_MONUMENT"/>
		</Update>
		<Update>
			<Set TrainedFreePromotion="PROMOTION_SIEGE" Cost="120" GoldMaintenance="0"/>
			<Where Type="BUILDING_BARRACKS"/>
		</Update>
		<Update>
			<Set Happiness="5" GoldMaintenance="6" Cost="100"/>
			<Where Type="BUILDING_COLOSSEUM"/>
		</Update>
		<Update>
			<Set Happiness="1" Cost="150" TrainedFreePromotion="PROMOTION_MEDIC"/>
			<Where Type="BUILDING_ARMORY"/>
		</Update>
		<Update>
			<Set Cost="400" GoldMaintenace="3" TrainedFreePromotion="PROMOTION_AMPHIBIOUS"/>
			<Where Type="BUILDING_MILITARY_ACADEMY"/>
		</Update>
		<Update>
			<Set Culture="2" Cost="250"/>
			<Where Type="BUILDING_CASTLE"/>
		</Update>
		<Update>
			<Set Culture="1" Cost="125"/>
			<Where Type="BUILDING_WALLS"/>
		</Update>
		<Update>
			<Set Culture="4" Happiness="2" Cost="550"/>
			<Where Type="BUILDING_MILITARY_BASE"/>
		</Update>
		<Update>
			<Set SpecialistType="SPECIALIST_MERCHANT" SpecialistCount="1"/>
			<Where Type="BUILDING_COURTHOUSE"/>
		</Update>
	</Buildings>
</GameData>

I have a feeling I made a mistake with adding the Specialist to the courthouse, but I'm not sure
 
On the Military Academy you misspelled "Maintenance", leaving out the second N. There might be other mistakes, but I didn't see one offhand.

There are two ways to track down something like that.
1> Use FireTuner, and watch the error messages when you first enter a game after loading the mods. It'll show a lot of these sorts of errors.
2> Brute force debugging. If a file doesn't work, then comment out half of it with
Code:
<!--
(stuff to be disabled)
-->

If it starts working again, then you know the mistake is in the disabled half of the file. Lather, rinse, repeat until you narrow it down enough to spot the mistake.
 
Back
Top Bottom