MV Spellsteal and two of its many Variants

Once more, I have returned with yet another mechanic on my to-do list: Spellsteal.

(Edit: I May have forgotten to write a reminder of which plugins I am using. I have purchased the full collection of the Yanfly Engine.)

By definition, "Spellsteal" Involves the act of "Stealing a Spell"-or in simpler words, "Taking a Spell from someone for yourself". It has been done in many variants, in many different franchises-but I would dare say the most notorious ones hail from Dungeons&Dragons and World of Warcraft; The both of which, I am attempting to replicate to some extent. (And miraculously succeeded to replicate one of the two, awkwardly enough.)

Now, Yanfly does have a Tips&Tricks page on yanfly.moe that performs Spellstealing to an extent: Spell Siphon. To prevent frustrations with the Blue Mage I am working on, I am using Spell Siphoning already(No Shenaniganry à la FFVI. No Sketch/Control.) but that is simply not enough for a completely different character. My intention is to allow said character to perform Spellstealing in both of its Dungeons&Dragons and World of Warcraft Variants, so allow me to describe how each Variant works. (And how I replicated one of the two Spellsteal Variants, for anyone wondering how that was possible.)


Dungeons&Dragons:

An Arcane Trickster Rogue can utilise this feature to intercept a Spell being cast that would target the Rogue or include them in its Area of Effect. When successful, the Spell's Effects are completely negated for the Rogue and the Caster is prevented from being able to cast that same spell-by virtue of its knowledge being transferred from the Caster to the Rogue, who is then able to utilise the Spell as though it were their own. This effect, however, is not permanent, and the Rogue cannot utilise this feature more than once per Long Rest. (For those unfamiliar with Dungeons&Dragons, one Long Rest has a minimum duration of eight hours.)

Through the Spell Siphon Tips&Tricks, this can be achieved. However, I would like for the Spell being Stolen to be sealed for as long as the effect is in place, and for said Spell to be lost once the effect expires. Sealing Skills through the Database is easy-sealing them through a reference from a different Skill, this I am not certain as to "How" to do. Adding them through a state, perhaps, may be easier... This I know not.


World of Warcraft:

This Variant of Spellstealing is much more different, and is available only to the Arcane Specialization of the Mage Class.


image_2023-11-16_103301617.png


In simpler words, this variant of Spellsteal targets only certain Beneficial Effects, removes them from the Target and Grants the Caster that same Effect with either a duration equal to its current, or two minutes if the current duration happened to be longer than that.

This specific Variant was strangely easier done than said, for Yanfly's Spell Siphon is so versatile, you may more than modify it to include a variety of other effects instead of simply "Stealing" Skills. The Notetags I have used for this specific variant are as follows. (Yell at me if something about this code is odd or could have potentially been better-implemented.)

JavaScript:
<Before Eval>
if (user.isActor()) {
var stealable = [];
stealable.push(17, 18, 19, 21);
var states = target.states();
for (var i = 0; i < states.length; ++i) {
  var state = states[i];
  if (state && stealable.contains(state.id)) {
    user.addState(state.id);
    target.removeState(state.id);
    user.startAnimation(53);
  }
}
}
</Before Eval>

Knowing the default behavior for States being applied(Or Re-Applied) is to Reset the Duration, I find the latter part of Spellsteal slightly redundant, and as such, I have found to need no further action on that front.

My only conundrum remains the former: How to reference the Skill being stolen in the earlier variant so that a state may add it, and remove it when the effect of Spellsteal expires and seal the target's through a different state.

Thank you for taking a few minutes of your time to read one more of my Game Development conundrums. I appreciate it as well as any assistance given.

~Noel Ardiens
May I suggest reducing the thematic explanations of things and presenting the simple, mechanical question? Going through the large amount of text describing your class thematically and then quoted from D&D manuals to figure out what you're asking for can be offputting 😉

"Once a battle, when the actor is targeted by a spell, instead of having its effect the actor gains access to that spell and the enemy can't use it."

That's it. All you needed to say.

Implementing it is a bit tricky because you'd need to use a dynamic traits plugin. Both Shaz and Galv have them, I believe.

As far as what's considered a "spell" for these purposes, do you just have specific skills you're allowing, like Spell Siphon shows and like your lower block of code shows? Or is it any damaging skill with an MP cost? And you know the notetag and structure of Spell Siphon is wrong for a skill that reacts to an incoming attack?

Very basically, if you really like using that Spell Siphon T&T as your base, then you would replace the line with learnSkill() and instead apply a state to the target; then use a script call from the dynamic traits plugin to put the Add Skill and Add Skill Type onto that state according to the incoming skill.

Similarly, the user would receive a state modified by the dynamic traits plugin that seals the skill they were using.
May I suggest reducing the thematic explanations of things and presenting the simple, mechanical question? Going through the large amount of text describing your class thematically and then quoted from D&D manuals to figure out what you're asking for can be offputting 😉

Perfectly understandable. I just went with the assumption Not everyone knows what I am referencing, or trying to achieve. Thought it would be best if I explained to the best of my ability with added references for clarity of intent.

As far as what's considered a "spell" for these purposes, do you just have specific skills you're allowing, like Spell Siphon shows and like your lower block of code shows? Or is it any damaging skill with an MP cost? And you know the notetag and structure of Spell Siphon is wrong for a skill that reacts to an incoming attack?

Well, most "Magic" Spells are in specific spell types. White Magic, Black Magic-Blue Magic. Also, my control key was tapped as I tried to press Enter, and forced me to post early without completing my thoughts. Thank you, Keyboard.

Back on track: Thanks to Yanfly's Multi-Type Skills Plugin, I was under the assumption I could label one of those as "Stealable" through Spellsteal, and have it appear under the same Skill Type as the Spellsteal Skill itself. Now, as far as Spell Siphon being wrong for a Skill that reacts to incoming attacks, I am aware of this, hence why it was not my intention. Allow me to re-word it in simpler terms:

"What I am looking for in this First Iteration of Spellsteal, is the ability to quite literally Steal the Skill itself, as though the enemy never had access to it."

Which is why I brought up the need for a method of sealing the Skill, and allowing that same Skill to be learned and usable by the Actor for a time-until the effect itself would wear off. I have managed to find a way to apply this-but not reference the Skill itself in the state. Thankfully you offered a solution-and I am on my way to check them out right away. I am leaning toward Galv's version of Dynamic Traits, having had a chance to work with his own handicraft in the past. I will be back with another edit.
"What I am looking for in this First Iteration of Spellsteal, is the ability to quite literally Steal the Skill itself, as though the enemy never had access to it."
I might yoink this for myself at some point, the ideas pretty cool. Not actually writing anything out yet unless you need it, but ill outline my take on it. i dont know if itll neccessarily be easier to implement than with the dynamic states, but when i read that, i thought of this:

give your "rogue" class a passive that teaches all the syphonable skills, but hide them by default(more on that in a sec) and have it track if the rogue got hit by one of your syphonable skills (easy since you said its a skill type). if theyre hit by a syphonable skill, make the state save the user and skill's id as a js variables to the rogue. Then have each syphonable skill have a custom requirement tag from yanfly's requirement plugin and a show requirement to make it so that in order to use it as a player you need the corresponding ID value saved, and as an enemy, no actor has both that enemy and that skill id saved to themself. lastly just clear the variable data once said skill is used by an actor and/or at the end of battle via the state
I might yoink this for myself at some point, the ideas pretty cool. Not actually writing anything out yet unless you need it, but ill outline my take on it. i dont know if itll neccessarily be easier to implement than with the dynamic states, but when i read that, i thought of this:

give your "rogue" class a passive that teaches all the syphonable skills, but hide them by default(more on that in a sec) and have it track if the rogue got hit by one of your syphonable skills (easy since you said its a skill type). if theyre hit by a syphonable skill, make the state save the user and skill's id as a js variables to the rogue. Then have each syphonable skill have a custom requirement tag from yanfly's requirement plugin and a show requirement to make it so that in order to use it as a player you need the corresponding ID value saved, and as an enemy, no actor has both that enemy and that skill id saved to themself. lastly just clear the variable data once said skill is used by an actor and/or at the end of battle via the state

Strangely enough, I had thought of something at least similar in one regard to this-Namely saving the Skill ID to a Variable. I may need to clarify one more part of this first variant of Spellsteal, which is why I am not attempting to make it work as a passive effect of sorts(No matter how cool it may sound; I can smell the hassle from three oceans away...): The Act of Stealing the Spell is more of a choice on the Player's Hands than it is an automatic, reactive effect(Meaning, you can choose not to steal a Spell you would not like to have...), leading me to seek an active Skill to accomplish this. Somewhat. Similar, in fact, to what Spell Siphon offers.

Hoping not to resort to more plugins, I have just tested wheter I could run certain script calls as a Custom Apply Effect and Custom Remove Effect on the "Spellsteal" States, after forcing the Spellsteal Skill to store the Target Skill's ID into a Variable. I had hoped I could utilise a simple script call-seeing as they tend to work in Lunatic Mode-to prompt the game to "Teach" and "Forget" the Skill by recalling the variable's value itself. I will just post the codes while I check the Dynamic Traits Plugins once again and choose which between Shaz's and Galv's seems to better fit what I am looking for. Maybe Shaz's, as it seems to be slightly easier to use and manage and it may just allow me to run those script calls I already have in the states' noteboxes. (Thus sparing a little of my wasted effort. Once more, the Spell Siphon Tips&Tricks Code returns-for ease of use and briefness of code. Searching for a Skill belonging to a Specific Skill Type and interacting with it made sense to use it as base.)

Spellsteal Skill's Notebox:

JavaScript:
<Before Eval>
if (user.isActor()) {
var allowed = [];
allowed.push(5);
var skills = target.skills();
for (var i = 0; i < skills.length; ++i) {
  var skill = skills[i];
  if (skill && allowed.contains(skill.stypeId) && !user.isLearnedSkill(skill.id)) {
    $gameVariables.setValue(60, skill.id);
    break;
  }
}
}
</Before Eval>
<target action>
motion spell: user
action animation: target
add state 57: user
add state 58: target
</target action>

State 57("Spellsteal", to be given to the User of "Spellsteal"):

JavaScript:
<Category: Bypass Death Removal>

<Custom Apply Effect>
var skillid = $gameVariables.value(60)
user.learnSkill(skillid);
</Custom Apply Effect>

<Custom Remove Effect>
user.forgetSkill(skillid);
</Custom Remove Effect>

State 58("Spell Stolen", to be given to the Target of "Spellsteal"):

JavaScript:
<Category: Bypass Death Removal>

<Custom Apply Effect>
var skillid = $gameVariables.value(60)
user.forgetSkill(skillid);
</Custom Apply Effect>

<Custom Remove Effect>
user.learnSkill(skillid);
</Custom Remove Effect>

Notes: Much as the States are correctly applied, they do not add nor remove the targeted Skill. I have tested this out with a Dummy Skill, and the Enemy Battler was still more than capable and willing to use said Dummy Skill. Here I do hope Shaz's Dynamic Traits Plugin somehow allows me to salvage some of this work... Because if not, I will have wasted quite a few hours of work on this.
give your "rogue" class a passive that teaches all the syphonable skills, but hide them by default
This is a doable alternative to using dynamic traits on the actor's side. I don't see the need for any passive, simply give them all the skills at level 1.

I'm not really going to work through reading more voluminous stuff from the OP 😉 so if I missed something notable, let me know. But this:
Spellsteal Skill's Notebox:
does not all appear to do what you'd want.

Give your blue mage a passive state. In that state, you put:
Code:
<Custom Battle Effect>
// Refresh at the start of every battle
user.spellSteal = 0;
</Custom Battle Effect>

<Custom React Effect>
// If the ability hasn't been used and the incoming attack is Blue Magic
if (!target.spellSteal && this.isAttack() && this.item().stypeId == X)
{
    // Record the ID
    target.spellSteal = this.item().id;
    // Cancel incoming damage
    value = 0;
    // Flag the attacker
    user.spellStolen = true;
}
</Custom React Effect>
where X is the skill type ID of Blue Magic.

Then enemies which have Blue Magic will give the skill, in their Action Patterns, the condition of a state - this is a passive state you put on the enemy.

In that passive state, you put:
Code:
<Custom Passive Condition>
condition = !user.spellStolen;
</Custom Passive Condition>
where X is the ID of the Blue Magic skill the enemy has.

Then, inside each Blue Magic skill, you give it the notetag:
Code:
<Custom Show Eval>
visible = user.spellSteal == skill.id;
</Custom Show Eval>

This requires a bit more copy and paste setup, as each enemy and skill needs to be configured. But it eliminates the need for you to try to muddle through the dynamic traits and get more code made.
Give your blue mage a passive state.

Then enemies which have Blue Magic will give the skill, in their Action Patterns, the condition of a state - this is a passive state you put on the enemy.

This requires a bit more copy and paste setup, as each enemy and skill needs to be configured. But it eliminates the need for you to try to muddle through the dynamic traits and get more code made.

It was within my hopes it would not turn out a passive-but, to be honest... I am starting to like it better that way. And, better yet, not only has your combined solution had the effect I desired(Almost fully faithful to the "original" way of doing so: The Enemy is still able to use the "Stolen" Skill... And perhaps I could sort that out on my own. Big maybe. However, congratulations to both of you none-the-less!) and not only do I now have a means to customize its "Proc" somewhat(Mostly the Aesthetics of Spellstealing, anyways.), but I can consider it a total success after one last question, now that you have sparked a small glimmer of an idea in my confused brain.

If I were to Implement Passive "Skills" not really different to this, could I use any similar logic by tying together the Skill shown in the Command Menu with a Passive State that uses as its requirement "actor.isLearnedSkill == X"? (Or user, or whichever other string may identify a specific actor. Thankfully for me, most Actors will learn Skills unique to their class with the exceptions of White and Black Magic.)

Edit: I completely forgot to point out one slight flaw in the first Passive State's Notetags.

JavaScript:
<Custom React Effect>
// If the ability hasn't been used and the incoming attack is Blue Magic
if (!target.spellSteal && this.isAttack() && this.item().stypeId == X)
{
    // Record the ID
    target.spellSteal = this.item().id;
    // Cancel incoming damage
    value = 0;
    // Flag the attacker
    user.spellStolen = true;
}
</Custom React Effect>

"this.isAttack()" as a condition virtually demands that all Skills that may be Stolen via Spellsteal to have the "Normal Attack" state attached to them. Removing that did the trick.
The Enemy is still able to use the "Stolen" Skill
If you share a screenshot of said enemy and its passive state, we'll see what's up.

If I were to Implement Passive "Skills" not really different to this, could I use any similar logic by tying together the Skill shown in the Command Menu with a Passive State that uses as its requirement "actor.isLearnedSkill == X"?
Yes, but that's not the correct syntax. If you want skill A to only show up if the actor has learned skill B, then you put into skill A's notes:
Code:
<Custom Show Eval>
visible = user.isLearnedSkill(ID of B);
</Custom Show Eval>

"this.isAttack()" as a condition virtually demands that all Skills that may be Stolen via Spellsteal to have the "Normal Attack" state attached to them. Removing that did the trick.
My mistake - replace that with this.isForOpponent() The intent was that it wouldn't trigger if someone in the party uses a Blue Magic healing skill.

If there are no such things, and all Blue Magic skills are attacks, then that part of the conditional isn't necessary at all.
The Act of Stealing the Spell is more of a choice on the Player's Hands than it is an automatic, reactive effect(Meaning, you can choose not to steal a Spell you would not like to have...), leading me to seek an active Skill to accomplish this. Somewhat. Similar, in fact, to what Spell Siphon offers.
the idea still works with the active approach too. itd just need a little adjustment. I totally forgot that the requirements tag was provided by the skill core itself and not some extension, so its not as if you'd be adding a new plugin to do use it. also, youve already seen, but forgetSkil() is an actor function, not an enemy function.

Are enemies going to have multiple syphonable skills? Im assuming not since in your skill you break the loop when the first applicable syphonable skill is found and you set a variable instead of adding to an array. If thats the case you could make it even simpler and have the enemy syphoned state seal the skill type entirely, then remove the state from them when the actor uses the stolen skill.
If you do have multiple per enemy though, you probably will want to stick to the idea of having the skill require an actor not having the skill's id and user saved if an enemy is using it. if you wanted keep the idea that the skill stolen should have been used too, then each stealable skill should save its own id into the user to make its specific selection possible when using the syphon skill if you keep it as an active skill



Good thing i refreshed before posting.
The Enemy is still able to use the "Stolen" Skill... And perhaps I could sort that out on my own. Big maybe
the custom show eval tag doesnt prevent an enemy from using the skill, the requirement tag does. all it does is prevent players from using it by virtue of not being able to see or select it
If I were to Implement Passive "Skills" not really different to this, could I use any similar logic by tying together the Skill shown in the Command Menu with a Passive State that uses as its requirement "actor.isLearnedSkill == X"?
Im not entirely sure what you mean here. the Passives are states, not skills. unless you meant skills that you give the passive state tag to to represent having the passive state, in which case you can have the skill show up in the command list, but since you wouldnt be selecting it, it really shouldnt be visible there. the state icon would do in showing that its active
If you share a screenshot of said enemy and its passive state, we'll see what's up.

image_2023-11-16_182742229.png


image_2023-11-16_182850669.png


As asked. I have yet to understand how Yanfly was able to enlarge Noteboxes, it would yield slightly better screenshots. I will simply drop the uncut Notetag here.
JavaScript:
<Custom Passive Condition>
condition = !$gameParty.members().some(actor => actor.spellSteal == 191);
</Custom Passive Condition>

No more and no less than what was recommended by you.

Yes, but that's not the correct syntax. If you want skill A to only show up if the actor has learned skill B, then you put into skill A's notes:

I must have misworded my thoughts. I will simplify them to the most barebones of explanations I can think of.

"Actor A learns Skill B, but Skill B is a Passive Skill. Skill B has its effects tied to State C, which has a Custom Passive Condition of "isLearnedSkill(Skill B.id)" to produce its effects."

Would something along those lines work out?


the idea still works with the active approach too. itd just need a little adjustment. I totally forgot that the requirements tag was provided by the skill core itself and not some extension, so its not as if you'd be adding a new plugin to do use it. also, youve already seen, but forgetSkil() is an actor function, not an enemy function.

Crud. In other words, that simply does not work on enemies, period-meaning the only alternative is to seal it somehow.

Are enemies going to have multiple syphonable skills?

Maybe in a few occasions, certain enemies(Or rather, Bosses) are meant to be a way to catch up on missed Skills. Would make it a little harsher on my end...

the custom show eval tag doesnt prevent an enemy from using the skill, the requirement tag does. all it does is prevent players from using it by virtue of not being able to see or select it

That is most likely what is actually missing from the "Seal" Effect of Spellsteal. I will give it a few tries and see how it responds.

Im not entirely sure what you mean here. the Passives are states, not skills. unless you meant skills that you give the passive state tag to to represent having the passive state, in which case you can have the skill show up in the command list, but since you wouldnt be selecting it, it really shouldnt be visible there. the state icon would do in showing that its active

You have nailed what the player is supposed to see down to the last dot. It would be visible to give the player an idea of how and what this Passive Skill entails. The rest is up above.
As asked.
You missed my instructions:
Then enemies which have Blue Magic will give the skill, in their Action Patterns, the condition of a state - this is a passive state you put on the enemy.
All of the skills listed in that enemy's Action Pattern still have condition: Always. They can still use the spell because you have nothing telling them not to.

"Actor A learns Skill B, but Skill B is a Passive Skill. Skill B has its effects tied to State C, which has a Custom Passive Condition of "isLearnedSkill(Skill B.id)" to produce its effects."

Would something along those lines work out?
I don't see the point of that - just put the Passive State notetag on Skill B. It doesn't need any condition.

The Act of Stealing the Spell is more of a choice on the Player's Hands than it is an automatic, reactive effect
I didn't see this in the middle of all of your stuff. Then you would have to do something more complex where you make the React Effect call a common event that has a choice window as to whether you're going to do the stealing. Everything else should work as is.
"Actor A learns Skill B, but Skill B is a Passive Skill. Skill B has its effects tied to State C, which has a Custom Passive Condition of "isLearnedSkill(Skill B.id)" to produce its effects."
simpler than that actually. Actor A learns skill B. Skill B has <Passive State:ID of State C>in its notebox and thats it. if you want to add additional conditionals like hp rate, enemies knowing some skill, having some other state, or whatever you can think of, youll add them through the custom passive condition tags youve been using.
You have nailed what the player is supposed to see down to the last dot. It would be visible to give the player an idea of how and what this Passive Skill entails. The rest is up above.
personally, Id add <Hide in Battle> into the skill's notebox so that you dont see it in combat and let the state icon handle displaying it. youll still be able to read the description out of combat, but imo showing it in combat will only add bloat to your command menus

Also your state isnt actually doing anything as it is. unless you were going to use its presence as a check to see if skill 191 specifically was stolen by any actor, it serves no purpose right now. you can make that state seal skill 191 (not recommended as if you continue, youll have to make a seal state for each skill), or you take your current condition and use it as the requirement for the skills themselves to handle the sealing that way.
Code:
<Custom Requirement>
value = !user.opponentsUnit().aliveMembers().some(member => member.spellSteal == item.id);
<Custom Requirement>
This way, regardless of if you use a state or a skill to enable the actor to syphon skills, the enemy wont be able to use the skill as long as an actor has "stolen" it. youll just have to make it so that the state's removal/skill's execution deletes the user's spellSteal variable to give the skill back to the enemy.
All of the skills listed in that enemy's Action Pattern still have condition: Always. They can still use the spell because you have nothing telling them not to.

... I should have known it to be something mind-breakingly simple. Cursed be my hindsight and lack of attention. I gave the Passive Condition yet another look to understand what I was missing-and now I do. How Embarrassing.

I don't see the point of that - just put the Passive State notetag on Skill B. It doesn't need any condition.

simpler than that actually. Actor A learns skill B. Skill B has <Passive State:ID of State C>in its notebox and thats it. if you want to add additional conditionals like hp rate, enemies knowing some skill, having some other state, or whatever you can think of, youll add them through the custom passive condition tags youve been using.


I was so sure that Yanfly's Passive States Plugin would not have any effect if placed into Skills' Notetags that I simply did not try it once. Damn it.

I didn't see this in the middle of all of your stuff. Then you would have to do something more complex where you make the React Effect call a common event that has a choice window as to whether you're going to do the stealing. Everything else should work as is.

I will leave it as for my own sake. It may end up better as a Passive Effect to help the Player with MP and TP Management.


That pretty much answers all that I needed out of Spellsteal, and it provided a nice bonus. Thank you so much, I am indebted to both of you once again-And I will make sure to use this knowledge well. Thank you again! 😀
I was so sure that Yanfly's Passive States Plugin would not have any effect if placed into Skills' Notetags that I simply did not try it once.
For your future reference, there doesn't need to be any guesswork involved - it's pretty standard that any plugin author tells you which database objects the notetags will work in. So for the example from Auto Passive States:
1700163802262.png

Original thread: https://forums.rpgmakerweb.com/threads/spellsteal-and-two-of-its-many-variants.162982/