I'm working on a custom magic item set: a pair of scimitars (Cinea and Nalayam). They're scaling weapons that gain additional abilities based on the hero's level. That part is working fine.
Per the item description, the swords only get their scaling bonuses if you are wielding both at once. So I need some way to check that both weapons are equipped, and that check has to happen very early in the process so that tag expression in the bootstrap conditions for the weapon properties can check for it.
I began by defining a pair of custom tags in a .1st file, thus:
Then, each sword has a script that checks to see if it's in the PC's inventory and if so whether it's equipped or not. Here's the one for Cinea:
There's a duplicate one for Nalayam. The idea is that if the hero has tags for both Cinea and Nalayam, then they're both equipped. At First/1000, I can safely bootstrap a weapon property with a tag expression in the conditon field like this:
And in the eval script for enhancement bonuses at Post-Levels/5000, I can just:
As far as it goes, everything is working great -- with just one wrinkle that I can't seem to resolve: field[gIsEquip] does not get set to 1 when the weapon is equipped in the PC's off-hand.
If I equip Cinea in the PC's main hand, they get the CinNal.Cinea tag just fine. Ditto for Nalayam. But equipping one of them in the off-hand means that script fails.
I tried working around this by checking for the tags Hero.MainHand and Her
ffHand on the weapons. But those tags are not assigned at First/750, and I suspect they don't get assigned until long after the bootstrap phase is done. I'm not sure how to find out exactly when a tag gets assigned. I generated a timing report, which proved to be 196,740 lines of XML listing everything that ever happens, but I couldn't locate anything containing the phrase "MainHand" or "OffHand" that would tell me when that happens.
So ... I'm stuck. Is it a bug or a design choice that wielding something in your off hand does not update field[gIsEquip]? Is there some other approach I'm not seeing?
Per the item description, the swords only get their scaling bonuses if you are wielding both at once. So I need some way to check that both weapons are equipped, and that check has to happen very early in the process so that tag expression in the bootstrap conditions for the weapon properties can check for it.
I began by defining a pair of custom tags in a .1st file, thus:
Code:
<group id="CinNal" name="CinNal">
<value id="Cinea" name="Cinea"/>
<value id="Nalayam" name="Nalayam"/>
</group>
Then, each sword has a script that checks to see if it's in the PC's inventory and if so whether it's equipped or not. Here's the one for Cinea:
Code:
~ Runs at First/750
foreach pick in hero from BaseWep
~ The weapon has to be Cinea
if (eachpick.tagis[thingid.iCinea] <> 0) then
~ Hero must have the weapon equipped.
if (eachpick.field[gIsEquip].value <> 0) then
perform hero.assign[CinNal.Cinea]
endif
endif
nexteach
There's a duplicate one for Nalayam. The idea is that if the hero has tags for both Cinea and Nalayam, then they're both equipped. At First/1000, I can safely bootstrap a weapon property with a tag expression in the conditon field like this:
Code:
(count:hero#Classes.? >= 7)&(count:hero#CinNal.Cinea > 0)&(count:hero#CinNal.Nalayam > 0)
And in the eval script for enhancement bonuses at Post-Levels/5000, I can just:
Code:
~ Must be wielding both swords.
doneif (hero.tagexpr[CinNal.Cinea & CinNal.Nalayam] <> 1)
As far as it goes, everything is working great -- with just one wrinkle that I can't seem to resolve: field[gIsEquip] does not get set to 1 when the weapon is equipped in the PC's off-hand.
If I equip Cinea in the PC's main hand, they get the CinNal.Cinea tag just fine. Ditto for Nalayam. But equipping one of them in the off-hand means that script fails.
I tried working around this by checking for the tags Hero.MainHand and Her

So ... I'm stuck. Is it a bug or a design choice that wielding something in your off hand does not update field[gIsEquip]? Is there some other approach I'm not seeing?