I have a relatively complex problem here... I'm implementing a bounty system that tracks the number of monsters you kill of a certain type. The only twist is, the Slime enemy in my game splits into two if you hit it with certain attacks.
The way this split works is: when the split event is triggered, the "Slime" enemy is transformed into a "Mini Slime," and a second "Mini Slime" is appeared next to it. For the bounty, split Slimes still only count as one, so you have to kill BOTH Minis to gain 1 credit toward the bounty.
I'm not sure how exactly to program this. I have an experimental script working that looks like this. When Enemy #1 is reduced to 0, first it checks to see if it's split (by checking if the second Mini Slime (#5) has appeared). If false, it adds 1 to the bounty. If true, it checks to see if it's already dead, and if so, adds 1 to the bounty; if not, the variable is not affected.
When it comes to the Mini Slime, the script merely checks to see if the main Slime is already dead, and if so, adds 1 to the bounty.
So basically, killing either Mini Slime only adds 1 to the bounty if the other is already dead. If you just kill 1 Mini Slime, then escape from the battle, you gain nothing toward the bounty.
This method works just fine when they're killed one at a time. The only problem is what will happen when the deaths are simultaneous. I'm using Yanfly's Action Sequences, which causes multiple enemies struck by the same attack to die simultaneously. When this happens, each script detects the other as being dead when they both run, causing them to add 2 to the bounty.
Perhaps I'm going about this the wrong way. Can anyone help me out with this?
The way this split works is: when the split event is triggered, the "Slime" enemy is transformed into a "Mini Slime," and a second "Mini Slime" is appeared next to it. For the bounty, split Slimes still only count as one, so you have to kill BOTH Minis to gain 1 credit toward the bounty.
I'm not sure how exactly to program this. I have an experimental script working that looks like this. When Enemy #1 is reduced to 0, first it checks to see if it's split (by checking if the second Mini Slime (#5) has appeared). If false, it adds 1 to the bounty. If true, it checks to see if it's already dead, and if so, adds 1 to the bounty; if not, the variable is not affected.
Code:
if #5 is appeared {
if #5 is affected by knockout {
control variables: #0043 bounty slime +=1
}
}
else {
control variables: #0043 bounty slime +=1
}
When it comes to the Mini Slime, the script merely checks to see if the main Slime is already dead, and if so, adds 1 to the bounty.
Code:
if #1 is affected by knockout {
control variables: #0043 bounty slime +=1
}
So basically, killing either Mini Slime only adds 1 to the bounty if the other is already dead. If you just kill 1 Mini Slime, then escape from the battle, you gain nothing toward the bounty.
This method works just fine when they're killed one at a time. The only problem is what will happen when the deaths are simultaneous. I'm using Yanfly's Action Sequences, which causes multiple enemies struck by the same attack to die simultaneously. When this happens, each script detects the other as being dead when they both run, causing them to add 2 to the bounty.
Perhaps I'm going about this the wrong way. Can anyone help me out with this?