Presentation to display Troop Tree like Rubik made for Custom Commander 's proved very useful for players.
The problem is for mods that have different factions or different troop trees from Native, we must make the troop trees for them one by one and to adjust the diagram positions is a boring and time consuming activity.
The solution is a generic presentation that read the troop upgrade from 1st tier of every faction and draw the diagram automatically.
Here's my trial to make it.
Issues :
- The code has not been optimized, even I am not interested in doing it because of this presentation will be called from the report menu where performance is not an issue.
- It has no support yet for troops that can be upgraded from more than 1 troop. (Caba's improved version on page 2 has support for this case).
- Limited Support to max 6 tiers and max 4 branches (visually)
- Limited Support to max 10 tiers and max 10 branches (data structure)
Credits :
- rubik, for the original idea and the script execute the drawing.
Windyplains' modmerger kit (with Caba's modification included) :
http://mountandblade.nexusmods.com/mods/3682
EDIT :
- Adding missing get_troop_max_hp and copy_inventory script and import declaration. Thanks to Dawg of War and Lav for pointing those.
- Diplomacy has CC included, so scripts from CC 's already on the it's Module System, but some of them have dplmc_ prefix.
The problem is for mods that have different factions or different troop trees from Native, we must make the troop trees for them one by one and to adjust the diagram positions is a boring and time consuming activity.
The solution is a generic presentation that read the troop upgrade from 1st tier of every faction and draw the diagram automatically.
Here's my trial to make it.
Code:
# Presentations Constants
title_pos_x = 500
title_pos_y = 650
title_size = 2000
title_black = 0x000000
title_red = 0xFF0000
title_yellow = 0xFFFF00
working_pos_y = 550
large_size = 1500
medium_size = 1200
normal_size = 1000
small_size = 800
smaller_size = 600
tinny_size = 450
troop_tree_size_x = 375
troop_tree_size_y = 500
troop_tree_space_x = 170
troop_tree_space_y = 140#170
troop_tree_left = 60
Code:
("faction_troop_tree", "Faction's Troop Tree"),
Code:
("faction_troop_tree", 0, mesh_load_window,
[(ti_on_presentation_load,
[(presentation_set_duration, 999999),
(set_fixed_point_multiplier, 1000),
# Title
(position_set_y, pos1, title_pos_y), (position_set_x, pos1, title_pos_x), # Title Position
(position_set_x, pos3, title_size), (position_set_y, pos3, title_size), # Title Size
(create_text_overlay, reg0, "str_faction_troop_tree", tf_center_justify), (overlay_set_color, reg0, title_black),
(overlay_set_position, reg0, pos1), (overlay_set_size, reg0, pos3),
(position_set_y, pos1, title_pos_y-1), (position_set_x, pos1, title_pos_x-1), # Title Position
(create_text_overlay, reg0, "str_faction_troop_tree", tf_center_justify), (overlay_set_color, reg0, title_red),
(overlay_set_position, reg0, pos1), (overlay_set_size, reg0, pos3),
# Create Objects
(create_combo_label_overlay, "$g_presentation_obj_1"), #type
(position_set_x, pos1, title_pos_x), (position_set_y, pos1, title_pos_y-50), (overlay_set_position, "$g_presentation_obj_1", pos1),
# Objects
(assign, ":hi_faction", "fac_kingdoms_end"),
(try_begin),
(faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
(assign, ":lo_faction", "fac_kingdom_1"),
(else_try),
(assign, ":lo_faction", "fac_player_supporters_faction"),
(try_end),
(try_for_range, ":faction", ":lo_faction", ":hi_faction"),
(str_store_faction_name, s1, ":faction"),
(overlay_add_item, "$g_presentation_obj_1", s1),
(try_end),
(store_sub, reg12, ":hi_faction", ":lo_faction"),
(val_clamp, reg11, 0, reg12),
(overlay_set_val, "$g_presentation_obj_1", reg11),
(store_add, "$faction_display", ":lo_faction", reg11),
(faction_get_slot, ":culture", "$faction_display", slot_faction_culture),
(call_script, "script_prsnt_culture_troop_tree", ":culture"), ]),
(ti_on_presentation_event_state_change,
[(store_trigger_param_1, ":object"),
(store_trigger_param_2, ":value"),
(set_fixed_point_multiplier, 1000),
(try_begin),
(eq, ":object", "$g_presentation_obj_1"),
(assign, reg11, ":value"),
(start_presentation, "prsnt_faction_troop_tree"),
(else_try),
(troop_get_slot, ":limit", "trp_temp_array_c", 100),
(val_add, ":limit", 1), (assign, ":troop_no", 0),
(try_for_range, ":slot", 101, ":limit"),
(le, ":troop_no", 0),
(troop_slot_eq, "trp_temp_array_c", ":slot", ":object"),
(troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot"),
(try_end),
(gt, ":troop_no", 0),
(assign, "$temp", ":troop_no"),
(assign, "$g_presentation_next_presentation", "prsnt_faction_troop_tree"),
(start_presentation, "prsnt_troop_note"),
(try_end), ]),
## Event to process when running the presentation
(ti_on_presentation_run,
[(try_begin),
(this_or_next|key_clicked, key_escape),
(key_clicked, key_right_mouse_button),
(presentation_set_duration, 0),
(assign, "$faction_display", 0),
(jump_to_menu, "mnu_reports"), # I asume it's called from report menu, you can modify it to any menus or using $next_menu declarated by menu that call this presentation
(try_end), ]), ]),
# rubik CC's Presentation
("troop_note", 0, mesh_load_window, [
(ti_on_presentation_load,
[
(presentation_set_duration, 999999),
(set_fixed_point_multiplier, 1000),
## init troop items
(call_script, "script_copy_inventory", "$temp", "trp_temp_array_a"),
(try_for_range, ":i_slot", 0, 10),
(troop_get_inventory_slot, ":item", "trp_temp_array_a", ":i_slot"),
(gt, ":item", -1),
(troop_add_item,"trp_temp_array_a",":item"),
(troop_set_inventory_slot, "trp_temp_array_a", ":i_slot", -1),
(try_end),
## back
(create_game_button_overlay, "$g_presentation_obj_1", "@Done"),
(position_set_x, pos1, 900),
(position_set_y, pos1, 25),
(overlay_set_position, "$g_presentation_obj_1", pos1),
################
(store_mul, ":cur_troop", "$temp", 2), #with weapons
(create_mesh_overlay_with_tableau_material, reg0, -1, "tableau_game_party_window", ":cur_troop"),
(position_set_x, pos1, 750),
(position_set_y, pos1, 1000),
(overlay_set_size, reg0, pos1),
(position_set_x, pos1, 750),
(position_set_y, pos1, 350),
(overlay_set_position, reg0, pos1),
(str_store_troop_name, s1, "$temp"),
(store_character_level, ":troop_level", "$temp"),
(assign, reg1, ":troop_level"),
(str_store_string, s1, "@Name: {s1}^Level: {reg1}"),
(call_script, "script_get_troop_max_hp", "$temp"),
(str_store_string, s1, "@{s1}^HP: {reg0}"),
(create_text_overlay, reg0, "@{s1}", tf_double_space),
(position_set_x, pos1, 500),
(position_set_y, pos1, 500),
(overlay_set_position, reg0, pos1),
(str_store_string, s3, "@Attributes:"),
(store_attribute_level, reg1, "$temp", ca_strength),
(store_attribute_level, reg2, "$temp", ca_intelligence),
(str_store_string, s3, "@{s3}^STR: {reg1}^INT: {reg2}^^Skills:"),
(store_skill_level, reg1, skl_power_strike, "$temp"),
(store_skill_level, reg2, skl_power_draw, "$temp"),
(store_skill_level, reg3, skl_power_throw, "$temp"),
(store_skill_level, reg4, skl_horse_archery, "$temp"),
(str_store_string, s3, "@{s3}^Power Strike: {reg1}^Power Draw: {reg2}^Power Throw: {reg3}^Horse Archery: {reg4}^^Weapon Proficiencies:"),
(store_proficiency_level, reg1, "$temp", wpt_one_handed_weapon),
(store_proficiency_level, reg2, "$temp", wpt_two_handed_weapon),
(store_proficiency_level, reg3, "$temp", wpt_polearm),
(str_store_string, s3, "@{s3}^1 Hand Wpns: {reg1}^2 Hand Wpns: {reg2}^Polearms: {reg3}"),
(create_text_overlay, reg0, "@{s3}", tf_double_space),
(position_set_x, pos1, 500),
(position_set_y, pos1, 100),
(overlay_set_position, reg0, pos1),
(str_store_string, s4, "str_empty_string"),
(store_attribute_level, reg1, "$temp", ca_agility),
(store_attribute_level, reg2, "$temp", ca_charisma),
(str_store_string, s4, "@{s4}^AGI: {reg1}^CHA: {reg2}^^"),
(store_skill_level, reg1, skl_ironflesh, "$temp"),
(store_skill_level, reg2, skl_athletics, "$temp"),
(store_skill_level, reg3, skl_shield, "$temp"),
(store_skill_level, reg4, skl_riding, "$temp"),
(str_store_string, s4, "@{s4}^Ironflesh: {reg1}^Athletics: {reg2}^Shield: {reg3}^Riding: {reg4}^^"),
(store_proficiency_level, reg1, "$temp", wpt_archery),
(store_proficiency_level, reg2, "$temp", wpt_crossbow),
(store_proficiency_level, reg3, "$temp", wpt_throwing),
(str_store_string, s4, "@{s4}^Archery: {reg1}^Crossbows: {reg2}^Throwing: {reg3}"),
(create_text_overlay, reg0, "@{s4}", tf_double_space),
(position_set_x, pos1, 710),
(position_set_y, pos1, 100),
(overlay_set_position, reg0, pos1),
################
(str_clear, s0),
(create_text_overlay, "$g_presentation_obj_2", s0, tf_scrollable),
(position_set_x, pos1, 50),
(position_set_y, pos1, 50),
(overlay_set_position, "$g_presentation_obj_2", pos1),
(position_set_x, pos1, 350),
(position_set_y, pos1, 560),
(overlay_set_area_size, "$g_presentation_obj_2", pos1),
(set_container_overlay, "$g_presentation_obj_2"),
(assign, ":pos_x", 0),
(assign, ":pos_y", 1840),
(assign, ":slot_no", 10),
(try_for_range, ":unused_height", 0, 24),
(try_for_range, ":unused_width", 0, 4),
(create_mesh_overlay, reg1, "mesh_inv_slot"),
(position_set_x, pos1, 800),
(position_set_y, pos1, 800),
(overlay_set_size, reg1, pos1),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg1, pos1),
(create_mesh_overlay, reg1, "mesh_mp_inventory_choose"),
(position_set_x, pos1, 640),
(position_set_y, pos1, 640),
(overlay_set_size, reg1, pos1),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg1, pos1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", reg1),
(troop_get_inventory_slot, ":item_no", "trp_temp_array_a", ":slot_no"),
(try_begin),
(gt, ":item_no", -1),
(create_mesh_overlay_with_item_id, reg1, ":item_no"),
(position_set_x, pos1, 800),
(position_set_y, pos1, 800),
(overlay_set_size, reg1, pos1),
(store_add, ":item_x", ":pos_x", 40),
(store_add, ":item_y", ":pos_y", 40),
(position_set_x, pos1, ":item_x"),
(position_set_y, pos1, ":item_y"),
(overlay_set_position, reg1, pos1),
(troop_set_slot, "trp_temp_array_b", ":slot_no", reg1),
(try_end),
(val_add, ":pos_x", 80),
(val_add, ":slot_no", 1),
(try_end),
(assign, ":pos_x", 0),
(val_sub, ":pos_y", 80),
(try_end),
(set_container_overlay, -1),
(create_text_overlay, reg1, "@Equipments: ", tf_vertical_align_center),
(position_set_x, pos1, 60),
(position_set_y, pos1, 635),
(overlay_set_position, reg1, pos1),
## items
# ####### mouse fix pos system #######
# (call_script, "script_mouse_fix_pos_ready"),
# ####### mouse fix pos system #######
]),
# (ti_on_presentation_run,
# [
# ####### mouse fix pos system #######
# (call_script, "script_mouse_fix_pos_run"),
# ####### mouse fix pos system #######
# ]),
(ti_on_presentation_mouse_enter_leave,
[
(store_trigger_param_1, ":object"),
(store_trigger_param_2, ":enter_leave"),
(try_begin),
(eq, ":enter_leave", 0),
(try_for_range, ":slot_no", 10, 106),
(troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
(troop_get_inventory_slot, ":item_no", "trp_temp_array_a", ":slot_no"),
(try_begin),
(gt, ":item_no", -1),
(troop_get_slot, ":target_obj", "trp_temp_array_b", ":slot_no"),
(overlay_get_position, pos0, ":target_obj"),
(show_item_details, ":item_no", pos0, 100),
(assign, "$g_current_opened_item_details", ":slot_no"),
(try_end),
(try_end),
(else_try),
(try_for_range, ":slot_no", 10, 106),
(troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
(try_begin),
(eq, "$g_current_opened_item_details", ":slot_no"),
(close_item_details),
(try_end),
(try_end),
(try_end),
]),
(ti_on_presentation_event_state_change,
[
(store_trigger_param_1, ":object"),
(try_begin),
(eq, ":object", "$g_presentation_obj_1"),
(try_begin),
(eq, "$g_presentation_next_presentation", "prsnt_faction_troop_tree"),
(assign, "$g_presentation_next_presentation", -1),
(try_begin),
(faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
(store_sub, reg11, "$faction_display", "fac_kingdom_1"),
(else_try),
(store_sub, reg11, "$faction_display", "fac_player_supporters_faction"),
(try_end),
(start_presentation, "prsnt_faction_troop_tree"),
(else_try),
(presentation_set_duration, 0),
(try_end),
(try_end),
]),
]),
# rubik CC's Presentation
Code:
from header_presentations import * # add this at the beggining of module_scripts.py
("prsnt_culture_troop_tree",
[(store_script_param_1, ":culture"),
(store_sub, ":num", ":culture", fac_culture_1), (val_mod, ":num", 6),
(store_add, ":slot", ":num","mesh_pic_arms_swadian"),
(create_mesh_overlay, reg0, ":slot"),
(store_add, ":slot", ":num", "mesh_pic_swad"),
(create_mesh_overlay, reg1, ":slot"),
(position_set_x, pos1, 180),(position_set_y, pos1, 560),
(position_set_x, pos2, 500),(position_set_y, pos2, 25),
(position_set_x, pos3, 500),(position_set_y, pos3, 500),
(overlay_set_position, reg0, pos1), (overlay_set_size, reg0, pos3),
(overlay_set_position, reg1, pos2), (overlay_set_size, reg1, pos3),
(try_for_range, ":slot", 0, 61),
(troop_set_slot, "trp_temp_array_a", ":slot", 0),
(troop_set_slot, "trp_temp_array_b", ":slot", 0),
(troop_set_slot, "trp_temp_array_c", ":slot", 0),
(store_add, ":num", 100),
(troop_set_slot, "trp_temp_array_b", ":num", -1),
(troop_set_slot, "trp_temp_array_c", ":num", -1),
(try_end),
(faction_get_slot, ":troop_no", ":culture", slot_faction_tier_1_troop),
# lowest troop tiers initialization BEGIN
(troop_set_slot, "trp_temp_array_a", 0, 1), # Number of Lowest Tier Troop
(troop_set_slot, "trp_temp_array_a", 1, 1), # 1 for 1st troop
(troop_set_slot, "trp_temp_array_b", 1, ":troop_no"), # 1st troop id
# lowest troop tiers initialization END
(assign, ":max_tier", 0), (assign, ":no_tier", 0),
(try_for_range, ":tier", 1, 10), # Asuming that you wont make troop tree more than 10 tiers
(eq, ":no_tier", 0),
(assign, ":no_tier", 1),
(store_sub, ":prev_tier", ":tier", 1),
(store_mul, ":slot_for_prev_num", ":prev_tier", 10),
(store_mul, ":slot_for_num", ":tier", 10),
(assign, ":num", 0),
(troop_get_slot, ":prev_num", "trp_temp_array_a", ":slot_for_prev_num"),
(gt, ":prev_num", 0),
(val_add, ":prev_num", 1),
(try_for_range, ":tree_no", 1, ":prev_num"),
(store_add, ":prev_slot", ":tree_no", ":slot_for_prev_num"),
(troop_get_slot, ":troop_no", "trp_temp_array_b", ":prev_slot"),
(gt, ":troop_no", 0),
(troop_get_upgrade_troop, ":next_troop", ":troop_no", 0),
(gt, ":next_troop", 0),
(assign, ":no_tier", 0),
(val_add, ":num", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_for_num", ":num"),
(store_add, ":slot", ":slot_for_num", ":num"),
(troop_set_slot, "trp_temp_array_a", ":slot", ":tree_no"),
(troop_set_slot, "trp_temp_array_b", ":slot", ":next_troop"),
(troop_get_upgrade_troop, ":next_troop", ":troop_no", 1),
(gt, ":next_troop", 0),
(val_add, ":num", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_for_num", ":num"),
(store_add, ":slot", ":slot_for_num", ":num"),
(troop_set_slot, "trp_temp_array_a", ":slot", ":tree_no"),
(troop_set_slot, "trp_temp_array_b", ":slot", ":next_troop"),
(try_end),
(eq, ":no_tier", 0),
(val_add, ":max_tier", 1),
(try_end),
(store_mul, ":max_num_tier", ":max_tier", 10), (val_add, ":max_tier", 1),
(troop_get_slot, ":num", "trp_temp_array_a", ":max_num_tier"),
(val_add, ":num", 1),
(try_for_range, ":tree_no", 1, ":num"),
(store_add, ":slot", ":max_num_tier", ":tree_no"),
(store_mul, ":subs", ":tree_no", troop_tree_space_y),
(store_sub, ":pos", working_pos_y + 35, ":subs"),
(troop_set_slot, "trp_temp_array_c", ":slot", ":pos"),
(try_end),
(try_for_range_backwards, ":tier", 1, ":max_tier"),
(store_mul, ":slot_for_num", ":tier", 10),
(store_sub, ":prev_tier", ":tier", 1),
(store_mul, ":slot_for_prev_num", ":prev_tier", 10),
(troop_get_slot, ":prev_num", "trp_temp_array_a", ":slot_for_prev_num"),
(gt, ":prev_num", 0),
(val_add, ":prev_num", 1),
(try_for_range, ":tree_no", 1, ":prev_num"),
(store_add, ":prev_slot", ":tree_no", ":slot_for_prev_num"),
(assign, ":prev_pos", 0), (assign, ":num", 0),
(try_for_range, ":subs", 1, 10),
(store_add, ":slot", ":subs", ":slot_for_num"),
(troop_slot_eq, "trp_temp_array_a", ":slot", ":tree_no"),
(troop_get_slot, ":pos", "trp_temp_array_c", ":slot"),
(val_add, ":prev_pos", ":pos"),
(val_add, ":num", 1),
(try_end),
(gt, ":num", 0),
(val_div, ":prev_pos", ":num"),
(troop_set_slot, "trp_temp_array_c", ":prev_slot", ":prev_pos"),
(try_end),
(assign, ":pos", 999),
(try_for_range, ":tree_no", 1, ":prev_num"),
(store_add, ":prev_slot", ":tree_no", ":slot_for_prev_num"),
(troop_get_slot, ":prev_pos", "trp_temp_array_c", ":prev_slot"),
(gt, ":prev_pos", 0),
(lt, ":prev_pos", ":pos"),
(assign, ":pos", ":prev_pos"),
(try_end),
(try_for_range, ":tree_no", 1, ":prev_num"),
(store_add, ":prev_slot", ":tree_no", ":slot_for_prev_num"),
(troop_get_slot, ":prev_pos", "trp_temp_array_c", ":prev_slot"),
(eq, ":prev_pos", 0),
(store_sub, ":prev_pos", ":pos", troop_tree_space_y),
(assign, ":pos", ":prev_pos"),
(troop_set_slot, "trp_temp_array_c", ":prev_slot", ":prev_pos"),
(try_end),
(try_end),
(val_add, ":max_num_tier", 11), (troop_set_slot, "trp_temp_array_c", 100, 0), (assign, ":num",100),
(try_for_range, ":slot", 0, ":max_num_tier"),
(troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot"),
(gt, ":troop_no", 0),
(store_div, ":posx", ":slot", 10),
(val_mul, ":posx", troop_tree_space_x),
(val_add, ":posx", troop_tree_left),
(troop_get_slot, ":posy", "trp_temp_array_c", ":slot"),
(val_add, ":num", 1),
(call_script, "script_prsnt_upgrade_tree_troop_and_name", ":troop_no", ":posx", ":posy"),
(troop_set_slot, "trp_temp_array_c", ":num", reg1),
(troop_set_slot, "trp_temp_array_b", ":num", ":troop_no"),
(store_mod, ":cur_slot", ":slot", 10),
(gt, ":cur_slot", 0),
(store_sub, ":cur_slot1", ":slot", ":cur_slot"),
(val_add, ":cur_slot1", 10),
(store_add, ":cur_slot2", ":cur_slot1", 10),
(try_for_range, ":slot2", ":cur_slot1", ":cur_slot2"),
(troop_slot_ge, "trp_temp_array_b", ":slot2", 1),
(troop_slot_eq, "trp_temp_array_a", ":slot2", ":cur_slot"),
(store_add, ":posx2", ":posx", troop_tree_space_x),
(store_add, ":posx1", ":posx", troop_tree_space_x/2),
(troop_get_slot, ":posy2", "trp_temp_array_c", ":slot2"),
(store_add, ":posy1", ":posy", troop_tree_space_y/2),
(val_add, ":posy2", troop_tree_space_y/2),
(call_script, "script_prsnt_lines_to", ":posx", ":posy1", ":posx2", ":posy2", title_black),
(val_sub, ":posy2", 3),
(call_script, "script_prsnt_upgrade_tree_troop_cost", ":troop_no", ":posx1", ":posy2"),
(try_end),
(try_end),
(troop_set_slot, "trp_temp_array_c", 100, ":num"), ]),
("prsnt_lines_to", # Drawing lines from (x1,y1) to (x2,y2), the line will be horizontal til half way, vertical and then horizontal again
[(store_script_param, ":pos_x1", 1),
(store_script_param, ":pos_y1", 2),
(store_script_param, ":pos_x2", 3),
(store_script_param, ":pos_y2", 4),
(store_script_param, ":color", 5),
(try_begin),
(eq, ":pos_x1", ":pos_x2"),
(store_sub, ":size", ":pos_y1", ":pos_y2"),
(val_abs, ":size"),
(val_min, ":pos_y1", ":pos_y2"),
(call_script, "script_prsnt_lines", 4, ":size", ":pos_x1", ":pos_y1", ":color"),
(else_try),
(eq, ":pos_y1", ":pos_y2"),
(store_sub, ":size", ":pos_x1", ":pos_x2"),
(val_abs, ":size"),
(val_min, ":pos_x1", ":pos_x2"),
(call_script, "script_prsnt_lines", ":size", 5, ":pos_x1", ":pos_y1", ":color"),
(else_try),
(store_add, ":pos_x", ":pos_x1", ":pos_x2"), (val_div, ":pos_x", 2), (val_sub, ":pos_x", 6),
(call_script, "script_prsnt_lines_to", ":pos_x1", ":pos_y1", ":pos_x", ":pos_y1", ":color"),
(call_script, "script_prsnt_lines_to", ":pos_x", ":pos_y1", ":pos_x", ":pos_y2", ":color"),
(call_script, "script_prsnt_lines_to", ":pos_x", ":pos_y2", ":pos_x2", ":pos_y2", ":color"),
(try_end), ]),
# rubik's CC scripts BEGIN
("prsnt_upgrade_tree_troop_and_name",
[(store_script_param, ":troop_no", 1),
(store_script_param, ":pos_x", 2),
(store_script_param, ":pos_y", 3),
(str_store_troop_name, s1, ":troop_no"),
(create_text_overlay, reg1, "@{s1}", tf_center_justify|tf_vertical_align_center),
(position_set_x, pos1, smaller_size),
(position_set_y, pos1, smaller_size),
(overlay_set_size, reg1, pos1),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg1, pos1),
(val_sub, ":pos_x", 52), # adjusted from 65
#(val_add, ":pos_y", 5), # adjusted from 10
(store_mul, ":cur_troop", ":troop_no", 2), #with weapons
(create_image_button_overlay_with_tableau_material, reg1, -1, "tableau_game_party_window", ":cur_troop"),
(position_set_x, pos1, troop_tree_size_x),
(position_set_y, pos1, troop_tree_size_y),
(overlay_set_size, reg1, pos1),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg1, pos1), ]),
("prsnt_upgrade_tree_troop_cost",
[(store_script_param, ":troop_no", 1),
(store_script_param, ":pos_x", 2),
(store_script_param, ":pos_y", 3),
(call_script, "script_game_get_upgrade_cost", ":troop_no"),
(create_text_overlay, reg1, "@{reg0}", tf_left_align|tf_vertical_align_center),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg1, pos1),
(position_set_x, pos1, smaller_size),
(position_set_y, pos1, smaller_size),
(overlay_set_size, reg1, pos1), ]),
("prsnt_lines",
[(store_script_param, ":size_x", 1),
(store_script_param, ":size_y", 2),
(store_script_param, ":pos_x", 3),
(store_script_param, ":pos_y", 4),
(store_script_param, ":color", 5),
(create_mesh_overlay, reg1, "mesh_white_plane"),
(val_mul, ":size_x", 50),
(val_mul, ":size_y", 50),
(position_set_x, pos0, ":size_x"),
(position_set_y, pos0, ":size_y"),
(overlay_set_size, reg1, pos0),
(position_set_x, pos0, ":pos_x"),
(position_set_y, pos0, ":pos_y"),
(overlay_set_position, reg1, pos0),
(overlay_set_color, reg1, ":color"), ]),
("get_troop_max_hp",
[(store_script_param_1, ":troop"),
(store_skill_level, ":skill", skl_ironflesh, ":troop"),
(store_attribute_level, ":attrib", ":troop", ca_strength),
(val_mul, ":skill", 2),
(val_add, ":skill", ":attrib"),
(val_add, ":skill", 35),
(assign, reg0, ":skill"), ]),
("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), ]),
# rubik's CC scripts END
Code:
("pic_arms_swadian", 0, "pic_arms_swadian", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_arms_vaegir", 0, "pic_arms_vaegir", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_arms_khergit", 0, "pic_arms_khergit", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_arms_nord", 0, "pic_arms_nord", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_arms_rhodok", 0, "pic_arms_rhodok", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_sarranid_arms", 0, "pic_sarranid_arms", 0, 0, 0, 0, 0, 0, 1, 1, 1),
# Dunde's BEGIN
("pic_swad", 0, "pic_swad", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_vaegir", 0, "pic_vaegir", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_khergit", 0, "pic_khergit", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_nord", 0, "pic_nord", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_rhodock", 0, "pic_rhodock", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_sarranid_encounter", 0, "pic_sarranid_encounter", 0, 0, 0, 0, 0, 0, 1, 1, 1),
# Dunde's END
Code:
("faction_troop_tree",[],"View Factions' Troop Tree.",
[(start_presentation, "prsnt_faction_troop_tree"), ]),
Issues :
- The code has not been optimized, even I am not interested in doing it because of this presentation will be called from the report menu where performance is not an issue.
- It has no support yet for troops that can be upgraded from more than 1 troop. (Caba's improved version on page 2 has support for this case).
- Limited Support to max 6 tiers and max 4 branches (visually)
- Limited Support to max 10 tiers and max 10 branches (data structure)
Credits :
- rubik, for the original idea and the script execute the drawing.
Windyplains' modmerger kit (with Caba's modification included) :
http://mountandblade.nexusmods.com/mods/3682
EDIT :
- Adding missing get_troop_max_hp and copy_inventory script and import declaration. Thanks to Dawg of War and Lav for pointing those.
- Diplomacy has CC included, so scripts from CC 's already on the it's Module System, but some of them have dplmc_ prefix.