Lecode Tactical Battle System 0.77.2B

@Amarok
That's a very interesting question, you can learn more about it on @Lecode 's Patreon!
The last message posted by @Lecode on Sep 30 is :

"Hello. Quick update about what's going on.
I recall 2 months ago I was planning to deliver the demo for Chao for testing. However at a point I noticed I had more work to do and things to complete. I do not want to release LeTBS with uncompleted features and WIP flags here and there, as it was for the last two releases. AI behaviors programming is one example of such things that were left uncompleted over the releases. It went out in around 0.4 and it's still not exploited yet.

I'm working very, very eagerly on 0.8 and I want it to be complete as much as possible. The thing is, as 0.8 is a total rework of LeTBS (from the ground up), why not just complete all fundamental features and polish them once and for all?

The demo is being prepared right now for Chao but it'll be available for release only when I will make sure everything is usable and when the documentation will be fully available.

I apologize for all the delays and I know people are really waiting for 0.8. Me too I am. There are many side projects and commissions I want to work on but LeTBS is holding me back. This is, however without any regret because I want it to be very, very good. I won't disclose any release date again because I won't be sure everything will be ready at that time.

So, my next post will likely be about 0.8 release, then what I plan until 1.0, and later I'll make a post about a new project I want to work on. It's not a battle system but a tool that I think would be really handy for creators.

Thanks for your supports so far and hopefully, see you soon."



--------------------------------------------------------------------

I still don't have the demo but I am very eager to test it!

I had some text messages with Lecode and I have some insights of what might be inside the 0.8 version that I'll share with you (Be careful, I have not tested the demo and some adds here might have been discarded, I might misunderstood what @Lecode said (I'm not that smart!) and there could be translation error since we both speak in french and I am roughly translating it in english.) :

5 June :
Asynchronous flow completed
I made a test with LeTBS 0.77B to generate a : "circle(40)" scope and it took 2 minutes and 10 seconds with my good Computer while on @Lecode version it took few seconds.

25 July :
I'm "nearly done" but I am struggling with an incompatibility, it might take some time to solve.

11 August :
I'm still on it, each time I think that I'm done, I realize that there is something better I can do!

20 August:
Today, I worked on Scope flexibility, now in sequence commands you can use : "+ - * /" so you can add scopes, , remove scopes and so on
For example, you can write : "
scope: (circle(2) + square(4)) - line(2)
"
-----------------------------------------------
The great thing with that is that you can for example make :

"
scope: enemies * circle(4)
"

This will generate a scope circle(4) around each enemies on the map!
Lecode also added more flexibility by adding "in" and "with".
Fore example :
"
scope: friends in circle(4)
"
This option will select all your allies in a circle zone of 4
------------------------------------------------
You can also mix all of this :
"
scope: (enemies in circle(4)) * circle(1)
"
-------------------------------------------------
With the "with" operand, you can also make quick conditions on selections :
"
scope: allies with "b.isStateAffected(5)
"
This would select all allies affected by the state ID 5.
--------------------------------------------------
Lecode would like to erase the concept of "neutral entities" and replace it by a "team system"
The user would be able to chose as many team he wants and how AI interact with it.

For example :
You can create a team with only female characters with the tag :
"
teams: girls
"


Then a notetag in enemy tag :
"
attackTeams: girls
"

This tag would mean, the monster with this tag on it would only attack members of the team "girls".
That way, you can create many teams like "supportTeams" and "healTeams" you can also receive many teams in this tag for example :
"
teams: girls, ghosts, ...
"

That way, you would be able to recreate the concept of neutral entities with more flexibility.
-------------------------------------------
I have still some work to check on characters that occupies more than 1 cell.

23 Sept :
This time, I've really made some progress, there is still things I would like to improve!
I'll post something about it around the end of this month (see patreon post).

30 sept (after the patreon post) :
I'm working on AI behaviors.
This project is not really hard, it is just VERY time consuming.

3 october:
When the demo is ready, I'll send it to some people to test it while I'm working on the doc.

---------------------------------------------

And no news from then (9 october) but I really think the next version of LeTBS 0.8 might come soon but since there might be heavy changes, you might need to change some things in your project if you want to adapt, but it might worth the time with all the upgrades incoming!

All we can do now is support him for the hard work, I think he needs it!

Good luck @Lecode !
@Chaosicaa thats awesome to hear! thanks a lot!
Trying to figure out how my counters are broken in 77, and trying to figure out how to fix them, but looks like I may need to upgrade to 77.2b...

This will suck big time.

I wish the code was more... commented, in particular to match the changelog.
In particular: * Fixed a bug where the modifier sequence system from 0.77.1 would prevent "after effects"

I have no idea where in the letbs.js file this fix was made.
(I do not have a 0.77.1 letbs.js file, so I can only compare to 0.77, and boy was there alot of changes between them.)

EDIT: Figured it out.

Updated
TBSSequenceManager.prototype.start
TBSSequenceManager.prototype.startWithData
and
TBSSequenceManager.prototype.isRunning

functions by copying parts of the 77.2b script.
Counters now work, I'm so happy.

Time to see if I can get me some auto-potions.
So the way lecode handles countters explicitly calls the default attack skill. Ie: skill 1

Im gonna see what o can do
Okay so check this out:

https://www.dropbox.com/s/32lvm3xl6ma768i/auto_potions.mp4?dl=0

I completely revamped the Counter Processing:
Basically, as long as the skill has a counter condition, it will evaluate it first.
To use this you MUST use the Custom Counter Condtions like this:
<Custom Counter Condition>
$gameParty.numItems($dataItems[1]) > 0
</Custom Counter Condition>

If the user has multiple Counter skills, then it will randomly choose one.
also the main issue that kept skills from triggering, was the whole this.setCursorCell(subject.getCell());
If you had a healing spell, with scope: circle(0) (such as auto-potion) then it wouldn't work, because the cursor was the enemy.
so I have 3 checks
invalid if the eval is bad
defensive if the defensive counter is in the defensive skill list
offensive if neither of the above.
Defensive/Offensive will also trigger the correct Text popup.

I also need to state that this currently only works with attacks from 1 cell away(directly next to you).
EDIT: Fixed the "Infinite counter Loop" 🙂
Spoiler: code
Code:
BattleManagerTBS.processCounterAttack = function (targets, subject, action) {
    if (!action) return;
    targets.forEach(function (entity) {
        if (entity) {
            var dist = LeUtilities.distanceBetweenCells(subject.getCell(), entity.getCell());
            if (dist <= 1 && Math.random() < action.itemCnt(entity.battler())) {
                //var skill = $dataSkills[entity.battler().attackSkillId()];
                entity.battler().makeCounterSkills();
                if(entity.battler().counterSkills() && entity.battler()._counters<entity.battler().counterTotal())
                {
                    var skills = entity.battler().counterSkills();
                    //Test
                    //skills = [1,1880];
                    //get random skill if user has multiple counter skills
                    var skillId = skills[Math.floor(Math.random()*skills.length)].id;
                   
                   
                    var skill = $dataSkills[skillId];
                    console.log(skill);
                    subject.battler().clearResult();
                    entity.lookAt(subject.getCell());
                    //Check Counter Type
                    if(this.checkCounter(skillId) === "Invalid")
                    {
                       
                    }
                    else if(this.checkCounter(skillId) === "Offensive")
                    {
                        entity.addTextPopup("Offensive Counter");
                        entity.startSequence("counter");
                        this.setCursorCell(subject.getCell());
                        this.forceAction(skill, entity);
                        entity.battler()._counters+=1;
                    }
                    else
                    {
                        entity.addTextPopup("Defensive Counter");
                        entity.startSequence("counter");
                        this.setCursorCell(entity.getCell());
                        this.forceAction(skill, entity);
                        entity.battler()._counters+=1;
                    }
                }//Won't do anything if user has no Counter Skills
               
               
            }
        }
    }.bind(this));
};
   
BattleManagerTBS.checkCounter = function (skillId) {
    var defensiveSkills = [1880];
    var n = defensiveSkills.indexOf(skillId);
    var eva = $dataSkills[skillId].counterConditionEval;
    if(eva) 
    { 
    // If the skill has an eval, this will make sure the skill is valid.
    // Example: If the skill is "Auto-Potion" it will make sure the player has enough potions.
    // To give enemies Auto-Potion, make sure to create a duplicate skill without the eval.
        if(!eval(eva)){return "Invalid";}
    }
    if (n>=0)
    {
        return "Defensive";
    }
    else
        return "Offensive";
   
    return "Offensive";
};
When I go into a tactical battle, I get this error? Anyone know what it is and how to resolve it?
When I go into a tactical battle, I get this error? Anyone know what it is and how to resolve it?
Could be many things. can you provide the full stack trace?
My counter system is essentially done (189 lines of code including some line breaks).

it is so intensive, holy cow.

Basically this:

calls yanfly's counter control to set up all counters

if entity is an actor, then it gets user's default counter
otherwise the "default" is set to 1

it validates distance, and custom conditions

if condition exists, it validates, if it comes up false, it's a bad skill

2 types of counter

Offensive
Defensive
These not only dictate the popup but set the target. Defensive will target the entity that will counter (so you can heal yourself) Offensive will target the person who hit you.

theres 2 different arrays used for returning the "best skills to use".

bestskills
goodskills
both are validated by distance

bestskills are an array of skills that have a counter distance EQUAL to the distance between the entity that is doing the countering and the entity that previously attacked them. OR if the "Counter Distance" is 0 (set your defensive skills to this)

good skills have a counter distance Greater than or Equal to the distance between both entities, or in other words, the distance between both entities is in range of this counter skills.

If bestskills has a length of 1 or more, this will be the final skill array,
otherwise it will return goodskills if that has anything

if no skills are valid, then it returns empty array [] and no counter takes place.


After it gets the list of "valid" skills, it randomly selects one, and pulls a function called "CheckCounter" and sends in the skill's ID
Which utilizes an array of preset skill ids
such as
defensiveskills = [1880,47]

first it checks the CustomCounterCondition of the skill and if it evaluates to false, then it returns "Invalid"
if the skill you sent in is in this array, it returns from the function with "Defensive" which is used above for the popup/targeting
and if it neither returns "Invalid" nor "Defensive" it returns "Offensive"

Using the Kadokawa plugin for LastUsedItem.js, you can set 2 variables,
one stores the item id, and one stores the item type
so if someone used the skill dagger with id 405 to counter the skill "Greatsword" which is skill 1502, you would set the following counter conditon:

if the skilltype is 1(skill) and the skillid = 1502 this e; will evaluate to true, and this skill will fire.
otherwise, it won't be used.

<Custom Counter Condition>
var e = true;
if($gameVariables.value(103)==1 && $gameVariables.value(102)==1502)
{e = true;}
else{e = false;}

e;
</Custom Counter Condition>

Using this format, I will be setting up several states for magical counters, elemental counters, etc.

====
If I remember anything else on how it works, I'll update THIS post
====

EDIT: If anyone is super curious about my own personal changelog for 0.77 (I'm a few versions behind 🙂 ) then here's one version of it.

Spoiler: 0.77PHX Changelog
Code:
# - 0.77.PHX
#       * ===========
#       * Positioning
#       * ===========
#       * Added support for variable-based actor cells
#       * Added support for switch-based actor cells
#       * Added support for leader-based actor cells (Party Leader auto-positioning
#       * Added support for neutral positioning cells that can be used by enemies or actors
#       * Added custom color for neutral positioning
#        * Added logic to determine of all player entities are placed in the pre-positioning phase.
#        * If this is the case, the battle is immediately started, eliminating the need for the player
#          to "Confirm" they are ready. Eliminates a bug where you could "Cancel" on a pre-placed unit.
#          Causing the game to crash.
#       * ===========
#       * Scope Select
#       * ===========
#       * Added support for Scope_Select if Actor is afflicted with a specific State
#       * Added support for Scope_Select if Enemy Unit is afflicted with a specific State
#       * Added support for Scope_Select if A Team Member is afflicted with a specific State
#       * Added support for Scope_Select if An Enemy Team Member (enemies if player, player if enemies0
#       * is afflicted with a specific State
#       * Added support for Scope_Select if Actor Knows a specific Skill
#       * Added support for Scope_Select if Enemy Knows a specific Skill
#       * ===========
#       * Turn Order
#       * ===========
#        * Added support for "Redrawing" the Turn Order
#        * If enabled, the turn order will be determined at the end of every turn.
#        * This allows for skills that raise a unit's agility to have a better advantage
#          The next turn.
#
#       * See PHX_LeUtility.js for turn types
#       * Added support for Initiative Battle System:
#       ** Allows the configuring of
#       *** Bonus Initiative for non-movement / remaining move points
#       *** Non-Action - Not attacking/using skills/items/ect.
#       *** Default Initiative cost - Initiative cost per turn
#       * ===========
#       * Counter System
#       * ===========
#       * Repaired Counter System for 0.77
#       * Added support for Yanfly Counter Control
#       * Added support for Counter Conditions, Counter Distance
#       * Counter is selected by determining "Best Counters"
#
#       * First, the skill's Counter Conditions are checked.
#       ** If no counter condition is set, it is evaluated as true -
#       ** otherwise it evaluates the counter condition. If false, it
#          it does not add the skill to any array, if true, proceed to next step.           
#       * Second, it checks Counter distance (If unavailable, assumes "0") of all Counter Skills
#         for the "countering" entity.
#       * If Counter Distance = Distance between attacker and the entity that counters
#         or the Counter Distance = 0, then that counter skill is added to the "Best" counters
#       * If Counter Distance is greater than or equal to the distance between the two entities,
#         then it is considered a "good" or otherwise "valid" counter.
#        * If the "Best" counters has a length > 0 then it is returned, otherwise, it checks if
#         the "Good" counters array has a length of > 0, if so, that one is returned.
#        * If neither array has elements, it returns an empty array, and the character does NOT counter.
#
#        * After the Counter SKills array is determined, it randomly selects one.
#       * This counter is then checked to see what "Type" of counter it is.
#       * Using an array of "Defensive Counters" (Will later be updated to use a notetag) it checks if the skill
#         selected is a Defensive Counter and returns such, otherwise it returns "Offensive".
#       ** CheckCounter is also used by getBestCounter(), which uses it to determine if the counter is Invalid
#       ** Here, it is simply used to determine if it is defensive or offensive.
#
#        * If the skill is defensive, the cursor is set to the countering entity, and the action is performed.
#        ** A popup will display with "Defensive Counter" and "Skill Name"
#        * If the skill is offensive, the cursor is set to the entity to BE countered, and the action is performed.
#        ** A popup will display with "Offensive Counter" and "Skill Name"
#       *** Will add support later for other counter types such as:
#        **** Support Counter
#        **** Magic Counter
#        **** Physical Counter
#        **** Elemental Counters
#        ***** Fire,Ice,Thunder,Water,Wind,Earth,Light,Dark
#
#        ****TO-DO****
#        * Check if counters affect allies.
#        * Add notetag to prevent ally counters
#        * Add notetag to allow ally counters
#        * Add notetag for specialiszed counters
#        ** Nearest Enemy
#        ** Nearest Ally
#        ** ETC
Could be many things. can you provide the full stack trace?
Full stack trace?
Full stack trace?
Open your game

Press F8 theres a console output with detailed errors

Without that we have no way of knowing what is causing that.

Likely its a missing quote, comma or semicolon in your letbsconfig file though.
This is what I get

TypeError: Cannot read property '1' of undefined
at Game_System.setTransitionR (/C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/MOG_BattleTransitions.js:106)
at Scene_Map.setTRType (/C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/MOG_BattleTransitions.js:648)
at Scene_Map.startEncounterEffect (/C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/MOG_BattleTransitions.js:634)
at Scene_Map.launchBattle (rpg_scenes.js:835)
at Scene_Map.stop (rpg_scenes.js:628)
at Function.SceneManager.goto (rpg_managers.js:2074)
at Function.SceneManager.push (rpg_managers.js:2080)
at Game_Interpreter.command301 (rpg_objects.js:10138)
at Game_Interpreter.executeCommand (rpg_objects.js:8930)
at Game_Interpreter.update (rpg_objects.js:8838)
This is what I get

TypeError: Cannot read property '1' of undefined
at Game_System.setTransitionR (/C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/MOG_BattleTransitions.js:106)
at Scene_Map.setTRType (/C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/MOG_BattleTransitions.js:648)
at Scene_Map.startEncounterEffect (/C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/MOG_BattleTransitions.js:634)
at Scene_Map.launchBattle (rpg_scenes.js:835)
at Scene_Map.stop (rpg_scenes.js:628)
at Function.SceneManager.goto (rpg_managers.js:2074)
at Function.SceneManager.push (rpg_managers.js:2080)
at Game_Interpreter.command301 (rpg_objects.js:10138)
at Game_Interpreter.executeCommand (rpg_objects.js:8930)
at Game_Interpreter.update (rpg_objects.js:8838)
Based on that,

It looks like there's an incompatibility with Mog's Battle transitions.
Disable that script then try again.

If you still get the error, it's something else.

Can you also send your full plugin order from the plugin manager?
I have the tbs plugins at the top. I read somewhere that there are issues with Yanfly's plugins. Could that be the case? I did another f8 error report and it gave problems with YEP_BattleEngineCore, YEP_PartySystem and YEP_X_ActorPartySwitch. All 3 of those plugins are vital to my next project. Is it possible that LETBS isn't compatibile with those?
I have the tbs plugins at the top. I read somewhere that there are issues with Yanfly's plugins. Could that be the case? I did another f8 error report and it gave problems with YEP_BattleEngineCore, YEP_PartySystem and YEP_X_ActorPartySwitch. All 3 of those plugins are vital to my next project. Is it possible that LETBS isn't compatibile with those?

I use partysystem and battle engine core so that's incorrect. which points me towards a possible order issue.
I also have them both ABOVE the Letbs scripts,
core engine, battle engine should definitely be above

If you are okay with it, you can send me a zipped copy of your project, and when I have time (probably tomorrow, its 8pm now) then I don't mind having a look to see if I can get your stuff working.

For now, I suggest putting your LETBS scripts at the bottom and see if that solves it, if not, I'll be happy to take a look.
I use partysystem and battle engine core so that's incorrect. which points me towards a possible order issue.
I also have them both ABOVE the Letbs scripts,
core engine, battle engine should definitely be above

If you are okay with it, you can send me a zipped copy of your project, and when I have time (probably tomorrow, its 8pm now) then I don't mind having a look to see if I can get your stuff working.

For now, I suggest putting your LETBS scripts at the bottom and see if that solves it, if not, I'll be happy to take a look.
I'll try that. Also, do you happen to have the help docs for LeTBS_WinConditions? If you do have the help doc, could you send it to me? I downloaded the tbs from the op (I've had to get a new comp recently) and winrar says the archive is either in unknown format or damaged
I'll try that. Also, do you happen to have the help docs for LeTBS_WinConditions? If you do have the help doc, could you send it to me? I downloaded the tbs from the op (I've had to get a new comp recently) and winrar says the archive is either in unknown format or damaged


Download the archive i posted on the previous page

Thats a working demo
Now these issues appear. I noticed that they all have different numbers. Could you take a look at the error report and let me know exactly what the errors are please?

TypeError: Cannot read property 'list' of undefined
at Game_Event.list (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/rpg_objects.js:8470:23)
at Function.<anonymous> (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/LeTBS.js:1768:39)
at Array.forEach (native)
at Function.BattleManagerTBS.prepareEntityFlags (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/LeTBS.js:1766:23)
at Function.BattleManagerTBS.prepare (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/LeTBS.js:1634:10)
at Function.BattleManagerTBS.startBattle (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/LeTBS.js:1624:10)
at Scene_Battle.start (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/LeTBS.js:957:26)
at Scene_Battle.start (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/plugins/LeTBS_WinConditions.js:116:44)
at Function.SceneManager.updateScene (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/rpg_managers.js:2019:25)
at Function.SceneManager.updateMain (file:///C:/Users/REDACTED/Google%20Drive/REDACTED/REDACTED/js/rpg_managers.js:1983:18)
this is awesome
Yeah, can't wait for LeTBS 0.8 !!!
Hello,

I noticed that some people were trying to change sprites mid-battle.

I managed to accomplish this, at least for actors, by having an extra state that gets added after the transformation skill effect.

The version I am using is 0.77.2B, and the project is based on the demo.

Spoiler: Content
The plugins required include yanfly's state core, skill core, and any dependancies. I followed the instructions in the documentation to determine the order of plugins.

First I made a state to represent the transformation, and I included the following note tags:
Code:
<Custom Apply Effect>
user._prevCharName = user._prevCharName || user._characterName;
user._prevCharIndex = user._prevCharIndex || user._characterIndex;
user.setCharacterImage("Nature9", 1);
$gamePlayer.refresh()
</Custom Apply Effect>

<Custom Remove Effect>
var charName = user._prevCharName;
var charIndex = user._prevCharIndex;
user.setCharacterImage(charName, charIndex);
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
$gamePlayer.refresh()
</Custom Remove Effect>

The code is based partly on yanfly's actor transformation tip, and partly on a post previous from Pharonix.

This state actually works fine outside of battle if you want your skill to work there. The problem is, the $gamePlayer.refresh() doesn't seem to work in the battle scene for LeTBS. That said, adding a state to your battler seems to trigger a refresh of the sprite.

Because of this, adding this note tag to the skill allows the sprite to update to the new character image:

Code:
<After Eval>
user.addState(329);
</After Eval>

The state used is just an empty state that wears off at the end of turn, or battle.

I hope someone finds this helpful.

Is it possible to get something like this to work on Actors that are using Battler Sprite instead of only working on Actors with the "use_chara" tag or no?

Original thread: https://forums.rpgmakerweb.com/threads/lecode-tactical-battle-system-0-77-2b.71572/