Skip to content

Commit

Permalink
this fucking sucks lmao
Browse files Browse the repository at this point in the history
  • Loading branch information
HisuianZoroark committed Feb 18, 2024
1 parent 3131af5 commit e15eef6
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
8 changes: 6 additions & 2 deletions data/mods/gen9ssb/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ export const Conditions: {[k: string]: ModdedConditionData & {innateName?: strin
onStart() {
this.add(`c:|${getName('aegii')}|**It is now aegii's turn to beat you down.**`);
},
onSwitchOut(pokemon) {
// @ts-ignore Support peeking at new pokemon
onSwitchOut(source, pokemon) {
// @ts-ignore
if (this.randomChance(2, 100)) {
// @ts-ignore
this.add(`c:|${getName('aegii')}|...right, I was saying in SSB4 to "stan loona", but this has to be changed now that we've found out that the company managing loona is shady af. I would like to amend that to "stan the individual members of loona" (or if you want, you can choose to stan any other group of your choice!)`);
} else {
this.add(`c:|${getName('aegii')}|~yes ${pokemon.side.active[0]}`);
// @ts-ignore
this.add(`c:|${getName('aegii')}|~yes ${pokemon.name}`);
}
},
onFaint() {
Expand Down
96 changes: 96 additions & 0 deletions data/mods/gen9ssb/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,102 @@ export const Scripts: ModdedBattleScriptsData = {
}
return hitResults;
},
switchIn(pokemon, pos, sourceEffect, isDrag) {
if (!pokemon || pokemon.isActive) {
this.battle.hint("A switch failed because the Pokémon trying to switch in is already in.");
return false;
}

const side = pokemon.side;
if (pos >= side.active.length) {
throw new Error(`Invalid switch position ${pos} / ${side.active.length}`);
}
const oldActive = side.active[pos];
const unfaintedActive = oldActive?.hp ? oldActive : null;
if (unfaintedActive) {
oldActive.beingCalledBack = true;
let switchCopyFlag: 'copyvolatile' | 'shedtail' | boolean = false;
if (sourceEffect && typeof (sourceEffect as Move).selfSwitch === 'string') {
switchCopyFlag = (sourceEffect as Move).selfSwitch!;
}
if (!oldActive.skipBeforeSwitchOutEventFlag && !isDrag) {
this.battle.runEvent('BeforeSwitchOut', oldActive);
if (this.battle.gen >= 5) {
this.battle.eachEvent('Update');
}
}
oldActive.skipBeforeSwitchOutEventFlag = false;
if (!this.battle.runEvent('SwitchOut', oldActive, pokemon)) {
// Warning: DO NOT interrupt a switch-out if you just want to trap a pokemon.
// To trap a pokemon and prevent it from switching out, (e.g. Mean Look, Magnet Pull)
// use the 'trapped' flag instead.

// Note: Nothing in the real games can interrupt a switch-out (except Pursuit KOing,
// which is handled elsewhere); this is just for custom formats.
return false;
}
if (!oldActive.hp) {
// a pokemon fainted from Pursuit before it could switch
return 'pursuitfaint';
}

// will definitely switch out at this point

oldActive.illusion = null;
this.battle.singleEvent('End', oldActive.getAbility(), oldActive.abilityState, oldActive);

// if a pokemon is forced out by Whirlwind/etc or Eject Button/Pack, it can't use its chosen move
this.battle.queue.cancelAction(oldActive);

let newMove = null;
if (this.battle.gen === 4 && sourceEffect) {
newMove = oldActive.lastMove;
}
if (switchCopyFlag) {
pokemon.copyVolatileFrom(oldActive, switchCopyFlag);
}
if (newMove) pokemon.lastMove = newMove;
oldActive.clearVolatile();
}
if (oldActive) {
oldActive.isActive = false;
oldActive.isStarted = false;
oldActive.usedItemThisTurn = false;
oldActive.statsRaisedThisTurn = false;
oldActive.statsLoweredThisTurn = false;
oldActive.position = pokemon.position;
pokemon.position = pos;
side.pokemon[pokemon.position] = pokemon;
side.pokemon[oldActive.position] = oldActive;
}
pokemon.isActive = true;
side.active[pos] = pokemon;
pokemon.activeTurns = 0;
pokemon.activeMoveActions = 0;
for (const moveSlot of pokemon.moveSlots) {
moveSlot.used = false;
}
this.battle.runEvent('BeforeSwitchIn', pokemon);
if (sourceEffect) {
this.battle.add(isDrag ? 'drag' : 'switch', pokemon, pokemon.getDetails, '[from] ' + sourceEffect);
} else {
this.battle.add(isDrag ? 'drag' : 'switch', pokemon, pokemon.getDetails);
}
pokemon.abilityOrder = this.battle.abilityOrder++;
if (isDrag && this.battle.gen === 2) pokemon.draggedIn = this.battle.turn;
pokemon.previouslySwitchedIn++;

if (isDrag && this.battle.gen >= 5) {
// runSwitch happens immediately so that Mold Breaker can make hazards bypass Clear Body and Levitate
this.battle.singleEvent('PreStart', pokemon.getAbility(), pokemon.abilityState, pokemon);
this.runSwitch(pokemon);
} else {
this.battle.queue.insertChoice({choice: 'runUnnerve', pokemon});
this.battle.queue.insertChoice({choice: 'runSwitch', pokemon});
}

return true;
},
},
pokemon: {
isGrounded(negateImmunity) {
Expand Down
3 changes: 3 additions & 0 deletions sim/global-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ interface ModdedBattleActions {
this: BattleActions, targets: SpreadMoveTargets, pokemon: Pokemon, move: ActiveMove,
moveData?: ActiveMove, isSecondary?: boolean, isSelf?: boolean
) => [SpreadMoveDamage, SpreadMoveTargets];
switchIn?: (
this: BattleActions, pokemon: Pokemon, pos: number, sourceEffect: Effect | null, isDrag?: boolean
) => string | boolean;
targetTypeChoices?: (this: BattleActions, targetType: string) => boolean;
terastallize?: (this: BattleActions, pokemon: Pokemon) => void;
tryMoveHit?: (
Expand Down

0 comments on commit e15eef6

Please sign in to comment.