Using Yanfly's states and buffs, elements, passives, auras, and action sequences, i seem to have found myself in a little bit of a funny situation in adding a mechanic. it works as follows: the user uses a self targeting skill that gives it a state with an aura effect. The aura effect adds another state to all alive battlers. Nothing fancy there and has no problem. The state that the aura adds makes it so that every time someone with it is struck with a single target lightning element skill, all their allies (not including themself) take a fraction of the damage the skill did (modified by their lightning resistance). this one seems to be the problem.
My first attempt of the state was this:
Thought it'd work, but after testing it i noticed that anything hit by a lightning skill with that state on seems to... die? they take the damage of the initial skill, allies take the intended splash damage, the initial target stays on screen, but they cant attack or be targeted by any skill regardless of the damage dealt. when i hit all enemies with a lightning skill, the fight ends as a victory despite no enemy actually dying. thought it was weird, but as far as i could tell, it should have worked. So i decided to just redo the effect with a different approach.
Second attempt was making it a set of states instead. after some trial and error regarding what the origin of a state applied by another state was, the state above eventually became 3 separate ones. the one above (State 413) eventually became this:
State 414 looks like this and has a resist for state 415:
State 415 is this:
It works, except for one very slight, but very janky kink. The mechanic for one of my classes is that magic cast by it may be modified through states it applies to itself for an increased mp cost. one of these states makes single target magics become AOE through action sequences. all applicable spells has the following in their notetags:
Reason for doing it this was that this makes all enemies/allies take the damage/heal at the same time instead of slowly and sequentially. However, since the single target lightning spell is single target in the database even if its aoe through action sequences, it makes isForOne() return true.
At this point, im not even bothered by it bypassing the single target check. What i want to know is why it does what it does. State 415 applies the damage of the effect and is resisted if affected by state 414 - the one that applies it. State 414 applies 415 to all allies sequentially, and then removes itself after the application to all its allies, right?. what happens when i use the class to make ST spells AOE is that each battler gets hits by the initial cast, but then all enemies take the splash damage in a way thats less than predictable. in a 3 enemy setup, they all take a direct hit, 2 of them get damaged through the effect once, and the last one takes the damage twice. wouldnt the expected result would have been either that they all take a spell hit, gain immunity from the splash damage of the one that hit them personally, 414 spreads, then it falls off, and they take the effect damage from the other 2 (meaning apply 415 apply happens after 414 removal), OR the first gets hit and gains immunity from the effect, the second takes the effect damage of the first gets hit by the spell, gains immunity, and the third takes the effect twice and the spell hit once and gains immunity with no immunity falling off until everything if over (415 apply happens before 415 removeal), no?. Additionally, since the 2 instances of bonus damage the one enemy that takes 2 takes arent equal to eachother, theyre distinct calculations, so i know its not showDamagePopup() producing some kind of unintended effect.
In an 8 target setup, they all take a skill hit, and they *all* take the bonus damage only once or twice instead of something that would have made more sense like 0-1-2-3-4-5-6-7 or 7-7-7-7-7-7-7-7
Does anyone have an idea as to why this is? to clarify, im not looking for a solution to the spell triggering the effect because i know can add !user.isStateAffected(100) to the conditional statement on state 413 and shut it down completely, im just curious as to what order these effects should be happening in and why. It doesnt seem to be right, but theres probably something I dont get here
i've also tried:
thinking that the order of operations here would change if the effect was moved to on state removal instead of application but no difference was made.
My first attempt of the state was this:
JavaScript:
<Custom Respond Effect>
if (this.getItemElements().contains(4)){
var shockT = target.friendsUnit().aliveMembers();
shockT.splice(shockT.indexOf(target), 1);
shockT.forEach(member => member.gainHp(-Math.ceil(value/4)));
shockT.forEach(member => member.startDamagePopup());
}
</Custom Respond Effect>
Thought it'd work, but after testing it i noticed that anything hit by a lightning skill with that state on seems to... die? they take the damage of the initial skill, allies take the intended splash damage, the initial target stays on screen, but they cant attack or be targeted by any skill regardless of the damage dealt. when i hit all enemies with a lightning skill, the fight ends as a victory despite no enemy actually dying. thought it was weird, but as far as i could tell, it should have worked. So i decided to just redo the effect with a different approach.
Second attempt was making it a set of states instead. after some trial and error regarding what the origin of a state applied by another state was, the state above eventually became 3 separate ones. the one above (State 413) eventually became this:
JavaScript:
<Custom Respond Effect>
if (this.getItemElements().contains(4) && this.isForOne()){
target.friendsUnit().aliveMembers().forEach(member => member._shockTransfer = -Math.ceil(value/4));
target.addState(414);
}
</Custom Respond Effect>
State 414 looks like this and has a resist for state 415:
JavaScript:
<Custom Apply Effect>
target.friendsUnit().aliveMembers().forEach(member => member.addState(415));
target.removeState(stateId);
</Custom Apply Effect>
<Custom Remove Effect>
user._shockTransfer = undefined;
</Custom Remove Effect>
State 415 is this:
Code:
<Custom Apply Effect>
user.gainHp(user._shockTransfer*user.elementRate(4));
user.startDamagePopup();
user.removeState(stateId);
</Custom Apply Effect>
<Custom Remove Effect>
user._shockTransfer = undefined;
</Custom Remove Effect>
It works, except for one very slight, but very janky kink. The mechanic for one of my classes is that magic cast by it may be modified through states it applies to itself for an increased mp cost. one of these states makes single target magics become AOE through action sequences. all applicable spells has the following in their notetags:
Code:
<target action>
if user.isStateAffected(100);
action animation: all opponents
action effect: all opponents
else
action animation
action effect
end
</target Action>
At this point, im not even bothered by it bypassing the single target check. What i want to know is why it does what it does. State 415 applies the damage of the effect and is resisted if affected by state 414 - the one that applies it. State 414 applies 415 to all allies sequentially, and then removes itself after the application to all its allies, right?. what happens when i use the class to make ST spells AOE is that each battler gets hits by the initial cast, but then all enemies take the splash damage in a way thats less than predictable. in a 3 enemy setup, they all take a direct hit, 2 of them get damaged through the effect once, and the last one takes the damage twice. wouldnt the expected result would have been either that they all take a spell hit, gain immunity from the splash damage of the one that hit them personally, 414 spreads, then it falls off, and they take the effect damage from the other 2 (meaning apply 415 apply happens after 414 removal), OR the first gets hit and gains immunity from the effect, the second takes the effect damage of the first gets hit by the spell, gains immunity, and the third takes the effect twice and the spell hit once and gains immunity with no immunity falling off until everything if over (415 apply happens before 415 removeal), no?. Additionally, since the 2 instances of bonus damage the one enemy that takes 2 takes arent equal to eachother, theyre distinct calculations, so i know its not showDamagePopup() producing some kind of unintended effect.
In an 8 target setup, they all take a skill hit, and they *all* take the bonus damage only once or twice instead of something that would have made more sense like 0-1-2-3-4-5-6-7 or 7-7-7-7-7-7-7-7
Does anyone have an idea as to why this is? to clarify, im not looking for a solution to the spell triggering the effect because i know can add !user.isStateAffected(100) to the conditional statement on state 413 and shut it down completely, im just curious as to what order these effects should be happening in and why. It doesnt seem to be right, but theres probably something I dont get here
i've also tried:
Code:
<Custom Apply Effect>
user.removeState(stateId);
</Custom Apply Effect>
<Custom Remove Effect>
user.gainHp(user._shockTransfer*user.elementRate(4));
user.startDamagePopup();
user._shockTransfer = undefined;
</Custom Remove Effect>