Associate villages to town?

Users who are viewing this thread

swasta

Regular
On the vanilla map, each town has 3 belonging villages, I mean, when that town is fallen, 3 more villages (and always the same 3) will also fall to the winning faction. If I'm creating new towns and villages, how do I set up such association?
 
It does it automatically.  It assigns villages to the closest castle or town and if the town or castle falls, the villages fall to the other side as well.
 
and how do you assign Towns and Castles to factions in the first place?

Couldn't find it on the board. Just one post witch didn't get an answer until the dude who made it postet that he knew now and didn't need an answer anymore  :wink:

Thanks in advance
 
In module_scripts.py
Look for something like this, its under the game start script(the first script, but it is a very long script):

Code:
      (call_script, "script_give_center_to_lord", "p_town_1",  "trp_kingdom_1_lord"),
      (call_script, "script_give_center_to_lord", "p_town_2",  "trp_knight_3_1"),
      (call_script, "script_give_center_to_lord", "p_town_3",  "trp_kingdom_4_lord"),
      (call_script, "script_give_center_to_lord", "p_town_4",  "trp_knight_1_3"),
      (call_script, "script_give_center_to_lord", "p_town_5",  "trp_knight_1_4"),
      (call_script, "script_give_center_to_lord", "p_town_6",  "trp_knight_1_1"),
      (call_script, "script_give_center_to_lord", "p_town_7",  "trp_knight_1_2"),
      
      (call_script, "script_give_center_to_lord", "p_town_8",  "trp_kingdom_5_lord"),
      (call_script, "script_give_center_to_lord", "p_town_9",  "trp_knight_5_3"),
      (call_script, "script_give_center_to_lord", "p_town_10", "trp_kingdom_2_lord"),
      (call_script, "script_give_center_to_lord", "p_town_11", "trp_knight_5_4"),
      (call_script, "script_give_center_to_lord", "p_town_12", "trp_knight_5_1"),
      (call_script, "script_give_center_to_lord", "p_town_13", "trp_knight_5_2"),
      (call_script, "script_give_center_to_lord", "p_town_14", "trp_kingdom_3_lord"),

      (call_script, "script_give_center_to_lord", "p_zendar", "trp_zendar_lord"),


      (call_script, "script_give_center_to_faction_aux", "p_castle_1", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_2", "fac_kingdom_5"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_3", "fac_kingdom_5"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_4", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_5", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_6", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_7", "fac_kingdom_2"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_8", "fac_kingdom_5"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_9", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_10", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_11", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_mousillon", "fac_mousillon"),
      
      (call_script, "script_give_center_to_faction_aux", "p_castle_12", "fac_kingdom_3"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_13", "fac_kingdom_5"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_14", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_15", "fac_kingdom_4"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_16", "fac_kingdom_1"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_17", "fac_kingdom_2"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_18", "fac_kingdom_5"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_19", "fac_kingdom_3"),
      (call_script, "script_give_center_to_faction_aux", "p_castle_20", "fac_kingdom_3"),

So all you have to do is click on find and search for (call_script, "script_give_center_to_lord", "p_town_1", to find the place.
 
Thanks.

Now is there a list wich shows what castle has what number?

Like this, bu for castles:

#  town_1  Sargoth    #plain
#  town_2  Tihr        #steppe
#  town_3  Veluca      #steppe
#  town_4  Suno        #plain
#  town_5  Jelkala    #plain
#  town_6  Praven      #plain
#  town_7  Uxkhal      #plain
#  town_8  Reyvadin    #plain
#  town_9  Khudan      #snow
#  town_10  Tulga      #steppe
#  town_11  Curaw      #snow
#  town_12  Wercheg    #plain
#  town_13  Rivacheg    #plain
#  town_14  Halmar      #steppe
 
Isn't it possible to associate villages to towns and castles manually? I didn't really looked into it, but I suppose there should be a way of doing this.
 
Here are some native uses in module_scripts (well I have modified the game start one so that one of my parties didnt have any villages associated with it so it's not exactly native):

Code:
#in the script game_start
# fill_village_bound_centers
    #pass 1: Give one village to each castle and town
      (try_for_range, ":cur_center", walled_centers_begin, walled_centers_end),
		(neq, ":cur_center", "p_fortress_monastery"),
        (assign, ":min_dist", 999999),
        (assign, ":min_dist_village", -1),
        (try_for_range, ":cur_village", villages_begin, villages_end),
          (store_distance_to_party_from_party, ":cur_dist", ":cur_village", ":cur_center"),
          (lt, ":cur_dist", ":min_dist"),
          (assign, ":min_dist", ":cur_dist"),
          (assign, ":min_dist_village", ":cur_village"),
        (try_end),
        (party_set_slot, ":min_dist_village", slot_village_bound_center, ":cur_center"),
        (store_faction_of_party, ":town_faction", ":cur_center"),
        (call_script, "script_give_center_to_faction_aux", ":min_dist_village", ":town_faction"),
      (try_end),
      
    #pass 2: Give other villages to closest town.
      (try_for_range, ":cur_village", villages_begin, villages_end),
        (neg|party_slot_ge, ":cur_village", slot_village_bound_center, 1), #skip villages which are already bound.
        (assign, ":min_dist", 999999),
        (assign, ":min_dist_town", -1),
        (try_for_range, ":cur_town", towns_begin, towns_end),
          (store_distance_to_party_from_party, ":cur_dist", ":cur_village", ":cur_town"),
          (lt, ":cur_dist", ":min_dist"),
          (assign, ":min_dist", ":cur_dist"),
          (assign, ":min_dist_town", ":cur_town"),
        (try_end),
        (party_set_slot, ":cur_village", slot_village_bound_center, ":min_dist_town"),
        (store_faction_of_party, ":town_faction", ":min_dist_town"),
        (call_script, "script_give_center_to_faction_aux", ":cur_village", ":town_faction"),
      (try_end),


Code:
# script_give_center_to_faction_aux
  # Input: arg1 = center_no, arg2 = faction
  ("give_center_to_faction_aux",
    [
      (store_script_param_1, ":center_no"),
      (store_script_param_2, ":faction_no"),

      (store_faction_of_party, ":old_faction", ":center_no"),
      (party_set_faction, ":center_no", ":faction_no"),

      (party_get_slot, ":old_town_lord", ":center_no", slot_town_lord),
      (party_set_slot, ":center_no", slot_town_lord, stl_unassigned),

      (try_begin),
        (party_set_banner_icon, ":center_no", 0),#Removing banner
      (try_end),

      (call_script, "script_update_faction_notes", ":old_faction"),
      (call_script, "script_update_faction_notes", ":faction_no"),
      (call_script, "script_update_center_notes", ":center_no"),
      (try_begin),
        (ge, ":old_town_lord", 0),
        (call_script, "script_update_troop_notes", ":old_town_lord"),
      (try_end),

      (try_for_range, ":other_center", centers_begin, centers_end),
        (party_slot_eq, ":other_center", slot_village_bound_center, ":center_no"),
        (call_script, "script_give_center_to_faction_aux", ":other_center", ":faction_no"),
      (try_end),
  ]),

Code:
# script_assign_lords_to_empty_centers
  # Input: none
  # Output: none
  ("assign_lords_to_empty_centers",
   [(try_for_range, ":cur_center", centers_begin, centers_end),
      (party_get_slot, ":center_lord", ":cur_center", slot_town_lord),
      (this_or_next|eq, ":center_lord", stl_unassigned),
      (eq, ":center_lord", stl_rejected_by_player),
    
      (store_faction_of_party, ":center_faction", ":cur_center"),
      (is_between, ":center_faction", kingdoms_begin, kingdoms_end),
      (neg|faction_slot_eq, ":center_faction", slot_faction_leader, "trp_player"),

      (assign, ":best_lord", -1),
      (assign, ":best_lord_score", -1),
      (try_begin),
        (eq, ":center_lord", stl_unassigned),
        (try_begin),
          (eq, "$players_kingdom", ":center_faction"),
          (assign, ":best_lord", stl_reserved_for_player),
          (call_script, "script_calculate_troop_score_for_center", "trp_player", ":cur_center"),
          (assign, ":best_lord_score", reg0),
        (try_end),
      (try_end),
    
      (try_for_range, ":cur_troop", kingdom_heroes_begin, kingdom_heroes_end),
        (troop_slot_eq, ":cur_troop", slot_troop_occupation, slto_kingdom_hero),
        (store_troop_faction, ":troop_faction", ":cur_troop"),
        (eq, ":troop_faction", ":center_faction"),

        (call_script, "script_calculate_troop_score_for_center", ":cur_troop", ":cur_center"),
        (assign, ":score", reg0),

        (gt, ":score", ":best_lord_score"),
        (assign, ":best_lord_score", ":score"),
        (assign, ":best_lord", ":cur_troop"),
      (try_end),
      (try_begin),
        (ge, ":best_lord", 0),
        (str_store_party_name, s1, ":cur_center"),
        (str_store_troop_name, s2, ":best_lord"),
        (call_script, "script_give_center_to_lord", ":cur_center", ":best_lord"),
        (try_begin),
          (party_slot_eq, ":cur_center", slot_party_type, spt_castle),
          (try_for_range, ":cur_village", villages_begin, villages_end),
            (party_slot_eq, ":cur_village", slot_village_bound_center, ":cur_center"),
            (call_script, "script_give_center_to_lord", ":cur_village", ":best_lord"),
          (try_end),
        (try_end),
      (else_try),
        (eq, ":best_lord", stl_reserved_for_player),
        (party_set_slot, ":cur_center", slot_town_lord, stl_reserved_for_player),
        (try_begin),
          (party_slot_eq, ":cur_center", slot_party_type, spt_castle),
          (try_for_range, ":cur_village", villages_begin, villages_end),
            (party_slot_eq, ":cur_village", slot_village_bound_center, ":cur_center"),
            (party_set_slot, ":cur_village", slot_town_lord, stl_reserved_for_player),
          (try_end),
        (try_end),
      (try_end),
    (try_end),
    ]),
 
Back
Top Bottom