Member
Join Date: Oct 2013
Posts: 46
|
I have a race that uses shortbows and gains a +1 bonus to attack with them. It shows up fine for a normal shortbow or composite shortbow but when a magical shortbow is equipped the bonus +1 does not get added in. I'm very new to this and not sure if I did the eval right.
Here it is: ~find all our shortbows and add +1 to hit foreach pick in hero from BaseWep where "IsWeapon.wShortbow | wCategory.RangeProj" eachpick.field[wAttRanged].value += 1 nexteach |
#1 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
I don't know the code right off the top of my head at the moment, but when you have magical weapons (and masterwork weapons as well), you need to reference the parent container of the object that is getting the bonus. This is an oddity of custom weapons and armor that I've run into more than a few times when coding HL.
A little pseudo-code that might help: if (container.ishero <> 0) field[wRanged].value += 1 else container.parent.field[wRanged].value += 1 endif Hope that helps! |
#2 |
Senior Member
Join Date: Jul 2010
Posts: 3,147
|
When you have a magic weapon (or masterwork weapon), you get a minimum +1 bonus to attack built in. This bonus is applied to the field [wAttBonus]. Without going through the exercise, my guess is that when this happens, the bonus you are applying to [wAttRanged] is not stacking. If you adjust your script to change wAttBonus instead, it would probably work.
Also, the addition of "wCategory.RangeProj" in the foreach seems extraneous based on your description of the ability. Last edited by Sendric; November 12th, 2013 at 10:04 AM. |
#3 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
I'm not sure this is the correct logic Sendric, magic weapons get their EnhanceBonus set, which gives both a +1 to hit and +1 to damage. If you only want a weapon to assign an attack bonus, you modify the wAttBonus or wRanged (I think that is the right name of the field). A masterwork weapon has this field set to 1, if you then somehow add an EnhanceBonus to that weapon, say through a Magic Weapon spell (using an Adjustment to that weapon) you will have +2 to hit and +1 to damage. Magic weapons don't exclude the masterwork +1 through the wAttBonus (or whatever it is called).
What is happening is that the gMagWpn (? again, just from the top of my head) item that designates a custom magic weapon as magical has a child of Shortbow. The Shortbow needs to be able to reference its parent to give it the bonus. Of course, I am working strictly from memory, but I believe that is how it works, I've done a ton of work for my campaign in regard to this and it came up all the time. Of course, I could also be wrong, as my memory is full of holes sometimes. I'll check for sure when I get home later today. |
#4 |
Senior Member
Join Date: Jul 2010
Posts: 3,147
|
I can't say I followed everything you just said. However, I did create a special that adds +1 attack to all shortbows (normal, mwk, and magical), and tried out several fields. Here's the one that seems to work:
Code:
foreach pick in hero from BaseWep where "IsWeapon.wShortbow" eachpick.field[wRanAttBAB].value += 1 nexteach Last edited by Sendric; November 12th, 2013 at 11:54 AM. |
#5 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
Wouldn't wRanAttBAB actually give you a better Base Attack Bonus. So a level 5 warrior of that race would actually get two attacks with the Shortbow when it should not. Though I'm not sure HL BAB works the same as one would expect it to.
Sorry for the jargon above, I was just riffing off the top of my head at the end of my lunch at work. |
#6 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
This will do what you want. Make a Special ability for your race and add this eval script:
@Pre-Levels 10000 Code:
~ Add +1 to Shortbows for *race*. foreach pick in hero from BaseWep where "IsWeapon.wShortbow" if (eachpick.container.ishero <> 0) then eachpick.field[wRanAtk].value += 1 elseif (eachpick.container.ishero = 0) then eachpick.container.parent.field[wRanAtk].value += 1 endif nexteach |
#7 |
Senior Member
Join Date: Jul 2010
Posts: 3,147
|
Quote:
|
|
#8 |
Member
Join Date: Oct 2013
Posts: 46
|
Thank you all for the responses. All of you have been a valuable help to my novice level skills with Hero Lab.
|
#9 |
|
|