I do not know why I am having a hard time finding this, I swear I have seen it before. Well, I am looking to make an enemy skill that allows the user to sacrifice/consume an ally to restore HP. The premise behind this is, for example, a bullywug frogman eatting bug allies to restore health. It can be used across the board for many other scenarios as well. Is anyone willing to help me out with this?
Enemy Consume Ally Skill
RPG Maker MV SupportYou theoretically could shove it all into the damage formula, but I think you're better off using something like Yanfly's Action Sequences. Do you want the amount of HP restored to depend on how much health the ally has, or just a set amount?
Sacrificial Bolt (MV Plugin Tips & Tricks) - Yanfly.moe Wiki
Thank you @ATT_Turan. I think restore based on how much hp the ally has would be reasonable. I have done damage formulas before but if you think yanflys action sequence would be best than I'm for trying that.
@eomereolsson - thank you. I have seen that before but wasn't sure where to begin to edit the lunatic coding to do what I wanted.
@eomereolsson - thank you. I have seen that before but wasn't sure where to begin to edit the lunatic coding to do what I wanted.
Kind of a lot of it is unnecessary for you but really the only edit you need to make is near the bottom where it says "Damage Formula used for the skill."
Just change the math after "value = " to be whatever you want, incorporating "user._allyHp" however you like. All the rest of it is already doing what you want, killing off a random ally and storing its current HP for reference.
The only thing worth mentioning is if you can have a mixed troop and only want to sacrifice specific ones - like if you can have two frogmen and some bugs and they shouldn't be able to eat each other. Then we'd need to tweak how it obtains the random ally.
Thank you @ATT_Turan. I'll modify that in a bit. That'll be great to have that to use it for other enemies.
Ooooh. Hm. Yeah, how would I modify it to only target certain ones. In this case, bugs? Would I need to place a state in the monsters in the troop? I had to do something similar to mark undead creatures before for another spell.
Ooooh. Hm. Yeah, how would I modify it to only target certain ones. In this case, bugs? Would I need to place a state in the monsters in the troop? I had to do something similar to mark undead creatures before for another spell.
You don't need to - if you had, like, multiple enemies that could all be considered edible bugs (sentences I didn't expect to type today), then that would be an easy way to go. Otherwise, if it's just one specific enemy, we can change how it gets a target ally.
Delete everything from "Get the group that the user belongs to" until "Pick a random ally." Replace it with:
Code:
var allies=$gameTroop.filter(member => member.enemyId()==bugId);
Similarly, replace the entirety of the Custom Requirement with:
Code:
value=$gameTroop.filter(member => member.enemyId()==bugId).length;
Thank you for helping me out, ATT_Turan. I am still stuck on the first bit currently. I am first making the Consume Skill for slimes and other baddies. Since slimes are ever hungry. I copy and pasted the Sacrifical Bolt skill and have edited out the user.Mp bit after the damage formula used for skill. I am uncertain what to put after that. I am having problems where the Gelatinous Cube is sometimes killing one or both his allies at once (no idea why when I have 1 ally as scope,) and he sometimes total party kills my actors when 1 enemy is selected. Again, no idea why. And despite that, he does not regain his health.
EDIT: Nevermind. I got the Consume skill working. I shouldn't edit everything at once and then test play XP One thing at a time. Fixed the problem by changing the damage type to HP drain instead of HP damage and added 'user.gainHp' after 'user._allyHp = undefined;' Now, the slime horde is one step closer to becoming terrifying. (It is strange to type that XD)
Gonna tackle the next skill step here, where the enemy, the bullywug's I had in mind, are more careful in who/what they eat.
Edit 2: I am at a loss on the second part. By bug ID you do mean the enemy id? I used that for Red Beetle (in this case 208), and I think I messed up on the second half. When you said delete the entirety of the Custom Requirement that would be everything below 'Pick a Random Ally,' correct until damage formula? If so, when I test played, Red Beetle was not consumed and the numbers showed that it was attempting to attack the actor instead.
EDIT: Nevermind. I got the Consume skill working. I shouldn't edit everything at once and then test play XP One thing at a time. Fixed the problem by changing the damage type to HP drain instead of HP damage and added 'user.gainHp' after 'user._allyHp = undefined;' Now, the slime horde is one step closer to becoming terrifying. (It is strange to type that XD)
Gonna tackle the next skill step here, where the enemy, the bullywug's I had in mind, are more careful in who/what they eat.
Edit 2: I am at a loss on the second part. By bug ID you do mean the enemy id? I used that for Red Beetle (in this case 208), and I think I messed up on the second half. When you said delete the entirety of the Custom Requirement that would be everything below 'Pick a Random Ally,' correct until damage formula? If so, when I test played, Red Beetle was not consumed and the numbers showed that it was attempting to attack the actor instead.
So, I was debating on having a few different bug types. Currently trying to test everything to see how it all flows, ya know? As it stands, I got the overall Consume skill to work, where any enemy ally but the target can be sacrificed for hp. However, I am still having trouble making it single out a specific enemy/group. Depending on how the finalized battle synergy comes out I might end up with just the one bug: Red Beetle, or a small cast of bugs that accompany the bullywug. The idea was that the bullywug's in this swamp travel in groups, so there is more than one in the troop.
Yes, you are meant to replace bugId with the enemy id of the enemy that should be eaten.
When @ATT_Turan instructed you to replace the custom requirement, he literally meant the content of the custom requirement notetag. It was not the intention that you also delete the custom execution.
In the custom execution you should only delete the following (and insert the code @ATT_Turan gave you above)
If you want to have several possible bug enemies that can be eaten we will need another filter criterion. However I'd say we worry about that once we get it to work as intended for a single bug type enemy.
When @ATT_Turan instructed you to replace the custom requirement, he literally meant the content of the custom requirement notetag. It was not the intention that you also delete the custom execution.
In the custom execution you should only delete the following (and insert the code @ATT_Turan gave you above)
JavaScript:
// Get the group that the user belongs to.
var group = user.friendsUnit();
// Get the alive members of the group.
var allies = group.aliveMembers();
If you want to have several possible bug enemies that can be eaten we will need another filter criterion. However I'd say we worry about that once we get it to work as intended for a single bug type enemy.
Thank you for responding, @eomereolsson . I still cannot get it to work. Not sure what is wrong. I replaced the enemy id with 208, the number of the Red Beetle in this experiment. Next, I have the custom requirement notetags there, but inside them I have replaced it with @ATT_Turan's code:
Next, I skipped on down to Custom Execution. Inside that, I deleted the following string of code:
And, again, I doubled and triple checked that the bugID was replaced with 208. Also, do I delete all of the Custom Cost Display content plus tags? And by ATT_Turan's last message, do I also delete this string of code from the Custom Execution?
// Remove the user from the group.
allies.splice(allies.indexOf(user), 1);
During test play, the enemy bullywug's perform the tech skill and attempt to sac Red Beetle. Both Red Beetle and Bullywug take 0. Red Beetle does not die. Bullywug is not healed. Instead both units become immortal after and immune to damage. Not sure what is happening here.
If it helps, the scope of the skill is '1 Ally' and I have damage type set to HP Drain.
Next, I skipped on down to Custom Execution. Inside that, I deleted the following string of code:
and replaced it again with ATT_Turan's code line:
And, again, I doubled and triple checked that the bugID was replaced with 208. Also, do I delete all of the Custom Cost Display content plus tags? And by ATT_Turan's last message, do I also delete this string of code from the Custom Execution?
// Remove the user from the group.
allies.splice(allies.indexOf(user), 1);
During test play, the enemy bullywug's perform the tech skill and attempt to sac Red Beetle. Both Red Beetle and Bullywug take 0. Red Beetle does not die. Bullywug is not healed. Instead both units become immortal after and immune to damage. Not sure what is happening here.
If it helps, the scope of the skill is '1 Ally' and I have damage type set to HP Drain.
That should not happen, and I can't explain what is going wrong for that to happen. Do you mind posting a screenshot of your exact skill setup?
For this to work, you should have the skill scope set to User and the damage type set to HP Restore - the goal of the skill is for the frog to heal itself.
As for the rest of it, I agree with @eomereolsson - just show us exactly what you have after all edits and we'll see if there's a mistake someplace.
As for the rest of it, I agree with @eomereolsson - just show us exactly what you have after all edits and we'll see if there's a mistake someplace.
Okay, so this is what I have. I tested your way too, @ATT_Turan with the scope being User and the damage type HP Restore but that didn't do anything either. I'm thinking it must be the code at this point?


Okay. So:
All the rest of the Custom Execution looks good to me, as does the Damage Formula.
Depending on the formation of your troop, it's possible that leaving in that splice command would have removed the only bug that was a legal target, causing the rest of the skill to fail. Try it with that removed, let us know what happens at that point.
That looks good.
You can delete that - you're only using it for enemies, they will never be looking in their skill menu to see the cost.
Still looks good.
This should have been deleted from my instructions above.
All the rest of the Custom Execution looks good to me, as does the Damage Formula.
Depending on the formation of your troop, it's possible that leaving in that splice command would have removed the only bug that was a legal target, causing the rest of the skill to fail. Try it with that removed, let us know what happens at that point.
Okay, I removed the bit you instructed me too, and I am still having the issue where it is reading 0 damage and the monsters are becoming immune to all damage thereafter. I noticed while tinkering with the scope that if it is set to 1 Enemy, it tries to wipe out an actor. The actor then becomes immune. When set to the 1 Ally (red beetle) he takes 0 and becomes immune.
I did realize that I had redone the damage code to get the first Hunger skill working, where they consume enemy allies indiscriminately. Even copy and pasting the code did not get it too work. The same problem persisted.
I did realize that I had redone the damage code to get the first Hunger skill working, where they consume enemy allies indiscriminately. Even copy and pasting the code did not get it too work. The same problem persisted.
I recently was helping someone else with a similar issue and it ended up being that something used in the calculations was undefined.
I'm not sure how that could be the case here. Just to double check, you have Yanfly's Skill Core and Damage Core installed, and in the order defined on the Yanfly Engine Plugins page, correct?
And you're testing this in a new play test each time, right? Not using the Battle Test from the editor or loading a save game?
I dunno...if I get some time tonight, I can walk you through adding some error checking console logs.
To answer your questions, I do have yanflys plugins installed in the correct order. I am meticulous about this. And I do test the battles each time on a new game file and NOT from a saved file and never in battle test.
I do have Yanflys Skill Core but...I do not know if I have Damage Core. Gimme a few...
Yup. I have Damage Core too. Drat. For a moment i was hoping that was the problem.
I do have Yanflys Skill Core but...I do not know if I have Damage Core. Gimme a few...
Yup. I have Damage Core too. Drat. For a moment i was hoping that was the problem.
So...I know the original format of the whole thing came from Yanfly, but I noticed this bit in the instructions for the Damage Formula notetag:
It kind of sounds like he's warning that using comments will cancel out the entire rest of the notetag's code. (I can't think of why else that statement would be in there, if comments just work the way they're expected to)
If you remove the comment lines (starting with // ), does that change anything?
Code:
This will overwrite the damage formula found at the top and use the
strings in the middle as the formula instead. Keep in mind that using
comments here will cancel out anything following after.
It kind of sounds like he's warning that using comments will cancel out the entire rest of the notetag's code. (I can't think of why else that statement would be in there, if comments just work the way they're expected to)
If you remove the comment lines (starting with // ), does that change anything?
Original thread: https://forums.rpgmakerweb.com/threads/enemy-consume-ally-skill.151296/