question on adding troops

Users who are viewing this thread

pan-boroda

Knight at Arms
Friends, tell me more on this issue. I would like to add that when hiring nobles, a certain number of warriors were automatically added to the squadron (something like squires), depending on the number of hired nobles (for example, 1 nobleman - 3 squires).
  (
    "recruit_nobles",0,
    "{s18}",
    "none",
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_4_troop),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (party_add_members, "p_main_party", "trp_mercenary_horseman", 3),    
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 50),#50 denars per man #I had to set this #as it was still 40
    (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", 50),#50 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"),
# this one was a big problem, was originally set different and thus player could not recruit troops by #pressing the button
                       
  (jump_to_menu, "mnu_town"),
      ]),
     
      ("forget_it",
      [
        (eq, reg7, 0),
        (gt, reg5, 0),
      ],
      "Forget it.",
      [
  (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),

If you register as above, then regardless of the number of the adopted nobles, only 3 hired riders are added to the squad ....
Hence questions ... 1) how to register, the number of mercenaries depended on the number of employed nobles .... And the second question, whether it is possible to register in order to view additional troops depended on the fraction ... For example, when hiring vaegir boyars added 3 combat serfs, among the Saranids when hiring sipahes — a fractional type of warrior, etc.
Perhaps you need to register something not only in games_menus. If anyone knows, tell me, please
 
After the prompts of kind people who recommended correcting the script, we got the following
  #script_town_castle_recruit_nobles_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_castle_recruit_nobles_recruit", #renamed
    [(store_faction_of_party, ":cur_faction", "$current_town"),
    (faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_4_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_add_members, "p_main_party", "trp_caravan_guard", ":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"),
    ]),

It seems everything worked ... There was a question, how to register, so that additional troops were added for faction.  If anyone knows, I will be glad to help
 
People, there was one problem.
There are three branches in the mod - village, city and fortress.
I plan to prescribe that certain ethnic groups are hired in specific places.
I figured out how to register the hiring of soldiers from the village branch, but with the city and fortress branches it does not work.
Town line - slot_faction_tier_4_troop
Fortresses - slot_faction_tier_5_troop
this is on the village branch:
#script_update_volunteer_troops_in_village
# INPUT: arg1 = center_no
# OUTPUT: none
("update_volunteer_troops_in_village",
[
(store_script_param, ":center_no", 1),
(party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
## Tocan begin
# (party_get_slot, ":center_culture", ":center_no", slot_center_culture),
(store_faction_of_party, ":center_culture", ":center_no"),
## Tocan end


## (try_begin),
## (eq, "$cheat_mode", 2),
## (str_store_party_name, s4, ":center_no"),
## (str_store_faction_name, s5, ":center_culture"),
## (display_message, "str_updating_volunteers_for_s4_faction_is_s5"),
## (try_end),

(faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
(assign, ":volunteer_troop_tier", 1),
(store_div, ":tier_upgrades", ":player_relation", 10),
(try_for_range, ":unused", 0, ":tier_upgrades"),
(store_random_in_range, ":random_no", 0, 100),
(lt, ":random_no", 10),
(store_random_in_range, ":random_no", 0, 2),
(troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", ":random_no"),
(try_begin),
(le, ":upgrade_troop_no", 0),
(troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", 0),
(try_end),
(gt, ":upgrade_troop_no", 0),
(val_add, ":volunteer_troop_tier", 1),
(assign, ":volunteer_troop", ":upgrade_troop_no"),
(try_end),

(assign, ":upper_limit", 8,
(try_begin),
(ge, ":player_relation", 4),
(assign, ":upper_limit", ":player_relation"),
(val_div, ":upper_limit", 2),
(val_add, ":upper_limit", 6),
(else_try),
(lt, ":player_relation", 0),
(assign, ":upper_limit", 0),
(try_end),


##diplomacy begin
(assign, ":percent", 100),
(try_begin), #-30% if not owner
(neg|party_slot_eq, ":center_no", slot_town_lord, "trp_player"),
(val_sub, ":percent", 30),
(try_end),
(try_begin), #1%/4 renown
(troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
(val_div, ":player_renown", 4),
(val_add, ":percent", ":player_renown"),
(try_end),
(try_begin), #1%/3 honour
(assign, ":player_honour", "$player_honor"),
(val_div, ":player_honour", 3),
(val_add, ":percent", ":player_honour"),
(try_end),
(try_begin), #+5% if king
(faction_get_slot, ":faction_leader", "fac_player_supporters_faction", slot_faction_leader),
(eq, ":faction_leader", "trp_player"),
(val_add, ":percent", 5),

(try_begin), #-5% for each point of serfdom
(faction_get_slot, ":serfdom", "fac_player_supporters_faction", dplmc_slot_faction_serfdom),
(neq, ":serfdom", 0),
(val_mul, ":serfdom", 5),
(val_sub, ":percent", ":serfdom"),
(try_end),

(try_begin), #+5% if king of village
(store_faction_of_party, ":faction", ":center_no"),
(eq, ":faction", "fac_player_supporters_faction"),
(val_add, ":percent", 5),
(try_end),
(try_end),

(try_begin),
(gt, ":upper_limit", 0),
(val_clamp, ":percent", 0, 201),
(val_mul, ":upper_limit", ":percent"),
(val_div, ":upper_limit", 100),
(try_end),

##diplomacy end


(val_mul, ":upper_limit", 3),
(store_add, ":amount_random_divider", 2, ":volunteer_troop_tier"),
(val_div, ":upper_limit", ":amount_random_divider"),

(store_random_in_range, ":amount", 0, ":upper_limit"),
(party_set_slot, "p_village_219", slot_center_volunteer_troop_type, "trp_nogai_kazak"),
(party_set_slot, "p_village_237", slot_center_volunteer_troop_type, "trp_nogai_kazak"),
(party_set_slot, "p_village_240", slot_center_volunteer_troop_type, "trp_nogai_kazak"),

(party_set_slot, ":center_no", slot_center_volunteer_troop_type, ":volunteer_troop"),
(party_set_slot, ":center_no", slot_center_volunteer_troop_amount, ":amount"),
]),

#script_update_npc_volunteer_troops_in_village
# INPUT: arg1 = center_no
# OUTPUT: none
("update_npc_volunteer_troops_in_village",
[
(store_script_param, ":center_no", 1),
## Tocan begin
# (party_get_slot, ":center_culture", ":center_no", slot_center_culture),
(store_faction_of_party, ":center_culture", ":center_no"),
## Tocan end
(faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
(assign, ":volunteer_troop_tier", 1),
(try_for_range, ":unused", 0, 5),
(store_random_in_range, ":random_no", 0, 100),
(lt, ":random_no", 10),
(store_random_in_range, ":random_no", 0, 2),
(troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", ":random_no"),
(try_begin),
(le, ":upgrade_troop_no", 0),
(troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", 0),
(try_end),
(gt, ":upgrade_troop_no", 0),
(val_add, ":volunteer_troop_tier", 1),
(assign, ":volunteer_troop", ":upgrade_troop_no"),
(try_end),

(assign, ":upper_limit", 12),

(store_add, ":amount_random_divider", 2, ":volunteer_troop_tier"),
(val_div, ":upper_limit", ":amount_random_divider"),

(store_random_in_range, ":amount", 0, ":upper_limit"),
(party_set_slot, "p_village_219", slot_center_volunteer_troop_type, "trp_nogai_kazak"),
(party_set_slot, "p_village_237", slot_center_volunteer_troop_type, "trp_nogai_kazak"),
(party_set_slot, "p_village_240", slot_center_volunteer_troop_type, "trp_nogai_kazak"),

(party_set_slot, ":center_no", slot_center_npc_volunteer_troop_type, ":volunteer_troop"),
(party_set_slot, ":center_no", slot_center_npc_volunteer_troop_amount, ":amount"),
]),
Can someone tell me how to do it right?
Thanks in advance
 
Last edited:
I found such a moment, can someone tell me whether to insert it into this script, or where to place it?
(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),
 
Good afternoon, can someone tell me what the problem is on this issue.
I plan to make dynamic icons of the main character so that the icon changes depending on the number of troops.
It seems that he did everything, the icon changes are normal - the rider, then the group of troops, but when adding the required number of troops, after the start of the movement, the icon returns to the original "player" icon.

What is the problem?

script
("draw_icons_my",
[
(store_party_size, ":party_size", "p_main_party"),
(party_get_current_terrain, ":terrain", "p_main_party"),
(assign, reg1, ":terrain"),
(try_begin),
(try_begin),
(this_or_next|eq, reg1, 15),
(eq, reg1, 7),
(this_or_next|eq, "$g_player_icon_state", 0),
(eq, "$g_player_icon_state", 1),
(try_begin),
(ge, ":party_size", 120),
(assign, ":icon", "icon_player_rus_army2"),
(else_try),
(ge, ":party_size", 7),
(assign, ":icon", "icon_player_rus_army"),
(else_try),
(assign, ":icon", "icon_player_horseman"),
(try_end),
(try_end),
(try_end),
(party_set_icon, "p_main_party", ":icon"),
]),

simple_triggers
# Updating player icon in every frame
(0,
[(troop_get_inventory_slot, ":cur_horse", "trp_player", :cool:,
(party_get_num_companions, ":num"),
(assign, ":new_icon", -1),
(try_begin),
(eq, "$g_player_icon_state", pis_normal),
(try_begin),
(is_between, ":num", 10, 90),
(assign, ":new_icon", "icon_player_rus_army"),
(else_try),
(is_between, ":num", 90),
(assign, ":new_icon", "icon_player_rus_army2"),
(else_try),
(ge, ":cur_horse", 0),
(assign, ":new_icon", "icon_player_horseman"),
(else_try),
(assign, ":new_icon", "icon_player"),
(try_end),
(else_try),
(eq, "$g_player_icon_state", pis_camping),
(assign, ":new_icon", "icon_camp"),
(else_try),
(eq, "$g_player_icon_state", pis_ship),
(assign, ":new_icon", "icon_ship"),
(try_end),
(neq, ":new_icon", "$g_player_party_icon"),
(assign, "$g_player_party_icon", ":new_icon"),
(party_set_icon, "p_main_party", ":new_icon"),
]),
 
Last edited:
this is how it looks in mod

rider icon
_.png

after starting the movement, the icon changes to player
_(2).png

changing the icon after adding troops
_10(2).png

changing the icon after starting the movement
_10.png
 
Use intendation to make it easier to read your code, also for yourself
Code:
# Updating player icon in every frame
(0,
[(troop_get_inventory_slot, ":cur_horse", "trp_player", :cool:,
 (party_get_num_companions, ":num"),
 (assign, ":new_icon", -1),
 (try_begin),
     (eq, "$g_player_icon_state", pis_normal),
     (try_begin),
         (is_between, ":num", 10, 90),
         (assign, ":new_icon", "icon_player_rus_army"),
     (else_try),
         (is_between, ":num", 90),
         (assign, ":new_icon", "icon_player_rus_army2"),
     (else_try),
         (ge, ":cur_horse", 0),
         (assign, ":new_icon", "icon_player_horseman"),
     (else_try),
         (assign, ":new_icon", "icon_player"),
     (try_end),
 (else_try),
     (eq, "$g_player_icon_state", pis_camping),
     (assign, ":new_icon", "icon_camp"),
 (else_try),
     (eq, "$g_player_icon_state", pis_ship),
     (assign, ":new_icon", "icon_ship"),
 (try_end),
 (neq, ":new_icon", "$g_player_party_icon"),
 (assign, "$g_player_party_icon", ":new_icon"),
 (party_set_icon, "p_main_party", ":new_icon"),
]),
The line (is_between, ":num", 90), is obviously not working, it should be (ge, ":num", 90),
Otherwise it should work normally, I have seen no misstake. I am however not sure about the script, I can't find such one in Native and I don't think that it is necessary. Where did you pick that up from?
 
Use intendation to make it easier to read your code, also for yourself
Code:
# Updating player icon in every frame
(0,
[(troop_get_inventory_slot, ":cur_horse", "trp_player", :cool:,
(party_get_num_companions, ":num"),
(assign, ":new_icon", -1),
(try_begin),
     (eq, "$g_player_icon_state", pis_normal),
     (try_begin),
         (is_between, ":num", 10, 90),
         (assign, ":new_icon", "icon_player_rus_army"),
     (else_try),
         (is_between, ":num", 90),
         (assign, ":new_icon", "icon_player_rus_army2"),
     (else_try),
         (ge, ":cur_horse", 0),
         (assign, ":new_icon", "icon_player_horseman"),
     (else_try),
         (assign, ":new_icon", "icon_player"),
     (try_end),
(else_try),
     (eq, "$g_player_icon_state", pis_camping),
     (assign, ":new_icon", "icon_camp"),
(else_try),
     (eq, "$g_player_icon_state", pis_ship),
     (assign, ":new_icon", "icon_ship"),
(try_end),
(neq, ":new_icon", "$g_player_party_icon"),
(assign, "$g_player_party_icon", ":new_icon"),
(party_set_icon, "p_main_party", ":new_icon"),
]),
The line (is_between, ":num", 90), is obviously not working, it should be (ge, ":num", 90),
Otherwise it should work normally, I have seen no misstake. I am however not sure about the script, I can't find such one in Native and I don't think that it is necessary. Where did you pick that up from?

Good day. There was a similar script on the forum for Dedal Icons, but then I changed it myself

unfortunately, your advice did not help, the icon continues to change after the start of the movement
 
Last edited by a moderator:
Back
Top Bottom