• 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

Finding Equipped Weapon

Im working on a class that has a special ability to imbue any normal melee weapon with a magical enhancement. So at a certain level any melee weapon he/she picks up is treated as a +1 weapon. Now if the weapon already has a +1 the two values dont stack.

Im thinking that all I have to do is use the #enhancementbonus[pick, bonus] macro. however I dont know how to find the currently equipped weapon. Or am I complely way off base here?
 
A weapon equipped in the primary hand will have field[gIsEquip].value = 1, and one equipped in the off hand will have field[wIs2nd].value = 1.

For abilities that apply to equipped things, like the Fighter's armor training abilities, I've actually preferred to apply the effects to everything a character is carrying - that way, you can compare thing A to thing B without having to unequip both or having to mentally calculate the differences that would be sue to that ability. So, I would recommend having this ability apply itself to all weapons, regardless of whether they're equipped or not.

You're on the right track with the #enhancementbons[] macro - that would work if you could target a specific weapon. Here's how to apply a change to many things:

A little bit below the #enhancementbonus[] macro description in the reference information page is the list of General Modifers - there you'll see that enhancement is BonEnhance.

You can search through all the things added to a character with a foreach loop:

Code:
foreach pick in hero from BaseWep where "wCategory.Melee"

That will find all the melee weapons, now for the enhancement bonus:

Code:
eachpick.field[BonEnhance].value = maximum(eachpick.field[BonEnhance].value, 1)
which will set the enhancement bonus of that weapon to the maximum of the Enhancement bonus that's already there or 1. That way, you handle stacking properly - if a weapon already has an enhancement bonus, nothing will be changed, so you don't have to search specifically for non-magical weapons.

Putting that together (and closing the foreach loop):

Code:
foreach pick in hero from BaseWep where "wCategory.Melee"
  eachpick.field[BonEnhance].value = maximum(eachpick.field[BonEnhance].value, 1)
  nexteach

Timing: Post-Levels/10000, the default timing for a class ability, should work in this case. If it doesn't, please tell me - I haven't tested this.
 
Back
Top