I first study these for the Achievement The Things Love Does for Us, then when I using hook/kidnap for inspiration, but for this thread, I will use murder as example.
For every scheme, there is a file correspond to it, for murder it is game\common\schemes\murder_scheme.txt, in it there is a
Code:
on_monthly = {
hostile_scheme_discovery_chance_effect = yes
if = {
limit = {
NOT = { exists = scope:discovery_event_happening }
}
scheme_owner = {
trigger_event = {
on_action = murder_ongoing
}
}
}
}
murder_ongoing is those event give bonus on the scheme, skip it for this time.
hostile_scheme_discovery_chance_effect is in game\common\scripted_effects\00_general_scheme_effects.txt
Code:
else_if = {
limit = {
#Does the target have a Spymaster?
exists = scope:target.host.cp:councillor_spymaster
}
#Save spymaster scope for later reference
scope:target.host.cp:councillor_spymaster = {
save_scope_as = spymaster
}
if = {
limit = {
is_scheme_exposed = no
#Spymaster won't expose their own Scheme
NOT = { scope:owner = scope:spymaster }
#Spymaster won't expose *your* (liege's) Scheme
NOT = { scope:owner = scope:spymaster.liege }
}
random = {
chance = scope:spymaster.spymaster_scheme_discovery_chance
save_temporary_scope_value_as = {
name = discover_scheme
value = yes
}
}
}
in which it checks if the target is in your court or not, your spymaster wont expose your plan, so he has to depends on himself,
there is another random determine it is the agent or you being discovered, but let's assume there is a spymaster, and check the
chance spymaster_scheme_discovery_chance first, it is in game\common\script_values\99_spymaster_values.txt
Code:
spymaster_scheme_discovery_base_chance = {
value = 1
add = {
add = intrigue
divide = 3
}
}
spymaster_scheme_discovery_chance = {
add = spymaster_scheme_discovery_base_chance
if = { # Percentage bonus applied to the base chance
limit = {
is_performing_council_task = task_disrupt_schemes
}
add = {
value = spymaster_scheme_discovery_base_chance
multiply = {
value = spymaster_disrupt_schemes_total_modifier
divide = 100
}
}
}
multiply = 0.5
}
the value is the (intrigue/3 + 1)/2, and + some bonus if the council task is disrupt schemes, but none of this is includes the value of success rate nor secrecy.
if got discovered, then it fires hostile_scheme_discovery.1001, which is the event that the spymaster report to his leige, and that chains into
hostile_scheme_discovery.3001, which informs you your plan is being discovered.
return to the scheme file, there is a on_ready block
Code:
on_ready = {
scheme_owner = {
if = {
limit = {
has_character_flag = is_in_event_murder_outcome_0001
}
trigger_event = {
id = murder_outcome.0001
days = 1
}
}
else = {
trigger_event = murder_outcome.0001
}
}
}
let me skip a number of steps from murder_outcome.0001, as the game use multiple steps just to ensure 2 murders wont happen on the same day,
then choose a set of murder method base on target's condition (common\on_action\schemes\murder_on_actions) and random pick one.
assume it use assassin, it is event murder_outcome.1001 (events\scheme_events\murder_scheme\murder_outcome_events.txt) ,
first it will calcuate the chance of discovery by just sample 100-secrecy (common\scripted_effects\00_murder_scheme-effects.txt)
Code:
immediate = {
murder_outcome_roll_setup_effect = yes
}
option = {
name = murder_outcome.1001.a
murder_outcome_roll_effect = yes
stress_impact = {
arbitrary = minor_stress_impact_loss
compassionate = medium_stress_impact_gain
gregarious = minor_stress_impact_gain
}
}
Code:
#Sets up the Outcome Roll values
murder_outcome_roll_setup_effect = {
#Discovery Roll setup
save_scope_value_as = {
name = discovery_chance
value = {
value = 100
subtract = scope:scheme.scheme_secrecy
}
}
}
then if you choose to do it, it goes to murder_outcome_roll_effect (common\scripted_effects\00_murder_scheme_effects.txt)
it rolls for the success rate and discover rate
Code:
#SUCCESS ROLL
random = {
chance = scope:scheme.scheme_success_chance
custom_tooltip = murder_successful_roll_tt
save_scope_value_as = {
name = scheme_successful
value = yes
}
}
### End Success roll
#DISCOVERY ROLL
custom_description_no_bullet = {
text = in_addition_effect_tooltip
}
random = {
chance = scope:discovery_chance
custom_tooltip = scheme_remain_secret_roll_tt
save_scope_value_as = {
name = scheme_discovered
value = yes
}
if = {
limit = {
exists = scope:target.host
}
scope:target.host = {
save_scope_as = murder_exposer
}
}
else = {
scope:target = {
save_scope_as = murder_exposer
}
}
}
### End Discovery roll
but even if the success roll success , it still have the murder save
Code:
if = {
limit = {
exists = scope:scheme_successful
}
trigger_event = {
on_action = murder_save_roll
days = 3
}
}
in which only the first one is success, others are being saved by someone
Code:
murder_save_roll = {
random_events = {
200 = murder_save.9999 #Murder succeeds
#Lover saves you from an assassin
50 = murder_save.0001
#Lover saves you from a creepy crawly
100 = murder_save.0002
#Mindbreak character saves you from an assassin
100 = murder_save.0003
#Warhorse saves you from a band of thugs
100 = murder_save.0004
#Your Prison Pet saves you in prison
100 = murder_save.0005
#Their personal guard protects them from a band of thugs
100 = murder_save.0006
#Your cat saves you!
100 = murder_save.0007
#Your dog saves you!
100 = murder_save.0008
# Dynasty Perk: Family Connections
700 = murder_save.0009
# A Varangian saves them
300 = murder_save.0010
# Saved from poisoned food by cat
50 = murder_save.0011
# Saved from poisoned food by dog
50 = murder_save.0012
# Saved from poisoned food by gluttonous trait
500 = murder_save.0013
# Saved from assassin by language skills
100 = murder_save.0014
#Saved by timely artifact
100 = murder_save.0015
# Saved from poisoned food by food taster
100 = court_position.9001
# Saved from poison by cup-bearer
50 = court_position.9011
# A Bodyguard saves you from an assassin
100 = court_position.9021
# A Shieldmaiden saves them
600 = fp1_shieldmaiden.0021
}
}
most only works for a specific type, for example lover for assassin and creepy crawly is 2 cases already, cup-bearer only works for poisoned drinks.
but some like the Dynasty Perk: Family Connections can work for any.