SP Tutorial Module System How to make troops recruitable from castle/towns.

Users who are viewing this thread

Yes, I fear I know the problem.

Tier5 is used in the script, but there isn't a tier5 in my trooptree. Thus it uses tier1 instead.
I could easily change that, if it wasn't my intention to remove trooptrees alltogether and replace them with single independent troops.
The only thing that confuses me is, that in castles it tells me that I am recruiting Vaegir Knights which aren't in the factions trooptree anymore.  :???:




Do you know how to get around the trooptree thing?

My only Idea would be to stop troops in trooptrees to level up.
 
In case you did not know, there are only 3 tiers (if I remember correctly). But you can create the 5th tier yourself. Just search for "tier_3" in module_scripts until you find a code that assigns troops into tiers. There you can just add new tiers.
 
Thank you, I finally found the problem.
There were no soldiers in castles recruited. I didn't pay any money, didn't get any troops, but the soldiers in the castle disappeared.


It was a simple mistake in module_game_menues

When it should load: script_town_castle_recruit_nobles_recruit
It loaded instead: script_town_recruit_nobles_recruit

This caused the problem.



Another question:
What if I want to recruit several troops from one castle, town or village?
Can I use the same steps as used here again? Do I need to copy all of the stuff or just the module_scripts part, where the troops are defined?

For exemple:

The old code:
Code:
	   
 #script_town_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_recruit_nobles_recruit", #renamed
    [(store_faction_of_party, ":cur_faction", "$current_town"),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_3_troop),  #changed tier so it wouldnt recruit nobles.
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (val_min, ":volunteer_amount", ":free_capacity"),
     (store_troop_gold, ":gold", "trp_player"),
     (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
     (val_min, ":volunteer_amount", ":gold_capacity"),
     (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
     (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
     (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
     (troop_remove_gold, "trp_player", ":cost"),
     ]), 

My new code:
Code:
	   
 #script_town_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_recruit_nobles_recruit", #renamed
    [(store_faction_of_party, ":cur_faction", "$current_town"),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_3_troop),  #changed tier so it wouldnt recruit nobles.
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_2_troop),  #my second troop
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (val_min, ":volunteer_amount", ":free_capacity"),
     (store_troop_gold, ":gold", "trp_player"),
     (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
     (val_min, ":volunteer_amount", ":gold_capacity"),
     (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
     (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
     (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
     (troop_remove_gold, "trp_player", ":cost"),
     ]), 

Or like this?
Code:
	   
 #script_town_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_recruit_nobles_recruit", #renamed
    [(store_faction_of_party, ":cur_faction", "$current_town"),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_3_troop),  #changed tier so it wouldnt recruit nobles.
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (val_min, ":volunteer_amount", ":free_capacity"),
     (store_troop_gold, ":gold", "trp_player"),
     (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
     (val_min, ":volunteer_amount", ":gold_capacity"),
     (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
     (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
     (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
     (troop_remove_gold, "trp_player", ":cost"),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_2_troop),  #my second troop
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (val_min, ":volunteer_amount", ":free_capacity"),
     (store_troop_gold, ":gold", "trp_player"),
     (store_div, ":gold_capacity", ":gold", 200),#200 denars per man
     (val_min, ":volunteer_amount", ":gold_capacity"),
     (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
     (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
     (store_mul, ":cost", ":volunteer_amount", 200),#200 denars per man
     (troop_remove_gold, "trp_player", ":cost"),
     ]), 


 
I am not sure whether your new codes would work or not. But you can just make new scripts and game menus to get more options like...

Go to Tavern
Recruit Swordsmen
Recruit Archers
Recruit Horsemen
Go to Prison

Though by just copying, after recruiting Archers, the Swordsmen and Horsemen options will disappear as well until the fief is refreshed.
 
Sir William the Brave said:
Do you have vanilla Mount and blader version of these codes? Because I try to use these codes but when I build_module I got an error.  :cry:
These codes are very unlikely to work with the original MB and do not count on any good coder like Laszers to make a new version of these codes for a very outdated game.
 
Is there a way to change the name of the troop displayed in the town/castle menue?

I tried out to change it in the script myself, but it seems that it needs the names "volunteers" and "nobles" which translate to the
recruits and heaviest troop name of each faction.
 
Life_Erikson said:
Is there a way to change the name of the troop displayed in the town/castle menue?

I tried out to change it in the script myself, but it seems that it needs the names "volunteers" and "nobles" which translate to the
recruits and heaviest troop name of each faction.
Where and what does it say?
If it is in the initial fief menu then it is decided here...
    ("recruit_nobles",[(call_script, "script_cf_town_castle_recruit_volunteers_cond"),]
      ,"Recruit Nobles.",    <------------- THERE
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_nobles"),
        (try_end),
        ]),
If you mean after that when you read what kind and amount of recruits you get then that should be tied to the recruit itself (tier#). If none of the above helps or I have misunderstood your situation then you need to give more details.
 
Thank you that was the problem.

(I totally forgot that there was more text above in module game menues  :oops:)
And I forgot to change the tiers in module_game_menues to what I have them changed in module scripts. That caused the troops being displayed with the wrong name in the second menue.
 
Sir William the Brave said:
Do you have vanilla Mount and blader version of these codes? Because I try to use these codes but when I build_module I got an error.  :cry:
As I said before, with some modifications, this code will work only in towns. But, for vanilla there is another code wich allows you to have recruits in both castles and towns.
That code enables you to recruit culture specific units if you are vassal of specific kingdom, you can have one to several number of units in both towns and castles and if you conquer enemy town or castle it changes units to your faction recruits, so you are able to recruit your kingdom troops in that settlement you conquered. Go on m&b repository and search for mod "Garnier mod", which has source code included or search for vanilla "The eagle and the radiant cross" source code if it is stil around, and take codes from there.

So. Since this is topic about recruits and recruitment, I would be interested in recruitment of specific troops if village belongs to other kingdom. For example, ‚village 49 belong to Khergits and I would like to recruit Vaegir peasants from there, villages 11, 43, should have "black Khergit tribesman" but that faction does not exists...
Also it maybe would be nice to be able to be able to recruit two kind of units for every faction.
For example, snow Vaegirs and plain terrain Vaegirs, norhen Rhodoks, southern Rhodoks, Suno and Praven Swadians- other Swadians... and so on.   
Something like this:

    (try_begin),
    (party_set_slot, ":center_no",”p_village_49”,
    slot_center_volunteer_troop_type,”trp_vaegir_recruit”,
          (try_end),
          (try_begin),
        (party_set_slot, ":center_no",”p_village_11”,
    slot_center_volunteer_troop_type,”trp_black_khergit_horseman”, # create recruits later
          (try_end),
          (try_begin),
    (party_set_slot, ":center_no",”p_village_43”,
    slot_center_volunteer_troop_type,”trp_black_khergit_horseman”,
          (try_end),

 
Alright I have to ask: what is the program you folks are using to edit the scripts.txt file?  I see that it is ms, but I've no idea what ms is.  I'm sure it's obvious and I'll feel dumb after you tell me, but nonetheless I would like to know. 

I'm tweaking part of ACOK for personal use.  Going to add new crownlander units to be recruited from the villages of king's landing, stokeworth, antlers, rosby, and duskendale, so that when I create my crownlander faction I will have culturally specific units available instead of crappy lannister goons.  The units have already been created via the troop editor. Now I only need to make the appropriate villages castles and towns recruit those units.

EDIT: Based on everything I've found around the forums, it seems I do not need the Modding System to edit files of a completed mod.  In that case, does anyone know how to make custom units spawn from certain villages?
 
Fewrfreyut said:
Alright I have to ask: what is the program you folks are using to edit the scripts.txt file?  I see that it is ms, but I've no idea what ms is.  I'm sure it's obvious and I'll feel dumb after you tell me, but nonetheless I would like to know. 

I'm tweaking part of ACOK for personal use.  Going to add new crownlander units to be recruited from the villages of king's landing, stokeworth, antlers, rosby, and duskendale, so that when I create my crownlander faction I will have culturally specific units available instead of crappy lannister goons.  The units have already been created via the troop editor. Now I only need to make the appropriate villages castles and towns recruit those units.

EDIT: Based on everything I've found around the forums, it seems I do not need the Modding System to edit files of a completed mod.  In that case, does anyone know how to make custom units spawn from certain villages?

Go here:

http://forums.taleworlds.com/index.php/topic,240255.0.html

If you have any questions go here:

http://forums.taleworlds.com/index.php/topic,6575.0/topicseen.html


Modding is a giant subject and most people will get anoyed if you ask them simple questions.
To prevent this make sure you allready tried to solve your problem by yourself by seeking existing information on this forum before posting.
(Use the forums search function!)


Good luck! :wink:
 
Tried to implement the first part of the script, every thing seemed alright until this popped up:

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...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
Traceback (most recent call last):
  File "process_game_menus.py", line 47, in <module>
    save_game_menus(variables,variable_uses,tag_uses,quick_strings)
  File "process_game_menus.py", line 31, in save_game_menus
    save_game_menu_item(ofile,variable_list,variable_uses,menu_item,tag_uses,qui
ck_strings)
  File "process_game_menus.py", line 14, in save_game_menu_item
    save_statement_block(ofile,0, 1, menu_item[3], variable_list, variable_uses,
tag_uses,quick_strings)
  File "C:\Users\Despair2K\Desktop\Warband Modding\Module_system 1.158\process_o
perations.py", line 449, in save_statement_block
    save_statement(ofile,opcode,no_variables,statement,variable_list,variable_us
es,local_vars, local_var_uses,tag_uses,quick_strings)
  File "C:\Users\Despair2K\Desktop\Warband Modding\Module_system 1.158\process_o
perations.py", line 398, in save_statement
    ofile.write("%d %d "%(opcode, lenstatement))
TypeError: %d format: a number is required, not str
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
WARNING: Global variable never used: g_enemy_surrenders
WARNING: Global variable never used: g_player_surrenders
WARNING: Global variable never used: g_private_battle_with_troop
WARNING: Global variable never used: cant_leave_encounter
WARNING: Global variable never used: g_leave_town_outside
WARNING: Global variable never used: character_gender
WARNING: Global variable never used: g_player_troop
WARNING: Global variable never used: g_camp_mode
WARNING: Global variable never used: g_prisoner_recruit_troop_id
WARNING: Global variable never used: g_prisoner_recruit_last_time
WARNING: Global variable never used: playerparty_postbattle_regulars
WARNING: Global variable never used: routed_party_added
WARNING: Global variable never used: thanked_by_ally_leader
WARNING: Global variable never used: last_freed_hero
WARNING: Global variable never used: capture_screen_shown
WARNING: Global variable never used: g_prison_heroes
WARNING: Global variable never used: g_siege_force_wait
WARNING: Global variable never used: g_siege_sallied_out_once
WARNING: Global variable never used: g_siege_join
WARNING: Global variable never used: qst_train_peasants_against_bandits_currentl
y_training
WARNING: Global variable never used: qst_eliminate_bandits_infesting_village_num
_villagers
WARNING: Global variable never used: g_player_raid_complete
WARNING: Global variable never used: quest_auto_menu
WARNING: Global variable never used: g_tournament_player_team_won
WARNING: Global variable never used: g_tournament_bet_placed
WARNING: Global variable never used: g_tournament_bet_win_amount
WARNING: Global variable never used: g_tournament_last_bet_tier
WARNING: Global variable never used: g_last_assassination_attempt_time
WARNING: Global variable never used: g_last_rest_payment_until
WARNING: Global variable never used: g_train_peasants_against_bandits_num_peasan
ts
WARNING: Global variable never used: last_sneak_attempt_town
WARNING: Global variable never used: last_sneak_attempt_time
WARNING: Global variable never used: g_training_ground_training_count
WARNING: Global variable never used: g_presentation_marshall_selection_max_renow
n_2
WARNING: Global variable never used: g_tutorial_entered
WARNING: Global variable never used: g_dont_give_marshalship_to_player_days
Exporting postfx_params...

______________________________

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

Anybody know what's going on?

EDIT:

Somebody from the first page had a very similar problem, yet I know that it's the script here that's causing the global variable problem, as my backup compiles just fine.

Anyway, I notice that people have been posting here recently, so hopefully somebody can help me out.


Welp, fixed it, never mind.
 
Sorry for the necro.

This is probably a total long shot, but if anybody is still following this thread I have a weird bug that I would greatly appreciate help with.

I've implemented the code, with some alterations based on people in the thread etc and it all works great. I can recruit from castles and towns. I have a weird side effect occurring however, where all of the doors in the castle scenes say stuff like "door to the arena" and "door to the shop" and stuff, and actually accessing them leads to weird mutant outdoor tournament scenes.  The doors inside the castles in towns are not labelled at all and don't do anything.
 
I actually have exactly the same bug. I didn't realize that this script was causing it as I was also modding other stuff at the time.
Hmm... would like to know how to get rid of it too.
 
Con22 said:
The doors inside the castles in towns are not labelled at all and don't do anything.

The order in the menu is used for the passages/doors. So each menu option can be used as a reference, starting from 0.

If you added new options to the menu... you broke the passages.

For example:
Code:
       "Speak with the merchant.",
       [           
           (try_begin),
             (this_or_next|eq,"$all_doors_locked",1),
             (eq,"$town_nighttime",1),
             (display_message,"str_door_locked",0xFFFFAAAA),
           (else_try),
             (assign, "$town_entered", 1),
             (set_jump_mission, "mt_town_default"),
             (mission_tpl_entry_set_override_flags, "mt_town_default", 0, af_override_horse),
             (try_begin),
               (eq, "$sneaked_into_town",1),
               (mission_tpl_entry_set_override_flags, "mt_town_default", 0, af_override_all),
             (try_end),
             (party_get_slot, ":cur_scene", "$current_town", slot_town_store),
             (jump_to_scene, ":cur_scene"),
             (scene_set_slot, ":cur_scene", slot_scene_visited, 1),
             (change_screen_mission),
           (try_end),
        ],"Door to the shop."), 
The menu option "Speak with the merchant." has the door message "Door to the shop"
 
Con22 said:
I've implemented the code, with some alterations based on people in the thread etc and it all works great. I can recruit from castles and towns. I have a weird side effect occurring however, where all of the doors in the castle scenes say stuff like "door to the arena" and "door to the shop" and stuff, and actually accessing them leads to weird mutant outdoor tournament scenes.  The doors inside the castles in towns are not labelled at all and don't do anything.
You must put "recruit troops" right above "wait here for some time" menu.
 
iggorbb said:
Con22 said:
I've implemented the code, with some alterations based on people in the thread etc and it all works great. I can recruit from castles and towns. I have a weird side effect occurring however, where all of the doors in the castle scenes say stuff like "door to the arena" and "door to the shop" and stuff, and actually accessing them leads to weird mutant outdoor tournament scenes.  The doors inside the castles in towns are not labelled at all and don't do anything.
You must put "recruit troops" right above "wait here for some time" menu.
kalarhan said:
Con22 said:
The doors inside the castles in towns are not labelled at all and don't do anything.

The order in the menu is used for the passages/doors. So each menu option can be used as a reference, starting from 0.

If you added new options to the menu... you broke the passages.

For example:
Code:
       "Speak with the merchant.",
       [           
           (try_begin),
             (this_or_next|eq,"$all_doors_locked",1),
             (eq,"$town_nighttime",1),
             (display_message,"str_door_locked",0xFFFFAAAA),
           (else_try),
             (assign, "$town_entered", 1),
             (set_jump_mission, "mt_town_default"),
             (mission_tpl_entry_set_override_flags, "mt_town_default", 0, af_override_horse),
             (try_begin),
               (eq, "$sneaked_into_town",1),
               (mission_tpl_entry_set_override_flags, "mt_town_default", 0, af_override_all),
             (try_end),
             (party_get_slot, ":cur_scene", "$current_town", slot_town_store),
             (jump_to_scene, ":cur_scene"),
             (scene_set_slot, ":cur_scene", slot_scene_visited, 1),
             (change_screen_mission),
           (try_end),
        ],"Door to the shop."), 
The menu option "Speak with the merchant." has the door message "Door to the shop"


Thanks to both of you very much. I figured it was something like this.
 
What fixes made the script work flawlessly for you guys? I'm getting some weird errors after trying to install this using Lav's compilier. Didn't even try to use the second part yet. Is there a better way to make nobel troops recruitable through castles?

(Using the latest MS and WB version)

I'll post the error soon...
 
Back
Top Bottom