I want to be able to have the ability to toggle a weapons capabilities during battle. So I could switch a throwing axe or javelin into a regular axe or spear by pressing a button. I did some testing with this in my star wars mod with the following code:
module_mission_templates.py
Note: I was only trying to test if this is possible, so the above code would need to be improved. Most likely we'd only want to be able to toggle the weapon we were wielding and we wouldn't want to hard-code weapon names but would probably use another slot on each weapon (or something like that) to tell what the alternative one was.
This code ALMOST works, I can start with only a "lightsaber pike", press the T key to switch it, and now I have a "throwing lightsaber pike". The problem is it ONLY seems to work if I go to my inventory screen... It does not automatically switch the weapon I have equipped, if I un-equip and re-equip the weapon it doesn't change, if I switch a weapon that is not equipped it doesn't change, etc.... So does anybody have an idea how to fix this so you wouldn't have to go to the inventory screen every time? Or at the minimum make it so you could toggle the weapon capabilities on the inventory screen itself ?
module_mission_templates.py
Code:
SW - toggle_weapon_capabilities
common_toggle_weapon_capabilities = (0, 0, 0, [
(key_clicked, key_t)
],
[
(get_player_agent_no, ":player_agent"),
(agent_is_alive, ":player_agent"),
(display_message, "@attempting to switch weapon capabilities..."),
(try_begin),
(agent_has_item_equipped, ":player_agent", "itm_lightsaber_green_pike"),
#(agent_get_wielded_item, ":handone", ":player_agent", 0),
#(agent_get_wielded_item, ":handtwo", ":player_agent", 1),
(try_for_range, ":slot_no", 0, 4),
#(troop_get_inventory_slot, ":item", "trp_player",":slot_no"),
(troop_get_inventory_slot, ":item", "$g_player_troop",":slot_no"), #since custom commander is integrated
(try_begin),
(eq, ":item", "itm_lightsaber_green_pike"),
(troop_set_inventory_slot, "trp_player", ":slot_no", "itm_force_throw_lightsaber_green_pike"),
(display_message, "@weapon capabilities were switched."),
(try_end),
(try_end),
(else_try),
(agent_has_item_equipped, ":player_agent", "itm_force_throw_lightsaber_green_pike"),
(try_for_range, ":slot_no", 0, 4),
#(troop_get_inventory_slot, ":item", "trp_player",":slot_no"),
(troop_get_inventory_slot, ":item", "$g_player_troop",":slot_no"), #since custom commander is integrated
(try_begin),
(eq, ":item", "itm_force_throw_lightsaber_green_pike"),
(troop_set_inventory_slot, "trp_player", ":slot_no", "itm_lightsaber_green_pike"),
(display_message, "@weapon capabilities were switched."),
(try_end),
(try_end),
(try_end),
])
Note: I was only trying to test if this is possible, so the above code would need to be improved. Most likely we'd only want to be able to toggle the weapon we were wielding and we wouldn't want to hard-code weapon names but would probably use another slot on each weapon (or something like that) to tell what the alternative one was.
This code ALMOST works, I can start with only a "lightsaber pike", press the T key to switch it, and now I have a "throwing lightsaber pike". The problem is it ONLY seems to work if I go to my inventory screen... It does not automatically switch the weapon I have equipped, if I un-equip and re-equip the weapon it doesn't change, if I switch a weapon that is not equipped it doesn't change, etc.... So does anybody have an idea how to fix this so you wouldn't have to go to the inventory screen every time? Or at the minimum make it so you could toggle the weapon capabilities on the inventory screen itself ?