Mod-Q: How to make "Trait-specific building"??

RobHunt

Chieftain
Joined
Nov 7, 2005
Messages
24
Location
Cincinnati, OH, USA
I've been looking at the idea of making a "trait-specific" building as a mod idea and I can't seem to figure out how to do it. I've figured out how to remove a building at the civilization level, and I can see how to make a building easier to build at the trait level... but I'm not sure if you can make it where only a leader with a certain trait can build that building...

If I'm just missing something, could somebody point me in the right direction? If there isn't a way, perhaps somebody should suggest this to Firaxis as the possibilities are endless -- imagine bringing back Sun-Tzu's war academy, for example, but only an aggressive leader could build it?

RH
 
There's no way I know of to do this. You'll have to wait for the SDK (or someone who knows more than me :p)
 
This could be done -- but it will be FAR more complicated than i make it sound...

This is just theory:

I'm not familiar with the XML of buildings and such, but there is possibly a way to add an additional XML field where they are defined - "Buildable By Trait" -- this field would contain either a text string containing a trait name, or a number that equates to a trait in the traits list (if one exists, ie "1" = aggressive, etc)
You would then set each building to the approriate trait... or leave it empty if anyone can build it.
Now comes the hard part: find the python that determines whether a buildign can be built, and add additional code to it to match the building's new field to the leader's trait, as an additional criteria for the check

Again, this is all theory, i'm not sure how the buildings are defined... but it seems sound in my head. the Python part might be much harder than i make it sound, I really am not even looking at the files right now, just theorizing =) Hope I at least give you a nudge in a proper direction!
 
that was what i was going try next, but still figuring out where the specific python stuff is hiding.
my first idea was to make a proxy tech, but only civs get free tech, not the leaders.
what i suggested is viable. suppose you multiply the cost by 10,000. then the discount would be 990,000 just to get it even. all you're changing are 2 values and you don't have to mess with python.
 
Rayanth said:
Now comes the hard part: find the python that determines whether a buildign can be built, and add additional code to it to match the building's new field to the leader's trait, as an additional criteria for the check

I'm guessing canConstruct in CvGameUtil.py can be used to check if a building can be built. But I have no idea how to see what the buildings new field is. I tried to do something a bit similar with promotions but couldn't find out how to get a units variables in python unless there's a predefined function for it.
 
snarko said:
I'm guessing canConstruct in CvGameUtil.py can be used to check if a building can be built. But I have no idea how to see what the buildings new field is. I tried to do something a bit similar with promotions but couldn't find out how to get a units variables in python unless there's a predefined function for it.

poke around for other python routines that check for XML values, there might be a generic load-xml-data function written. Or they may at least give enough details to tweak their methods to your uses...

I honestly haven't looked at the files, i was just theorizing and hoping to help out =)
 
Rayanth said:
poke around for other python routines that check for XML values, there might be a generic load-xml-data function written. Or they may at least give enough details to tweak their methods to your uses...

I honestly haven't looked at the files, i was just theorizing and hoping to help out =)

Well I have looked at the XML quite extensively and it doesn't look like the original XML can handle it. I don't like the "rediculous discount" idea because an AI would almost surely still try to build it... I didn't think about trying to play with the python. I don't know python per se but it wouldn't be the first time I've picked up a new language by reading somebody else's code... maybe I'll try that.

RH
 
Whew on second thought... that stuff is definately not something I'm going to pick up quickly without some help. I see lots of "def" commands that define functions but I don't ever see any of the actual script code that does anything... what am I missing? Is that all pre-compiled into DLLs or are they in other files that i'm not looking at?

RH
 
RobHunt said:
Whew on second thought... that stuff is definately not something I'm going to pick up quickly without some help. I see lots of "def" commands that define functions but I don't ever see any of the actual script code that does anything... what am I missing? Is that all pre-compiled into DLLs or are they in other files that i'm not looking at?

RH

*Dom Pedro II breathes a sigh of relief as RobHunt asks the question that he has been wondering himself but was too shy and embarressed to ask*

Yeah... anybody who's made a mod using python, answer the poor man's question! :p
 
RobHunt said:
Whew on second thought... that stuff is definately not something I'm going to pick up quickly without some help. I see lots of "def" commands that define functions but I don't ever see any of the actual script code that does anything... what am I missing? Is that all pre-compiled into DLLs or are they in other files that i'm not looking at?

RH

There isn't much code that actually does anything in the python part. It's in the c++ part but you can override some things (and add to others) by using those functions. The mods that come with the game are a good example. The mods that are available here another... atleast those that change python some way.
 
Do it the exact same way we did for Civ3 ;)

Make a set of inaccessible techs, one for each trait (be sure to set them to no-trade and no-research!), then give each leader the techs associated with their traits. Once you've done that, simply add that tech to the required techs list on the building and voila. It's actually even better with Civ4 because you can have things require multiple techs to build, so placing them in the tech tree is easier.
 
Zurai said:
Do it the exact same way we did for Civ3 ;)

Make a set of inaccessible techs, one for each trait (be sure to set them to no-trade and no-research!), then give each leader the techs associated with their traits. Once you've done that, simply add that tech to the required techs list on the building and voila. It's actually even better with Civ4 because you can have things require multiple techs to build, so placing them in the tech tree is easier.

well... if the "right" way isn't available (yet -- hurry up that SDK firaxis!)...

/me starts digging in the tech tree file...

Hmm I see "bTrade" and "bDisable"... which are usually 1 and 0, so I'm guessing that reversing that would set "no-trade" and "no-research"...

But then I crash-and-burn again... how to give the tech to a leader. I see how to give the tech to a Civilization, but not to a specific leader.

Yeah I'm sure I could hack up the schema to allow me to put the "free tech" tag into a leader, but would it do any good? I doubt the system would be able to load it, and even if it did manage to load it, would it have any clue what to do with it?

RH
 
Python script. I'd forgotten that you can't directly assign techs to leaders in the XML, but you can assign techs in Python. Just tie an event to the GameStart event in CvEventManager.py to go through each leader in the game and assign techs based on their traits.

If you don't mind waiting about a month, I'll whip up a quick mod shell to do this. I want to have trait-specific buildings, units, etc in my own mod so I need to do the work for it anyway.
 
Well if I haven't gotten impatient and hacked it out myself I'll probably use your stuff then... or at least take a look at it.

So if you can't research it but you can still possess it, I'm kinda wondering what ways you could obtain it if it's no-trade no-research. There's the gamestart event... random events... goody huts (though you probably wouldn't want it there)... special events like building your first gunpowder unit (for example)... and a few others...

Speaking of events giving techs, I'm reminded of the SciFi game from Test of Time. Anybody else play that? I wonder if the linked-multi-map feature of that could be replicated (and/or improved) in Civ4 after the SDK comes out... I mean, why not? I'm idly curious how long it will be after the SDK comes out before everything folks liked from earlier Civ games is replicated in a mod somewhere...

RH
 
Chinese American said:
that doesnt work because you can still research a tech if you click on the second tech.

Even if that's true (which I hope it's not), the free tech probably wouldn't lead to anything in this case. For other mods that could be a problem.

About the DLLs, a lot of the Python files import stuff directly from the DLLs. That's why you can't find the functions that are referenced.
 
Back
Top Bottom