#############
## Traits ##
#############
#script_ta_init
#Initializes all T&A stuff.
("ta_init",
[
#Each trait/ancillary has four options.
#0 (false_no_trait): false/doesn't have the trait.
#1 (false_had_trait): false/once had the trait but no longer does.
#2 (false_had_trait_bonus): false/once had the trait but no longer does AND bonus taken.
#3 (true_has_trait): true/has the trait.
#4 (true_has_trait_bonus): true/has the trait AND trait bonus has been given.
#Handle kings.
(try_for_range, ":king", kings_begin, kings_end),
#Set all traits to false.
(try_for_range, ":ta", ta_begin, ta_end),
(troop_set_slot, ":king", ":ta", false_no_trait),
(try_end),
#Add 3-7 random traits.
(store_random_in_range, ":rand", 4,
,
(try_for_range, reg1, 3, ":rand"),
(store_random_in_range, ":rand", ta_begin, ta_end),
(call_script, "script_ta_enable_trait_no", ":king", ":rand"),
(try_end),
(try_end),
#Handle lords.
(try_for_range, ":lord", lords_begin, lords_end),
#Set all traits to false.
(try_for_range, ":ta", ta_begin, ta_end),
(troop_set_slot, ":lord", ":ta", false_no_trait),
(try_end),
#Add 1-3 random traits.
(store_random_in_range, ":rand", 2, 4),
(try_for_range, reg1, 1, ":rand"),
(store_random_in_range, ":rand", ta_begin, ta_end),
(call_script, "script_ta_enable_trait_no", ":lord", ":rand"),
(try_end),
(try_end),
]),
#script_ta_enable_trait_no
#Input: troop, trait no.
#Gives the given trait to the given troop.
("ta_enable_trait_no",
[
(store_script_param, ":troop", 1),
(store_script_param, ":trait_no", 2),
(try_begin),
(ge, ":trait_no", ta_begin),
(lt, ":trait_no", ta_end),
(troop_get_slot, ":trait", ":troop", ":trait_no"),
(try_begin),
(neq, ":trait", false_had_trait),
(neq, ":trait", false_had_trait_bonus),
(neq, ":trait", true_has_trait),
(neq, ":trait", true_has_trait_bonus),
(troop_set_slot, ":troop", ":trait_no", true_has_trait),
(try_end),
(try_end),
]),
#script_ta_disable_trait_no
#Input: troop, trait no.
#Disables the given trait of the given troop.
("ta_disable_trait_no",
[
(store_script_param, ":troop", 1),
(store_script_param, ":trait_no", 2),
(try_begin),
(ge, ":trait_no", ta_begin),
(lt, ":trait_no", ta_end),
(troop_get_slot, ":trait", ":troop", ":trait_no"),
(try_begin),
(neq, ":trait", false_no_trait),
(neq, ":trait", false_had_trait),
(neq, ":trait", false_had_trait_bonus),
(try_begin),
(eq, ":trait", true_has_trait),
(troop_set_slot, ":troop", ":trait_no", false_had_trait),
(else_try),
(eq, ":trait", true_has_trait_bonus),
(troop_set_slot, ":troop", ":trait_no", false_had_trait_bonus),
(try_end),
(troop_set_slot, ":troop", 201, 2), #ta_disgraced
(try_end),
(try_end),
]),
#script_ta_get_trait_text
#Input: trait no.
#Output: s0 as trait text.
#Gets the text of a certain trait.
("ta_get_trait_text",
[
(store_script_param, ":trait_no", 1),
(str_store_string, s0, "@"),
(try_begin),
(eq, ":trait_no", 201), #ta_disgraced
(str_store_string, s0, "@Disgraced.^What this man once knew,^he can no longer recollect."),
(else_try),
(eq, ":trait_no", 202), #ta_goodcommander
(str_store_string, s0, "@Good commander.^Great at military tactics.^(+3 tactics)"),
(else_try),
(eq, ":trait_no", 203), #ta_intelligent
(str_store_string, s0, "@Intelligent.^Born with a good wit.^(+4 intelligence)"),
(else_try),
(eq, ":trait_no", 204), #ta_strong
(str_store_string, s0, "@Strong.^Has grown muscles large enough.^(+2 ironflesh, +1 strength)"),
(try_end),
]),