rubik
Squire
As is known to all, the max inventory slots of a troop(with 10 inventory Management) is 96, so do the amount of war booties.
Related code is here in module_scripts.py. It makes trp_temp_troop to loot all the defeated enemies one by one. Maybe when trp_temp_troop had looted some low-level troops preceding, its inventory is full with 96 poor items, then it can't loot the high-level troops left with good items. It's a big loss.
We can enlarge the max inventory slots to 288 by connecting 3 troops which with 10 inventory Management, then let them to loot the defeated enemies one by one. They can loot 288 war booties at most. At last, we can choose the 96 most valuable items and add them to the inventory of trp_temp_troop to let the player to choose.
The following is the improved code to overwrite the code mentioned above:
The following are two scripts used in the code above, add these to the end of module_scripts.py if your MOD has not them.
script_copy_inventory:
script_get_item_value_with_imod:
Related code is here in module_scripts.py. It makes trp_temp_troop to loot all the defeated enemies one by one. Maybe when trp_temp_troop had looted some low-level troops preceding, its inventory is full with 96 poor items, then it can't loot the high-level troops left with good items. It's a big loss.
(party_get_num_companion_stacks, ":num_stacks",":enemy_party"),
(try_for_range, ":i_stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop",":enemy_party",":i_stack"),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":enemy_party",":i_stack"),
(try_for_range, ":unused", 0, ":stack_size"),
(troop_loot_troop, "trp_temp_troop", ":stack_troop", ":loot_probability"),
(try_end),
(try_end),
We can enlarge the max inventory slots to 288 by connecting 3 troops which with 10 inventory Management, then let them to loot the defeated enemies one by one. They can loot 288 war booties at most. At last, we can choose the 96 most valuable items and add them to the inventory of trp_temp_troop to let the player to choose.
The following is the improved code to overwrite the code mentioned above:
## CC
(store_add, ":temp_array_c_plus_one", "trp_temp_array_c", 1),
(try_for_range, ":cur_troop", "trp_temp_array_a", ":temp_array_c_plus_one"),
(troop_clear_inventory, ":cur_troop"), # clear_inventory
# raise skl_inventory_management level to 10
(store_skill_level, ":cur_level", skl_inventory_management, ":cur_troop"),
(store_sub, ":dest_level", 10, ":cur_level"),
(troop_raise_skill, ":cur_troop", skl_inventory_management, ":dest_level"),
(try_end),
(call_script, "script_copy_inventory", "trp_temp_troop", "trp_temp_array_a"),
(party_get_num_companion_stacks, ":num_stacks", ":enemy_party"),
(try_for_range, ":i_stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop",":enemy_party",":i_stack"),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":enemy_party",":i_stack"),
(try_for_range, ":unused", 0, ":stack_size"),
(try_begin),
(store_free_inventory_capacity, ":inv_cap_a", "trp_temp_array_a"),
(gt, ":inv_cap_a", 0),
(troop_loot_troop, "trp_temp_array_a", ":stack_troop", ":loot_probability"),
(else_try),
(store_free_inventory_capacity, ":inv_cap_b", "trp_temp_array_b"),
(gt, ":inv_cap_b", 0),
(troop_loot_troop, "trp_temp_array_b", ":stack_troop", ":loot_probability"),
(else_try),
(troop_loot_troop, "trp_temp_array_c", ":stack_troop", ":loot_probability"),
(try_end),
(try_end),
(try_end),
(troop_clear_inventory, "trp_temp_troop"),
(try_for_range, ":unused", 0, 96), # for 96 times
# find the best item
(assign, ":best_score", 0),
(assign, ":best_troop", -1),
(assign, ":best_slot", -1),
(try_for_range, ":cur_troop", "trp_temp_array_a", ":temp_array_c_plus_one"),
(troop_get_inventory_capacity, ":inv_cap", ":cur_troop"),
(try_for_range, ":i_slot", 10, ":inv_cap"),
(troop_get_inventory_slot, ":item", ":cur_troop", ":i_slot"),
(troop_get_inventory_slot_modifier, ":imod", ":cur_troop", ":i_slot"),
(gt, ":item", -1),
(call_script, "script_get_item_value_with_imod", ":item", ":imod"),
(assign, ":score", reg0),
(val_div, ":score", 100),
(val_max, ":score",1),
(gt, ":score", ":best_score"),
(assign, ":best_score", ":score"),
(assign, ":best_troop", ":cur_troop"),
(assign, ":best_slot", ":i_slot"),
(try_end),
(try_end),
(gt, ":best_score", 0),
# already found
(troop_get_inventory_slot, ":item", ":best_troop", ":best_slot"),
(troop_get_inventory_slot_modifier, ":imod", ":best_troop", ":best_slot"),
(troop_add_item, "trp_temp_troop", ":item", ":imod"), # add to trp_temp_troop
(troop_set_inventory_slot, ":best_troop", ":best_slot", -1), # remove it
(try_end),
## CC
The following are two scripts used in the code above, add these to the end of module_scripts.py if your MOD has not them.
script_copy_inventory:
("copy_inventory",
[
(store_script_param_1, ":source"),
(store_script_param_2, ":target"),
(troop_clear_inventory, ":target"),
(troop_get_inventory_capacity, ":inv_cap", ":source"),
(try_for_range, ":i_slot", 0, ":inv_cap"),
(troop_get_inventory_slot, ":item", ":source", ":i_slot"),
(troop_set_inventory_slot, ":target", ":i_slot", ":item"),
(troop_get_inventory_slot_modifier, ":imod", ":source", ":i_slot"),
(troop_set_inventory_slot_modifier, ":target", ":i_slot", ":imod"),
(troop_inventory_slot_get_item_amount, ":amount", ":source", ":i_slot"),
(gt, ":amount", 0),
(troop_inventory_slot_set_item_amount, ":target", ":i_slot", ":amount"),
(try_end),
]),
script_get_item_value_with_imod:
("get_item_value_with_imod",
[# returns the sell price based on the item's money value and its imod
(store_script_param, ":item", 1),
(store_script_param, ":imod", 2),
(store_item_value, ":score", ":item"),
(try_begin),
(eq, ":imod", imod_plain),
(assign, ":imod_multiplier", 100),
(else_try),
(eq, ":imod", imod_cracked),
(assign, ":imod_multiplier", 50),
(else_try),
(eq, ":imod", imod_rusty),
(assign, ":imod_multiplier", 55),
(else_try),
(eq, ":imod", imod_bent),
(assign, ":imod_multiplier", 65),
(else_try),
(eq, ":imod", imod_chipped),
(assign, ":imod_multiplier", 72),
(else_try),
(eq, ":imod", imod_battered),
(assign, ":imod_multiplier", 75),
(else_try),
(eq, ":imod", imod_poor),
(assign, ":imod_multiplier", 80),
(else_try),
(eq, ":imod", imod_crude),
(assign, ":imod_multiplier", 83),
(else_try),
(eq, ":imod", imod_old),
(assign, ":imod_multiplier", 86),
(else_try),
(eq, ":imod", imod_cheap),
(assign, ":imod_multiplier", 90),
(else_try),
(eq, ":imod", imod_fine),
(assign, ":imod_multiplier", 190),
(else_try),
(eq, ":imod", imod_well_made),
(assign, ":imod_multiplier", 250),
(else_try),
(eq, ":imod", imod_sharp),
(assign, ":imod_multiplier", 160),
(else_try),
(eq, ":imod", imod_balanced),
(assign, ":imod_multiplier", 350),
(else_try),
(eq, ":imod", imod_tempered),
(assign, ":imod_multiplier", 670),
(else_try),
(eq, ":imod", imod_deadly),
(assign, ":imod_multiplier", 850),
(else_try),
(eq, ":imod", imod_exquisite),
(assign, ":imod_multiplier", 1450),
(else_try),
(eq, ":imod", imod_masterwork),
(assign, ":imod_multiplier", 1750),
(else_try),
(eq, ":imod", imod_heavy),
(assign, ":imod_multiplier", 190),
(else_try),
(eq, ":imod", imod_strong),
(assign, ":imod_multiplier", 490),
(else_try),
(eq, ":imod", imod_powerful),
(assign, ":imod_multiplier", 320),
(else_try),
(eq, ":imod", imod_tattered),
(assign, ":imod_multiplier", 50),
(else_try),
(eq, ":imod", imod_ragged),
(assign, ":imod_multiplier", 70),
(else_try),
(eq, ":imod", imod_rough),
(assign, ":imod_multiplier", 60),
(else_try),
(eq, ":imod", imod_sturdy),
(assign, ":imod_multiplier", 170),
(else_try),
(eq, ":imod", imod_thick),
(assign, ":imod_multiplier", 260),
(else_try),
(eq, ":imod", imod_hardened),
(assign, ":imod_multiplier", 390),
(else_try),
(eq, ":imod", imod_reinforced),
(assign, ":imod_multiplier", 650),
(else_try),
(eq, ":imod", imod_superb),
(assign, ":imod_multiplier", 250),
(else_try),
(eq, ":imod", imod_lordly),
(assign, ":imod_multiplier", 1150),
(else_try),
(eq, ":imod", imod_lame),
(assign, ":imod_multiplier", 40),
(else_try),
(eq, ":imod", imod_swaybacked),
(assign, ":imod_multiplier", 60),
(else_try),
(eq, ":imod", imod_stubborn),
(assign, ":imod_multiplier", 90),
(else_try),
(eq, ":imod", imod_timid),
(assign, ":imod_multiplier", 180),
(else_try),
(eq, ":imod", imod_meek),
(assign, ":imod_multiplier", 180),
(else_try),
(eq, ":imod", imod_spirited),
(assign, ":imod_multiplier", 650),
(else_try),
(eq, ":imod", imod_champion),
(assign, ":imod_multiplier", 1450),
(else_try),
(eq, ":imod", imod_fresh),
(assign, ":imod_multiplier", 100),
(else_try),
(eq, ":imod", imod_day_old),
(assign, ":imod_multiplier", 100),
(else_try),
(eq, ":imod", imod_two_day_old),
(assign, ":imod_multiplier", 90),
(else_try),
(eq, ":imod", imod_smelling),
(assign, ":imod_multiplier", 40),
(else_try),
(eq, ":imod", imod_rotten),
(assign, ":imod_multiplier", 5),
(else_try),
(eq, ":imod", imod_large_bag),
(assign, ":imod_multiplier", 190),
(try_end),
(val_mul, ":score", ":imod_multiplier"),
(assign, reg0, ":score"),
]),