• 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

Need help with Puzzling Attribute Bonus script

Ecneconni

Member
So try as I might, I can't get this script to function the way I want it to.

It is supposed to work in conjunction between two class abilities. One being "Infernal Constitution" for which I have created a custom tag called "Custom.InfernlCon".

The other ability is "Reservoir" which the class gains every level. There are 20 unique id's for this ability. It's done this way, because I am using the custom array-based menu as a way to activate the ability. If it's set to usrIndex 1, it grants access to the classes special, and adds the user tag "Custom.InfernlCon"

The scripts I used are as follows:

For Reservoir:

Script 1 Phase: Pre-levels Priority: 10000


~ If we're disabled, do nothing
doneif (tagis[Helper.FtDisable] <> 0)

if (hero.child[cvktReserv].field[usrIndex].value <> 0) then
hero.childfound[cHelpVKT].field[cGiveSpec].value += 1
endif

~ If we're disabled, do nothing
doneif (tagis[Helper.FtDisable] <> 0)

if (hero.child[cvktReserv].field[usrIndex].value <> 0) then
perform assign[Custom.InfernlCon]
else
perform delete[Custom.InfernlCon]
endif

---- This is the same script for every copy of this ability. ----

For Infernal Constitution:
Script 1
Phase: Attributes Priority 100

~ If we're disabled, do nothing
doneif (tagis[Helper.FtDisable] <> 0)

~ We will grant the hero a constitution of +1 for every three ~ tags "Custom.InfernalCon" found for a max of +7.

if (hero.tagcount[Custom.InfernlCon] <= 21) then
hero.child[aCON].field[Bonus].value += 7
elseif (hero.tagcount[Custom.InfernlCon] <= 18) then
hero.child[aCON].field[Bonus].value += 6
elseif (hero.tagcount[Custom.InfernlCon] <= 15) then
hero.child[aCON].field[Bonus].value += 5
elseif (hero.tagcount[Custom.InfernlCon] <= 12) then
hero.child[aCON].field[Bonus].value += 4
elseif (hero.tagcount[Custom.InfernlCon] <= 9) then
hero.child[aCON].field[Bonus].value += 3
elseif (hero.tagcount[Custom.InfernlCon] <= 6) then
hero.child[aCON].field[Bonus].value += 2
elseif (hero.tagcount[Custom.InfernlCon] <= 3) then
hero.child[aCON].field[Bonus].value += 1
else
hero.child[aCON].field[Bonus].value += 0
endif

-------------------------

Using the Debug Mode I have found that the tag does propagate and is removed when I switch Reservoir on and off.

However, the bonus +7 appears on the constitution ability score regardless of the tag's presence or not. Would someone be able to point out a flaw if they see it, or have encountered this issue before?
 
In your elseif, you're using "less than or equal to", so as soon as it enters the elseif, the tagcount is <= 21, so the very first test passes, and the bonus is set to 7.
 
Your 2nd script is trying to count the number of custom tags on the hero. Your First script is assigning them to the initial context (which is the pick running the script), instead of the hero context. I am also concerned with the following:

Code:
if (hero.child[cvktReserv].field[usrIndex].value <> 0) then
  perform assign[Custom.InfernlCon]
else
  perform delete[Custom.InfernlCon]
  endif

The else branch runs the risk of wiping out all copies of the tag assigned before, if any particular copy of the pick goes down that branch.
 
Try reversing the order of your tests.


if (hero.tagcount[Custom.InfernlCon] <= 3) then
hero.child[aCON].field[Bonus].value += 1
elseif (hero.tagcount[Custom.InfernlCon] <= 6) then
hero.child[aCON].field[Bonus].value += 2
elseif (hero.tagcount[Custom.InfernlCon] <= 9) then
hero.child[aCON].field[Bonus].value += 3
elseif (hero.tagcount[Custom.InfernlCon] <= 12) then
hero.child[aCON].field[Bonus].value += 4
elseif (hero.tagcount[Custom.InfernlCon] <= 15) then
hero.child[aCON].field[Bonus].value += 5
elseif (hero.tagcount[Custom.InfernlCon] <= 18) then
hero.child[aCON].field[Bonus].value += 6
elseif (hero.tagcount[Custom.InfernlCon] <= 21) then
hero.child[aCON].field[Bonus].value += 7
endif

or you could do some math:

~ Set initial bonus to zero
var bonus as number
hero.child[aCON].field[Bonus].value += round(hero.tagcount[Custom.InfernlCon]/3,0,0)

(I may have syntax issues with the round function)
 
Thank you Aaron, that fixed it. :)

I removed the else script, and changed the first one to:

perform hero.assign and that fixed it. I also simplified my Infernal Con script to

hero.child[aCON].field[Bonus].value += round(hero.tagcount[Custom.InfernlCon]/3,0,-1)

and that seems to work nicely.

:) Also thank you Quintin, I had already simplified it when you made the suggestion, but I'm thankful for your input nontheless.
 
Last edited:
Back
Top