Skip to content

Commit

Permalink
No more wait when status effect doesn't apply in battle + no more wai…
Browse files Browse the repository at this point in the history
…t when effect common reaction is instant commands in battles
  • Loading branch information
Wano-k committed Sep 21, 2023
1 parent 3d07acf commit 91c4716
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Scene/BattleAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ class BattleAnimation {
.currentEffectIndex < l; this.battle.currentEffectIndex++)
{
let effect = this.battle.effects[this.battle.currentEffectIndex];
effect.execute();
if (effect.isAnimated()) {
effect.execute(true);
if (!effect.canSkip && effect.isAnimated()) {
if (effect.kind === Enum.EffectKind.Status) {
this.battle.currentTargetIndex = -1;
}
Expand Down
23 changes: 21 additions & 2 deletions src/System/Effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Effect extends Base {
public isTemporarilyChangeTarget: boolean;
public temporarilyChangeTargetFormula: System.DynamicValue;
public skillItem: System.CommonSkillItem;
public canSkip = false;

constructor(json?: Record<string, any>) {
super(json);
Expand Down Expand Up @@ -227,9 +228,10 @@ class Effect extends Base {
* Execute the effect.
* @returns {boolean}
*/
execute(): boolean {
execute(forceReaction = false): boolean {
let user = Scene.Map.current.user ? Scene.Map.current.user.player :
Player.getTemporaryPlayer();
this.canSkip = false;
Scene.Map.current.tempTargets = Scene.Map.current.targets;
if (this.isTemporarilyChangeTarget) {
Scene.Map.current.targets = Interpreter.evaluate(this
Expand Down Expand Up @@ -403,12 +405,23 @@ class Effect extends Base {
case EffectKind.Status: {
let precision: number, miss: boolean, id: number, previousFirst:
Status;
this.canSkip = true;
for (let i = 0, l = targets.length; i < l; i++) {
battler = targets[i];
target = battler.player;
id = this.statusID.getValue();
if (!target.hasStatus(id)) {
battler.damages = null;
battler.isDamagesMiss = false;
battler.isDamagesCritical = false;
battler.lastStatus = null;
battler.lastStatusHealed = null;
continue;
} else {
this.canSkip = false;
}
precision = Interpreter.evaluate(this.statusPrecisionFormula
.getValue(), { user: user, target: battler.player });
id = this.statusID.getValue();
// Handle resistance
if (target.statusRes[id]) {
precision /= target.statusRes[id].multiplication;
Expand Down Expand Up @@ -464,6 +477,12 @@ class Effect extends Base {
.commonReactionID), null, null, this.commonReaction.parameters);
Manager.Stack.top.reactionInterpretersEffects.push(reactionInterpreter);
Manager.Stack.top.reactionInterpreters.push(reactionInterpreter);
if (forceReaction) {
Manager.Stack.top.updateInterpreters();
if (Manager.Stack.top.reactionInterpretersEffects.length === 0) {
this.canSkip = true;
}
}
result = true;
break;
case EffectKind.SpecialActions:
Expand Down

0 comments on commit 91c4716

Please sign in to comment.