Formule AnyDice

https://anydice.com/program/19869

function: rha QUALITY:n SKILL:n
{
result: QUALITYd{0,1} + SKILLd{0,1}
}

function: aux QUALITY:n SKILL:n QUALITY_ROLL:s SKILL_ROLL:s
{
if QUALITY_ROLL = QUALITY
{
result: QUALITY_ROLL + [highest of SKILL_ROLL and SKILLd{0,1}]
}
else if SKILL_ROLL = SKILL
{
result: SKILL_ROLL + [highest of QUALITY_ROLL and QUALITYd{0,1}]
}
else if QUALITY_ROLL $TMP_GT$ SKILL_ROLL
{
result: QUALITY_ROLL + [highest of SKILL_ROLL and SKILLd{0,1}]
}
else
{
result: SKILL_ROLL + [highest of QUALITY_ROLL and QUALITYd{0,1}]
}
}

function: rha QUALITY:n SKILL:n adv
{
result: [aux QUALITY SKILL QUALITYd{0,1} SKILLd{0,1}]
}

\usage\
output [rha 4 3] named "normal roll"
output [rha 6 1 adv] named "ADV 6u1"
output [rha 5 2 adv] named "ADV 5u2"
output [rha 4 3 adv] named "ADV 4u3"