I want an actor to have a skill that passively reduces the damage they take based on how much more AGI they have than the enemy, and if the enemy is faster, then they deal the damage they would have normally done. Would I have to create a state that has this type of effect and condition and add it to the actor as a permeant feature? What if I have a passive skill that has a cooldown, like resisting death every x turns?
Help with making a damage reduction passive skill
RPG Maker MZ SupportYou seem to be asking a few things all together, so I'll try to sort this.
Once you have that set up, you'll need VisuStella's Battle Core to give the state the notetag:
You didn't actually say how you want the damage reduction to be calculated, so I can't fill that in for you. Put it after the = sign, and you can see value refers to the original damage amount, user to the attacker and target to the actor being attacked.
See Trihan's thread for how to implement the Auto-Life state:
forums.rpgmakerweb.com
Then you'd encapsulate all of the code in the notetag with this:
Again, you didn't say what x is, so replace it with a valid number.
And you'd also give the state the notetag:
Yes and no. You would need to use VisuStella's Skills & States Core, and use notetags to attach the state to the skill as a passive state. Once any actor has learned that skill, they will have the state.
Once you have that set up, you'll need VisuStella's Battle Core to give the state the notetag:
Code:
<JS Pre-Apply as Target>
if (target.agi > user.agi)
value =
</JS Pre-Apply as Target>
You didn't actually say how you want the damage reduction to be calculated, so I can't fill that in for you. Put it after the = sign, and you can see value refers to the original damage amount, user to the attacker and target to the actor being attacked.
Completely different question, but sure.
See Trihan's thread for how to implement the Auto-Life state:
How to implement every possible Yanfly Tips & Tricks effect in MZ with VisuStella plugins
Hi all. This is by far one of the biggest topics I've seen people asking about, to the point where I've been commissioned twice to make an MZ project containing all of the T&T effects. So I figured I'd make a topic about how to implement them all yourselves. If no other plugins are specified...
forums.rpgmakerweb.com
Then you'd encapsulate all of the code in the notetag with this:
Code:
if (!target.lifeCooldown)
{
// original code pasted in here
target.lifeCooldown = x;
}
And you'd also give the state the notetag:
Code:
<JS Post-End Turn>
if (user.lifeCooldown)
user.lifeCooldown = Math.max(user.lifeCooldown - 1, 0);
</JS Post-End Turn>
Specifically, I want the damage to be reduced up to 30% if the AGI difference cap is met. Let's say the maximum bonus occurs when the user is 50 AGI higher than the enemy, and any AGI difference between 0 to 49 gives less damage reduction. How would I write that?
Yeah, I wanted to ask an additional question for different types of passive skills, specifically, skills that activate passively but aren't a permeant effect.
Would this be under the "Second Chance" spoiler? If so, I need some clarification on the code there.
Value is still the damage that would be dealt as you said above? Then in the if statement it turns the damage equal to the user's current HP minus 1, so that they live on one HP?Would
target.lifeCooldown be equal to the name of the skill? Would I just change lifeCooldown to whatever the skill's name is?And this code would be from the Auto-Life state in Trihan's thread? This is probably the most confusing part for me.
Not unless Trihan changed the name from the original Yanfly Tip & Trick, which would rather defeat the point of the thread. Did you search the page for the name I gave you, "Auto-Life"?
Why would you change anything? Unless someone gives you the instruction to (as I did with "replace x"), or you are proficient enough with JavaScript to understand what you're doing, you shouldn't change anything in code.
The answer to the question is that it's an arbitrary name, but it needs to be selected as something that doesn't already exist in the default core scripts or any major plugins I was familiar with.
I'm happy to clarify, but I don't see how "paste Trihan's original code here" is confusing. Please tell me what in my instructions you don't understand and I'll rephrase as necessary.
I didn't include the hyphen so i got 0 results. But yeah I see it now.
I ask so I can try to understand the function to why something works the way it does. I don't want to have to keep asking for help on the same things because I just copy and pasted what someone told me to do.
It was confusing because I couldn't find the auto-life spoiler before so I didn't know which specifically I was supposed to put in. Only thing I think I need clarifying is that the
//Original code part that you wrote is referring to the auto-life code?That's fine, and there's certainly nothing wrong with asking. 🙂 It was the way the question was framed that you were assuming you should change it.
I would suggest, however, that if you're interested in learning, doing a proper tutorial with a sequential progression of concepts is much better. Otherwise you're liable to end up with piecemeal knowledge that has holes in it.
I suggest the w3schools tutorial, starting with the Statements chapter.
Yes. When the instruction has looking up Trihan's adaptation of Auto-Life, there is code inside the notetag in that spoiler.
Thus, I said to put that code inside the conditional I provided, and indicated where. The code from Auto-Life should be the only code to reference at that point. (that's why I was confused by your confusion...it seemed like me telling you "go get your car from down the block. Then park the car in my driveway," and you ask me "which car" 😛 )
To be clear, you'd end up with
Code:
<JS Post-Apply As Target>
if (!target.lifeCooldown)
{
if (target.hp <= 0 || target.isDead()) {
$gameTemp.requestAnimation([target], 49);
const rate = 0.1;
const heal = Math.floor(target.mhp * rate);
target.removeState(state.id);
target.gainHp(heal);
target.startDamagePopup();
}
target.lifeCooldown = x;
}
</JS Post-Apply As Target>
again, replacing x with how many turns you want it to be on cooldown.
Good luck with your project.
Okay I'll do that then. Thanks for the suggestion.
Got it, thanks.
But back to the original question, I wanted the damage reduction calculation to be something based off this concept. How would I implement it?
It depends on how exactly you want the damage reduction percentage to be calculated. If it's just supposed to be a linear progression, I'd go for:
<JS Pre-Damage as Target>if ((target.agi - user.agi) > 50) value = value * 0.7elif (target.agi > user.agi) value = value * (1-(((target.agi - user.agi) / 50) * 0.3))</JS Pre-Damage as Target>Original thread: https://forums.rpgmakerweb.com/threads/help-with-making-a-damage-reduction-passive-skill.168913/