State that delays other negative states until expires.

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
410
Reaction score
61
First Language
English
Primarily Uses
I haven't found anything really like this except with damage.
I want to make a state that reduces all damage by 50% for 3 turns and any negative states (psn, blind, etc) and debuffs are removed until the state expires then are reapplied. Second if possible any new states added will not be added but will be also be applied when the state expires.
Ex: The actor uses "last stand" skill and removes PSN, DEF Debuff and now is immune to all negatives status.
An enemy casts BLINDand it does not get applied.
Another enemy applies ATK Debuff and it is not applied.
Finally when last stand expires, the actor regains the initial PSN and DEF Debuff but additionally BLIND and ATK Debuff are added.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Are you using Yanfly's Buffs & States Core plugin?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Okay, give your state the PDR * 50% and MDR * 50% traits to half all damage, then in the notebox put

Code:
<Custom Apply Effect>
target._savedStates = [];
let states = target.states().filter(state => state.id !== 12);
states.forEach(function(state) {
  target._savedStates.push([state.id, target.stateTurns(state.id)]);
  target.removeState(state.id);
});
</Custom Apply Effect>
<Custom Deselect Effect>
let states = target.states().filter(state => state.id !== 12);
states.forEach(function(state) {
  target._savedStates.push([state.id, target.stateTurns(state.id)]);
  target.removeState(state.id);
});
</Custom Deselect Effect>
<Custom Remove Effect>
target._savedStates.forEach(function(state) {
  target.addState(state[0]);
  target._stateTurns[state[0]] = state[1];
});
delete target._savedStates;
</Custom Remove Effect>
This will store any state the user is afflicted with while the state is active (except itself, obviously; replace 12 with the ID of the state that's doing this effect) and then reapply them all when the state ends at the number of turns that were left on them when stored.
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
410
Reaction score
61
First Language
English
Primarily Uses
<Custom Apply Effect> target._savedStates = []; let states = target.states().filter(state => state.id !== 12); states.forEach(function(state) { target._savedStates.push([state.id, target.stateTurns(state.id)]); target.removeState(state.id); }); </Custom Apply Effect> <Custom Deselect Effect> let states = target.states().filter(state => state.id !== 12); states.forEach(function(state) { target._savedStates.push([state.id, target.stateTurns(state.id)]); target.removeState(state.id); }); </Custom Deselect Effect> <Custom Remove Effect> target._savedStates.forEach(function(state) { target.addState(state[0]); target._stateTurns[state[0]] = state[1]; }); delete target._savedStates; </Custom Remove Effect>
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode {stack: (...), message: "Block-scoped declarations (let, const, function, class) not yet supported outside strict mode"}

Got this error, running RM1.5.1, I think I should update it but im scared to lose any plugins lol. Should I just update it?

Also wondering how to go about saving states, I tried a few things but couldnt figure it out.

Debuffs are a bit more tricky because of the way buffs and debuffs are considered the same. I was trying an idea but im not so good with coding.
Code:
If 0 being HP debuff is active, it will set it to off //
if (user._buffs[0] >= 1) {
    user._buffs[0] *= 0;}
I could do this for all of the params, but I am unsure how to store and then re-add them. Even looking at your code I dont fully know the work around.
How do you cycle through buffs[0-7] then if it finds a debuff (value at -1), it 'Pushes' that debuff to save and then re-add when state is removed. Since I don't understand how cycle and loops work I would do something crazy long and unnecessary to achieve it.

Code:
For each buff 0-7 //
<Custom Apply Effect>
var hpbuff = 0
if (user._buffs[0] >= 1) {
    user._buffs[0] *= 0;
   var hpbuff += 1;}
</Custom Apply Effect>

<Custom Remove Effect>
if (var hpbuff = 1){
user.addDebuff(0,??);}
</Custom Remove Effect>
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Just change let to var if you're using an older version.

I'll answer the second part of your query when I'm home. :)

Edit: So in addition to doing this with states, you want it to remove/store debuffs as well?
 
Last edited:

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
410
Reaction score
61
First Language
English
Primarily Uses
Just change let to var if you're using an older version.

I'll answer the second part of your query when I'm home. :)

Edit: So in addition to doing this with states, you want it to remove/store debuffs as well?
It didnt work so I just updated to 1.6.1 and it works great now!
Yes I was hoping debuffs and not buffs would work with it, sort of a nothing bad can happen to you until it runs out.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Okay, gimme a sec.

Code:
<Custom Apply Effect>
target._savedStates = [];
target._savedDebuffs = [];
let states = target.states().filter(state => state.id !== 12);
states.forEach(function(state) {
  target._savedStates.push([state.id, target.stateTurns(state.id)]);
  target.removeState(state.id);
});
target._buffs.forEach(function(buff, index) {
  if (buff < 0) {
    target._savedDebuffs.push([index, target._buffTurns[index]]);
    target.removeBuff(index);
  }
});
</Custom Apply Effect>
<Custom Deselect Effect>
let states = target.states().filter(state => state.id !== 12);
states.forEach(function(state) {
  target._savedStates.push([state.id, target.stateTurns(state.id)]);
  target.removeState(state.id);
});
target._buffs.forEach(function(buff, index) {
  if (buff < 0) {
    target._savedDebuffs.push([index, target._buffTurns[index]]);
    target.removeBuff(index);
  }
});
</Custom Deselect Effect>
<Custom Remove Effect>
target._savedStates.forEach(function(state) {
  target.addState(state[0]);
  target._stateTurns[state[0]] = state[1];
});
target._savedDebuffs.forEach(function(debuff) {
  target.addDebuff(debuff[0]);
  target._buffTurns[debuff[0]] = debuff[1];
});
delete target._savedStates;
delete target._savedDebuffs;
</Custom Remove Effect>
 
Last edited:

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
410
Reaction score
61
First Language
English
Primarily Uses
Okay, gimme a sec.

Code:
<Custom Apply Effect>
target._savedStates = [];
target._savedDebuffs = [];
let states = target.states().filter(state => state.id !== 12);
states.forEach(function(state) {
  target._savedStates.push([state.id, target.stateTurns(state.id)]);
  target.removeState(state.id);
});
target._buffs.forEach(function(buff, index) {
  if (buff < 0) {
    target._savedDebuffs.push([index, target._buffTurns[index]]);
    target.removeBuff(index);
  }
});
</Custom Apply Effect>
<Custom Deselect Effect>
let states = target.states().filter(state => state.id !== 12);
states.forEach(function(state) {
  target._savedStates.push([state.id, target.stateTurns(state.id)]);
  target.removeState(state.id);
});
target._buffs.forEach(function(buff, index) {
  if (buff < 0) {
    target._savedDebuffs.push([index, target._buffTurns[index]]);
    target.removeBuff(index);
  }
});
</Custom Deselect Effect>
<Custom Remove Effect>
target._savedStates.forEach(function(state) {
  target.addState(state[0]);
  target._stateTurns[state[0]] = state[1];
});
target._savedDebuffs.forEach(function(debuff) {
  target.addDebuff(debuff[0]);
  target._buffTurns[debuff[0]] = debuff[1];
});
delete target._savedStates;
delete target._savedDebuffs;
</Custom Remove Effect>
Wow awesome it works :) Thanks a lot!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Do you need me to explain any of the code to you?
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
410
Reaction score
61
First Language
English
Primarily Uses
Do you need me to explain any of the code to you?
<Custom Apply Effect>
target._savedStates = [];
target._savedDebuffs = [];
let states = target.states().filter(state => state.id !== 12); // Not sure why target and not user. // filter? // Does state equal to or less than state with exception of 12?
states.forEach(function(state) { // forEach? Unfamilar with this is just just "for"?
target._savedStates.push([state.id, target.stateTurns(state.id)]);
target.removeState(state.id);
}); // from forEach () It will cycle to all the states and push them and then remove them? Also excluding 12?
target._buffs.forEach(function(buff, index) {
if (buff < 0) {
target._savedDebuffs.push([index, target._buffTurns[index]]);
target.removeBuff(index);
}
}); // Think I understand the buffs, I forget that if you want to keep the turns you need to add Turns and index.
</Custom Apply Effect>
<Custom Deselect Effect> //Same as above but applies when selected as a target and instanly stores and removes the state?
let states = target.states().filter(state => state.id !== 12);
states.forEach(function(state) {
target._savedStates.push([state.id, target.stateTurns(state.id)]);
target.removeState(state.id);
});
target._buffs.forEach(function(buff, index) { // may sound dumb but what does index refer to or mean?
if (buff < 0) {
target._savedDebuffs.push([index, target._buffTurns[index]]);
target.removeBuff(index);
}
});
</Custom Deselect Effect>
<Custom Remove Effect>
target._savedStates.forEach(function(state) {
target.addState(state[0]); // I dont get this I know its supposed to add the states that were previously stored. Why "0"
target._stateTurns[state[0]] = state[1]; // No idea what the "0" and "1" do?
});
target._savedDebuffs.forEach(function(debuff) {
target.addDebuff(debuff[0]);
target._buffTurns[debuff[0]] = debuff[1];
});
delete target._savedStates; // delete = undefined?
delete target._savedDebuffs;
</Custom Remove Effect>
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Because the skill targets the user, user and target are the same so it doesn't matter which you use. You could have used user there if you'd wanted. The ID in the filter is to make sure you don't store and remove the state that's storing and removing negative states/debuffs. Note that it will also store positive states right now; you'd have to provide it a list of negative ones that should be stored if you want to do that.

forEach is a function of arrays that iterates through each element using the variable you supply to it. You can then refer to the current element of the array using that variable inside the code block. Basically yeah this'll cycle through all states that don't have ID 12, add them to the _savedStates array and remove them from the user.

Correct on the Deselect effect. Just does the same thing as the apply after the user has been selected as a target, storing any states that were added to them to the array.

Index refers to the current array element; in a forEach if you supply a second parameter to the function, it'll store the current element's index as well as the element itself. Because we need to refer to a specific element of _buffTurns in order to get the one for the buff we're currently looking at, it's easier to pass the index in so we can use it in the code block.

The 0 and 1 are array elements. _savedStates and _savedDebuffs are stored as arrays of arrays, the first element (0) being the state/debuff ID and the second element (1) being the number of turns.

Delete sets the variable back to being undefined, yeah.
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
410
Reaction score
61
First Language
English
Primarily Uses
Because the skill targets the user, user and target are the same so it doesn't matter which you use. You could have used user there if you'd wanted. The ID in the filter is to make sure you don't store and remove the state that's storing and removing negative states/debuffs. Note that it will also store positive states right now; you'd have to provide it a list of negative ones that should be stored if you want to do that.

forEach is a function of arrays that iterates through each element using the variable you supply to it. You can then refer to the current element of the array using that variable inside the code block. Basically yeah this'll cycle through all states that don't have ID 12, add them to the _savedStates array and remove them from the user.

Correct on the Deselect effect. Just does the same thing as the apply after the user has been selected as a target, storing any states that were added to them to the array.

Index refers to the current array element; in a forEach if you supply a second parameter to the function, it'll store the current element's index as well as the element itself. Because we need to refer to a specific element of _buffTurns in order to get the one for the buff we're currently looking at, it's easier to pass the index in so we can use it in the code block.

The 0 and 1 are array elements. _savedStates and _savedDebuffs are stored as arrays of arrays, the first element (0) being the state/debuff ID and the second element (1) being the number of turns.

Delete sets the variable back to being undefined, yeah.
Wow that you so much for taking the time to break it all down, I feel now that I might actually be able to attempt a task such as thing. I really appreciate it! Forum needs more like you :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top