according to kalarhan's instructions, in this thread
https://forums.taleworlds.com/index...quick-questions-and-answers.6575/post-9073428
I looked for the code in mission_template, but it seems it only works for bady_armor ...
I tried various combinations or modifications to make it work for all 3 types of items (armor, boot and head), but they worked poorly or half ...
Does anyone know what could be done so that the group of soldiers randomize all the items that I have put to the troop? (I have 3 boots, 3 uniforms and 5 hats)
Thanks in advance.
https://forums.taleworlds.com/index...quick-questions-and-answers.6575/post-9073428
I looked for the code in mission_template, but it seems it only works for bady_armor ...
I tried various combinations or modifications to make it work for all 3 types of items (armor, boot and head), but they worked poorly or half ...
Does anyone know what could be done so that the group of soldiers randomize all the items that I have put to the troop? (I have 3 boots, 3 uniforms and 5 hats)
Thanks in advance.
Code:
#Armor randomization ########################################
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(agent_is_human, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_is_non_player, ":agent_no"),
(agent_get_item_slot, ":cur_armor", ":agent_no", ek_body),
(agent_get_troop_id, ":troop", ":agent_no"),
(neg|troop_is_hero,":troop"),
(troop_get_inventory_capacity, ":end_cond", ":troop"),
(assign, ":result", -1),
(assign, ":slot_no", 0),
(try_for_range, ":i_slot", 0, ":end_cond"),
(troop_get_inventory_slot, ":item_id", ":troop", ":i_slot"),
(gt,":item_id",0),
(item_get_type, ":item_type", ":item_id"),
(eq, ":item_type", itp_type_body_armor),
(troop_get_inventory_slot_modifier, ":item_imod", ":troop", ":i_slot"),
(troop_set_slot, "trp_temp_array_b", ":slot_no", ":item_id"),
(troop_set_slot, "trp_temp_array_a", ":slot_no", ":item_imod"),
(val_add, ":slot_no", 1),
(try_end),
(try_for_range, ":unused", 0, 2),
(call_script, "script_shuffle_troop_slots", "trp_temp_array_b",0,":slot_no"),
(try_end),
(gt, ":slot_no", 0),
(store_mul, ":slot10", ":slot_no",10),
(try_for_range, ":unused", 0, 6),
(store_random_in_range, ":result", 0, ":slot10"),
(try_end),
(val_div, ":result", 10),
(try_begin),
(gt, ":slot_no", 6),
(store_div, ":half", ":slot_no", 2),
(eq, ":result", ":half"),
(store_random_in_range, ":rand", -2,3),#-2,3
(val_add, ":result", ":rand"),
(try_end),
(neq, ":result", -1),
(store_random_in_range, ":imod", 0, ":slot_no"),
(troop_get_slot, ":cur_slot", "trp_temp_array_b", ":result"),
(troop_get_slot, ":cur_imod", "trp_temp_array_a", ":imod"),
(neq, ":cur_slot", ":cur_armor"),
(try_begin),
(gt, ":cur_armor", -1),
(agent_unequip_item, ":agent_no",":cur_armor"),
(try_end),
(agent_equip_item, ":agent_no",":cur_slot",ek_body, ":cur_imod"),
]),
Last edited by a moderator: