Grunwave

Veteran
Veteran
Joined
Feb 4, 2017
Messages
636
Reaction score
182
First Language
English
<Custom Apply Effect>

target._paramPlus[3] += origin.mdf;

</Custom Apply Effect>

<Custom Remove Effect>

target._paramPlus[3] -= origin.mdf;

</Custom Remove Effect>

I am currently accomplishing this with:


The issue is that, if the Actor dies with this buff up, his DEF is permanently raised.

Anyone know another way to accomplish this? Thank you in advance.
 

Johnny_Ray

Also known as Toby Yasha
Veteran
Joined
Sep 11, 2019
Messages
70
Reaction score
40
First Language
English
Primarily Uses
RMMV
You will need BaseParamControl Plugin.
Try this:

<Custom Apply Effect>
var org = target.stateOrigin(YourStateID);
user.addDef(org.mdf);
</Custom Apply Effect>

<Custom Remove Effect>
var org = target.stateOrigin(YourStateID);
user.minusDef(org.mdf);
</Custom Remove Effect>
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
928
Reaction score
582
First Language
English
Primarily Uses
RMMV
You will need BaseParamControl Plugin.
Try this:

<Custom Apply Effect>
var org = target.stateOrigin(YourStateID);
user.addDef(org.mdf);
</Custom Apply Effect>

<Custom Remove Effect>
var org = target.stateOrigin(YourStateID);
user.minusDef(org.mdf);
</Custom Remove Effect>
While this suggestion is good for removing the extra defense if something happens to the origin, like being removed from the party mid-battle, or being killed (if it's an enemy), it won't solve OPs problem.

The problem here is that on death, states are not removed in the traditional sense. The battler.states array is just cleared. That means no states that have a remove (or leave) effect will have them happen on death, and is why you can't make a re-raise state that would auto-resurrect someone without also making it bypass the death removal.

A <Custom Deselect Effect> might run before the death is actually registered. You could put that on the same state, and have it check if the battler's hp == 0, and then reset his defense that way. Alternatively, you could make this state bypass death removal via the state categories plugin, and it will not be removed upon death, then you can use <custom regeneration effect> to check if the afflicted battler is currently dead, and reset his defense and/or remove the state then.

If the deselect effect doesn't work by itself, bypassing the death removal and then using that same tag to remove the state if the battler is dead probably will work, so you could do that too.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
955
Reaction score
499
First Language
English
Primarily Uses
RMMV
@Johnny_Ray - How would that function differently from the OP? The script calls he's making are changing the parameter, but it's not getting called during the Custom Remove - why would your suggestion, getting called at the same time, work differently?

(as an aside - why create a variable you use only once on the very next line?)

I'd suggest...ninja'ed!
 

Grunwave

Veteran
Veteran
Joined
Feb 4, 2017
Messages
636
Reaction score
182
First Language
English
While this suggestion is good for removing the extra defense if something happens to the origin, like being removed from the party mid-battle, or being killed (if it's an enemy), it won't solve OPs problem.

The problem here is that on death, states are not removed in the traditional sense. The battler.states array is just cleared. That means no states that have a remove (or leave) effect will have them happen on death, and is why you can't make a re-raise state that would auto-resurrect someone without also making it bypass the death removal.

A <Custom Deselect Effect> might run before the death is actually registered. You could put that on the same state, and have it check if the battler's hp == 0, and then reset his defense that way. Alternatively, you could make this state bypass death removal via the state categories plugin, and it will not be removed upon death, then you can use <custom regeneration effect> to check if the afflicted battler is currently dead, and reset his defense and/or remove the state then.

If the deselect effect doesn't work by itself, bypassing the death removal and then using that same tag to remove the state if the battler is dead probably will work, so you could do that too.




<Custom Deselect Effect>

if (target.hp <= 0) {-= origin.mdf * 0.5};

</Custom Deselect Effect>

Is that the correct script?
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
928
Reaction score
582
First Language
English
Primarily Uses
RMMV
<Custom Deselect Effect>

if (target.hp <= 0) {-= origin.mdf * 0.5};

</Custom Deselect Effect>

Is that the correct script?
No. You have no reference to the target's current def, so the argument inside the if check has an error in it.

The easiest way to do this would be to remove the state in the deselect effect, which would cause it to do what your <custom remove effect> was already doing. The only difference being this should happen before the actor actually dies, so it should still remove the extra def in that case.

Another thing I'd change is to remove the reference to the origin in anything other than the <custom apply effect>. Things can happen during battle, like a battler could be ejected from the fight, removed from the party, or killed (if it's an enemy), which will cause your remove effect to no longer know what the origin was, or its mdf, so it'll crash when it tries to remove the extra defense.

In your apply effect, set a local variable on the battler:

Code:
<Custom Apply Effect>
target._bonusdef = origin.mdf * 5
target.def += target._bonusdef
</Custom Apply Effect>
It might also be a good idea to prevent this state from giving the bonus defense if it is reapplied, to prevent it from stacking up in a weird way, and causing you to remove an incorrect amount of defense later:
Code:
<Custom Apply Effect>
if (target._bonusdef){
target._bonusdef = origin.mdf * 5
target.def += target._bonusdef
}
</Custom Apply Effect>
With the above change, you'd also want to add a delete target._bonusdefto the remove effect, to allow the bonus to be applied again later.
 

Latest Threads

Latest Profile Posts

my main character isn't the warrior of light or the chosen one, he's a self righteous, invasive try hard who gets ahead of himself and makes a critical error, resulting in a downward moral spiral that, eventually, leads him to truths that make him a better man, and im DAMN proud of that.
Generate Actors, Dark Fantasy Monsters, & I Heard There Was a Chosen One, | RPG Maker News #42

Work on Cat Quest: The Last Catmancer continues slowly but surely. :kaopride: Today I received the Game Over screen from @Finnuval!
GameOver.png
Hey everyone! No Studio Blue RPG Maker Critiques Stream today! But you can always check the playlist for old streams you've missed!

Forum statistics

Threads
111,445
Messages
1,061,150
Members
144,806
Latest member
HowlingMeteor277
Top