OSP Code QoL Dynamic Kingdom Troop Tree Presentation

Currently viewing this thread:

xenoargh

Grandmaster Knight
Best answers
0
Sorry Caba, you're right, it does use that operation, it just uses it in a funky way.

What I was thinking was that you'd just write out a script that iterates through every troop and for any of them that tree out, builds the rest of the data and checks for connectivity.

So, you'd go through all of the troops, looking for troop_get_upgrade_troop results other than -1; then you'd check for chaining and find the roots of all the trees.  So instead of a Swadia, you'd have a progression for trp_swadian_peasant --> trp_swadian_knight / trp_swadian_supercrossbowguy or whatever, built on the fly. 

In theory you'd just build that data one time in game_start, since that wouldn't change, but I'm fairly certain that by some straightforward optimizations such as cutting out everybody with -1, -1 results from the chaining analysis it could be made fairly fast and then it'd be nice to keep it live instead of static, so that modders could change data and then see it reflected in testing immediately.  Anyhow, I'll see if I can find some time to look at this when I'm done working on the mod instead of just jabbering about it; I think it'd be a useful piece of utility code :smile:
 

FALX

Master Knight
Best answers
0
Is it possible to get the code under which the tree of the troops will not recruit from the same village, and according to the three types of settlements in a way that would recruit from the village a line of troop tree , from a recruit from the castle - another recruit from the city and the third line of troop  tree ?

1 recruit  village --  swordsman -....
                                            \
2 recruit castle --  mounted  varrior  -.....
                                            /
3 recruit city  --  varrior  -.....
                              \
                            guard 
                         
 

Windyplains

Grandmaster Knight
WB
Best answers
0
With Dunde's permission I repackaged this mod into a modmerger kit and hosted it on the M&B nexus site.

This copy of it includes Caba'drin's modifications as well.
 

eswallie

Veteran
M&BWBWF&S
Best answers
0
Anybody ever get a chance to take  a look at the screen shot, and my upgrade path, to see if they can see what is causing the display to be scrambled like it is?
 

Gurutten

Recruit
Best answers
0
Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Error: Unable to find object:str_faction_troop_tree
ERROR: Illegal Identifier:str_faction_troop_tree
Error: Unable to find object:str_faction_troop_tree
ERROR: Illegal Identifier:str_faction_troop_tree
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
WARNING: Global variable never used: g_dplmc_cam_activated
WARNING: Global variable never used: g_dplmc_charge_when_dead
Imported 22 global variables for saved-game compatability that are not used.
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .





what did I do wrong?
 

Vades

Knight
Best answers
0
Are those strings (str_), in the strings module? The error is coming from your presentations module in regards to those.

Sometimes you will get errors on your fist compile because files update in a certain order. But I'm  sure you tried it a couple times.
 

Gurutten

Recruit
Best answers
0
Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Error: Unable to find object:script_prsnt_culture_troop_tree
ERROR: Illegal Identifier:script_prsnt_culture_troop_tree
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
WARNING: Global variable never used: g_dplmc_cam_activated
WARNING: Global variable never used: g_dplmc_charge_when_dead
Imported 22 global variables for saved-game compatability that are not used.
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .



(((((((((
 

Vades

Knight
Best answers
0
Is the script in module_scripts (prsnt_culture_troop_tree)? It probably isn't and this is what is causing your global variable issue.
 

dunde

Count
WB
Best answers
0
@Gurutten, it seems that you put the scripts at the wrong places at module_scripts.py
Put this line above scripts = [:
Code:
from header_presentations import * # add this at the beggining of module_scripts.py
Then put the rest of scripts before the last ].
Code:
("prsnt_culture_troop_tree",
...
# rubik's CC scripts END 
 

Yldrania

Regular
WBM&BWF&S
Best answers
0
I'm a little bit confused about where to add this last thing: ("faction_troop_tree",[],"View Factions' Troop Tree.",
      [(start_presentation, "prsnt_faction_troop_tree"), ]),

I know this is an old topic, but could anyone help me please?
 

SWAT_1990

Yldrania said:
I'm a little bit confused about where to add this last thing: ("faction_troop_tree",[],"View Factions' Troop Tree.",
      [(start_presentation, "prsnt_faction_troop_tree"), ]),

I know this is an old topic, but could anyone help me please?
[size=10pt]module_game_menus.py (if i'm not wrong it belong there -- i do not read the rest only this question)
If you have merged troop tree with ModSys then it's in tree_game_menus.py
[spoiler="Ex: tree_game_menus.py]
......
........
def modmerge_game_menus(orig_game_menus, check_duplicates = False):
    if( not check_duplicates ):
        orig_game_menus.extend(game_menus) # Use this only if there are no replacements (i.e. no duplicated item names)
    else:
    # Use the following loop to replace existing entries with same id
        for i in range (0,len(game_menus)-1):
          find_index = find_object(orig_game_menus, game_menus[ i ][0]); # find_object is from header_common.py
          if( find_index == -1 ):
            orig_game_menus.append(game_menus[ i ])
          else:
            orig_game_menus[find_index] = game_menus[ i ]
# splice this into report menu to call the mod options presentation
    find_index = find_object(orig_game_menus, "reports")
    orig_game_menus[find_index][5].insert(0,
            ("troop_tree_viewer",[],"View troop trees.", [(start_presentation, "prsnt_faction_troop_tree")]),
          )

 
 
# Used by modmerger framework version >= 200 to merge stuff
......
.......[/spoiler]

Why do you want to do it like this instead of adding the troop tree files and merge them ?!
 

Yldrania

Regular
WBM&BWF&S
Best answers
0
SWAT_1990 said:
Yldrania said:
I'm a little bit confused about where to add this last thing: ("faction_troop_tree",[],"View Factions' Troop Tree.",
      [(start_presentation, "prsnt_faction_troop_tree"), ]),

I know this is an old topic, but could anyone help me please?
[size=10pt]module_game_menus.py (if i'm not wrong it belong there -- i do not read the rest only this question)
If you have merged troop tree with ModSys then it's in tree_game_menus.py
[spoiler="Ex: tree_game_menus.py]
......
........
def modmerge_game_menus(orig_game_menus, check_duplicates = False):
    if( not check_duplicates ):
        orig_game_menus.extend(game_menus) # Use this only if there are no replacements (i.e. no duplicated item names)
    else:
    # Use the following loop to replace existing entries with same id
        for i in range (0,len(game_menus)-1):
          find_index = find_object(orig_game_menus, game_menus[ i ][0]); # find_object is from header_common.py
          if( find_index == -1 ):
            orig_game_menus.append(game_menus[ i ])
          else:
            orig_game_menus[find_index] = game_menus[ i ]
# splice this into report menu to call the mod options presentation
    find_index = find_object(orig_game_menus, "reports")
    orig_game_menus[find_index][5].insert(0,
            ("troop_tree_viewer",[],"View troop trees.", [(start_presentation, "prsnt_faction_troop_tree")]),
          )

 
 
# Used by modmerger framework version >= 200 to merge stuff
......
.......[/spoiler]

Why do you want to do it like this instead of adding the troop tree files and merge them ?!
Just the first way I understood how I should do it ^^ Thanks for that, I'll try to do it that way.
 

Yldrania

Regular
WBM&BWF&S
Best answers
0
I tried it in the one you said it, but it messed up my whole module system. I then downloaded the modmerger kits, and installed that stuff, but after installing it how to I access the troop trees? I might be really newbish, and I'm sorry for that, but I'd rather ask..^^

Or am I doing something wrong? I installed it and added that:

mods_active = [
# insert the active mod names here
#    "trees",

to the modmerger file it named in the readme. Do I have to take the codes I copy pasted before back out? Or what am I missing? Do I have to add more directories? If yes, where?
 

SWAT_1990

Yldrania said:
I tried it in the one you said it, but it messed up my whole module system. I then downloaded the modmerger kits, and installed that stuff, but after installing it how to I access the troop trees? I might be really newbish, and I'm sorry for that, but I'd rather ask..^^

Or am I doing something wrong? I installed it and added that:

mods_active = [
# insert the active mod names here
#    "trees",

to the modmerger file it named in the readme. Do I have to take the codes I copy pasted before back out? Or what am I missing? Do I have to add more directories? If yes, where?
Ok, here we are.We take native as working space! I take ModSys 1.153 and i start: copy the code lines from the first page and i create the following .py files: trooptrees_scripts.py | trooptrees_strings.py | trooptrees_constants.py | trooptrees_game_menus.py | trooptrees_meshes.py | trooptrees_presentations.py -- Here we have create 6 new .py files.Add ModMerger files into ModSys and then go to modmerger_option.py and i will add:
mods_active = [
# insert the active mod names here
    "trooptrees", # <-- The files we create are named ' trooptrees_lalalaExample ' so i add the "trooptrees" of the files we created right ?!
#    "mymod",
#    "anothermod",
]
and cancel
module_sys_info = {
#        "engine" : "warband", # only "warband" or "vanilla" for now. (unused)
        "version": 1153,      # version number * 1000
}
It's so mutch to tell about -- if you don't understand to well how to merge files it's hard to do it you known...
So far it's ok now let's try to make it work ok Yldrania ?
Copy - paste from here:
trooptrees_constants.py
# Dynamic Troop Trees by Dunde, modified by Caba'drin.

# 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

trooptrees_game_menus.py
# Dynamic Troop Trees by Dunde, modified by Caba'drin.

from header_game_menus import *
from header_parties import *
from header_items import *
from header_mission_templates import *
from header_music import *
from header_terrain_types import *

from module_constants import *


game_menus = [

]


def modmerge_game_menus(orig_game_menus, check_duplicates = False):
    if( not check_duplicates ):
        orig_game_menus.extend(game_menus) # Use this only if there are no replacements (i.e. no duplicated item names)
    else:
    # Use the following loop to replace existing entries with same id
        for i in range (0,len(game_menus)-1):
          find_index = find_object(orig_game_menus, game_menus[0]); # Yldrania copy game_menus[ i ][0]); without space betwen brackets and the letter i because he sees the text leaning if i leave it so.
          if( find_index == -1 ):
            orig_game_menus.append(game_menus)
          else:
            orig_game_menus[find_index] = game_menus
# splice this into report menu to call the mod options presentation
    find_index = find_object(orig_game_menus, "reports")
    orig_game_menus[find_index][5].insert(0,
            ("troop_tree_viewer",[],"View troop trees.", [(start_presentation, "prsnt_faction_troop_tree")]),
          )

 
 
# Used by modmerger framework version >= 200 to merge stuff
def modmerge(var_set):
    try:
        var_name_1 = "game_menus"
        orig_game_menus = var_set[var_name_1]
        modmerge_game_menus(orig_game_menus)
    except KeyError:
        errstring = "Variable set does not contain expected variable: \"%s\"." % var_name_1
        raise ValueError(errstring)


trooptrees_meshes.py
# Dynamic Troop Trees by Dunde, modified by Caba'drin.

from header_meshes import *

meshes = [
  ("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

]

from util_common import *

def modmerge_meshes(orig_meshes):
    # add remaining meshes
    from util_common import add_objects
    num_appended, num_replaced, num_ignored = add_objects(orig_meshes, meshes)
    #print num_appended, num_replaced, num_ignored


# Used by modmerger framework version >= 200 to merge stuff
# This function will be looked for and called by modmerger if this mod is active
# Do not rename the function, though you can insert your own merging calls where indicated
def modmerge(var_set):
    try:
        var_name_1 = "meshes"
        orig_meshes = var_set[var_name_1]
        modmerge_meshes(orig_meshes)
    except KeyError:
        errstring = "Variable set does not contain expected variable: \"%s\"." % var_name_1
        raise ValueError(errstring)

trooptrees_presentations.py
# Dynamic Troop Trees by Dunde, modified by Caba'drin.

from header_common import *
from header_presentations import *
from header_mission_templates import *
from ID_meshes import *
from header_operations import *
from header_triggers import *
from module_constants import *
# from header_items import *  # Added for Show all Items presentation.
# from module_items import *  # Added for Show all Items presentation.
from header_skills import *

import string


presentations = [

("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, ":eek:bject"),
  (store_trigger_param_2, ":value"),
  (set_fixed_point_multiplier, 1000),
  (try_begin),
    (eq, ":eek:bject", "$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", ":eek:bject"),
        (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, ":eek:bject"),
      (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", ":eek:bject"),
          (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", ":eek:bject"),
          (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, ":eek:bject"),

        (try_begin),
          (eq, ":eek:bject", "$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

]

def modmerge_presentations(orig_presentations, check_duplicates = False):
    if( not check_duplicates ):
        orig_presentations.extend(presentations) # Use this only if there are no replacements (i.e. no duplicated item names)
    else:
    # Use the following loop to replace existing entries with same id
        for i in range (0,len(presentations)-1):
          find_index = find_object(orig_presentations, presentations[0]); # # Yldrania copy presentations[ i ][0]); without space betwen brackets and the letter i because he sees the text leaning if i leave it so.
            orig_presentations.append(presentations) # Yldrania copy (presentations[ i ]) without space betwen brackets and the letter i because he sees the text leaning if i leave it so.
          else:
            orig_presentations[find_index] = presentations # Yldrania copy presentations[ i ] without space betwen brackets and the letter i because he sees the text leaning if i leave it so.

# Used by modmerger framework version >= 200 to merge stuff
def modmerge(var_set):
    try:
        var_name_1 = "presentations"
        orig_presentations = var_set[var_name_1]
        modmerge_presentations(orig_presentations)
    except KeyError:
        errstring = "Variable set does not contain expected variable: \"%s\"." % var_name_1
        raise ValueError(errstring)


trooptrees_scripts.py
# Dynamic Troop Trees by Dunde, modified by Caba'drin.

from header_common import *
from header_operations import *
from module_constants import *
from header_mission_templates import *
from header_items import *
from header_presentations import *
from header_skills import *


scripts = [

("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", ":slot", 100), #Caba - was missing ":slot"
    (troop_set_slot, "trp_temp_array_b", ":num", -1),
    (troop_set_slot, "trp_temp_array_c", ":num", -1),
  (try_end),
  #try-else block here to get 'troop-no' (or above) for non-kingdom trees
  (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),
  ## Calculates number of tiers--":max_tiers" and number of branches (more or less)
  (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),
        #Caba - check for duplication
        (assign, ":end", ":tree_no"),
        (try_for_range, ":i", 1, ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
            (store_add, ":eek:ther_prev_slot", ":i", ":slot_for_prev_num"),
            (neq, ":prev_slot", ":eek:ther_prev_slot"), #just to be sure
            (troop_slot_eq, "trp_temp_array_b", ":eek:ther_prev_slot", ":troop_no"),
            (assign, ":end", 0), #break loop, found in checked list
        (try_end),
        (neq, ":end", 0),
        #Caba - end
        (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),
  #Calculate Y Position of last tier's branches? ???
  (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),
  #Calculate Troop Y positions
  (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"),
          #Caba - check for duplication - loop over past troops rather than using a troop slot (change?)
          (troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot"),
          (assign, ":end", ":slot"),
          (try_for_range, ":i", 0, ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
                (neq, ":i", ":slot"), #just to be sure
                (troop_slot_eq, "trp_temp_array_b", ":i", ":troop_no"),
                (assign, ":end", 0), #break loop, found in checked list
          (try_end),
          (neq, ":end", 0),
          #Caba - end
          (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),
  #Draw Troops, Titles - Calcuate X and position of Connecting Lines
  (try_for_range, ":slot", 0,  ":max_num_tier"),
    (troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot"),
    (gt, ":troop_no", 0),
    #Caba - check for duplication - loop over past troops rather than using a troop slot (change?)
    (assign, ":end", ":slot"),
    (try_for_range, ":i", 0, ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
        (neq, ":i", ":slot"), #just to be sure
        (troop_slot_eq, "trp_temp_array_b", ":i", ":troop_no"),
        (assign, ":end", 0), #break loop, found in checked list
    (try_end),
    (neq, ":end", 0),
    #Caba - end
    (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),
    ## Draw lines to next troops, if found
    (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"),
        #Caba - check for duplication - loop over past troops rather than using a troop slot (change?)
        (troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot2"),
        (assign, ":end", ":slot2"),
        (try_for_range, ":i", ":cur_slot1", ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
            (neq, ":i", ":cur_slot1"), #just to be sure           
            (troop_slot_eq,  "trp_temp_array_b", ":i", ":troop_no"),
            (assign, ":posy_to_use", ":i"),
            (assign, ":end", 0), #break loop, found in checked list
        (try_end),
        (try_begin),
            (neq, ":end", 0),
            (assign, ":posy_to_use", ":slot2"),
        (try_end),
        #Caba - end
        (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", ":posy_to_use"), #caba ":slot2"),
        (store_add, ":posy1", ":posy", troop_tree_space_y/2),
        (val_add, ":posy2", troop_tree_space_y/2),
        #Caba
        (try_begin),
            (neq, ":end", 0),
        #Caba - end
            (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"),
        #Caba 
        (else_try),
            (val_sub, ":posy2", 20),
            (store_sub, ":posx3", ":posx2", 20),
            (call_script, "script_prsnt_lines_to", ":posx", ":posy1", ":posx3", ":posy2", title_black),
            (call_script, "script_prsnt_lines_to", ":posx3", ":posy2", ":posx2", ":posy2", title_black),
        (try_end),
        #Caba - end
    (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 
]


from util_wrappers import *
from util_scripts import *

               
def modmerge_scripts(orig_scripts):
# process script directives first
# process_script_directives(orig_scripts, scripts_directives)
# add remaining scripts
add_scripts(orig_scripts, scripts, True)

# Used by modmerger framework version >= 200 to merge stuff
# This function will be looked for and called by modmerger if this mod is active
# Do not rename the function, though you can insert your own merging calls where indicated
def modmerge(var_set):
    try:
        var_name_1 = "scripts"
        orig_scripts = var_set[var_name_1]
   
       
# START do your own stuff to do merging

        modmerge_scripts(orig_scripts)

# END do your own stuff
       
    except KeyError:
        errstring = "Variable set does not contain expected variable: \"%s\"." % var_name_1
        raise ValueError(errstring)

trooptrees_strings.py
# Dynamic Troop Trees by Dunde, modified by Caba'drin.

strings = [

("faction_troop_tree", "Faction's Troop Tree"),

]

from util_common import *

def modmerge_strings(orig_strings):
    # add remaining strings
    from util_common import add_objects
    num_appended, num_replaced, num_ignored = add_objects(orig_strings, strings)
    #print num_appended, num_replaced, num_ignored


# Used by modmerger framework version >= 200 to merge stuff
# This function will be looked for and called by modmerger if this mod is active
# Do not rename the function, though you can insert your own merging calls where indicated
def modmerge(var_set):
    try:
        var_name_1 = "strings"
        orig_strings = var_set[var_name_1]
        modmerge_strings(orig_strings)
    except KeyError:
        errstring = "Variable set does not contain expected variable: \"%s\"." % var_name_1
        raise ValueError(errstring)

NOW you can install ModMerger and you are ready to go.
This is an example with Native troops Yldrania and if you have more factions and troops then you must edit trooptree files and add them. Sorry if I am wrong somewhere !
Author/s have total credit for this i just give an example!

For me it works perfectly with no errors !
FOR Yldrania !
 

Arven2802

Recruit
Best answers
0
Hello, I am having an error somewhere.
This is the log:
Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Error: Unable to find object:str_faction_troop_tree
ERROR: Illegal Identifier:str_faction_troop_tree
Error: Unable to find object:str_faction_troop_tree
ERROR: Illegal Identifier:str_faction_troop_tree
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
WARNING: Global variable never used: battle_won
WARNING: Global variable never used: g_presentation_battle_active
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .

What am I doing wrong?
 

dunde

Count
WB
Best answers
0
Arven2802 said:
Hello, I am having an error somewhere.
This is the log:
ERROR: Illegal Identifier:str_faction_troop_tree
Error: Unable to find object:str_faction_troop_tree
ERROR: Illegal Identifier:str_faction_troop_tree
What am I doing wrong?
You forgot to add 1 line code to module_strings.py that introduce str_faction_troop_tree.
 

Janycz

Knight at Arms
WB
Best answers
0
I adapted this for mod "Rus 13th century".

Code:
#input: faction_no
("prsnt_culture_troop_tree",
 [
  (store_script_param_1, ":faction_no"),
  # (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", ":faction_no", 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),
		
		#Caba - check for duplication
        (assign, ":end", ":tree_no"),
        (try_for_range, ":i", 1, ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
            (store_add, ":other_prev_slot", ":i", ":slot_for_prev_num"),
            (neq, ":prev_slot", ":other_prev_slot"), #just to be sure
            (troop_slot_eq, "trp_temp_array_b", ":other_prev_slot", ":troop_no"),
            (assign, ":end", 0), #break loop, found in checked list
        (try_end),
        (neq, ":end", 0),
        #Caba - end
		
#rusmod begin
		(troop_get_slot, ":type", ":troop_no", slot_troop_upgrade_1),
		
		(try_begin),
		  (gt, ":type", 0),
		  #first castle (rusmod)
		  (troop_get_slot, ":next_troop", ":troop_no", slot_troop_upgrade_1),
          (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"),
		
		  #second castle (rusmod)
		  (troop_get_slot, ":next_troop", ":troop_no", slot_troop_upgrade_2),
          (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"),
		  
		  #third castle (rusmod)
		  (troop_get_slot, ":next_troop", ":troop_no", slot_troop_upgrade_3),
          (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"),
		(else_try),
		  (le, ":type", 0),
		  #first standart
          (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"),
		
		  #second standart
          (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),
#rusmod end		
     (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),
  #Calculate Y Position of last tier's branches? ???
  (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),
  #Calculate Troop Y positions
  (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"),
           #Caba - check for duplication - loop over past troops rather than using a troop slot (change?)
           (troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot"),
           (assign, ":end", ":slot"),
           (try_for_range, ":i", 0, ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
                (neq, ":i", ":slot"), #just to be sure
                (troop_slot_eq, "trp_temp_array_b", ":i", ":troop_no"),
                (assign, ":end", 0), #break loop, found in checked list
           (try_end),
           (neq, ":end", 0),
           #Caba - end
           (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),
  #Draw Troops, Titles - Calcuate X and position of Connecting Lines
  (try_for_range, ":slot", 0,  ":max_num_tier"),
     (troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot"),
     (gt, ":troop_no", 0),
     #Caba - check for duplication - loop over past troops rather than using a troop slot (change?)
     (assign, ":end", ":slot"),
     (try_for_range, ":i", 0, ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
        (neq, ":i", ":slot"), #just to be sure
        (troop_slot_eq, "trp_temp_array_b", ":i", ":troop_no"),
        (assign, ":end", 0), #break loop, found in checked list
     (try_end),
     (neq, ":end", 0),
     #Caba - end
     (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),
     ## Draw lines to next troops, if found
     (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"),
        #Caba - check for duplication - loop over past troops rather than using a troop slot (change?)
        (troop_get_slot, ":troop_no", "trp_temp_array_b", ":slot2"),
        (assign, ":end", ":slot2"),
        (try_for_range, ":i", ":cur_slot1", ":end"), #check troops of this prev_tier previously looped over, be sure this troop hasn't been checked
            (neq, ":i", ":cur_slot1"), #just to be sure            
            (troop_slot_eq,  "trp_temp_array_b", ":i", ":troop_no"),
            (assign, ":posy_to_use", ":i"),
            (assign, ":end", 0), #break loop, found in checked list
        (try_end),
        (try_begin),
            (neq, ":end", 0),
            (assign, ":posy_to_use", ":slot2"),
        (try_end),
        #Caba - end
        (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", ":posy_to_use"), #caba ":slot2"),
        (store_add, ":posy1", ":posy", troop_tree_space_y/2),
        (val_add, ":posy2", troop_tree_space_y/2),
        #Caba
        (try_begin),
            (neq, ":end", 0),
        #Caba - end
            (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"),
        #Caba  
        (else_try),
            (val_sub, ":posy2", 20),
            (store_sub, ":posx3", ":posx2", 20),
            (call_script, "script_prsnt_lines_to", ":posx", ":posy1", ":posx3", ":posy2", title_black),
            (call_script, "script_prsnt_lines_to", ":posx3", ":posy2", ":posx2", ":posy2", title_black),
        (try_end),
        #Caba - end
     (try_end),     
  (try_end),
  (troop_set_slot, "trp_temp_array_c", 100, ":num"),  ]),
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),
   
   ## back Button added by eswallie
   (create_game_button_overlay, "$g_presentation_obj_2", "@Done"),
   (position_set_x, pos1, 900),
   (position_set_y, pos1, 25),
   (overlay_set_position, "$g_presentation_obj_2", pos1),
   ## Back button added by eswallie
   
   # Objects
#rusmod begin
   (assign, ":hi_faction", "fac_troop_tree_end"),
   (assign, ":lo_faction", "fac_rus_vil"),
   (try_for_range, ":faction", ":lo_faction", ":hi_faction"),
      (str_store_faction_name, s1, ":faction"),
      (overlay_add_item,  "$g_presentation_obj_1", s1),
   (try_end),
#rusmod 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", "$faction_display"), ]),
 (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), 
   
   ## Back button code added by eswallie
   (try_begin),
     (eq, ":object", "$g_presentation_obj_2"),
     (presentation_set_duration, 0),
   (try_end), 
   ## Back button code added by eswallie
   
 ]), 
   ## 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), ]), ]),
Code:
  ("rus_vil",  "Ruthenia Kioviensis (village)", 0, 0.5, [], []),
  ("rus_town_n",  "Ruthenia Kioviensis (north town)", 0, 0.5, [], []),
  ("rus_town_s",  "Ruthenia Kioviensis (south town)", 0, 0.5, [], []),
  ("rus_castle",  "Ruthenia Kioviensis (young druzhina)", 0, 0.5, [], []),
  ("rus_elite",  "Ruthenia Kioviensis (old druzhina)", 0, 0.5, [], []),
  ("mon_vil",  "Altan Ordyn Uls (village)", 0, 0.5, [], []),
  ("mon_town",  "Altan Ordyn Uls (town)", 0, 0.5, [], []),
  ("mon_castle",  "Altan Ordyn Uls (castle)", 0, 0.5, [], []),
  ("mon_elite",  "Altan Ordyn Uls (elite)", 0, 0.5, [], []),
  ("pl_vil",  "Regnum Poloniae (village)", 0, 0.5, [], []),
  ("pl_town",  "Regnum Poloniae (town)", 0, 0.5, [], []),
  ("pl_castle",  "Regnum Poloniae (castle)", 0, 0.5, [], []),
  ("pl_elite",  "Regnum Poloniae (elite)", 0, 0.5, [], []),
  ("teu_village",  "Ordo Teutonicus (village)", 0, 0.5, [], []),
  ("teu_town",  "Ordo Teutonicus (town)", 0, 0.5, [], []),
  ("teu_castle",  "Ordo Teutonicus (castle)", 0, 0.5, [], []),
  ("teu_elite",  "Ordo Teutonicus (elite)", 0, 0.5, [], []),
  ("troop_tree_end",  "troop_tree_end", 0, 0.5, [], []),

In fact, I just changed the algorithm for finding a soldier modernization.
But the presentation of working with bugs for the Polish town.


                                                        Tarczownic
                                                                |
                                    ----------------------------------------------
                                    |                                                      |
                                Piechur                                    Piechur Strzelczy
                                    |                                                      |
                            = Piechur =                        Piechur Strzelczy Ciezkozbrojny
                                    |                                                      |
                  -------------------------------          = Piechur Strzelczy Ciezkozbrojny =
                  |                                    |                                  |
      Piechur Ciezkozbrojny      Lekki jezdziec              ------------------
                                                        |                        |                    |
                                            = Lekki Jezdziec =      Kusznik    Konny Kusznik
                                                        |
                                              Ciezki Jezdziec 



 

Marko͘

Section Moderator
WBNWM&BWF&SVC
Best answers
3
I copied everything from the OP, except the script bit which I took from Caba'drin's post(the EDIT2) bit.

It gives me from exporting presentations

ERROR: unable to find object: script_copy_inventory
Error: Illegal identifier: script_copy_inventory
ERROR: unable to find object: script_get_troop_max_hp
Error: Illegal identifier: get_troop_max_hp
from exporting scripts

ERROR: unable to find object: script_prsnt_upgrade_tree_troop_and_name
Error: Illegal identifier: script_prsnt_upgrade_tree_troop_and_name
ERROR: unable to find object: script_prsnt_lines_to
Error: Illegal identifier: script_prsnt_lines_to
ERROR: unable to find object: script_prsnt_upgrade_tree_troop_cost
Error: Illegal identifier: script_prsnt_upgrade_tree_troop_cost
A quick Ctrl-F for me noticed that in the new caba'drin's code the script copy inventory isn't referenced, and the other errors I have no idea what to do. Anyone got a helping hand?