• 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.

tompalmer

Colonel
93 Badges
Jan 20, 2012
1.158
13
  • Victoria 2: A House Divided
  • For The Glory
  • For the Motherland
  • Hearts of Iron III
  • Arsenal of Democracy
  • Heir to the Throne
  • Magicka
  • Knights of Honor
  • Europa Universalis IV: Res Publica
  • Semper Fi
  • Stellaris - Path to Destruction bundle
  • Hearts of Iron III: Their Finest Hour
  • Victoria 2: Heart of Darkness
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines Deluxe Edition
  • Europa Universalis IV: Pre-order
  • Pride of Nations
  • Europa Universalis IV: Mare Nostrum
  • Pillars of Eternity
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Wealth of Nations
  • Cities in Motion
  • Cities in Motion 2
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Darkest Hour
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Europa Universalis IV
  • Divine Wind
  • Europa Universalis III Complete
  • Europa Universalis III: Chronicles
  • Europa Universalis III
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: El Dorado
  • Magicka: Wizard Wars Founder Wizard
  • Europa Universalis III Complete
  • Mount & Blade: Warband
  • Battle for Bosporus
  • 500k Club
  • Europa Universalis IV: Common Sense
Hi people,

I found the CK2+ loean feature rather limitate so I contructed one on my own.

FEATURES :
*******
2 types of Loans :
Asking a bank : which is the actual ck2+ system (thank's WIZ).
Asking your vassals

Crispy feature, if you don't refund your loan, the bank will fund a pretunder to overthrow you !
State of devellopment, as you may not know I'm a shitty coder, so I 'm a bit stuck with the vassal event chain, giveme thoughts !
Code:
#I want to take a loan
character_event = {
	id= 64420
	desc= "EVTDESC64420"
	picture = GFX_evt_council
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA64420" # Confirm Borrow money from a vassal
	ai_chance = {
		factor = 1
		}#ai
	character_event = { id = 64421 tooltip = "EVTTOOLTIP64421" }
	any_vassal = {letter_event = { id = 64421 days = 10 tooltip = "EVTTOOLTIPxxx" } }
			}#opta
	
	option = { 
		name = "EVTOPTBXXX" #change my mind
		}#optb

	}#evt


# Vassals receive the request
letter_event = {
	id= 64421
	desc= "EVTDESC64421"
	picture = GFX_evt_council
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA64421" #ACCEPT
		FROM = {
			if= { 
				limit = {
							wealth = 200 #controls if he has enough money
						liege = { primary_title = { tier = EMPEROR } }
				
				transfer_wealth = {
					to = PREVPREV
					value = 200
						}#xfer
					}#if

				if = {
					limit = {
							 wealth = 150 #controls if he has enough money						
                             liege = { primary_title = { tier = KING } } 
							}#lim
				transfer_wealth = {
					to = PREVPREV
					value = 150
						}#xfer
				}#if
				if = {
					limit = {
						wealth = 100 #controls if he has enough money
						liege = { primary_title = { tier = DUKE } } 
							}#lim
				transfer_wealth = {
					to = PREVPREV
					value = 100
						}#xfer
				}#if
				if = {
					limit = {
							wealth = 50 #controls if he has enough money						
							liege = { primary_title = { tier = COUNT } } 
						
							}#lim
				transfer_wealth = {
					to = PREVPREV
					value = 50
						}#xfer
				}#if
			}#from
		}#opt


		option = {
			name = "EVTOPTBXXX" #REFUSE
			character_event = { id = 64424 tooltip = "EVTTOOLTIPxxxx" } #Ruler informed of refusal

			}#opt
		}#evt


#Ruler informed of the loan attempt result
letter_event = {
	id = 64223
	desc = "EVTDESC64223"
	picture = GFX_evt_tyroshi

	is_triggered_only


		option = {
			name = "EVTOPTA64223" #OK

			}#opt
		}#evt
 
Last edited:

richvh

Preserver of the Light
63 Badges
Dec 1, 2001
14.691
1.999
Visit site
  • Stellaris: Leviathans Story Pack
  • Pillars of Eternity
  • Crusader Kings II: Horse Lords
  • Cities: Skylines - After Dark
  • Knights of Pen and Paper 2
  • Crusader Kings II: Conclave
  • Stellaris
  • Hearts of Iron IV Sign-up
  • Stellaris Sign-up
  • Crusader Kings II: Reapers Due
  • Tyranny: Archon Edition
  • Tyranny: Archon Edition
  • Tyranny: Gold Edition
  • Crusader Kings II: Way of Life
  • Crusader Kings II: Monks and Mystics
  • Stellaris - Path to Destruction bundle
  • Surviving Mars
  • Stellaris: Synthetic Dawn
  • Tyranny - Tales from the Tiers
  • Tyranny - Bastards Wound
  • Age of Wonders III
  • Age of Wonders: Shadow Magic
  • Age of Wonders
  • Age of Wonders II
  • Crusader Kings II: Jade Dragon
  • Crusader Kings III: Royal Edition
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • A Game of Dwarves
  • King Arthur II
  • Knights of Pen and Paper +1 Edition
  • Magicka
  • Majesty 2 Collection
  • Europa Universalis IV: Res Publica
  • Europa Universalis: Rome
  • Rome Gold
  • Rome: Vae Victis
  • 500k Club
  • Cities: Skylines
A few things I see:
* IF should be if
* There should be only one { between if and limit
* The wealth test should be inside the braces after limit
* You're missing a closing } for the final event
 

tompalmer

Colonel
93 Badges
Jan 20, 2012
1.158
13
  • Victoria 2: A House Divided
  • For The Glory
  • For the Motherland
  • Hearts of Iron III
  • Arsenal of Democracy
  • Heir to the Throne
  • Magicka
  • Knights of Honor
  • Europa Universalis IV: Res Publica
  • Semper Fi
  • Stellaris - Path to Destruction bundle
  • Hearts of Iron III: Their Finest Hour
  • Victoria 2: Heart of Darkness
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines Deluxe Edition
  • Europa Universalis IV: Pre-order
  • Pride of Nations
  • Europa Universalis IV: Mare Nostrum
  • Pillars of Eternity
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Wealth of Nations
  • Cities in Motion
  • Cities in Motion 2
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Darkest Hour
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Europa Universalis IV
  • Divine Wind
  • Europa Universalis III Complete
  • Europa Universalis III: Chronicles
  • Europa Universalis III
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: El Dorado
  • Magicka: Wizard Wars Founder Wizard
  • Europa Universalis III Complete
  • Mount & Blade: Warband
  • Battle for Bosporus
  • 500k Club
  • Europa Universalis IV: Common Sense
A few things I see:
* IF should be if
* There should be only one { between if and limit
* The wealth test should be inside the braces after limit
* You're missing a closing } for the final event

Ok I did the changes, I'm not familiar with scripting AI so I don't really know what to add to make that look nice.
 

waylit1

Captain
27 Badges
Jun 11, 2010
333
0
  • Crusader Kings II
  • Crusader Kings II: Horse Lords
  • Crusader Kings II: Holy Fury
  • Cities: Skylines Industries
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Crusader Kings II: Jade Dragon
  • Age of Wonders III
  • Cities: Skylines - Mass Transit
  • Crusader Kings II: Monks and Mystics
  • Cities: Skylines - Natural Disasters
  • Crusader Kings II: Reapers Due
  • Stellaris
  • Crusader Kings II: Conclave
  • Cities: Skylines - After Dark
  • Crusader Kings II: Way of Life
  • Mount & Blade: Warband
  • 500k Club
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Cities: Skylines
Also use
Code:
 instead of spoilers.  Or I guess code inside spoilers would work, too.  It lets us see how you've formatted it.  I'll go through and apply Richvh's suggestions because they pop right out at ya.  One thing I think he misses is that all = should have spaces around it.  Id =  not Id= .  I don't think IF if or If matters.  The Validator thinks it does, but that thing is stupid.  

Also I'm not good enough to read it vertical like that, so the reformatting helps me understand it.  One last trick is the comment out #comment feature.  I use this at the end of my clauses to help me keep track of what closes what. 

[code]
#I want to take a loan
character_event = {
	id = xxxxx
	desc = "EVTDESCxxxxx"
	picture = GFX_evt_council

	is_triggered_only = yes

	option = {
		name = "EVTOPTAXXX" # Confirm Borrow money from a vassal
	ai_chance = {
		factor = 1
		}#ai
	character_event = { id = xxxx tooltip = "EVTTOOLTIPxxxx" }
	any_vassal = { letter_event = { id = xx days = 10 tooltip = "EVTTOOLTIPxxx" } }
			}#opta
	
	option = { 
		name = "EVTOPTBXXX" #change my mind
		}#optb

	}#evt


# Vassals receive the request
	letter_event = {
	id = xxxxx
	desc = "EVTDESCxxxxx"
	picture = GFX_evt_council

	is_triggered_only = yes

		option = {
			name = "EVTOPTAXXX" #ACCEPT
			FROM = {
				IF = {
					limit = { 
						liege = { primary_title = { tier = EMPEROR } }
						wealth = 200 #controls if he has enough money
							}#limit
				transfer_wealth = {
					to = PREVPREV
					value = 200
						}#xfer
					}#if

				IF = {
					Limit = {
						liege = { primary_title = { tier = KING } } 
						wealth = 150 #controls if he has enough money
							}#lim
				transfer_wealth = {
					to = PREVPREV
					value = 150
						}#xfer
				}#if
				IF = {
					Limit = {
						liege = { primary_title = { tier = DUKE } } 
						wealth = 100 #controls if he has enough money
							}#lim
				transfer_wealth = {
					to = PREVPREV
					value = 100
						}#xfer
				}#if
				IF = {
					Limit = {
						liege = { primary_title = { tier = COUNT } } 
						wealth = 50 #controls if he has enough money
							}#lim
				transfer_wealth = {
					to = PREVPREV
					value = 50
						}#xfer
				}#if
			}#from
		}#opt


		option = {
			name = "EVTOPTBXXX" #REFUSE
			character_event = { id = xxxx tooltip = "EVTTOOLTIPxxxx" } #Ruler informed of refusal

			}#opt
		}#evt


#Ruler informed of the loan attempt result
letter_event = {
	id = xxx
	desc = "EVTDESCxxxxx"
	picture = GFX_evt_tyroshi

	is_triggered_only


		option = {
			name = "EVTOPTAXXX" #OK

			}#opt
		}#evt

I added one option to the first event, because a confirmation event without an option to back out is a notification event. ;)

I hope cleaning it up like this helps you. Generally my theory is that I build my events to work first, and then add on little modules of code as I go. Slowly. Methodically. Loading CK2 and testing every 5 minutes. But doing that helps me learn exactly what breaks events when I make changes.

I can tell that this event will not do what you want it to do, but once you get it working, you will figure out how to add more constraints so that it acts as you want it to. Part of the learning.
 

waylit1

Captain
27 Badges
Jun 11, 2010
333
0
  • Crusader Kings II
  • Crusader Kings II: Horse Lords
  • Crusader Kings II: Holy Fury
  • Cities: Skylines Industries
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Crusader Kings II: Jade Dragon
  • Age of Wonders III
  • Cities: Skylines - Mass Transit
  • Crusader Kings II: Monks and Mystics
  • Cities: Skylines - Natural Disasters
  • Crusader Kings II: Reapers Due
  • Stellaris
  • Crusader Kings II: Conclave
  • Cities: Skylines - After Dark
  • Crusader Kings II: Way of Life
  • Mount & Blade: Warband
  • 500k Club
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Cities: Skylines
Well, you put the ai_chance under the option and then decide how you think it should work. The numbers are all relative. So I set the preferred option at 1, and then use decimals for the modifiers. All decimals must be 0.1 not .1.

Here is from my code:

This is a 20% chance option. But if they are wroth, it goes up to a 200% (2x) chance, but if they are also humble it will be dropped back down to 20% again. If they are not wroth, envious, or proud, but humble, it becomes a 2% chance option.

Code:
ai_chance = { 
			factor = 0.2 

				modifier = {
					factor = 10
					trait = wroth 
					}
				modifier = {
					factor = 10
					trait = envious 
					}
				modifier = {
					factor = 20
					trait = proud
					}
				modifier = {
					factor = 0.1
					trait = humble
				}	
			}#ai
You can do all sorts of other things below factor...I think basically anything that is a trigger can modify AI behavior. What else would you like to know?
 

waylit1

Captain
27 Badges
Jun 11, 2010
333
0
  • Crusader Kings II
  • Crusader Kings II: Horse Lords
  • Crusader Kings II: Holy Fury
  • Cities: Skylines Industries
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Crusader Kings II: Jade Dragon
  • Age of Wonders III
  • Cities: Skylines - Mass Transit
  • Crusader Kings II: Monks and Mystics
  • Cities: Skylines - Natural Disasters
  • Crusader Kings II: Reapers Due
  • Stellaris
  • Crusader Kings II: Conclave
  • Cities: Skylines - After Dark
  • Crusader Kings II: Way of Life
  • Mount & Blade: Warband
  • 500k Club
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Cities: Skylines
Hmm, I dunno. When in doubt, find a similar thing in somebody elses code and see how they did it. CK2Plus' loan event has such a timer on it. I haven't really had to mess with those yet, so I haven't learned it.
 

tompalmer

Colonel
93 Badges
Jan 20, 2012
1.158
13
  • Victoria 2: A House Divided
  • For The Glory
  • For the Motherland
  • Hearts of Iron III
  • Arsenal of Democracy
  • Heir to the Throne
  • Magicka
  • Knights of Honor
  • Europa Universalis IV: Res Publica
  • Semper Fi
  • Stellaris - Path to Destruction bundle
  • Hearts of Iron III: Their Finest Hour
  • Victoria 2: Heart of Darkness
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines Deluxe Edition
  • Europa Universalis IV: Pre-order
  • Pride of Nations
  • Europa Universalis IV: Mare Nostrum
  • Pillars of Eternity
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Wealth of Nations
  • Cities in Motion
  • Cities in Motion 2
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Darkest Hour
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Europa Universalis IV
  • Divine Wind
  • Europa Universalis III Complete
  • Europa Universalis III: Chronicles
  • Europa Universalis III
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: El Dorado
  • Magicka: Wizard Wars Founder Wizard
  • Europa Universalis III Complete
  • Mount & Blade: Warband
  • Battle for Bosporus
  • 500k Club
  • Europa Universalis IV: Common Sense
Hmm, I dunno. When in doubt, find a similar thing in somebody elses code and see how they did it. CK2Plus' loan event has such a timer on it. I haven't really had to mess with those yet, so I haven't learned it.

in fact it's easy as hell : letter_event = { id = xxx days = 1825 tooltip = "EVTTOOLTIPxxxx" }

And then I let the choice for ROOT to reimbourse or risk a vengence
 

Fawr

Field Marshal
79 Badges
Jan 22, 2003
3.165
1.598
  • Europa Universalis IV: Common Sense
  • Semper Fi
  • Sengoku
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • 500k Club
  • Cities: Skylines
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Pre-order
  • Mount & Blade: Warband
  • Crusader Kings II: Way of Life
  • Magicka 2
  • Europa Universalis IV: Res Publica
  • Crusader Kings II: Horse Lords
  • Knights of Pen and Paper 2
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Stellaris Sign-up
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Stellaris: Leviathans Story Pack
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Art of War
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sword of Islam
  • Europa Universalis III
  • Europa Universalis III Complete
  • Divine Wind
  • Europa Universalis IV
  • Cities in Motion
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • For the Motherland
  • Hearts of Iron III
  • Hearts of Iron III: Their Finest Hour
  • Heir to the Throne
  • Europa Universalis III Complete
  • Knights of Pen and Paper +1 Edition
  • Magicka
  • Majesty 2
For loan repayments the only issue may be what happens if you take a loan and then die. The bank may not end up realising that they should collect the money from your heir. Not sure what the solution for this should be, unless you just accept it and increase the interest rate to compensate.