# Clearing conversion fails
(troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
(try_begin),
(troop_slot_eq, ":troop_no", slot_troop_conv, 1),
(troop_set_slot, ":troop_no", slot_troop_conv, 0),
# Player's converts
(else_try),
(troop_slot_eq, ":troop_no", slot_troop_conv, 2),
(try_begin),
(eq, ":religion", 1),
(troop_set_slot, ":troop_no", slot_troop_religion, 2),
(else_try),
(troop_set_slot, ":troop_no", slot_troop_religion, 1),
(try_end),
(val_add, ":controversy", 5),
(troop_set_slot, ":troop_no", slot_troop_controversy, ":controversy"),
(troop_set_slot, ":troop_no", slot_troop_conv, 0),
# Random conversion
(else_try),
(assign, ":chance", 1),
#lord will convert to religion favored by faction/lords 3x faster, so on average only 1/3 faction will be a different religion
#faction religion
(try_begin),
(eq, ":religion", 1),
(faction_slot_eq, ":faction", slot_faction_religion, cb3_pagan),
(val_add, ":chance", 1),
(else_try),
(eq, ":religion", 2),
(faction_slot_eq, ":faction", slot_faction_religion, cb3_christian),
(val_add, ":chance", 1),
(try_end),
#don't convert to the "wrong" religion if already in too much trouble
(this_or_next|gt, ":chance", 1),
(lt, ":controversy", 40),
#lords' religion
(assign, ":rel_comp", 0),
(try_for_range, ":active_npc", active_npcs_begin, active_npcs_end),
(troop_slot_eq, ":active_npc", slot_troop_occupation, slto_kingdom_hero),
(store_faction_of_troop, ":npc_faction", ":active_npc"),
(eq, ":npc_faction", ":faction"),
(neq, ":active_npc", ":troop_no"),
(troop_get_slot, ":religion1",":active_npc", slot_troop_religion),
(try_begin),
(eq, ":religion1", ":religion"),
(val_add, ":rel_comp", -1),
(else_try),
(val_add, ":rel_comp", 1),
(try_end),
(try_end),
# (assign, reg33, ":rel_comp"),
# (display_message, "@{reg33} more lords with a different religion"),
(try_begin),
(gt, ":rel_comp", 0),
(val_add, ":chance", 1),
(try_end),
#lord personalities
(try_begin),
(this_or_next|troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_cunning),
(troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_debauched),
(val_add, ":chance", 2),
(else_try),
(this_or_next|troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_roguish),
(troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_quarrelsome),
(val_add, ":chance", 1),
(try_end),
# (assign, reg32, ":chance"),
# (str_store_troop_name, s31, ":troop_no"),
# (display_message, "@{s31} has a {reg32} chance of conversion"),
(store_random_in_range, ":conv", 0, 150), #lord will convert on average n = log(.5)/log(1.00 - 1/150) = 103 weeks = 2 years
# (assign, reg33, ":conv"),
# (display_message, "@Random is {reg33}"),
(lt, ":conv", ":chance"),
(try_begin),
(eq, ":religion", 1),
(troop_set_slot, ":troop_no", slot_troop_religion, 2),
(else_try),
(troop_set_slot, ":troop_no", slot_troop_religion, 1),
(try_end),
(val_add, ":controversy", 5),
(troop_set_slot, ":troop_no", slot_troop_controversy, ":controversy"),
(try_end),
# End conversion