• Please note that we've updated the Mount & Blade II: Bannerlord save file system which requires you to take certain steps in order for your save files to be compatible with e1.7.1 and any later updates. You can find the instructions here.

WB [Code/Tuto] [Warband] [SP] Patrouilles, éclaireurs, fourageurs, etc...

Users who are viewing this thread

Encore un tutoriel inédit rédigé par mes soins avec du mauvais français.

Pour ce  tutoriel il vous faut:
-> Module system de warband
-> Notepad ou programme similaire d'édition du module system

Q: En quoi consiste ce tutoriel?
R: Ce tutoriel consiste à rajouter, comme le nom l'indique, les Patrouilles, éclaireurs, fourageurs, etc... qui ont été retiré du jeux.

Q: C'est difficile?
R: Si j'y suis arrivé, c'est que non.

Commençons:

Code:
  # script_create_kingdom_party_if_below_limit
  # Input: arg1 = faction_no, arg2 = party_type (variables beginning with spt_)
  # Output: reg0 = party_no
  ("create_kingdom_party_if_below_limit",
    [
      (store_script_param_1, ":faction_no"),
      (store_script_param_2, ":party_type"),

      (call_script, "script_count_parties_of_faction_and_party_type", ":faction_no", ":party_type"),
      (assign, ":party_count", reg0),
      
      (assign, ":party_count_limit", 0),

      (faction_get_slot, ":num_towns", ":faction_no", slot_faction_num_towns),

      (try_begin),
        (eq, ":party_type", spt_forager),
        (assign, ":party_count_limit", 1),
      (else_try),
        (eq, ":party_type", spt_scout),
        (assign, ":party_count_limit", 1),
      (else_try),
        (eq, ":party_type", spt_patrol),
        (assign, ":party_count_limit", 1),
      (else_try),
        (eq, ":party_type", spt_messenger),
        (assign, ":party_count_limit", 1),
      (else_try),
        (eq, ":party_type", spt_kingdom_caravan),
        (try_begin),
          (eq, ":num_towns", 0),
          (assign, ":party_count_limit", 0),
        (else_try),
          (eq, ":num_towns", 1),
          (assign, ":party_count_limit", 1),
        (else_try),
          (eq, ":num_towns", 2),
          (assign, ":party_count_limit", 3),
        (else_try),
          (assign, ":party_count_limit", 5),
        (try_end),
      (else_try),
        (eq, ":party_type", spt_prisoner_train),
        (assign, ":party_count_limit", 1),
      (try_end),
      
      (assign, reg0, -1),
      (try_begin),
        (lt, ":party_count", ":party_count_limit"),
        (call_script,"script_cf_create_kingdom_party", ":faction_no", ":party_type"),
      (try_end),
  ]),
  
  
  # script_cf_create_kingdom_party
  # Input: arg1 = faction_no, arg2 = party_type (variables beginning with spt_)
  # Output: reg0 = party_no
  ("cf_create_kingdom_party",
    [
      (store_script_param_1, ":faction_no"),
      (store_script_param_2, ":party_type"),
      
      (str_store_faction_name, s7, ":faction_no"),
      (assign, ":party_name_str", "str_no_string"),
      
      (faction_get_slot, ":reinforcements_a", ":faction_no", slot_faction_reinforcements_a),
      (faction_get_slot, ":reinforcements_b", ":faction_no", slot_faction_reinforcements_b),
      (faction_get_slot, ":reinforcements_c", ":faction_no", slot_faction_reinforcements_c),
      
      (try_begin),
        (eq, ":party_type", spt_forager),
        (assign, ":party_template", "pt_forager_party"),
        (assign, ":party_name_str", "str_s7_foragers"),
      (else_try),
        (eq, ":party_type", spt_scout),
        (assign, ":party_template", "pt_scout_party"),
        (assign, ":party_name_str", "str_s7_scouts"),
      (else_try),
        (eq, ":party_type", spt_patrol),
        (assign, ":party_template", "pt_patrol_party"),
        (assign, ":party_name_str", "str_s7_patrol"),
      (else_try),
        (eq, ":party_type", spt_kingdom_caravan),
        (assign, ":party_template", "pt_kingdom_caravan_party"),
        (assign, ":party_name_str", "str_s7_caravan"),
      (else_try),
        (eq, ":party_type", spt_messenger),
        (assign, ":party_template", "pt_messenger_party"),
        (assign, ":party_name_str", "str_s7_messenger"),
      (else_try),
        (eq, ":party_type", spt_raider),
        (assign, ":party_template", "pt_raider_party"),
        (assign, ":party_name_str", "str_s7_raiders"),
      (else_try),
        (eq, ":party_type", spt_prisoner_train),
        (assign, ":party_template", "pt_prisoner_train_party"),
        (assign, ":party_name_str", "str_s7_prisoner_train"),
      (try_end),
      
      (assign, ":result", -1),
      (try_begin),
        (try_begin),
          (eq, ":party_type", spt_kingdom_caravan),
          (call_script,"script_cf_select_random_town_with_faction", ":faction_no", -1),
          (set_spawn_radius, 0),
        (else_try), #not used at the moment
          (call_script,"script_cf_select_random_walled_center_with_faction", ":faction_no", -1),
          (set_spawn_radius, 1),
        (try_end),
        (assign, ":spawn_center", reg0),
        (is_between, ":spawn_center", centers_begin, centers_end),
        (spawn_around_party,":spawn_center",":party_template"),
        (assign, ":result", reg0),
        (party_set_faction, ":result", ":faction_no"),
        (try_begin),
          (eq, ":party_type", spt_kingdom_caravan),
          (party_set_slot, ":result", slot_party_home_center, ":spawn_center"),
          (party_set_slot, ":result", slot_party_last_traded_center, ":spawn_center"),
		(try_end),
        (party_set_slot, ":result", slot_party_type, ":party_type"),
        (party_set_slot, ":result", slot_party_ai_state, spai_undefined),
        (try_begin),
          (neq, ":party_name_str", "str_no_string"),
          (party_set_name, ":result", ":party_name_str"),
        (try_end),
        
        (try_begin),
          (eq, ":party_type", spt_forager),
          (party_add_template, ":result", ":reinforcements_a"),
        (else_try),
          (eq, ":party_type", spt_scout),
          (party_add_template, ":result", ":reinforcements_c"),
        (else_try),
          (eq, ":party_type", spt_patrol),
          (party_add_template, ":result", ":reinforcements_a"),
          (party_add_template, ":result", ":reinforcements_b"),
        (else_try),
          (eq, ":party_type", spt_kingdom_caravan),
          (try_begin),
            (eq, ":faction_no", "fac_player_supporters_faction"),
            (party_get_slot, ":reinforcement_faction", ":spawn_center", slot_center_original_faction),
            (faction_get_slot, ":reinforcements_b", ":reinforcement_faction", slot_faction_reinforcements_b),
          (try_end),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_set_ai_behavior,":result",ai_bhvr_travel_to_party),
          (party_set_ai_object,":result",":spawn_center"),
          (party_set_flags, ":result", pf_default_behavior, 1),
          (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_goods_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_set_slot, ":result", ":cur_goods_price_slot", average_price_factor),
          (try_end),
        (else_try),
          (eq, ":party_type", spt_messenger),
          (faction_get_slot, ":messenger_troop", ":faction_no", slot_faction_messenger_troop),
          (party_add_leader, ":result", ":messenger_troop"),
          (party_set_ai_behavior,":result",ai_bhvr_travel_to_party),
          (party_set_ai_object,":result",":spawn_center"),
          (party_set_flags, ":result", pf_default_behavior, 0),
        (else_try),
          (eq, ":party_type", spt_raider),
          (party_add_template, ":result", ":reinforcements_c"),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_add_template, ":result", "pt_raider_captives"),
        (else_try),
          (eq, ":party_type", spt_prisoner_train),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_add_template, ":result", ":reinforcements_a"),
          (try_begin),
            (call_script,"script_cf_faction_get_random_enemy_faction",":faction_no"),
            (store_random_in_range,":r",0,3),
            (try_begin),
              (lt, ":r", 1),
              (faction_get_slot, ":captive_reinforcements", reg0, slot_faction_reinforcements_b),
            (else_try),
              (faction_get_slot, ":captive_reinforcements", reg0, slot_faction_reinforcements_a),
            (try_end),
            (party_add_template, ":result", ":captive_reinforcements",1),
          (else_try),
            (party_add_template, ":result", "pt_default_prisoners"),
          (try_end),
        (try_end),
      (try_end),
      (ge, ":result", 0),
      (assign, reg0, ":result"),
  ]),
Remplacez le script create_kingdom_party_if_below_limit  et cf_create_kingdom_party par celui ci dessus

Rajoutez dans module_strings.py ces lignes tout en bas:
Code:
  ("s7_patrol","{s7} Patrol"),
  ("s7_scouts","{s7} Scouts"), 
  ("s7_foragers","{s7} Foragers"),
  ("s7_caravan","{s7} Caravan"),
  ("s7_messenger","{s7} Messenger"), 
  ("s7_prisoner_train","{s7} Prisoner Train"),

Dans module_constants.py
Remplacez:
Code:
##spt_caravan            = 1
spt_castle             = 2
spt_town               = 3
spt_village            = 4
##spt_forager            = 5
##spt_war_party          = 6
##spt_patrol             = 7
##spt_messenger          = 8
##spt_raider             = 9
##spt_scout              = 10
spt_kingdom_caravan    = 11
##spt_prisoner_train     = 12
spt_kingdom_hero_party = 13
##spt_merchant_caravan   = 14
spt_village_farmer     = 15
spt_ship               = 16
spt_cattle_herd        = 17
spt_bandit_lair       = 18
#spt_deserter           = 20
par:
Code:
##spt_caravan            = 1
spt_castle             = 2
spt_town               = 3
spt_village            = 4
spt_forager            = 5
spt_war_party          = 6
spt_patrol             = 7
spt_messenger          = 8
spt_raider             = 9
spt_scout              = 10
spt_kingdom_caravan    = 11
spt_prisoner_train     = 12
spt_kingdom_hero_party = 13
##spt_merchant_caravan   = 14
spt_village_farmer     = 15
spt_ship               = 16
spt_cattle_herd        = 17
spt_bandit_lair       = 18
#spt_deserter           = 20

Dans module_triggers.py remplacez la trigger #Kingdom Parties par celle ci:
Code:
#Kingdom Parties
  (1.0, 0, 0.0, [],
   [(try_for_range, ":cur_kingdom", kingdoms_begin, kingdoms_end),
      (faction_slot_eq, ":cur_kingdom", slot_faction_state, sfs_active),
      (neq, ":cur_kingdom", "fac_player_supporters_faction"),
      (try_begin),
        (store_random_in_range, ":random_no", 0, 100),
        (lt, ":random_no", 10),
        (call_script, "script_create_kingdom_party_if_below_limit", ":cur_kingdom", spt_forager),
      (try_end),
      (try_begin),
        (store_random_in_range, ":random_no", 0, 100),
        (lt, ":random_no", 10),
        (call_script, "script_create_kingdom_party_if_below_limit", ":cur_kingdom", spt_scout),
      (try_end),
      (try_begin),
        (store_random_in_range, ":random_no", 0, 100),
        (lt, ":random_no", 10),
        (call_script, "script_create_kingdom_party_if_below_limit", ":cur_kingdom", spt_patrol),
      (try_end),
      (try_begin),
        (store_random_in_range, ":random_no", 0, 100),
        (lt, ":random_no", 10),
        (call_script, "script_create_kingdom_party_if_below_limit", ":cur_kingdom", spt_messenger),
      (try_end),
      (try_begin),
        (store_random_in_range, ":random_no", 0, 100),
        (lt, ":random_no", 10),
        (call_script, "script_create_kingdom_party_if_below_limit", ":cur_kingdom", spt_kingdom_caravan),
      (try_end),
      (try_begin),
        (store_random_in_range, ":random_no", 0, 100),
        (lt, ":random_no", 10),
        (call_script, "script_create_kingdom_party_if_below_limit", ":cur_kingdom", spt_prisoner_train),
      (try_end),
    (try_end),
    ]),

C'est mal rédigé car j'ai la flemme de dire enlevez ces ## et non ces # alors je l'ai fait pour vous, que du copier coller. Je rédigerais mieux si l'envie m'en prends ou si c'est complètement incompréhensible.

 

bisthebis25

Knight
Au fait, je me demandais, ces armées-là... Que font-elles ? Je sais bien que les patrouilles engagent l'ennemi, mais le reste ? Les convois de prisonniers ? les fourrageurs ? les messagers ? les armées de guerres ? Ont-elles un objectif précis chacun, ou servent-elles juste à se battre et à décorer la map ?
 
Je les ais pas testé en profondeur mais les messagers vont de ville en ville, les patrouilles se débarrassent des bandits et les convois de prisonniers emmènent les prisonniers dans les villes.
 

bisthebis25

Knight
ils les prennent où les prisonniers ? (EDIT : ah, ce sont des renforts a ou b d'une faction ennemie aléatoire ><)
pour les war parties, forragers, scouts et raiders, tu as une idée ?
N'empêche, c'est ahurissant. tout ce qu'ils ont bougé :smile:
 
Regarde cette partie du code:
Code:
(try_begin),
          (eq, ":party_type", spt_forager),
          (party_add_template, ":result", ":reinforcements_a"),
        (else_try),
          (eq, ":party_type", spt_scout),
          (party_add_template, ":result", ":reinforcements_c"),
        (else_try),
          (eq, ":party_type", spt_patrol),
          (party_add_template, ":result", ":reinforcements_a"),
          (party_add_template, ":result", ":reinforcements_b"),
        (else_try),
          (eq, ":party_type", spt_kingdom_caravan),
          (try_begin),
            (eq, ":faction_no", "fac_player_supporters_faction"),
            (party_get_slot, ":reinforcement_faction", ":spawn_center", slot_center_original_faction),
            (faction_get_slot, ":reinforcements_b", ":reinforcement_faction", slot_faction_reinforcements_b),
          (try_end),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_set_ai_behavior,":result",ai_bhvr_travel_to_party),
          (party_set_ai_object,":result",":spawn_center"),
          (party_set_flags, ":result", pf_default_behavior, 1),
          (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_goods_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_set_slot, ":result", ":cur_goods_price_slot", average_price_factor),
          (try_end),
        (else_try),
          (eq, ":party_type", spt_messenger),
          (faction_get_slot, ":messenger_troop", ":faction_no", slot_faction_messenger_troop),
          (party_add_leader, ":result", ":messenger_troop"),
          (party_set_ai_behavior,":result",ai_bhvr_travel_to_party),
          (party_set_ai_object,":result",":spawn_center"),
          (party_set_flags, ":result", pf_default_behavior, 0),
        (else_try),
          (eq, ":party_type", spt_raider),
          (party_add_template, ":result", ":reinforcements_c"),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_add_template, ":result", "pt_raider_captives"),
        (else_try),
          (eq, ":party_type", spt_prisoner_train),
          (party_add_template, ":result", ":reinforcements_b"),
          (party_add_template, ":result", ":reinforcements_a"),
          (try_begin),
            (call_script,"script_cf_faction_get_random_enemy_faction",":faction_no"),
            (store_random_in_range,":r",0,3),
            (try_begin),
              (lt, ":r", 1),
              (faction_get_slot, ":captive_reinforcements", reg0, slot_faction_reinforcements_b),
            (else_try),
              (faction_get_slot, ":captive_reinforcements", reg0, slot_faction_reinforcements_a),
            (try_end),
            (party_add_template, ":result", ":captive_reinforcements",1),
          (else_try),
            (party_add_template, ":result", "pt_default_prisoners"),
          (try_end),
        (try_end),
      (try_end),
      (ge, ":result", 0),
      (assign, reg0, ":result"),
  ]),

Les différent groupes reçoivent des troupes qui viennent de party_templates:
Code:
("kingdom_1_reinforcements_a", "{!}kingdom_1_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_swadian_recruit,5,10),(trp_swadian_militia,2,4)]),
("kingdom_1_reinforcements_b", "{!}kingdom_1_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_swadian_footman,3,6),(trp_swadian_skirmisher,2,4)]),
("kingdom_1_reinforcements_c", "{!}kingdom_1_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_swadian_man_at_arms,2,4),(trp_swadian_crossbowman,1,2)]),

("kingdom_2_reinforcements_a", "{!}kingdom_2_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_vaegir_recruit,5,10),(trp_vaegir_footman,2,4)]),
("kingdom_2_reinforcements_b", "{!}kingdom_2_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_vaegir_veteran,2,4),(trp_vaegir_skirmisher,2,4),(trp_vaegir_footman,1,2)]),
("kingdom_2_reinforcements_c", "{!}kingdom_2_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_vaegir_horseman,2,3),(trp_vaegir_infantry,1,2)]),

Les parties de Messagers utilisent la troupe messager de chaque faction qui jusque là ne servaient à presque rien.

Je te laisse découvrir, moi j'ai la flemme... Mais il y as plein de truc qui ont été retiré du jeux, dont un système de création de bannière (presque fonctionnel).
 
Top Bottom