• 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

How to validate prereq with multiple Edges/requirements

Gumbytie

Well-known member
This would be for Gaslight and the spell system. Problem, each Arcane background and Race may be able to cast the same spell but have different prereqs to cast, in this case one being Forbidden Knowledge Edge, the other the Race.

Races: Human, Vampire, Werewolf (for now)
Arcane Background: Mage, Mesmerist, Mystic (for now)

Spell: Armor, below is the whole code:

Code:
<thing 
	id="powGArmor" 
	name="Armor" 
	description="{i}Armor{/i} creates a field of magical protection around a character or an actual shell of some sort, effectively giving the target Armor. Success grants the recipient 2 points of Armor. A raise grants 4 points of Armor.\n\nWhether the {i}armor{/i} is visible or not depends largely on the trapping." 
	compset="Power" 
	summary="Confers 2 or 4 points of Armor" 
	uniqueness="unique">
    <fieldval field="powPoints" value="2"/>
    <fieldval field="powRange" value="Touch"/>
    <fieldval field="powLength" value="3"/>
    <fieldval field="powMaint" value="1/round"/>
    <fieldval field="powTraps" value="A mystical glow, hardened skin, ethereal armor, a mass of insects or worms, densening"/>
    <fieldval field="powPrtMain" value="1/r"/>
    <usesource source="Gaslight"/>
    <tag group="MinRank" tag="0"/>
    <pickreq ispreclude="yes" thing="racGWildin"/>
    <prereq message="Arcance Background (Mage) and Forbidden Knowledge Edge required.">
      <validate><![CDATA[
        if (hero.tagis[Edge.edgArcGMag] = 1) then 
          validif (hero.tagis[Edge.edgGForKno] = 1)
          endif
        if (@ispick <> 0) then
          altpick.linkvalid = 0
          endif]]></validate>
      </prereq>
    </thing>

So what I expect to happen is to check if:
1) The character has the Arcane Background (Mage)
2) Check if the character has Forbidden Knowledge Edge

If both ARE true then player can select the Armor spell.

It could also be something like:
1) The character Race is Vampire
2) Check if the character has Forbidden Knowledge Edge

So somewhere in here I assume I need to make this work. And I have tried various permutations of this but never quite nailing it.

Code:
    <prereq message="Arcance Background (Mage) and Forbidden Knowledge Edge required.">
      <validate><![CDATA[
        if (hero.tagis[Edge.edgArcGMag] = 1) then 
          validif (hero.tagis[Edge.edgGForKno] = 1)
          endif
        if (@ispick <> 0) then
          altpick.linkvalid = 0
          endif]]></validate>
      </prereq>
    </thing>

Another code attempt:
Code:
    <prereq message="Arcance Background (Mage) and Forbidden Knowledge Edge required.">
      <validate><![CDATA[
        if (hero.tagis[Edge.edgArcGMag] >= 1) then
          @valid = 1
          done
          endif
        if (hero.tagis[Edge.edgGForKno] >= 1) then
          @valid = 1
          done
          endif
        altthing.linkvalid = 1]]></validate>
      </prereq>
    </thing>

And:

Code:
	<prereq message="">
      	<validate><![CDATA[
        	if (hero.tagis[Edge.edgArcGMag] <> 0) then
          @valid = 1
          endif
        	if (hero.tagis[Edge.edgGForKno] <> 0) then
          @valid = 1
          endif]]>
	</validate>
      </prereq>

I have never had to essentially write an if/then for a prereq or validation so struggling. Basically the last portion of finishing a complete datafile for Gaslight. I hope I explained this well enough :)

Cheers
 
Some further information

This might help explain better:

powers_list.jpg


Powers with an (X) are normally available for that Arcane background with no prereqs. Powers with an (o) are only available with the Forbidden Powers Edge. Powers with a dash (-) are unavailable.

So you can see my dilemma. Quite a few different possible combinations for just the first spell.
 
Probably the easier way would be like the on I've used in the Common Codes thread with an Expr-Req:

Code:
hero.tagis[Edge.edgTDNCO] + hero.tagis[Edge.edgTDOffic] <> 0

So the idea there was to check for an either/or situation but you could still do the same thing to require both. So for the Mage and Forbidden Knowledge part maybe something like:
Code:
hero.tagis[Edge.edgArcGMag] + hero.tagis[Edge.edgGForKno] > 1

At least I think that should work, although I don't know if you run into an issue with the idea that having one of those Edges simply returns a non-zero result (meaning they could be more than 1 for either of them, although I'm not sure what that would be.) Heck of a lot shorter to code if it works, though!

Although that non-zero part might actually be the reason your first code wasn't working, too. So maybe you'd need something like:
Code:
if (hero.tagis[Edge.edgArcGMag] <> 0) then
   validif (hero.tagis[Edge.edgGForKno] <> 0)
endif
 
Last edited:
An answer (of sorts) based on Zarlor's suggestions

Okay, so I used a bit of Zarlor's code suggestion for a bunch of 'OR' statements then made two versions of every affected spell. Essentially one version is the all arcane backgrounds and races needing Forbidden Knowledge required and the other version is everyone NOT.

So here is a sample code.

All requiring Forbidden Knowledge Edge (version 1 of power):
Code:
	<prereq message="Arcance Background (Mesmerist/Mystic), Werewolf or Vampire.">
      	<validate><![CDATA[
	if (hero.tagis[Edge.edgArcGMes] + hero.tagis[Edge.edgArcGMys] + hero.tagis[Race.racGVampir] + hero.tagis[Race.racGWere] <> 0) then
	@valid = 1
	endif
	]]>
	</validate>
	</prereq>
	<prereq message="Forbidden Knowledge Edge required.">
      	<validate><![CDATA[
	if (hero.tagis[Edge.edgGForKno] <> 0) then
	@valid = 1
	endif
	]]>
	</validate>
	</prereq>

Forbidden Knowledge Edge not required (version 2 of power):
Code:
    <pickreq ispreclude="yes" thing="edgArcGMes"/>
    <pickreq ispreclude="yes" thing="edgArcGMys"/>
    <pickreq ispreclude="yes" thing="racGVampir"/>
    <pickreq ispreclude="yes" thing="racGWere"/>

The second version is always easier, simply Preclude everything from first version of Power. Mind you, a lot of typing and cannot discount typos :)

Anyway, that is the best solution I could come up with helpful advice from Zarlor.

Cheers.
 
Seems to me you could have nested those if statements so you only needed one version of the power, right? The tools available are that on any given Arcane Background you can preclude a power for that AB by selecting them with the "Invalid Powers" button on that tab in the Editor. So that takes care of those ABs that simply shouldn't have that power available to them at all. In the example of Armor above you'd just check the Armor power box for Wilding to make it unavailable to them.

That leaves those that should simply be allowed to take it (so in Armor normally no coding would be required for the Mystic, Mad Scientist, Beast Man and Werewolf) and then there are those that are allowed, but also need the Forbidden Knowledge Edge. So for those I think trapping like this might work a little easier, but I'm going to use your table for Armor above (since I don't think that is the same you coded for):

Code:
if (hero.tagis[Edge.edgArcGMes] + hero.tagis[Edge.edgArcGMag] + hero.tagis[Race.racGVampir] <> 0) then
   validif (hero.tagis[Edge.edgGForKno] <> 0)
endif

I'd think that would be all you would need, unless I'm missing something.

EDIT: Ah, I just realized some of those are not ABs, but races. Do the races also have their own AB in order to activate the Powers tab on their portfolio? If so you should be able to use the AB for that purpose (unless it's one AB for all races...)
 
Last edited:
Better code from Zarlor

Okay, so I did use your version of the code to combine what I had as two separate prereqs. Not sure why I didn't think to try that, hmm.

So that part does work. But I still need two versions of the powers. The code does identify requirements to learn, but if it isn't one of the ABs or Races that meets the 'needed' requirements, then it stays flagged with needed requirement and is greyed out, unable to be selected.

There doesn't seem to be a method that says if you are NOT one of the following that need to meet the requirements, then feel free to select this power. Hence two versions for now, at least until someone smarter than I posts an answer or I get smarter as I bang away at this :)
 
Wow, I figured it out not longer after the last post...sigh

Maybe it was the green tea I brewed but after posting earlier and thinking about Zarlor's version of the code, I realized it was and 'if' statement and I could add an 'else', yeesh.

Code:
	<prereq message="Requires Forbidden Knowledge Edge.">
      	<validate><![CDATA[
	if (hero.tagis[Edge.edgArcGMag] + hero.tagis[Edge.edgArcGMes] + hero.tagis[Race.racGVampir] <> 0) then
		validif (hero.tagis[Edge.edgGForKno] <> 0)
	else
	@valid = 1
	endif
	]]>
	</validate>
	</prereq>

So start with his code version, checks to see if it an AB or Race that needs Forbidden Knowledge Edge, if so, flag it. if not (via the Else) simply validate and let them select that power.

Okay, so maybe less coffee at night and more tea.

Cheers, and thanks to Zarlor for guiding me down the correct path. Now I have to go delete a bunch of duplicate powers in my dataset and fix some code.
 
Lol. I think we've all been there... although I don't think I've done as much work as creating a bunch of duplicate powers that I needed to go back and delete. :D

I'm just glad I could be of some help. :)
 
Back
Top