Member
Join Date: Aug 2013
Posts: 30
|
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 |
#1 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
#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).
|
#2 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
#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)) 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 |
#3 |
Member
Join Date: Aug 2013
Posts: 30
|
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 Quote:
Last edited by bertraze; June 3rd, 2014 at 02:13 PM. Reason: Pasted in correct version of code. |
|
#4 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
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 I think what you want is this: Code:
if (focus.tagis[Custom.Analyzer1] <> 0) then 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) 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. |
#5 |
|
|