Great Person Abilities

Faustaud

Chieftain
Joined
Jun 25, 2012
Messages
16
Location
USA
So i have a question that required forum posting since i can't find the relevant info. I want to make a custom unit(s) that has one of the abilities of the great people. Great people each have 3 and i'd like to break these down to individual units with one a piece. Not bulbing though that'd be overpowered. So my question is, is this possible? For the life of me i can't figure out how to give these abilities out to a new unit or even make a buildable version of a GP. If anyone has insight on this i'd appreciate it greatly. For exact specifics i'm trying to give the GM's Trade mission ability to a custom unit.
 

Spatzimaus

Mad Scientist
Joined
Sep 21, 2005
Messages
3,063
Location
Los Angeles, CA
Each GP's unique ability (rush production, bulb a tech, etc.) is handled through an XML schema in the Units table. For instance, the Great Scientist has
<NumFreeTechs>1</NumFreeTechs>
which tells the game that this unit can be sacrificed to gain 1 tech; each other great person has a similar line (or two) for their own special ability. Engineers have BaseHurry=300 and HurryMultiplier=30, and the combination of these two tells the game how many hammers the engineer creates when it's sacrificed (30% of the rushed item's cost, plus 300 hammers, I think). Great Merchants are BaseGold=350, NumGoldPerEra=50 to determine how many gold you get from a trade mission (350 + 50*Era, where Era goes from 0 to 6); the amount of Influence it gets is set inside GlobalDefines. Artists get CultureBombRadius=1, which is pretty straightforward. The Great General's special ability to buff units is handled through a custom promotion (PROMOTION_GREAT_GENERAL), which unfortunately doesn't have any modifiable numbers associated with it and is just a promotion with the GreatGeneral flag set to true.

Likewise, the Golden Age ability of each person is handled through the
<GoldenAgeTurns>8</GoldenAgeTurns>
entry in Units, although that number is then modified by the game to adjust for how many golden ages you've already triggered. 8 is the base value for a GP. And finally, the ability of each GP to create a great improvement (Academy, Manufactory, etc.) is handled through an entry in the Unit_Builds table. For instance, the Manufactory is
Code:
<Unit_Builds>
    <Row>
        <UnitType>UNIT_ENGINEER</UnitType>
        <BuildType>BUILD_MANUFACTORY</BuildType> 
    </Row>
</Unit_Builds>

In all three cases, you can give these abilities to other units, and the game will handle it perfectly fine, with one exception: each of these units has a special UnitAI for the custom ability (not the improvement or the golden age, those are handled by the default AI just fine); for example, the great merchant has UNITAI_MERCHANT that tells it how to do a trade mission. So if you want to give the mission ability to some other unit and have it know to use it, you'll have to give that unit the merchant AI as one of its options (preferably the main one) and depending on what the unit is supposed to do, that might not work well. For instance, that Merchant AI doesn't just tell the unit how to sacrifice to get gold, it tells it to move to a city-state's territory before doing it. Some people have used this to their advantage (the City-State Diplomacy mod's diplomat units use this code to move to city-state territory to perform their function), but if you're trying to make a combat unit that can also do a weak version of the Great Engineer's rush effect, that's not always so good.

Unfortunately, most of the custom effects are fairly hard-coded; you can't make a unit with a weaker culture bomb, you can't make a unit that gives half a free tech, and so on... unless you bring Lua into it, but doing THAT would require a huge amount of UI and code changes, depending on what you want to make the units do, and the AI would likely not know how to do what you wanted, even if you DID fix the interface so that the active player could use it.

--------------------
So there you go. You can make units that sacrifice to start golden ages, you can make units that can build a Manufactory (or, by creating a new Build action, units that SACRIFICE to build a Manufactory), and with an AI change, you can make units that rush production, do trade missions, sacrifice for techs, and so on. The game will handle it about as well as it does anything else; I've done some of these in my own mods, like adding a Golem unit that acts as a worker, has decent combat charaacteristics, and can sacrifice to rush production a bit in a city (basically giving the city the amount spent on the golem's construction). It works just fine.
 

Faustaud

Chieftain
Joined
Jun 25, 2012
Messages
16
Location
USA
That's awesome! I'd seen those abilities in their stats but didn't realize it was the controller for it. I'm gonna go back to working on my merchant now. Thanks Spatz!
 

cryptc

Chieftain
Joined
Oct 29, 2010
Messages
83
I seem to have problems with NumFreeTechs = 0 on great scientists in G&K, anyone know if their function has changed with the expansion?
 

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,612
Location
Near Portsmouth, UK
I seem to have problems with NumFreeTechs = 0 on great scientists in G&K, anyone know if their function has changed with the expansion?

The field is still there, and the default is zero, but the Great Scientist no longer works that way, so it really depends on what the problems are.
 

cryptc

Chieftain
Joined
Oct 29, 2010
Messages
83
Problem is I want to disable their techgiving ability, which no longer works by changing that field
 

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,612
Location
Near Portsmouth, UK
There is another field on the unit that controls it so just change that one instead (it's about three lines higher in the units.xml file)
 

cryptc

Chieftain
Joined
Oct 29, 2010
Messages
83
There is another field on the unit that controls it so just change that one instead (it's about three lines higher in the units.xml file)

I'm working in SQL not XML (I can't stand XML), so any hint on the field name? since 3 lines above is AirUnitCap and nothing close by seems like the right one either
 

cryptc

Chieftain
Joined
Oct 29, 2010
Messages
83
Could it be BaseBeakersTurnsToCount ? if so, what exactly does it mean by that?
 

cryptc

Chieftain
Joined
Oct 29, 2010
Messages
83
Nevermind, tested BaseBeakersTurnsToCount=0 and it did what I was trying to do (disabling their teching ability), am still curious exactly what it does though, might be I don't have to disable it in my mod anymore if it doesn't auto-invent a tech anymore
 
Top Bottom