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

ulmont

Field Marshal
103 Badges
May 9, 2001
2.788
1
Visit site
  • Europa Universalis: Rome Collectors Edition
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Europa Universalis: Rome
  • Victoria 2
  • Victoria 2: A House Divided
  • Rome: Vae Victis
  • 200k Club
  • 500k Club
  • Cities: Skylines
  • Crusader Kings II: Holy Knight (pre-order)
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Pre-order
  • Europa Universalis III Complete
  • Crusader Kings II: Way of Life
  • Pillars of Eternity
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Nemesis
  • Europa Universalis III
  • 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
  • Darkest Hour
  • Deus Vult
  • Diplomacy
  • Hearts of Iron II: Armageddon
  • Europa Universalis III: Chronicles
  • Divine Wind
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Hearts of Iron III
  • Heir to the Throne
  • Europa Universalis III Complete
jova said:
I want to make an event which can occur, but not necessarily. Let's say I want it to occur in 60% of the games. How to code that?
My suggestion involves 2 events, assumes that there is a specific country this event should occur for, and is completely untested:
Code:
event = {
	id = 100001 # change this 
	random = no
	country = HOL # change this too, probably.

	trigger = { 
		random = 60 # the 60% chance...
                NOT = { event = 100001 } # if we haven't fired
                NOT = { event = 100002 } # if the never fire side hasn't fired
	}

	name = "Hey, 60% hit!" 
	desc = "This event should only occur in 60% of the games!"

	date = { day = 1 month = january year = 1936 }
	offset = 30
	deathdate = { day = 30 month = december year = 1947 }

	action_a = {
		command = { type = delete_unit which = -1 } # or whatever
	}
}

event = {
	id = 100002 # change this 
	random = no
	country = HOL # change this too, probably.

	trigger = { 
		random = 40 # the 40% chance...
                NOT = { event = 100001 } # if the main event hasn't fired
                NOT = { event = 100002 } # if we haven't fired
	}

	name = "Hey, 40% hit!" 
	desc = "This event should only occur in 40% of the games!"

	date = { day = 1 month = january year = 1936 }
	offset = 30
	deathdate = { day = 30 month = december year = 1947 }

	action_a = {
		command = { type = delete_unit which = -1 } # or whatever
	}
}
Basically, as soon as the game starts 2 events start being tested each month, one with a 60% chance and one with a 40% chance. As soon as one of them fires, the other will never fire.

Main drawback is that an event will fire to symbolize that the other will never happen, which is somewhat annoying.

If this event can fire once, for whichever country hits it first, I would replace "country =" with "invention = yes", remove the date / offset / deathdate, and add a global flag instead of testing on the events.

If this event can fire once per country for all countries, I would replace "country =" with "invention = yes", remove the date / offset / deathdate, and add a local flag instead of testing on the events.
 

ulmont

Field Marshal
103 Badges
May 9, 2001
2.788
1
Visit site
  • Europa Universalis: Rome Collectors Edition
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Europa Universalis: Rome
  • Victoria 2
  • Victoria 2: A House Divided
  • Rome: Vae Victis
  • 200k Club
  • 500k Club
  • Cities: Skylines
  • Crusader Kings II: Holy Knight (pre-order)
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Pre-order
  • Europa Universalis III Complete
  • Crusader Kings II: Way of Life
  • Pillars of Eternity
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Nemesis
  • Europa Universalis III
  • 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
  • Darkest Hour
  • Deus Vult
  • Diplomacy
  • Hearts of Iron II: Armageddon
  • Europa Universalis III: Chronicles
  • Divine Wind
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Hearts of Iron III
  • Heir to the Throne
  • Europa Universalis III Complete
jova said:
Thanks, I supposed that "random = x" is the key, but I have seen some events with random = 40 and they occured almost every time.
Perhaps it was just a coincidence. :)
With the date / offset / deathdate parameters, the events get multiple chances to hit the random number.
 

Passivocalia

Major
Nov 24, 2005
537
0
ulmont said:
Main drawback is that an event will fire to symbolize that the other will never happen, which is somewhat annoying.

If you make

name = "AI_EVENT"

Then the message should only appear to the player who gets the event. If you're any other country, then it should just take place without letting you know.