• 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

Weapon Crystals - How to tie them to weapons?

Adam.Ormond

Well-known member
I'm working on implementing a few Weapon Crystals from the Magic Item Compendium, and I'm not quite sure how to create them such that they're tied to a specific weapon.

Thanks in advance for any advice!

Here's my definition so far:
Code:
  <thing id="ioLfeDrnk1" name="Crystal of Life Drinking, Least" description="This transparent black crystal has a faint, sickly glow.\n\nA crystal of life drinking bestows a small amount of life energy upon you each time you damage a living creature with the weapon to which the crystal is attached. Dealing nonlethal damage with the weapon doesn&#146;t activate the crystal&#146;s effect.\n\nEach time you deal damage to a living creature with the weapon to which this crystal is attached, you heal 1 point of damage. When the crystal has healed a total of 10 points of damage, it becomes inert until the following day." compset="Wondrous" summary="Heal 1hp each time you deal damage to a living, up to 10 hps/day">
    <fieldval field="gCost" value="400"/>
    <fieldval field="trkMax" value="10"/>
    <tag group="gType" tag="Wonder"/>
    <tag group="Helper" tag="EquipAvail"/>
    <tag group="Helper" tag="EquipMag"/>
    <tag group="Custom" tag="WpnCrystal" name="Weapon Crystal"/>
    <tag group="Helper" tag="NoPathSoc"/>
    <tag group="iSchool" tag="Necromancy"/>
    <tag group="Helper" tag="ShowSpec"/>
    <eval phase="Final">if (this.field[gIsEquip].value = 1) then
  perform this.assign[User.Tracker]
endif</eval>
    </thing>
 
As before - what do these do? What rules are you trying to implement?

And just as a note, I have to read so much code during the day that my eyes just glaze over if I see large blocks of code included in a question. I'd much rather you describe what you're trying to accomplish, and then describe what portions of that you have been able to accomplish and what portions you are not sure about.
 
A Weapon Crystal attaches to a weapon. Ideally, weapons would be gearholders that could hold one Weapon Crystal, but I think that'd be a lot of work involving recreating every weapon as a gearholder.

I'd like to tie a Weapon Crystal magic item to a specific Weapon. If multiple Weapon Crystals are tied to a single weapon, an error should occur.

I have the Weapon Crystal defined as a Wondrous Item right now. I have the first "Select from..." option setup for a user to define an Energy Type. The "Second Selection from..." I've tried "All Weapons" and "All Picks on Hero", but that doesn't seem to work at all (just shows me two options: Ranged Touch and Unarmed). I've also tried "Melee Weapons" and "All Picks on Hero", and that shows me the melee weapons I've picked, but it hides the first "Select from...".

edit: I just swapped the order of the First and Second Selections, and that is now working. Now I just need an Eval Rule -- I'm not quite sure how to proceed. I can find all my Weapon Crystal picks and Weapon picks, but I'm having trouble figuring out how to determine what the user selected on the Weapon Crystal to know if multiple Weapon Crystals share the same weapon.

And why doesn't "All Weapons" list work? A Weapon Crystal shouldn't be limited to melee weapons -- a hack would be to create two types of weapon crystals for each, one that ties to Ranged and one for Melee.
 
The 3.5 MIC had these crystals that went into slots for weapons and armor. I always thought they would be a good item but touch to code. i would most likely go with Evilash's idea. make them each a specific wonderour item and pit an activation button on it. then have the ability effect the weapon or armor. that way you would need to mess with each weapon and armor individually.
 
I have the tracker currently set on the Wondrous Item, but I'd like to tie it to the weapon. Is it possible to set the parent's trkmax if I don't know the parent's thingid?
Code:
perform this.parent.assign[User.Tracker]
var parentPick as string
parentPick = this.parent.idstring
#trkmax[parentPick] = 30

If anyone's interested in how I have this thing defined, below is the definition:
Item Power: Life Drinking, Least
Code:
  <thing id="ipLfeDrnk1" name="Life Drinking (Least)" description="Each time you deal lethal damage to a living creature with this weapon, you heal 1 point of damage. When the weapon has healed a total of 10 points of damage, this power becomes inactive until the following day." compset="ItemPower" summary="Heal 1hp each time you deal lethal damage to a living creature,  up to 10 hps">
    <tag group="PowerType" tag="Weapon"/>
    <tag group="Helper" tag="NoPathSoc"/>
    <tag group="Custom" tag="WpnCrystal"/>
    <tag group="Custom" tag="wcLfeDrnk2"/>
    <tag group="Helper" tag="NotMagicPw"/>
    <eval phase="Final">perform this.parent.assign[Custom.WpnCrystal]
perform this.parent.assign[Custom.wcLfeDrnk1]
</eval>
    <evalrule phase="Validation" index="2" message="Only one weapon crystal may be attached to a weapon">validif (this.parent.tagcount[Custom.WpnCrystal] = 1)</evalrule>
    <prereq message="Wondrous Item: Crystal of Life Drinking, Least must be equipped">
      <validate>validif (hero.childfound[ioLfeDrnk1].field[gIsEquip].value = 1)</validate>
      </prereq>
    </thing>
Wondrous Item: Crystal of Life Drinking, Least
Code:
<thing id="ioLfeDrnk1" name="Crystal of Life Drinking, Least" description="This transparent black crystal has a faint, sickly glow.\n\nA crystal of life drinking bestows a small amount of life energy upon you each time you damage a living creature with the weapon to which the crystal is attached. Dealing nonlethal damage with the weapon doesn&#146;t activate the crystal&#146;s effect.\n\nEach time you deal damage to a living creature with the weapon to which this crystal is attached, you heal 1 point of damage. When the crystal has healed a total of 10 points of damage, it becomes inert until the following day." compset="Wondrous" summary="Heal 1hp each time you deal damage to a living, up to 10 hps/day">
    <fieldval field="gCost" value="400"/>
    <fieldval field="trkMax" value="10"/>
    <fieldval field="iCL" value="5"/>
    <tag group="Helper" tag="EquipAvail"/>
    <tag group="Helper" tag="EquipMag"/>
    <tag group="Helper" tag="NoPathSoc"/>
    <tag group="iSchool" tag="Necromancy"/>
    <tag group="gType" tag="Wonder"/>
    <tag group="Custom" tag="wcLfeDrnk1"/>
    <eval phase="Final">if (this.field[gIsEquip].value = 1) then
  perform this.assign[User.Tracker]
endif</eval>
    <evalrule phase="Validation" message="Crystal must be attached to a weapon"><![CDATA[var crystals as number
crystals = 0
var attached as number
attached = 0

if (this.field[gIsEquip].value = 1) then
  foreach pick in hero where "Custom.wcLfeDrnk1"
    if (eachpick.tagis[gType.Wonder] <> 0) then
      crystals += 1
    elseif (eachpick.tagis[IsWeapon.?] <> 0) then
      attached += 1
    endif
  nexteach
endif

@valid = 0
if (this.field[gIsEquip].value = 0) then
  @valid = 1
elseif (crystals = attached) then
  @valid = 1
endif]]></evalrule>
    </thing>
 
Last edited:
BTW,

Code:
this.
is assumed at the beginning of every line in a script in Hero Lab, and you don't need to keep typing it yourself.
 
You did note that trkMax is already in use for many weapons - the count of a stack of daggers, for example.
 
You did note that trkMax is already in use for many weapons - the count of a stack of daggers, for example.
Ah yes, good point; I had already forgotten :D I'm going to break that if I set the trkmax on the parent, won't I? I suppose I need to keep the tracker on the Wondrous Item.
 
Back
Top