• 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

+1 to attack and Damage

chiefweasel

Well-known member
I was looking to add a new feat, which give a + to attack and damage, but was having a hard time finding the code to do so. I pulled up the code for a feat that gives + to attack, but just cant find where the code says to give it. same for the + to damage, just cant find the code to allow this to occur.

Anyone know how to do this? Thanks.
 
The code is in the "Eval Scripts" button.

Start with the help file accessed by pressing help within the editor. The "Reference Information" section is where attack and defense are covered.
 
Check there, I see the code, but dont see the actual number that is being used as the increase. I am looking at the feat, Weapon Focus, which gives a +1 to attack. But I dont see the number 1 used in the code anywhere.
 
Don't start from weapon focus - it works by adding a tag to the weapon, which in the weapon's own calculations gives the bonus to hit.
 
Not quite following you here. The weapons dont have any bonus to them yet, they need to be added with feats like weapon focus. Weapon focus gives a +1 attack, where does it assign the +1?
 
I'd start with something like improved initiative - that way, you can see how the script adds a bonus to initiative.

Then, in the help, you'll find how to modify the +initiative code to be +attack or +damage code.
 
k, I messed with trying the Improve Init and changed the Thing to the range attack, but no effect.

It am still confused how Weapon Focus adds the attack value in. I just dont see it in the feat anywhere. Any idea how it assigns a +1 to the chosen weapon?
 
The relevant line in weapon focus is:
result = eachpick.assign[Broadcast.WepFocus]

What the script in weapon focus does is to find each weapon your character carries that matches the weapon type you have focus in, and assign it the Broadcast.WepFocus tag.

Later, when it comes time for the weapon to calculate its attack bonus, it performs its own calculations, looking up everything it needs; for example its enhancement bonus, the character's BAB, etc., and then it adds +1 to hit if the Broadcast.WepFocus tag is present.

There's currently a bug in "Test Now" - it won't load the script of the tested thing. You'll need to use ctrl-r "Reload All" to get the script loaded. Is that the reason your new script isn't working?

Timing is also important in scripts, but I checked, and the Improved Initiative script runs at Pre-Level 5000. The adjustment "Attack Bonus (Ranged)" runs at Pre-Level 10,000, so that shouldn't be a problem.
 
Last edited:
It does error off when I try the Cntrl-r. So the script isnt working. I do need to assign a +2 for the feat I am working with (Range Weapon Mastery - PH2). The feat give a +2 to attack and +2 to damage and adds +20 to the range increment.

Even using the script from weapon focus, it would give me a +1 ont, and to attack only.

It seems that this is a huge area of development that was over looked. You should easily be able to assign a + to an attack or damage. Even in the inply adjustments, there is no way to add damage to a weapon. Just seems much more difficult then it needs to be. (Sorry for the rant)
 
What's your script? I know I make a number of typos when coding for HL, but I've gotten used to finding them and fixing them with experience, maybe I can help.
 
Adding a damage bonus to all ranged weapons is going to be complex.

You'll need a foreach...nexteach loop to cycle through every ranged weapon on the hero. Since it already needs a foreach to modify the damage and range increment, might as well directly modify the weapon's attack bonus while we're there.

timing: UserPreLv, 100

Code:
foreach pick in hero where "wCategory.Range?"
   eachpick.field[wAttBonus].value +=2
   eachpick.field[wDamBonus].value +=2
   eachpick.field[wRangeInc].value +=20
nexteach

Explaining everything in that script:
wCategory.Range? finds both wCategory.RangeProj (projectile weapons) and wCategory.RangeThrow (throwing weapons), and putting in the "?" wildcard allows the foreach loop to find both types of ranged weapons (but not wCategory.Melee or wCategory.Unarmed).

Each line starts with "eachpick", which changes the context to whatever selection the foreach loop is currently working on.

The "Reference Information" page I mentioned earlier, at the bottom, details weapons, which is where I found the specific fields I wanted to modify.
 
That seems to have done the trick, thank you. Now I can sue the same code to make some other changes I have been working at as well. Thanks again.
 
Back
Top