Okay, shopping is done, dinner is cooked and eaten, dishes have been dealt with, and now here's the code.
The Mechanic I currently have set up looks like this (after some compositing into a single screenshot):
In addition, it has a fairly simple eval script that runs at Final Phase 100:
Code:
doneif (hero.tagis[source.WiSRules] = 0)
~ We're an NPC, and subject to feat taxes, so we're done
doneif (hero.tagis[WiSRules.PayFeatTax] <> 0)
~ Check if we're a Kapenia Dancer, and bail out if not
doneif (hero.tagcount[ClassVary.arMagKapen] = 0)
perform hero.child[fwsWepFoc].assign[thing.skipprereq]
All that really does is tell it to ignore the pre-reqs.
Meanwhile, the eval script for Weapon Focus, running at Post-Levels 10000, is as follows:
Code:
~ If we're disabled, do nothing
doneif (tagis[Helper.FtDisable] <> 0)
~if we haven't chosen anything yet, just get out now
doneif (field[usrChosen1].ischosen + tagis[GTarget.?] = 0)
~get the wFtrGroup tag from our choice or GTarget tag
if (tagis[GTarget.?] <> 0) then
perform this.pulltags[GTarget.?,wFtrGroup]
else
perform field[usrChosen1].chosen.pulltags[wFtrGroup.?]
endif
~if we didn't find a wFtrGroup tag, there's nothing more we can do
doneif (tagis[wFtrGroup.?] = 0)
~ Get the list of weapons in the group.
var searchexp as string
searchexp = tagids[wFtrGroup.?,"|"]
~ Tag the hero has having weapon focus for each weapon
~ in order to satisfy pre-requisites for feats that
~ require weapon focus with a specific weapon.
foreach thing in BaseWep where searchexp
if (eachthing.tagis[WepFocus.?] <> 0) then
perform hero.assignstr[eachthing.tagids[WepFocus.?, ","]]
endif
nexteach
~ Iterate through the weapons currently in the hero's possession
~ and apply the bonus to those that the hero is proficient with.
foreach pick in hero from BaseWep
var proceed as number
proceed = 0
~ Must be part of this weapon group.
if (eachpick.tagmatch[wFtrGroup,wFtrGroup,initial] <> 0) then
proceed += 1
endif
~ Hero must be proficient with the weapon.
if (eachpick.tagcount[Helper.Proficient] <> 0) then
proceed += 1
endif
~ Yay, passed both tests. Award them their shiny +1.
if (proceed > 1) then
perform eachpick.assign[Broadcast.WepFocus]
endif
nexteach
~ Finally, tag the hero as having group weapon focus.
var boundary as number
var group as string
boundary = pos(searchexp, ".") + 1
group = mid(searchexp, boundary, length(searchexp))
perform hero.assignstr["WepGFoc." & group]
The end result on my test Kapenia Dancer looks like this:
The attack bonus appears to be correct. Under World is Square rules, all heros get Weapon Finesse automatically on light weapons, hence the dex mod in the attack bonus. And the weapon focus is applied to the scarf, but not the unarmed strike.
The only problem is that the Weapon Focus feat remains in an unselected state instead of selected. It
should look like this:
Ideally, it would also be impossible to change the assignment away from Flails, since the PC is supposed to get this specific one, not their choice of any. That's all I really need to do -- set the state of usrChosen1 to the correct value and then turn it off.