Trying to create a stacking state.

Hi everyone,

I'm trying to replicate a little mechanic from the game Final Fantasy X, whereby a character's skill can stack on the enemy up to 5 times.

For example, I'm trying to come up with a skill that applies a state to an enemy that adds the trait of "Parameter - Defense 105%", which from what I understand, will reduce the enemy's DEF stat by 5% (not taking into other potential factors, anyway).

This is all good and well, but the next steps would be to

A ) Make this stack-able

and

B ) Make sure that after this has been applied to the enemy 5 times, there is no longer any advantage of using this skill on the same target again.

The idea is that it would remove 5% DEF each time, making a total reduction of 25% from their original DEF stat possible.

Open to using plugins, if anyone has any solutions.

Thanks!
first thing:
"Parameter - Defense 105%",
i think that adds 5% def
(Parameter - Defense 95% should reduce 5%)

second thing:
The idea is that it would remove 5% DEF each time, making a total reduction of 25% from their original DEF stat possible.
I think it woks better to use different States, and the "stack counter" Variable should decide which state gets added..
for example.. :
-if "stack counter" Var = 1 add State with Parameter - Defense 95%
(and remove any other Parameter - Defense State if affected)
-if "stack counter" Var = 2 add State with Parameter - Defense 90%
(and remove any other Parameter - Defense State if affected)
.. and so on, ect.


EDIT 2 ( i figured out a better way to solve this in a Common Event)
In that Case you want the State to change with each Skill Usage, you can do that with using a Common Event which is attached to The Skill
JavaScript:
var target = ???

if (target.isStateAffected(4)) {
     target.addState(5);
     target.removeState(4);
};

if (target.isStateAffected(3)) {
     target.addState(4);
     target.removeState(3);
};

if (target.isStateAffected(2)) {
     target.addState(3);
     target.removeState(2);
};

if (target.isStateAffected(1)) {
     target.addState(2);
     target.removeState(1);
};

if (!target.isStateAffected(1)) {
    if (!target.isStateAffected(2)) {
        if (!target.isStateAffected(3)) {
            if (!target.isStateAffected(4)) {
                if (!target.isStateAffected(5)) {
                    target.addState(1);
                }
            }
        }
    }
};
You need the right Code for the var "target" ..
(in SRPG that would be :
"$gameSystem.EventToUnit($gameTemp.targetEvent().eventId())[1];"
,
but i dont know the Similar Code for normal RPG Projects..sry)

if that is solved , this Code above will ask about, what state is affected and add or remove The States how its needed
(EDIT INFO, the right order/sequence is important to avoid unwanted chain reaction)
- if State 4 is affected it will remove it and add State 5
- if State 3 is affected it will remove it and add State 4
- if State 2 is affected it will remove it and add State 3
- if State 1 is affected it will remove it and add State 2
- if none of the 5 states is affected it will add State 1, that should happen at the End of the Common Event.


Edit 3
If you cant figure out the Code for "var target" ,you could also use the Plugin Hime placeHolder States instead.
sry for double posting i had to edit the previous Code, because the order in which the Script Parts are set is Important to avoid a Chain Reaction which isnt wanted.
I just wanted to make sure this Issue is recognized..
( thats why the Code Now ask&remove first state 4&adds5 if affected, than 3&adds4 if affected than 2&adds3 if affected than 1&adds2 if affected.. and set State 1 at the end if none of the States is affected )
Hi there again @Dopan ,

Yes, this may work. The script call in question is:

Code:
BattleManager._action._targetIndex

I'm going to give it a test.

However - and I just saw your second message - the conditional branch segment still confuses me a bit.

At no point does it check "If enemy does NOT have state", so I think I need to start there, right?
At no point does it check "If enemy does NOT have state", so I think I need to start there, right?
sure it Does thats the last Code part.. this one:
(thats why that part has to be at the end to avoid chain reaction which could be started with adding state 1 to early)
-> i realized later that all other code parts needs also to be in the right order ,because of the same reason

JavaScript:
if (!target.isStateAffected(1)) {
    if (!target.isStateAffected(2)) {
        if (!target.isStateAffected(3)) {
            if (!target.isStateAffected(4)) {
                if (!target.isStateAffected(5)) {
                    target.addState(1);
                }
            }
        }
    }
};

Puting " ! " before " target.isStateAffected(2) " for Example means:
" NOT target.isStateAffected(2) "
! negates the target.isStateAffected(2)
Ah! Certainly, I missed that. Sorry! Thanks a bunch!

Secondly, I decided to change the DEF parameter to elemental resistance instead.

So I changed the states to:

State #1: 105% Element X
State #2: 110% Element X
State #3: 115% Element X
State #4: 120% Element X
State #5: 125% Element X

That makes sense right? Because in the case of elemental resistance, the higher the number, the greater the weakness to that element. That all makes sense right?
That makes sense right? Because in the case of elemental resistance, the higher the number, the greater the weakness to that element. That all makes sense right?
I think yes , atleast thats what the system says when hovering over it^^
i hope it works but i think it should anyway^^
Hi again @Dopan ,

I did the test, but the state doesn't even seem to be applying to the enemy. I added an animation to the state to make sure it was at least applying, but that doesn't seem to be the case. Perhaps the code for the enemy index is not working.
Hi again @Dopan ,

I did the test, but the state doesn't even seem to be applying to the enemy. I added an animation to the state to make sure it was at least applying, but that doesn't seem to be the case. Perhaps the code for the enemy index is not working.
If you cant figure out the target part try hime Placeholder states, you have to Setup them in a similar way like its explained earlier for the Common Event..
(that plugin allows to use state notes to make conditions what state gets affected,but its a bit tricky to setup to get a longer chain)
Both solutions should work..

also if something doesnt work you can also always hit F8 to open the console and look if there is an error that gives some extra info

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-create-a-stacking-state.129598/