• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Andrei Gijgorev

Civilian
3 Badges
May 23, 2007
686
65
  • Arsenal of Democracy
  • Darkest Hour
  • For The Glory
If you've ever played Muscovy/Russia in FtG, you'll know that around the end of the 17th century there's an event called the Treaty of Nerchinsk. Historically, this was an agreement between Russia and the still young Qing (Manchu) dynasty of China. The subject of this treaty was control over the Amur basin, i.e. the fertile lowlands left of the Amur River that today belong to Russia and are also known as Outer Manchuria in China. Moskvitin had reached the Pacific coast near Okhotsk in 1639, and when the Manchu (a.k.a. Jurchen) had consolidated their power in China, they also expanded into this region that was very close to their ancestral homelands and already partly settled by semi-nomadic Jurchen tribes.

There were a number of small-scale conflicts in the region that eventually culminated in the siege of Albazin, a fortified Russian settlement on the left bank of the Amur River. Following the expulsion of the Russian forces, the treaty of Nerchinsk was signed in 1689 and all lands left of the Amur River and south of the Stanovoy Range watershed were given to China. China wasn't interested in the inhospitable regions north of the Stanovoy Range and subsequently mostly focused on westward expansion, while Russia was ultimately more concerned with trading opportunities and peace in Far East than the Amur region. Those territories would remain in Chinese hands until the Treaty of Aigun in 1858, when the much-weakened Qing dynasty had no choice but to surrender all lands to the left of the Amur River to Russia, as well as the coastal region to the right of the Ussuri River (including Sakhalin) two years later.

What's important about this treaty is that it wasn't merely a cession of territories. It was an agreement about a demarcation line between colonial interests, not unlike the Treaty of Tordesillas. This treaty, with only very minor adjustments, lasted nearly 170 years.


Since probably not everyone's familiar with Siberian geography, here's a map:

230-0.jpg



The blue area is the Amur basin, and the green area is Primorye. The same region in Watkabaoi, with accordingly defined Amur and Primorye areas:

screensave000419gj0v.png



So far, this is looking pretty good. Now all we need are the following ingredients:


  • ignore = { <areas/regions/continents> }
    This list in an AI file would cause an AI not to settle any of those provinces, except if the according areas/regions/continents are already listed in the area/region/continent colonisation lists. For example, for Portugal you could list Brazil in the region list, and America in the ignore list, which would result in Portugal not colonising any provinces in America outside of Brazil. So if you wanted an AI to strictly adhere to the colonisation lists, you could simply list all continents in the ignore list.
    Area/region/continent labels can overlap, so the ignore list should always interpret labels as continents before regions before areas. There's no reason why modders shouldn't make all geographic labels unique anyway.
    This is an essential addition that cannot be replaced by existing methods.

  • command = { type = ai_add which = <list> value = <item> }
  • command = { type = ai_rem which = <list> value = <item> }
  • command = { type = ai_set which = <parameter> value = <value> }
    The first two would add respectively remove entries from AI lists, i.e. country tags in combat lists and geographic labels in colonisation lists. The valid 'which' parameters would therefore be combat, area, region, continent, and ignore. Likewise, 'ai_set' would allow to set non-list parameters.
    The commands 'ai_add' and 'ai_rem' are essential additions that cannot reasonably be replaced by existing methods.
    The command 'ai_set' is optional.

  • which = all
    Analogous to 'capital', 'random' and so on, for province-specific commands this would target all valid provinces, which means that the command is executed once for each of the provinces. This would allow to write muchshorter events and, more importantly, it would drastically reduce the likelihood of wrong IDs being present in long province lists. It would also slightly increase mod compatibility.
    (The 'validcommand' trigger should return true if a command with an 'all' parameter is valid for at least one province, and the 'last_random' parameter should ignore all commands with 'all' parameters.)
    This parameter is optional.

  • continentowned = <continent>
  • regionowned = <region>
  • areaowned = <area>
    Analogous to 'owned', these would check if the country owns at least one province with the specified geographic label. Like the 'all' parameter, this is mainly for ease of modding, and can already be done with long lists of IDs.
    These commands are optional.

  • command = { type = setflag which = <flag> where = <tag> }
    This would allow to set AI flags for other countries, mainly to make handling of global flags more comfortable by removing the need to fire a separate event for an AI country. A way to execute any command for another country would of course be even better, but is probably unrealistic.
    This parameter is optional.

The event chain itself is very straightforward: China decides whether to initiate talks and Russia can propose one of several historical lines of demarcation, then China either accepts or rejects that proposal, and the according provinces change ownership.

The first event could look like this:
Code:
event = {
	id = 40001020
	country = CHI
	trigger = {
		neighbour = RUS
		atwar = no
		isvassal = no
		RUS = {
			isvassal = no
			OR = {
				areaowned = Amur
				areaowned = Primorye
			}
		}
		NOT = {
			alliance = { country = CHI country = RUS }
			exists = JUR	# Jurchen
			exists = MCH	# Manchu
			exists = DMG	# Ming
			MUS = { flag = aigun }
		}
	}
	name = "Russian-Manchu dispute over the Amur region"
	desc = "Desc"
	date = { year = 1644 }
	offset = 1
	deathdate = { year = 1848 }
	action = {
		name = "Let's talk"
		command = { type = setflag which = nerchinsk where = MUS }
		command = { type = relation which = RUS value = 50 }
		command = { type = trigger which = 40001021 }	# RUS: Russian-Manchu dispute over the Amur region (peace talks)
	}
	action = {
		name = "No treaties with the barbarians"
		command = { type = relation which = RUS value = -200 }
		command = { type = addcore_claim which = all where = Amur }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_add which = area value = Primorye }
		command = { type = ai_rem which = ignore value = Siberia }
		command = { type = revoketrade which = RUS }
		command = { type = trigger which = 40001021 }	# RUS: Russian-Manchu dispute over the Amur region (no peace talks)
	}
}

The trigger is pretty much what you'd expect. Checking for stability or other minor factors might also make sense, but either way it's not really important here. For laughs, here's the trigger of the original EU2 event that still exists in vanilla FtG in this form:
NOT = { war = { country = RUS country = CHI } }
Yep, that's the trigger. All of it. Notice that since this event is for RUS, it will trigger even if CHI doesn't exist...

Anyway, looking at the event effects, you'll notice something unusual: Both actions trigger the same event. The actions in the next event will have actions whose availability depends on whether the flag "nerchinsk" has been set. This works because the 'setflag' command is written before the 'trigger' command. We'll make use of this technique again in later events.

For now, let's proceed with the first event for Russia:

Code:
event = {
	id = 40001021
	country = RUS
	name = "Russian-Manchu dispute over the Amur region"
	desc = "Desc"
	action = {
		name = "Argun River & Stanovoy Range"
		trigger = { MUS = { flag = nerchinsk } }
		command = { type = setflag which = nerchinsk_stanovoy where = MUS }
		command = { type = relation which = CHI value = 100 }
		command = { type = addcore_claim which = all where = Kamchatka }
		command = { type = addcore_claim which = all where = Lena }
		command = { type = addcore_claim which = all where = Baikal }
		command = { type = addcore_claim which = all where = Jenisej }
		command = { type = ai_add which = area value = Kamchatka }
		command = { type = ai_add which = area value = Lena }
		command = { type = ai_add which = area value = Baikal }
		command = { type = ai_add which = area value = Jenisej }
		command = { type = trigger which = 40001022 }	# CHI: Peace talks in Nerchinsk (historical demarcation line)
	}
	action = {
		name = "Argun & Amur Rivers"
		trigger = { MUS = { flag = nerchinsk } }
		command = { type = setflag which = nerchinsk_amur where = MUS }
		command = { type = relation which = CHI value = -100 }
		command = { type = addcore_claim which = all where = Kamchatka }
		command = { type = addcore_claim which = all where = Lena }
		command = { type = addcore_claim which = all where = Baikal }
		command = { type = addcore_claim which = all where = Jenisej }
		command = { type = addcore_claim which = all where = Amur }
		command = { type = ai_add which = area value = Kamchatka }
		command = { type = ai_add which = area value = Lena }
		command = { type = ai_add which = area value = Baikal }
		command = { type = ai_add which = area value = Jenisej }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_rem which = ignore value = Amur }
		command = { type = trigger which = 40001022 }	# CHI: Peace talks in Nerchinsk (Aigun Treaty demarcation line)
	}
	action = {
		name = "Argun, Amur & Ussuri Rivers"
		trigger = { MUS = { flag = nerchinsk } }
		command = { type = setflag which = nerchinsk_ussuri where = MUS }
		command = { type = relation which = CHI value = -200 }
		command = { type = addcore_claim which = all where = Kamchatka }
		command = { type = addcore_claim which = all where = Lena }
		command = { type = addcore_claim which = all where = Baikal }
		command = { type = addcore_claim which = all where = Jenisej }
		command = { type = addcore_claim which = all where = Amur }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = area value = Kamchatka }
		command = { type = ai_add which = area value = Lena }
		command = { type = ai_add which = area value = Baikal }
		command = { type = ai_add which = area value = Jenisej }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_add which = area value = Primorye }
		command = { type = ai_rem which = ignore value = Amur }
		command = { type = ai_rem which = ignore value = Primorye }
		command = { type = trigger which = 40001022 }	# CHI: Peace talks in Nerchinsk (Beijing Treaty demarcation line)
	}
	action = {
		name = "It all belongs to Mother Russia"
		command = { type = clrflag which = nerchinsk where = MUS }
		command = { trigger = { MUS = { flag = nerchinsk } } type = relation which = CHI value = -250 }
		command = { type = addcore_claim which = all where = Siberia }
		command = { type = addcore_claim which = all where = Kamchatka }
		command = { type = addcore_claim which = all where = Lena }
		command = { type = addcore_claim which = all where = Baikal }
		command = { type = addcore_claim which = all where = Jenisej }
		command = { type = addcore_claim which = all where = Amur }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = region value = Siberia }
		command = { type = ai_add which = area value = Kamchatka }
		command = { type = ai_add which = area value = Lena }
		command = { type = ai_add which = area value = Baikal }
		command = { type = ai_add which = area value = Jenisej }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_add which = area value = Primorye }
		command = { type = ai_rem which = ignore value = Siberia }
		command = { type = ai_rem which = ignore value = Amur }
		command = { type = ai_rem which = ignore value = Primorye }
		command = { type = revoketrade which = CHI }
		command = { type = revokeaccess which = CHI }
		command = { trigger = { MUS = { flag = nerchinsk } } type = trigger which = 40001023 }	# CHI: Peace talks break down
	}
}

As you can see, Russia has the choice between three histprical lines of demarcation. Again, every action (except the last one) triggers the same event but sets different flags. We also add claims and fill the AI colonisation lists, while the inverse will be done in a later event after all parties have agreed on the treaty, where provinces are also exchanged. (Kamchatka, Lena, Baikal and Jenisej are the other Siberian areas north of China.)

Next, the Chinese events where the treaty is either accepted or rejected:

Code:
event = {
	id = 40001022
	country = CHI
	name = "Peace talks in Nerchinsk"
	desc = "Desc"
	action = {
		name = "Accept the proposal"
		trigger = { MUS = { flag = nerchinsk_stanovoy } }
		command = { type = stability value = 1 }
		command = { type = relation which = RUS value = 150 }
		command = { type = addcore_claim which = all where = Amur }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_add which = area value = Primorye }
		command = { type = ai_add which = ignore value = Siberia }
		command = { type = cedeprovince which = RUS value = all where = Kamchatka }
		command = { type = cedeprovince which = RUS value = all where = Lena }
		command = { type = cedeprovince which = RUS value = all where = Baikal }
		command = { type = cedeprovince which = RUS value = all where = Jenisej }
		command = { type = provincereligion which = all value = buddhist where = Amur }
		command = { type = provincereligion which = all value = buddhist where = Primorye }
		command = { type = provinceculture which = all value = manchu where = Amur }
		command = { type = provinceculture which = all value = manchu where = Primorye }
		command = { type = givetrade which = RUS }
		command = { type = trigger which = 40001024 }	# RUS: Treaty of Nerchinsk (historical demarcation line)
	}
	action = {
		name = "Reject the proposal"
		command = { type = clrflag which = nerchinsk where = MUS }
		command = { type = clrflag which = nerchinsk_stanovoy where = MUS }
		command = { type = clrflag which = nerchinsk_amur where = MUS }
		command = { type = clrflag which = nerchinsk_ussuri where = MUS }
		command = { trigger = { MUS = { flag = nerchinsk_stanovoy } } type = stability value = -1 }
		command = { type = relation which = RUS value = -100 }
		command = { type = addcore_claim which = all where = Amur }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_add which = area value = Primorye }
		command = { type = revoketrade which = RUS }
		command = { type = revokeaccess which = RUS }
		command = { type = trigger which = 40001025 }	# RUS: Peace talks break down
	}
	action = {
		name = "Accept the proposal"
		trigger = { MUS = { flag = nerchinsk_amur } }
		command = { type = stability value = -1 }
		command = { type = relation which = RUS value = 100 }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = area value = Primorye }
		command = { type = ai_rem which = area value = Amur }
		command = { type = ai_add which = ignore value = Siberia }
		command = { type = ai_add which = ignore value = Amur }
		command = { type = cedeprovince which = RUS value = all where = Kamchatka }
		command = { type = cedeprovince which = RUS value = all where = Lena }
		command = { type = cedeprovince which = RUS value = all where = Baikal }
		command = { type = cedeprovince which = RUS value = all where = Jenisej }
		command = { type = cedeprovince which = RUS value = all where = Amur }
		command = { type = provincereligion which = all value = buddhist where = Primorye }
		command = { type = provinceculture which = all value = manchu where = Primorye }
		command = { type = givetrade which = RUS }
		command = { type = trigger which = 40001024 }	# RUS: Treaty of Nerchinsk (Aigun Treaty demarcation line)
	}
	action = {
		name = "Accept the proposal"
		trigger = { MUS = { flag = nerchinsk_ussuri } }
		command = { type = stability value = -2 }
		command = { type = relation which = RUS value = 50 }
		command = { type = ai_rem which = area value = Amur }
		command = { type = ai_rem which = area value = Primorye }
		command = { type = ai_add which = ignore value = Siberia }
		command = { type = ai_add which = ignore value = Amur }
		command = { type = ai_add which = ignore value = Primorye }
		command = { type = cedeprovince which = RUS value = all where = Kamchatka }
		command = { type = cedeprovince which = RUS value = all where = Lena }
		command = { type = cedeprovince which = RUS value = all where = Baikal }
		command = { type = cedeprovince which = RUS value = all where = Jenisej }
		command = { type = cedeprovince which = RUS value = all where = Amur }
		command = { type = cedeprovince which = RUS value = all where = Primorye }
		command = { type = givetrade which = RUS }
		command = { type = trigger which = 40001024 }	# RUS: Treaty of Nerchinsk (Beijing Treaty demarcation line)
	}
}

event = {
	id = 40001023
	country = CHI
	name = "Peace talks break down"
	desc = "Desc"
	action = {
		name = "We shall crush those barbarions"
		command = { type = addcore_claim which = all where = Amur }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_add which = area value = Primorye }
		command = { type = revoketrade which = RUS }
		command = { type = revokeaccess which = RUS }
	}
}

This is pretty similar to the previous event, except here the respective Chinese provinces are ceded to Russia and the areas removed from the AI colonisation lists. Also, the already settled provinces that are to remain in Chinese hands change religion and culture, just in case those provinces had been conquered from Russia earlier.

The reason for the weird order of the actions is that when historical AI choices are enabled, the AI (always picking the first valid option) accepts only the historical proposal (along the Stanovoy Range) and rejects any other proposal.

Finally, the last events for Russia, where again the respective provinces are ceded to China, AI colonisation lists are updated, and so on:

Code:
event = {
	id = 40001024
	country = RUS
	name = "Treaty of Nerchinsk"
	desc = "Desc"
	action = {
		name = "Great!"
		trigger = { MUS = { flag = nerchinsk_stanovoy } }
		command = { type = ai_rem which = region value = Siberia }
		command = { type = ai_rem which = area value = Amur }
		command = { type = ai_rem which = area value = Primorye }
		command = { type = ai_add which = ignore value = China }
		command = { type = ai_add which = ignore value = Amur }
		command = { type = ai_add which = ignore value = Primorye }
		command = { type = removecore_national which = all where = China }
		command = { type = removecore_national which = all where = Amur }
		command = { type = removecore_national which = all where = Primorye }
		command = { type = provincereligion which = all value = buddhist where = Amur }
		command = { type = provincereligion which = all value = buddhist where = Primorye }
		command = { type = provinceculture which = all value = manchu where = Amur }
		command = { type = provinceculture which = all value = manchu where = Primorye }
		command = { type = cedeprovince which = CHI value = all where = China }
		command = { type = cedeprovince which = CHI value = all where = Amur }
		command = { type = cedeprovince which = CHI value = all where = Primorye }
	}
	action = {
		name = "Great!"
		trigger = { MUS = { flag = nerchinsk_amur } }
		command = { type = stability value = 1 }
		command = { type = ai_rem which = region value = Siberia }
		command = { type = ai_rem which = area value = Primorye }
		command = { type = ai_add which = ignore value = China }
		command = { type = ai_add which = ignore value = Primorye }
		command = { type = removecore_national which = all where = China }
		command = { type = removecore_national which = all where = Primorye }
		command = { type = provincereligion which = all value = buddhist where = Primorye }
		command = { type = provinceculture which = all value = manchu where = Primorye }
		command = { type = cedeprovince which = CHI value = all where = China }
		command = { type = cedeprovince which = CHI value = all where = Primorye }
	}
	action = {
		name = "Great!"
		trigger = { MUS = { flag = nerchinsk_ussuri } }
		command = { type = stability value = 1 }
		command = { type = ai_rem which = region value = Siberia }
		command = { type = ai_add which = ignore value = China }
		command = { type = removecore_national which = all where = China }
		command = { type = cedeprovince which = CHI value = all where = China }
	}
}

event = {
	id = 40001025
	country = RUS
	name = "Peace talks break down"
	desc = "Desc"
	action = {
		name = "They'll regret this!"
		command = { type = addcore_claim which = all where = Siberia }
		command = { type = addcore_claim which = all where = Kamchatka }
		command = { type = addcore_claim which = all where = Lena }
		command = { type = addcore_claim which = all where = Baikal }
		command = { type = addcore_claim which = all where = Jenisej }
		command = { type = addcore_claim which = all where = Amur }
		command = { type = addcore_claim which = all where = Primorye }
		command = { type = ai_add which = region value = Siberia }
		command = { type = ai_add which = area value = Kamchatka }
		command = { type = ai_add which = area value = Lena }
		command = { type = ai_add which = area value = Baikal }
		command = { type = ai_add which = area value = Jenisej }
		command = { type = ai_add which = area value = Amur }
		command = { type = ai_add which = area value = Primorye }
		command = { type = ai_rem which = ignore value = Siberia }
		command = { type = ai_rem which = ignore value = Amur }
		command = { type = ai_rem which = ignore value = Primorye }
		command = { type = revoketrade which = CHI }
		command = { type = revokeaccess which = CHI }
	}
}


If everything went according to plan, the events should result in something like this:

screensave000441ax9w.png



And with that, we're done! We now have an event chain that will seamlessly integrate with yet-unwritten events such as the Treaty of Kyakhta where the western border between Russia and China (i.e. the northern border of Mongolia and Tuva) was defined. The event chain can also serve as a blueprint for various similar treaties such as the many adjustments to the Treaty of Tordesillas or for territorial purchases, where the focus isn't just on territorial changes but also on the limits of colonial expansion. The commands 'ai_add' and 'ai_rem' are paramount for this, as is the addition of an 'ignore' list for provinces the AI won't colonise.
 
...
Since probably not everyone's familiar with Siberian geography, here's a map:
...

A map of the Amur area with english descriptions
http://upload.wikimedia.org/wikipedia/commons/1/11/China_USSR_E_88.jpg

...
The trigger is pretty much what you'd expect. Checking for stability or other minor factors might also make sense, but either way it's not really important here. For laughs, here's the trigger of the original EU2 event that still exists in vanilla FtG in this form:

Yep, that's the trigger. All of it. Notice that since this event is for RUS, it will trigger even if CHI doesn't exist...

For the vanilla game with it´s very few events that actually makes sense in a way: Russia starts the game without those cores. If China does not exist then Russia should get those cores too (no imperial china in their way to grab the whole area). So either the event needs to trigger even if China does not exist or a 2nd event is needed that gives Russia those cores without the "treaty of Nerchinsk" event in case in a game China has vanished.
 
This would be great to shorten those revolt events in regions like Persia or China, to code generic events like peasant revolts and the like. I really hope Michael can add it to the next beta.

What is the difference between giving provincial revoltrisk in ALL provinces and simply using the revoltrisk command that gives RR in the whole state?

command = { type = province_revoltrisk which = x value = y }
Modifies the revolt risk in province x with value y indefinitely, until lowered by another event, or until the province is in the hands of another nation - i.e. revoltrisk is unaltered if the nation changes tags. Province revoltrisk can not be negative - no matter mow much you lower it, it will stop at zero.

command = { type = revoltrisk which = x value = y }
Raises the nation's revoltrisk for x months with y percents. May also be negative. If which is omitted, default is 12 months.