Senior Member
Join Date: Jul 2010
Posts: 157
|
Tying to code the following....but I'm getting no where.....what the right track?
You gain a +2 natural armor bonus to Armor Class when wearing leather or hide armor. You do not gain this bonus if you are wearing, wielding, or holding anything made out of metal. Code (pre Att, 10000) ~ Loop through all armor and weapons of metal material foreach pick in container where "EquipType.Metal" ~ Add a -2 to our armor class if (each.tagis[EquipType.Metal] <> 1) then hero.child[ArmorClass].field[Bonus].value -= 2 endif nexteach Am I even close? Help! P.S., I compiles without errors...but it does nothing? |
#1 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Yea I would say close. The general idea is right but you need to set a variable instead of the AC directly. This is because you want to loop through all items first.
My question is based on the rules wording its ok to carry such an item but only when equipped does it negate the +2 bonus right? That makes it a little more complex then. Lets fix the idea you have working and I would move the timing up in this case to Post-Levels/10000: Code:
var nValid as number ~ Set our armor bonus value here so that outside ~ scripts can adjust us if needed. field[abValue].value += 2 ~ Set to one as we assume we are valid unless ~ we specifically find metal equipment. nValid = 1 ~ Loop through all picks on the hero that have the ~ Metal tag. foreach pick in hero where "EquipType.Metal" ~ We found a metal item so we are no longer valid nValid = 0 nexteach ~ if we are not valid get out now! doneif (nValid <> 1) ~ Give a bonus to AC hero.child[ArmorClass].field[tACNatural].value += field[abValue].value Post-levels/10000 Code:
var nValid as number ~ Set our armor bonus value here so that outside ~ scripts can adjust us if needed. field[abValue].value += 2 ~ Set to one as we assume we are valid unless ~ we specifically find metal equipment. nValid = 1 ~ Loop through all picks on the hero that have the ~ Metal tag. foreach pick in hero where "EquipType.Metal" ~ if we are weapon then check here if (each.tagis[component.BaseWep] <> 0) then ~ lets see if we are equipped in either hand? if (each.field[wIs2nd].value + each.field[gIsEquip].value <> 0) then ~ we are a metal weapon that is equipped so we are not valid nValid = 0 endif ~..if we are armor then check here elseif (each.tagis[component.BaseArmor] <> 0) then ~ lets see if we are equipped? if (each.field[gIsEquip].value <> 0) then ~ we are a metal armor that is equipped we are not valid nValid = 0 endif endif nexteach ~ if we are not valid get out now! doneif (nValid <> 1) ~ Give a bonus to AC hero.child[ArmorClass].field[tACNatural].value += field[abValue].value Hero Lab Resources: Pathfinder - d20pfsrd and Pathfinder Pack Setup 3.5 D&D (d20) - Community Server Setup 5E D&D - Community Server Setup Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources. Created by the community for the community - Realm Works kickstarter backer (Alpha Wolf) and Beta tester.- d20 HL package volunteer editor. Last edited by ShadowChemosh; August 31st, 2014 at 05:35 PM. Reason: Change Bonus to tACNatural.... |
#2 |
Senior Member
Join Date: Mar 2007
Location: Muskegon, MI
Posts: 2,975
|
Only thing I'd note is it's a Natural armor so you need to add to field tACNatural not Bonus
|
#3 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Picky picky... I updated the scripts...
Hero Lab Resources: Pathfinder - d20pfsrd and Pathfinder Pack Setup 3.5 D&D (d20) - Community Server Setup 5E D&D - Community Server Setup Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources. Created by the community for the community - Realm Works kickstarter backer (Alpha Wolf) and Beta tester.- d20 HL package volunteer editor. |
#4 |
Senior Member
Join Date: Jul 2010
Posts: 157
|
Sorry for the late response. Worked Great! That was a tough one for me. Again... Thanks to everyone!
Don |
#5 |
|
|