#########################################################################################################################
#Faction Rebellion trigger for multiple claimants in the one center #
#########################################################################################################################
#
# Simple trigger for multiple claimants in the one center
# NOTE: maybe change it to once a week.
#
(72,
[
(store_current_day, ":cur_day"),
(assign, ":main_faction", 0),
(assign, ":main_center", 0),
(assign, ":sub_faction", 0),
(assign, ":sub_center", 0),
(assign, ":bonus", 3),
(try_for_range, ":main_npc", pretenders_begin, pretenders_end),
(troop_get_slot, ":main_center", ":main_npc", slot_troop_cur_center),
#Patch start part 1
(store_troop_faction, ":party_faction", ":main_npc"),
(str_store_faction_name, ":main_faction", ":party_faction"),
#possibly 1 part end
#(str_store_faction_name, ":main_faction", ":main_npc"), #Patch part 1 disable
(try_for_range, ":sub_npc", pretenders_begin, pretenders_end),
(troop_get_slot, ":sub_center", ":sub_npc", slot_troop_cur_center),
#Patch 2 start
(store_troop_faction, ":partb_faction", ":sub_npc"),
(str_store_faction_name, ":sub_faction", ":partb_faction"),
#Patch 2 end
#(str_store_faction_name, ":sub_faction", ":sub_npc"), #patch part 2 disable
(neq, ":main_npc", ":sub_npc"),
(eq, ":main_center", ":sub_center"),
(try_begin),
(faction_slot_eq, ":main_faction", slot_faction_state, sfs_inactive),
(neg|faction_slot_eq, ":main_faction", slot_faction_state, sfs_defeated),
(faction_get_slot, ":main_date", ":main_faction", slot_rebellion_date),
#Check that the current date is greater than the minimum day for rebellion to start
(ge, ":cur_day", ":main_date"),
(neg|main_party_has_troop, ":main_npc"),
(call_script, "script_rebelion_assesment", ":main_faction"),
(faction_get_slot, ":main_chance", ":main_faction", slot_faction_has_rebellion_chance),
#Modify the random chance generation so that low fracturing makes it harder for a rebellion
(val_add, ":main_chance", ":bonus"),
(store_sub, ":lower_limit", 9, ":main_chance"),
(store_random_in_range, ":main_random_chance", ":lower_limit", 9),
(try_begin),
#Could change this conditional check to ge for a easier activation of rebellion
(ge, ":main_chance", ":main_random_chance"),
(call_script, "script_rebellion_faction_call", ":main_faction"),
(try_end),
(try_end),
##################### debugging messages ################################
(try_begin),
(eq, "$kaos_debug_mode", 1),
(str_store_faction_name, s52, ":main_faction"),
(assign, reg53, ":main_random_chance"),
(assign, reg54, ":main_chance"),
(faction_get_slot, ":main_leader_no", ":main_faction", slot_faction_leader),
(str_store_troop_name, s55, ":main_leader_no"),
(display_log_message, "@{!} {s52} has a rebelion chance of {reg54} must be gt than {reg53} for rebel leader {s55}", 0xFF0000),
(try_end),
##################### debugging messages ################################
(try_begin),
(faction_slot_eq, ":sub_faction", slot_faction_state, sfs_inactive),
(neg|faction_slot_eq, ":sub_faction", slot_faction_state, sfs_defeated),
(faction_get_slot, ":sub_date", ":sub_faction", slot_rebellion_date),
#Check that the current date is greater than the minimum day for rebellion to start
(ge, ":cur_day", ":sub_date"),
(neg|main_party_has_troop, ":sub_npc"),
(call_script, "script_rebelion_assesment", ":sub_faction"),
(faction_get_slot, ":sub_chance", ":sub_faction", slot_faction_has_rebellion_chance),
#Modify the random chance generation so that low fracturing makes it harder for a rebellion
(val_add, ":sub_chance", ":bonus"),
(store_sub, ":lower_limit", 9, ":sub_chance"),
(store_random_in_range, ":sub_random_chance", ":lower_limit", 9),
(try_begin),
#Could change this conditional check to ge for a easier activation of rebellion
(ge, ":sub_chance", ":sub_random_chance"),
(call_script, "script_rebellion_faction_call", ":sub_faction"),
(try_end),
(try_end),
##################### debugging messages ################################
(try_begin),
(eq, "$kaos_debug_mode", 1),
(str_store_faction_name, s52, ":sub_faction"),
(assign, reg53, ":sub_random_chance"),
(assign, reg54, ":sub_chance"),
(faction_get_slot, ":sub_leader_no", ":sub_faction", slot_faction_leader),
(str_store_troop_name, s55, ":sub_leader_no"),
(display_log_message, "@{!} {s52} has a rebelion chance of {reg54} must be gt than {reg53} for rebel leader {s55}", 0xFF0000),
(try_end),
##################### debugging messages ################################
(try_end),
(try_end),
]
),