LeTBS get active actor and enemy ID at turn start

rpgdude

Warper
Member
Joined
Aug 10, 2018
Messages
1
Reaction score
0
First Language
German
Primarily Uses
RMMV
Dear rpgmakerweb-community,

I'm using Lecode's LeTBS for my project, but I run into a big issue.
For my whole project to function I need to get the current active actor id and
when its an enemy turn the current active enemy id to be put into a variable at the start of a turn.
I'm no programmer but I think this is the code which Lecode uses to determinate who's turn it is.

BattleManagerTBS.determineTurnOrder = function () {
if (Lecode.S_TBS.turnOrderFairDistribution)
this.determineTurnOrderFair();
else
this.determineTurnOrderSimple();
};

BattleManagerTBS.determineTurnOrderSimple = function () {
var array = [];
this._turnOrder = [];
this._activeIndex = 0;

this.allPlayableEntities().forEach(function (entity) {
array.push(entity);
});
array = array.sort(function (a, b) {
return b._battler.agi - a._battler.agi;
});

this._turnOrder = array;
this._turnOrderVisual.set(this._turnOrder);
};

BattleManagerTBS.activeEntity = function () {
return this._turnOrder[this._activeIndex];
};

BattleManagerTBS.activeBattler = function () {
return this.activeEntity()._battler;
};

BattleManagerTBS.startTurn = function () {
this._actionScope = {};
this.getLayer("scopes").clear();
this.getLayer("scopes").clearSelection();
this._subPhase = "";
var entity = this.activeEntity();
entity.onTurnStart();

var battler = this.activeBattler();
this.newAction(battler, true);
LeUtilities.getScene().showStatusWindow(entity, true);

var cell = entity.getCell();
this.setCursorCell(cell);
this.cursor().show();

if (entity.playableByAI()) {
this.startAiTurn(entity);
}

this.executeEventsWhen("turn_start");
if (this.activeBattler().isActor()) {
this.executeEventsWhen("actor_turn_start");
} else {
this.executeEventsWhen("enemy_turn_start");
}
this.executeEntityEventsWhen("entity_turn_start", entity);
};

By using a script call like this, the variable always returns [object Object]:

var currentbattler = BattleManagerTBS.activeBattler();
$gameVariables.setValue(1, currentbattler)

Also, when I converted it into an integer it's always zero.

The second thing I need determinate is whether its an actor's or an enemy's turn.
I guess the following code can do that but I don't know how to use it:

if (this.activeBattler().isActor()) {
this.executeEventsWhen("actor_turn_start");
} else {
this.executeEventsWhen("enemy_turn_start");

I hope someone can help me.
 
Last edited:

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

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
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'??

Forum statistics

Threads
105,859
Messages
1,017,037
Members
137,566
Latest member
Fl0shVS
Top