PDA

View Full Version : More Scripting Questions


BenT1
May 26th, 2010, 04:33 PM
I am trying to create a feat, Shield Ward.

It will add the Hero's Shield AC bonus (including magic) to his Touch AC and his CMD. Here is the script I have to far, but it Herolab doesn't seem to like it much.


~find all our shields
foreach pick in hero from BaseArmor where "EquipType.Shield"

var bonus as number
~if it's equipped
if (eachpick.field[gIsEquip].value <> 0) then
bonus = eachpick.field[tACShield].value
eachpick.field[tACTouch].value += bonus
endif
nexteach

It compiles it without a complaint, but it does not adjust the Touch AC of the character. Then there is figuring out how to add it to the CMD.....

And when it is used on a character with a Magic Shield, Herolabs complains bitterly that the 'attempt to access field "TACShield" that does not exist for thing "IMagArmor"'

BenT1

BenT1
May 26th, 2010, 04:34 PM
By the way, the Weapon talent of the Fighter's does transfer now, Thanks!!

BenT1

ShadowChemosh
May 27th, 2010, 08:04 AM
So you where pretty close actually, but a few problems. The AC field on shields is actually arAC not tACShield. Then you where trying to modify the touch AC on the shield by using eachpick.field[tACTouch].value. What you really wanted to do was modify the Touch AC of the hero. So you needed hero.child[ArmorClass].field[tACTouch].value.

You didn't say what your timing was for the script, but some playing around shows that Post-Attributes 10,000 seems to work the best for Magic and nonmagic shields.

Here is the final working script.

~Post-attributes 10,000
var bonus as number

~find all our shields
foreach pick in hero from BaseArmor where "EquipType.Shield"
~if it's equipped
if (eachpick.field[gIsEquip].value <> 0) then
bonus = eachpick.field[arAC].value
hero.child[ArmorClass].field[tACTouch].value += bonus
endif
nexteach




Then there is figuring out how to add it to the CMD.....

Check out the CMB/CMD for weapons (http://forums.wolflair.com/showthread.php?t=10100) thread where I am doing stuff with CMB/CMD and Mathias answers a bunch of questions on it. Plus their are some example scripts you should be able to use as a base.

Hope that helps.

BenT1
May 27th, 2010, 03:30 PM
Thanks for the help ShadowC, I appreciate it. I just moved the timing to Final/10000 so it would also pick up the Enhancement bonus of the shield.

BenT1

BenT1
May 27th, 2010, 03:53 PM
This is a script where I am trying to count the number of 'Draconic' feats a character has and use the number to determine the abilities granted by the feat. Timing is set at Final/10001. The var bonus is returning a 1, even though the character has 4 'Draconic' feats. I used the example from the help file to create the tagcount[fCategory.Draconic]

var bonus as number
~ Count our Draconic feats- How many do I have?
bonus = tagcount[fCategory.Draconic]
#skillbonus[skPercep] += bonus

~ gain low light vision
field[livename].text = "Lowlight Vision" & " Bonus" & bonus
~ Improve our darkvision if necessary
if (bonus >= 3) then hero.child[raDarkVis].field[abValue].value = maximum(hero.child[raDarkVis].field[abValue].value,60)
endif
if (bonus >= 4) then hero.child[rBlindsen].field[abValue].value = maximum(hero.child[rBlindsen].field[abValue].value,20)
endif

Mathias
May 27th, 2010, 11:16 PM
If you use tagcount[fCategory.Draconic], you're counting the number of fCategory.Draconic tags on the thing where the script is running - so just that feat.

hero.tagcount[fCategory.Draconic] will get you the total number of tags on the character.

BenT1
May 28th, 2010, 02:31 PM
Ok, that does return the proper value for the var bonus. But it is not adding to the #skillbonus[skPercep] += bonus is not adding it correctly to the Perception skill. It is still only adding 1, even though it is returning a value of 4. And my If statements are returning errors, 'extra characters on end of line'. I originally tried to assign the racial ability 'raLowLight', but that did not work.... I know it can be done, just can't find an example of it.

BenT1

ShadowChemosh
May 28th, 2010, 06:41 PM
~ Improve our darkvision if necessary
if (bonus >= 3) then hero.child[raDarkVis].field[abValue].value = maximum(hero.child[raDarkVis].field[abValue].value,60)
endif
if (bonus >= 4) then hero.child[rBlindsen].field[abValue].value = maximum(hero.child[rBlindsen].field[abValue].value,20)
endif
Assuming this is exact, as you don't have it wrapped in code, you can't have stuff after the THEN except a new line.

Try this.

~ Improve our darkvision if necessary
if (bonus >= 3) then
hero.child[raDarkVis].field[abValue].value = maximum(hero.child[raDarkVis].field[abValue].value,60)
endif
if (bonus >= 4) then
hero.child[rBlindsen].field[abValue].value = maximum(hero.child[rBlindsen].field[abValue].value,20)
endif

BenT1
May 28th, 2010, 08:06 PM
Yes, it was a cut and paste. Thanks for the format info.

But, how does one check and assign a racial ability using a script?

The editor complains about trying to access a non-live child pick for raDarkVis and raBlindsen.

BenT1

ShadowChemosh
May 29th, 2010, 09:57 AM
But, how does one check and assign a racial ability using a script?

The editor complains about trying to access a non-live child pick for raDarkVis and raBlindsen.

My understanding here is that you have to "Bootstraps" that ability on to your Thing before you can try and access it.

So for example if I wanted to apply Silver DR to a creature I first would have to bootstrap on xDamRdSil (Damage Reduction, Silver) so that it would have the Thing to apply against.

Mathias
June 1st, 2010, 09:57 AM
Could you tell me more about what you're trying to do with those abilities? Exactly when do you get them, how do they change by levels, etc.?