So I have variable that stores how much the actor that you did not choose at the start of the game likes the actor that you've chosen at the start of game.
Dependend on that variable I want certain effects to happen during battle. For example I want a small chance, that this particular actor attacks his friend instead of the selected enemy.
I currently have the following code:
This works fine, but my problem is the attack animation still playes on the selected enemy.
Where do I need to exchange the target so that the animation playes on the new target, but I am still able to select the enemy I want to attack under normal conditions?
I also don't want BattleManager.applySubstitute to change the target again to any other actor after that exchange. Is this possible?
Now I found out myself, that Game_Action.prototype.makeTargets is the function I was looking for. Debugging sometimes really helps. I always thought that is the function that determines which targets I am able to select, but now I've learned that this is not the case.
Dependend on that variable I want certain effects to happen during battle. For example I want a small chance, that this particular actor attacks his friend instead of the selected enemy.
I currently have the following code:
Code:
BurningOrca.MyGame.BattleManager_applySubstitute = BattleManager.applySubstitute
BurningOrca.MyGame.BattleManager_applySubstitute = BattleManager.applySubstitute
BattleManager.applySubstitute = function(target)
{
target = BurningOrca.MyGame.BattleManager_applySubstitute.call(this, target);
if( this._action.isDamage() )
{
target = this._action.applyTargetSubstitute(target);
}
return target;
}
Game_Action.prototype.applyTargetSubstitute = function(target)
{
if( this.isForOne()
&& target.isEnemy() )
{
if( this.subject() === $gameActors.actor($gameVariables.value(4))
&& $gameVariables.value(5) < 50 )
{
var chanceToHitFriend = (50 - $gameVariables.value(5)) / 2.0;
if( BurningOrca.MyGame.RandomNumberBetween(0.0, 100.0) <= chanceToHitFriend )
{
if( $gameVariables.value(4) === 2 )
{
target = $gameActors.actor(1);
}
else
{
target = $gameActors.actor(2);
}
}
}
}
return target;
}
This works fine, but my problem is the attack animation still playes on the selected enemy.
Where do I need to exchange the target so that the animation playes on the new target, but I am still able to select the enemy I want to attack under normal conditions?
I also don't want BattleManager.applySubstitute to change the target again to any other actor after that exchange. Is this possible?
Now I found out myself, that Game_Action.prototype.makeTargets is the function I was looking for. Debugging sometimes really helps. I always thought that is the function that determines which targets I am able to select, but now I've learned that this is not the case.