• 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

Have the ingredients, but need help with the recipe

Bob G

Well-known member
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?
 
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>

Hint: You can set variables and include them with tag expressions.
 
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?
 
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

I think that should work.
 
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.
 
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.

You're right, Mathias, I'm not sure how that happened, but it wasn't intentional. I've changed it back to the original.

Thanks for the catch!
 
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

I think that should work.

Thanks Aaron, that makes sense. The 'HasRanks' tag is redundant if skRanks is greater than zero.

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
 
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

Splice has 3 elements inside the (), the first is the string of text you are inserting into, the second is the text inserted, and the third is a divider that comes before element 2, but is only inserted if element one is not empty. So if the first skill you iterate to in the foreach is Acrobatics will insert "thingid.skAcrobat", and the second is Bluff it will add " | thingid.skBluff"
 
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
but it gave me an error on the field context. How do I point it correctly to the user's selection?
 
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.
 
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.

Will do, sir!
 
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.

I think the abbreviation you're referencing is something like this:
Code:
field[usrChosen1].value += field[BonComp].value += 5
But I know that's not exactly right. I want to point to the skill that the user selects, go to that skill, and add a +5 competence bonus to it. Is it better to do:
Code:
field[usrChosen1].field[BonComp].value +=5
Thanks for all your patience with me. I'm learning slowly, but surely.
 
The first of those will not work. The second one is close, but you've made a mistake in your transitions - there's something missing in-between field[usrChosen1] and field[BonComp].value.
 
The first of those will not work. The second one is close, but you've made a mistake in your transitions - there's something missing in-between field[usrChosen1] and field[BonComp].value.

Figured it out!
Code:
~Take the selection chosen by the user and grant a +5 competence bonus to the skills selected
     field[usrChosen1].chosen.field[BonComp].value +=5
There's one thing left to fix, and this ability is perfect:
1. If the user is selecting two skills to apply the bonus to, and choses the first skill, can we eliminate that choice from the list of candidates on the second list?
 
Eliminating the second one is more work than we consider it to be worth for our own material when writing abilities that make changes to two separate choices from the same list. If you want, you can write an eval rule to complain if the user selects the same thing twice (there should be several examples of that sort of thing out there).

Now, in the editor's help menu...help on using the editor, and then read the section named "Reference Information". Start with the "General Modifiers" section there, and then scroll back up a little ways, and look within "Useful Macros" for things that are designed to work along with those General Modifiers.
 
Eliminating the second one is more work than we consider it to be worth for our own material when writing abilities that make changes to two separate choices from the same list. If you want, you can write an eval rule to complain if the user selects the same thing twice (there should be several examples of that sort of thing out there).

Now, in the editor's help menu...help on using the editor, and then read the section named "Reference Information". Start with the "General Modifiers" section there, and then scroll back up a little ways, and look within "Useful Macros" for things that are designed to work along with those General Modifiers.

Right, so the #applybonus macro already has the Maximum function built in, so that non-stacking bonuses don't stack:
Code:
#applybonus[BonComp],field[usrChosen1].chosen, 5
:)
 
You're closing the [ ] too early - you're closing it just after the bonus type, but you'll need to close it at the end.
 
Back
Top