• 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

Racial Ability 2

Manalishi66

Well-known member
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?
 
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

[B][COLOR="Green"]~ Set our armor bonus value here so that outside
~ scripts can adjust us if needed.[/COLOR][/B]
field[abValue].value += 2

[B][COLOR="Green"]~ Set to one as we assume we are valid unless
~ we specifically find metal equipment.[/COLOR][/B]
nValid = 1
[B][COLOR="Green"]
~ Loop through all picks on the hero that have the
~ Metal tag.[/COLOR][/B]
foreach pick in hero where "EquipType.Metal"
  [B][COLOR="Green"]~ We found a metal item so we are no longer valid[/COLOR][/B]
  nValid = 0
nexteach

[B][COLOR="Green"]~ if we are not valid get out now![/COLOR][/B]
doneif (nValid <> 1) 
[B][COLOR="Green"]
~ Give a bonus to AC[/COLOR][/B]
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

[B][COLOR="Green"]~ Set our armor bonus value here so that outside
~ scripts can adjust us if needed.[/COLOR][/B]
field[abValue].value += 2
[B][COLOR="Green"]
~ Set to one as we assume we are valid unless
~ we specifically find metal equipment.[/COLOR][/B]
nValid  = 1

[B][COLOR="Green"]~ Loop through all picks on the hero that have the
~ Metal tag.[/COLOR][/B]
foreach pick in hero where "EquipType.Metal"

  [B][COLOR="Green"]~ if we are weapon then check here[/COLOR][/B]
  if (each.tagis[component.BaseWep] <> 0) then

    [B][COLOR="Green"]~ lets see if we are equipped in either hand?[/COLOR][/B]
    if (each.field[wIs2nd].value + each.field[gIsEquip].value <> 0) then

      [COLOR="Green"][B]~ we are a metal weapon that is equipped so we are not valid[/B][/COLOR]
      nValid  = 0

    endif

  [B][COLOR="Green"]~..if we are armor then check here[/COLOR][/B]
  elseif (each.tagis[component.BaseArmor] <> 0) then

    [B][COLOR="Green"]~ lets see if we are equipped?[/COLOR][/B]
    if (each.field[gIsEquip].value <> 0) then

      [B][COLOR="Green"]~ we are a metal armor that is equipped we are not valid[/COLOR][/B]
      nValid  = 0

    endif
  endif  

nexteach

[B][COLOR="Green"]~ if we are not valid get out now![/COLOR][/B]
doneif (nValid  <> 1) 

[B][COLOR="Green"]~ Give a bonus to AC[/COLOR][/B]
hero.child[ArmorClass].field[tACNatural].value += field[abValue].value
 
Last edited:
Back
Top