Trait - Earn gold by # of civs

Discussion in 'Civ5 - Creation & Customization' started by martijnaikema, Dec 7, 2010.

  1. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    Hi all,

    I was wondering if it possible to make a trait where you earn gold/hapiness by:
    * the number of civs you met
    * the number of civs you are not at war with
    * the number of citystates you met
    * the number of citystates you are not at war with

    I looked at the Civ5Traits.xml file and the only things I could find is:
    - CityStateBonusModifier -> city-state bonuss (food, culture) -RAMKHAMHAENG
    - CityStateFriendshipModifier -> city-state influence - ALEXANDER

    But maybe there is another way like trait that gives you a unique unit or building which can give the things I need.

    Hope someone can help me out.

    Greetings,
    Martijn
     
  2. magzhi

    magzhi Warlord

    Joined:
    May 23, 2010
    Messages:
    197
    I think that you can't do it by using xml.
     
  3. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    I would have to agree.
     
  4. Louis XXIV

    Louis XXIV Le Roi Soleil

    Joined:
    Mar 12, 2003
    Messages:
    13,579
    Location:
    Norfolk, VA
    Anyone know if it's possible through lua?
     
  5. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    I also would like to know :)
     
  6. Louis XXIV

    Louis XXIV Le Roi Soleil

    Joined:
    Mar 12, 2003
    Messages:
    13,579
    Location:
    Norfolk, VA
    Heh, I figured you'd want to know more than me. My only interest is intellectual. I want to know the extent and power of lua.

    BTW, what civ do you want to give this ability to?
     
  7. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    It sure is. I'm not really convinced by the design, though. It scales very strongly with map size and type and could be extremely bad in some games but completely awesome in others if the bonus is large enough to matter. Still, it's not worse than the German or Ottoman UA

    There's a Team:GetHasMetCivCount() function that could be easily used to implement it, then you'd just have to adjust the palace yield and make it display in the UI if the player is playing that faction. For someone who never coded Lua, it's still difficult, though ;)
     
  8. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    Guess i got to learn some lua then :)
    I will read the tuts and see if I can figure it out.

    Thanx for you help :)
     
  9. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    Actually what I meant with palace yield was to use one of the City:ChangeBaseYieldRateFromMisc() or City:ChangeBaseYieldRateFromBuildings() functions for the capital, not sure which one works. Might take a bit of fiddling around.
     
  10. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    Thanx a lot. You know a good place to start learning LUA? I have some basic programming skills but haven't tried LUA yet.
     
  11. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    Yes there is a slightly outdated book freely available on lua.org called Programming in Lua, which is a quite decent play to start. There are unfortunately no good tutorials for Civ5 yet.
     
  12. Slowpoke

    Slowpoke The Mad Modder

    Joined:
    Sep 30, 2010
    Messages:
    1,321
    Heh, yeah lua doesn't look hard. What's hard is finding out what all the functions do :cry: That's why I haven't really started it in earnest.
     
  13. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    I can agree...I read some basic stuff lua.org, but I think I am going to skip that and focus on the available lua files in the game-directory and play with them in FireTuner. I might be able to figure it out myself :).
     
  14. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    It's also a good idea to look at other mods and what they do, you can learn a lot from that
     
  15. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    I did a quick search at the LUA Reference WIKI and I guess I have to look at the following functions:
    * Team:GetHasMetCivCount() -> Determine how many civs the user has met
    * Team:GetAtWarCount() -> Determine how many civs the user is at war with
    * With this two functions I can determine how many civs the user knows and is not at war with

    Next I use a formula to determine how many gold a turn the civ is getting for the peaceful trait. Then if I want to make the Gold Yield (so Ancient/Classic * 1, Medieval/Rennaisance *2, Industrial/Modern *3, Future *4), I have to make the script determine which Era the civ is in (I guess I can use function Team.GetCurrentEra ()).

    And after the yield is determined I have to actually give the gold yield to the civ. Do I need to asign it to a (unique) building?

    I am going to have a look at the lua-mods and see if I can figure it out :). Thanx so far!
     
  16. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    What I could do is to make the yield dependend of the number of civs that are playing. I guess I can get that information with the function Game:CountCivPlayersAlive ().
     
  17. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    Yes you pretty much got it right I think. I guess the easiest way is just to use Player:ChangeGold() for every player at the start of the active player's turn to add money. It's a bit difficult to display things in the UI, though. If you want to release the mod you probably have to do that, so you have to edit TopPanel for the GPT display and probably the EconomicGeneralInfo.

    If you choose to go that way, be aware that the AI isn't going to understand it. I don't think that matters much if the sum given isn't huge, though.
     
  18. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    I am on my way of understandig the lua a little better.

    One thing I am struggling with is the code to count how many civs a team has met. I hope someone can help me out with it.

    I figured out to use Team:GetHasMetCivCount(), but I can not get it to work.

    What I tried:
    Get the ID of the active player: aID = Game.GetActivePlayer()
    Use this to get the civs the player met: print (Players[aID]:GetHasMetCivCount())

    But when I use this code I get an error saying:
    Runtime Error: [string "_cmdr = {print (Players[aID]:GetHasMetCivCo..."]:1: attempt to call method 'GetHasMetCivCount' (a nil value)
     
  19. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    Well, it's a function of the Team object, not the Player object. So you can use Players[0]:GetTeam():GetHasMetCivCount()

    If you use GetActivePlayer, it will not work for the AI but I guess you're just testing code and know that ;)
     
  20. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    Thanx again :)
    And yes I knew that. Assigning it to the correct player will be the last of my coding :)
     

Share This Page