MZ Map based Card Battle System

I've been stuck thinking about the fight system in my project Middlemoon.
The RPG Maker MZ combat system really didn't fit well in a dark modern adventure that winks to Chronicles Of Darkness.

At first I thought about using a plugin to run a Parallel Event through the Battle while storing the Variables of Attackers, Target, Skill and so on, to be able to create completely new skills (using the D10 dice system).

But when it was the time to code a fight I was left with a MEH feeling.

So I decided to up my game, I decided to create my most complex plugin so far (probably laughable by hardcore programmer but everyone has his own skillset ^^')
A plugin that once called on the map would overlay a deck-building based fighting style, moving events on the map and setting bonduaries to the Battle Area.

It's a ton of work for someone used to do Plugins that could be coded in a week max.
I'm trying to keep everything in an ordered fashion but each function, needs a function that calls a function that server 3 more other functions...

Still I'm confident, it won't be fast, it won't be easy, but I can do it!

Basic goals set:
  • A functional deck building based combat system
  • A JSON file in data to easily create all the possible cards
  • As usual, an high costumization rate
  • Combo work with my other plugin "RPG Style Stats and Skill", that's for me mostly as I need a Chronicle Of Darkness vibe to the fight
  • Decent battle AI behaviour
Ideal but not critical:
  • Ease of use (right now setting up a battle isn't really straightforward, especially if there are obstacles on the map)
  • Graphic effects (cards dealing, card use, etc..)

For now I just create part of the backbone, the plugin successfully load from the parameters of the user who is in the battle and sort them in initiative order (for now only in combo mode with the other plugin) as well as sets the AP, HP, search the player deck, shuffles it and deals the cards. (except for the initiative order all Allied and Enemies actions aren't built yet)

Now it comes the difficult part, we have our deck, we have our hand of cards, it's time to chose the card and do some action!

Screenshot 2023-08-06 17.54.32.png



Small steps, but steps forward nonetheless. Now the cycle of draw card, show card, select card, choose action and back via cancel is done!

It has been a while and it seem I've gone silent

But I'm not!

This plugin is honestly huge compared to the others I made and it will take a lot of time, around every corner there is a thing to fix or several new function that I need to add.

At least I'm steadly making progress! Here is a video of the ongoing progress:



Please don't mind the lack of graphic/SE, I'm focusing on getting the flow of functions working. I'll refine the looks when it's functioning.

The action/attack selector is almost done, at least the most compicated function, the translator that uses the code in the card, takes the actors parameters and decide hit and damage results.



I hope to give more news soon!
AI Logic is painfuuuuuullll

I've reached the most difficult part of the plugin, I've tried to postpone it as longest as possible T_T
It's great to have a my player select cards and use them but it's pretty useless against inactive opponents and without the help of your allies.

So here we are, we need to introduce the artificial intelligence logics in the opponents and allies.
It has been 3 days I'm working on it, it's not "difficult" but it's incredibly long and nested.

How is the battle situation?
Is your team winning? Or your ass is getting whooped?
Based on the behaviour preset, the general situation, your health and your card, what's the order you prefer to play them?
But do you have the Action Points to do so? MP? TP?
You want to attack? Nice!
Are you in range? No? Can you move with your current card or with another card in range?
Great! You choose an AOE card?
Ohhh... but your allies are in the AOE
Can you avoid them?

And so on! Every step has a lot of checks... but I hope to come to an end sooner or later!
After a LOT of coding the first AI steps are here!

In this video our allied Lily does the following:
  • Decide what type of card she wants, she prefer range
  • There is no range card in her hand, there is no need to heal and she doesn't have buff cards
  • Looks like she need to use an aggro card!
  • All the aggro card in her hand don't have enough range to hit an enemy
  • She checks if she has the AP to use a card to move closer and then a card to attack
  • She decide for the card with move moment and less aggro as "support" card then for the card with most aggro as "attack" card
  • And she goes!

After this I'll have to fix the AP management and loop the actions to make a complete turn for the AI battlers but this is the easiest part of the work

The next complex part will be to complete the action card resolver function, for now it handles only single target cards, I need to make it work for every type of damage (AOE, Whole field, tile)

Then there will be a LOT of debug, as the code is way more complex than what is shown in the video, it handles friendly fire, decisions for getting closer or pulling away from enemies, etc..

Finally we have a full turn played out!



There is still a lot to do, like making a full battle run, adding buff and debuff, upgrading the animations, improving the AI and so on but after today I feel that the hardest part of the plugin is behind me.

And here is a battle!

Finally an update!

It took me a while but when you lose a single typo that changes a crucial variable value in a 15.000+ lines code is not easy to find it... and absolutely the new game released that we will call Baldurs G. for privacy has NOOOTTTTHHIINNG to do with this delay.

Anyway, on a serious note, this is an important milestone for the plugin!
A battle finished, from the start to the end!

There are still A LOT of things to do, like adding some AI logic (for example in this battle the Black Knight switched from a wounded Lily to a more healty Reid and it's not ideal. Truth is I put the focus on the player for the AI attacks but a "Who will go down first" logic is in order), polishing the animations, let the plugin transfer the HP, MP and TP remaining to the editor once the battle is over... But still, we are there! This proves I'm on the right path!

Wow, I realised I didn't wrote in this thread from.. September???

Actually the work went on for quite a while but then I realized the fundations of this plugin were too "old". I grow a lot in the plugin making and I started this ambitious project too soon.

So I'm developing a new version now and here is the latest update!



I admit, I would have loved to deliver this update way sooner but the work behind this rework was immense. What was a transfer of old functions on a new improved fundation is becoming an all-new plugin.

This took a toll on the development time but the functionalities are more powerful and flexible.

Now the AI part will pose a challenge on the renewed AI mechanism BUT most of the player function are usable by AI. Animations, card usage, deck management, statuses, buffs, draw rules and many more are not to be redesigned for the AI part, those will work as they are!



But let's take a deeper look to what the video doesn't show, shall we?

  • New Card Graphic Management: Now the cards will be show as a (up to) 5 cards fan, by scrolling the fan you will see all the cards in the hand. The Plugin auto-resize the cards so this is something the dev won't need to worry about.
  • Infographics windows: In the old plugin we had a small windows showing the actual battler stats, in the new plugin we have bigger windows showing the player controlled character stats and (once selected) a 1:1 sized picture of the card. Both can be hidden and shown using keyboard or controller inputs! For Character Stats we can use keyboard Q or Page Up, or controller LB. For the 1:1 card we can use keyboard W or Page Down, or controller RB.
  • One card, Unlimited Effects: Another part that took quite some time is the new Action side of the cards. While there is only one "main" effect, the card can have as many extra effects as the developer wants. Those effects includes extra damage, extra heal, status apply, buff, debuff or revive.
  • More movements type: In the old verson movement was movement. If the tile was in range you could move there, end of the story. That posed some problems for reachable tiles behind a block (like a wall). Now the new movement system is golden compared to the old, it allows for normal movements, jump movements, fly movements and teleports! But that's not the only improvement to the movement system!
  • BETTER pathfinding: With this version of the plugin I decided to use a reliable pathfinding to avoid problems with barriers and obstacles. I was going with RPG Maker native pathfinding and... oh my gosh, it's horrible!! And I don't know why honestly, making a decent pathfinding on a 2D map is not much of an hassle. That's why I ditched RMMZ pathfinding and included a simple dijkstra pathfinding algorithm that creates TWO paths, a safe route and a dangerous route (includes damaging tiles). If it can reach destination with the given steps and the safe route it will choose that, if not it will choose the dangerous route.
  • Status: Sleep, Confusion, Poison, whatever you want to create you can! The status can alter parameters, add buff, disable turns, reverse enemies, add cards, force random actions, plus you can set how it goes away, after X steps, turns, damages, when you land and hit or get damaged!
  • Buffs: Buffs now are easily tracked, can modifiy about any configurable parameter or even battle cards, they also affect indrectly the formulas of damage, resistances, etc..
  • Elements: By default all damage dealt are "Default" but cards can now deal different Elemental damage, even separated (40% normal damage, 30% fire, 30% ice? No problem)
  • Resistance and Vulnerabilities: Battlers can have different resistances / vulnerabilities to elements or status. This values can be altered by buffs or even equipment.
  • Equipment tags for Actors: Actors characters can flag a "Read Equipment" option. With this option enabled you can tag your RMMZ items to add/remove resistances and cards.
Work for this project is progressing!

I know I'm not writing a lot lately but that's because I'm head down working on this plugin and I can see the end of it now!

  • In those days I ran several battles and ironed out all the bugs I found, being a long and complex work this took me a lot of time but now there are no critical failures in the code, the AI seem to be working ok but I'll keep stress testing it to see if it acts up
  • I removed the barenaked floating text for damage, heal and other related battle mini informations and replaced it with a copycat enhanced version of original RPG Maker battle damage popups
  • I extended the animations for the characters to 1 standard more (being healed) and 10 blank spaces for the dev to use
  • I made the whole text translable with the WinterDream auto-language detector
Now I've some tasks ahead to complete but they should be low - mid time consuming:

  • Allow battlers to move (but not stop) on a dead body
  • Refine the card selection animation to make it more clear
  • See if I can improve the health bars, now they are rather dull
  • Add the rules for close combat ranged fighting
  • Add the "Step Back" AI logic if above rule is active and they want to range attack while near an enemy
  • Change the cards action property to allow the devs to decide if they want to play multiple animations on multiple targets or just one
  • Add two more effects to status: Continuous Damage, Continuous Heal
  • Add special triggers to End Battle Controls (the series of check and switches / variables changes once the fight is over)
  • Add more options to the language translator / create a save-state for languages options choices
  • Create more AI cards display animations
  • Create the "Flee from battle" mechanism
  • Add infographics about the AI battler
  • Force AI actions when they have a possible victory move in their hands
  • Add "Flee from battle" AI logic
  • Add status incos to info and customizable gauges
  • Make the "hide player info" and "hide card" buttons moddable
As you can see, still a lot of work but the list isn't infinite!

Once it will be done expect a teaser with some different fights!

Then I'll take a small break to do a couple of updates on the other plugins before going into the last part of this plugin: The in-Game Deck Management

Original thread: https://forums.rpgmakerweb.com/threads/map-based-card-battle-system.160117/