The Forums Are Now Closed!

The content will remain as a historical reference, thank you.

Treaties in Elemental

By on December 3, 2009 6:01:05 PM from Elemental Forums Elemental Forums

One of my tasks for this beta was getting in basic diplomacy, although it's still pretty primitive because the relations code is still pretty basic.

You can bring up the Diplomacy screen by going to KingdomWnd and clicking on Foreign Relations.  If you've encountered another player, you can click on their entry and click the speak to button or double click on the entry.  This gives you 3 options, one of which is disabled: Info, Trade (disabled) and Negotiations.  Info compares your stats to the other faction (currently doesn't require espionage or anything else). Trade will be for actually trading resources, units, etc. but is not yet implemented.  Negotiation has several treaties, which actually do work.

In the Info screen, you can click on one of three categories to display information about: Civilization, Warfare and Magic.  Magic currently doesn't show anything since magic is not currently enabled.  Civilization shows stats about things like your treasury, food, research, etc.  Warfare lists stats about your military.  We may also want to show Diplomacy/Foreign Relations info on this screen also.

Apparently the latest version of the Negotiate screen introduced a bug where not all the treaties are listed immediately; scrolling with the scrollbar fixed this for me.  The Negotiate screen lists all the possible treaties, with information about what you would get from each treaty.   This needs to be tweaked further because they could really use a 1 line description under each treaty.  At any rate, there are thre kinds of treaties right now: treaties that give you bonuses, treaties that affect your relations, and treaties that the code checks for to allow certain behaviors. 

New in this beta is the ability to build to roads to foreign cities so that you can trade with other players. This gives you a bonus to your income. I believe that trade between your own cities gives you a bonus to your income as well. If you setup a trade treaty with another player, you will get an additional bonus to income based on the trade income of the other player and your diplomacy score.  They also get a bonus based on your trade income and their diplomacy score.

The technology treaty gives you a bonus to your research points per turn based on the other player's research points per turn and your diplomacy score, and similarly, the other player gets a bonus from your research points per turn (not including bonuses from treaties).

The other treaties affect your relations.  Currently, you can't declare war from this screen unless you have hostile relations with the other player.  But you can get peace if you declare war by invading enemy territory.  Declaring war cancels all treaties with the other player.  This is currently the only way to cancel treaties.

The Non-Agression Pact allows you to pass through the other player's territory.  Eventually, we may make a dialog so that you can limit the duration, but for now it's infinite unless you declare war.  The Non-Agression Pact doesn't affect relations or give you anything else.

The really cool thing about the treaties is that they're completely data driven.  Here's an example from the xml file that defines the treaties:

Code: xml
  1. <Treaty InternalName = "TradeTreaty" Type = "Trade">
  2.   <DisplayName>Trade Treaty</DisplayName>
  3.   <Description>Both parties get a bonus to their income from trade.</Description>
  4.   <Duration>-1</Duration>
  5.   <MinimumRelations><![CDATA[[RELATIONS_NEUTRAL]]]></MinimumRelations>
  6.   <Calculate InternalName = "TradeTreatyValue" ValueOwner="Player_2">
  7.    <Expression><![CDATA[[TradeIncome]*[TradeTreatyRate]]]></Expression>
  8.   </Calculate>
  9.   <Calculate InternalName ="TradeTreatyRate" ValueOwner="Player_1">
  10.    <Expression><![CDATA[[A_Diplomacy]*0.1]]></Expression>
  11.    <Min>0.01</Min>
  12.    <Max>1.0</Max>
  13.   </Calculate>
  14.   <Calculate InternalName = "TradeIncomeBonus" ValueOwner="Player_1">
  15.    <Expression><![CDATA[[TradeTreatyValue]+[TradeIncomeBonus]]]></Expression>
  16.   </Calculate>

Duration is the number of turns that the treaty lasts. -1 is infinite, 0 is a one time effect, and anything else is a limited treaty.

You can specify Minimum and Maximum relations, or simply RequiredRelations. These were easy to do, but the really cool part was desiging the calculation system.

Each Calculate object has an internal name which can in turn be used as a variable in another Calculate object. 

The ValueOwner attribute is a tag that lets the parent class (in this case, the treaty) know what can provide the other variables it needs. When the treaty is created, it calls a function called SetValueOwner which goes down the chain and sets the pointer for the ValueOwner based on the tag.  The tags are meaningful for the code that calls it: the treaty code only deals with the two players it has pointers to, so "Player_1" and "Player_2" refer to its pointers rather than the players with IDs 1 and 2, which might be tags used by another class.

Each Expression can be at most a binary operation (one operator, two operands), but you can build more complicated equations by chaining the Calculate objects. Each Expression can specify a max and min value, although they don't have to specify both.

When the calculation is performed, the Calculate object first goes through and asks its ValueOwner to replace tags in a copy of the expression tag with the appropriate values, and also asks its child calculations for their values.  When all the tags have been replaced, the expression is evaluated.

Right now, only a few values have been exposed to the interface that gets passed to the Calculate values, but we'll be able to expose more over time so that you can use the interface in scripts and mods.  I'd really like to see more of the data types using the Calculate objects because it would mean that even non-coders could make significant mods, and C++ would be doing most of the work (since C++ is faster than python for a lot of tasks).

 

+52 Karma | 9 Replies
December 3, 2009 7:20:03 PM from Elemental Forums Elemental Forums

Can't wait to see it. A robest political/diplomatic system is one of the main things I find fun in 4X games, especially in the later game when all the exploring is done.

I really like the numerical system as well. Even for those of us who know how to code would just assume avoid it if it isn't necessary.

December 3, 2009 8:06:23 PM from Elemental Forums Elemental Forums

Fascenating modding system..... of course, it still alarms me to see the devs proceeding further down the "closed borders" track.......... but I'll be modding that out shortly if they don't......

December 4, 2009 7:18:44 AM from Elemental Forums Elemental Forums

That's great work Cari, very useful as well. Especially the peek at the internal code. It's going to be very moddable from the looks of it. Well done.

December 4, 2009 7:31:50 AM from Elemental Forums Elemental Forums

Quoting Raven X,
That's great work Cari, very useful as well. Especially the peek at the internal code. It's going to be very moddable from the looks of it. Well done.

Indeed...can't wait to test it!

December 5, 2009 12:16:00 PM from Elemental Forums Elemental Forums

Interesting thing with the CDATA for computations.

Iwould like to suggest the standard Dominions' NAP duration to be available, namely -3 = needs three turns before cancelling.

Basically, -1 currently means infinite, but I guess it can be cancelled immediately (like peace treaty ends when you declare war). So if I want a NAP that requires 3 turns of warning before it's actually cancelled, and the game enforces this, a -3 value could be used.

I think this duration is very important, at least for multiplayer. So for instance you can't declare war until 3 turns elapsed. Furthermore, being coded, you won't get bad surprises because one player thought the delay started running on the turn after announcing end of the treaty, and the other thought on the same turn as announcing.

December 5, 2009 3:54:22 PM from Elemental Forums Elemental Forums

Quoting LDiCesare,
Interesting thing with the CDATA for computations.

Iwould like to suggest the standard Dominions' NAP duration to be available, namely -3 = needs three turns before cancelling.

Basically, -1 currently means infinite, but I guess it can be cancelled immediately (like peace treaty ends when you declare war). So if I want a NAP that requires 3 turns of warning before it's actually cancelled, and the game enforces this, a -3 value could be used.

I think this duration is very important, at least for multiplayer. So for instance you can't declare war until 3 turns elapsed. Furthermore, being coded, you won't get bad surprises because one player thought the delay started running on the turn after announcing end of the treaty, and the other thought on the same turn as announcing.

I agree with LDiCesare said.   Probably instead of using -ve value to implement that, just add a value call "# of turns needed to actually cancell" it

==

Yes, treaties are about getting bonus when there is +ve interaction with a friend.     But this implies the more treaties you made the better off you are.   I believe there should be some mechanism to combat this 'more is better' no-brainer decision.

For example, you can only establish 2 trade treaties total untill you reseach/reach a higher diplomacy technology.

Or, establishing a trade treaty with player A, will reduce your diplo friendliess with many other players because player A is a Evil player.

Or, the more treaties you have with the player A, it takes a lot more number of turns you can actually attack him AFTER you declare war.

 

 

December 5, 2009 6:25:35 PM from Elemental Forums Elemental Forums

Ah this is just great...

Several treaty types is fantastic news.

CariElf, will their be any bonuses tied to relations status? As in increasing values depending on the flow of love? It would be a great way to deepen alliances in the game and a possible way out against a recourse lucky juggernaught.

Would it possible to integrate tech trade into the diplomacy model?

December 6, 2009 7:09:57 AM from Elemental Forums Elemental Forums

Just a quick note: Please implement a "Joint attack on X city' diplomatic option. I always loved this feature in the KOEI strategy games. [It's working like this in the KOEI games: If the relations are high enough between your Kingdom and the AI Kingdom, you can ask the AI to launch a joint attack on X province.]

January 13, 2010 10:33:18 AM from Elemental Forums Elemental Forums

Hope trades, diplomacy and warmaking decisions are openended in multiplayer format.  With only set game type diplomacy, etc for computer AI.

Stardock Forums v1.0.0.0    #108435  walnut2   Server Load Time: 00:00:00.0000469   Page Render Time:

Stardock Magazine | Register | Online Privacy Policy | Terms of Use

Copyright ?? 2012 Stardock Entertainment and Gas Powered Games. Demigod is a trademark of Gas Powered Games. All rights reserved. All other trademarks and copyrights are the properties of their respective owners. Windows, the Windows Vista Start button and Xbox 360 are trademarks of the Microsoft group of companies, and 'Games for Windows' and the Windows Vista Start button logo are used under license from Microsoft. ?? 2012 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo and combinations thereof are trademarks of Advanced Micro Devices, Inc.