[VX ACE] Effect based on attack element

So here's what I'd like to do.


There's an enemy in my game that is flammable.  When it receives a [Fire] elemental attack, I'd like it to gain the state [On Fire], which changes its attack element to Fire, raises its stats, etc.


How would I go about doing this?  Am I going to need to use (yet another) script? ^_^;;
There is only one way to do this without a script, and that is to make all other enemies in the game immune to the state, and have all fire attacks grant the state on fire with 999% chance (999% chance is to make it really improbable that a miss occurs due to the luck bonus or penalty).


So if you want other enemies able to be inflicted with this state as well, it will take a script.
There is only one way to do this without a script, and that is to make all other enemies in the game immune to the state, and have all fire attacks grant the state on fire with 999% chance (999% chance is to make it really improbable that a miss occurs due to the luck bonus or penalty).


So if you want other enemies able to be inflicted with this state as well, it will take a script.



*looks sadly at long, long list of enemies in database


Crap.


So, uh, d'you happen to know which script I'd have to use? ^_^;;;;;
Nope. You probably have to request this, or see if someone has a script that lets you do something like this. Probably not a simple request though as it would require both a way for the script to know which enemies are flammable, and which state to add.


Though I did think of something...there might be a way with the ACE damage formula to do this with if statements. There's a thread for how to use the damage formula (be sure to use the ACE one, the MV one won't work for you), and see if you can find a way to do that.
There is an existing script which would enable you to do this,  Yanfly's Passive States - there are others, but you would have to search for them. (Note, use the Github link to get the script, not the one marked Download).


Give every enemy that you want to be flammable a passive state, which for this example we'll say is state #23.  Create your On Fire state which we'll say is state #24. Then in your fire skill damage formula put this


if b.state?(23); b.add_state(24); end; damage formula
There is an existing script which would enable you to do this,  Yanfly's Passive States - there are others, but you would have to search for them. (Note, use the Github link to get the script, not the one marked Download).


Give every enemy that you want to be flammable a passive state, which for this example we'll say is state #23.  Create your On Fire state which we'll say is state #24. Then in your fire skill damage formula put this


if b.state?(23); b.add_state(24); end; damage formula



This is good, this is good.


However, there are certain skills in my game that change a character's physical attack to Fire, and I'd like a Fire physical attack to trigger the On Fire state as well.


Hm... is there an AND function in the damage formula?  Something like "If a.state?(Fire Attack) AND b.state?(Flammable); b.add_state(On Fire)"
@pathos Please don't quote whole posts simply to indicate who you are replying to.  It makes loading the page and scrolling down it much slower, especially for those accessing this on their phone.  If you want to make it clear who you are answering, just use the @membername convention as I have done on this post.


I can't test it at the moment, but it's probably something like this, with state #25 being your fire attack:


if a.state?(25) && b.state?(23); b.add_state(24); end; damage formula
@ksjp17 Ok, I think we're almost there.


So 21 is my "Fire Attack" state, 35 is my "Flammable" state, and 36 is my "On Fire" state.



if a.state?(21) && b.state?(35); b.add_state(36); end; a.atk * 4 - b.def * 2


This works, however I also need b.state 35 to go away when 36 is added, otherwise I get the "Enemy caught on fire!" message every time someone uses a Fire attack from then on.


But: 


if a.state?(21) && b.state?(35); b.add_state(36); b.remove_state(35); end; a.atk * 4 - b.def * 2


and


if a.state?(21) && b.state?(35); b.add_state(36) && b.remove_state(35) ; end; a.atk * 4 - b.def * 2


both result in problems - the "On Fire" status is added just fine, but the attack no longer does any damage.  I'm sure this is just a syntax issue resulting from my unfamiliarity with Ruby.
I can't see what the problem is either.  The simplest solution would be to change the message to "Enemy on fire!" which would cover both the initial infliction and the ongoing state.


Have you tried putting the remove_state(35) before the add_state(36)?
@ksjp17  I missed a semicolon in the one that I'd actually typed into the formula box >_>;;;  Put the semicolon in and it works 98% perfectly now.


Only remaining issue: since the "On Fire" status includes an immunity to Fire attacks, Fire spells no longer do any damage to Flammable enemies.


This is the formula for my Fire spell:
if b.state?(35); b.add_state(36); b.remove_state(35); end; 150 + a.mat * 4 - b.mdf * 2



I've also tried putting the damage formula first, like:


150 + a.mat * 4 - b.mdf * 2; if b.state?(35); b.add_state(36); b.remove_state(35); end


But that does the same thing.  The enemy catches on fire perfectly, then "IMMUNE - 0 damage." Is there a quick way to make it so the damage is applied first before the change in state?  If not, I'm fairly done with this; it's so minor I can live with it. XD
Ah typos, the bane of every developer's life.  In order to catch things like that, it is better to copy/paste the formula from your damage formula box into your posts rather than re-type it.  It can, of course, work the other way - in re-typing you could introduce a new error.


As for your final request, I'm afraid not.  The way the engine works, damage is calculated after everything else has happened.  Therefore the immunity has already been granted by the time the damage is worked out.


If you're satisfied with what you've got, I will close the thread. 
@ksjp17 Go for it; super thanks. ^_^
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/vx-ace-effect-based-on-attack-element.72051/