Advanced Diplomacy 2

This:
Code:
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++) 
    { 
        if ((iI == ePlayer) || (iI == getID())) 
            continue;
Should most likely be this:
Code:
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++) 
    { 
        if ((iI != ePlayer) || (iI != getID())) 
            continue;
 
While compiling I found a few errors. The == NULL should probably read == NO_PLAYER.
True, I could replace the kPlayer == NULL checks with ePlayer == NO_PLAYER at the start of both functions

In addition for the AI_sharedEnemyattitude function, calling on kPlayer.isAlive causes a argument list error.
I forgot the brackets after the function call, should be:
PHP:
if (GET_PLAYER(ePlayer).isAlive() && !atWar(getTeam(), GET_PLAYER(ePlayer).getTeam()))

This:
Code:
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++) 
    { 
        if ((iI == ePlayer) || (iI == getID())) 
            continue;
Should most likely be this:
Code:
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++) 
    { 
        if ((iI != ePlayer) || (iI != getID())) 
            continue;
No, the original code is correct. The continue statement in C++ says to continue to the next loop iteration, which in this case if the for MAX_CIV_PLAYERS loop. So the code is saying that if the loop player (iI) is the same as ePlayer or the player calling the function then don't bother doing any more checks on it as it isn't a third party and move on to the next player.
 
I took a look at the close borders attitude code. It checks to see if the borders have changed recently and then returns an attitude value. It isn't a memory so it does not decay. It does not return a value if you the other civ is your vassal or on the same team.
 
New version is up:

Version 2.51
-Open Borders requires Right of Passage for bug fix
-Bug Fixed where trading right of passage and open borders at same time did not cancel right of passage
-Free Trade Agreement requires Open Borders
 
Well, if, the continue statement isn't something I normally use, so that is wehere my confusion comes from. Please tell me if I am correct or not. Continue in a loop tells the loop to go onto the next iteration of the loop, and not to continue to the next if/else statement.
 
Indeed, which is why the altered code he quoted of yours don't make sense.
If iI != ePlayer: continue
Means skip everyone except ePlayer
 
I've attached the lastest revision to look at. It crashes with an unhandled exception so I can't pinpoint the code. It only does so after you have a common enemy (checked via worldbuilder). Otherwise, no CTD. I've included a debug.dll.

Hopefully someone can figure it out.
 

Attachments

  • Advanced Diplomacy v2.52.7z
    2.5 MB · Views: 201
I unfortunately am unable to figure out the CTD from the sharedenemy code.

You should ask Afforess for advice
He is back nowadays, and working on some updates for his RoM-AND mod
 
I know this modcomp is based on my original work, so just an FYI I have fixed the two-liner embassy bug and added 2 new trade options today:

Revision 726

  • Turn on old BTS path finding
  • Add new diplomacy trade option: Cease Relations With (Player)
  • Add new diplomacy trade option: Pay War Reparations
  • Fixed Embassy diplomacy trade option to only use 1 line instead of 2 on trade screen
  • Track war mongering by players, have it influence attitude
  • Minor diplomacy AI improvements & bug fixes

Diff View
 
This is great Afforress. It is definelty based on your work and would not be possible without you. I can't wait to take a look at your additions. I will merge them too.

Thanks for fixing the embassy node. If you get a chance and notice anything in the shared enemy code in the above posts, please let us now. Thanks.
 
Version 2.6
-Added Backstab memory to trigger for friends and teamates
-Embassy node removed
-AND additions (embassy visibility fix, AI less likely to ask for help if they don't like you)
-Added cancelled non aggression memory
-Added Gameoption to Backstab, war pretexts, all new memories, new votes
-Added in missing can trade workers globaldefines
-rearranged order of trades
 
I figured out how to code the shared enemy attitude. I'm going to take some of Afforess's code and use some of the worst enemy code already in the C++. In addition, I can just inverse that the get a shared friends code. Lastly, I'll add a text string for Closest Ally of.
 
Hi stolenrays.

I merged this into Better BAT AI, but I'm 77 turns into a game, and I've met 5 civs so far. They are all at pleased or friendly with me (even Tokugawa). Is this normal? It seems a little odd to me... I must have merged something wrong, yes?
 
Top Bottom