• 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

Issue with #hasability

bertraze

Active member
Right now I'm having an issue with #hasability that I'm having a hard time understanding. I'm trying to use an eval script to give an additional bonus from a custom ability if the character has a certain class special.

I've tried running this script at final/10000, render/10000, and first/10000, all to no avail. (The frustrating bit is I have a render script testing for the exact same ability that seems to be working, so maybe I've just derped the code somehow.

I'm currently running the below at Final/10000, and I get the bonus for having the item (which is bootstrapped by the custom ability) equipped, but I'm not getting the extra bonuses for having the upgrade class ability, even though my hero has the ability. Please tell me where I'm going wrong.

Code:
var bonus as number

bonus = maximum(1,round(#levelcount[Machsmith]/2,0,-1))
perform hero.childfound[ioAnalyzer].setfocus

~ apply skill and sense bonuses if Analyzer is equipped
if (focus.field[gIsEquip].value <> 0) then
  #skillbonus[skKnowArca] += bonus

  ~ extra bonuses if we have the first upgrade
  if (#hasability[cMacGW1U1] <> 0) then
    #skillbonus[skKnowDun] += bonus
    #skillbonus[skKnowEng] += bonus
    #skillbonus[skKnowGeog] += bonus
    #skillbonus[skKnowNat] += bonus
    #skillbonus[skKnowPlan] += bonus
  endif
endif
 
#hasability checks for a tag that is applied way too late to be useful in eval scripts. It's chiefly for pre reqs and such. If you need to check if a certain ability is present, you can look for the Ability tag applied to the hero, do a childlives, or something else (in case you're worried about whether an ability is disabled).
 
#hasability is only intended for use in prereqs, not in scripts - the tags it's testing for are added extremely late in the Final phase - too late to be useful for calculating skill bonuses.

Use a field, rather than a variable to store the value:
Code:
field[abValue].value = maximum(1,round(#levelcount[Machsmith]/2,0,-1))
That way, a script on cMacGW1U1 can access that field's value:
Code:
field[abValue].value += #value[that other ability]
perform hero.childfound[ioAnalyzer].setfocus

~ apply skill and sense bonuses if Analyzer is equipped
if (focus.field[gIsEquip].value <> 0) then

The second script runs slightly after the first, so that it can look up the value calculated on the first ability.
 
I'm trying to implement what you're suggesting, Mathias, but I'm getting an error saying that focus is undefined from the line after I setfocus, and I'm confused.

Post-Levels/11000
Script on cMacGW1Ana (the other ability) is at Post-Levels/10000
This code is for Upgrade 1 for Greatwork 1
cMacGW1Ana has added the tag Custom.Analyzer1 to the ioAnalyzer it bootstrapped so we can tell if this analyzer came from the first greatwork chosen, or a later one for archetypes that get more

Code:
var bonus as number
bonus = #value[cMacGW1Ana]

~ provide upgrade bonuses for Analyzer
if (hero.childlives[ioAnalyzer] <> 0) then
  perform hero.childfound[ioAnalyzer].setfocus

  ~ make sure it's our first greatwork for archetypes with multiple
  if (focus.childlives[Custom.Analyzer1] <> 0) then
    if (focus.field[gIsEquip].value <> 0) then
      #skillbonus[skKnowDun] += bonus
      #skillbonus[skKnowEng] += bonus
      #skillbonus[skKnowGeog] += bonus
      #skillbonus[skKnowNat] += bonus
      #skillbonus[skKnowPlan] += bonus
    endif
  endif
endif

I'm getting this error, and this seems counter to how setfocus is supposed to work.
Hero Lab was forced to stop compilation after the following errors were detected:

Syntax error in 'eval' script for Thing 'cMacGW1U1' (Eval Script '#1') on line 9
-> Reference to undeclared variable: 'focus'
 
Last edited:
Yea thats a little off as what it really means is that "childlives" is not something you can do with focus. Focus means you have the pointer to the Pick which is "ioAnalyzer".

This line is not valid at all:
Code:
if (focus.childlives[Custom.Analyzer1] <> 0) then
So can't use focus and childlives. And childlives goes after a "unique ID" but you put in a tag.

I think what you want is this:
Code:
if (focus.tagis[Custom.Analyzer1] <> 0) then
Which in English is saying is the tag "Custom.Analizer1" on the Thing "ioAnalyzer".

I would also recommend adding the following after the setfocus to make sure you have a pointer to the pick in memory.
Code:
doneif (state.isfocus = 0)

Otherwise if the ioAnalyzer is not live on the hero your script would throw an error. When it tries to do the tagis[].

So the full script is:
Code:
var bonus as number
bonus = #value[cMacGW1Ana]

~ provide upgrade bonuses for Analyzer
if (hero.childlives[ioAnalyzer] <> 0) then
  perform hero.childfound[ioAnalyzer].setfocus
  doneif (state.isfocus = 0)

  ~ make sure it's our first greatwork for archetypes with multiple
  if (focus.tagis[Custom.Analyzer1] <> 0) then
    if (focus.field[gIsEquip].value <> 0) then
      #skillbonus[skKnowDun] += bonus
      #skillbonus[skKnowEng] += bonus
      #skillbonus[skKnowGeog] += bonus
      #skillbonus[skKnowNat] += bonus
      #skillbonus[skKnowPlan] += bonus
    endif
  endif
endif
 
Back
Top