Stacking States and Increased Damage

Status
Not open for further replies.

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
Hello,

I'm trying to create a stacking state which increases the overall damage output of the users attacks.

Basically, when the state is applied, damage increase by .25. When the skill is cast again, the state counter goes from 1 to 2, and then damage is increased again from 1.25 to 1.50. This would stack to a max of 2.00 damage, and when the state is removed, the counter goes back to 0.

However, I can't get it to work. I'm using Yanfly Buff and State Core to try to accomplish this.

Here's my current code:

<Custom Apply Effect>
// Defaults user's combo stacks to 0.
user._atkupStacks = user._atkupStacks || 0;
// Get the current number of stacks. Min 0, Max 4.
var stacks = user._atkupStacks.clamp(0, 4);
// Increase stack count.
stacks += 1;
// Set stack count min to 0, max to 4.
stacks = stacks.clamp(0, 4);
// Set the counter for the state.
user.setStateCounter(stateId, 'x' + stacks);
// Apply stack count to user's combo count.
user._comboStacks = stacks;
</Custom Apply Effect>

<Custom Remove Effect>
// Reset combo stacks to 0.
user._atkupStacks = 0;
// Get the current number of stacks. Min 0, Max 4.
var stacks = user._atkupStacks.clamp(0, 4);
// Set the counter for the state.
user.setStateCounter(stateId, 'x' + stacks);
</Custom Remove Effect>

<Custom Confirm Effect>
// Check if the user is delivering physical damage.
if (this.isPhysical() && this.isMagical() && value > 0 ) {
// Get the current number of stacks. Min 0, Max 4.
var stacks = user._atkupStacks.clamp(0, 4);
// Calculate the extra damage rate from Combo stacks.
var rate = 1.00 + stacks * 0.25;
// Round the damage upward.
value = Math.ceil(value * rate);
}
</Custom Confirm Effect>

I could be handling this all wrong, lol but i guess that's what this topic is for.

Thanks for looking at this!
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
What part doesnt work? Does the attack boost never added? Does it only get added once? It doesnt reset?
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
I made some tweaks to the code. Here it is now.

Now, the stacks work, but the damage bonus is the thing that isn't changing. I can't figure that part out:

<Custom Apply Effect>
// Default the atkup stacks to 0.
user._atkup = user._atkup || 0;
// Increase the stockpile stack by 1
user._atkup += 1;
// Cap the atkup stack at 4
user._atkup = Math.min(user._atkup, 4);
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._atkup);
</Custom Apply Effect>

<Custom Remove Effect>
// Set the user's stockpile stack to 0
user._atkup = 0;
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._atkup);
</Custom Remove Effect>

<Custom Confirm Effect>
// Check if the user is delivering physical damage.
if (this.isPhysical() && value > 0 ) {
// Get the current number of stacks. Min 0, Max 4.
var stacks = user._atkup(0, 4);
// Calculate the extra damage rate from stacks.
var rate = 1.00 + stacks * 0.25;
// Round the damage upward.
value = Math.ceil(value * rate);
}
</Custom Confirm Effect>

Would it be possible to use damage core, to add a "Damage step" that would take into account the stacks? I'm not sure that's possible, and I know there's an easier way lol
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
Hmmm your user._atkup is a property so why are you doing this "user._atkup(0, 4)" in the confirm effect instead of just "user._atkup"?
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
Hmmm your user._atkup is a property so why are you doing this "user._atkup(0, 4)" in the confirm effect instead of just "user._atkup"?
I was trying to make sure, the max state cap was 4, but I'm a newb at this stuff, so I'm not sure if that works.

EDIT: So, I removed that part, and it looks like the formula is working now...

What exactly was the issue?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
._atkup is a property, calling a property is done via simply calling its name. While you did ._atkup(0,4) which is a function call, which means it will try to actually find a function named _atkup that takes 2 parameters, which is most probably nonexistent in your game.

basically:

Property: name;
Function: name(*params);

Right now there is no need to check if _atkup is within 0-4 because you're only setting it via the notetags which already caps it at 4, so unless you modify the value elsewhere, it should always cap at 4 anyway.

If you want to still make sure, the way to do it is via Math.min and Math.max

Math.min(Math.max(0,user._atkup),4);

This gets first which is larger between 0 and your _atkup, then checks which is smaller between the answer and 4.
 
Last edited:

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
Ah, I see. That makes a lot of sense.

As you can see, I'm still learning, so I appreciate your explanation.

Here's my final code for anyone who wants to use it or edit it to their own liking:

<Custom Apply Effect>
// Default the atkup stacks to 0.
user._atkup = user._atkup || 0;
// Increase the atkup stack by 1
user._atkup += 1;
// Cap the atkup stack at 4
user._atkup = Math.min(user._atkup, 4);
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._atkup);
</Custom Apply Effect>

<Custom Remove Effect>
// Set the user's atkup stack to 0
user._atkup = 0;
// Update the state counter for the atkup stack
user.setStateCounter(stateId, user._atkup);
</Custom Remove Effect>

<Custom Confirm Effect>
// Check if the user is delivering physical damage.
if (this.isPhysical() && this.isMagical() && value > 0 ) {
// Get the current number of stacks. Min 0, Max 4.
var stacks = user._atkup;
// Calculate the extra damage rate from stacks.
var rate = 1.00 + stacks * 0.25;
// Round the damage upward.
value = Math.ceil(value * rate);
}
</Custom Confirm Effect>

The only other thing I kind of want to do is add the number of stacks into a variable, so when it shows the state name on a battlelog, the number of stacks would show as well.

Where do you think the best place to put that would be? I'm thinking the last line in the apply effect.

Edit: So now, I'm actually having another issue, but its in another state.

Basically, its the same state but I'm trying to increase defense this time. The problem is again, with the damage. Damage doesn't change. Here's the code

<Custom Apply Effect>

//remove def debuffs.

target.removeState(16)

// Default the defup stacks to 0.

user._defup = user._defup || 0;

// Increase the defup stack by 1

user._defup += 1;

// Cap the defup stack at 4

user._defup = Math.min(user._defup, 4);

// Update the state counter for the stockpile stack

user.setStateCounter(stateId, user._defup);

</Custom Apply Effect>




<Custom Remove Effect>

// Set the user's defup stack to 0

user._defup = 0;

// Update the state counter for the defup stack

user.setStateCounter(stateId, user._defup);

</Custom Remove Effect>




<Custom React Effect>

// Check if the user is delivering physical damage.

if (this.isPhysical() && this.isMagical() && value > 0 ) {

// Get the current number of stacks. Min 0, Max 4.

var stacks = user._defup;

// Calculate the extra damage rate from stacks.

rate = 1.00 - stacks * 0.25;

// Round the damage upward.

value = Math.ceil(value * rate);

}

</Custom React Effect>
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
Well to show the stacks, you dont even need to set it to another variable, you can use the .atkup property directly to do that, you just need to pass the message into the Battle Log... Sadly Im not sure of the method to do that in MV, but if you read thru the functions handling battle flow, you will surely be able to see how it sends messages to the battle log.

As for your new state, you had this condition

if (physical && magical)

That will never be true because items/skills can only be either physical, magical or certain hit, not a combination of any of those.

Based on your comment on your own code, you only want to check physical, so why is there a check for magical too in that condition?

PS: I also checked your new atkup and saw that you also edited the condition to be the same as the defup, can you confirm that it is still working? Because logically, the condition physical && magical would never be true. Your old code only have the physical condition in it (+ the value > 0)
 
Last edited:

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
Yes, I actually noticed this when I was testing this morning. I think I would have to use this.isHpEffect() instead, or just use only physical attacks for my game, which actually won't be an issue.

Here's the working code:
<Custom Apply Effect>

//remove Atk debuffs.

target.removeState(14)

// Default the atkup stacks to 0.

user._atkup = user._atkup || 0;

// Increase the atkup stack by 1

user._atkup += 1;

// Cap the atkup stack at 4

user._atkup = Math.min(user._atkup, 4);

// Update the state counter for the stockpile stack

user.setStateCounter(stateId, user._atkup);

</Custom Apply Effect>



<Custom Remove Effect>

// Set the user's atkup stack to 0

user._atkup = 0;

// Update the state counter for the atkup stack

user.setStateCounter(stateId, user._atkup);

</Custom Remove Effect>



<Custom Confirm Effect>

// Check if the user is delivering physical damage.

if (this.isPhysical() && value > 0 ) {

// Get the current number of stacks. Min 0, Max 4.

var stacks = user._atkup;

// Calculate the extra damage rate from stacks.

var rate = 1.00 + stacks * 0.25;

// Round the damage upward.

value = Math.ceil(value * rate);

}

</Custom Confirm Effect>

and here's the defense code. Now now this code really has thrown me for a loop. It just doesn't really work at all. For some reason, whenever the actor uses the state, they take no damage at all. Not only, do they take no damage but it creates this weird effect where the character HP bar completly empties out but the numbers don't move. Here's a screenshot. You can see the HP bar is blank, but I still have 24 hp!
upload_2019-3-31_7-45-12.png

<Custom Apply Effect>

//remove Atk debuffs.

target.removeState(16)

// Default the defup stacks to 0.

user._defup = user._defup || 0;

// Increase the defup stack by 1

user._defup += 1;

// Cap the defup stack at 4

user._defup = Math.min(user._defup, 4);

// Update the state counter for the stockpile stack

user.setStateCounter(stateId, user._defup);

</Custom Apply Effect>



<Custom Remove Effect>

// Set the user's defup stack to 0

user._defup = 0;

// Update the state counter for the defup stack

user.setStateCounter(stateId, user._defup);

</Custom Remove Effect>



<Custom React Effect>

// Check if the action dealt damage.

if (this.isPhysical() && value > 0) {

// Get the current number of stacks. Min 0, Max 4.

var stacks = user._defup;

// Calculate the amount of damage to reduce.

var rate = 1.00 - stacks * 0.25

// Reduce that amount of damage from the actual damage.

value -= value * rate;

}

</Custom React Effect>
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
if you want to make it work for all attacks, you can just remove the isPhysical condition. Using isHpEffect is a good idea too so it doesnt work for MP effects etc

as for your def... hmmm thats a weird behavior.. Maybe you can try adding this to your notetag after the value -= line

console.log(value);

Then run the game and turn on the console, and see what value gets printed into the console when your character gets damaged with the state on
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
if you want to make it work for all attacks, you can just remove the isPhysical condition. Using isHpEffect is a good idea too so it doesnt work for MP effects etc

as for your def... hmmm thats a weird behavior.. Maybe you can try adding this to your notetag after the value -= line

console.log(value);

Then run the game and turn on the console, and see what value gets printed into the console when your character gets damaged with the state on
I’m not by my computer now, but I did try it without the -= effect and it didn’t work either. I’ll try the console log value thing when I get back near my computer so we can see what value gets used.

Is there any way I can change the pdr rate in the custom apply effect based on the number of stacks? That might be a good way to go about it. As a work around at least.

Just being honest, I’m looking for anyway I can uses the stacked states to reduce the overall damage, so if this doesn’t work, I’ll try other methods :)
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
I’m not by my computer now, but I did try it without the -= effect and it didn’t work either.
You still dont get damaged even without the value -= line? Now thats totally weird...

You can add new pdr traits to modify the pdr value in the react effect but I highly not suggest it..
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
You still dont get damaged even without the value -= line? Now thats totally weird...

You can add new pdr traits to modify the pdr value in the react effect but I highly not suggest it..

Yeah it has me totally stumped lol!

@Engr. Adiktuzmiko: So I ran the consolelog.value thing and this is what I got: NaN

upload_2019-4-1_8-29-49.png
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
try to put the console call to before the line now, if it still shows NaN, it means "value" doesn't exist in that code space.. Which will mean you need to find another tag or method to use to reduce the damage taken.
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
try to put the console call to before the line now, if it still shows NaN, it means "value" doesn't exist in that code space.. Which will mean you need to find another tag or method to use to reduce the damage taken.
I actually just figured it out. I changed all of the instances of “user” to “target” in the def codes and they worked as intended. I’m not sure why, but it’s all working now!
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,647
Reaction score
2,974
First Language
Tagalog
Primarily Uses
Most probably because user is the user of the skill, target is the target. Your def code is for react, which means it runs on the target, not the user.
 

Lonewulf123

Veteran
Veteran
Joined
Oct 13, 2014
Messages
289
Reaction score
86
First Language
Enlish
Most probably because user is the user of the skill, target is the target. Your def code is for react, which means it runs on the target, not the user.
Yes, that makes complete sense.

Once I get access to my computer again, I’ll edit this post with the final codes I used, so others can create stacking states of their own.

Thank you for the help @Engr. Adiktuzmiko! I’ve learned a lot just from talking to you.

and here are the codes:

<Custom Apply Effect>

//remove Atk debuffs.

target.removeState(14)

// Default the atkup stacks to 0.

user._atkup = user._atkup || 0;

// Increase the atkup stack by 1

user._atkup += 1;

// Cap the atkup stack at 4

user._atkup = Math.min(user._atkup, 4);

// Update the state counter for the stockpile stack

user.setStateCounter(stateId, user._atkup);

</Custom Apply Effect>



<Custom Remove Effect>

// Set the user's atkup stack to 0

user._atkup = 0;

// Update the state counter for the atkup stack

user.setStateCounter(stateId, user._atkup);

</Custom Remove Effect>



<Custom Confirm Effect>

// Check if the user is delivering physical damage.

if (this.isPhysical() && value > 0 ) {

// Get the current number of stacks. Min 0, Max 4.

var stacks = user._atkup;

// Calculate the extra damage rate from stacks.

var rate = 1.00 + stacks * 0.25;

// Round the damage upward.

value = Math.ceil(value * rate);

}

</Custom Confirm Effect>

<Custom Apply Effect>

//remove Atk debuffs.

target.removeState(16)

// Default the defup stacks to 0.

target._defup = target._defup || 0;

// Increase the defup stack by 1

target._defup += 1;

// Cap the defup stack at 4

target._defup = Math.min(target._defup, 4);

// Update the state counter for the stockpile stack

target.setStateCounter(stateId, target._defup);

</Custom Apply Effect>



<Custom Remove Effect>

// Set the target's defup stack to 0

target._defup = 0;

// Update the state counter for the defup stack

target.setStateCounter(stateId, target._defup);

</Custom Remove Effect>



<Custom React Effect>

// Check if the action dealt damage.

if (this.isPhysical() && value > 0) {

// Get the current number of stacks. Min 0, Max 4.

var stacks = target._defup;

// Calculate the amount of damage to reduce.

var rate = 1.00 - stacks * 0.25

// Reduce that amount of damage from the actual damage.

value = Math.floor(value * rate);

}

</Custom React Effect>
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
5,902
Reaction score
4,219
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

It took me 6 retries to get the color of Yoshi I wanted. 30 mins of recording. 30 mins of voice work. Probably another 20 mins of waiting in between takes. But finally I got him...
I bought a 2 week emergency food supply. And people are already making fun of me :( I'll be fed for a bit while they go hungry when food supplies get cut(for whatever reason).
Start of semester today. This is going to be a long one.
Can't wait for the next Sonichu
Birdhouses are usually made of wood. Birds typically live in trees. Trees are wood. Birdhouses are made of birdhouses.

Forum statistics

Threads
93,675
Messages
914,491
Members
123,265
Latest member
karqui
Top