Jump to content

apply spell upon unequipping item?


Recommended Posts

Is there a best way to do this? Let's say, for instance, that I want certain items to remove an innate ability. Say, if a paladin equips an item, it will remove your Lay On Hands ability. But if you unequip the item, you get it back.

Off the top of my head, the item could:

  • op172 remove the innate ability, timing mode 1
  • op206 vs. spellB, timing mode 2
  • repeating .eff applying effA

effA uses op146 with delayed/permanent timing to cast spellB after ~3 seconds

SpellB uses op171 to give you Lay on Hands

So the item keeps trying to give you the ability back, but you are immune while you wear the item. But a few seconds after you remove the item, the spell successfully fires and you get your innate ability back.

I think that should work, but am I overthinking it? Is there a better way?

 

EDIT - boy, I'm rusty with this stuff...

Edited by subtledoctor
Link to comment

I think that approach will cause trouble:

(i) you'll have to hardcode character abilities into the item, which is compatibility-unfriendly

(ii) taking the object off and back on again will recharge the ability.

My immediate thought is to get the item to set a spellstate. Then edit the spell to block it, and display a 'this power can't be used while wearing blah' message, when the spellstate is set.

Link to comment
7 hours ago, DavidW said:

(i) you'll have to hardcode character abilities into the item, which is compatibility-unfriendly

(ii) taking the object off and back on again will recharge the ability.

These are okay. To be more specific, I am trying to replicate the inability to cast arcane spells in armor, with my 5E casting conversion mod.

The way the mod works is: there is an innate ability corresponding to every arcane and divine spell. You select which spells to 'memorize' and the next day the innate abilities corresponding to those memorized spells inhabit your spellcasting button, in a number determined by your 'spell slots' - which is tracked via a stat value. When you cast one of those innate abilities, it:

  1. casts the appropriate spell
  2. reduces the stat value to mimic expending a spell slot
  3. casts a subspell with 172 effects that remove every innate ability in the system
  4. casts another subspell that grants you the innate abilities corresponding to your memorized spells, in a number matching the new 'spell slot' stat value

While a bit processor-heavy, the system works well, essentially allowing you to prepare spells like a mage but cast them like a sorcerer.

However, opcode 145 can no longer be used in armor, because I would have to block innate abilities with it - which would be bad. Instead I'll hook into the casting system:

  • when you equip armor, it casts the 172 spell to remove all innate abilities corresponding to arcane spells
  • it will carry a 206 equipping effect blocking any arcane-related innate abilities from being given to you in step 4 above (in the event that, say, a cleric/mage in armor casts a divine spell)
  • when you remove the armor, we want the innate abilities relating to your memorized arcane spells to reappear under the spellcasting button.

That last part is the tricky bit, because the engine does not generally register removing an item. We don't have to worry about which innates reappear; that is already handled by the spellcasting system. (Specifically, removing the armor should cause all innates to appear... but the ones that you don't have memorized are blocked by 206 effects.) And we don't have to worry about recharging the abilities, because that is already handled by the system that tracks your spell slots. A single uniform spell will be enough to be triggered by all armors, and will correctly handle all casters with all possible combinations of memorized spells and all possible current spell slot values. All of that works wonderfully. The issue is simply, how best to trigger the casting of that spell by removing a piece of equipment.

Edited by subtledoctor
Link to comment

Here's what I currently have:

Armors get the following added as equipping effects, in this order:

  1. Opcode 146, timing 1, casting...
    • ...Spell_A, which removes specified innate abilities
  2. Opcode 177, timing 2, triggering...
    • ...Eff_B, which uses opcode 232, timing 2, to cast every round (hp<102%)...
    • ...Spell_C, which uses opcode 326, timing 4, duration 3, to cast...
    • ...Spell_D, which gives you back the specified innate abilities
  3. Opcode 177, timing 2, triggering...
    • ...Eff_E, which uses opcode 206 to provide immunity to Spell_D

This is not working. Step 2 fails - Spell_D does not get cast after you remove the armor. I thought  this would cast Spell_C every 6 seconds, and thus cast Spell_D every 6 seconds on a 3-second delay. The armor itself immunizes you against Spell_D, but it should always be cast once after you remove the armor.  Right? That's the idea behind the delayed timing mode, but it doesn't seem to be happening... :(

Link to comment

Ah - I think I figured it out. With the above setup, with the 3-second delay in Spell_C, it is possible to unequip the armor during the gap between Spell_D being cast and the next instance of Spell_C being triggered. Instead, Spell_C needs to use a 6- or 7- second delay, so that there is no way to unequip the armor without a follow-up instance of Spell_D happening. Then, add another instant 146 effect at the beginning, in case someone equips and then unequips the armor before the 232 repetition starts up. So, this seems to be working:

  1. Opcode 146, timing 1, casting...
    • ...Spell_A, which removes specified innate abilities
  2. Opcode 146, timing 1, casting...
    • ...Spell_C (see below)
  3. Opcode 177, timing 2, triggering...
    • ...Eff_B, which uses opcode 232, timing 2, to cast every round (hp<102%)...
    • ...Spell_C, which uses opcode 318 for filtering out non-casters, and then opcode 146, timing 4, duration 7, to cast...
    • ...Spell_D, which gives you back the specified innate abilities
  4. Opcode 177, timing 2, triggering...
    • ...Eff_E, which uses opcode 206 to provide immunity to Spell_D

(#4 goes through an .eff instead of being s simple while-equipped 206 effect, because somebody might need to be immune to it depending on your mod choices (like, with Tome & Blood's "Bards Can Cast in Leather" component, they need Spell_D to work for them when wearing armor; by giving Eff_E a parent resource name, a class/kit/character can be given 206 protection against this 206 protection :cool: )

This looks a bit creaky, but I think it is working reliably, based on my quick tests. One down-side is that your basic Fighter wearing this armor will have a 232 effect casting a Spell_C on him/her every 6 seconds. It won't do anything because of the 318 filter, but it would be preferable to prevent it altogether. I suppose the #3 177 effect can be duplicated, and filtered to apply solely to arcane caster classes (M/B/S/FM/MT/CM/FMC). It's probably worth doing that.

Edited by subtledoctor
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...