As you know, I made a trigger that fixes the problem of CKO troops sometimes not showing up with all the weapons they're given. Unfortunately, it becomes outdated every time a new version of the mod comes out, and I'm back to square one. To put a stop to it, I decided to create this thread. Sure, I'd just post it on the CKO thread in a perfect world, but after seeing people repeatedly fail to find a lot of this kind of stuff and ask for the same questions time and time again, I came to think a new thread is easier to find.
The reason the script stops working is that the troop order in troops.txt changes with every new version. The troops trp_player_knight, trp_player_sergeant, trp_player_knight_save and trp_player_sergeant_save are used in it, so you'll have to find their correct IDs all the time.
Once upon a time, my script was like this:
The operation troop_get_inventory_slot means you're looking for the item a troop has in a particular inventory slot. The commands using it always go like " 1541 3 [item to return] [troop] [slot no] " (with leading and trailing spaces). Which means the second number after " 1541 3 " strings refers to the troop. There are 4 such commands in the code with the first referring to trp_player_knight, 2nd trp_player_knight_save, 3rd trp_player_sergeant and the last trp_player_sergeant_save.
Whatever hex version of the script you have, you can follow these steps if it stops working:
- Search for these " 1541 3 "s in the script and jot down the 2nd numbers after these, because they must be replaced. Don't forget the order.
- Open up troops.txt and search for these 4 troops (their verbose versions starting with trp, not the numbers). Subtract 3 from the line no you find the results on and then divide it by 7, which gives you the troop ID. Then add the ID to 360287970189639680.
- Replace the old numbers in the script with the new ones you just calculated.
- ???
- Profit!
The reason the script stops working is that the troop order in troops.txt changes with every new version. The troops trp_player_knight, trp_player_sergeant, trp_player_knight_save and trp_player_sergeant_save are used in it, so you'll have to find their correct IDs all the time.
Once upon a time, my script was like this:
-25.000000 0.000000 0.000000 0 45 2071 1 1224979098644774912 1718 2 1224979098644774913 1224979098644774912 4 0 31 2 1224979098644774913 360287970189639960 1540 2 1224979098644774914 1224979098644774913 6 3 1224979098644774915 0 1224979098644774914 1541 3 1224979098644774916 360287970189639960 1224979098644774915 32 2 1224979098644774916 0 1570 2 1224979098644774917 1224979098644774916 4 0 33 3 1224979098644774917 2 11 1729 2 1224979098644774912 1224979098644774916 1774 2 1224979098644774912 1224979098644774916 3 0 3 0 6 3 1224979098644774918 0 4 1541 3 1224979098644774919 360287970189640716 1224979098644774918 4 0 32 2 1224979098644774919 0 2120 3 1224979098644774920 1224979098644774918 1 1779 3 1224979098644774912 1224979098644774919 1224979098644774920 3 0 3 0 5 0 31 2 1224979098644774913 360287970189640004 1540 2 1224979098644774914 1224979098644774913 6 3 1224979098644774915 0 1224979098644774914 1541 3 1224979098644774916 360287970189640004 1224979098644774915 32 2 1224979098644774916 0 1570 2 1224979098644774917 1224979098644774916 4 0 33 3 1224979098644774917 2 11 1729 2 1224979098644774912 1224979098644774916 1774 2 1224979098644774912 1224979098644774916 3 0 3 0 6 3 1224979098644774918 0 4 1541 3 1224979098644774919 360287970189640717 1224979098644774918 4 0 32 2 1224979098644774919 0 2120 3 1224979098644774920 1224979098644774918 1 1779 3 1224979098644774912 1224979098644774919 1224979098644774920 3 0 3 0 3 0
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent"),
(agent_get_troop_id, ":troop", ":agent"),
(try_begin),
(eq, ":troop", "trp_player_knight"),
(troop_get_inventory_capacity, ":inv_cap", ":troop"),
(try_for_range, ":cur_inv_slot_no", 0, ":inv_cap"),
(troop_get_inventory_slot, ":cur_inv_item", "trp_player_knight", ":cur_inv_slot_no"),
(gt, ":cur_inv_item", 0),
(item_get_type, ":cur_item_type", ":cur_inv_item"),
(try_begin),
(is_between, ":cur_item_type", 2, 11), # if it's a weapon or shield
(agent_has_item_equipped, ":agent", ":cur_inv_item"),
(agent_unequip_item, ":agent", ":cur_inv_item"),
(try_end),
(try_end),
(try_for_range, ":cur_eq_slot", 0, 4),
(troop_get_inventory_slot, ":cur_inv_item_to_eq", "trp_player_knight_save", ":cur_eq_slot"),
(try_begin),
(gt, ":cur_inv_item_to_eq", 0),
(store_add, ":cur_eq_slot_plus_one", ":cur_eq_slot", 1),
(agent_equip_item, ":agent", ":cur_inv_item_to_eq", ":cur_eq_slot_plus_one"),
(try_end),
(try_end),
(else_try),
(eq, ":troop", "trp_player_sergeant"),
(troop_get_inventory_capacity, ":inv_cap", ":troop"),
(try_for_range, ":cur_inv_slot_no", 0, ":inv_cap"),
(troop_get_inventory_slot, ":cur_inv_item", "trp_player_sergeant", ":cur_inv_slot_no"),
(gt, ":cur_inv_item", 0),
(item_get_type, ":cur_item_type", ":cur_inv_item"),
(try_begin),
(is_between, ":cur_item_type", 2, 11), # if it's a weapon or shield
(agent_has_item_equipped, ":agent", ":cur_inv_item"),
(agent_unequip_item, ":agent", ":cur_inv_item"),
(try_end),
(try_end),
(try_for_range, ":cur_eq_slot", 0, 4),
(troop_get_inventory_slot, ":cur_inv_item_to_eq", "trp_player_sergeant_save", ":cur_eq_slot"),
(try_begin),
(gt, ":cur_inv_item_to_eq", 0),
(store_add, ":cur_eq_slot_plus_one", ":cur_eq_slot", 1),
(agent_equip_item, ":agent", ":cur_inv_item_to_eq", ":cur_eq_slot_plus_one"),
(try_end),
(try_end),
(try_end),
]),
[
(store_trigger_param_1, ":agent"),
(agent_get_troop_id, ":troop", ":agent"),
(try_begin),
(eq, ":troop", "trp_player_knight"),
(troop_get_inventory_capacity, ":inv_cap", ":troop"),
(try_for_range, ":cur_inv_slot_no", 0, ":inv_cap"),
(troop_get_inventory_slot, ":cur_inv_item", "trp_player_knight", ":cur_inv_slot_no"),
(gt, ":cur_inv_item", 0),
(item_get_type, ":cur_item_type", ":cur_inv_item"),
(try_begin),
(is_between, ":cur_item_type", 2, 11), # if it's a weapon or shield
(agent_has_item_equipped, ":agent", ":cur_inv_item"),
(agent_unequip_item, ":agent", ":cur_inv_item"),
(try_end),
(try_end),
(try_for_range, ":cur_eq_slot", 0, 4),
(troop_get_inventory_slot, ":cur_inv_item_to_eq", "trp_player_knight_save", ":cur_eq_slot"),
(try_begin),
(gt, ":cur_inv_item_to_eq", 0),
(store_add, ":cur_eq_slot_plus_one", ":cur_eq_slot", 1),
(agent_equip_item, ":agent", ":cur_inv_item_to_eq", ":cur_eq_slot_plus_one"),
(try_end),
(try_end),
(else_try),
(eq, ":troop", "trp_player_sergeant"),
(troop_get_inventory_capacity, ":inv_cap", ":troop"),
(try_for_range, ":cur_inv_slot_no", 0, ":inv_cap"),
(troop_get_inventory_slot, ":cur_inv_item", "trp_player_sergeant", ":cur_inv_slot_no"),
(gt, ":cur_inv_item", 0),
(item_get_type, ":cur_item_type", ":cur_inv_item"),
(try_begin),
(is_between, ":cur_item_type", 2, 11), # if it's a weapon or shield
(agent_has_item_equipped, ":agent", ":cur_inv_item"),
(agent_unequip_item, ":agent", ":cur_inv_item"),
(try_end),
(try_end),
(try_for_range, ":cur_eq_slot", 0, 4),
(troop_get_inventory_slot, ":cur_inv_item_to_eq", "trp_player_sergeant_save", ":cur_eq_slot"),
(try_begin),
(gt, ":cur_inv_item_to_eq", 0),
(store_add, ":cur_eq_slot_plus_one", ":cur_eq_slot", 1),
(agent_equip_item, ":agent", ":cur_inv_item_to_eq", ":cur_eq_slot_plus_one"),
(try_end),
(try_end),
(try_end),
]),
The operation troop_get_inventory_slot means you're looking for the item a troop has in a particular inventory slot. The commands using it always go like " 1541 3 [item to return] [troop] [slot no] " (with leading and trailing spaces). Which means the second number after " 1541 3 " strings refers to the troop. There are 4 such commands in the code with the first referring to trp_player_knight, 2nd trp_player_knight_save, 3rd trp_player_sergeant and the last trp_player_sergeant_save.
Whatever hex version of the script you have, you can follow these steps if it stops working:
- Search for these " 1541 3 "s in the script and jot down the 2nd numbers after these, because they must be replaced. Don't forget the order.
- Open up troops.txt and search for these 4 troops (their verbose versions starting with trp, not the numbers). Subtract 3 from the line no you find the results on and then divide it by 7, which gives you the troop ID. Then add the ID to 360287970189639680.
- Replace the old numbers in the script with the new ones you just calculated.
- ???
- Profit!