WB Coding SOLVED: Warband - How to change tournament weapon with the official modsys?

正在查看此主题的用户

topazwarrior

Recruit
Hi everyone!
I currently tried my luck in modding Warband. I created a new faction along with some new cities. Everything seems good now, but I was hoping to edit tournament. I've search the .py files for quite a time now (~2 hours) and I can't seems to find where do I need to declare the tournament weapon's for each of my newly made cities. For example, I was hoping that participants would always spawn with Practice_Lance much in the same way like Praven does, but I can't find any reference in the code about that. Module_scripts seems to initiate arena_info, but it seems that it only manages team sizes. So my question is, which .py files contain such information and, preferably, in which section of the code?

Thanks for your help
 
解决方案
It should be set_items_for_tournament in module_scripts.

All I have is this. I don't see the declaration for each town, or maybe I am seeing it wrong.

插入代码块:
("set_items_for_tournament",
    [
      (store_script_param, ":horse_chance", 1),
      (store_script_param, ":lance_chance", 2),
      (store_script_param, ":sword_chance", 3),
      (store_script_param, ":axe_chance", 4),
      (store_script_param, ":bow_chance", 5),
      (store_script_param, ":javelin_chance", 6),
      (store_script_param, ":mounted_bow_chance", 7),
      (store_script_param, ":crossbow_sword_chance", :cool:,
      (store_script_param, ":armor_item_begin", 9),
      (store_script_param, ":helm_item_begin", 10),
      (store_add, ":total_chance", ":sword_chance", ":axe_chance"),
      (val_add, ":total_chance", ":crossbow_sword_chance"),
      (try_for_range, ":i_ep", 0, 32),
        (mission_tpl_entry_clear_override_items, "mt_arena_melee_fight", ":i_ep"),
        (assign, ":has_horse", 0),
        (store_div, ":cur_team", ":i_ep", :cool:,
        (try_begin),
          (store_random_in_range, ":random_no", 0, 100),
          (lt, ":random_no", ":horse_chance"),
          (assign, ":has_horse", 1),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_horse"),
        (try_end),
        (try_begin),
          (eq, ":has_horse", 1),
          (store_add, ":cur_total_chance", ":total_chance", ":lance_chance"),
          (val_add, ":cur_total_chance", ":javelin_chance"),
          (val_add, ":cur_total_chance", ":mounted_bow_chance"),
        (else_try),
          (store_add, ":cur_total_chance", ":total_chance", ":bow_chance"),
        (try_end),
        (store_random_in_range, ":random_no", 0, ":cur_total_chance"),
        (store_add, ":cur_shield_item", "itm_arena_shield_red", ":cur_team"),
        (try_begin),
          (val_sub, ":random_no", ":sword_chance"),
          (lt, ":random_no", 0),
          (try_begin),
            (store_random_in_range, ":sub_random_no", 0, 100),
            (lt, ":sub_random_no", 50),
            (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_sword"),
            (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_shield_item"),
#            (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"),
          (else_try),
            (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_heavy_practice_sword"),
          (try_end),
        (else_try),
          (val_sub, ":random_no", ":axe_chance"),
          (lt, ":random_no", 0),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_axe"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_shield_item"),
#         (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"),
        (else_try),
          (val_sub, ":random_no", ":crossbow_sword_chance"),
          (lt, ":random_no", 0),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_sword"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_crossbow"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
          (eq, ":has_horse", 0),
          (val_sub, ":random_no", ":bow_chance"),
          (lt, ":random_no", 0),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bow"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_dagger"),
        (else_try),
          (eq, ":has_horse", 1),
          (val_sub, ":random_no", ":lance_chance"),
          (lt, ":random_no", 0),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_lance"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_shield_item"),
#          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"),
        (else_try),
          (eq, ":has_horse", 1),
          (val_sub, ":random_no", ":javelin_chance"),
          (lt, ":random_no", 0),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_shield_item"),
#          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"),
        (else_try),
          (eq, ":has_horse", 1),
          (val_sub, ":random_no", ":mounted_bow_chance"),
          (lt, ":random_no", 0),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bow"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_dagger"),
        (try_end),
        (try_begin),
          (ge, ":armor_item_begin", 0),
          (store_add, ":cur_armor_item", ":armor_item_begin", ":cur_team"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_armor_item"),
        (try_end),
        (try_begin),
          (ge, ":helm_item_begin", 0),
          (store_add, ":cur_helm_item", ":helm_item_begin", ":cur_team"),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_helm_item"),
        (try_end),
      (try_end),
     ]),
 
由板主最后编辑:
点赞 0
It is connected with the mission template arena_melee_fight in module_mission_templates as noted in the comments which you probably didn't read :wink:
插入代码块:
  # script_set_items_for_tournament
  # Input: arg1 = horse_chance, arg2 = lance_chance (with horse only), arg3 = sword_chance, arg4 = axe_chance, arg5 = bow_chance (without horse only), arg6 = javelin_chance (with horse only), arg7 = mounted_bow_chance (with horse only), arg8 = crossbow_sword_chance, arg9 = armor_item_begin, arg10 = helm_item_begin
  # Output: none (sets mt_arena_melee_fight items)

Take also a look here:

Somebody wrote also this note here (leading to the other thread I linked above)

Somebody 说:
I've made a post a long time ago. Basically, the game arbitrarily assigns equipment to all the troops, passing the various items (or starting points, in the case of armor since they should be different colors) as parameters to the script, which you can modify in any way you want. Note however that the equipment assignment is based on the factional index - when a city is taken, that index is changed, so you might want to have specific cases for each city instead of a randomized number when deciding equipment.
 
点赞 0
Thank for the reply. I'm not a programmer so I'm having trouble to understand the post and how its code is organized. So, if the equipment is randomize based on faction, where are located the variables that tell which gears to pick from depending on the faction? The module_mission_template does have a list of 32 possible equipment, but I don't see where "faction index" check is. Wouldn't it be simpler to just create a function that compare "current town" and assign gear based on the index? For example, if current town = 23, assign practice_lance ?
 
点赞 0
点赞 0
解决方案
Okay that definitely makes everything more clear! It seems a bit odd that red armor pieces are assigned in this script while there's a entry point check for that, but I guess I'll tinker around. Thanks for the help!
 
点赞 0
It could be an initial assignment which gets then later overwritten again by the entry point check. So in case something is not working the troops have at least a red armour and are not fighting naked.
 
点赞 0
Oh and for future reference, if that might help anyone who is creating a new faction: I've noticed the script (the one that check for the town_original faction in module_game_menu) ends with sarranid tournament gears: turban helmet, a chance of horse, sword/bow/javelina. Basically, if the previous condition aren't met (if your newly made town isn't rhodok, swadia, vaegir, khergit or nord), you'll end up with sarranid as default gear for tournament. In order to circumvent this, you just need to expand the conditional branch. Personally, I added
插入代码块:
(eq, ":town_original_faction", "fac_kingdom_6"),
right before
插入代码块:
(store_mod, ":mod", ":town_index_within_faction", 2),
then I added a (else_try), so it basically looks like this:
插入代码块:
          #Sarranids
             (eq, ":town_original_faction", "fac_kingdom_6"),
             (store_mod, ":mod", ":town_index_within_faction", 2),
             (try_begin),
               (eq, ":mod", 0),
               (call_script, "script_set_items_for_tournament", 100, 40, 60, 0, 30, 30, 0, 0, "itm_arena_tunic_red", "itm_arena_turban_red"),
             (else_try),
               (call_script, "script_set_items_for_tournament", 50, 0, 60, 0, 30, 30, 0, 0, "itm_arena_tunic_red", "itm_arena_turban_red"),
             (try_end),
           (else_try),
           #my new faction. I provided an example here that any makes any town of my new faction starts with either axe+shield or sword+shield
           # (eq, ":town_original_faction", "fac_kingdom_7"),
           # (call_script, "script_set_items_for_tournament", 0, 0, 50, 80, 0, 0, 0, 0, "itm_arena_tunic_red", -1),
           (try_end),
           (jump_to_scene, ":arena_scene"),
           (change_screen_mission),
As you can see, I also provided a sample for your new faction (assuming its kingdom_7). So if your new tournament gears doesn't seems to appear even though there wasn't any error on the compiler, make sure to double check the conditional branch in module_game_menu (line 10258 if you're using the native module)
 
点赞 0
后退
顶部 底部