sub EvaluateRuleChain
namespace push
namespace local RULES , %4
set !chain %1
set !findid %2
set !findtype %3
set !loot_match #FALSE
set !level %4 + 1
str del !chain 1 9
set !tempchain #STRRES
set !present_logic #FALSE
set !logic_toggle #FALSE
set !present_logic_operator N/A
namespace copy RULE* from local RULES
set !tempindex !rulechain_index . !tempchain - 1
set !chainindex 0
EvaluateRuleChain_loop1:
set !temp_rule RULECHAIN_rule , !tempchain , _ , !chainindex
set !temp_rule ! . !temp_rule
set !temp_ruleindex RULEITEM , !temp_rule
if RULECHAIN notin ! . !temp_ruleindex
{
if !temp_rule in AND_OR_NOT
{
if !temp_rule = NOT
set !logic_toggle ! !logic_toggle
else
set !present_logic_operator !temp_rule
}
else
{
gosub EvaluateRule !temp_rule !findid !findtype
gosub CheckLogic
}
}
else
{
gosub EvaluateRuleChain ! . !temp_ruleindex !findid !findtype !level
gosub CheckLogic
}
set !chainindex !chainindex + 1
if !chainindex <= !tempindex
goto EvaluateRuleChain_loop1
set !loot_match !present_logic
namespace copy loot_match to local RULES
set #RESULT !present_logic
namespace clear
namespace pop
return #RESULT