Senior Member
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788
|
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! |
#1 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
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. |
#2 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
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. |
#3 |
Senior Member
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788
|
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:
Watch your back, Conserve your ammo, and NEVER cut a deal with a dragon! |
|
#4 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
Quote:
Code:
foreach pick in hero from BaseWep where “thingid.wRapier or IsWeapon.wRapier ” |
|
#5 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
Quote:
Code:
foreach pick in hero from BaseWep where “IsWeapon.wRapier” |
|
#6 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
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 Code:
IsWeapon.wRapier|IsWeapon.wLongsword 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. |
#7 |
Senior Member
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788
|
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. |
#8 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
Quote:
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. |
|
#9 |
Senior Member
Join Date: Sep 2012
Location: Ottawa, Canada
Posts: 788
|
Quote:
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! |
|
#10 |
|
|