• 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

[Code Q] Choice of energy resistance

Bishop37

Well-known member
Ok, new question...I am working on a template that will give the creature a choice of energy resist (acid, cold, electricity or fire). I am basing this loosely off of the elemental bloodline and ShadowChemosh's work on the shifter racial traits.

Let me start with the code for the core racial ability and a sample of one of the subtypes

Here is the core ability:
Code:
<thing id="raGmGargER" name="Energy Resistance" description="You have resistance 10  to acid, cold, electricity, or fire (choose one)." compset="RaceSpec" summary="You have resistance 10 to one energy type.">
    <fieldval field="usrCandid1" value="thingid.raGGrgERAc|thingid.raGGrgERCd|thingid.raGGrgEREl|thingid.raGGrgERFi"/>
    <tag group="ChooseSrc1" tag="Thing"/>
    <bootstrap thing="raGGrgERAc">
      <containerreq phase="First" priority="500">Custom.GemAcid</containerreq>
      </bootstrap>
    <bootstrap thing="raGGrgERCd">
      <containerreq phase="First" priority="500">Custom.GemCold</containerreq>
      </bootstrap>
    <bootstrap thing="raGGrgEREl">
      <containerreq phase="First" priority="500">Custom.GemElec</containerreq>
      </bootstrap>
    <bootstrap thing="raGGrgERFi">
      <containerreq phase="First" priority="500">Custom.GemFire</containerreq>
      </bootstrap>
    <eval phase="First" priority="10000"><![CDATA[~First 10,000
if (field[usrChosen1].ischosen <> 0) then
   perform field[usrChosen1].chosen.pulltags[Custom.?]
endif]]></eval>
    <eval phase="PostLevel" priority="10000" index="2"><![CDATA[~Post-Levels 10,000
      ~ If we're not shown, just get out now
      doneif (tagis[Helper.ShowSpec] = 0)
      ~ If we are not activated get out now
      doneif (field[abilActive].value = 0)

      if (hero.tagis[Custom.GemAcid] <> 0) then
           #applyresist[xDamRsAcid, 10]
      endif
      if (hero.tagis[Custom.GemCold] <> 0) then
           #applyresist[xDamRsCold, 10]
      endif
      if (hero.tagis[Custom.GemElec] <> 0) then
           #applyresist[xDamRsElec, 10]
      endif
      if (hero.tagis[Custom.GemFire] <> 0) then
           #applyresist[xDamRsFire, 10]
      endif]]></eval>
    </thing>

And here is one of the sub abilities (for acid)
Code:
<thing id="raGGrgERAc" name="Energy Resistance (Acid)" description="You have resistance 10  to acid." compset="RaceSpec" summary="You have resistance 10 to acid">
    <tag group="Custom" tag="GemAcid"/>
    <tag group="SpecType" tag="Resist"/>
    <eval phase="PreLevel" priority="10000" index="2"><![CDATA[field[livename].text = "Acid"]]></eval>
    <eval phase="PostLevel" priority="1000"><![CDATA[~Post-Levels 1,000
if (hero.tagis[Custom.GemAcid] <> 0) then
     perform assign[Helper.ShowSpec]
endif]]></eval>
    </thing>

What works:
The template creates a field on the background tab, under racial abilities to choose the energy type.
I don't get any errors.

What doesn't work:
Everything else :)

The drop down field is showing the full name "Energy Resistance (Acid)" for the energy type, although I just want it to show "Acid".
It does not apply the energy resistance at all.
It adds an additional racial ability "Energy Resistance (Acid)" that is showing a long name in the help popup of "Acid (Energy Resistance: Energy Resistance (Acid))". I was expecting the added racial ability due to how the Shifter abilities worked on ShadowChemosh's data files, but this particular error is beyond me.

Any help on this would be much appreciated. Lack of sleep made me overlook that #applydr doesn't work with spell resistance, but I can't use that as an excuse for the rest of this. I'm just a lil lost :)

Rob
 
Let me outline the way I'd go about this.

First, there's already an energy selection option available - there's no reason to create new selection things.

Create your selector as a racial special. In the "Select From" option, choose "Energy Type (Base 4)".

For the script, you can use the BloodEner tags that exist on the elemental/energy selector picks.
Code:
~if nothing's been selected, there's nothing we can do
doneif (field[usrChosen1].ischosen = 0)
 
if (field[usrChosen1].chosen.tagis[BloodEner.Acid] <> 0) then
  #applydr[xDamRsAcid, 10]
elseif (field[usrChosen1].chosen.tagis[BloodEner.Cold] <> 0) then
  #applydr[xDamRsCold, 10]
 elseif (field[usrChosen1].chosen.tagis[BloodEner.Elec] <> 0) then
  #applydr[xDamRsCold, 10] 
elseif (field[usrChosen1].chosen.tagis[BloodEner.Fire] <> 0) then
  #applydr[xDamRsCold, 10]
  endif
 
I think I see what's not working with your thing.

You use pulltags to pull the tag you're working with from the selection to the special.

But later on, you're looking for it on the hero, not on the special.

You'd need to add the following code after the pulltags to forward that tag to the hero:

Code:
perform forward[Custom.?]
 
Let me outline the way I'd go about this.

First, there's already an energy selection option available - there's no reason to create new selection things.

Create your selector as a racial special. In the "Select From" option, choose "Energy Type (Base 4)".

I had seen that option, but I couldn't figure out the rest of the code to go with it. I'll try this out when I get home today.
 
Well, the first bit you provided helped fix a lot of my issues...the drop down menu displays correctly and its much cleaner. But it still isn't applying the energy resistance, so there is still something I'm missing. Here is the updated code for the ability.

Code:
<thing id="raGmGargER" name="Energy Resistance" description="You have resistance 10  to acid, cold, electricity, or fire (choose one)." compset="RaceSpec" summary="You have resistance 10 to one energy type.">
    <tag group="ChooseSrc1" tag="Thing"/>
    <tag group="SpecType" tag="Resist"/>
    <tag group="fShowWhat" tag="EnergyBase"/>
    <eval phase="PostLevel" priority="1000" index="2"><![CDATA[~if nothing's been selected, there's nothing we can do
doneif (field[usrChosen1].ischosen = 0)
 
if (field[usrChosen1].chosen.tagis[BloodEner.Acid] <> 0) then
  #applyresist[xDamRsAcid, 10]
elseif (field[usrChosen1].chosen.tagis[BloodEner.Cold] <> 0) then
  #applyresist[xDamRsCold, 10]
elseif (field[usrChosen1].chosen.tagis[BloodEner.Elec] <> 0) then
  #applyresist[xDamRsElec, 10] 
elseif (field[usrChosen1].chosen.tagis[BloodEner.Fire] <> 0) then
  #applyresist[xDamRsFire, 10]
  endif]]></eval>
    <eval phase="First" priority="10000" index="3"><![CDATA[~First 10,000
if (field[usrChosen1].ischosen <> 0) then
   perform field[usrChosen1].chosen.pulltags[BloodEner.?]
endif]]></eval>
    </thing>
 
Your template is bootstrapping all 4 damage resistance picks, right?

(You could bootstrap them from the ability instead)
 
Your template is bootstrapping all 4 damage resistance picks, right?

(You could bootstrap them from the ability instead)

I had tried bootstrapping from the ability but I was getting the following error:
Attempt to access non-live child pick 'xDamRsAcid' from script
(repeats 3 more times)

When I bootstrap from the template I get the following similar error:
Attempt to access non-live child pick 'xDamRsAcid' from script
Location: 'eval' script for Thing 'raGmGargER' (Eval Script '#2') near line 5

My bootstrapping is First:499, xDamRsAcid, conditional BloodEner.Acid and so on for each of the energy types.
 
Don't put any conditionals on the bootstrapped xDamRs's Damage Resistances automatically hide themselves if their value is 0, so there's no harm in having all four present on every character that takes this template - only the one that's getting a value added by the script will be seen.

The reason you're having trouble is that your conditional is looking for BloodEner tags at First/499, but you're not pulling the BloodEner tags onto the ability until later, at First/10000. You'd also need to forward them to the hero before the conditionals could look for them.
 
On this same note, how would I exclude the Acid selection from the Energy list?

I try using !BloodEner.Acid but no luck...

Thoughts?
 
Please expand on what you mean by "using !BloodEner.Acid" - it's best to see the whole expression in cases like this.
 
Sorry. :)

I've got the Select From set to Energy Type. If I don't have anything in the Custom Expression, I get the following list in the dropdown:

Acid
Cold
Electricity
Fire
Sonic

That's the same no matter if I have the Restrict to None, Container or Hero.

I need the dropdown to be just:
Cold
Electricity
Fire
Sonic

I thought by adding !BloodEner.Acid to the Custom Expression, that that would exclude Acid from the selection dropdown but it doesn't.

If I use '(BloodEner.Cold|BloodEner.Elec|BloodEner.Fire|BloodEner.Soni)' as the Custom Expression and don't have Select From set to Energy Type, I get the Energy Types, but I also get all the Creatures, etc with those types in the dropdown.

If I use:
Component.Energy & (BloodEner.Cold|BloodEner.Elec|BloodEner.Fire|BloodEner.Soni)

I get nothing to Select from.

Does that help? :)

Thanks!
TC
 
Select From and Custom Expression are mutually exclusive - Select From works by overwriting the Custom Expression with an expression from a hard-coded list of expressions.

It's component.SelectHelp, not component.Energy, but otherwise you were on the right track for your custom expression. You can find that by going to the Develop menu...Floating Info Windows...Show Selection Tags, and then find the energy type selection helpers (note that there are two things there named "Acid" - one is the acid selection helper, the other is the [Acid] spell descriptor.
 
Thanks Matthias! :)

This is what I changed it to:
component.SelectHelp & (BloodEner.Cold|BloodEner.Elec|BloodEner.Fire|BloodEner.Sonic)

However, While the Acid isn't present, I still get:
Air
Blue Dragon (Electricity)
Brass Dragon (Fire)
Bronze Dragon (Electricity)
Cold
Electricity
Fire
Fire
Gold Dragon (Fire)
Red Dragon (Fire)
etc...

Seems like I still need to add something....

Thanks!
TC
 
The "Energy Type" option for Select from adds the following Custom Expression:

Code:
component.SelectHelp & Selection.Energy

There are also selection helpers for the type of dragon that a Draconic Sorcerer is linked to - and those also have BloodEner tags for the energy type that dragon race is linked to (BloodEner - "Bloodline Energy Type" - I ended up re-using those same tags when the Energy Type selectors were created)
 
Back
Top