• 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

Eval Script help

Mergon

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

foreach pick in hero from BaseWep where “thingid.Rapier or IsWeapon.Rapier
 
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 ”
 
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.
 
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 |
      [B]searchexpr [/B]= field[usrChosen1].chosen.tagids[IsWeapon.?,"|"]

      foreach pick in hero from BaseWep where [B]searchexpr[/B]
      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.
 
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.
 
Last edited:
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 |
      [B]searchexpr [/B]= field[usrChosen1].chosen.tagids[IsWeapon.?,"|"]

      foreach pick in hero from BaseWep where [B]searchexpr[/B]
      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.
 
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.) :D
 
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.
Making a guess but I think its the field[usrChosen1].chosen that is throwing you. That "field" means we have a dropdown list of Picks/Things that a person selected. Sense we do not know "which" weapon was chosen (in example we assumed Rapier) but it could have just as easily been longsword or greatsword. In other words the dropdown has a choice of weapons from one to hundred.

So we need to pull a "Tag" group from the weapon chosen without knowing what the "specific" tag is. Then use that tag to find all Live Picks of that weapon on the hero which is what the foreach loop is doing. Sense the "search expression" field holds all the logic of which Picks to select we do not need to test for anything in the foreach loop.

My initial comment was to not use "thingid.?" tag group for the search expression as a Pick can only have ONE thingid.? group on itself. Where IsWeapon.? group can be assigned many times to a Pick. Which allows flexibility.

Hopefully that helps. :)
 
Making a guess but I think its the field[usrChosen1].chosen that is throwing you. That "field" means we have a dropdown list of Picks/Things that a person selected. Sense we do not know "which" weapon was chosen (in example we assumed Rapier) but it could have just as easily been longsword or greatsword. In other words the dropdown has a choice of weapons from one to hundred.

So we need to pull a "Tag" group from the weapon chosen without knowing what the "specific" tag is. Then use that tag to find all Live Picks of that weapon on the hero which is what the foreach loop is doing. Sense the "search expression" field holds all the logic of which Picks to select we do not need to test for anything in the foreach loop.

My initial comment was to not use "thingid.?" tag group for the search expression as a Pick can only have ONE thingid.? group on itself. Where IsWeapon.? group can be assigned many times to a Pick. Which allows flexibility.

Hopefully that helps. :)

OK, yep. You were exactly right on the point I was missing. I had to go back and read the original post to put it all together, but I got it now. Thanks.
 
Back
Top