var proficient as number
var wpnFocus as number
var wpnEnhBon as number
var tripBon as number
var tripTemp as number
var disarmBon as number
var disarmTemp as number
foreach pick in hero where "IsWeapon.?"
proficient = 0
wpnFocus = 0
wpnEnhBon = 0
tripTemp = 0
disarmTemp = 0
~ No need to do anything if this weapon isn't equipped
if (eachpick.field[gIsEquip].value = 1) then
wpnEnhBon = eachpick.field[BonEnhance].value
~ Could this be a masterwork weapon?
if (wpnEnhBon = 0) then
~ Must have thingid.iMagWeapon tag to be masterwork
if (eachpick.tagis[thingid.iMagWeapon] <> 0) then
~ Check the actName field for "Masterwork" substring
if (pos("Masterwork",eachpick.field[actName].text) <> -1) then
wpnEnhBon = 1
~ Check the iCustSumm field for "Masterwork" substring
elseif (pos("Masterwork",eachpick.field[iCustSumm].text) <> -1) then
wpnEnhBon = 1
endif
endif
endif
~ What proficiency is required?
if (eachpick.tagcount[wProfReq.?] = 0) then
~ This weapon requires no particular proficiency
proficient = 1
~ Is hero proficient with just this weapon?
elseif (eachpick.heromatch[WepProf,WepProf,current] <> 0) then
proficient = 1
~ Is this weapon Exotic?
elseif (eachpick.tagis[wProfReq.Exotic] <> 0) then
~ If we got here, Hero is not proficient with
~ this Exotic weapon - nothing to do.
~ Is this weapon Martial?
elseif (eachpick.tagis[wProfReq.Martial] <> 0) then
~ Is Hero proficient with Martial weapons?
if (hero.tagis[Hero.ProfMart] <> 0) then
proficient = 1
endif
~ Is this weapon Simple?
elseif (eachpick.tagis[wProfReq.Simple] <> 0) then
~ Is Hero proficient with Simple weapons?
if (hero.tagis[Hero.ProfSimple] <> 0) then
proficient = 1
endif
~ Unexpected wProfReq tag
else
debug "Unexpected proficiency requirement (" & eachpick.tagids[wProfReq.?,";"] & ") for " & eachpick.livename
endif
~ Check for Weapon Proficiency
if (proficient = 1) then
~ Check for Weapon Focus
if (eachpick.tagis[Broadcast.WepFocus] <> 0) then
wpnFocus = 1
~Check for Greater Weapon Focus
if (eachpick.tagis[Broadcast.WepGrFoc] <> 0) then
wpnFocus += 1
endif
endif
else
~ Not proficient, lets levy a penalty
wpnFocus -= 4
endif
~ Check for Trip Property
if (eachpick.tagis[wSpecial.Trip] <> 0) then
tripTemp = wpnEnhBon + wpnFocus
if (tripTemp > tripBon) then
tripBon = tripTemp
endif
endif
~ Check for Disarm Property
if (eachpick.tagis[wSpecial.Disarm] <> 0) then
disarmTemp = wpnEnhBon + wpnFocus + 2
if (disarmTemp > disarmBon) then
disarmBon = disarmTemp
endif
endif
endif
nexteach
hero.child[manTrip].field[manCMB].value += tripBon
hero.child[manDisarm].field[manCMB].value += disarmBon