Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - D&D 5th Edition SRD
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
Mergon
Senior Member
 
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788

Old September 2nd, 2016, 10:04 AM
I need help again.

I am working on a class ability where you pick a favored type of weapon (say rapiers).

I need help figuring out how to get the thingid from the selected weapon to use in a foreach loop to cycle through all the weapons on the hero and add a bonus to the appropriate weapons attack rolls.

I just can't for the life of me figure out how to the pulled thingid from the chosen weapon into my foreach loop?

Watch your back, Conserve your ammo,
and NEVER cut a deal with a dragon!
Mergon is offline   #1 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old September 3rd, 2016, 12:16 PM
There are at least two ways to do this.

METHOD 1:
If you're in the editor, click on the Equipment tab at the top, then in the subheadings, click on the Weapon tab.

In the bottom left, click "New (Copy)", and in the list that shows up, you should see a list of weapons with the thingid in parentheses for each weapon. You can click cancel once you have what you need.

METHOD 2:
On the Develop menu, make sure "Enable Data File Debugging" is checked. (It's at the very top of that menu.)

Add the weapon to the character.

Move the mouse pointer over the name of the weapon, right-click, and select "Show Debug Fields for <weapon-name>"

A new window should open up showing you all the fields for that weapon. At the top, centered above the column headers, you'll see something like: Fields for "<weapon-name>" (<thingid>) on hero "Unnamed Hero"

Again, the thingid is the value in parentheses.
EightBitz is offline   #2 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old September 3rd, 2016, 12:29 PM
Yes. But don't actually ever use Thingid in a search expression. Its much better to use "other" universal Tag Groups. For weapons you would want to use IsWeapon.? actually. That way you get any weapon "tagged" as a Rapier. Its not uncommon to have a weapon that gets "treated" as a another weapon.

Also allows players/groups to have a "specific" rapier types like "Elven Gold Rapier" and in the editor they select "Treat as Rapier".

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.
ShadowChemosh is offline   #3 Reply With Quote
Mergon
Senior Member
 
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788

Old September 3rd, 2016, 06:28 PM
EightBitz
Thanks for the info, but I already knew that part.

Shadow:

I'd normally agree with you but this ability covers even weapons treated as rapiers. My problem is getting the weapon type. like raper, from a field[usrChosen1.chosen . . . so I can somehow use it in a Foreach loop . . .

For example, if I chose a rapier from my weapons dropdown, I need my Foreach loop to search all the weapons on the hero for rapiers and weapons that are treated as rapier. Then eachpick will be granted abilities based on the level of the hero.

For example if you have chosen rapiers as your favored weapon, then at first level they are treated as a non-magical +1 weapon (on attack & damage rolls).

What I am having issues with is getting the weapon type, either thingid.Rapier or IsWeapon.Rapier out of the choice dropdown and into my

Quote:
foreach pick in hero from BaseWep where “thingid.Rapier or IsWeapon.Rapier

Watch your back, Conserve your ammo,
and NEVER cut a deal with a dragon!
Mergon is offline   #4 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old September 3rd, 2016, 07:09 PM
Quote:
Originally Posted by Mergon View Post
EightBitz
Thanks for the info, but I already knew that part.

Shadow:

I'd normally agree with you but this ability covers even weapons treated as rapiers. My problem is getting the weapon type. like raper, from a field[usrChosen1.chosen . . . so I can somehow use it in a Foreach loop . . .

For example, if I chose a rapier from my weapons dropdown, I need my Foreach loop to search all the weapons on the hero for rapiers and weapons that are treated as rapier. Then eachpick will be granted abilities based on the level of the hero.

For example if you have chosen rapiers as your favored weapon, then at first level they are treated as a non-magical +1 weapon (on attack & damage rolls).

What I am having issues with is getting the weapon type, either thingid.Rapier or IsWeapon.Rapier out of the choice dropdown and into my
Code:
foreach pick in hero from BaseWep where “thingid.Rapier or IsWeapon.Rapier ”
You may have already known the part that I told you, but you don't seem to have followed the steps.

Code:
foreach pick in hero from BaseWep where “thingid.wRapier or IsWeapon.wRapier ”
EightBitz is offline   #5 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old September 3rd, 2016, 07:13 PM
Quote:
Originally Posted by EightBitz View Post
You may have already known the part that I told you, but you don't seem to have followed the steps.

Code:
foreach pick in hero from BaseWep where “thingid.wRapier or IsWeapon.wRapier ”
Also, your code seems redundant.

Code:
foreach pick in hero from BaseWep where “IsWeapon.wRapier”
If the thingid is wRapier, then it will have the tag IsWeapon.wRapier, so you shouldn't need to test for both. You should only have to test for the tag.
EightBitz is offline   #6 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old September 3rd, 2016, 08:21 PM
Like this:

Code:
      var searchexpr as string
      ~ "TagIds" builds you a string of all the different IsWeapon tags on the 
      ~ Pick. The 2nd parameter "|" says separate each Tag using |
      searchexpr = field[usrChosen1].chosen.tagids[IsWeapon.?,"|"]

      foreach pick in hero from BaseWep where searchexpr
      nexteach
So if the weapon selected had the tags "IsWeapon.wRapier" and "IsWeapon.wLongsword" you would get:
Code:
IsWeapon.wRapier|IsWeapon.wLongsword
in the "SearchExpr" variable.

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.
ShadowChemosh is offline   #7 Reply With Quote
Mergon
Senior Member
 
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788

Old September 4th, 2016, 08:08 AM
Shadow:

Thanks yet again. Of all things in HL scripting, its expression that give me the most difficulty.

Note: Something new learned; I didn't know you could use a variable in foreach pick in hero from BaseWep where searchexpr.

Watch your back, Conserve your ammo,
and NEVER cut a deal with a dragon!

Last edited by Mergon; September 4th, 2016 at 04:20 PM.
Mergon is offline   #8 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old September 5th, 2016, 03:34 AM
Quote:
Originally Posted by ShadowChemosh View Post
Like this:

Code:
      var searchexpr as string
      ~ "TagIds" builds you a string of all the different IsWeapon tags on the 
      ~ Pick. The 2nd parameter "|" says separate each Tag using |
      searchexpr = field[usrChosen1].chosen.tagids[IsWeapon.?,"|"]

      foreach pick in hero from BaseWep where searchexpr
      nexteach
So if the weapon selected had the tags "IsWeapon.wRapier" and "IsWeapon.wLongsword" you would get:
Code:
IsWeapon.wRapier|IsWeapon.wLongsword
in the "SearchExpr" variable.
Just for my own understanding, in this example, within the foreach loop, you would have to test the value of searchexpr to see if it contains "IsWeapon.wRapier", right? Because if that's not the case, I'm missing something fundamental.

Why is this better than including "IsWeapon.wRapier" in the initial search expression? such as:

searchexpr = field[usrChosen1].chosen.tagids[IsWeapon.wRapier]

I'm still very much a novice at this, so I'm not trying to argue. Just trying to understand.
EightBitz is offline   #9 Reply With Quote
Mergon
Senior Member
 
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788

Old September 5th, 2016, 04:35 AM
Quote:
Originally Posted by EightBitz View Post
Just for my own understanding, in this example, within the foreach loop, you would have to test the value of searchexpr to see if it contains "IsWeapon.wRapier", right? Because if that's not the case, I'm missing something fundamental.

Why is this better than including "IsWeapon.wRapier" in the initial search expression? such as:

searchexpr = field[usrChosen1].chosen.tagids[IsWeapon.wRapier]

I'm still very much a novice at this, so I'm not trying to argue. Just trying to understand.
From what ShadowChemosh explained using thingid.wRapier is bad coding. It identifies that are both rapiers and weapons that are treated as rapier where WeaponIs.wRapier identifies only true rapiers. Understand, I was using Rapiers only as examples.

In my case I wanted to chose a weapon from a list of weapons on the hero. From the chosen weapon, I wanted to extract the Type of weapon it was. Once I had that I wanted to to grant all weapons of that type, and all weapons that are treated as that type, a bonus on attack & damage rolls or +1-3 depending on the level. Making it trickier was the fact that this bonus would not stack with any bonuses already on the weapon; just the higher of the 2 bonuses.

Also this is for a class ability called Favored Weapon.

The information that Shadow provided me with both taught me something I didn't know about HL scripting and solved my issue within 5 minutes (after I fitted it in to my script.)

Watch your back, Conserve your ammo,
and NEVER cut a deal with a dragon!
Mergon is offline   #10 Reply With Quote
Reply


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 03:46 PM.


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