I would like to detect the type of a weapon, melee or ranged, equipped by a character. Why? When the character switches from melee to ranged weapon, he should retreat a bit from his target not to suffer thac0 penalty. The AI script documentation does not offer any access to inventory items - nothing returns ObjectType record of an item. The only way which may work is OR together more than 40 HasItemEquipped(...) lines for all BOWxx, XBOWxx and SLNGxx items. Ridiculous? Sure.
Q: Does anybody know the way of detecting equipped weapon type (melee, ranged) in the AI script?
Note: Hotkeys do not work well. Hotkey will be sent to all active characters after unpausing the game. This is not what we usually want.