~ Work out if we're equipped or, if we're the child of a magic item,
~ if our parent is equipped.
var result as number
result = field[gIsEquip].value
if (container.ishero = 0) then
  result += container.parent.field[gIsEquip].value
endif
~ If shield bash is being used, allow for use of shield and bash.
~ Remove shield AC if equipped, unless Improved Shield Bash exists.
if (result <> 0) then
  var ac as number
  if (container.ishero = 0) then
    if (container.parent.gizmo.child[wShldBash].field[gIsEquip].value <> 0) then
      perform hero.assign[Hero.ShldOffOK]
      if (#hasfeat[fImpShdBsh] = 0) then
        ac = container.parent.field[mAC].value + container.parent.field[BonEnhance].value
      endif
    elseif (container.parent.gizmo.child[wShldBash].field[wIs2nd].value <> 0) then
      perform hero.assign[Hero.ShldOffOK]
      if (#hasfeat[fImpShdBsh] = 0) then
        ac = container.parent.field[mAC].value + container.parent.field[BonEnhance].value
      endif
    endif
  elseif (hero.child[wShldBash].field[gIsEquip].value <> 0) then
    perform hero.assign[Hero.ShldOffOK]
    if (#hasfeat[fImpShdBsh] = 0) then
      ac = field[mAC].value
    endif
  elseif (hero.child[wShldBash].field[wIs2nd].value <> 0) then
    perform hero.assign[Hero.ShldOffOK]
    if (#hasfeat[fImpShdBsh] = 0) then
      ac = field[mAC].value
    endif
  endif
  hero.child[ArmorClass].field[tACShield].value -= ac
endif