@Danielcross Fixed the Confusion (for enemies. For confused Allies, it might not work right. But for enemies, he'll attack the enemy until all his buddies are dead (or confusion wears off, but here its a passive state).
https://www.dropbox.com/s/4onvlchc63l2g7n/charmed.mp4?dl=0
spent about 3 hours today fixing this.
Lecode's definition of ally and enemy are solid:
Ally = Player Units
Enemy = Enemies.
The problem with this, is it breaks a ton of real-world logic.
If anyone wants to do this: TAKE A BACKUP YO.
and let me know if something's broken, most likely I forgot about an altered function 🙁
https://www.dropbox.com/s/4onvlchc63l2g7n/charmed.mp4?dl=0
spent about 3 hours today fixing this.
Lecode's definition of ally and enemy are solid:
Ally = Player Units
Enemy = Enemies.
The problem with this, is it breaks a ton of real-world logic.
If anyone wants to do this: TAKE A BACKUP YO.
and let me know if something's broken, most likely I forgot about an altered function 🙁
TBSAiManager is Ally:
basically I rewrote this in a way that...
If you are an actor, and the target is an ally, AND you are not inflicted with confusion lv3 (attack ally), then you are an ally
alternatively, if you are an enemy, and the target is an enemy and you ARE inflicted with LV3 confusion, then you count as ally.
TBSAiManager.prototype.isAlly = function (entity) {
aEntity = BattleManagerTBS.activeEntity();
if (entity.isSummon()) return entity._summonData.caster.battler().isActor() === this._battler.isActor();
return (this._battler.isActor() === entity.battler().isActor() && aEntity.battler().confusionLevel() != 3) || (aEntity.battler().isEnemy() && aEntity.battler().confusionLevel === 3);
}
Next is a reworking of my earlier getEnemiesOf function:
This was reworked to take into consideration an ally or enemy unit that is inflicted with confuions BUT is the last member of their team
alive.
It will then treat the character as if they do not have confusion (they will begin to attack the real enemy now).
I think lastly these ones:
applyParamToScope needs to be edited - mainly regarding exclude_allies and exclude_enemies from scope:
originally these would just pull the respective pools, but we want the true allies/enemies
if (param.exclude_allies) {
var user = param.user;
var party = TBSAiManager.getAlliesOf(user, true);//user.battler().isEnemy() ? this.enemyEntities() : this.allyEntities();
cells = cells.filter(function (cell) {
return !party.some(function (e) {
return cell.isSame(e.getCell());
});
});
}
if (param.exclude_enemies) {
var user = param.user;
var party = TBSAiManager.getEnemiesOf(user, true); //user.battler().isActor() ? this.enemyEntities() : this.allyEntities();
cells = cells.filter(function (cell) {
return !party.some(function (e) {
return cell.isSame(e.getCell());
});
});
}
Under: TBSSequenceManager.prototype.readTargets
var aoeEnemyTargets = aoeTargets.filter(function (entity) {
var aEnt = BattleManagerTBS.activeEntity();
var isLast = BattleManagerTBS.enemyEntities().length>1;
return this.isEnemy(entity.battler()) || (aEnt.battler().isEnemy && aEnt.battler().confusionLevel === 3 && !isLast);
}.bind(this));
basically I rewrote this in a way that...
If you are an actor, and the target is an ally, AND you are not inflicted with confusion lv3 (attack ally), then you are an ally
alternatively, if you are an enemy, and the target is an enemy and you ARE inflicted with LV3 confusion, then you count as ally.
TBSAiManager.prototype.isAlly = function (entity) {
aEntity = BattleManagerTBS.activeEntity();
if (entity.isSummon()) return entity._summonData.caster.battler().isActor() === this._battler.isActor();
return (this._battler.isActor() === entity.battler().isActor() && aEntity.battler().confusionLevel() != 3) || (aEntity.battler().isEnemy() && aEntity.battler().confusionLevel === 3);
}
Next is a reworking of my earlier getEnemiesOf function:
This was reworked to take into consideration an ally or enemy unit that is inflicted with confuions BUT is the last member of their team
alive.
It will then treat the character as if they do not have confusion (they will begin to attack the real enemy now).
Code:
TBSAiManager.prototype.getEnemiesOf = function (battler, needAlive) {
var enemyEntities = this.BM().enemyEntities();
var allyEntities = this.BM().enemyEntities();
var isLastEnemy = battler.isEnemy() && enemyEntities.length == 1;
var isLastActor = battler.isActor() && allyEntities.length == 1;
var isLast = isLastEnemy || isLastActor;
var group = battler.isActor() ? this.BM().enemyEntities() : this.BM().allyEntities();
if (battler.hasConfusionStateAttackAlly())
group = battler.isActor() ? this.BM().allyEntities() : this.BM().enemyEntities();
if (battler.hasConfusionStateAttackAnyone() && Math.randomInt(2) === 0)
group = battler.isActor() ? this.BM().allyEntities() : this.BM().enemyEntities();
if(battler.isActor() && isLastActor)
{
group = this.BM().enemyEntities();
}
if(battler.isEnemy() && isLastEnemy)
{
group = this.BM().allyEntities();
}
for (var i = 0; i<group.length-1; i++)
{
if (group[i].battler() == battler)
{
group.splice(i, 1);
}
}
if (needAlive) {
return group.filter(function (ent) {
return !ent.battler().isDead();
});
} else {
return group;
}
};
I think lastly these ones:
applyParamToScope needs to be edited - mainly regarding exclude_allies and exclude_enemies from scope:
originally these would just pull the respective pools, but we want the true allies/enemies
if (param.exclude_allies) {
var user = param.user;
var party = TBSAiManager.getAlliesOf(user, true);//user.battler().isEnemy() ? this.enemyEntities() : this.allyEntities();
cells = cells.filter(function (cell) {
return !party.some(function (e) {
return cell.isSame(e.getCell());
});
});
}
if (param.exclude_enemies) {
var user = param.user;
var party = TBSAiManager.getEnemiesOf(user, true); //user.battler().isActor() ? this.enemyEntities() : this.allyEntities();
cells = cells.filter(function (cell) {
return !party.some(function (e) {
return cell.isSame(e.getCell());
});
});
}
Under: TBSSequenceManager.prototype.readTargets
var aoeEnemyTargets = aoeTargets.filter(function (entity) {
var aEnt = BattleManagerTBS.activeEntity();
var isLast = BattleManagerTBS.enemyEntities().length>1;
return this.isEnemy(entity.battler()) || (aEnt.battler().isEnemy && aEnt.battler().confusionLevel === 3 && !isLast);
}.bind(this));