Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - d20 System (http://forums.wolflair.com/forumdisplay.php?f=46)
-   -   Applying different modifier to attack rolls (http://forums.wolflair.com/showthread.php?t=9127)

bodrin September 1st, 2009 06:22 AM

Applying different modifier to attack rolls
 
I'm trying to swap the Dex mod for the Wis mod on all ranged attack rolls but

I can't find any code examples that show how to implement this. The modifier will be applied by a feat and not a class.

The weapon finesse feat seems to be similar but that only applies to light weapons and doesn't actually alter the attack bonus, I think it relies on the player to remember it.

Any ideas?

Lawful_g September 1st, 2009 10:20 AM

I am doind a similar feat called Brutal Throw. The only problem is I don't know how to say "not" in the Foreach statement.

foreach pick in hero where "wCategory.RangeThrow and not wCategory.Melee"

"&" is and, "|" is or, what is not?

Lawful_g September 1st, 2009 10:21 AM

Here is my example code, for reference

~ If our dexterity bonus is higher than our strength bonus, do nothing and get out now.
var dexterity as number
var strength as number
dexterity = hero.child[aDEX].field[aModBonus].value
strength = hero.child[aSTR].field[aModBonus].value
if (dexterity >= strength) then
done
endif

~ Since our Strength is higher than our dexterity and we passed, iterate through all weapons which are thrown, and subtract dexterity and add strength instead to our attack rolls.

foreach pick in hero where "wCategory.RangeThrow Missing stuff here"
each.field[wAttBonus].value = each.field[wAttBonus].value - dexterity + strength
nexteach

bodrin September 1st, 2009 11:52 AM

Zen archery is the feat i'm looking at complete warrior page 106.
I think your on the right track with this though.

If you look at this thread

http://forums.wolflair.com/showthrea...=graceful+edge

it contains a custom expression that ignores specific weapons and kind of explains the usage of the & tags.

I think [wCategory.Range?] ignores anything that doesn't have a specific range increment.

I don't know if that will give you any pointers for your code Lawful_g.

Mathias September 1st, 2009 11:57 AM

Quote:

Originally Posted by Lawful_g (Post 32596)
I am doind a similar feat called Brutal Throw. The only problem is I don't know how to say "not" in the Foreach statement.

foreach pick in hero where "wCategory.RangeThrow and not wCategory.Melee"

"&" is and, "|" is or, what is not?

"!"

foreach pick in hero where "wCategory.RangeThrow & !wCategory.Melee"

just a note - that expression's not going to find javelins and daggers.

Mathias September 1st, 2009 12:10 PM

Quote:

Originally Posted by Lawful_g (Post 32597)
Here is my example code, for reference

~ If our dexterity bonus is higher than our strength bonus, do nothing and get out now.
var dexterity as number
var strength as number
dexterity = hero.child[aDEX].field[aModBonus].value
strength = hero.child[aSTR].field[aModBonus].value
if (dexterity >= strength) then
done
endif

~ Since our Strength is higher than our dexterity and we passed, iterate through all weapons which are thrown, and subtract dexterity and add strength instead to our attack rolls.

foreach pick in hero where "wCategory.RangeThrow Missing stuff here"
each.field[wAttBonus].value = each.field[wAttBonus].value - dexterity + strength
nexteach

to condense your code, may I suggest the following:

Code:

var bonus as number
bonus = maximum(hero.child[aDEX].field[aModBonus].value - hero.child[aSTR].field[aModBonus].value , 0)
doneif (bonus= 0)
 
foreach pick in hero where "wCategory.RangeThrow & !wCategory.Melee"
eachpick.field[wAttBonus].value += bonus
nexteach

That way, taking the maximum of your difference and 0 means that if STR is greater than DEX, it will add +0 - and your if statement can be compressed into one line with doneif.

Your code was fine, except that you should be using eachpick. instead of each. within your foreach loop (the other will still work, but only because the program still supports legacy code).

Mathias September 1st, 2009 12:20 PM

Quote:

Originally Posted by bodrin (Post 32600)
I think [wCategory.Range?] ignores anything that doesn't have a specific range increment.

Actually, check out a weapon in the editor. Near the top you'll find a selector named "Category" which has options like "Melee", "Thrown", "Projectile", etc. - those are the wCategory tags. [wCategory.Range?] finds "wCategory.RangeThrow" and "wCategory.RangeProj" - thrown and projectile, respectively.

Range increment is wRangeInc.

Lawful_g September 1st, 2009 12:28 PM

Because of the way the tags work now, any weapon that has both the melee and throwing tag (like javelins and daggers) already uses Strength to determine it's attack roll (assuming by default that they are wielded in melee and ignoring the possibility of using them as ranged weapons, especially incorrect for javelins because they should be taking a penalty for melee use but are not). I think I have mentioned this error before.

Anyway, I have worked around this by creating custom Throwing versions (IE Dagger, Throwing) of those weapons with the projectile and throwing tags so that they correctly use Dex for attack rolls and Str for damage rolls.

Lawful_g September 1st, 2009 12:29 PM

Thanks for the "!" trick mghel, that should be helpful in the future.

bodrin September 7th, 2009 03:57 PM

I can't get this code to apply the Wisdom Modifier to ranged attacks i've tried altering the timing but to no avail.

Timing final phase 10000

Code:

var bonus as number
bonus = maximum(hero.child[aWIS].field[aModBonus].value - hero.child[aDEX].field[aModBonus].value , 0)
doneif (bonus= 0)
 
foreach pick in hero where "wCategory.RangeProj & wCategory.RangeThrow & !wCategory.Melee"
eachpick.field[wAttBonus].value += bonus
nexteach

Any pointers on what i'm doing wrong.


All times are GMT -8. The time now is 12:09 PM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.