Surrender / Arrest Enemies

● ARCHIVED · READ-ONLY
Started by SJWebster 10 posts View original ↗
  1. 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?
  2. 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.
  3. The way to accomplish it without plugins would be to have Troop Events that check whether each enemy is either killed OR surrendered, and decreases a variable (which starts on Turn 0 as the number of enemies in the troop) by 1 if so. Once the variable hits 0, if the battle isn't over, you'll know that the battle is over, so you can either forcibly wipe all enemies that remain (ending the battle in a victory), or abort the battle. You can use Hime's Custom Page Conditions plugin to make the checks easier to implement, but it's not absolutely necessary.

    Otherwise, you'll need to create/commission a plugin which changes the "Judge" method in battle and considers whether enemies have surrendered when determining whether you have won a combat. If this is the case (you have won and enemies have surrendered), you'd want to run a new method you create that is similar to the Victory method, except that it handles special processing like multiplying your EXP and Gold gains. This is the best way to do it if you have the programming proficiency (or can commission someone who does - should be a pretty cheap commission), because creating/copying all the troop events will take considerable time, and will force you to change the events if you change a troop's composition during development.
  4. 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.
  5. SJWebster said:
    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 do not have access to MV at this moment so I can't check myself, but can't you just use a script call from the event page to achieve this?

    Something like

    Code:
    for (var i = 0; i < $gameTroop.members().length; i++){
       var member = $gameTroop.members()[i];
       member.exp = member.exp * 1.2; //member.exp probably is not the right variable name
    }

    The only part you would have to change is "member.exp" to whatever variable is responsible for how much exp an enemy should give. This way you should be able to use the common troop event.
  6. 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).
  7. SJWebster said:
    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).

    Yep that is exactly correct. You don't have to put the if statement in the javascript itself. though, you can just put this script inside a conditional branch inside the event. Both ways work and it's just about which one you prefer.
    If you do that, the only thing you might need to change is the "member.exp" variable if it gives you a reference error.

    If you want to go with the if-statement-inside-javascript route, you just need to add this:
    Code:
    if (member.isStateAffected(x)){
       //dothething
    }
  8. 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.
  9. 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.
  10. 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.