Junior Member
Join Date: Feb 2013
Posts: 20
|
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! |
#1 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
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 Code:
If (hero.tagis[Ability.feAberr] <> ) Then ~ Do stuff endif Code:
If (hero.childlives[feAberr] <> 0) Then ~ Do stuff Endif 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. |
#2 |
Junior Member
Join Date: Feb 2013
Posts: 20
|
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.
|
#3 |
Junior Member
Join Date: Feb 2013
Posts: 20
|
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 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. |
#4 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,217
|
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.
|
#5 |
Junior Member
Join Date: Feb 2013
Posts: 20
|
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? |
#6 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,217
|
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. |
#7 |
Senior Member
Join Date: Apr 2010
Location: Lemont, IL
Posts: 320
|
Quote:
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. |
|
#8 |
Junior Member
Join Date: Feb 2013
Posts: 20
|
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 |
#9 |
|
|