Hello,
There's some great scripts for weapon-breaking around the forums. These have to hard-limit weapon breaking for AI so they don't end up unarmed. I didn't really like that solution, so I made this script to have my AI agents get sticks if they are unarmed.
TLDR; If an AI agent has no weapon, he'll sometimes get a Stick.
The bit about setting the crouching animation isn't working. Anyone have any advice on that?
Also its been a very long time since I wrote code for Warband. That last (try_begin) probably isn't necessary.
Cleaned up via Sebastian, thanks:
edit: Just realized this didn't check for horses, my mod doesn't use them. Fixed.
There's some great scripts for weapon-breaking around the forums. These have to hard-limit weapon breaking for AI so they don't end up unarmed. I didn't really like that solution, so I made this script to have my AI agents get sticks if they are unarmed.
TLDR; If an AI agent has no weapon, he'll sometimes get a Stick.
The bit about setting the crouching animation isn't working. Anyone have any advice on that?
Also its been a very long time since I wrote code for Warband. That last (try_begin) probably isn't necessary.
Cleaned up via Sebastian, thanks:
Code:
common_AI_pickup_weapon = (10, 0, 0, [],
[
(get_player_agent_no, ":player"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player"),#Don't auto-give to player. He can find his own!
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(agent_get_horse, ":check",":agent"),
(eq,":check",-1),#No horse here.
(agent_slot_eq, ":agent", slot_agent_is_running_away, 0),#Isn't fleeing the battle.
(agent_get_wielded_item, ":check", ":agent", 0),#AI usually only resorts to fisticuffs when unarmed.
(eq, ":check", -1),#No Weapon
(agent_get_attack_action, ":check", ":agent"),
(eq, ":check", 0),#Not Attacking
(agent_get_defend_action, ":check", ":agent"),
(eq, ":check", 0),#Not Defending
(store_random_in_range, ":check", 0, 5),#40% chance to get something every check, which is 10 seconds.
(try_begin),
(eq, ":check", 4), #Only found a rock.
(agent_equip_item, ":agent", itm_stones),
(agent_set_wielded_item, ":agent", itm_stones),
(agent_set_ammo, ":agent",itm_stones,1),
(agent_set_animation, ":agent", "anim_stand_to_crouch", 0),
(else_try),
(gt, ":check", 4), #Found a stick.
(agent_equip_item, ":agent", itm_wooden_stick),
(agent_set_wielded_item, ":agent", itm_wooden_stick),
(agent_set_animation, ":agent", "anim_stand_to_crouch", 0),
(try_end),
(try_end),
])
edit: Just realized this didn't check for horses, my mod doesn't use them. Fixed.