Chain Battles

Imagine the following situation: your brave heroes sneak into the enemy base and because they’re The Good Guys they will just charge blindly on in a Ranger/Hamster team fashion. It doesn’t matter if they kill all the poor mooks blocking their path – Mook Chivalry is in action, and all those henchmen will wait for you to come within 1 tile radius of them before attacking you (or if you are using random encounters, they will simply wait for the designated number of steps).

Well, screw the rules I have the Chain Battles script. With this, your mook will call reinforcements if you don’t do your carnage quickly and an endless wave of battles will overwhelm the heroes. If you – the developer – so desires.
However this is just one use of the script. You can very well setup special battles which will always result in a chain, or a strange life form spewing seeds during battle, seeds which develop enough to attack you when you think you’ve won. I don’t know, you certainly can think of something, can you?

Something to note, the battle results are delayed until the chain is over. Which means, if you flee during the second battle for instance, you won’t gain the experience and gold from the first either. Life is harsh, my friend, life is harsh. However, for each chain completed, the total (for both exp and gold) gained in the end – the sum of the rewards for all battles composing the chain – is raised by 25% per battle.



You will need to reserve two variables for the Chain Battles use. Then allocate them within the script body.
module KRX


CHAIN_TROOP represents the troop which will be fought in the chain and CHAIN_CHANCE the chance for the chain to happen at all.
Now, you need to find a situation where you want to alter those variables value. In a skill? In a battle event? Your call.

Let’s use a simple example with automatic chains (chains that always happen, no matter what).

Chain Battles Screen 1

The Mage (enemy 3) appears just after the slime. Every time.

Chain Battle Screen 2

And here, the Minotaur spawns after the Mage. Every time too.

You will notice that the variable CHAIN_CHANCE hasn’t been touched again. It’s because it is never reseted until you do it manually. CHAIN_TROOP on the other hand, is automatically set to 0 if you lose or escape a chain battle. But not if you win, which means you actually need to set it yourself to 0 in order to end the chain. There is actually an advantage to this: in case you want a chain to be endless unless certain circumstances are met, you won’t have to set it again and again.

Compatibility notes

Compatible with Ace Battle Engine and with my Skill Fusion script. Put it below Yanfly’s script of course. Other than that, there are a lot of aliases of the BattleManager methods.

About Kread-EX

I code. And try to make games.

Posted on 11/12/2011, in RGSS3, RPG Maker VX Ace and tagged , . Bookmark the permalink. 35 Comments.

  1. Iamwatchingyou e – e *staaaaaaaaaaaaaaaaaaare*

  2. Do you intend to always write scripts that are compatible with YEA? 🙂 That would be great.

    • I’ll try to. I know that a lot of people will use Yanfly’s scripts, so making them compatible from the start saves me headaches later due to heaps of requests asking for such compatibility.

      • Yeah, I think so, too. 🙂 Well, in this case, you just gained another bookmarker. 🙂

  3. infamous bon bon

    Yeah I tend to use Yanfly Scripts as a base (they are always organized and tend to customizable enough). All of these scripts are great Kread-EX. This one in particular has many uses in my opinion.

  4. Oh, do you take requests, by the way? Because if you did, maybe you could write a script for having shadows under characters and NPCs? 🙂 It just looks much better in my opinion.

  5. Another awesome script :o. Nice work Kread 😀

  6. ok im having issues getting this to work, i added a chain from slime to sand snake to be 100 but once the slime battle ended nothing happened

  7. Have you configured the variable allocation correctly? Have you set the variables values in an event that actually triggers?

  8. If I wish not to have the 25% bonus for consecutive battles, I simply delete that one line? $game_temp.chain_bonus += 0.25

  9. nekomimibaka

    Hello Kread-EX, I was doing some testing with this script and I’ve had it crash the game.exe during the transition between troops at least 50% of the time. Have you encountered this or anyone else using this script have this happen?

    • I have never heard of this before O_o

      Crash, literally? If you’re using Windows XP it’s most likely a PC issue.

      With Vista or 7, well, if you can, try to upload a demo with the issue, because a complete crash is not the kind of thing I can pinpoint with just a bit of info.

  10. nekomimibaka

    I’m using XP…if that makes it obviously a PC issue is there a reason why that would be? ^_^;; I tried commenting out the screen flash during the transition, but that wasn’t it. It crashes right before it would draw the window elements in the battle scene, and after the battler graphic for the new troop, if that helps.

    The crash generates a text file called “xxxx_appcompat.txt” …so I’m not doubting that you’re right about XP (for whatever reason), just not sure what about this script would cause such an obvious crash. I haven’t had any other crashes while playtesting (other than my own stupid scripting/notetag hilarities). It bothers me that it’s random. But it definitely happens a lot. I’m testing a sequence of 4 battles with 100% to chain, and out of like 10 times, I’ve never gotten to finish the sequence, and the furthest I’ve gotten was it crashing at the 4th chain. Well, not sure what to do if it’s really “just because I use XP”. I guess I won’t be able to use this script. Ah well. It is pretty neat though!

    • I honestly don’t know the exact reason. I’ve got several crashes with Melody when I was a XP user, there are people who bought commercial games with RMVX and couldn’t play them without crashes if they were on a Win XP…

      If you want, send me a demo with the issue and I’ll try to see, but I’m on Win 7 and I somehow doubt I will experience it.

  11. I’ve been messing with this trying to adjust it so that the bonus of XP fluctuates depending on a $game_variable, or even some other variable factor that I can control, but it doesn’t seem to work quite as intended for one reason or another.

    Any way you can officially implement something other than just the default 25% bonus per chain battle?

  12. WCouillard

    Can you tell me how I can reset the turn counter to 0 when a new troop arrives? I am using this script to create a battle arena of sorts, and have events that run on Turn No. 0 for each “round” but the events never activate as the turn order does not reset to zero.

  13. WCouillard

    Nevermind on that problem, it was on my end.

    Suggestion: add-on the ability to disable item drops from enemies when turning on a variable. When I finished an eight-round battle, I was still getting drops from enemies, but it was multiplying them. I gained 99 of one of the drops from the first enemy in the first troop I battled.

  14. i dont quite understand where you get the variable operation from i cant find that command when i try to edit the troop battle events

    • This screenshot is pretty old and was taken with the JP trial version and a fan translation.
      In the English version, it’s Control Variables.

  15. I’m having the same issues with PClaydon; I’ve tried checking every control variables used but it doesn’t seemed to work for me.

    It’ll only take long if I mentioned the scripts I’ve used. So I’ve left a demo for you to check out what’s wrong with my control variables.

  16. Would it be possible to use random variable operations for the troop chosen in the next slot and then terminate the chain sometime after a predetermined amount of fights?

    • That’s a good idea. I’ll work on it when I have a bit more time.

      • Awesome sauce! My interest in this is because I’m looking do to a battle arena type deal with random enemies in the chain. I’ve been looking for something like this instead of making a large set of conditional branches to make things feel very random.
        Thanks a bunch for the quick reply too 😀

  17. WCouillard

    This script doesn’t seem to be compatible with Victor Sant’s Active Time Battle. Any change of a compatibility patch? I REALLY want to utilize this, but I can’t give up the other VE script.

    • WCouillard

      Has anyone gotten this to work with VE Active Time Battle? I still can’t figure it out.

  18. Harley Obermiller

    I am running into an issue. I am getting a Window_Selection Line 61 error, where it says it is divided by 0. I Got the script to work, but every time i defeat an enemy, it pulls up this error. Can you help with this?

  1. Pingback: YEA – Call Random Battle « Yanfly Channel

  2. Pingback: Battle Manager – Multiple battle systems | (姫) Hime Works

  3. Pingback: Battle Manager – Multiple battle systems | (姫) Hime Works

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: