Losing battle on actor death?

Hi, it's my first post so I don't know if it should go here, but anyway. I have a question related to forcing a battle lose.


On the project I'm making, you usually play with just 1 actor, from time to time you can bring in another one to the party but just for a time. I wanted the player to lose the battle if the main actor died. I tried with troop eventing but I don't think that's the best solution because most of the time the player will be on their own, and dying alone do cause a battle lose, I also tried with some scripts, one from Yanfly(Death Common Event) and one from Mr. Bubble(Lose Battle on Actor Death), Yanfly's one works perfect for deleting the auxiliar party members when they die, but Mr. Bubble's script don't work at all on my project, I think it is because of the battle system I'm using(Classical Active Time Battle, from Yami). I make my battles with events forcing them and you can always lose them, if you lose them I have some things going on in the bracket, that's why I need to be able to force a battle lose, and not just a battle abort.


After a lot of searching, I've come to thinking two solutions that maybe possible, but I can't manage to achieve:


1.- Modifying the Battle_Manager Win/Loss Results part to process a defeat if the main actor dies, I alredy tried it without success, my attempt was inserting this line below the process abort one:


     #return process_defeat  if $game_party.battle_members[0].dead?


2.- Create a common event that manages to somehow call a battle lose, if possible, and using that event with Yanfly's script.


I usually never post on the forums because most of the times I find the information I need just searching and with trial and error, but this time I can't work things out. Hope anyone knows more on this subject and thanks if you do and respond.
Okay, I think I have a solution for you. It's a Common Event. I set it up to look like this:


Control Variables: [0007😛layerLife] = [Eric]'s HP


Conditional Branch: Variable [0007😛layerLife] ==0


> Change HP: Entire Party, -9999


>


Else


>


Branch End


You can name the Variable whatever you want and I used Eric for testing, obviously you should use our main character for the variable.


Next, I went to Troop and in the Battle Event, I called this Common Event. For Conditions, I used "When the End of the Turn" and for Span I used "Turn". Just keep in mind, that you will have to add this common event to every Troop you create.
Thanks for the reply GreyStone, I tried your solution but I got an error:


"Script 'Game_Interpreter' line 119: FiberError occurred.


 double resume"


I understand some things on the scripts but I've never seen this "fiber thing", so I don't know what it means.


I even changed the decrease hp with an add death state, for the entire party too, but the error was the same. On the other hand, if I unchecked the box of allow knockdown, the event just left the actors with 1 hp and no error occurred, so I guess the problem is the part of actually killing them. If you got this without the error the problem here could be with the battle system, but I don't think so because it process the turn ends just right.


Any thoughts on that?
I have no problems running it, but I don't have any scripts running. Which script is it that is giving you the problem? I can try installing it and seeing what happens.
Well, I really don't know since the error is from the Game_Interpreter, but it happens on combat, so my guess its that it should be one of the combat scripts I'm using, they are just 2:


Yanfly's Ace Battle Engine and Yami's Classical Active Time Battle. Try using them and if you get the error hopefully you can understand it.
@Braveado For the Yami's Classical ATB, I noticed on the site there are add-ons. Are you using any of those too, or just the basic script?


EDIT: Also just noticed there are add-ons for Yanfly's as well. Any of those?
No, I'm not using any of those, just the base script.
@Braveado Okay, one last thing I forgot to ask, did you adjust any of the settings in either of the scripts? I just play tested with Yanfly's Battle Engine, and everything worked fine (I did not touch any of the settings in the script), so it might be Yami's Script, but I can't test it atm, because I'm getting a Busy Dropbox error 🙁  


I think I found it, can you double check that this is the right script for Yami's CATB? https://raw.githubusercontent.com/suppayami/rmvxa-collection/master/old-ace-scripts/catb.txt
Yep, that's the catb script, I changed some things on both, but just customization options on the editable parts, mainly color and sizes stuff, I didn't change anything else.


Edit:


Obviously I put :catb on line 245 of ABE so catb would work.


And if it matters, I put catb to full on wait time, and action on turn type.
@Braveado Okay, on Yami's did you adjust anything else? It came default with Full on wait time and Action on Turn Type for me. There are numbers below each of those settings, did you change any of those? Like AFTER_ACTION or anything? I know it might be a pain, but if you could list anything you changed, just in case, that would be helpful. My game messes up a couple of times ever since I've put in Yami's, but I can't get it to replicate your issue yet.


Oh, one more thing, too. Which one is the top most script, Yami or Yanfly?
Let's see, on Yami's I have this settings:

Spoiler
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - General Configuration -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DEFAULT_FILL_TIME = 150 # Frames
    DEFAULT_WAIT      = :full # :full, :semi, :quarter, :wait
    FILL_TIME_VARIABLE  = 15 # Change DEFAULT_FILL_TIME by variable.
   
    PAUSE_WHEN_ACTIVE_PARTY_COMMAND = false
   
    PREEMTIVE_ATB_ACTOR = 70
    PREEMTIVE_ATB_ENEMY = 0
    SURPRISE_ATB_ACTOR = 0
    SURPRISE_ATB_ENEMY = 70
   
    FORCE_ACTION_CLEAR_ATB = false
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Turn Configuration -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DEFAULT_TURN          = :action # :tick, :action
   
    TICK_COUNT            = 150    # Turn after TICK_COUNT
    TICK_COUNT_VARIABLE   = 16     # Change TICK_COUNT by variable.
   
    AFTER_ACTION          = 2      # Turn after AFTER_ACTION actions.
    AFTER_ACTION_VARIABLE  = 3     # Change AFTER_ACTION by variable.
    FORCE_ACTION_COUNT = false # Count force action as a turn action?
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Actor ATB Gauges -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    GAUGE_COLOR1 = 20
    GAUGE_COLOR2 = 21
    CHARGE_COLOR1 = 18
    CHARGE_COLOR2 = 10
    ATB_GAUGE_Y_PLUS = 11
    ATB_PHRASE = ""
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Enemy ATB Gauges -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    SHOW_ENEMY_ATB_GAUGE    = true  # Display Enemy HP Gauge?
    ENEMY_GAUGE_WIDTH      = 128    # How wide the enemy gauges are.
    ENEMY_GAUGE_HEIGHT     = 5     # How tall the enemy gauges are.
    ENEMY_ATB_GAUGE_COLOUR1 = 20     # Colour 1 for ATB.
    ENEMY_ATB_GAUGE_COLOUR2 = 21     # Colour 2 for ATB.
    ENEMY_BACKGAUGE_COLOUR = 19     # Gauge Back colour.

And I have Yanfly's on top of Yami's.


Let me know if you need to know anything else.
Okay, I'm stumped because I can't even get my common event to activate now


Alright, so I had to change the common event to get it to work. For some reason I think the ATB system doesn't register "turns" like the default system so I switched the event and changed it a bit too, now you don't need that common event. Just go into Troop, for the Condition, put "Actor [YourMainCharHere]'s HP is 0% or below" and for the span use "Moment". Now in the event area, just put "Change HP: Entire Party -9999".


I'm still not getting any errors with that. Let me know if you are getting the error again, if so, it could be either something is wrong with your battle event or another script is interfering. 
Sorry but I'm getting the same error that way, if you think that the issue is indeed the combat screen and it may be another script(because I really don't know what does fiber and double resume means here), I'm using some little scripts that I didn't mention because I didn't think they could be a problem for this(because they don't have nothing to do with turn ends, at least that I know of). I use 2 for different ones for enemy hp gauges, one that is a hotfix for the catb one, and one for animations for front view battlers.


If you think one of those might be the problem tell me and I will post them. On the other hand though, seeing you modified the catb script, do you know a proper way to make another defeat condition on the Battle_Manager Win/Loss Results part?
Yes, it is possible that one of your other scripts is causing the issue, so it would be great if you can link them. As for the Battle_Manager, I MAY be able to. I haven't modified the CTAB script at all, but I understand how some of the scripts work and may be able to make another outcome if you can tell me what you need. I assume you would want the "If Hero dies in battle, end battle", right?
That's great to hear! If you could make a condition on win/lose result that process a defeat on the first actor dying, that would be perfect, because I tried it and look for a way to do it, but my line on the OP is the best I could make.


If you want to try installing the other scripts though, here are they:


MOG Battler Motion, this one doesn't have a direct download, you have to download a master demo with a bunch of his scripts, but just copy/paste this script on your test project.


DoubleX RMVXA Bug Fix v1.05b to YSA Battle System: Classical ATB, I mainly needed this to fix the auto battle actors.


VTS-Enemy HP Bars and Enemy HP Bars are the hp gauges ones.


Hope you can sort something out for this, I've been looking for information on the fiber error thing and read something about it and the update of frames or something along those lines, so the problem may be indeed one of these.
I've tried adding ALL of those scripts and still can't get an error. My last thought is either I don't have them fully configured like you, or it is something in the Enemy Event that is incorrect. What order are your scripts in? Can you give a screen shot of an Enemy Event? Also, have you tried it versus a different enemy or keep trying against the same one?
Okay, let me see. I've tried with diferent enemies, I always get the same error when I have at least 2 actors on the party and the main one dies. I've attached a screenshot of the event.


I have the scripts in the next order: MOG, Ace BE, Classical ATB, Bug Fix for catb, Ace HP Bars, VTS HP Bars.


I didn't changed anything past the configurations for each one, you think you need to set them like I did? Or maybe could be another script? That's everything I have for combat though.

Battle Event.png
That wasn't the event I meant, sorry, I should have been more clear. I meant the event with the enemy. You said:

I make my battles with events forcing them

A screen shot of that event is what I meant.


If you have more scripts, please list all of them. It would be easiest to list them in the order you have them and provide links if you can, please.
I've attached a screenshot of the event.


All the scripts I'm using in the orden I'm using them:


If I didn't put a link it was because I already did it on the posts above.


I know they might be quite a few so, sorry if this problem is taking much of your time, hope you find something.

Battle Event on Map.png
Wow, that's quite a list! I didn't think it would be so long.


Okay, to make things easier, since you have all of those scripts configured the way you need them to and it would take a lot of time for you to copy and paste all the configurations you've made, it makes more sense for you to troubleshoot the scripts on your side. So what you need to do is to go into each of your scripts, press Ctrl+A (this will select everything) and then press Ctrl+Q (this will comment out the entire script which makes the script inactive).


Next, what you want to do is a play test to make sure you aren't getting that error. If that works, then go back into your scripts, choose one and then use Ctrl+A and Ctrl+Q to make that script active again, then go and playtest. You will want to continue doing this, adding a script one by one, until you do get that error again, then you will know that the last script you added was the one causing the problem. Once you find the script the script that causes the problem, deactivate it again and continue going through the list just in case there is another script causing the problem.


Now once you have finished going through all the scripts, hopefully its just one script that is causing the issue. Meanwhile, I will try my hand at making that script in the Battle_Manager for you.


EDIT!!!!  Alright, figured something out for you. Delete the common event, and stuff you added because of me. Try adding in this line in your BattleManager under your Determine Win/Loss section. I put this line in at line 194 below the original defeat:


return process_defeat  if $game_actors[001].dead?  #GS84


I took off all the scripts and it does work to stop the battle in defeat, not abort. Even though your main character does technically "die", the other party members keep their current health and your main character will have 1 health after the battle. You can delete the #GS84 if you want, it's up to you. I only put those in the scripts at the lines I add or edit in case something goes wrong, I can easily find what I edited by searching for that comment.


Also, the [001] is for the number of your main character in case he isn't [001].

Original thread: https://forums.rpgmakerweb.com/threads/losing-battle-on-actor-death.62486/