Tournament script.

正在查看此主题的用户

Pisces

Veteran
To learn to ropes of scripting I decided to script the tournament rules. If you've played the 1257 AD mod then it's tournament lets you keep all your equipment aside from body armour (for team colours). Now this is nice, fun and probably realistic that you'd use your own equipment, but of course it is incrediably boring as every tournament is the same, which happens to also be the same as most battles you've played, and you're likely going to win because your good with your equipment. So I decided to let you use your equipment but impose rules on tournaments (ie no horse, ranged only, no polearms, must have polearm/horse, etc.). So to test the basic principle of works, I replace the set tournament items script with this:
("set_items_for_tournament",
    [
      (store_script_param, ":armor_item_begin", 1),
      (assign, ":weapon1", itp_type_one_handed_wpn),
      (assign, ":weapon2", itp_type_shield),
      (assign, ":weapon3", itp_type_crossbow),
      (assign, ":weapon4", itp_type_bolts),
      (try_for_range, ":i_ep", 0, 32),
      (mission_tpl_entry_clear_override_items, "mt_arena_melee_fight", ":i_ep"),
      (store_div, ":cur_team", ":i_ep", 8 ),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_horse"),
      (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),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":i_ep", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon1"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
      (ge, ":selected_weapon", 0),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_sword"),
      (try_end),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":i_ep", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon2"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
      (ge, ":selected_weapon", 0),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_arena_shield_red"),
      (try_end),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":i_ep", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon3"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
      (ge, ":selected_weapon", 0),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_crossbow"),
      (try_end),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":i_ep", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon4"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
      (ge, ":selected_weapon", 0),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
      (try_end),
      (try_end),
    ]),
Obviously there should be a for loop enclosing the thing, but I decided to do the basics first as I wasn't sure of the exact commands for the enclosing for loop. Basically you are guaranteed a practice horse, as a simple test to make sure the override item is working (and it did), you are then guaranteed 1 melee weapon, 1 shield, 1 crossbow & 1 set of bolts (also worked with 1 exception to the bolts), I copied the armour script from the original script (almost worked), and if you had one of those types of equipment it would let you use that too (this is where things really broke down).

Ok, so first Halmar failed miseribly, everyone was naked, on horseback, had 1 crossbow, 1 shield (occasionally overridden with a different one), 1 practice sword (occasionally overridden) but no bolts, instead they had a second random melee weapon. I initially thought it was a total bust but then in the third round I had all my player's equipment exactly right and I came to realise, aside from the armour the script was worked perfectly but we were getting a random person's equipment, and for some reason it considered bolts to be any weapon it so desired. VERY entertaining tournament, I had no idea what side anyone was on and had no idea what type of melee weapons I'd get.

Then I went to Jekala for further testing, this time people had armour, but not the standard armour they are supposed to have, it was skins vs. mail hauberk vs. that leather armour the green team used to wear in previous versions vs. the yellow padded cloth type armour. Everyone had 1 of each type of weapon and they were replaced with their own inventory if they had them, except it wasn't their own inventory it was someone else's (blast! why did I buy that nice simitiar?). Also incrediably fun, but I think the skins might have had trouble against the mail hauberks.

Finally to Dhirim, where everyone was where the correct era of tournament armour, had weapons like Jekala, and was generally quite good, aside from the random person's equipment and while they had the right style of tournament armour, the green team had been replaced by the white team.

Clearly I am unlocking some previous settings with the armour, once thought buried only to be unlocked by the foolish patterings of a newbie scriptor. But if anyone can point to the places where the script went wrong, I might have a few typos in there too. Also, I highly recommend using this muddled code to reinvigourate your tournament playing experience.
 
Ok, I had another look at it and solved some of my original stupidness. Fixed the armour and now understand how store_script_param works. I also understand that it wasn't actually giving people different people's weapons but were giving them the weapons of the first 32 troops in the troop file. I've now fixed it so they DO get tournament participant's weapons, but they are still randomised. I'm sure the answer is somewhere in the game_menu file but I currently have a mind blank. Here is my updated script, less fun than the original but more correct. If someone can solve my current mind blank then please do.

  ("set_items_for_tournament",
    [
      (assign, ":weapon1", itp_type_one_handed_wpn),
      (assign, ":weapon2", itp_type_shield),
      (assign, ":weapon3", itp_type_crossbow),
      (assign, ":weapon4", itp_type_bolts),
      (try_for_range, ":i_ep", 0, 32),
      (troop_get_slot, ":pisces", "trp_temp_array_a", ":i_ep"),
      (mission_tpl_entry_clear_override_items, "mt_arena_melee_fight", ":i_ep"),
      (store_div, ":cur_team", ":i_ep", :cool:,
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_horse"),
      (store_add, ":cur_shield_item", "itm_arena_shield_red", ":cur_team"),
      (store_add, ":cur_armor_item", "itm_arena_armor_red", ":cur_team"),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_armor_item"),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon1"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_sword"),
      (try_end),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":i_ep", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon2"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_shield_item"),
      (try_end),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":i_ep", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon3"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_crossbow"),
      (try_end),
      (assign, ":selected_weapon", -1),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":i_ep", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapon4"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
      (try_end),
      (try_end),
    ]),

-Pisces
 
hello man,

I don't wanna slow you down, but I wanna try tests on tournaments too and I wander if you could know how to make

tournaments exactly like in the 1257 AD mod.

because it is a really good and stable base to start tests...

si if you could post the way to set the tournamants like that for a good start, it would be great.
 
I'm not exactly sure, but try going into mission templates, down to arena_melee_fight (use find). Replace af_override_all with af_override_armor for the entries from 0 to 31. Then you don't need to change the tournament script but if you want to you could tone it down to this:

("set_items_for_tournament",
    [
      (try_for_range, ":i_ep", 0, 32),
      (mission_tpl_entry_clear_override_items, "mt_arena_melee_fight", ":i_ep"),
      (store_div, ":cur_team", ":i_ep", ,
      (store_add, ":cur_armor_item", "itm_arena_armor_red", ":cur_team"),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_armor_item"),
      (try_end)
  ]),

Changes to scripts.py are savegame compatable (as long as you don't change anything else). I'm not sure about changes to mission_templates, so you might like to start a new game just in case.

EDIT: And tell me if it works. If I'm wrong then it means my educated guess isn't as educated as I thought.
 
Ok, af_override_armor should be af_override_body and it does work. I've finally got the script working as intented, I still need to do some bug fixing but should be finished soon. It requires 3-4 changes:
1. Copy temp_array_c in the troop file & paste it underneath and rename it to d. This will unfortunately make the changes not compatible with earlier save-games; it is possible to do the script without making a new temp_array but you'll have to write that script yourself (unless someone asks nicely).

2. Open the game_menu.py file. Find "items_for_tournament" scroll up a couple of paragraphs and add the following line.
            (try_for_range, ":cur_index", 0, "$g_tournament_next_team_size"),
              (store_mul, ":cur_entry_point", ":cur_team", :cool:,
              (troop_get_slot, ":entry_offset", "trp_temp_array_c", ":cur_index"),
              (val_add, ":cur_entry_point", ":entry_offset"),
              (troop_get_slot, ":troop_no", "trp_temp_array_a", ":cur_slot"),
              (set_visitor, ":cur_entry_point", ":troop_no"),
              (troop_set_slot, "trp_temp_array_d", ":cur_entry_point", ":troop_no"),#added by Pisces
              (val_add, ":cur_slot", 1),
            (try_end),
Go back down a couple of paragraphs and replace it with this, and make the appropriate changes you want.
          (try_begin),
            (eq, ":town_original_faction", "fac_kingdom_1"),
            #Swadia: Suno, Praven, Uxhal, Dhirim?
            (store_mod, ":mod", ":town_index_within_faction", 4),
            (try_begin),
              (eq, ":mod", 0),
              #weapon1,weapon_1else,weapon_1else_2,weapon2,weapon3,weapon4,horse (-1=free). Weapon1else/2=itp_type as weapon1 is always used if there are none in inventory.Use :cur_shield_item for shield
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, itp_type_two_handed_wpn, 0, itm_english_shield_b, itm_lance, 0, itm_hunter),
            (else_try),
              (eq, ":mod", 1),
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, 100, 0, 0, 0, 0, 0, 0, "itm_arena_armor_red", "itm_tourney_helm_red"),
            (else_try),
              (eq, ":mod", 2),
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, 0, 100, 0, 0, 0, 0, 0, "itm_arena_armor_red", "itm_tourney_helm_red"),
            (else_try),
              (eq, ":mod", 3),
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, 80, 50, 20, 40, 0, 0, 0, "itm_arena_armor_red", "itm_tourney_helm_red"),
            (try_end),
          (else_try),
            (eq, ":town_original_faction", "fac_kingdom_2"),
            #Vaegirs: Reyvadin, Khudan, Curaw, Rivacheg?
            (store_mod, ":mod", ":town_index_within_faction", 4),
            (try_begin),
              (eq, ":mod", 0),
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, 80, 50, 20, 0, 0, 0, 0, "itm_arena_armor_red", "itm_steppe_helmet_red"),
            (else_try),
              (eq, ":mod", 1),
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, 50, 0, 0, 0, 20, 30, 0, "itm_arena_armor_red", "itm_steppe_helmet_red"),
            (else_try),
              (eq, ":mod", 2),
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, 0, 50, 0, 0, 20, 30, 0, "itm_arena_armor_red", "itm_steppe_helmet_red"),
            (else_try),
              (eq, ":mod", 3),
              (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, 80, 50, 20, 30, 0, 60, 0, "itm_arena_armor_red", "itm_steppe_helmet_red"),
            (try_end),
          (else_try),
            (eq, ":town_original_faction", "fac_kingdom_3"),
            #Khergit: Tulga, Halmar...Rest?
            (store_mod, ":mod", ":town_index_within_faction", 2),
            (try_begin),
              (eq, ":mod", 0),
              (call_script, "script_set_items_for_tournament", itm_practice_bow, itp_type_thrown, itp_type_crossbow, itm_sword_khergit_1, 0, 0,itm_hunter),
          (else_try),
              (eq, ":mod", 1),
              (call_script, "script_set_items_for_tournament", itm_practice_bow, itp_type_thrown, itp_type_crossbow, itm_sword_khergit_1, 0, 0, itm_hunter),
            (try_end),
          (else_try),
            (eq, ":town_original_faction", "fac_kingdom_4"),
            #Nords: Sargoth, Tihr, Wercheg.
            (store_mod, ":mod", ":town_index_within_faction", 3),
            (try_begin),
              (eq, ":mod", 0),
              (call_script, "script_set_items_for_tournament", 0, 0, 50, 80, 0, 0, 0, 0, "itm_arena_armor_red", -1),
            (else_try),
              (eq, ":mod", 1),
              (call_script, "script_set_items_for_tournament", 0, 0, 50, 80, 50, 0, 0, 0, "itm_arena_armor_red", -1),
            (else_try),
              (eq, ":mod", 2),
              (call_script, "script_set_items_for_tournament", 40, 0, 0, 100, 0, 0, 0, 0, "itm_arena_armor_red", -1),
            (try_end),
          (else_try),
            #Rhodoks
            (call_script, "script_set_items_for_tournament", itm_sword_medieval_b, itp_type_two_handed_wpn, 0, itm_english_shield_b, itm_lance, 0, -1),
          (try_end),
          (set_jump_mission, "mt_arena_melee_fight"),
          (jump_to_scene, ":arena_scene"),
          (change_screen_mission),
        ]),

3. Open script.py and add replace “set_items_for_tournments with:.
  ("set_items_for_tournament",
    [
      (store_script_param, ":weapon1", 1),
      (store_script_param, ":weapon_1else", 2),
      (store_script_param, ":weapon_1else_2", 3),
      (store_script_param, ":weapon2", 4),
      (store_script_param, ":weapon3", 5),
      (store_script_param, ":weapon4", 6),
      (store_script_param, ":horse", 7),
      (try_for_range, ":i_ep", 0, 32),
      (troop_get_slot, ":pisces", "trp_temp_array_d", ":i_ep"),
      (mission_tpl_entry_clear_override_items, "mt_arena_melee_fight", ":i_ep"),
#assign weapons & armor
      (store_div, ":cur_team", ":i_ep", :cool:,
      (store_add, ":cur_armor_item", "itm_arena_armor_red", ":cur_team"),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_armor_item"),
      (assign, ":selected_weapon", -1),
      (item_get_type, ":weapontype", ":weapon1"),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (eq, ":selected_weapon", -1),
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapontype"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (else_try),
        (ge, ":weapon_1else", 1),
        (eq, ":item_type", ":weapon_1else"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (else_try),
        (ge, ":weapon_1else_2", 1),
        (eq, ":item_type", ":weapon_1else_2"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon1"),
      (try_end),
      #add ammo for slot a
      (try_begin),
        (ge, ":selected_weapon", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", itp_type_crossbow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
        (eq, ":item_type", itp_type_bow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
        (eq, ":item_type", itp_type_pistol),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_musket),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_thrown),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
      (else_try),
        (item_get_type, ":item_type", ":weapon1"),
        (try_begin),
        (eq, ":item_type", itp_type_crossbow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
        (eq, ":item_type", itp_type_bow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
        (eq, ":item_type", itp_type_pistol),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_musket),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_thrown),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
      (try_end),
#preferably to be enclosed in a for loop.
      (try_begin),
        (ge, ":weapon2", 1),
        (item_get_type, ":weapontype", ":weapon2"),
        (assign, ":selected_weapon", -1),
        (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (eq, ":selected_weapon", -1),
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", ":weapontype"),
          (assign, ":selected_weapon", ":cur_item"),
        (try_end),
        (try_end),
        (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
        (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon2"),
        (try_end),
      #add ammo for ranged weapon in slot b
        (try_begin),
        (ge, ":selected_weapon", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", itp_type_crossbow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
          (eq, ":item_type", itp_type_bow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
          (eq, ":item_type", itp_type_pistol),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_musket),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_thrown),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
        (else_try),
        (item_get_type, ":cur_item", ":weapon1"),
        (try_begin),
          (eq, ":item_type", itp_type_crossbow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
          (eq, ":item_type", itp_type_bow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
          (eq, ":item_type", itp_type_pistol),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_musket),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_thrown),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":weapon3", 1),
        (item_get_type, ":weapontype", ":weapon3"),
        (assign, ":selected_weapon", -1),
        (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", ":weapontype"),
          (eq, ":selected_weapon", -1),
          (assign, ":selected_weapon", ":cur_item"),
        (try_end),
        (try_end),
        (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
        (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon3"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":weapon4", 1),
        (item_get_type, ":weapontype", ":weapon4"),
        (assign, ":selected_weapon", -1),
        (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", ":weapontype"),
          (eq, ":selected_weapon", -1),
          (assign, ":selected_weapon", ":cur_item"),
        (try_end),
        (try_end),
        (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
        (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon4"),
        (try_end),
      (try_end),
      (assign, ":selected_weapon", -1),
#Not getting i_ep's horse atm.
      (try_begin),
        (troop_get_inventory_slot, ":cur_item", ":pisces", :cool:,
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":horse", 0),
        (else_try),
        (eq, ":item_type", ":horse"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (ge, ":horse", 1),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":horse"),
      (try_end),
      (try_end),
    ]),
Horses still don’t replace properly, and shields won’t have appropriate colours yet. What each slot means is quickly described in the changes to the game_menu file.
4. (optional) As explained previously, go to the arena_melee_fight template in mission_templates.py. Replace af_override_all with af_override_body|af_override_weapons|af_override_horse for i_ep 0 to 31.
 
Any chance for me to use this as a script to store the player's weapons when he mounts a horse and change them? When he unmounts, he'll receive his old weapons again.
 
Sure, go ahead. Don't bother giving me credit, I think things get too confusing when you have to worry about who to give credit to. This applys to anyone reading this thread too, you may freely use this script without asking permission or giving credit.
 
Updated script, works almost perfectly, but heros with javelins will use their original 7, then they will run around with their fists and not change to their additional javelins or even their sword unless severly harrassed.

  # script_set_items_for_tournament
  # Input: Weapon1, Weapon_1else(itp_type), weapon_1else_2 (itp_type), weapon2, weapon3 (team-coloured shield if applicible, not ranged), weapon4 (not ranged), horse (-1=free).
  # Output: none (sets mt_arena_melee_fight items)
#currently incompatible with giving heros extra javelins & the AI.
  ("set_items_for_tournament",
    [
      (store_script_param, ":weapon1", 1),
      (store_script_param, ":weapon_1else", 2),
      (store_script_param, ":weapon_1else_2", 3),
      (store_script_param, ":weapon2", 4),
      (store_script_param, ":weapon3", 5),
      (store_script_param, ":weapon4", 6),
      (store_script_param, ":horse", 7),
      (try_for_range, ":i_ep", 0, 32),
      (troop_get_slot, ":pisces", "trp_temp_array_d", ":i_ep"),
      (mission_tpl_entry_clear_override_items, "mt_arena_melee_fight", ":i_ep"),
#assign weapons & armor
      (store_div, ":cur_team", ":i_ep", :cool:,
      (store_add, ":cur_shield_item", "itm_arena_shield_red", ":cur_team"),
      (store_add, ":cur_armor_item", "itm_arena_armor_red", ":cur_team"),
      (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_armor_item"),
      (assign, ":selected_weapon", -1),
      (item_get_type, ":weapontype", ":weapon1"),
      (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (eq, ":selected_weapon", -1),
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", ":weapontype"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (else_try),
        (ge, ":weapon_1else", 1),
        (eq, ":item_type", ":weapon_1else"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (else_try),
        (ge, ":weapon_1else_2", 1),
        (eq, ":item_type", ":weapon_1else_2"),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon1"),
      (try_end),
      #add ammo for slot a
      (try_begin),
        (ge, ":selected_weapon", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
        (eq, ":item_type", itp_type_crossbow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
        (eq, ":item_type", itp_type_bow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
        (eq, ":item_type", itp_type_pistol),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_musket),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_thrown),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
      (else_try),
        (item_get_type, ":item_type", ":weapon1"),
        (try_begin),
        (eq, ":item_type", itp_type_crossbow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
        (eq, ":item_type", itp_type_bow),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
        (eq, ":item_type", itp_type_pistol),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_musket),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
        (eq, ":item_type", itp_type_thrown),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
      (try_end),
#preferably to be enclosed in a for loop.
      (try_begin),
        (ge, ":weapon2", 1),
        (item_get_type, ":weapontype", ":weapon2"),
        (assign, ":selected_weapon", -1),
        (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (eq, ":selected_weapon", -1),
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", ":weapontype"),
          (assign, ":selected_weapon", ":cur_item"),
        (try_end),
        (try_end),
        (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
        (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon2"),
        (try_end),
      #add ammo for ranged weapon in slot b
        (try_begin),
        (ge, ":selected_weapon", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", itp_type_crossbow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
          (eq, ":item_type", itp_type_bow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
          (eq, ":item_type", itp_type_pistol),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_musket),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_thrown),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
        (else_try),
        (item_get_type, ":cur_item", ":weapon1"),
        (try_begin),
          (eq, ":item_type", itp_type_crossbow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bolts"),
        (else_try),
          (eq, ":item_type", itp_type_bow),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"),
        (else_try),
          (eq, ":item_type", itp_type_pistol),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_musket),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_cartridges"),
        (else_try),
          (eq, ":item_type", itp_type_thrown),
          (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_javelin"),
        (try_end),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":weapon3", 1),
        (item_get_type, ":weapontype", ":weapon3"),
        (assign, ":selected_weapon", -1),
        (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", ":weapontype"),
          (eq, ":selected_weapon", -1),
          (assign, ":selected_weapon", ":cur_item"),
        (try_end),
        (try_end),
        (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
        (else_try),
      #add correct coloured shield.
        (eq, ":weapontype", itp_type_shield),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_shield_item"),
        (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon3"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":weapon4", 1),
        (item_get_type, ":weapontype", ":weapon4"),
        (assign, ":selected_weapon", -1),
        (try_for_range, ":cur_slot", 0, 4),#equipment slots
        (troop_get_inventory_slot, ":cur_item", ":pisces", ":cur_slot"),
        (ge, ":cur_item", 0),
        (item_get_type, ":item_type", ":cur_item"),
        (try_begin),
          (eq, ":item_type", ":weapontype"),
          (eq, ":selected_weapon", -1),
          (assign, ":selected_weapon", ":cur_item"),
        (try_end),
        (try_end),
        (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
        (else_try),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":weapon4"),
        (try_end),
      (try_end),
      (assign, ":selected_weapon", -1),
#Not getting i_ep's horse atm.
      (try_begin),
        (troop_get_inventory_slot, ":cur_item", ":pisces", :cool:,
        (ge, ":cur_item", 0),
        (try_begin),
        (eq, ":horse", 0),
        (else_try),
        (eq, ":selected_weapon", -1),
        (assign, ":selected_weapon", ":cur_item"),
        (try_end),
      (try_end),
      (try_begin),
        (ge, ":selected_weapon", 0),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":selected_weapon"),
      (else_try),
        (ge, ":horse", 1),
        (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":horse"),
      (try_end),
      (try_end),
    ]),
 
后退
顶部 底部