OSP Kit SP Top-Tier-Troop-to-Hero Script (Fully working but still needs a few tweaks)

Users who are viewing this thread

Nothing wrong with the menu. The error is at module_simple_triggers.py. May be you lost comma or something.
Calling the menu is free for any menu or script. In this case, we use to update the list. Only 4 heroes listed on the menu once. If there are more than 4 upgrade posibility, than prev and next menu are used to scroll the list.
 
Ok. But I'll post the trigger that I have and I'll let you take a look at it. It's the same that you have thou.

Code:
  (24,
   [
      #################################################################
      ## LEVEL CHECK BEGIN
      ## Comment to disable LEVEL CHECK
      (store_character_level, ":level", "trp_player"),   
      (ge, ":level", 15),
      ## LEVEL CHECK END
      #################################################################
      (store_current_hours,":now"), 
      (ge, ":now", "$g_upgrade_time"),
      (store_random_in_range, ":rand", 14, 22),         ## Next Call 14 - 21 days ahead   
      (val_mul, ":rand", 24),
      (val_add, ":rand", ":now"),
      (assign, "$g_upgrade_time"),
      (assign, reg10, additional_heroes_begin),
      (jump_to_menu, "mnu_upgrade_to_hero"),
    ]), 
 
"'tuple' object is not callable" error on line 2639 means that:
                                          a) On line 2638, you forgot a comma
                                          b) On the previous tuple (= menu, simple trigger, whatever) there is no comma at the end
 
Hmm. I can't get it right it seems.

This is the trigger that I have in module_simple_triggers.py in the end before the last ]
The trigger is copied it from my module directly. This is most definitely the most awkward error I've encountered in my time. I don't see why it won't work. As I see it, no comma is missing. Do you see anything wrong in the trigger down below?


Code:
  (24,
   [
      #################################################################
      ## LEVEL CHECK BEGIN
      ## Comment to disable LEVEL CHECK
      (store_character_level, ":level", "trp_player"),   
      (ge, ":level", 15),
      ## LEVEL CHECK END
      #################################################################
      (store_current_hours,":now"), 
      (ge, ":now", "$g_upgrade_time"),
      (store_random_in_range, ":rand", 14, 22),         ## Next Call 14 - 21 days ahead   
      (val_mul, ":rand", 24),
      (val_add, ":rand", ":now"),
      (assign, "$g_upgrade_time"),
      (assign, reg10, additional_heroes_begin),
      (jump_to_menu, "mnu_upgrade_to_hero"),
    ]),

I've tried to do compile it like this:

      (assign, reg10, additional_heroes_begin),
      (jump_to_menu, "mnu_upgrade_to_hero"),
    ])

And like this:

      (assign, reg10, additional_heroes_begin),
      (jump_to_menu, "mnu_upgrade_to_hero"),
    ]),

But the problem remains.
 
This was the last trigger of native module system. You had pasted our new trigger below this one so this trigger  is not the last anymore so you should give the comma (I bold) so you will get no error)
(4,
  [(try_for_range, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end),
      (troop_slot_ge, ":troop_no", slot_troop_change_to_faction, 1),
      (store_troop_faction, ":faction_no", ":troop_no"),
      (troop_get_slot, ":new_faction_no", ":troop_no", slot_troop_change_to_faction),
      (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
      (assign, ":continue", 0),
      (try_begin),
        (le, ":party_no", 0),
        #(troop_slot_eq, ":troop_no", slot_troop_is_prisoner, 0),
        (neg|troop_slot_ge, ":troop_no", slot_troop_prisoner_of_party, 0),
        (assign, ":continue", 1),
      (else_try),
        (gt, ":party_no", 0),

        #checking if the party is outside the centers
        (party_get_attached_to, ":cur_center_no", ":party_no"),
        (try_begin),
          (lt, ":cur_center_no", 0),
          (party_get_cur_town, ":cur_center_no", ":party_no"),
        (try_end),
        (this_or_next|neg|is_between, ":cur_center_no", centers_begin, centers_end),
        (party_slot_eq, ":cur_center_no", slot_town_lord, ":troop_no"),
   
        #checking if the party is away from his original faction parties
        (assign, ":end_cond", kingdom_heroes_end),
        (try_for_range, ":enemy_troop_no", kingdom_heroes_begin, ":end_cond"),
          (troop_get_slot, ":enemy_party_no", ":enemy_troop_no", slot_troop_leaded_party),
          (gt, ":enemy_party_no", 0),
          (store_faction_of_party, ":enemy_faction_no", ":enemy_party_no"),
          (eq, ":enemy_faction_no", ":faction_no"),
          (store_distance_to_party_from_party, ":dist", ":party_no", ":enemy_party_no"),
          (lt, ":dist", 4),
          (assign, ":end_cond", 0),
        (try_end),
        (neq, ":end_cond", 0),
        (assign, ":continue", 1),
      (try_end),
      (eq, ":continue", 1),
      (call_script, "script_change_troop_faction", ":troop_no", ":new_faction_no"),
      (troop_set_slot, ":troop_no", slot_troop_change_to_faction, 0),
      (try_begin),
        (is_between, ":new_faction_no", kingdoms_begin, kingdoms_end),
        (str_store_troop_name_link, s1, ":troop_no"),
        (str_store_faction_name_link, s2, ":faction_no"),
        (str_store_faction_name_link, s3, ":new_faction_no"),
        (display_message, "@{s1} has switched from {s2} to {s3}."),
        (try_begin),
          (eq, ":faction_no", "$players_kingdom"),
          (call_script, "script_add_notification_menu", "mnu_notification_troop_left_players_faction", ":troop_no", ":new_faction_no"),
        (else_try),
          (eq, ":new_faction_no", "$players_kingdom"),
          (call_script, "script_add_notification_menu", "mnu_notification_troop_joined_players_faction", ":troop_no", ":faction_no"),
        (try_end),
      (try_end),
    (try_end),
    ]),
 
Aach! Ofcourse  :wink:

Tried it out and it compiled perfectly. I'll test it and see how it works.


EDIT:

There's always something, right?  :???:
The game doesn't seem to start properly.

"Loading Map"
"Initializing Map"
"Launching Game"
*Crash*

Could it have something to do with the game_start script?

EDIT 2:
Nope! I commented out the whole thing in the game_start script but it still crashed.
Weird to say the least. Any ideas? If you manage to get the module that you have up for download, I could take a look at it just to make sure that I've done everything correct.
 
just make sure that you had copied all files, including the subfolders from modules\native folder to the target folder of new module of module_info.py, and try to compile again.
 
The files are compiled again, and the map is correct.

export_dir = "C:/Program/Mount&Blade/Modules/Copy of Native/ModuleSystem/Pyfiles"


The thing is that it compiles just fine, but I cant play. When I move over the compiled files, I can't start a new game due to the crash.
It worked before inserted the code  :???:
But you may call me a noob and throw some pie at me :grin:




It would be good if we could get someone else to try this code out. I'm starting to think that I'm losing it, cus I've never had this much fuzz with implementing a code.
I'm not saying that there is something wrong with it, just that I can't seem to get it right and it frustrates me, alot.


But if someone else would like to try the code out, go ahead. It might just confirm my theories :grin:
 
Ok, let's do step by step :
1. Copy your  C:\Program\Mount&Blade\Modules\Native to C:\Program\Mount&Blade\Modules\Copy of Native
2. Go to your edited module system, open module_info.py, and set :
export_dir = "C:/Program/Mount&Blade/Modules/Copy of Native/"

3. Compile the edited module system

4. Play the game, select 'copy of Native' module
 
I think I know what the problem is now. It seems like it wasn't a clean copy *duh*
But the original native wouldn't start either, so I don't think it's because you scripts :grin:
So no I've re-downloaded the ModSys and will try again.


I'll give it a shot when I come home from work. Gotta rush now or my boss will have my head on a plate.
 
I know... Dubbel posting!

However, I tried it out now and the problem was that my native module was totally screwed up. But it works fine.
Now the user just needs to adjust the heroes to be more "Faction like" since they all look like Borcha  :grin:


Some minor spelling errors and double-words.


EDIT:

Oh yeah!
When you talk to one of the new heroes there is a small bug. The bug is that when you talk to him via the party menu he says. Yes, NO STRING!
Is that fixable?

And the last thing. I've forgotten how to make the heroes killable (mortal). Do I have to remove the tf_hero flag or the unmoveable_in_party_window?
 
Oops, I haven't made dialog links for new heroes yet.
And I found more bug. When we talk to the top tier troop to upgrade them, his face is so ugly.
Making them killable is a little complicated because they re tf_hero flagged. We must remove them from the party via script when they re down in battle, reseting their stats and set their occupation back to top tier troop id to make them available again as ugrading hero target.
I'll fix them soon.
 
dunde said:
Oops, I haven't made dialog links for new heroes yet.
And I found more bug. When we talk to the top tier troop to upgrade them, his face is so ugly.
I'll fix them soon.

Hahaha...
He sure is. I saw it but didn't put so much thought to it. I'm going to see if I can correct some of the spelling errors and then post the dialogue and menu.
 
Here are the corrected/ updated menus and dialogues:

game_menus.py:

Code:
  ("upgrade_to_hero",0,
   "You notice that one or more of your warriors exceeds your expectations in battle. ^You walk towards the lines of your troops, and ...",
   "none",
   [
       (assign, reg11, 0), # sub menu 1
       (assign, reg12, 0), # sub menu 2
       (assign, reg13, 0), # sub menu 3
       (assign, reg14, 0), # sub menu 4
       (assign, "$g_upgrade_talk", 0),
     ],
    [
      ("hero_1",
      [         
         (assign, ":limit", reg10),
         (assign, ":found", 0),
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg11, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg11),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg11),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("hero_2",
      [         
         (ge, reg11, reg10),
         (store_add, ":limit", reg11, 1),
         (assign, ":found", 0),         
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg12, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg12),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg12),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("hero_3",
      [         
         (gt, reg12, reg11),
         (store_add, ":limit", reg12, 1),
         (assign, ":found", 0),         
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg13, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg13),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg13),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("hero_4",
      [         
         (gt, reg13, reg12),
         (store_add, ":limit", reg13, 1),
         (assign, ":found", 0),         
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),         
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg14, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg14),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg14),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("prev",
      [
          (gt, reg10, additional_heroes_begin),
          (assign, ":limit", reg10),
          (assign, ":found", 0),         
          (try_for_range_backwards, ":hero_id", ":limit", additional_heroes_begin),
             (lt, ":found", 4),         
             (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
             (gt, ":hero_ocu", 0),
             (neq, ":hero_ocu",slto_kingdom_hero),
             (neq, ":hero_ocu",slto_player_companion),
             (main_party_has_troop, ":hero_ocu"),
             (assign, reg15, ":hero_id"),
             (val_add, ":found", 1),
         (try_end),
         (gt, ":found", 0),         
      ],"go to the previous lines",
       [
          (assign, reg10, reg15),
          (jump_to_menu, "mnu_upgrade_to_hero"),
        ]
       ),
      ("next",
      [
          (gt, reg14, reg13),
          (store_add, ":limit", reg14, 1),
          (assign, ":found", 0),         
          (try_for_range, ":hero_id", ":limit", additional_heroes_end),
             (eq, ":found", 0),         
             (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
             (gt, ":hero_ocu", 0),
             (neq, ":hero_ocu",slto_kingdom_hero),
             (neq, ":hero_ocu",slto_player_companion),
             (main_party_has_troop, ":hero_ocu"),
             (assign, ":found", 1),
         (try_end),
         (eq, ":found", 1),         
      ],"go to the next lines",
       [
           (store_add, reg10, reg14, 1),
           (jump_to_menu, "mnu_upgrade_to_hero"),
        ]
       ),
      ("close",
      [
       ],"close",
       [
          (assign, "$g_upgrade_talk", 1),
          (change_screen_map),
       ]
      ),
    ] 
  ),

dilagoues.py:

Code:
   [anyone,
      "event_triggered",
      [
         (store_conversation_troop,"$g_talk_troop"),
         #(is_between,"$g_talk_troop", additional_heroes_begin, additional_heroes_end),
                        (eq, "$g_talk_troop", reg20),
         (eq, "$g_upgrade_talk", 1),
                        (troop_get_type, reg65, "trp_player"),
                        (str_store_string,s65,"@{reg65?my Lady:my Lord}"),
                        (str_store_troop_name,s21,reg21),
      ],
      "Yes, {s65}?",
      "upgrade_talk",
      []
   ],
       [anyone|plyr,
      "upgrade_talk",
      [],
      "I have seen you fight well in battles, soldier.",
      "upgrade_talk_1",
      []
   ],
        [anyone,
      "upgrade_talk_1",
      [
      ],
      "I only do my duty to {s65}, sire.",
      "upgrade_talk_2",
      []
         ],
         [anyone|plyr,
      "upgrade_talk_2",
      [],
      "And well, too. The only time I've heard someone with such skills in battle, it has been in sagas. You are a hero!",
      "upgrade_talk_3a",
      []
         ],         
         [anyone|plyr,
      "upgrade_talk_2",
      [],
      "I just wanted you to know that I take notice in such skills in battle. Now fall back in line!",
      "upgrade_talk_3b",
      []
         ],
   [anyone,
      "upgrade_talk_3a",
      [
      ],
      "You honour me with your words. I will do my utter best to honour them.",
      "upgrade_talk_4a",
      []
         ],
         [anyone|plyr,
      "upgrade_talk_4a",
      [],
      "From now on you shall be remembered as a {s21}",
      "upgrade_talk_5",
      []
         ],
   [anyone,
      "upgrade_talk_5",
      [
                    (call_script,"script_upgrade_troop_to_hero", reg20, reg21),
      ],
      "I will defend my new title to my death, and I will not let you down. I promise you this; The blood on my steel will never dry!",
      "close_window",
      []
         ],         
   [anyone,
      "upgrade_talk_3b",
      [
      ],
      "Yes, {s65}",
      "close_window",
      []
   ],
 
dunde said:
I write this code on my work place with notepad, no module system and MnB to check. So please anybody help me to debug.


First, define 10 new heroes on module_troops.py , put between "merchant20" and #Seneschals :
Code:
##  ["merchant_20","merchant_20_F","merchant_20_F",tf_hero|tf_female, 0,0, fac_merchants,[itm_courser,            itm_arming_sword,       itm_padded_leather,         itm_leather_boots,                          ],              def_attrib|level(15),wp(100),knows_inventory_management_10, 0x000000000010500401f6837d27688212],


###########################################################################
  ["hero1","Swadian Warrior","Swadian Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero2","Vaegir Warrior","Vaegir Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero3","Kerghit Warrior","Kerghit Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero4","Nord Warrior","Nord Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero5","Rodhok Warrior","Rodhok Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero6","Swadian Patriot","Swadian Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero7","Vaegir Patriot","Vaegir Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero8","Kerghit Patriot","Kerghit Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero9","Nord Patriot","Nord Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
  ["hero10","Rodhok Patriot","Rodhok Warriors",tf_hero|tf_unmoveable_in_party_window, 0, reserved, fac_commoners,[itm_khergit_armor,itm_nomad_boots,itm_knife],
   str_8|agi_7|int_12|cha_7|level(3),wp(60),knows_tracker_npc|
   knows_ironflesh_1|knows_power_strike_1|knows_pathfinding_3|knows_athletics_2|knows_tracking_1|knows_riding_2, #skills 2/3 player at that level
   0x00000004bf086143259d061a9046e23500000000001db52c0000000000000000],
###########################################################################
  
#Seneschals
I only copy "trp_npc1" form native. Please feel free to modify the stats and rename them, and it will be better if hero1 and hero6 are given swadian face,
hero2 and hero7 are vaegir faces, etc.

Define new constants on module_constants.py :
Code:
additional_heroes_begin = "trp_hero1"
additional_heroes_end = "trp_town_1_seneschal"

module_scripts.py's change :
Add these lines on "game_start" script :
Code:
  ("game_start",
   [
      ##################################################################
     (troop_set_slot,"trp_hero1", slot_troop_occupation, "trp_swadian_knight"),   # Hero1's occupation before upgraded is Swadian Knight
     (troop_set_slot,"trp_hero2", slot_troop_occupation, "trp_vaegir_knight"),    
     (troop_set_slot,"trp_hero3", slot_troop_occupation, "trp_khergit_lancer"),
     (troop_set_slot,"trp_hero4", slot_troop_occupation, "trp_nord_champion"),    
     (troop_set_slot,"trp_hero5", slot_troop_occupation, "trp_rhodok_sergeant"),    
     (troop_set_slot,"trp_hero6", slot_troop_occupation, "trp_swadian_knight"),
     (troop_set_slot,"trp_hero7", slot_troop_occupation, "trp_vaegir_knight"),    
     (troop_set_slot,"trp_hero8", slot_troop_occupation, "trp_khergit_lancer"),
     (troop_set_slot,"trp_hero9", slot_troop_occupation, "trp_nord_champion"),    
     (troop_set_slot,"trp_hero10", slot_troop_occupation, "trp_rhodok_sergeant"),
     (assign, "$g_upgrade_time", 336), # 2 weeks for 1st upgrade call
     ##################################################################
     ## TEST ONLY : COMMENT for farther use
     (assign, "$g_upgrade_time", 10), # 24 hours for 1st call
     (party_add_members,"p_main_party","trp_swadian_knight",2),
     (party_add_members,"p_main_party","trp_vaegir_knight",2),
     (party_add_members,"p_main_party","trp_khergit_lancer",2),
     (party_add_members,"p_main_party","trp_nord_champion",2),
     (party_add_members,"p_main_party","trp_rhodok_sergeant",2),
     (add_xp_to_troop, 100000, "trp_player"),
     ##################################################################

Main Script, I make it slimmer, taking away all checking removing the cf(can fail), assumed that this script only called from our menu.
Put before last ]
Code:
   # ##script_upgrade_troop_to_hero
   # ##usage   : (call_script,"script_upgrade_troop_to_hero",<troop_ID>,<hero_ID>),
   # ##Input 1 : <troop_ID> should be one of troop_id of top tier troop
   # ##Input 2 : <hero_ID> should be one of troop_id of inactive hero on module_troops.py
   # ##This must be passed.  The code block calling this script should have already checked if there is that troop.
   # ##Output: None, will adjust p_main_party
   # ##May call a dialog to communicate this happening
   ("upgrade_troop_to_hero",
      [(store_script_param,":troop_id",1),
       (store_script_param,":hero_id",2),
       (try_begin),
          (main_party_has_troop, ":troop_id"),
          (troop_slot_eq, ":hero_id", slot_troop_occupation, ":troop_id"),
          (troop_set_slot,":hero_id", slot_troop_occupation, slto_player_companion),
          (party_remove_members,"p_main_party",":troop_id",1),      # ##remove the regular troop
          (party_add_members,"p_main_party",":hero_id",1),          # ##Add the hero found
       (try_end),
      ]),

The Menu, called by trigger
on module_game_menus.py, before last ] :
Code:
###########################################################################
  ("upgrade_to_hero",0,
   "You notice that one or more of your warriors exceeds your expectations in battle. ^You walk towards the lines of your troops, and ...",
   "none",
   [
       (assign, reg11, 0), # sub menu 1
       (assign, reg12, 0), # sub menu 2
       (assign, reg13, 0), # sub menu 3
       (assign, reg14, 0), # sub menu 4
       (assign, "$g_upgrade_talk", 0),
     ],
    [
      ("hero_1",
      [         
         (assign, ":limit", reg10),
         (assign, ":found", 0),
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg11, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg11),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg11),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("hero_2",
      [         
         (ge, reg11, reg10),
         (store_add, ":limit", reg11, 1),
         (assign, ":found", 0),         
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg12, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg12),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg12),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("hero_3",
      [         
         (gt, reg12, reg11),
         (store_add, ":limit", reg12, 1),
         (assign, ":found", 0),         
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg13, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg13),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg13),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("hero_4",
      [         
         (gt, reg13, reg12),
         (store_add, ":limit", reg13, 1),
         (assign, ":found", 0),         
         (try_for_range, ":hero_id", ":limit", additional_heroes_end),
            (eq, ":found", 0),         
            (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
            (gt, ":hero_ocu", 0),
            (neq, ":hero_ocu",slto_kingdom_hero),
            (neq, ":hero_ocu",slto_player_companion),
            (main_party_has_troop, ":hero_ocu"),
            (assign, ":found", 1),
            (assign, reg14, ":hero_id"),
         (try_end),
         (eq, ":found", 1),
         (str_store_troop_name,s1,reg14),
      ],"stop to talk to {s1}",
       [
           (assign, ":hero_id", reg14),
           (troop_get_slot, ":troop_id", ":hero_id", slot_troop_occupation),
           (assign, reg20, ":troop_id"),
           (assign, reg21, ":hero_id"),
           (assign, "$g_upgrade_talk", 1),
           (start_map_conversation, ":troop_id"),
           (change_screen_return),
        ]
       ),
      ("prev",
      [
          (gt, reg10, additional_heroes_begin),
          (assign, ":limit", reg10),
          (assign, ":found", 0),         
          (try_for_range_backwards, ":hero_id", ":limit", additional_heroes_begin),
             (lt, ":found", 4),         
             (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
             (gt, ":hero_ocu", 0),
             (neq, ":hero_ocu",slto_kingdom_hero),
             (neq, ":hero_ocu",slto_player_companion),
             (main_party_has_troop, ":hero_ocu"),
             (assign, reg15, ":hero_id"),
             (val_add, ":found", 1),
         (try_end),
         (gt, ":found", 0),         
      ],"go to the previous lines",
       [
          (assign, reg10, reg15),
          (jump_to_menu, "mnu_upgrade_to_hero"),
        ]
       ),
      ("next",
      [
          (gt, reg14, reg13),
          (store_add, ":limit", reg14, 1),
          (assign, ":found", 0),         
          (try_for_range, ":hero_id", ":limit", additional_heroes_end),
             (eq, ":found", 0),         
             (troop_get_slot, ":hero_ocu", ":hero_id", slot_troop_occupation),
             (gt, ":hero_ocu", 0),
             (neq, ":hero_ocu",slto_kingdom_hero),
             (neq, ":hero_ocu",slto_player_companion),
             (main_party_has_troop, ":hero_ocu"),
             (assign, ":found", 1),
         (try_end),
         (eq, ":found", 1),         
      ],"go to the next lines",
       [
           (store_add, reg10, reg14, 1),
           (jump_to_menu, "mnu_upgrade_to_hero"),
        ]
       ),
      ("close",
      [
       ],"close",
       [
          (assign, "$g_upgrade_talk", 1),
          (change_screen_map),
       ]
      ),
    ]
  ),

###########################################################################

Here you are your dialogs. Put it under dialog = [ on module_dialogs.py. I'm not sure about the initial state. Is it "start" or "event_triggered", I'll test it when I have module_system.
Code:
dialogs = [
###########################################################################
   [anyone,
      "event_triggered",
      [
         (store_conversation_troop,"$g_talk_troop"),
         #(is_between,"$g_talk_troop", additional_heroes_begin, additional_heroes_end),
                        (eq, "$g_talk_troop", reg20),
         (eq, "$g_upgrade_talk", 1),
                        (troop_get_type, reg65, "trp_player"),
                        (str_store_string,s65,"@{reg65?my Lady:my Lord}"),
                        (str_store_troop_name,s21,reg21),
      ],
      "Yes, {s65}?",
      "upgrade_talk",
      []
   ],
       [anyone|plyr,
      "upgrade_talk",
      [],
      "I have seen you fight well in battles, soldier.",
      "upgrade_talk_1",
      []
   ],
        [anyone,
      "upgrade_talk_1",
      [
      ],
      "I only do my duty to {s65}, sire.",
      "upgrade_talk_2",
      []
         ],
         [anyone|plyr,
      "upgrade_talk_2",
      [],
      "And well, too. The only time I've heard someone with such skills in battle, it has been in sagas. You are a hero!",
      "upgrade_talk_3a",
      []
         ],         
         [anyone|plyr,
      "upgrade_talk_2",
      [],
      "I just wanted you to know that I take notice in such skills in battle. Now fall back in line!",
      "upgrade_talk_3b",
      []
         ],
   [anyone,
      "upgrade_talk_3a",
      [
      ],
      "You honour me with your words. I will do my utter best to honour them.",
      "upgrade_talk_4a",
      []
         ],
         [anyone|plyr,
      "upgrade_talk_4a",
      [],
      "From now on you shall be remembered as a {s21}",
      "upgrade_talk_5",
      []
         ],
   [anyone,
      "upgrade_talk_5",
      [
                    (call_script,"script_upgrade_troop_to_hero", reg20, reg21),
      ],
      "I will defend my new title to my death, and I will not let you down. I promise you this; The blood on my steel will never dry!",
      "close_window",
      []
         ],         
   [anyone,
      "upgrade_talk_3b",
      [
      ],
      "Yes, {s65}",
      "close_window",
      []
   ],
  
###########################################################################

Ok,I follow your way, I make it called by timed trigger, but I make the interval is not fixed 14 days, but random 14-21 days.
Then, optional from me, I think it will be more balanced if we put more limitation, only player reached 15 level can recruit new hero
on module_simple_triggers.py :
Code:
  (24,
   [
      #################################################################
      ## LEVEL CHECK BEGIN 
      ## Comment to disable LEVEL CHECK 
      (store_character_level, ":level", "trp_player"),   
      (ge, ":level", 15),
      ## LEVEL CHECK END
      #################################################################
      (store_current_hours,":now"),  
      (ge, ":now", "$g_upgrade_time"),
      (store_random_in_range, ":rand", 14, 22),         ## Next Call 14 - 21 days ahead    
      (val_mul, ":rand", 24),
      (val_add, ":rand", ":now"),
      (assign, "$g_upgrade_time"),
      (assign, reg10, additional_heroes_begin),
      (jump_to_menu, "mnu_upgrade_to_hero"),
    ]), 
 
This code is untested. I'll test it soon, and update if there's error on it.
     

Here is the post with the whole code. I took the liberty to implement the updated version of the dialogues and game menues into his post here. If you wan't the original, just klick his quote.
 
I'm working on it. It's only need link to companion dialog for the new heroes. I'm finishing my tournament mod now, if it's done, i'll post this entire code again with spelling corection from naglfaar above.
 
Back
Top Bottom