[SDK] Advanced Diplomacy

Discussion in 'Civ4 - Mod Components' started by Afforess, Jul 30, 2010.

  1. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,481
    Are embassies needed for alliances?
     
  2. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    No, but you can make them a requirement fairly simply if you wish.
     
  3. jerrybp

    jerrybp Chieftain

    Joined:
    May 17, 2010
    Messages:
    20
    Just what i wanted!
    I'm very interested in this mod, but I'm getting several errors. Help is appreciated...

    I'm loading the mod plainly as a stand alone mod, to test it first before attempting any merge.

    The screenshots I took showing the errors are in the attached file.

    At the very beginning, just before the "dawn of man" message, I get bug1.jpg and bug3.jpg

    I get bug2.jpg every time I go to another application in my PC.

    I get bug4.jpg at first contact with a civ.

    The diplo window is incomplete and no text appears, as shown in bug5.jpg. Basically i cannot talk to rival leaders!

    Also, I have no interface in the main map. Alt+I doesn't work. Calling BUG (CTRL+ALT+O) does not work either.

    Since I'm using BUG, I renamed the BUG_CvMainInterface.py file in python/screens folder to CvMainInterface.py, as the readme.txt says in that same folder.

    I suspect something is colliding with BUG, but I don't know what to do to solve it....:sad:
     

    Attached Files:

  4. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    You'd to merge the files by hand. The mod only works stand-alone, merging with BUG requires a bit more know-how. First off, you need to install BUG as a mod, not in the CustomAssets. Then you'd need to use Winmerge, or some similar tool to merge the differences in overlapping files.
     
  5. jerrybp

    jerrybp Chieftain

    Joined:
    May 17, 2010
    Messages:
    20
    I uninstalled BUG and it worked. :D
    This is excellent. Many thanks for this mod, Afforess.

    A couple of questions:
    1) In the leaderheads XML there's no "RefuseAttitudeThreshold" tag for Rights of Passage.... does this mean RoP will be accepted by leaders in most ocasions? Is there a fixed internal threshold you're using?

    2) You said above that it should be simple to set embassies as requirements for alliances... How exactly? More general really: where can I set the diplo agreements that are allowed with embassies?
     
  6. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    1.) The Threshold for RoP is the same as Open Borders.

    2.) In CvPlayer::canTradeItem, it breaks down each trading object and the critieria needed to trade it. The function "GET_TEAM(getTeam()).canSignOpenBorders(GET_PLAYER(eWhoTo).getTeam())" determines if the player should have an embassy for the trading item. So if you wanted to make embassies a requirement, for say, map trading, find the map section:

    Code:
    case TRADE_MAPS:
    		if (getTeam() != GET_PLAYER(eWhoTo).getTeam())
    		{
    			if (GET_TEAM(getTeam()).isMapTrading() || GET_TEAM(GET_PLAYER(eWhoTo).getTeam()).isMapTrading())
    			{
    				return true;
    			}
    		}
    		break;
    
    And add a new if check for the embassies, like so:

    Code:
    case TRADE_MAPS:
    		if (getTeam() != GET_PLAYER(eWhoTo).getTeam())
    		{
    			if (GET_TEAM(getTeam()).isMapTrading() || GET_TEAM(GET_PLAYER(eWhoTo).getTeam()).isMapTrading())
    			{
    				[COLOR="Red"]if (GET_TEAM(getTeam()).canSignOpenBorders(GET_PLAYER(eWhoTo).getTeam()))[/COLOR]
    				[COLOR="red"]{[/COLOR]
    					return true;
    				[COLOR="red"]}[/COLOR]
    			}
    		}
    		break;
    
     
  7. Musketeer935

    Musketeer935 AoEIII Fan

    Joined:
    Apr 15, 2009
    Messages:
    67
    Something I've always wanted in the game is better Diplomacy :D

    Anyway, one thing that would be nice is a non-permanent alliance.
    I'll set up a scenario to better explain. I am Lincoln. I am allied with Victoria.

    If I declare war with anyone, Victoria is automatically prompted to either join the war or break the alliance. If she breaks the alliance, we lose a few relation points, and possibly it auto-cancels other deals (thoughts on this?). The same thing would happen to me if Victoria declares war, of course. The leader of an alliance (whoever either declared the war, or was declared on) negotiates peace for the whole alliance.

    Also, if say Victoria is allied with Peter, and I am not allied with Peter. Victoria joins a war I declared, Peter probably should either not be prompted, or should be prompted but will have no penalties for not joining. (thoughts on this also? I think Alliance Chains would get annoying; one war might trigger the whole world. But, also, this is kind of realistic. )

    Also, when declaring war, another nice feature is the 'Are you sure?' prompt should list their allies (and indirect allies from chains if chains are there.)
     
  8. jerrybp

    jerrybp Chieftain

    Joined:
    May 17, 2010
    Messages:
    20
    Thanks a lot. I'll get into it.

    One thing: I'm refusing RoP offered by rivals, and they keep insisting in it every turn. Did you experience something like that in your tests?

    (On a side note: I made a very specific question in other forum regarding python code... It'd be nice if you could take a look at it, if that's not much to ask...)
     
  9. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    They ask just as often for RoP as they do for Open Borders in BTS.
     
  10. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    That's actually a LOT more complex than you think it is. Several modders, including myself discussed it a few months back on the Better AI forums, but the agreement was that the cost-to-benefit ratio was too low to add it as a feature.
     
  11. Musketeer935

    Musketeer935 AoEIII Fan

    Joined:
    Apr 15, 2009
    Messages:
    67
    I realized that it was indeed very complex (it was hard enough to explain, I can't even imagine coding it), I just wondered if you were willing to do it.

    Thanks anyways, the mod is great. :goodjob:

    The other thing I never really thought about too much, is when do Defensive Pacts become available? It seems I can never get one. :p
     
  12. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,481
    How can I prevent the AI from contacting the player every round?

    I've found this code for example

    PHP:
            if (AI_getContactTimer(((PlayerTypes)iI), CONTACT_PEACE_PRESSURE) == 0)
                                                {
                                                    if (
    GC.getGameINLINE().getSorenRandNum(GC.getLeaderHeadInfo(getPersonalityType()).getContactRand(CONTACT_PEACE_PRESSURE), "AI Diplo End War") == 0)
    But I cannot find XML variables for CONTACT_PEACE_PRESSURE. How can I set Contact Rands for all of your new contact types?


    Nevermind. Just found this in your civilizationinfos.xml. I must have missed it.

    PHP:
    <!-- Afforess Advanced Diplomacy-->
                    <
    ContactRand>
                        <
    ContactType>CONTACT_PEACE_PRESSURE</ContactType>
                        <
    iContactRand>100</iContactRand>
                    </
    ContactRand>
                    <
    ContactRand>
                        <
    ContactType>CONTACT_EMBASSY</ContactType>
                        <
    iContactRand>25</iContactRand>
                    </
    ContactRand>
                    <
    ContactRand>
                        <
    ContactType>CONTACT_TRADE_STOP_TRADING</ContactType>
                        <
    iContactRand>20</iContactRand>
                    </
    ContactRand>
                    <
    ContactRand>
                        <
    ContactType>CONTACT_TRADE_JOIN_WAR</ContactType>
                        <
    iContactRand>10</iContactRand>
                    </
    ContactRand>
                    <
    ContactRand>
                        <
    ContactType>CONTACT_TRADE_MILITARY_UNITS</ContactType>
                        <
    iContactRand>15</iContactRand>
                    </
    ContactRand>
                    <
    ContactRand>
                        <
    ContactType>CONTACT_TRADE_WORKERS</ContactType>
                        <
    iContactRand>25</iContactRand>
                    </
    ContactRand>
                    <
    ContactRand>
                        <
    ContactType>CONTACT_TRADE_CONTACTS</ContactType>
                        <
    iContactRand>25</iContactRand>
                    </
    ContactRand>
                    <!-- 
    Afforess Advanced Diplomacy-->
     
  13. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Are you sure you added the new CIV4LeaderheadInfos.xml for each leader:

    Code:
    <!-- Afforess Advanced Diplomacy-->
    				<ContactRand>
    					<ContactType>CONTACT_PEACE_PRESSURE</ContactType>
    					<iContactRand>100</iContactRand>
    				</ContactRand>
    				<ContactRand>
    					<ContactType>CONTACT_EMBASSY</ContactType>
    					<iContactRand>25</iContactRand>
    				</ContactRand>
    				<ContactRand>
    					<ContactType>CONTACT_TRADE_STOP_TRADING</ContactType>
    					<iContactRand>20</iContactRand>
    				</ContactRand>
    				<ContactRand>
    					<ContactType>CONTACT_TRADE_JOIN_WAR</ContactType>
    					<iContactRand>10</iContactRand>
    				</ContactRand>
    				<ContactRand>
    					<ContactType>CONTACT_TRADE_MILITARY_UNITS</ContactType>
    					<iContactRand>15</iContactRand>
    				</ContactRand>
    				<ContactRand>
    					<ContactType>CONTACT_TRADE_WORKERS</ContactType>
    					<iContactRand>25</iContactRand>
    				</ContactRand>
    				<ContactRand>
    					<ContactType>CONTACT_TRADE_CONTACTS</ContactType>
    					<iContactRand>25</iContactRand>
    				</ContactRand>
    				<!-- Afforess Advanced Diplomacy-->
    And

    Code:
    <!-- Afforess Advanced Diplomacy-->
    				<ContactDelay>
    					<ContactType>CONTACT_PEACE_PRESSURE</ContactType>
    					<iContactDelay>100</iContactDelay>
    				</ContactDelay>
    				<ContactDelay>
    					<ContactType>CONTACT_EMBASSY</ContactType>
    					<iContactDelay>25</iContactDelay>
    				</ContactDelay>
    				<ContactDelay>
    					<ContactType>CONTACT_TRADE_STOP_TRADING</ContactType>
    					<iContactDelay>20</iContactDelay>
    				</ContactDelay>
    				<ContactDelay>
    					<ContactType>CONTACT_TRADE_JOIN_WAR</ContactType>
    					<iContactDelay>20</iContactDelay>
    				</ContactDelay>
    				
    				<ContactDelay>
    					<ContactType>CONTACT_TRADE_MILITARY_UNITS</ContactType>
    					<iContactDelay>20</iContactDelay>
    				</ContactDelay>
    				<ContactDelay>
    					<ContactType>CONTACT_TRADE_WORKERS</ContactType>
    					<iContactDelay>20</iContactDelay>
    				</ContactDelay>
    				<ContactDelay>
    					<ContactType>CONTACT_TRADE_CONTACTS</ContactType>
    					<iContactDelay>15</iContactDelay>
    				</ContactDelay>
    				<!-- Afforess Advanced Diplomacy-->
    That is what controls how often leaders contact the player.
     
  14. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,481
    That's the same. I think you mean memory decay. ;)
     
  15. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Memory is how long the AI remember's past events, contacts are the time in-between trading sessions.
     
  16. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,481
    I've meant your post above. You've posted 2x the same.
     
  17. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,481
    the following line differs from your code in AND:

    AND code:

    PHP:
    bConsiderPeace = ((GET_TEAM(getTeam()).AI_getAtWarCounter(GET_PLAYER((PlayerTypes)iI).getTeam()) > 10) || (GET_TEAM(getTeam()).getAtWarCount(falsetrue) > 1) ||
    AD Code:

    PHP:
    bConsiderPeace = ((GET_TEAM(getTeam()).AI_getAtWarCounter(GET_PLAYER((PlayerTypes)iI).getTeam()) > 10) || (GET_TEAM(getTeam()).getAtWarCount(true) > 1) ||
    What's better/newer? You should change the date stamps. ;) Or update AD. :p
     
  18. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    I believe the AND code is better, but requires BBAI, which is why I used the second version in this modcomp.
     
  19. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,481
    Question: Do the new trade requests get blocked by the RevDCM new diplomacy option "Do not bother us"? If not, this should added to AND, so I could adept it. ;)
     
  20. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Did you notice the comments I made in CvPlayerAI?

    Code:
    //If using RevDCM, use AI_beginDiplomacy, otherwise, use gDLL->beginDiplomacy()
    gDLL->beginDiplomacy(pDiplo, (PlayerTypes)iI);
    //AI_beginDiplomacy(pDiplo, (PlayerTypes)iI);
    
    They appear a few times and will make the new trade items compatible with the Cease Bothering Us option.
     

Share This Page