Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Pathfinder Roleplaying Game
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
Manalishi66
Senior Member
 
Join Date: Jul 2010
Posts: 157

Old August 31st, 2014, 12:41 AM
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?
Manalishi66 is offline   #1 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old August 31st, 2014, 05:28 PM
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
Here is a more complex script that actually makes sure a character is wearing or wielding the said weapon/armor:
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....
ShadowChemosh is offline   #2 Reply With Quote
AndrewD2
Senior Member
 
Join Date: Mar 2007
Location: Muskegon, MI
Posts: 2,975

Old August 31st, 2014, 05:32 PM
Only thing I'd note is it's a Natural armor so you need to add to field tACNatural not Bonus
AndrewD2 is offline   #3 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old August 31st, 2014, 05:36 PM
Quote:
Originally Posted by AndrewD2 View Post
Only thing I'd note is it's a Natural armor so you need to add to field tACNatural not Bonus
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.
ShadowChemosh is offline   #4 Reply With Quote
Manalishi66
Senior Member
 
Join Date: Jul 2010
Posts: 157

Old September 1st, 2014, 01:25 AM
Sorry for the late response. Worked Great! That was a tough one for me. Again... Thanks to everyone!

Don
Manalishi66 is offline   #5 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:27 PM.


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