Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Pathfinder Roleplaying Game
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
bertraze
Member
 
Join Date: Aug 2013
Posts: 30

Old June 3rd, 2014, 12:39 PM
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
bertraze is offline   #1 Reply With Quote
Aaron
Senior Member
 
Join Date: Oct 2011
Posts: 6,793

Old June 3rd, 2014, 12:48 PM
#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).
Aaron is offline   #2 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old June 3rd, 2014, 12:51 PM
#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.
Mathias is offline   #3 Reply With Quote
bertraze
Member
 
Join Date: Aug 2013
Posts: 30

Old June 3rd, 2014, 02:12 PM
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.
Quote:
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 by bertraze; June 3rd, 2014 at 02:13 PM. Reason: Pasted in correct version of code.
bertraze is offline   #4 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old June 3rd, 2014, 02:27 PM
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

Hero Lab Resources:
Pathfinder - d20pfsrd and Pathfinder Pack Setup
3.5 D&D (d20) - Community Server Setup
5E D&D - Community Server Setup
Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources.
Created by the community for the community
- Realm Works kickstarter backer (Alpha Wolf) and Beta tester.
- d20 HL package volunteer editor.
ShadowChemosh is offline   #5 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:54 AM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.