Making Battle Events process before judge_win_loss

Status
Not open for further replies.

Zelfore

Villager
Member
Joined
Apr 5, 2019
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
I'm having a very specific issue here.

I've managed to setup a series of battle events that allow an enemy to "return" (restore life to full) after an action finishes processing. The issue I'm having occurs if all enemies are all_dead by the end of an action (AoE moves, killing all at once basically).

What I'd like to do is make it so battle events run one more time before the BattleManager.judge_win_loss process begins, because the moment it does the battle ends without giving the battle events a chance activate again.

I've tried tampering with the Script Maker and throwing certain code into other places without much success. The closest I got was removing BattleManager.judge_win_loss from the three instances found in Scene_Battle and placing the judge script instead after the innermost end of turn_end, but the turn doesn't seem to end if there are no enemies on screen.

So I need one of two options to pull off my goal.
1. Make it so Battle Events process before judge_win_loss gets a chance to.
Or 2. Find a way to reach turn_end even when all enemies are eliminated.

So if you can manage to make it so the battle doesn't end immediately after all enemies are dead, you've successfully managed what I hoped for. (You can easily test this by setting up a troop with one enemy and a Battle Event that activates when that enemy's HP drops below 0%, the event being Enemy Recovers All.)

Note: This is all being done with the initially provided scripts found in RPGMaker VX Ace, I have not added or edited any of the scripts you start with, and any changes I'd originally made were reverted.

What I'm NOT looking for:
Complex New Scripts (Materials) - I'm not looking for complicated/advance battle systems. I'm working with the original tools provided. I'm not risking a brand new battle system messing up the Battle Events I've built.

If the (Material) script isn't long or complicated, I'll throw it in, but otherwise I'd prefer the OG battle system with a few minor tweaks.

P.S. Credit will be given to whomever helps me with this, but this is a heavy W.I.P. right now, so if I ultimately don't release the project you'll have to excuse me.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Why don't you simply turn a switch on when the battle starts and then use that switch as triggering condition for a common event that does what you want to do? This way the common event effectively acts as an event that triggers when the battle ends.
 

Zelfore

Villager
Member
Joined
Apr 5, 2019
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Either I don't understand what you mean or you don't understand what I mean.

Just to make sure. According to your suggestion, if a Troop with a single enemy is killed, with the condition of dying to be healed to full again, the battle won't automatically end? Because that's what I'm trying to accomplish.

Autorun (which is the only way a Common Event can be triggered by a switch) only works on the map screen. I can NOT allow the battle to end before the event triggers, it has to happen after an action ends and before the judging win/loss begins, no other time will work for what I'm trying to achieve.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
What you say is true but going back to map you can have the player enter the battle again through that common event. That works in the same way as healing all troop enemies. If all you want to achieve is to simply heal all enemies this should work quite well. If this is not what you are trying to achieve and you want to run those troop events for another reason, you might have to edit the script itself. However, if what you want is just heal all troop members why not starting the battle again?

I am not saying there are no reason to not let the battle end, I am just asking which reasons you have that prevent you from starting the battle again without restoring actors' hp/mp.
 

Zelfore

Villager
Member
Joined
Apr 5, 2019
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
The reason I cannot allow the battle to end is because of the system I've setup. It works like so...

There are five enemies in the battle, the Battle Event counts these enemies (this adds up to 5). When an enemy is defeated, and before the next action, the enemy respawns (is healed to full) and adds +1 to the counter. When the counter adds up to 10, enemies stop respawning upon death and the battle plays out like normal.

Essentially, I've managed to create a working death counter that revives enemies until a specified number is reached. But this is as far as I can manage it, because using an AoE ability and successfully killing all enemies at once ignores the death counter and ends the fight on the spot.

That's why I'd already figured some scripting was in order, but the exact points I need to refine is a little complex as the battle system is spread through out several scripts.

So I need advice/help on prolonging the judge_win/loss check until turn_end, or to force Battle Events to go off before the judge_win/loss check.
Worst case scenario? I remove all obtainable AoE abilities/items from my game. Which would be unfortunate but manageable.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Ok, that helps me understanding what you need and also helps me figuring out possible options to achieve that. I am from mobile right now so I cannot test the code for you, that is something you have to do on your own. However, try putting this in your material:
Code:
module HBSE
 
  module Config
 
   PROCESS_EVENTS = true
 
   COUNTER_VARIABLE = 10 # Change this to be your variable
 
  end
 
  def self.count_var
    $game_variables[Config::COUNTER_VARIABLE]
  end
 
  def self.prevent_victory?
    Config::PROCESS_EVENTS
  end
 
end

class Game_Troop
 
  def all_dead?
    result = super
    return result && (HBSE.count_var > 10) if HBSE.prevent_victory? # Change the number here
    return result
  end
 
end
if you set PROCESS_EVENTS to false the system works as the usual VX Ace battle system. This prevents the player from winning unless the designed variable has reached 10. Of course you can change that to be a different number or event another variable. Up to you.

I am using my memory here so I do not remember if this causes issues with single target skills when all enemies are dead. Be aware that it might cause issues. If it does I can give you another small code to append to this one, but you have to wait until I can use a computer.
 
Last edited:

Zelfore

Villager
Member
Joined
Apr 5, 2019
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Unfortunately no luck, comes back with an error message when testing battle.
Code:
Script 'TESTING' line 18 SyntaxError occured.

unexpected $end, expecting keyword_end
Line 18 being the last 'end' in the script.

Edit: Still getting the same error message without the battle starting, even when WIN_THROUGH_EVENTS is set to false.

I'll wait until you get to a computer to test. I need to be going now as is, so I'll check back later.
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Yes, you are right, I forgot one "end". I edited my post, copy the code again, this time it has the right amount of "end" keywords.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,358
Reaction score
7,671
First Language
German
Primarily Uses
RMMV
In general, there are two ways around the battlemechanic that causes the last troop events to be ignored on the turn where all enemies are dead.

The first way is by the use of events and states alone, no scripting needed. the other way is to use one of tsukihimes scripts that adds new conditions to the troop events, including some that will work despite the all enemy dead (basically tsukihime rewrote the existing battlescript to add those capacities.

I don't know if you can use either alternative - you can search for that script on himeworks.com
the evented solution works as follow:
1) create an "immortal" state that makes a battler immune to the death state.
2) have a troop event apply that state to all enemies on firt battle turn (turn 0)
3) have one troop event for each enemy triggered on HP=0, checking for whatever other functions before removing the immortal state.

the immortal state will prevent the regular all-dead-sequence until after the troop event for that enemy has removed the state, allowing you to enter whatever event command after the battler has been "killed" at HP=0 but before the death-state itself becomes active. And yoiu only allow the death-processing after all your own event functions have been completed.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@Zelfore I edited my post because I thought of a better solution.
 

Zelfore

Villager
Member
Joined
Apr 5, 2019
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
I wrote this script a while back; it may be what you're looking for.
https://forums.rpgmakerweb.com/index.php?threads/manual-defeat-gameover.83645/
The script works perfectly! Had to tweak the events only a little to get it working as intended and hoped.

Many thanks, Heirukichi! For trying to help and writing up some code for my sake.
Thanks, Andar, for the referral to himeworks! I'll definitely use some of the scripts located there.
And special thanks to Rinobi! For providing an awesome and simple script that even a newbie like myself can understand and implement.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Zelfore If this has answered your query to your satisfaction, please Report your post and ask for the thread to be closed.
Thanks.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,222
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top