• 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

FATE Core Evaluation Rule

EightBitz

Well-known member
I have an evaluation rule that isn't working. The condition that should clear it doesn't. The thing that confuses me is that as far as I can tell, it's logically identical to another rule that works perfectly well.

Both scripts have been added as Eval Rules, and both scripts have had their timing set for Validation, 100.

Here's the non-working script:
Code:
if (hero.findchild[Stunt].tagis[thingid.pwrInhuRec] <> 0) then
  @valid = 1
  done
endif

@valid = 0
linkvalid = 0
@message = "This ability requires a Toughness power."

Here's the working script:
Code:
if (hero.findchild[Stunt].tagis[thingid.pwrCatch] <> 0) then
  @valid = 1
  done
endif

@valid = 0
linkvalid = 0
@message = "This ability requires a Catch."

Originally, the non-working script had a few "elseif" statements to check the existence of other stunts, but I took those out to simplify troubleshooting.

I copied and pasted the code from the working script stunt to the non-working stunt. I copied and pasted the name of the pwrInhuRec stunt, so there should not be any typos. I still checked, though, and I can't see any.

I tried changing the timing on the non-working script to Initialization:200, wondering if it had to run after its counterpart. That didn't help.

I removed the script from the other stunt to see if there was a recursion problem. That didn't help either.

Either I'm missing something simple and stupid, or there's a bug. I've learned from my other scripting experiences that when it comes down to those two options, it's most often the case that I'm missing something simple and stupid.
 
findchild[] is not the way I would go about this.

I'm sorry to say that the script you're copying from is very strangely written, so you may want to double-check where you got it from - if you add the three stunts it looks like you're allowed to add to a character in Fate Core, it would only have a 1 in 3 chance of working correctly, since there are 3 stunts, and findchild[] will find a random one of them. It might be choosing the first alphabetically, which is why "Catch" would have a better chance of working correctly than "Toughness".

Is the rule you're trying to implement "Toughness required"?

If so, I'd make a copy of a stunt with a similar requirement, like Gift of Tongues or Walking Library or Cut Off - they all require the presence of a specific other stunt. Take a look at the Expr-Reqs there to see how they did it.
 
Expr-Reqs aren't quite the right fit for this.

There are maybe six or seven powers that fall under the category of "Toughness". Each Toughness ability requires that you have a Catch to it. For a popular example, Superman has "Physical Immunity", but one catch for him would be "Kryptonite."

The thing is, though, each Toughness power doesn't require a separate catch. If you take three Toughness powers (e.g. Inhuman Toughness, Inhuman Recovery, Physical Immunity), you're only required to have one catch, so long as it applies to all powers.

So I want to make sure that however many toughness powers are picked, there exists at least one catch, and that however many catches are picked, there exists at least one toughness power. If I used Expr-Req, then that would force each Toughness power to have its own catch.

As far as the logic of the script, I don't remember where I got that. It was either from a scripting example here on this forum, or from the authoring kit wiki, or from some other element within Hero Lab (maybe a pathfinder skill or something). Those are the only sources I've used for scripting logic.

As far as the conditional statement, I kinda pieced that together from different bits in your examples.

If I understand you correctly, the problem is with the conditional statement. I think I was thinking it would find the first stunt that had the tag specified as the thingid, but I think you're saying that's not what it does. It finds the first stunt and checks if it has that thingid? Is that what's going wrong?
 
If you want to find the first stunt that has that particular thingid:

hero.findchild[Stunt,"thingid.pwrInhuRec"]

But why use findchild at all? Why not just check for the tag on the hero that this stunt adds?

Also, please re-phrase what you're talking about for the number of catches and the number of toughness powers - I'm not following that. I don't see why it matters whether you test for the other thing only after adding this item, and not test for it both before and after you add it. Also, why would there be a different restriction on the number of things required for an expr-req vs. an eval rule?
 
Also, while you're just learning to code in Hero Lab, I highly recommend that when you have a question to ask, you describe the game rule you're trying to implement, along with describing the problem you've encountered. Many times I've seen newer coders start down a non-optimal path, encounter a problem, and then ask on the forums how to solve that problem, and then it takes many questions before I understand what they're trying to accomplish, which is when I can see that there's an easier path to solving that problem.
 
But why use findchild at all? Why not just check for the tag on the hero that this stunt adds?

That's exactly what I'm trying to figure out how to do.

So, when you said expr-reqs, for some reason, I was thinking pick-reqs. So ignore everything I said in that regard.

Rephrase:
I'm not trying to be condescending by explaining this step-by-step. I'm just not sure where my phrasing was ambiguous, so I'm erring on the side of caution.

Inhuman Recovery: Allows a character to recover from injury faster than a normal human would.

Inhuman Toughness: Allows a character to take more damage than a normal human could. A normal human maxes out at four boxes for physical stress. This adds another two.

Physical Immunity: Allows a character to be immune to normal, physical attacks.

The Catch: Defines an exception for one or more of the above powers. A faerie might be able to recover from injury more quickly than a human ... unless the injury was caused by something that contained cold iron.

A faerie might be able to sustain more damage than a human ... unless the damage is caused by something containing cold iron.

A faerie might be immune to damage from normal weapons ... unless the weapons contain cold iron.

In this example, a faerie could one, two, or all three of the toughness powers, and only one instance of a Catch. That catch would be defined as "Cold Iron", and would apply to all three powers.

Or, a different catch could be defined for each power. So, three different toughness powers with three catches, each catch applying to a different power.

Or, multiple catches could apply to one toughness power.

So basically, if you are going to take one or more toughness powers, you need at least one catch, even if you take multiple toughness powers. And if you are going to take one or more catches, you need at least one toughness power, even if you take multiple catches.
 
Okay, so what you want is an eval rule on Toughness that says "You must select a catch", and an expr-req on each catch that says "Toughness required". That way, you aren't in the catch-22 of not being able to select toughness until you select a catch, but can't select a catch until you select toughness. What will happen is that the user can select toughness, and will then see toughness turn red until they select a catch, and all the catches will be greyed out until you select toughness, at which time they become white.

So, for toughness's Eval rule - that only needs a single line of code:
Code:
validif (hero.tagis[Stunt.the first catch's Id] + hero.tagis[Stunt.the second catch's Id] + ... <> 0)
And each catch gets this Expr-req:

Code:
hero.tagis[Stunt.toughness's id] <> 0
(put in the correct Ids inside the brackets and replace the ... with as many more +hero.tagis[] you need to cover all the available catch abilities)
 
I think I have to reverse that.

The Catch power only exists once, but multiple instances can be added. So it's eval rule would be:
Code:
validif (hero.tagis[Stunt.the first toughness's Id] + hero.tagis[Stunt.the second toughness's Id] + ... <> 0)

And there are multiple toughness powers, each of which are unique, so they would each have this Expr-req:
Code:
hero.tagis[Stunt.catch's id] <> 0

But then, that grays-out the toughness powers until a Catch is added.
 
I took your syntax for the validation rule and applied it to both Catch and the Toughness powers, and it seems to work fine.

Thank you.
 
You still want each toughness to have an eval rule and the catch to have an exprreq. The change to make is that toughness's eval rule only looks for a single stunt, and the catch's expr-req needs to look for lots of different stunts.
 
So a follow-up question if you're willing. Each character in Dresden files has to have a template. Templates are things that describe the basic nature of the character. For instance, a character can be a "Pure Mortal" with no supernatural powers, a human "Wizard" with certain spell-casting abilities, or a "Champion of God" where they have certain abilities derived from their faith.

There are 15 different templates. In addition to defining these templates, I created a xxx.1st file where I defined a "Template" group tag. Within the group, I defined a tag for each template, and I defined a tag called simply "Template".

In the editor, I added two tags to each template. I added the "Template.<specific template>" tag, and I added the "Template.Template" tag.

To make sure each character has picked a template, I was using this validation rule at the campaign level:
Code:
if (hero.findchild[Stunt].tagis[Template.Template] <> 0) then
  @valid = 1
  done
endif

@valid = 0
@message = "You must pick a template (listed in Stunts as; Template: ....)"

That's seemed to work, but as I learned from you yesterday, that's not the best way to do this, and a better alternative would be:

Code:
validif (hero.tagis[Stunt.tmpMortal] + hero.tagis[Stunt.tmpWizard] + ... <> 0)

But with 15 templates, I'll have to have 15 tagis expressions in there. Is that the best way to do this, or is there a simpler expression I can use to say "find any stunt that has the 'Template.Template' tag"?
 
Do you want to require exactly one template, or 1+ templates?

1+

Code:
perform hero.findchild[Stunt,"Template.Template"].setfocus
validif (state.isfocus <> 0)
exactly 1:

Code:
var foundcount as number
foreach pick in hero from Stunt where "Template.Template"
  foundcount += 1
  nexteach
validif (foundcount = 1)
You can ditch all that @valid = 0 and @message= at the end. @valid is already set to 0 at the beginning of all eval rules and prereqs, so there's no need to set it to the value it's already at, and @message is already set in the header, so unless you're writing a custom @message, like in this case "You must have exactly one Template, but you have " & foundcount & ".", you can just use the message you've already entered.
 
Also, I was including the message in the script, because that makes it easier to copy and paste to other objects.
 
Back
Top