Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Hi everyone, still working on the Battle Lord class, up to 12th abilities now, thanks to all of your gracious help.
I've hit a mental block on one ability. I want the script to find all skills that have a minimum number of ranks equal to half the character's class level, and place those in a item selection drop down. Then, once the user makes a selection, grant a bonus to the selected skill. I got started with a foreach pick in hero from BaseSkill where "helper.hasRanks" to narrow the list. After that, I thought I would use the #skillranks macro to identify which ones met the criterion, but I got stuck when I didn't know how to point the macro to all skills. I can figure out how to do the bonus to the user pick, but can't figure out the middle part of the recipe. Any suggestions? |
#1 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
See if you can draw from this example to accomplish what you want:
Code:
<thing id="cMedKnoTal" name="Knowledge of Tales" description="A storyteller gains a +1 bonus on all Knowledge skill checks with Knowledge skills in which he’s trained. This bonus increases by 1 for every 4 medium levels that he possesses.\n\nThis ability replaces spirit bonus." compset="ClSpecial"> <tag group="abAction" tag="None"/> <tag group="abRange" tag="Personal"/> <tag group="abDuration" tag="Constant"/> <tag group="AbilType" tag="Extra"/> <tag group="Helper" tag="SpecUp"/> <eval phase="PostLevel" priority="10000"><![CDATA[ field[abValue].value += round(field[xAllLev].value/4,0,-1) + 1 ~ If we're not shown, just get out now doneif (tagis[Helper.ShowSpec] = 0) ~ If we're disabled, do nothing doneif (tagis[Helper.SpcDisable] <> 0) foreach pick in hero from BaseSkill where "Helper.SkCatKnow & fieldval:skRanks > 0" eachpick.field[Bonus].value += field[abValue].value nexteach ]]></eval> </thing> |
#2 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Hi Aaron, thanks for the challenge. I took it up to the best of my ability, but was not able to figure out how variables could help me, nor could I get the results of my foreach loop dumped into a usr field.
~Set abValue to half the battle lord class levels, rounded down. field[abValue].value += round(field[xTotalLev].value/2,0,-1) ~ If we're disabled, do nothing doneif (tagis[Helper.FtDisable] <> 0) ~ If we're not activated, just get out now doneif (field[abilActive].value = 0) foreach pick in hero from BaseSkill where "Helper.HasRanks & fieldval:skRanks >= field[abValue].value" That's as far as I was able to get. How do I tell the editor to put the results of the foreach into a usr field? |
#3 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
You got the important elements (calculate the number of ranks you want to check for, then combine it with the fieldval element looking at the skRanks field), so good job on that! The bit you're missing is that when building a tag expression like the one you are using in this foreach, only certain types of info can be included. The "field[abValue].value" being included directly into the tag expression isn't understood, but you can have the program alter it into a simple number and incorporate that by placing it outside the "". You need to include and & when appending a value like that though.
Code:
foreach pick in hero from BaseSkill where "fieldval:skRanks >= " & field[abValue].value |
#4 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
Also, double-check your doneifs - you changed one of them from the original example, which was a pair of tests designed for use on class specials to a single doneif that uses a tag designed for feats. Since you're building a class special, like the original example, that shouldn't have changed.
|
#5 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Quote:
Thanks for the catch! |
|
#6 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Quote:
So, once the foreach has proper syntax, I want to throw all positive results from the foreach into a usr field...would this be the right way? Code:
eachpick.field[usr1].value = field[abValue].value nexteach |
|
#7 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
Well, you want to build up the candidate expression field, right? So you can store the thing id of each skill it foreaches over with a splice. BTW the field you are probably wanting isn't usr1, it is usrCandid1
Code:
foreach pick in hero from BaseSkill where "fieldval:skRanks >= " & field[abValue].value field[usrCandid1].text = splice(field[usrCandid1].text, eachpick.tagids[thingid.?], " | ") nexteach |
#8 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Yes, a candidate expression is what I was looking for. We use the splice command to basically say "take the picks that meet the qualifications in the foreach, and place them into a drop-down menu for the user to select. The final element of the splice tells the command to keep looking until it finds no more matching results. I tried it and worked perfectly. Thanks.
Now I want to tell the editor to take the user's selection, and apply a competence bonus to that selection. I tried Code:
field[usrChosen1] = hero.child[usrChosen1].field[BonComp].value += 5 |
#9 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
Back to the scripting tutorials:
http://forums.wolflair.com/showthread.php?t=21688 You're doing math here, so what does the math tutorial say about how you can use an abbreviation to save yourself a lot of typing when doing arithmetic? Once you've got that fixed, then we'll do another fix for this line - competence bonuses are non-stacking, so you're not actually adding a bonus in the correct way. As written, your bonus will stack with anything else that's adding a competence bonus. But still best to make sure you understand how to set up the basic math, and then we'll do a lesson on how to apply non-stacking bonuses. |
#10 |
|
|