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

Users who are viewing this thread

Has anybody figured out how to get mercenaries back into taverns? Somebody suggested that the problem is a slot conflict between the mercenary update script and the npc volunteer update script, but I can't figure out which slot it could be.
 
TheCaitularity said:
Has anybody figured out how to get mercenaries back into taverns? Somebody suggested that the problem is a slot conflict between the mercenary update script and the npc volunteer update script, but I can't figure out which slot it could be.
simple_triggers must be look like:
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
#(call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", villages_begin, villages_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      (call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
# (call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", centers_begin, centers_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      #(call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),
 
Mispronounced said:
Wait, you guys got this to work? I can't even get the first part to work. What did you do to fix it?

Could it be something to do with the way you installed it with Lav's compiler? I just took the text and copied it over into the module_ files.

Edit:

frozenpainter said:
TheCaitularity said:
Has anybody figured out how to get mercenaries back into taverns? Somebody suggested that the problem is a slot conflict between the mercenary update script and the npc volunteer update script, but I can't figure out which slot it could be.
simple_triggers must be look like:
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
#(call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", villages_begin, villages_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      (call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
# (call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", centers_begin, centers_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      #(call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),

Aha, it works! Thank you!
 
Ah - I think I remember having to monkey around with the script names of a few things to get it to work.

For instance, in the last piece of code (recruit_nobles), it calls "script_town_recruit_nobles_recruit", which is a typo: it SHOULD be "script_town_castle_recruit_nobles_recruit".

That might be your issue.
 
Does anyone know how to make so troops can only be recruited if the player belong to the troop faction?

Edit- manage to make it work, here are the changes i have made

Code:
    #script_cf_castle_recruit_elite_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_castle_recruit_elite_cond",
  
    [(party_get_slot,":town_faction","$g_encountered_party",slot_center_ex_faction),#you are the same faction as the town.
     (eq,":town_faction","$players_kingdom"),
	 #[(store_faction_of_party, ":town_faction", "$current_town"),
	# (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
     # (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
	 # (ge, ":center_relation", 0),
     # (this_or_next|ge, ":center_relation", 5),
     # (this_or_next|eq, ":town_faction", "$players_kingdom"),
     # (this_or_next|ge, ":town_faction_relation", 0),
     # (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
     # (             eq, "$players_kingdom", 0),
	 (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
     (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (ge, ":free_capacity", 1),
	 ]),
	 ]),
 
Does anyone have any ideas about how to maintain the availability of the original mercenary troop tree? I find it kind of awkward that it is initially available and then after three days it disappears (even if you are using the workaround where you don't have to wait three days for troops to be recruited from castle/city). I'd basically like to either have these troops available indefinitely or not at all, and im having trouble figuring it out. Thanks.
 
frozenpainter said:
TheCaitularity said:
Has anybody figured out how to get mercenaries back into taverns? Somebody suggested that the problem is a slot conflict between the mercenary update script and the npc volunteer update script, but I can't figure out which slot it could be.
simple_triggers must be look like:
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
#(call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", villages_begin, villages_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      (call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
# (call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", centers_begin, centers_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      #(call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),

Check this
 
Slavos said:
frozenpainter said:
TheCaitularity said:
Has anybody figured out how to get mercenaries back into taverns? Somebody suggested that the problem is a slot conflict between the mercenary update script and the npc volunteer update script, but I can't figure out which slot it could be.
simple_triggers must be look like:
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
#(call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", villages_begin, villages_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      (call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),
(72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
# (call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", centers_begin, centers_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      #(call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),

Check this

Must have missed this! Thanks for pointing it out,  I'll give it a try.
 
I followed the tutorial perfectly and maked all the changes I saw in the 7 pages of comments.

I using the last version of MB Warband (1.170) and the last version of MS (1.171).

The following errors appeared:

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 13, in save_game_menu_item
    ofile.write(" %s "%(string.replace(menu_item[2]," ","_")))
  File "C:\Python27\lib\string.py", line 521, in replace
    return s.replace(old, new, maxreplace)
AttributeError: 'tuple' object has no attribute 'replace'
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_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...

EDIT:

Here are my code lines:

(module_game_menus).

      ("castle_wait",
      [
        #(party_slot_eq,"$current_town",slot_party_type, spt_castle),
        (this_or_next|ge, "$g_encountered_party_relation", 0),
        (eq,"$castle_undefended",1),
        (assign, ":can_rest", 1),
        (str_clear, s1),
        (try_begin),
          (neg|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
  (troop_get_slot, ":player_spouse", "trp_player", slot_troop_spouse),
          (neg|party_slot_eq, "$current_town", slot_town_lord, ":player_spouse"),

          (party_slot_ge, "$current_town", slot_town_lord, "trp_player"), #can rest for free
          (store_faction_of_party, ":current_town_faction", "$current_town"),
          (neq, ":current_town_faction", "fac_player_supporters_faction"),
          (party_get_num_companions, ":num_men", "p_main_party"),
          (store_div, reg1, ":num_men", 4),
          (val_add, reg1, 1),
          (str_store_string, s1, "@ ({reg1} denars per night)"),
          (store_troop_gold, ":gold", "trp_player"),
          (lt, ":gold", reg1),
          (assign, ":can_rest", 0),
        (try_end),
        (eq, ":can_rest", 1),
      ],

      ("recruit_nobles",[(is_between, "$current_town",
        castles_begin, castles_end), (call_script,
      "script_cf_town_castle_recruit_volunteers_cond"),]
      ,"Recruit Nobles.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_nobles"),
        (try_end),
      ]),

      ("recruit_normals",[(is_between, "$current_town",
        towns_begin, towns_end), (call_script,
      "script_cf_town_recruit_volunteers_cond"),]
      ,"Recruit Volunteers.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (jump_to_menu, "mnu_recruit_normales"),
        (try_end),
      ]),


      "Wait here for some time{s1}.",
      [
        (assign, "$auto_enter_town", "$current_town"),
        (assign, "$g_town_visit_after_rest", 1),
        (assign, "$g_last_rest_center", "$current_town"),
        (assign, "$g_last_rest_payment_until", -1),

        (try_begin),
          (party_is_active, "p_main_party"),
          (party_get_current_terrain, ":cur_terrain", "p_main_party"),
          (try_begin),
            (eq, ":cur_terrain", rt_desert),
            (unlock_achievement, ACHIEVEMENT_SARRANIDIAN_NIGHTS),
          (try_end), 
        (try_end), 

        (rest_for_hours_interactive, 24 * 7, 5, 0), #rest while not attackable
        (change_screen_return),
      ]),

  (
    "recruit_nobles",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 160),#160 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 160),#160 denars per man #again was 40
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_castle_recruit_nobles_recruit"),
                       
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

  (
  "recruit_normales",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_3_troop),  #Tier 3
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
    (assign, ":party_capacity", ":free_capacity"),
    (val_min, ":party_capacity", ":gold_capacity"),
    (try_begin),
      (gt, ":party_capacity", 0),
      (val_min, ":volunteer_amount", ":party_capacity"),
    (try_end),
    (assign, reg5, ":volunteer_amount"),
    (assign, reg7, 0),
    (try_begin),
      (gt, ":volunteer_amount", ":gold_capacity"),
      (assign, reg7, 1), #not enough money
    (try_end),
    (try_begin),
      (eq, ":volunteer_amount", 0),
      (str_store_string, s18, "@No one here seems to be willing to join your party."),
    (else_try),
      (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
      (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
      (try_begin),
        (eq, reg5, 1),
        (str_store_string, s18, "@One {s3} volunteers to follow you."),
      (else_try),
        (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
      (try_end),
      (set_background_mesh, "mesh_pic_recruits"),
    (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                 
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_recruit_nobles_recruit"),
                     
  (jump_to_menu, "mnu_town"),
      ]),
   
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),


]

(module_scripts).

  #script_cf_town_castle_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_castle_recruit_volunteers_cond",
    [(store_faction_of_party, ":town_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
    (ge, ":center_relation", 0),
    (this_or_next|ge, ":center_relation", 5),
    (this_or_next|eq, ":town_faction", "$players_kingdom"),
    (this_or_next|ge, ":town_faction_relation", 0),
    (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
    (            eq, "$players_kingdom", 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (ge, ":free_capacity", 1),
    ]),

  #script_cf_town_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_recruit_volunteers_cond",  #renamed
    [(store_faction_of_party, ":town_faction", "$current_town"),
    (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
    (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
    (ge, ":center_relation", 0),
    (this_or_next|ge, ":center_relation", 5),
    (this_or_next|eq, ":town_faction", "$players_kingdom"),
    (this_or_next|ge, ":town_faction_relation", 0),
    (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
    (            eq, "$players_kingdom", 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
    (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (ge, ":free_capacity", 1),
    ]),

  #script_village_recruit_volunteers_recruit
  # INPUT: none
  # OUTPUT: none
  ("village_recruit_volunteers_recruit",
    [(party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
    (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", 10),#10 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", 10),#10 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

  #script_town_castle_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_castle_recruit_nobles_recruit",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_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", 160),#160 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", 160),#160 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

  #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), 
    (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", 40),#40 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", 40),#40 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

(module_simple_triggers).

  # Adding mercenary troops to the towns
  (72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
    #(call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", villages_begin, villages_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      (call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),
  (72,
  [
    (call_script, "script_update_mercenary_units_of_towns"),
  # (call_script, "script_start_update_mercenary_units_of_towns"),
    #NPC changes begin
    # removes  (call_script, "script_update_companion_candidates_in_taverns"),
    #NPC changes end
    (call_script, "script_update_ransom_brokers"),
    (call_script, "script_update_tavern_travellers"),
    (call_script, "script_update_tavern_minstrels"),
    (call_script, "script_update_booksellers"),
    (call_script, "script_update_villages_infested_by_bandits"),
    (try_for_range, ":village_no", centers_begin, centers_end),
      (call_script, "script_update_volunteer_troops_in_village", ":village_no"),
      #(call_script, "script_update_npc_volunteer_troops_in_village", ":village_no"),
    (try_end),
    ]),

Really appreciate some help!  :wink:
 
Sorry to bump a older thread but I need help. For some reason it wont show up under the menus when i visit a castle or town.I'm not getting any errors from python so it kind of has me stumped.One thing I didnt touch though is the simple triggers
Code:
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...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
Imported 27 global variables for saved-game compatability that are not used.
Exporting postfx_params...

______________________________

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

I followed all of the steps from the first post, I edited the module scripts & added it both for the castle & town.
Code:
  #script_cf_town_castle_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_castle_recruit_volunteers_cond",
    [(store_faction_of_party, ":town_faction", "$current_town"),
     (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
     (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
     (ge, ":center_relation", 0),
     (this_or_next|ge, ":center_relation", 5),
     (this_or_next|eq, ":town_faction", "$players_kingdom"),
     (this_or_next|ge, ":town_faction_relation", 0),
     (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
     (             eq, "$players_kingdom", 0),
     (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
     (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (ge, ":free_capacity", 1),
     ]),

  #script_cf_town_recruit_volunteers_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_town_recruit_volunteers_cond",  #renamed
    [(store_faction_of_party, ":town_faction", "$current_town"),
     (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
     (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
     (ge, ":center_relation", 0),
     (this_or_next|ge, ":center_relation", 5),
     (this_or_next|eq, ":town_faction", "$players_kingdom"),
     (this_or_next|ge, ":town_faction_relation", 0),
     (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
     (             eq, "$players_kingdom", 0),
     (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
     (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (ge, ":free_capacity", 1),
     ]),]

Code:
  #script_town_castle_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_castle_recruit_nobles_recruit",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_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"),
     ]),

  #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_1_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", 50),#50 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", 50),#50 denars per man
     (troop_remove_gold, "trp_player", ":cost"),
     ]),

Then i went to the module Game menu's and added the necessary codes also i edited the script lines to the correct names
like TheCaitularity said.

Code:
("recruit_nobles",[(call_script, "script_cf_town_castle_recruit_volunteers_cond"),]
       ,"Recruit Nobles.",
       [
         (try_begin),
           (call_script, "script_cf_enter_center_location_bandit_check"),
         (else_try),
           (jump_to_menu, "mnu_recruit_nobles"),
         (try_end),

      ("recruit_normals",[(is_between, "$current_town",
        towns_begin, towns_end),      (call_script, "script_cf_town_recruit_volunteers_cond"),]
       ,"Recruit Volunteers.",
       [
         (try_begin),
           (call_script, "script_cf_enter_center_location_bandit_check"),
         (else_try),
           (jump_to_menu, "mnu_recruit_normales"),
         (try_end),
        ]),[code]

[code]   ( "recruit_nobles",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_5_troop), 
     (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (store_troop_gold, ":gold", "trp_player"),
     (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
     (assign, ":party_capacity", ":free_capacity"),
     (val_min, ":party_capacity", ":gold_capacity"),
     (try_begin),
       (gt, ":party_capacity", 0),
       (val_min, ":volunteer_amount", ":party_capacity"),
     (try_end),
     (assign, reg5, ":volunteer_amount"),
     (assign, reg7, 0),
     (try_begin),
       (gt, ":volunteer_amount", ":gold_capacity"),
       (assign, reg7, 1), #not enough money
     (try_end),
     (try_begin),
       (eq, ":volunteer_amount", 0),
       (str_store_string, s18, "@No one here seems to be willing to join your party."),
     (else_try),
       (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
       (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
       (try_begin),
         (eq, reg5, 1),
         (str_store_string, s18, "@One {s3} volunteers to follow you."),
       (else_try),
         (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
       (try_end),
       (set_background_mesh, "mesh_pic_recruits"),
     (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
       
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                   
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
       
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_castle_recruit_nobles_recruit"),
                        
  (jump_to_menu, "mnu_town"),
      ]),
      
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

   ( "recruit_normales",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
     (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop),  #Notice the changed tier
     (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (store_troop_gold, ":gold", "trp_player"),
     (store_div, ":gold_capacity", ":gold", 40),#40 denars per man
     (assign, ":party_capacity", ":free_capacity"),
     (val_min, ":party_capacity", ":gold_capacity"),
     (try_begin),
       (gt, ":party_capacity", 0),
       (val_min, ":volunteer_amount", ":party_capacity"),
     (try_end),
     (assign, reg5, ":volunteer_amount"),
     (assign, reg7, 0),
     (try_begin),
       (gt, ":volunteer_amount", ":gold_capacity"),
       (assign, reg7, 1), #not enough money
     (try_end),
     (try_begin),
       (eq, ":volunteer_amount", 0),
       (str_store_string, s18, "@No one here seems to be willing to join your party."),
     (else_try),
       (store_mul, reg6, ":volunteer_amount", 40),#40 denars per man
       (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
       (try_begin),
         (eq, reg5, 1),
         (str_store_string, s18, "@One {s3} volunteers to follow you."),
       (else_try),
         (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
       (try_end),
       (set_background_mesh, "mesh_pic_recruits"),
     (try_end),
    ],
    [
      ("continue_not_enough_gold",
      [
        (eq, reg7, 1),
      ],
      "I don't have enough money...",
      [
  (jump_to_menu, "mnu_town"),
      ]),
       
      ("continue",
      [
        (eq, reg7, 0),
        (eq, reg5, 0),
      ], #noone willing to join                   
      "Continue...",
      [
        (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
  (jump_to_menu, "mnu_town"),
      ]),
       
      ("recruit_them",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Recruit them ({reg6} denars).",
      [
        (call_script, "script_town_castle_recruit_nobles_recruit"),
                        
  (jump_to_menu, "mnu_town"),
      ]),
      
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),
 
Totenkopf900 said:
you have to wait 3 days in game or follow the the first post in this tutorial
i followed Ritter Dummbatz post and edited so i wouldnt have to wait the the three days.
 
Totenkopf900 said:
Does anyone know how to make so troops can only be recruited if the player belong to the troop faction?

Edit- manage to make it work, here are the changes i have made

Code:
    #script_cf_castle_recruit_elite_cond
  # INPUT: none
  # OUTPUT: none
  ("cf_castle_recruit_elite_cond",
  
    [(party_get_slot,":town_faction","$g_encountered_party",slot_center_ex_faction),#you are the same faction as the town.
     (eq,":town_faction","$players_kingdom"),
	 #[(store_faction_of_party, ":town_faction", "$current_town"),
	# (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
     # (store_relation, ":town_faction_relation", ":town_faction", "fac_player_faction"),
	 # (ge, ":center_relation", 0),
     # (this_or_next|ge, ":center_relation", 5),
     # (this_or_next|eq, ":town_faction", "$players_kingdom"),
     # (this_or_next|ge, ":town_faction_relation", 0),
     # (this_or_next|eq, ":town_faction", "$supported_pretender_old_faction"),
     # (             eq, "$players_kingdom", 0),
	 (party_slot_ge, "$current_town", slot_center_volunteer_troop_amount, 0),
     (party_slot_ge, "$current_town", slot_center_volunteer_troop_type, 1),
     (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (ge, ":free_capacity", 1),
	 ]),
	 ]),

What way to have some relation with faction?
and only after then get troops from town / castle?

was thinking of noble line that faction lords get special troops like in pop.
but player get those special troops too after faction reputation/relation is example 50 or 80.
 
Back
Top Bottom