View Single Post
Lord Magus
Senior Member
 
Join Date: Jan 2011
Location: Quebec, QC, Canada
Posts: 464

Old December 17th, 2021, 06:32 PM
One of the other abilities a character can have is a large short-term stat buff from those affinities; when the ability is used, you get a bonus to any stat for which you have at least 2 ranks in the corresponding affinity, the bonus being one-half the total level (rank + bonus) of the affinity (yes, crazy at high levels).

I am trying to code the buff without using a series of if/then statements. A foreach loop iterating through the affinities seems appropriate, but I can’t get it to work so far.

Post-Levels 50100
(...)
Code:
  foreach pick in hero where "abCategory.AMSAffin & Helper.FirstCopy"
     var AffAttr as string
     var AttBon as number
     AffAttr = "hero.child[" & eachpick.field[abText].text &"]"
     AttBon = round(eachpick.field[abValue3].value/2,0,-1)
     #enhancementbonus[AffAttr, AttBon]
 nexteach
The field [abText] holds the corresponding attribute ID for each affinity (ex: aDEX)
the field [abValue3] holds the total level for each affinity (and is calculated at post levels 50000)

The error message:
Hero Lab was forced to stop compilation after the following errors were detected:
Syntax error in 'eval' script for Thing 'cAMSElAug' (Eval Script '#2') on line 15
-> Unspecified error parsing script
Line 15 is the bonus macro

1) Is the problem the use of variables such in the macro? At least for the number, it usually works. Is there a problem with the string variable?
2) Any advice on how to optimize this script? I can't seem to find a way to travel to the attribute linked to the affinity without reconstructing it through the above string. Tags?

Thanks!

Last edited by Lord Magus; December 17th, 2021 at 06:42 PM.
Lord Magus is offline   #2 Reply With Quote