• 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

What's the user's choice for "Favored Enemy"?

I'd like to write an eval script in a class that can detect the user's selection of a custom ability I created, based on the Ranger's "Favored Enemy" or "Favored Terrain". How can I get the value of the user's selection and then do an if/else or switch operation depending on the user's selection?

Thanks!
 
Favored Enemy and Terrain are just Abilities actually. So in example Favored Enemy (Aberrations) is Thingid.feAberr. So to test for it you could do the following:

Code:
~ Test for the presence of FE aberration 
If (#hasability[feAberr] <> 0) Then
  ~ Do stuff here
Endif

Though without knowing the rest of what you want to accomplish the above may not work as you will have to test for the HasAbility.? tag very late in timing. For earlier you would want to look for the Ability.? tag instead:
Code:
If (hero.tagis[Ability.feAberr] <> ) Then
  ~ Do stuff
endif

As the ability is a unique Thing one way to test without checking tags is to see if the childlives. This method you could test for very early if you need to but have to be careful in other cases using this as it does no testing to see if something else disabled the ability.
Code:
If (hero.childlives[feAberr] <> 0) Then
  ~ Do stuff
Endif
 
Thanks ShadowChemosh, but I'm still confused about how to get the users selection from the drop down control. I need to run an if/else based on what the user chose.
 
For example, I'd like to do something like...

Code:
If (hero.tagis[Ability.feAberr] <> ) Then
  ~ Do stuff like...
  var usersFavoredEnemy = #howDoIGetThisValue[Ability.feAberr]
  If (usersFavoredEnemy == firstThingFromTheListOfPossibleChoices) Then
    ~ setup some extra abilities and add help text to character sheet printouts
  ElseIf (usersFavoredEnemy == secondThingFromTheListOfPossibleChoices) Then
    ~ setup some extra abilities and add help text to character sheet printouts
  ElseIf (usersFavoredEnemy == thirdThingFromTheListOfPossibleChoices) Then
    ~ setup some extra abilities and add help text to character sheet printouts
  ElseIf (usersFavoredEnemy == fourthThingFromTheListOfPossibleChoices) Then
    ~ setup some extra abilities and add help text to character sheet printouts
  EndIf 
endif

I'm very curious about how to setup the values for the variables usersFavoredEnemy, firstThingFromTheListOfPossibleChoices, secondThingFromTheListOfPossibleChoices, thirdThingFromTheListOfPossibleChoices, and fourthThingFromTheListOfPossibleChoices.

My 10 year old son is trying to build a new class called "Elementalist" and at level 1 you are required to chose one of the four elements. Based on your element selection, you have different abilities and feats available. Any help provided here gives me and my son more fun in Hero Lab, and I'm very grateful for all the support people like you provide on these forums and elsewhere for Hero Lab scripting.
 
Could you explain the game rules of what you're trying to accomplish, please? From the quick bit you just said, I don't think favored enemies are the right mechanism to use for this.
 
We want a class that on its first level forces the user to select a favored element, air, fire, earth or water. Once the favored element is selected, we want to enable different abilities. The air elementalist will have a different set of abilities from the other three.

We were thinking that we might need to use archetypes to do this and that would be how the elementalist chose their favored element... in other words, have an elementalist class and 4 archetypes for it... Air Elementalist, Fire Elementalist, Earth Elementalist and Water Elementalist. To us it seemed that containing things all in a single class might be a better user experience though.

What's your recommendation for implementing this? Did I give enough information about our idea?
 
Are there any abilities that are completely unique to specific elements?

How much does each element differ from the others? Are they using the same powers, and just changing the description or damage type based on the element, or are they using completely different powers?

Favored Enemies are completely unrelated to what you're trying to accomplish. I'd recommend looking at the Elemental bloodline for Sorcerers - that's probably the closest thing to what you're trying to accomplish.

Most likely, it'll be easiest to implement this as four completely separate classes - switching the way an ability works and turning on or off abilities depending on a selection are advanced topics, and I would not recommend trying to accomplish that if this is the first thing you've ever created in the Hero Lab editor.
 
We want a class that on its first level forces the user to select a favored element, air, fire, earth or water. Once the favored element is selected, we want to enable different abilities. The air elementalist will have a different set of abilities from the other three.

This sounds like it is exactly what I just finished doing here. The Archetype I created has to choose an element, once two of those elements were selected, it unlocked additional abilities.

Basically what I did was create separate Class Specials for each of them. So there are 4 four class specials where they select the base element (Earth, Fire, Water, Air). Depending on which element they choose, a tag is added to the hero. Then the others (Air + Water, Air + Fire etc) are attached to the class with a condition to look for the tags. (You will need to create new tags and not use the ones that I have listed because it could cause problems if you get the file I used them in.)

Hope that helps.
 
Umarian, I owe you a beer, perfect match to what i was trying to do!

Here's the code I was able to use in the First phase as an eval script of my new class:

Code:
doneif (hero.tagis[Ability.FE] <> 0)
If (hero.child[FE].field[usrChosen1].chosen.tagis[thingid.selElAir] <> 0) Then
   debug "Favored Element: Air!"
elseIf (hero.child[FE].field[usrChosen1].chosen.tagis[thingid.selElEarth] <> 0) Then
   debug "Favored Element: Earth!"
elseIf (hero.child[FE].field[usrChosen1].chosen.tagis[thingid.selElFire] <> 0) Then
   debug "Favored Element: Fire!"
elseIf (hero.child[FE].field[usrChosen1].chosen.tagis[thingid.selElWater] <> 0) Then
   debug "Favored Element: Water!"
else 
   debug "Favored Element: no selection made yet!"
Endif

I love it! On to more puzzles!
 
Back
Top