Thanks for your reply.
By the way, there is a bug(should be warband's bug) in pbod.
This is where the bug hides:
(ti_on_agent_spawn, 0, 0, [], [(store_trigger_param_1, ":agent"),(call_script, "script_weapon_use_classify_agent", ":agent")]), # On spawn, mark lancers, spears, horse archers using a slot. Force lancers to equip lances, horse archers to equip bows
The script weapon_use_classify_agent uses the operation agent_get_wielded_item to get what agents wield. However, agent_get_wielded_item only returns -1 when called immediately agent is spawned, which spoils all your weapon switch ai...
As I know, agent_get_wielded_item will return what agents wield from about 2 seconds after the battle starts.
In fact, the weapon switch ai totally doesn't work due to the small bug...