[SDKMOD] Scriptable Leader Traits

TheLopez

Deity
Joined
Jan 16, 2006
Messages
2,525
Location
Oregon
Scriptable Leader Traits
By: TheLopez

Last Updated 11/08/06

Version: 0.3w
Patch Compatibility: Warlords v2.0.8.0
MP Compatible: ?
Download Mod v0.3w

Version: 0.1.1
Patch Compatibility: v1.61
MP Compatible: ?
Download Mod v0.1.1

Description:
Adds the ability to add and remove traits from leaders through python.

I have tried to test the code as best as possible to make sure when a leader
trait is added or removed all of the game attributes are updated as well.
Please report any inconsistent behavior as soon as you find it so I can fix the
issue and make a new release.

-----Notes to Modmakers-----

If you want to use this mod component in your mod I have tried to make things
as easy as possible for you. In the SDK files I have added
// < Scriptable Leader Traits Start > and
// < Scriptable Leader Traits End > in all of the places where changes
were made.

As part of the changes to the SDK files I have also included two new methods in
the CvPlayer class and exposed them to python they are:
void CvPlayer::addTrait(TraitTypes eTrait);
void CvPlayer::removeTrait(TraitTypes eTrait);

This way any traits in the game can be added or removed through python.


-----Version Information-----

-----v0.1.1------

- Added missing code provided by Kael to addTrait and removeTrait

Spoiler :

-----v0.1------

- Setup the Scriptable Leader Traits mod infrastructure by branching off the
Dynasty Mod.

- Added the code needed in the SDK to enable the scripting of leader traits
through Python



-----===Credits & Thanks===-----

- Exavier
Composite Mod - readme.txt format
 
This will be a good addition to the things we can do with Python. I know of one problem I'll have though because I have it with the AIAutoPlay mod that lets you switch leaders (and thus, leader traits). If you have a leader trait that gives a special ability that you store in data storage (or SDToolkit), when you switch leader traits the values won't be initialized correctly.
I'm sure there is a way around this (maybe just call the init code again) but I thought I'd share it in case some people have special traits that use data storage like some of mine do.

Roger Bacon
 
Cool TheLopez! This will be useful for my mod as well, the ability to change leaders. Then again, your whole Dynasties Mod will be useful for me, so I should just wait to incorporate the whole thing. Thanks :)
 
Shqype said:
Cool TheLopez! This will be useful for my mod as well, the ability to change leaders. Then again, your whole Dynasties Mod will be useful for me, so I should just wait to incorporate the whole thing. Thanks :)
Shqype, you misunderstand, this mod doesn't let you swap leaders, just leader traits.
 
Isn't that essentially the same thing? The only thing that really makes a leader are his traits, no? If I began a game as "American Leader" I could get a printout to the screen that Washington (Financial, Organized) is leading the American people.

Later I can trigger an event that Bill Clinton (Financial, Aggressive) has risen up to lead the American people.

Sure, it's not as simple as having multiple leaders in the XML and having python code to more easily "switch" to a new leader, but it's better than what we've had up until now!
 
Shqype said:
Isn't that essentially the same thing? The only thing that really makes a leader are his traits, no? If I began a game as "American Leader" I could get a printout to the screen that Washington (Financial, Organized) is leading the American people.
No, not really, there is also the favorite civic and some other "attitude" characteristics.

Shqype said:
Later I can trigger an event that Bill Clinton (Financial, Aggressive) has risen up to lead the American people.

Sure, it's not as simple as having multiple leaders in the XML and having python code to more easily "switch" to a new leader, but it's better than what we've had up until now!
True, but wait until I get the rest of the dynasty mod coded up. I might just release several of its pieces as standalone mod comps as well, like this one.
 
TheLopez said:
No, not really, there is also the favorite civic and some other "attitude" characteristics.
Ahh, how could I forget ... the attitude or personality of the leader is really what makes him. Good point.

True, but wait until I get the rest of the dynasty mod coded up. I might just release several of its pieces as standalone mod comps as well, like this one.
Would be cool if you could release a python function that changes the leader of the civ :)
 
Hasn't jdog5000 made a mod for switching the whole leader and or Civ or a player? shurly the Traits are switched when that is done but did he alow only the combinations that already exist in XML? Ware as this could be used to arbitrarily change a leader (well actualy the "Player" at the code level) to any consivable combination or Traits.
 
Lopez I think you might have acidently uploaded virgin SDK files rather then the changed files, I cant find any diffs under win-merge nor any of the new functions.
 
Impaler[WrG] said:
Lopez I think you might have acidently uploaded virgin SDK files rather then the changed files, I cant find any diffs under win-merge nor any of the new functions.

Ok, the zip is fixed.
 
Updated with Warlords compatible link!!!
 
Very cool, now we can make leaders changes by year like in Europa Universalis so that a immortal ruler don't govern our civs forever
 
TheLopez, I am certain cvplayer.cpp is missing stuff. I was working on my mod when I saw your post. Since I already ported the code over to warlords, I double checked and the file is missing these enteries.

Code:
				changeExtraHappiness(GC.getTraitInfo((TraitTypes)iI).getHappiness());

				for (iJ = 0; iJ < GC.getNumBuildingInfos(); iJ++)
				{
					changeExtraBuildingHappiness((BuildingTypes)iJ, GC.getBuildingInfo((BuildingTypes)iJ).getHappinessTraits(iI));
				}

				changeLevelExperienceModifier(GC.getTraitInfo((TraitTypes)iI).getLevelExperienceModifier());
				changeGreatGeneralRateModifier(GC.getTraitInfo((TraitTypes)iI).getGreatGeneralRateModifier());
				changeDomesticGreatGeneralRateModifier(GC.getTraitInfo((TraitTypes)iI).getDomesticGreatGeneralRateModifier());

Edit: I'd upload the 'cerekted' one, but my files have a ton of other stuff in 'em :p
 
ocedius said:
TheLopez, I am certain cvplayer.cpp is missing stuff. I was working on my mod when I saw your post. Since I already ported the code over to warlords, I double checked and the file is missing these enteries.

Code:
				changeExtraHappiness(GC.getTraitInfo((TraitTypes)iI).getHappiness());

				for (iJ = 0; iJ < GC.getNumBuildingInfos(); iJ++)
				{
					changeExtraBuildingHappiness((BuildingTypes)iJ, GC.getBuildingInfo((BuildingTypes)iJ).getHappinessTraits(iI));
				}

				changeLevelExperienceModifier(GC.getTraitInfo((TraitTypes)iI).getLevelExperienceModifier());
				changeGreatGeneralRateModifier(GC.getTraitInfo((TraitTypes)iI).getGreatGeneralRateModifier());
				changeDomesticGreatGeneralRateModifier(GC.getTraitInfo((TraitTypes)iI).getDomesticGreatGeneralRateModifier());

Dit: I'd upload the 'cerekted' one, but my files have a ton of other stuff in 'em :p


Thanks, I'll update the code and reupload it. :goodjob:
 
Alright I have posted a new version for Warlords that includes ocedius's fix.
 
Nothing to see here.
 
Ahh.. I think I missed a step.
 
:confused: Kael, did I miss something? :confused:
 
Top Bottom