1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

[SDKMOD] Scriptable Leader Traits

Discussion in 'Civ4 - Mod Components' started by TheLopez, Jun 26, 2006.

  1. TheLopez

    TheLopez Chieftain

    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
     
  2. Dom Pedro II

    Dom Pedro II Modder For Life

    Joined:
    Apr 3, 2002
    Messages:
    6,811
    Location:
    Exit 16, New Jersey
    This is very nice! I'm not entirely sure how I can make use of it right now, but I'm sure I'll find a way :)
     
  3. RogerBacon

    RogerBacon Chieftain

    Joined:
    Nov 16, 2003
    Messages:
    649
    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
     
  4. Shqype

    Shqype Shqyptar

    Joined:
    Nov 15, 2005
    Messages:
    2,468
    Location:
    New York + Shqypni
    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 :)
     
  5. TheLopez

    TheLopez Chieftain

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon
    Shqype, you misunderstand, this mod doesn't let you swap leaders, just leader traits.
     
  6. Shqype

    Shqype Shqyptar

    Joined:
    Nov 15, 2005
    Messages:
    2,468
    Location:
    New York + Shqypni
    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!
     
  7. TheLopez

    TheLopez Chieftain

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon
    No, not really, there is also the favorite civic and some other "attitude" characteristics.

    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.
     
  8. Shqype

    Shqype Shqyptar

    Joined:
    Nov 15, 2005
    Messages:
    2,468
    Location:
    New York + Shqypni
    Ahh, how could I forget ... the attitude or personality of the leader is really what makes him. Good point.

    Would be cool if you could release a python function that changes the leader of the civ :)
     
  9. Impaler[WrG]

    Impaler[WrG] Civ4:Col UI programmer

    Joined:
    Dec 5, 2005
    Messages:
    1,750
    Location:
    Vallejo, California
    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.
     
  10. Impaler[WrG]

    Impaler[WrG] Civ4:Col UI programmer

    Joined:
    Dec 5, 2005
    Messages:
    1,750
    Location:
    Vallejo, California
    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.
     
  11. TheLopez

    TheLopez Chieftain

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon
    Ok, the zip is fixed.
     
  12. TheLopez

    TheLopez Chieftain

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon
    Updated with Warlords compatible link!!!
     
  13. Tabris

    Tabris Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    98
    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
     
  14. ocedius

    ocedius C++ induced baldness

    Joined:
    Jun 27, 2003
    Messages:
    617
    Location:
    TX and proud of it!
    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
     
  15. TheLopez

    TheLopez Chieftain

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon

    Thanks, I'll update the code and reupload it. :goodjob:
     
  16. ocedius

    ocedius C++ induced baldness

    Joined:
    Jun 27, 2003
    Messages:
    617
    Location:
    TX and proud of it!
    Did I mention I absolutely love this component now that I have got it to work :goodjob:
     
  17. TheLopez

    TheLopez Chieftain

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon
    Alright I have posted a new version for Warlords that includes ocedius's fix.
     
  18. Kael

    Kael Chieftain

    Joined:
    May 6, 2002
    Messages:
    17,400
    Location:
    Ohio
  19. Kael

    Kael Chieftain

    Joined:
    May 6, 2002
    Messages:
    17,400
    Location:
    Ohio
  20. TheLopez

    TheLopez Chieftain

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon
    :confused: Kael, did I miss something? :confused:
     

Share This Page