• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

field[gIsEquip] doesn't apply to off-hand?

wdmartin

Well-known member
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:

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 Hero.OffHand 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?
 
gIsEquip is the checkbox that means it's held in the main hand - keep looking for another field that means it's held in the off hand.

Also, debug the tags - you're looking for an "I'm equipped" tag that's applied no matter which hand the item is held in, since the better solution would be to have a single test that works regardless of which hand the character equips it in.
 
Ah, I found field[wMenuEquip] and checked whether that is 1 (main hand) or 2 (off hand) and that did the trick.

Everything seems to work now, though it's slightly wonky in some ways. If you un-equip one of the two swords, unlocked properties (flaming on Cinea, frost on Nalayam, holy on both) continue to show up on the weapons tab even though they have been removed from the weapon. Triggering a full evaluation of the rules clears them out. Enhancement bonuses and the threat range (from Keen) drop normally.

So that's slightly weird, but I don't think it's going to be a huge issue for my one PC. I'll just tell the player to leave the swords equipped and it should be fine.

Thanks for the assistance.
 
The off-hand field is wIs2nd. I don't remember what wMenuEquip is, but I do know that's not how we test "are we equipped" on our own weapons.

This is copied from the script on a Luck Blade:
Code:
      ~ If we're not equipped, get out
      doneif (field[gIsEquip].value + field[wIs2nd].value = 0)
 
Hmm! Well, I missed seeing that in the list. There were several hundred fields in there.

It works notably better than wMenuEuip -- unequipping one of the swords now makes all of the scaling bonuses go away. Thanks!
 
Back
Top