WB Coding Forcing lords to recruit kingdom culture troops (Diplomacy 4.2)

Currently viewing this thread:

Skuthai

Veteran
WBWF&SNWVC
In diplomacy there is a script for choosing a kindom culture to make your lords recruit same type of troops (ie all nord or all khergit etc.). However script does not work. After choosing my kingdom culture as vaegir, only the city guards changed to vaegir troops. Lords continued to recruit their native troops for their parties. Interestingly, when awarding castles/cities to lords they reinforce the garrisons with vaegir troops. I have a little bit of modding knowledge (but a noob in coding) so i downloaded the source code and looked to module.scripts but couldn't find the problem. Any help would be very appreciated.

Here is the cf_reinforcement_party code from module.scripts.py
Code:
  # script_cf_reinforce_party
  # Input: arg1 = party_no,
  # Output: none
  # Adds reinforcement to party according to its type and faction
  # Called from several places, simple_triggers for centers, script_hire_men_to_kingdom_hero_party for hero parties
  ("cf_reinforce_party",
    [
      (store_script_param_1, ":party_no"),

      (store_faction_of_party, ":party_faction", ":party_no"),
      ##diplomacy start+ The party faction may be changed for culture, but we still need the original
      (assign, ":real_party_faction", ":party_faction"),
      ##diplomacy end+
      (party_get_slot, ":party_type",":party_no", slot_party_type),

#Rebellion changes begin:
      (try_begin),
        (eq, ":party_type", spt_kingdom_hero_party),
        (party_stack_get_troop_id, ":leader", ":party_no"),
        (troop_get_slot, ":party_faction",  ":leader", slot_troop_original_faction),
        ##diplomacy start+ Use player culture for companions and spouse (and any hypothetical non-hero mercenaries)
        (eq, ":real_party_faction", "fac_player_supporters_faction"),
        (is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
        (this_or_next|is_between, ":leader", companions_begin, companions_end),
        (this_or_next|troop_slot_eq, "trp_player", slot_troop_spouse, ":leader"),
           (neg|is_between, ":leader", heroes_begin, heroes_end),
        (assign, ":party_faction", "$g_player_culture"),
        ##diplomacy end+
      (try_end),
#Rebellion changes end

      (try_begin),
        (eq, ":party_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":town_lord", ":party_no", slot_town_lord),
        (try_begin),
        ##diplomacy begin
          (is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
          (assign, ":party_faction", "$g_player_culture"),

          (try_begin), #debug
            (eq, "$cheat_mode", 1),
            (str_store_party_name, s11, ":party_no"),
            (display_message, "@pt in {s11}"),
          (try_end),

        (else_try),
        ##diplomacy end
          (gt, ":town_lord", 0),
          (troop_get_slot, ":party_faction", ":town_lord", slot_troop_original_faction),
        (else_try),
          (party_get_slot, ":party_faction", ":party_no", slot_center_original_faction),
        (try_end),
      (try_end),
      ##diplomacy start+ Player culture cleanup (do this once here, instead of separately for each type)
      (try_begin),
         (gt, ":real_party_faction", "fac_commoners"),
         (this_or_next|eq, ":real_party_faction", "fac_player_faction"),
         (this_or_next|eq, ":real_party_faction", "fac_player_supporters_faction"),
         (eq, ":real_party_faction", "$players_kingdom"),
         (neg|is_between, ":party_faction", npc_kingdoms_begin, npc_kingdoms_end),
         (is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
         (assign, ":party_faction", "$g_player_culture"),
      (try_end),
      ##diplomacy end+

      (faction_get_slot, ":party_template_a", ":party_faction", slot_faction_reinforcements_a),
      (faction_get_slot, ":party_template_b", ":party_faction", slot_faction_reinforcements_b),
      (faction_get_slot, ":party_template_c", ":party_faction", slot_faction_reinforcements_c),

      (assign, ":party_template", 0),
      (store_random_in_range, ":rand", 0, 100),
        ##diplomacy start+
      #Implement "quality vs. quantity" in a way that is visible in player battles
      #(previously, quantity increased party size, but quality only had an effect
      #in autocalc battles)
      (try_begin),
        (is_between, ":real_party_faction", kingdoms_begin, kingdoms_end),
        (faction_get_slot, ":dplmc_quality", ":real_party_faction", dplmc_slot_faction_quality),
        (val_clamp, ":dplmc_quality", -3, 4),
        (val_add, ":rand", ":dplmc_quality"),
        (val_clamp, ":rand", 0, 101),
      (try_end),
      ##diplomacy end+
      (try_begin),
        (this_or_next|eq, ":party_type", spt_town),
        (eq, ":party_type", spt_castle),  #CASTLE OR TOWN
        (try_begin),
          (lt, ":rand", 65),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (assign, ":party_template", ":party_template_b"),
        (try_end),
      (else_try),
        (eq, ":party_type", spt_kingdom_hero_party),
        (try_begin),
          (lt, ":rand", 50),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (lt, ":rand", 75),
          (assign, ":party_template", ":party_template_b"),
        (else_try),
          (assign, ":party_template", ":party_template_c"),
        (try_end),
      (else_try),
      ##diplomacy start+ Reinforcements for patrols
        (eq, ":party_type", spt_patrol),
        (try_begin),
           (lt, ":rand", 65),
           (assign, ":party_template", ":party_template_a"),
        (else_try),
           (assign, ":party_template", ":party_template_b"),
        (try_end),
      ##diplomacy end+
      (try_end),

      (try_begin),
        (gt, ":party_template", 0),
        (party_add_template, ":party_no", ":party_template"),
      (try_end),
  ]),

Edit: I am using vanilla Diplomacy4.2+pbod0.92
 
Solution
Thanks, it seems to be working for both the lords and garrisons. Here is how i did it:

Just put "#" infront of the red lines and it should look like this:
("cf_reinforce_party",
[
(store_script_param_1, ":party_no"),

(store_faction_of_party, ":party_faction", ":party_no"),
##diplomacy start+ The party faction may be changed for culture, but we still need the original
(assign, ":real_party_faction", ":party_faction"),
##diplomacy end+
(party_get_slot, ":party_type",":party_no", slot_party_type),

#Rebellion changes begin:
##(try_begin),
##(eq, ":party_type", spt_kingdom_hero_party),
##(party_stack_get_troop_id, ":leader", ":party_no")...

Skuthai

Veteran
WBWF&SNWVC
Thanks, it seems to be working for both the lords and garrisons. Here is how i did it:

Just put "#" infront of the red lines and it should look like this:
("cf_reinforce_party",
[
(store_script_param_1, ":party_no"),

(store_faction_of_party, ":party_faction", ":party_no"),
##diplomacy start+ The party faction may be changed for culture, but we still need the original
(assign, ":real_party_faction", ":party_faction"),
##diplomacy end+
(party_get_slot, ":party_type",":party_no", slot_party_type),

#Rebellion changes begin:
##(try_begin),
##(eq, ":party_type", spt_kingdom_hero_party),
##(party_stack_get_troop_id, ":leader", ":party_no"),
##(troop_get_slot, ":party_faction", ":leader", slot_troop_original_faction),
##diplomacy start+ Use player culture for companions and spouse (and any hypothetical non-hero mercenaries)
##(eq, ":party_faction", "fac_player_supporters_faction"),
##(is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
##(this_or_next|is_between, ":leader", companions_begin, companions_end),
##(this_or_next|troop_slot_eq, "trp_player", slot_troop_spouse, ":leader"),
## (neg|is_between, ":leader", heroes_begin, heroes_end),
##(assign, ":party_faction", "$g_player_culture"),
##diplomacy end+
##(try_end),
#Rebellion changes end


(try_begin),
(eq, ":party_faction", "fac_player_supporters_faction"),
(party_get_slot, ":town_lord", ":party_no", slot_town_lord),
(try_begin),
##diplomacy begin
(is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
(assign, ":party_faction", "$g_player_culture"),

##(try_begin), #debug
##(eq, "$cheat_mode", 1),
##(str_store_party_name, s11, ":party_no"),
##(display_message, "@pt in {s11}"),
##(try_end),

##(else_try),
##diplomacy end
##(gt, ":town_lord", 0),
## (troop_get_slot, ":party_faction", ":town_lord", slot_troop_original_faction),
##(else_try),
##(party_get_slot, ":party_faction", ":party_no", slot_center_original_faction),

(try_end),
(try_end),
##diplomacy start+ Player culture cleanup (do this once here, instead of separately for each type)
(try_begin),
(gt, ":real_party_faction", "fac_commoners"),
(this_or_next|eq, ":real_party_faction", "fac_player_faction"),
(this_or_next|eq, ":real_party_faction", "fac_player_supporters_faction"),
(eq, ":real_party_faction", "$players_kingdom"),
(neg|is_between, ":party_faction", npc_kingdoms_begin, npc_kingdoms_end),
(is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
(assign, ":party_faction", "$g_player_culture"),
(try_end),
##diplomacy end+
 
Upvote 0
Solution
Top Bottom