mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-15 12:52:20 +02:00
Remove Target Requirement of SacrificialAttr
This commit is contained in:
parent
d74bb29929
commit
737ccda398
@ -744,7 +744,7 @@ export class RecoilAttr extends MoveEffectAttr {
|
|||||||
**/
|
**/
|
||||||
export class SacrificialAttr extends MoveEffectAttr {
|
export class SacrificialAttr extends MoveEffectAttr {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(true, MoveEffectTrigger.PRE_APPLY);
|
super(true, MoveEffectTrigger.POST_TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -762,13 +762,6 @@ export class SacrificialAttr extends MoveEffectAttr {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The AI is calculating how beneficial it is to use this move. Bosses will always return -20. Otherwise, the score is calculated based on the user's current hp ratio and the move's type effectiveness against the user
|
|
||||||
* @param user Pokemon that used the move
|
|
||||||
* @param target The target of the move
|
|
||||||
* @param move Move with this attribute
|
|
||||||
* @returns The benefit score of using this move (how likely the AI is to use this move)
|
|
||||||
**/
|
|
||||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||||
if (user.isBoss())
|
if (user.isBoss())
|
||||||
return -20;
|
return -20;
|
||||||
@ -781,11 +774,11 @@ export class SacrificialAttr extends MoveEffectAttr {
|
|||||||
**/
|
**/
|
||||||
export class SacrificialAttrOnHit extends MoveEffectAttr {
|
export class SacrificialAttrOnHit extends MoveEffectAttr {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(true, MoveEffectTrigger.PRE_APPLY);
|
super(true, MoveEffectTrigger.POST_TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deals damage to the user equal to their current hp
|
* Deals damage to the user equal to their current hp if the move lands
|
||||||
* @param user Pokemon that used the move
|
* @param user Pokemon that used the move
|
||||||
* @param target The target of the move
|
* @param target The target of the move
|
||||||
* @param move Move with this attribute
|
* @param move Move with this attribute
|
||||||
@ -804,13 +797,6 @@ export class SacrificialAttrOnHit extends MoveEffectAttr {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The AI is calculating how beneficial it is to use this move. Bosses will always return -20. Otherwise, the score is calculated based on the user's current hp ratio and the move's type effectiveness against the user
|
|
||||||
* @param user Pokemon that used the move
|
|
||||||
* @param target The target of the move
|
|
||||||
* @param move Move with this attribute
|
|
||||||
* @returns The benefit score of using this move (how likely the AI is to use this move)
|
|
||||||
**/
|
|
||||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||||
if (user.isBoss())
|
if (user.isBoss())
|
||||||
return -20;
|
return -20;
|
||||||
|
@ -2304,12 +2304,6 @@ export class MovePhase extends BattlePhase {
|
|||||||
return this.end();
|
return this.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the move has no valid targets (because they are flying, etc.) - if the used move is sacrificial it does not need a target so we add the user as a target so the move does not fail
|
|
||||||
if (targets.length === 0 && this.move.getMove().getAttrs(SacrificialAttr).length) {
|
|
||||||
// Add the user as a target if the move is sacrificial
|
|
||||||
targets.push(this.pokemon);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!moveQueue.length || !moveQueue.shift().ignorePP) // using .shift here clears out two turn moves once they've been used
|
if (!moveQueue.length || !moveQueue.shift().ignorePP) // using .shift here clears out two turn moves once they've been used
|
||||||
this.move.usePp(ppUsed);
|
this.move.usePp(ppUsed);
|
||||||
|
|
||||||
@ -2473,17 +2467,8 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
|
|
||||||
// Move animation only needs one target
|
// Move animation only needs one target
|
||||||
new MoveAnim(this.move.getMove().id as Moves, user, this.getTarget()?.getBattlerIndex()).play(this.scene, () => {
|
new MoveAnim(this.move.getMove().id as Moves, user, this.getTarget()?.getBattlerIndex()).play(this.scene, () => {
|
||||||
// Check if the user is in the targets list for sacrificial moves, if not add them
|
|
||||||
if (this.move.getMove().getAttrs(SacrificialAttr).length && !targets.includes(user)) {
|
|
||||||
targets.push(user);
|
|
||||||
targetHitChecks[user.getBattlerIndex()] = true;
|
|
||||||
}
|
|
||||||
for (let target of targets) {
|
for (let target of targets) {
|
||||||
if (!targetHitChecks[target.getBattlerIndex()]) {
|
if (!targetHitChecks[target.getBattlerIndex()]) {
|
||||||
// If we have a sacrifical move, and the target isnt the user - it should not "miss". So we skip the miss check
|
|
||||||
if (this.move.getMove().getAttrs(SacrificialAttr).length && target !== user) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
user.turnData.hitCount = 1;
|
user.turnData.hitCount = 1;
|
||||||
user.turnData.hitsLeft = 1;
|
user.turnData.hitsLeft = 1;
|
||||||
this.scene.queueMessage(getPokemonMessage(user, '\'s\nattack missed!'));
|
this.scene.queueMessage(getPokemonMessage(user, '\'s\nattack missed!'));
|
||||||
@ -2544,8 +2529,14 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// Trigger effect which should only apply one time after all targeted effects have already applied
|
// Trigger effect which should only apply one time after all targeted effects have already applied
|
||||||
applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveEffectAttr && (attr as MoveEffectAttr).trigger === MoveEffectTrigger.POST_TARGET,
|
const postTarget = applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveEffectAttr && (attr as MoveEffectAttr).trigger === MoveEffectTrigger.POST_TARGET,
|
||||||
user, null, this.move.getMove())
|
user, null, this.move.getMove());
|
||||||
|
|
||||||
|
if (applyAttrs.length) // If there is a pending asynchronous move effect, do this after
|
||||||
|
applyAttrs[applyAttrs.length - 1]?.then(() => postTarget);
|
||||||
|
else // Otherwise, push a new asynchronous move effect
|
||||||
|
applyAttrs.push(postTarget);
|
||||||
|
|
||||||
Promise.allSettled(applyAttrs).then(() => this.end());
|
Promise.allSettled(applyAttrs).then(() => this.end());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user