help with recruit menus scripting

Users who are viewing this thread

smokindog

Veteran
Hi, mounted & bladed.

Need help with adding recruit menus to towns and castles. I've already found some brief advices on this popular issue on the forum, but it's quite difficult for non-coder to make it all work properly. When it's said "look how recruit_villagers_something work and repeat it in town menus" I see there's some conditions, checks and other things that regulate this, and I guess one in village must not exactly repeat castle/town one, besides there's too much additional .py files involved into the process so the mission looks almost impossible...

What exact I'd like to receive is Recruit Volunteers menus in every Town/Castle. Village, town and castle recruit types are different and you can't see this castle/town menus if the owner faction is hostile to you (like you cannot just enter the town).

Any help would be greatly appreciated. Thanks in advance.
 
exactly ) and to make it impossible to recruit in hostile castles/towns

besides, i guess there is another issue, maybe not so important: we got fac_culture troop_tiers, that determines villages that are very friendly to you give you troops of higher tiers. So if recruit function is added to city - won't it cause some script bugs if I say have won 100 tournaments in this city and the city love me ) For we have a troop tree from city different from village troop tree. I'm just curious. And ignorant )
 
thanks, Darvin, but it seems to me it won't solve the problem completely )
may be I couldn't make the idea clear for english is not my native, sorry

I mean I'm not able neither add menus nor make it work properly by myself - there's to much things to be changed through the code so I'm helpless
 
I'm from Russia, but please don't make this topic fall into flood )

I've spent almost a week of my social life to find anything on this problem so now I'm down and in extreme need for help of a fluent coder )
 
thank you, I've already asked on the biggest ru_forum

I realize that it's not that simple to explain big things so I'll hardly find the solution here, I'm just asking for a bit too much ) Maybe there is some thread where people can invite other people to join the team?
 
well, guys, I've managed somehow to set it up, but it still doesn't work properly

look what I've done:
I've put this piece to module_game_menus:
Code:
("recruit_volunteers",[
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
          (this_or_next|eq,"$entry_to_town_forbidden",0),
          (eq, "$sneaked_into_town",1)]
       ,"Recruit Townsmen.",
       [
         (try_begin),
           (call_script, "script_cf_enter_center_location_bandit_check"),
         (else_try),
           (jump_to_menu, "mnu_recruit_volunteers_town"),
         (try_end),
        ]),

it takes us to the next added piece:
Code:
(
    "recruit_volunteers_town",0,
    "{s18}",
    "none",
    [(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", 50),#10 denars per man
     (val_min, ":volunteer_amount", ":gold_capacity"),
     (assign, reg5, ":volunteer_amount"),
     (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),#10 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",[(eq, reg5, 0)],
       "Continue...",[(party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),(jump_to_menu,"mnu_town")]),
      ("recruit_them",[(gt, reg5, 0)],
       "Recruit them ({reg6} denars).",[(call_script, "script_town_recruit_volunteers_recruit"),
                        (jump_to_menu,"mnu_town"),
                        ]),
      ("forget_it",[(gt, reg5, 0)],
      "Forget it.",[(jump_to_menu,"mnu_town")]),
    ],
  ),
Then I've added following script to module_scripts:
Code:
  #script_town_recruit_volunteers_recruit
  # INPUT: none
  # OUTPUT: none
  ("town_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", 50),#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", 50),#10 denars per man
     (troop_remove_gold, "trp_player", ":cost"),
     ]),
Everything was done according to my intuition ))

Now when I enter the town and push "Recruit townsmen" I always get "Nobody's willing to join you". It's obviously for script doesn't know how many recruits available are in this city and of what type. But how to set this?

When I've tried the above operation with replacing "village_recruit_volunteers" with "town_recruit volunteers" and adding new slot_townsmen_troop_type to module_constants I've got "-15 Novice Fighters willing to join you" and no buttons to respond.
What should I fix to get a recruits in towns different to village recruits?
 
According to your code, if you don't have enough money, you don't have room, or there are no volunteers, then you get that message.

When do you add volunteers to the town party?  By default if you don't add anything to a slot value, it starts as 0.  Also, I don't see where your script is called...
 
)) I'm still not able for it does'n work )
I've never been so deep into scripting and I had no idea of how it goes. After spending 48 hour staring into the script lines I've started to understand some logic and did this ) But I still need help )
 
jik said:
According to your code, if you don't have enough money, you don't have room, or there are no volunteers, then you get that message.

When do you add volunteers to the town party?  By default if you don't add anything to a slot value, it starts as 0.  Also, I don't see where your script is called...

Where am I supposed to do this? Is it the last figures of party description in module_parties? All my towns are Native ones. And what do I have to do with slot_volunteer_type? I can't find where it's all defined
 
That's up to you. 

You can set a simple trigger that adds 5 to that every week/month.  The type would be up to you as well.  The type would be one of the troop types (such as trp_farmer)
 
thanks for your respond, jik
actually I can't use triggers for I don't know how )

I've found this script:
Code:
  ("update_volunteer_troops_in_village",
    [
       (store_script_param, ":center_no", 1),
       (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
       (party_get_slot, ":center_culture", ":center_no", slot_center_culture),
       (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", 7),
       (try_begin),
         (ge, ":player_relation", 5),
         (assign, ":upper_limit", ":player_relation"),
         (val_div, ":upper_limit", 2),
         (val_add, ":upper_limit", 10),
       (else_try),
         (lt, ":player_relation", 0),
         (assign, ":upper_limit", 0),
       (try_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, ":center_no", slot_center_volunteer_troop_type, ":volunteer_troop"),
       (party_set_slot, ":center_no", slot_center_volunteer_troop_amount, ":amount"),
     ]),

is it possible to use it somehow for generating recruits amount in towns?
 
triggers are easy, when you understand the layout of the tuple.  A good one to look at (timing wise) would be the weekly paying your troops simple trigger:

  #Pay day.
  (24 * 7,                  ##This would be every 24*7 game hours
  [
    (call_script, "script_calculate_player_faction_wage"),
    (assign, ":total_wages", reg0),
    (store_add, ":total_debt", ":total_wages", "$g_player_debt_to_party_members"),
    (try_begin),
      (gt, ":total_debt", 0),
      (jump_to_menu,"mnu_pay_day"),
    (try_end),
    (assign, "$g_cur_week_half_daily_wage_payments", 0),#Reseting the weekly half wage payments
    ]),

You could even just add your stock up recruits stuff to this one, though I would make a separate one just for better programming...

In a trigger like this, you can use a try_for_range loop to go through each town and add how many troops you want.  There is no party_slot_add command, but if you want, you can use this script I made:

##script_party_slot_add
##So I don't have to do this manually every time I do basic math in slots.  PARTY SLOTS ONLY
##Usage : (call_script,"script_party_slot_add",<party>,<slot>,<value to add>),
##Input : The party name, the slot, the value to add (negative number to subtract)
##Output: None, slot value will be changed
("party_slot_add",
[(store_script_param,":cur_party",1),
(store_script_param,":this_slot",2),
(store_script_param,":adder",3),
(party_get_slot,":num",":cur_party",":this_slot"),
(val_add,":num",":adder"),
(party_set_slot,":cur_party",":this_slot",":num"),
]
),


 
jik, thank you very much, man ) you got a big heart

unfortunatelly I can't use your advise because I've wrote no single script line in my whole life and all this "set-", "get-", "try-" are a mystery for me )) don't count me too dumb please, I'm just out of programming )

I've already found the way to get the similar result - I'll assign different recruits types to different villages and everything will go in similar way i hope
and thank you one more time for wasting your time on such a boring noobs like me and others ) it's really a big deal
 
Back
Top Bottom