# Character scope
on_startup = {
	events = {
		# JD.10006 # Save game fix for setting the name of the Chinese empire
		JD.50401 # Set correct value of the Silk Road
		JD.30504 # Clean up living members of the chinese dynasty
	}
}

# Character scope
on_yearly_pulse = {
	events = {
		JD.20041 # Chinese commander teaching other commanders their leadership trait
		JD.4000 # Character raiding China result events
	}

	random_events = {
		# Jade Dragon events
		200 = JD.30010 # Courtier from Chinese court compliments/berates
		200 = JD.10032 # Gifted refugee appears
		150 = JD.20002 # Visit by Chinese councilor
		150 = JD.30002 # Traders acting dishonest
		150 = JD.10011 # Courtier offers to visit the Western Protectorate
		150 = JD.70002 # Escaped Chinese Noble
		150 = JD.7000  # Chinese Teacher visits
		150 = JD.7010  # Radhanite Merchant asks for money
		150 = JD.4100  # Radhanites want their money
		 25 = JD.60002 # Envoy from China offers trade for artifacts
		 20 = JD.2100  # Chance of Religious Liberation CB
	}
}

# Character scope
on_five_year_pulse = {
	events = {
		JD.1000 # Muslim Adventurers targeting India
	}
}

# Triggers when someone gets imprisoned for any reason
# ROOT is prisoner
# FROM is imprisoner
on_become_imprisoned_any_reason = {
	events = {
		JD.10022 # Chinese councilor visiting is imprisoned - cancels visit
	}
}

# Character scope, isn't dead yet
on_death = {
	events = {
		JD.60210 # Destroy Pretender Chinese Empire if heir is not same dynasty and chinese
		JD.60015 # Notify of Suzerain dying and you being free
		JD.60006 # Destroy prosthetics
		JD.3042  # Clear Supply Horses modifier if no longer Nomadic
		JD.10080 # Your Chinese Prince/Princess has died (for children or spouse - must be read before JD.60310!)
		JD.60310 # Courtier from China dies
		JD.10022 # Chinese councilor visiting dies and cancels visit
	}
}

# ROOT is the character
# FROM is the title
# FROMFROM is the old holder
on_new_holder = {
	events = {
		JD.60204 # Rebel General's Empire continues temple names, triggers for any title with the uses_temple_names_by_script title flag
	}
}

# ROOT is the character
# FROM is the title
# FROMFROM is the old holder
on_new_holder_inheritance = {
	events = {
		JD.60204 # Rebel General's Empire continues temple names, triggers for any title with the uses_temple_names_by_script title flag
		JD.9000  # Reapply Scholar Bureaucrat bonus on death/inheritance
	}
}

# ROOT is the character
# FROM is the title
# FROMFROM is the old holder
on_new_holder_usurpation = {
	events = {
		JD.60204 # Rebel General's Empire continues temple names, triggers for any title with the uses_temple_names_by_script title flag
	}
}

# FROM is attacker
# ROOT is defender
on_war_started = {
	events = {
		JD.30020 # Western protectorate receives reinforcements from China
		JD.30030 # Western protectorate receives reinforcements from China
		JD.30015 # Clean up trade contracts
	}
}

# FROM is attacker
# ROOT is defender
on_war_ended_victory = {
	events = {
		JD.30051 # Offmap China end of war clean-up
	}
}

# FROM is attacker
# ROOT is defender
on_war_ended_defeat = {
	events = {
		JD.30052 # Offmap China end of war clean-up
	}
}

# FROM is attacker
# ROOT is defender
on_war_ended_invalid = {
	events = {
		JD.30050 # China is a main participant
	}
}

# FROM is attacker
# ROOT is defender
on_war_ended_whitepeace = {
	events = {
		JD.30050 # Offmap China end of war clean-up
	}
}

# ROOT is builder
# FROM is title
# on_settlement_construction_start = {
	# events = {
		# JD.40002 # Start constructing a city on the Silk Road for trade competition
	# }
# }

# ROOT is builder
# FROM is title
# on_settlement_construction_completed = {
	# events = {
		# JD.40003 # Finish constructing a city on the Silk Road for trade competition
	# }
# }

# An offmap power changes its policy. Triggers for the governor
# ROOT is governor
# FROM is offmap
on_offmap_policy_changed = {
	events = {
		JD.30501 # Print policy update to logs
		JD.50020 # News from China about Policy Change
		JD.50400 # Update Silk Road values
		JD.32298 # Abandon kowtow when China goes Isolationist
	}
}

# An offmap power changes its status. Triggers for the governor
# ROOT is governor
# FROM is offmap
on_offmap_status_changed = {
	events = {
		JD.30502 # Print status update to logs
		JD.50030 # News from China about Status Change
		JD.50400 # Update Silk Road values
	}
}

# An offmap power changes its ruler. Triggers for the new ruler
# ROOT is new ruler
# FROM is old ruler
# FROMFROM is offmap
on_offmap_ruler_changed = {
	events = {
		JD.30503 # Logging new ruler data
		JD.10005 # In case of dynasty change
		JD.10202 # Delayed cleanup event. Makes sure the new administration may also launch Chinese invasions
		JD.50000 # Select a new Policy and send News Event
		JD.31000 # Logging for emperor statistics
	}
}

# Happens once a month on a random day. Triggers for the governor
# ROOT is governor
# FROM is offmap
on_offmap_monthly_pulse = {
	events = {
		JD.10121  # Fallback event to make sure that Displaced Royals, Jurchen Invaders, and Rebel Generals actually appear (regardless of new administration in China or not)
	}
}

# Happens once a year during a random monthly update. Triggers for the governor (once for each offmap governor, if there's more than one)
# ROOT is governor
# FROM is offmap
on_offmap_yearly_pulse = {
	events = {
		JD.10100 # Chinese Invasion tombola
		# JD.40000 # Chinese Trade Competition - disabled in trigger
		JD.30500 # China logging variable increment
		JD.10200 # Chinese Invasion clean-up event - REGULAR (tributary invasion + other flags)
		JD.10201 # Chinese Invasion clean-up event - MAJOR Invasion (rare)
	}
	random_events = {
		450 = JD.50160 # 'Mongol Invasion' Resolution
		450 = JD.50200 # 'Jurchen Invasion' Resolution
		400 = JD.50300 # 'Civil War' Resolution
		350 = JD.50280 # Status changes to 'Civil War'
		300 = JD.50100 # Status returns to 'Stable'
		150 = JD.50120 # Status changes to 'Unrest'
		100 = JD.50220 # Status changes to 'Great Famine'
		100 = JD.50240 # Status changes to 'Devastating Plague'
		100 = JD.50260 # Status changes to 'Golden Age'
		 50 = JD.50140 # Status changes to 'Mongol Invasion'
		 50 = JD.50180 # Status changes to 'Jurchen Invasion'
	}
}

# Happens just prior to the EU4 converter converting the game
# ROOT is player, or random character if in observe mode
on_eu4_conversion_start = {
	events = {
		JD.60205 # Prepare on map China for conversion
	}
}

# Happens just after the EU4 converter is done converting the game
# ROOT is player, or random character if in observe mode
on_eu4_conversion_done = {
	events = {
		JD.60206 # Restore on map China after conversion
	}
}
