Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - d20 System

Notices

Reply
 
Thread Tools Display Modes
draco963
Member
 
Join Date: Jul 2015
Location: Ottawa
Posts: 52

Old December 13th, 2020, 12:14 PM
Ok I'll try to be clearer about the field[value] thing.

The way the Legacy items work, they reference the increment count of the Legacy adjustment. So, each Legacy item uses the code:
Code:
foreach pick in hero from BaseInPlay where "thingid.pRM_LgcyRitsWndr"
  if (eachpick.field[pChosen].chosen.tagis[thingid.ioRMAssHnd]<>0) then
    field[Value].value = eachpick.field[pAdjust].value
  endif
nexteach
The thingid's change for each Legacy item, based on if it's armour, weapon, or wondrous item, but the functionality is the same. to count the increment of the Adjustment for the individual Legacy item. That count is then "found", or maybe "assigned" is the better term, in each subsequent script for the Legacy item (most have over a dozen scripts by level 20), using this:
Code:
Rit = field[Value].value
So, for one item in particular, the Assassin's Hands, the plan is for them to increase the Sneak Attack dice. So, to do that, I searched how Sneak Attack works, and found this script:
Code:
hero.child[xSneakAtt].field[Value].value
So, I figure this following code should work to increase the Sneak Attack dice count:
Code:
hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
But, my concern was that the command to increase the SneakAttack value is nested under an If statement, which checks that Rit value assigned above. So, the whole thing looks like this:
Code:
var HD as number
HD = hero.tagcount[Hero.HitDice]
var Rit as number
Rit = field[Value].value

    if (HD >= 18) then
        if (Rit >= 3) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 4
        elseif (Rit >= 2) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 3
        elseif (Rit >= 1) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
        endif
    elseif (HD >= 14) then
        if (Rit >= 2) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 3
        elseif (Rit >= 1) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
        endif
    elseif (HD >= 11) then
        if (Rit >= 2) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 2
        elseif (Rit >= 1) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
        endif
    elseif (HD >= 9) then
        if (Rit >= 1) then
            hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
        endif
    endif
As you can see, in that long chunk above, there are two entirely separate things, The Ritual count and the Sneak Attack dice count, both referenced as "field[Value].value", which in my brain, breaks.

So, I finally tested it just now , and it does appear to work. But I truly do not understand why...

As for the ShowMenu drop-down list for Legacy Wondrous items:
I'm confused how/why this script is working also. In the Editor, the actual ShowMenu selection for the Wondrous Items Legacy Adjustment is currently set to "Current Armor". When I use the script you sent me, it nevertheless shows only the Magic Items on the Hero. I changed it to check BaseWonder instead, and now it shows only Assassin's Hands. This is great! Fantastic, wunderbar! But, is there any way to add a different entry to the ShowMenu list itself? I think I understand what the script is doing (replacing the selected drop-down list with the scripted one), but if I add a new tag to the ShowMenu drop-down in the Editor, the script breaks, and shows me every wondrous item, instead of those only on my hero. How can I build a new ShowMenu slection?

Thank you Sendric! I really appreciate the help and your explanations!
draco963 is offline   #11 Reply With Quote
Sendric
Senior Member
 
Join Date: Jul 2010
Posts: 2,985

Old December 14th, 2020, 05:25 AM
Quote:
Originally Posted by draco963 View Post
Ok I'll try to be clearer about the field[value] thing.

But, my concern was that the command to increase the SneakAttack value is nested under an If statement, which checks that Rit value assigned above.

As you can see, in that long chunk above, there are two entirely separate things, The Ritual count and the Sneak Attack dice count, both referenced as "field[Value].value", which in my brain, breaks.

So, I finally tested it just now , and it does appear to work. But I truly do not understand why...
So as you have already learned, this is totally fine. Why? Because:

Code:
Rit = field[Value].value
means "set the variable Rit equal to the value of the Value field on the thing this script is written in"

while

Code:
hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
means "add 1 to the value of the Value field of the thing xSneakAtt".

In each case you are referencing the Value field, but of two different things. If you don't include "hero.child[xxx]." before "field[Value].value" it defaults to the thing the script is written on.

Two coding tips to be aware of:

1) It's often better to use "hero.childfound" instead of "hero.child". Adding found reduces the potential for error messages because it will only function if the the thing you're trying to manipulate is found on the hero. "hero.child" should only be used in cases where you know for sure the thing will always be on the hero in all situations.

2) The following two lines of code mean exactly the same thing:

Code:
hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
Code:
hero.child[xSneakAtt].field[Value].value += 1
For obvious reasons, I generally prefer the one with less characters.

Quote:
Originally Posted by draco963 View Post
As for the ShowMenu drop-down list for Legacy Wondrous items:
I'm confused how/why this script is working also. In the Editor, the actual ShowMenu selection for the Wondrous Items Legacy Adjustment is currently set to "Current Armor". When I use the script you sent me, it nevertheless shows only the Magic Items on the Hero. I changed it to check BaseWonder instead, and now it shows only Assassin's Hands. This is great! Fantastic, wunderbar! But, is there any way to add a different entry to the ShowMenu list itself? I think I understand what the script is doing (replacing the selected drop-down list with the scripted one), but if I add a new tag to the ShowMenu drop-down in the Editor, the script breaks, and shows me every wondrous item, instead of those only on my hero. How can I build a new ShowMenu slection?

Thank you Sendric! I really appreciate the help and your explanations!
The script works because of the timing. The ShowMenu selection sets the field at Pre-Levels/10000. Unfortunately, this seems to not be working properly. I can't do much about that, so instead we create a script to replace the field with what we want immediately after that time. This is perfectly fine and easier than trying to deal with creating a new tag.

As to why adding a new tag breaks it, I'm not sure, but I'd recommend sticking with using a script to set it. You still need to use a tag to make sure the show selection drop down appears in the adjustment, but you should use one of the pre-set ones and not a new one.

You originally asked for a script that showed all magic items, which is what I provided. Are you looking for something narrower?
Sendric is offline   #12 Reply With Quote
draco963
Member
 
Join Date: Jul 2015
Location: Ottawa
Posts: 52

Old December 14th, 2020, 12:45 PM
Thank you Sendric! I get it now! I really appreciate the coding examples and explanations, and I'll switch my scripts to hero.childfound, because absolutely yes, these things could be used in circumstances where the scripts they're aimed at aren't available on the hero.

I had been using Magic Items, then I realised that that pulls ALL magic items, not just items, as opposed to weapons or armours. Hmm... Actually, typing this out, having a custom drop-down that snags all magic items might be better, becuase then I could use one adjustment that catches all three types, as oppsed to sepearte ones for weapons, armours, and items. Right?
draco963 is offline   #13 Reply With Quote
Illyahr
Senior Member
 
Join Date: Feb 2013
Posts: 322

Old December 14th, 2020, 07:36 PM
Ah, the two moods for coders everywhere:
Yes! It works!
Why doesn't this work?!
Illyahr is offline   #14 Reply With Quote
draco963
Member
 
Join Date: Jul 2015
Location: Ottawa
Posts: 52

Old December 15th, 2020, 06:47 PM
lol
draco963 is offline   #15 Reply With Quote
Reply

Thread Tools
Display Modes

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:28 PM.


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