Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Dancer using the battle queue and the AnyAfterMove event #10975

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions data/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,15 +843,15 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
// Ties go to whichever Pokemon has had the ability for the least amount of time
this.queue.insertChoice({
choice: 'move',
order: 198,
speed: -source.storedStats['spe'],
order: 198 + dancer.storedStats['spe'] / 100000, // FIXME HACK
speed: -source.storedStats['spe'], // speed gets reset
effectOrder: dancer.abilityState.effectOrder,
pokemon: dancer,
moveid: move.id,
targetLoc: dancersTargetLoc,
sourceEffect: this.dex.abilities.get('dancer'),
externalMove: true,
});
}, false, false);
},
condition: {
noCopy: true, // doesn't get copied by Baton Pass
Expand Down
8 changes: 4 additions & 4 deletions sim/battle-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class BattleQueue {
* Returns an array of Actions because some ActionChoices (like mega moves)
* resolve to two Actions (mega evolution + use move)
*/
resolveAction(action: ActionChoice, midTurn = false): Action[] {
resolveAction(action: ActionChoice, midTurn = false, updateSpeed = true): Action[] {
if (!action) throw new Error(`Action not passed to resolveAction`);
if (action.choice === 'pass') return [];
const actions = [action];
Expand Down Expand Up @@ -263,7 +263,7 @@ export class BattleQueue {
}
action.originalTarget = action.pokemon.getAtLoc(action.targetLoc);
}
if (!deferPriority) this.battle.getActionSpeed(action);
if (!deferPriority) this.battle.getActionSpeed(action, updateSpeed);
return actions as any;
}

Expand Down Expand Up @@ -362,7 +362,7 @@ export class BattleQueue {
* would have happened (sorting by priority/speed), without
* re-sorting the existing actions.
*/
insertChoice(choices: ActionChoice | ActionChoice[], midTurn = false) {
insertChoice(choices: ActionChoice | ActionChoice[], midTurn = false, updateSpeed = true) {
if (Array.isArray(choices)) {
for (const choice of choices) {
this.insertChoice(choice);
Expand All @@ -374,7 +374,7 @@ export class BattleQueue {
if (choice.pokemon) {
choice.pokemon.updateSpeed();
}
const actions = this.resolveAction(choice, midTurn);
const actions = this.resolveAction(choice, midTurn, updateSpeed);

let firstIndex = null;
let lastIndex = null;
Expand Down
4 changes: 2 additions & 2 deletions sim/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,7 @@ export class Battle {
}
}

getActionSpeed(action: AnyObject) {
getActionSpeed(action: AnyObject, updateSpeed = true) {
if (action.choice === 'move') {
let move = action.move;
if (action.zmove) {
Expand Down Expand Up @@ -2597,7 +2597,7 @@ export class Battle {
if (this.gen > 5) action.move.priority = priority;
}

if (!action.speed) {
if (updateSpeed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't this work?

Copy link
Contributor Author

@andrebastosdias andrebastosdias Mar 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!action.speed gives errors on other tests that update speed mid turn (e.g. Megas). updateSpeed is not passing the should activate in order of lowest to highest raw speed test.

Copy link
Contributor Author

@andrebastosdias andrebastosdias Mar 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!action.externalMove) { is a still hack, but at least is working correctly. I don't know why the argument updateSpeed was allowing the speed to be updated when false.

if (!action.pokemon) {
action.speed = 1;
} else {
Expand Down