• 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

Dynamic prepreq message

frumple

Well-known member
I have a feat that one of its prereqs scales with the number of times it is taken.
For example, Dex >= 14 + # times feat taken

Is there a way to change the prereq error message to reflect this.

For example, if I have taken the feat once, the error message should be "Dex 15+ required"
 
Code:
validif (@ispick <> 0)

var totaldex as number
totaldex = 13 + hero.tagcount[HasFeat.fTestReq]
@message = "Dexterity " & totaldex & " required."
validif (#attrvalue[aDEX] >= totaldex)

Replace fTestReq with your feat ID
 
Just to build on the above @message is a special system variable. The three most common system variables used are:

@valid = allows for setting the pre-req as valid(1) or not valid(0).
@message = allows for setting the string value that the gamer sees (ie a custom error message).
@ispick = allows for testing if the script is running on a Thing or a Pick. @ispick is 1 means we are a pick and 0 means we are a Thing. Pick being live and on the hero.
 
Also I will note that this doesn't say it's invalid if you add more than you should so if you only had a dex 14 and you added the feat 3 times it would still say it's valid, so you might want to add some logic to counter that.
 
Ok I am close. I either get all the feat valid for all or none of them.

Code:
var cnt as number
cnt = hero.tagcount[HasFeat.FEATNAME]

if (@ispick <> 0) then
~ this handles feats that have already been picked
  if (cnt = 1) then
    validif (#attrvalue[aDEX] >= 14)
  elseif (cnt = 2) then
    validif (#attrvalue[aDEX] >= 15)
  elseif (cnt = 3) then
    validif (#attrvalue[aDEX] >= 16)
  elseif (cnt = 4) then
    validif (#attrvalue[aDEX] >= 17)
  endif
  var msg as number
  msg = 13 + cnt
  @message = "Dexterity " & msg & "+ required"

else

var dx as number
dx = 14 + cnt
@message = "Dexterity " & dx & "+ required"
validif (#attrvalue[aDEX] >= dx)

endif

Looks like @valid sets for all instances of the feat, not just the individual ones. :/
 
I think the problem you're going to face is that by using the tagcount to dynamically increase the requirement, any checks you make are going to automatically be increased by the check.
 
Looks like @valid sets for all instances of the feat, not just the individual ones. :/
Actually it has to do with the fact that the feat has the "exact" same script running on each Pick. So if one pick is invalid then all of them would.

Code:
var cnt as number
cnt = hero.tagcount[HasFeat.FEATNAME]
This counts the "total" number of feats taken. So you add FEATNAME to the character and it counts one tag. You add two FEATNAME and now it counts 2 for both feats.

I think you expect FEATNAME-1 to count "one" and FEATNAME-2 to count "two" but both count "two".

So short answer is either all valid or all not valid.. :)
 
and with that you can simplify it down to

Code:
var totaldex as number
totaldex = 13 + hero.tagcount[HasFeat.fTestReq]

validif (#attrvalue[aDEX] >= totaldex)

@message = "Dexterity " & totaldex & " required."
 
DO feats have an Index field? I know some object types do, Class specials and such. If so, that could be used in the script, to calculate the dex requirement, that way each feat pick would have its own independent prerequisite criteria. (would only work for validating picks, and would not necessarily work for validating choices in the feat chooser). So you'd also have to check if it is a pick, and if not, run the check shown above with count.
 
Nope. Only Class Specials have that feature. Feats do not.

I think you could create a situation where you only have one of the scripts work actually by using a Eval-Req instead. Basically you could have a script that assigns a Custom.First tag to itself if it can't find any other feats that have that tag already. Then have a script run a little later that only does your Validation section if the "Custom.First" tag is found.

It really seems like allot of extra code that solves a non-situation. I mean either you have an error or you don't. Does it really hurt to have multiple warnings instead of one?

In theory you maybe able to script the feats in away that they could assign themselves a Tag that would number them from 1 to X. Then your pre-req could calc the Dex value based on the Tag.Value instead of counting HasFeat tags. So this way each feat "could" actually know if it was the 1st, 2nd, 3rd iteration of the feat. I have never actually done this but I think it could work. Hmmmm

Below is a theory code written without access to HL. This includes needing a .1st file.

Code:
<group id="FEATID" name="Feat Counter"
   dynamic="yes"
   minvalue="0"
   maxvalue="20"
</group>

Code:
[B]~ Post-Levels/10000[/B]
var nCount as number
nCount = hero.tagcount[FEATID.?]
perform hero.assignstr["FEATID." & nCount]
perform altpick.assign["FEATID." & nCount]

[B]~ Validation/10000[/B]
var totaldex as number
totaldex = 14 + altpick.tagvalue[FEATID.?]

validif (#attrvalue[aDEX] >= totaldex)

@message = "Dexterity " & totaldex & " required."
 
I did some playing around with this, and I was able to create an 'index' using the abValue field.

fFUZaIndex Eval Pre-levels 1000
Code:
var fcount as number
fcount = 1

foreach pick in hero where "thingid.fFUZaIndx"
    if (eachpick.field[abValue].value <= 1) then
        eachpick.field[abValue].value = fcount
        fcount += 1
    endif
nexteach
 
Nice that would work also! Though I am thinking you would need to have that run "once" not multiple times on each feat. So you could put it on a Simple Thing set to unique and bootstrap it to the feat. Then even though the feat is added multiple times only 1 Simple Pick would be added.

The other thing to keep in mind is that "foreach" loops use allot of CPU and Pathfinder already uses lots of them. So we should try and avoid them when we can especially with the iPad.

Using Tags even a Tag String is way less CPU then the foreach. I have been really trying to not use foreach loops anymore if I can code around it.
 
In my debugging, this seems to work as written. It only sets the abValue if it was previously unset (<= 1), so even if it runs multiple times, each individual pick only gets it's value set once, and each pick the next number. That way, once it's all said and done, each pick has its own unique index.

I'm not familiar with prereq's though, and for some reason am having a problem getting the prereq to access the field properly:

Code:
var mindex as number
mindex = 13 + field[abValue].value

validif (#attrvalue[aDEX] >= mindex)

@message = "Dexterity " & mindex & " required."

is throwing an "invalid use of reserved word on line 2" on compile. Are prereqs not able to access their own pick's fields?
 
nevermind, I was putting this in pre-reqs, which i believe is run before a pick is added, so the fields aren't set there.. I now put it in Eval Rules, and it seems to be working.
 
In my debugging, this seems to work as written. It only sets the abValue if it was previously unset (<= 1), so even if it runs multiple times, each individual pick only gets it's value set once, and each pick the next number. That way, once it's all said and done, each pick has its own unique index.
Ahhh good point missed the <= 1! :)
 
so here's what I've done for the validations:

pre-req to check if it's okay to add the feat:
Code:
validif (@ispick <> 0)

var mindex as number
mindex = 13 + hero.tagcount[HasFeat.fFUZaIndx]

validif (#attrvalue[aDEX] >= mindex)

@message = "Dexterity " & mindex & " required."

eval rule to check if the added picks are individually valid:

post-attributes 10000
Code:
var mindex as number
mindex = 12 + this.field[abValue].value

validif (#attrvalue[aDEX] >= mindex)

@message = "Dexterity " & mindex & " required."

Seems to all work as requested. You can add the feat multiple times up to the limit by dex, then it becomes invalid in the feat configurable. Adding the feat more times than your dex allows shows only the ones that are above your dex based limit as invalid.
 
of course, if the feat in question needs to use abValue for it's own function, then this index could be created in abValue2, abValue3, or abValue4, as necessary.
 
Back
Top