Could anyone please tell me how to make this script work?

Users who are viewing this thread

bakabaka

Recruit
I wanna add female fighters (aka Shieldmaidens) to Nord faction, and make them recruitable in Nord villages (along side the male "Nord Recruits").

Found a script here http://forums.taleworlds.com/index.php?topic=74552.5 but it does not work at all. Help please? Thanx a lot : )

("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"),
(try_for_range, ":villages", villages_begin,villages_end), #~ CD - Male/Female Begin ~
        (store_random_in_range, ":random", 1,10),
        (assign, ":nord_faction", "fac_kingdom_4"),
        (store_faction_of_party, ":villages"),
        (eq, ":villages", ":nord_faction"),
        (try_begin),
            (ge, ":random", 5),
            (assign, ":volunteer_troop", "trp_nord_recruit"),
            (party_set_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
        (else_try),
            (lt, ":random", 5),
            (assign, ":volunteer_troop", "trp_nord_female_warrior"),
            (party_set_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
        (try_end),
    (try_end), #~ CD - Male/Female End ~

    (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"),
    ]),
 
Be more specific please.Do you create trp_nord_female_warrior in module_troops.py ? Do you enabled the troop ?

If you want me to help you be more explicit.
 
SWAT_1990 said:
Be more specific please.Do you create trp_nord_female_warrior in module_troops.py ? Do you enabled the troop ?

If you want me to help you be more explicit.

Yes, I created nord_female_warrior in module_troops.py

 
["nord_female_warrior","Shieldmaiden","Shieldmaidens",tf_female|tf_mounted|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_boots|tf_guarantee_helmet|tf_guarantee_shield|tf_guarantee_ranged,0,0,fac_kingdom_4,
  [(itm_nordic_warlord_helmet,imod_thick),(itm_mail_shirt,imod_thick),(itm_mail_boots,imod_thick),(itm_mail_mittens,imod_thick),(itm_sword_viking_3,imod_tempered),(itm_war_spear,imod_balanced),(itm_tab_shield_round_c,imod_reinforced),(itm_darts,imod_large_bag),(itm_warhorse,imod_heavy)],
def_attrib|str_12|agi_21|int_12|cha_12|level(21),wp(120),knows_ironflesh_7|knows_power_strike_7|knows_power_throw_7|knows_riding_5|knows_athletics_5|knows_shield_7,0x000000003f001007000000000000000000000000001c00000000000000000000, 0x000000000000000136db6db6db6db6db00000000001db6db0000000000000000],


I am fairly new with the ModuleSytem, but I have created 2 custom troops, 3 NPCs, and some new weapons / heraldic armors before. They all worked.

I also put together many different stuffs from various OSPs I found in the forum (like Diplomacy, Pre-Battle Orders & Deployment Kits, Bodyguards/Escorts, Shield bashing, Spear bracing, Formations, View all items ingame, Dynamic Kingdom Troop Tree Presentation, Guarantee all melee weapons, Randomize companion vassals' banner)... And my custom module is working fine.

Only this one doesn't work (after compiling, I ran the game twice and tested, but could only get Nord Recruits in nord villages. That script is supposed to give 50% chance of getting nord female warriors).
 
First, the whole script is wrote quite strange (probably would have more sense if placed in update_volunteer_troops_in_village).

Problems:
1)
Code:
        (assign, ":nord_faction", "fac_kingdom_4"),
        (store_faction_of_party, ":villages"),
        (eq, ":villages", ":nord_faction"),
should be:
Code:
        (assign, ":nord_faction", "fac_kingdom_4"),
        (store_faction_of_party,  ":faction",":villages"),
        (eq, ":faction", ":nord_faction"),
2)
Code:
           (party_set_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
should be:
Code:
           (party_set_slot,  ":villages", slot_center_volunteer_troop_type,":volunteer_troop"),
this line is pointless anyway, you are randomizing troops each visit, so there is no point in storing it;

Anyway, it could be much simpler:
Code:
   #~ CD - Male/Female Begin ~
      (try_begin),
        (store_faction_of_party,  ":faction","$current_town"),
        (eq, ":faction", "fac_kingdom_4"),
        (store_random_in_range, ":random", 1,10),
        (try_begin),
            (ge, ":random", 5),
            (assign, ":volunteer_troop", "trp_nord_recruit"),
        (else_try),
            (assign, ":volunteer_troop", "trp_nord_female_warrior"),
        (try_end),
      (try_end),
      #~ CD - Male/Female End ~

 
I fixed the script like you suggest, and it works

  ("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),

##### Male/Female Nord Recruit Begin
  (try_for_range, ":villages", villages_begin,villages_end),
        (store_random_in_range, ":random", 1,10),
        (assign, ":nord_faction", "fac_kingdom_4"),
        (store_faction_of_party,  ":faction",":villages"),
        (eq, ":faction", ":nord_faction"),
        (try_begin),
            (ge, ":random", 2),
            (assign, ":volunteer_troop", "trp_nord_recruit"),
            (party_set_slot,  ":villages", slot_center_volunteer_troop_type,":volunteer_troop"),
        (else_try),
            (lt, ":random", 2),
            (assign, ":volunteer_troop", "trp_nord_female_recruit"),
          (party_set_slot,  ":villages", slot_center_volunteer_troop_type,":volunteer_troop"),
        (try_end),
    (try_end),
##### Male/Female Nord Recruit 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),

Many many thanx :grin:
 
Well, now I can recruit both Nord Male and Female Recruits from Nord villages, but the AI Nord lords don't get the female ones. How do I change what kind of troops faction lords get?
 
Through the module_party_templates.py file:

Code:
  ("kingdom_4_reinforcements_a", "{!}kingdom_4_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_nord_footman,2,7),(trp_nord_recruit,2,4),(trp_nord_female_recruit,2,4)]),
  ("kingdom_4_reinforcements_b", "{!}kingdom_4_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_nord_huntsman,2,5),(trp_nord_archer,2,3),(trp_nord_footman,1,2)]),
  ("kingdom_4_reinforcements_c", "{!}kingdom_4_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_nord_warrior,3,5)]),
For example.
 
Back
Top Bottom