Senior Member
Join Date: May 2013
Posts: 240
|
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> 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 Code:
(count:hero#Classes.? >= 7)&(count:hero#CinNal.Cinea > 0)&(count:hero#CinNal.Nalayam > 0) Code:
~ Must be wielding both swords. doneif (hero.tagexpr[CinNal.Cinea & CinNal.Nalayam] <> 1) 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? |
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
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. |
#2 |
Senior Member
Join Date: May 2013
Posts: 240
|
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. |
#3 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
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) |
#4 |
Senior Member
Join Date: May 2013
Posts: 240
|
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! |
#5 |
|
|