I'm trying to give the player a non lethal approach that awards more money and experience than out and out killing foes.
So I have a state called Surrender that stops all movement, like Petrify. I've also created skills that can inflict it.
Where I'm stuck is making all battles recognise if an enemy was defeated using Surrender and then awarding 1.2x EXP, money, etc.
Any ideas?
you need to use a troop event to check every enemy at the end of every turn, and if all remaining enemies are in that state give extra rewards and abort battle.
Cheers guys! I'm guessing Yanfly's Base Troop Events won't streamline it because each enemy awards a different amount of EXP so I'm going to be manually assigning EXP gains for surrendering enemies? That also means manually changing Troops events if I ever adjust the base EXP.
I might post in the jobs forum, just see how much it might cost for a script. I've started learning JavaScript with a tutorial that teaches you how to make Blackjack but I'm not near the level needed to write MV plug ins myself yet.
I think I actually understand a little bit of that code, the lessons are working!
So, the start is a For loop. It initialises "i" to 0 then says if "i" is less than the length of the array game Troop.members (the enemy party) then set the variable "member" equal to that member of the enemy's party. Then use that information to apply the 1.2x EXP from the database value for that enemy. Afterwards, add 1 to "i" so the For loop continues cycling through enemies until "i" is equal to their party size and the loop breaks. Is that even close to right? (I'm a complete JavaScript n00b)
If that's the case, I'm guessing I'd have to nest an if statement to say if the enemy party member at that index of that array is inflicted with Surrender, otherwise it'll apply 1.2x EXP to all enemies I think?
On a bus to work at the moment so not got my bulky JavaScript reference books or anything to hand to double check, but that sounds about right (I think).
just one point of advice:
doing it that way would still require the enemy to be killed for the EXP to be added (you cannot simply abort the battle in this case), but it would display the gained EXP on the aftermath screen.
alternatively you can store that number inside a variable with control variable, and then use that variable to add EXP by event command - that would allow you to simply abort the battle without killing, and the aftermath screen would only show the EXP gained by killing. So you'll probably have to make your own message about the EXP gained, but that would help differentiating "EXP gained for capturing enemies" to the player as well.
Ideally, all the EXP gain should be on the aftermath screen to avoid confusing the player.
Technically "killing" the enemies behind the scenes so the aftermath screen works okay isn't the end of the world if I can skip the collapse effect. I'm sure someone somewhere put together a method to skip collapse, then I just have to tie that to having the Surrender status effect.
We're getting into areas of the MV code I haven't worked with before, but my instinct is that (especially if the "surrendered" enemy EXP isn't automatically added) that it would be smart to just give the EXP to the party directly right before you abort the battle (after you multiply by the 1.2 surrender bonus), for each enemy that surrendered. You can probably just call a method like $battleMembers.gainExp() or something like that (but $battleMembers is almost definitely the wrong object name to call; I forget what the right one is). I'm not sure whether the Yanfly Results Window would need any extra modification.
This seems like a useful and small enough plugin that you'd at least have a chance of having it completed as a favor in Plugin Requests, but if not, you can probably commission it for $30 or less. Shouldn't require anything too exceptional.