Need some help on coding a UA/UB

lordrj15

Manx Modder
Joined
Oct 14, 2014
Messages
831
Location
Lancaster University
Okay, so I'm working on my first mod with some help from a couple modders, but we've come across a problem in our original plans.

Now, there's part of the UA and the power of the UB that we can't code with XML, and none of us have any real experience with lua.

How could I code the following?

UA-+1 food from plantations with access to fresh water once civil service is researched. (This isn't the whole UA)

UB-Shrine replacement, +1 faith from plantations.

Anyway of coding this in XML, or does anyone know where I can find coding from another mod that is similar to this so that I may adapt it?

Thanks.
 
Okay, so I'm working on my first mod with some help from a couple modders, but we've come across a problem in our original plans.

Now, there's part of the UA and the power of the UB that we can't code with XML, and none of us have any real experience with lua.

How could I code the following?

UA-+1 food from plantations with access to fresh water once civil service is researched. (This isn't the whole UA)

UB-Shrine replacement, +1 faith from plantations.

Anyway of coding this in XML, or does anyone know where I can find coding from another mod that is similar to this so that I may adapt it?

Thanks.
UA should theoretically be able to be coded in XML; add the PrereqTech tag to your UA, then use the table <Trait_ImprovementYieldChanges> or something like that.

Can't do the building thing. There is no built-in XML way to make buildings generate extra yields from improvements.
 
UA should theoretically be able to be coded in XML; add the PrereqTech tag to your UA, then use the table <Trait_ImprovementYieldChanges> or something like that.

Can't do the building thing. There is no built-in XML way to make buildings generate extra yields from improvements.



Hmm, the other part of the UA is a flat +1 food from plantations.

Then there is +1 food from plantations with access to fresh water on the discovery of civil service, would that entire UA be possible in XML then?

Might have to keep brainstorming with the UB aswell
 
So to clarify... the UA is: +1 food from plantations, and an additional +1 after the discovery of Civil Service?
In that case no, there will a miniscule amount of lua required. I'm thinking you can keep the current trait - the +1 food after Civil service part - as is, then use a dummy policy to give the flat +1 food. See Rob's post in this thread for a basic run-through on using a dummy policy alongside a trait and an example of the required lua.
 
So to clarify... the UA is: +1 food from plantations, and an additional +1 after the discovery of Civil Service?
In that case no, there will a miniscule amount of lua required. I'm thinking you can keep the current trait - the +1 food after Civil service part - as is, then use a dummy policy to give the flat +1 food. See Rob's post in this thread for a basic run-through on using a dummy policy alongside a trait and an example of the required lua.

Er, I have to note I am a novice in any sortof coding whatsoever, this is my first mod, and I'm probably going to need some simpler information with regards to making a "dummy" building
 
No, I was suggesting using a dummy policy. I linked that thread because Rob (R8XFT)'s post - post #4 - gives a good albeit quick run-through on how to use dummy policies to create some of the effects of the UA.

The thing you need to know is: Firaxis didn't supply us with all the built-in XML we need to create anything we want using just XML. And realistically we can't blame them, or else we're getting mad at Firaxis for not being able to predict what an enormous group of players will each individually want to tweak with their game. We have other reasons to hate on Firaxis. ;)

That in mind, modders usually want to make a UA but its stipulations and effects can't just be coded using the XML from the <Traits> table. So modders have come up with a couple workarounds...

A QUICK INTRODUCTION TO DUMMY BUILDINGS:

The most common one is to create a "dummy" building, a building that uses XML tags not available directly to traits. The building is then, using lua or the <FreeBuilding> tag within a trait, given to the necessary cities of the player in order to create the effects of the UA not directly possible using only the Trait XML. e.g. Consider a UA where the player gets an extra 10% :c5gold: from city conncections. This isn't possible just within <Traits>, but we can make a building with the TradeRouteModifier tag like Machu Picchu uses, and then plop that building in the player's capital.* Dummy buildings are usually invisible, especially in BNW mods. (There is a way to make buildings invisible, but it's restricted to BNW)

Dummy policies are a similar concept, and we use them when we need to use to use XML that is neither available from <Buildings> nor <Traits> in order to make a UA. Again, see Rob's post in the linked thread for a run-through on how the process of making a dummy policy.

~~~~~~~~~~~~~~~~~~~~

So here's what I was thinking: Use Traits to make half the UA, adding +1 food to plantations and making use of the <PrereqTech> tag within <Traits>. Then use a dummy policy to do the other half of the trait, adding +1 food to plantations regardless of whether you have civil service or not. This way, you have half of the trait not constrained by <PrereqTech>. Savvy?






*In this case using Lua is actually advised, because of the way <FreeBuilding> operates. Be aware that <FreeBuilding> ignores all building requirements, such as that it must be built in a holy city or capital or what have you, unless it's a geographical constraint like needing to be built next to a river or coast, hence why Carthage doesn't get harbors in landlocked cities. Using FreeBuilding would therefore add the dummy building to every city, thereby changing the trait to "+10% gold from city connections per city", with ridiculous stacking. With lua, we can just add the building straight to and only to the capital. But that's an aside.
 
No, I was suggesting using a dummy policy. I linked that thread because Rob (R8XFT)'s post - post #4 - gives a good albeit quick run-through on how to use dummy policies to create some of the effects of the UA.

The thing you need to know is: Firaxis didn't supply us with all the built-in XML we need to create anything we want using just XML. And realistically we can't blame them, or else we're getting mad at Firaxis for not being able to predict what an enormous group of players will each individually want to tweak with their game. We have other reasons to hate on Firaxis. ;)

That in mind, modders usually want to make a UA but its stipulations and effects can't just be coded using the XML from the <Traits> table. So modders have come up with a couple workarounds...

A QUICK INTRODUCTION TO DUMMY BUILDINGS:

The most common one is to create a "dummy" building, a building that uses XML tags not available directly to traits. The building is then, using lua or the <FreeBuilding> tag within a trait, given to the necessary cities of the player in order to create the effects of the UA not directly possible using only the Trait XML. e.g. Consider a UA where the player gets an extra 10% :c5gold: from city conncections. This isn't possible just within <Traits>, but we can make a building with the TradeRouteModifier tag like Machu Picchu uses, and then plop that building in the player's capital.* Dummy buildings are usually invisible, especially in BNW mods. (There is a way to make buildings invisible, but it's restricted to BNW)

Dummy policies are a similar concept, and we use them when we need to use to use XML that is neither available from <Buildings> nor <Traits> in order to make a UA. Again, see Rob's post in the linked thread for a run-through on how the process of making a dummy policy.

~~~~~~~~~~~~~~~~~~~~

So here's what I was thinking: Use Traits to make half the UA, adding +1 food to plantations and making use of the <PrereqTech> tag within <Traits>. Then use a dummy policy to do the other half of the trait, adding +1 food to plantations regardless of whether you have civil service or not. This way, you have half of the trait not constrained by <PrereqTech>. Savvy?






*In this case using Lua is actually advised, because of the way <FreeBuilding> operates. Be aware that <FreeBuilding> ignores all building requirements, such as that it must be built in a holy city or capital or what have you, unless it's a geographical constraint like needing to be built next to a river or coast, hence why Carthage doesn't get harbors in landlocked cities. Using FreeBuilding would therefore add the dummy building to every city, thereby changing the trait to "+10% gold from city connections per city", with ridiculous stacking. With lua, we can just add the building straight to and only to the capital. But that's an aside.


I get you now, quite clever really!

Thanks for that, we've been scratching our heads over this!

I suppose I might have to rethink the UB though >.<
 
However, I already have the flat +1 food bonus in XML, couldn't they both be done without XML without a dummy policy?
 
As far as I know, the <PrereqTech> tag applies to the entire UA, so trying to control both parts of the UA without a dummy anything would result in +2 food from plantations after researching civil service.

Unfortunately, the <Policies> table does not have a <PrereqTech> tag, so without some extension to the dummy policy lua, you won't be able to switch around which part of the UA the policy controls and which part the actual Trait controls.
 
Top Bottom