1. I want to have a skill hit 2 random enemies, but without a chance for it to hit the same enemy twice (if there is only 1 enemy, the attack hits only once). I guess I'm going to need a plugin for that? If not, how do I make this, and if yes, anybody knows of a plugin that can make this work?
2. I have a skill that hits 2 random enemies at once and restores 5 MP to the user for each hit. How do I make the restore MP function work? I tried with applying a state, and then use a Common Event to read each enemy's state, but it fails to read if the damage from the skill killed the enemy. Are there any better ways of doing this?
How to make this work? (2 Battle questions)
RPG Maker MV Support1. You can use http://yanfly.moe/2016/02/26/yep-74-target-core/ and applying states.
Specifically the custom eval which should be placed in the skill's notetag section:
<Custom Target Eval>
for (var i = 0; i < foes.aliveMembers().length; ++i) {
var member = foes.aliveMembers();
if (member.isStateAffected(10)) targets.push(member);
}
</Custom Target Eval>
Setup the state to drop after 1 turn. Once you are confident in the state, remove the icon and text. (yanfly's battle core will remove state text as well if configured to do so).
2. You can do that by adding the following to your damage formula:
a.gainMp(5)
edit: Updated example. It should look like THIS (the MP should be Mp or the whole line won't work):
c=100 + a.mat * 2 - b.mdf * 2; a.gainMp(5); c
**Disclaimer, both of these are untested as I am at work on my lunch hour & off the top of my head... hopefully they work out or at least point you in the right direction. I'll play around with it more tonight when I get home to confirm**
Again, hope this helps!
Specifically the custom eval which should be placed in the skill's notetag section:
<Custom Target Eval>
for (var i = 0; i < foes.aliveMembers().length; ++i) {
var member = foes.aliveMembers();
if (member.isStateAffected(10)) targets.push(member);
}
</Custom Target Eval>
Setup the state to drop after 1 turn. Once you are confident in the state, remove the icon and text. (yanfly's battle core will remove state text as well if configured to do so).
2. You can do that by adding the following to your damage formula:
a.gainMp(5)
edit: Updated example. It should look like THIS (the MP should be Mp or the whole line won't work):
c=100 + a.mat * 2 - b.mdf * 2; a.gainMp(5); c
**Disclaimer, both of these are untested as I am at work on my lunch hour & off the top of my head... hopefully they work out or at least point you in the right direction. I'll play around with it more tonight when I get home to confirm**
Again, hope this helps!
@Traveling Bard, thank you for replying. I had looked at the Target Core, but it seems I'm going to need to write code, which is something I cannot do. I copied your code into the skill's notetags, but it gave me this error: TypeError undefined is not a function
I added the ; a.gainMP(5) to the damage formula. The MP gain now works, but the skill won't deal damage any longer. 🙁 The formula currently looks like this: a.atk-b.def; a.gainMP(5)
I added the ; a.gainMP(5) to the damage formula. The MP gain now works, but the skill won't deal damage any longer. 🙁 The formula currently looks like this: a.atk-b.def; a.gainMP(5)
Almost off work and I know this seems kind of crazy but try adding the following for #2
c= a.atk-b.def; a.gainMP(5); c
I do that because only the last number/variable in the damage formula is supposed to be able to deal damage. I forgot about that. As for the type error on #1, I'll check that in about an hour or so.
c= a.atk-b.def; a.gainMP(5); c
I do that because only the last number/variable in the damage formula is supposed to be able to deal damage. I forgot about that. As for the type error on #1, I'll check that in about an hour or so.
That didn't work either, but I switched around the effects like this: a.gainMp(5); a.atk-b.def, and now it functions like it should.
Alrighty, thanks a lot for the help! Anything code related really is my weak spot with gamemaking. 🙁
I dabble... and apparently need more work lol glad it worked out for you!
Checked into it a bit more and I think I'm at the limit of my ability. I feel like your answer for 1 is close to what I was saying... the logic is something like:
Is there more than 1 enemy?
//Yes
-select one of them randomly.
-hit that one.
-select another one randomly that isn't the one you hit before.
-hit them too.
-end.
//No
-hit them.
-end.
So I think between Yanfly's battle core & target core plugins you'll find the answer... perhaps someone else reading this can help you?
As for 2, I found that my original formula was using a.gainMP(5) which was causing the whole calculation to fail. Once I changed it to this:
c = a.atk-b.def; a.gainMp(5); c
It worked just fine. This method is a good way to do conditions such as checking for states and what not, so I recommend it in the future.
Hope you find the answers you are looking for! Good luck.
Is there more than 1 enemy?
//Yes
-select one of them randomly.
-hit that one.
-select another one randomly that isn't the one you hit before.
-hit them too.
-end.
//No
-hit them.
-end.
So I think between Yanfly's battle core & target core plugins you'll find the answer... perhaps someone else reading this can help you?
As for 2, I found that my original formula was using a.gainMP(5) which was causing the whole calculation to fail. Once I changed it to this:
c = a.atk-b.def; a.gainMp(5); c
It worked just fine. This method is a good way to do conditions such as checking for states and what not, so I recommend it in the future.
Hope you find the answers you are looking for! Good luck.
With Yanfly's Target Core, try this in the skill's notetag:
<Custom Target Eval>
var members = [];
for (var j = 0; j < foes.aliveMembers().length; ++j) {
members.push(foes.aliveMembers()[j]);
}
for (var i = 0; i < 2; i++) {
if (members.length > 0) {
var randInt = Math.floor(Math.random() * members.length);
targets.push(members[randInt]);
members.splice(members.randInt, 1);
}
}
</Custom Target Eval>
You can also adjust it to hit more than two enemies by changing the 2 in the line "for (var i = 0; i < 2; i++)".
<Custom Target Eval>
var members = [];
for (var j = 0; j < foes.aliveMembers().length; ++j) {
members.push(foes.aliveMembers()[j]);
}
for (var i = 0; i < 2; i++) {
if (members.length > 0) {
var randInt = Math.floor(Math.random() * members.length);
targets.push(members[randInt]);
members.splice(members.randInt, 1);
}
}
</Custom Target Eval>
You can also adjust it to hit more than two enemies by changing the 2 in the line "for (var i = 0; i < 2; i++)".
@LadyBaskerville, I put that in the skill's notetag, but the skill still seems to be able to strike the same enemy twice. I'm using TargetCore v1.02a (the latest version).
Yes, that one does work. 🙂
Yes, that one does work. 🙂
Sorry, made a mistake when editing the formula. It should be:
Code:
<Custom Target Eval>
var members = [];
for (var j = 0; j < foes.aliveMembers().length; j++) {
members.push(foes.aliveMembers()[j]);
}
for (var i = 0; i < 2; i++) {
if (members.length > 0) {
var randInt = Math.floor(Math.random() * members.length);
targets.push(members[randInt]);
members.splice(randInt, 1);
}
}
</Custom Target Eval>
@LadyBaskerville, yes, that works perfectly! 😀 Thanks a lot for helping me with that skill.
No problem 🙂
@LadyBaskerville, if it's not too much, I have another question regarding a similar skill. This skill hits the same enemy multiple times, but if the enemy dies before the skill has finished, the other hit(s) strike another enemy. How do I make it so that the skill stops if the enemy dies before the skill has done its full number of hits?
Do you make the enemy repeat the skill, or do you make the skill be multihit?
Because in the database you can make a skill hit up to 9 times.
Because in the database you can make a skill hit up to 9 times.
Ah, yeah. This was my bad. Got it. This time, I had an issue with another plugin, but it's working now. Thread can be closed. 😀
Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-this-work-2-battle-questions.70454/