private static void MultiTurn(AtkContext atk, int turn, bool isRandom = false) { atk.SetCondition(Cs.MultiTurn, new Condition() { Turn = turn, Bool = isRandom }); }
private static bool ContinuousUse(AtkContext atk) { if (atk.Controller.ActingPokemons[atk.Controller.ActingPokemons.Count - 1] == atk.Attacker) { atk.Attacker.OnboardPokemon.RemoveCondition(Cs.ContinuousUse); return(false); } var o = atk.Attacker.OnboardPokemon; var c = o.GetCondition(Cs.LastMove); if (c != null) { if (c.Move.HardToUseContinuously) { var count = o.GetCondition <int>(Cs.ContinuousUse); if (atk.Controller.GetRandomInt(0, 0xffff - 1) < 0xffff >> count) { o.SetCondition(Cs.ContinuousUse, count + 1); return(true); } atk.Attacker.OnboardPokemon.RemoveCondition(Cs.ContinuousUse); return(false); } } o.SetCondition(Cs.ContinuousUse, 1); return(true); }
private static void MirrorMove(AtkContext atk) { var last = atk.Target.Defender.AtkContext; if (last != null && last.Move != null && last.Move.Mirrorable) { atk.StartExecute(last.Move, atk.Target.Defender.Tile); } atk.FailAll(); }
private static void Metronome(AtkContext atk) { LOOP: var m = MoveTypeE.Get(atk.Controller.GetRandomInt(1, RomData.MOVES)); if (METRONOME_BLOCK.Contains(m.Id) || m.Zmove) { goto LOOP; } atk.StartExecute(m, null, "Metronome"); }
public static void Execute(AtkContext atk) { var aer = atk.Attacker; switch (atk.Move.Id) { case Ms.THRASH: //37 case Ms.PETAL_DANCE: case Ms.OUTRAGE: MultiTurn(atk, aer.Controller.GetRandomInt(2, 3), true); break; case Ms.BIDE: //117 MultiTurn(atk, 3); atk.SetCondition(Cs.Bide, new Condition()); break; case Ms.THIEF: //168 case Ms.COVET: //343 if (aer.Pokemon.Item == 0) { atk.SetCondition(Cs.Thief); } break; case Ms.ROLLOUT: //205 case Ms.ICE_BALL: MultiTurn(atk, 5); break; case Ms.PRESENT: //217 { var random = atk.Controller.GetRandomInt(0, 99); atk.SetCondition(Cs.Present, random < 20 ? 0 : random < 60 ? 40 : random < 90 ? 80 : 100); } break; case Ms.MAGNITUDE: //222 Magnitude(atk); break; case Ms.PURSUIT: //228 if (aer.OnboardPokemon.HasCondition(Cs.Pursuiting)) { atk.IgnoreSwitchItem = true; } break; case Ms.UPROAR: //253 MultiTurn(atk, 3); break; } }
private static bool PrepareOneTurn(AtkContext atk) { var aer = atk.Attacker; if (aer.Action == PokemonAction.MoveAttached) { var m = atk.Move.Id; switch (m) { case Ms.FLY: //19 case Ms.BOUNCE: //340 aer.CoordY = CoordY.Air; break; case Ms.DIG: //91 aer.CoordY = CoordY.Underground; break; case Ms.DIVE: //291 aer.CoordY = CoordY.Water; break; case Ms.SHADOW_FORCE: //467 case Ms.PHANTOM_FORCE: aer.CoordY = CoordY.Another; break; case Ms.SKY_DROP: MoveE.FilterDefContext(atk); if (atk.Target == null) { atk.FailAll(null); } else { aer.CoordY = CoordY.Air; atk.Target.Defender.CoordY = CoordY.Air; atk.Target.Defender.OnboardPokemon.SetCondition(Cs.SkyDrop); aer.ShowLogPm(Ls.EnSkyDrop, atk.Target.Defender.Id); atk.SetAttackerAction(PokemonAction.Moving); } return(true); } aer.ShowLogPm("Prepare" + m.ToString()); if (m == Ms.SKULL_BASH) { aer.ChangeLv7D(atk.Attacker, StatType.Def, 1, false); } atk.SetAttackerAction(PokemonAction.Moving); return(!((m == Ms.SOLAR_BEAM || m == Ms.Solar_Blade) && aer.Controller.Weather == Weather.IntenseSunlight || ITs.PowerHerb(aer))); } return(false); }
private static void Copycat(AtkContext atk) { var o = atk.Controller.Board.GetCondition(Cs.LastMove); if (o == null || COPYCAT_BLOCK.Contains(o.Move.Id)) { atk.FailAll(); } else { atk.StartExecute(o.Move); } }
private static void Instruct(AtkContext atk) { var last = atk.Target.Defender.AtkContext; if (last != null && last.Move != null && last.Move.Mirrorable) { last.StartExecute(last.Move, last.Attacker.SelectedTarget, "UseMove", false); } else { atk.FailAll(); } }
private static void MeFirst(AtkContext atk) { var der = atk.Target.Defender; var m = der.SelectedMove.MoveE; if (der.OnboardPokemon.HasCondition(Cs.SkyDrop) || m.Id == Ms.STRUGGLE || m.Id == Ms.FOCUS_PUNCH || m.Id == Ms.Shell_Trap || m.Zmove) { atk.FailAll(); } else { atk.SetTurnCondition(Cs.MeFirst); atk.StartExecute(m, der.Tile); } }
public static bool MagicCoat(AtkContext atk, PokemonProxy der) { //atk.Move.AdvancedFlags.MagicCoat is already checked if (der.OnboardPokemon.HasCondition(Cs.MagicCoat) || atk.DefenderAbilityAvailable() && der.AbilityE(As.MAGIC_BOUNCE)) { var o = atk.GetCondition <List <PokemonProxy> >(Cs.MagicCoat); if (o == null) { o = new List <PokemonProxy>(); atk.SetCondition(Cs.MagicCoat, o); } o.Add(der); return(true); } return(false); }
private static void NaturePower(AtkContext atk) { MoveTypeE m; switch (atk.Controller.GameSettings.Terrain) { case Terrain.Path: m = MoveTypeE.Get(Ms.EARTHQUAKE); break; default: atk.Controller.ReportBuilder.ShowLog("error"); return; } atk.StartExecute(m, null, "NaturePower"); }
private static void NaturePower(AtkContext atk, Tile selectTile = null) { MoveTypeE m; switch (atk.Controller.GameSettings.Terrain) { case Terrain.Path: m = MoveTypeE.Get(Ms.TRI_ATTACK); break; default: atk.Controller.ReportBuilder.ShowLog("error"); return; } atk.StartExecute(m, selectTile, "NaturePower"); }
private static void Magnitude(AtkContext atk) { var random = atk.Controller.GetRandomInt(0, 99); if (random >= 95) { atk.SetCondition(Cs.Magnitude, 7); atk.Controller.ReportBuilder.ShowLog("Magnitude", 10); } else { var a = random < 5 ? 0 : random < 16 ? 1 : random < 35 ? 2 : random < 65 ? 3 : random < 85 ? 4 : 5; atk.SetCondition(Cs.Magnitude, a); atk.Controller.ReportBuilder.ShowLog("Magnitude", 4 + a); } }
private static Modifier PlusMinus(AtkContext atk) { if (atk.Move.Move.Category == MoveCategory.Special) { foreach (var p in atk.Attacker.Field.Pokemons) { if (p != atk.Attacker) { var a = p.Ability; if (a == As.PLUS || a == As.MINUS) { return(0x1800); } } } } return(0x1000); }
private static void Weather_Ball(AtkContext atk) { if (atk.Controller.Weather == Weather.Hailstorm) { atk.Type = BattleType.Ice; } else if (atk.Controller.Weather == Weather.IntenseSunlight) { atk.Type = BattleType.Fire; } else if (atk.Controller.Weather == Weather.Rain) { atk.Type = BattleType.Water; } else if (atk.Controller.Weather == Weather.Sandstorm) { atk.Type = BattleType.Rock; } }
private static void SleepTalk(AtkContext atk) { var aer = atk.Attacker; var moves = new List <MoveTypeE>(); foreach (var m in aer.Moves) { if (!(m.MoveE.PrepareOneTurn || SLEEPTALK_BLOCK.Contains(m.MoveE.Id))) { moves.Add(m.MoveE); } } var n = moves.Count; if (n == 0) { atk.FailAll(); } else { atk.StartExecute(moves[aer.Controller.GetRandomInt(0, moves.Count - 1)]); } }
public static Modifier AccuracyModifier(AtkContext atk) { var aer = atk.Attacker; int ab = aer.Ability; Modifier m = (Modifier)(ab == As.COMPOUNDEYES ? 0x14cc : ab == As.HUSTLE && atk.Move.Move.Category == MoveCategory.Physical ? 0xccc : 0x1000); foreach (PokemonProxy pm in atk.Controller.GetOnboardPokemons(aer.Pokemon.TeamId)) { if (pm.AbilityE(As.VICTORY_STAR)) { m *= 0x1199; } } if (aer.OnboardPokemon.RemoveCondition(Cs.MicleBerry)) { m *= 0x1199; } if (aer.ItemE(Is.WIDE_LENS)) { m *= 0x1199; } return(m); }
private static void Assist(AtkContext atk) { var aer = atk.Attacker; var moves = new List <MoveTypeE>(); foreach (var pm in aer.Field.Pokemons) { if (pm != aer && pm.Pokemon.Owner == aer.Pokemon.Owner) { foreach (var m in pm.Moves) { if (!ASSIST_BLOCK.Contains(m.MoveE.Id)) { moves.Add(m.MoveE); } } } } for (int i = aer.Controller.GameSettings.Mode.OnboardPokemonsPerPlayer(); i < aer.Pokemon.Owner.Pokemons.Count(); ++i) { foreach (var m in aer.Pokemon.Owner.GetPokemon(i).Moves) { if (!ASSIST_BLOCK.Contains(m.MoveE.Id)) { moves.Add(m.MoveE); } } } if (moves.Count == 0) { atk.FailAll(); } else { atk.StartExecute(moves[aer.Controller.GetRandomInt(0, moves.Count - 1)]); } }
private static void Assist(AtkContext atk) { var aer = atk.Attacker; var moves = new List <MoveTypeE>(); foreach (var pm in aer.Pokemon.Owner.Pokemons) { foreach (var m in pm.Pokemon.Moves) { if (pm != aer && !(ASSIST_BLOCK.Contains(m.Type.Id))) { moves.Add(MoveTypeE.Get(m.Type)); } } } if (moves.Count == 0) { atk.FailAll(); } else { atk.StartExecute(moves[aer.Controller.GetRandomInt(0, moves.Count - 1)]); } }
private static Modifier One3rdHp(AtkContext atk, BattleType type) { return((Modifier)(atk.Type == type && atk.Attacker.Hp * 3 <= atk.Attacker.Pokemon.MaxHp ? 0x1800 : 0x1000)); }
/// <summary> /// contains battle log /// </summary> /// <param name="atk"></param> /// <returns></returns> public static bool Execute(AtkContext atk) { var aer = atk.Attacker; if (atk.Targets == null || atk.Target != null) { switch (atk.Move.Id) { case Ms.SKETCH: //166 case Ms.TELEPORT: case Ms.HAPPY_HOUR: break; case Ms.SELFDESTRUCT: //120 case Ms.EXPLOSION: if (aer.Controller.Board.Pokemons.RaiseAbility(As.DAMP) != null) { atk.FailAll("FailSp", atk.Attacker.Id, atk.Move.Id); return(false); } return(true); case Ms.REST: //156 if (aer.Hp == aer.Pokemon.MaxHp) { atk.FailAll("FullHp", aer.Id); return(false); } if (!PTs.CanAddXXX(aer, aer, true, AttachedState.SLP, true)) { atk.FailAll(null); return(false); } return(true); case Ms.SNORE: //173 case Ms.SLEEP_TALK: if (aer.State == PokemonState.SLP) { return(true); } break; case Ms.FAKE_OUT: //252 case Ms.MAT_BLOCK: foreach (var m in aer.Moves) { if (m.HasUsed) { goto FAIL; } } return(true); case Ms.STOCKPILE: //254 if (aer.OnboardPokemon.GetCondition <int>(Cs.Stockpile) != 3) { return(true); } break; case Ms.SPIT_UP: //255 case Ms.SWALLOW: if (aer.OnboardPokemon.HasCondition(Cs.Stockpile)) { return(true); } break; case Ms.NATURAL_GIFT: //363 if (ITs.CanLostItem(aer) && ITs.CanUseItem(aer) && ITs.Berry(aer.Pokemon.Item)) { return(true); } break; case Ms.FLING: //374 if (ITs.CanLostItem(aer) && ITs.CanUseItem(aer) && MoveBasePower.FlingPower(aer.Pokemon.Item) != 0) { return(true); } break; case Ms.ME_FIRST: //382 case Ms.SUCKER_PUNCH: //389 { var der = atk.Target.Defender; var dm = der.SelectedMove; if (!(der.LastMoveTurn == der.Controller.TurnNumber || dm == null || dm.Move.Type.Category == MoveCategory.Status)) { return(true); } } break; case Ms.LAST_RESORT: //387 foreach (var m in aer.Moves) { if (!m.HasUsed && m.MoveE.Id != Ms.LAST_RESORT) { goto FAIL; } } return(true); case Ms.ALLY_SWITCH: if (aer.Controller.GameSettings.Mode == GameMode.Double || aer.Controller.GameSettings.Mode == GameMode.Triple && aer.OnboardPokemon.X != 1) { return(true); } break; case Ms.BESTOW: //516 if (aer.Pokemon.Item == 0 || ITs.NeverLostItem(aer.Pokemon)) { return(true); } break; case Ms.BELCH: //562 if (aer.OnboardPokemon.HasCondition(Cs.Belch)) { return(true); } break; case Ms.HYPERSPACE_FURY: if (aer.Pokemon.Form.Species.Number == Ps.HOOPA) { return(true); } break; default: if (!atk.Move.HardToUseContinuously || ContinuousUse(atk)) { return(true); } break; } } FAIL: atk.FailAll(); return(false); }
public static Modifier Hustle(AtkContext atk) { return((Modifier)(atk.Attacker.AbilityE(As.HUSTLE) && atk.Move.Move.Category == MoveCategory.Physical ? 0x1800 : 0x1000)); }
private static Modifier Category(AtkContext atk, MoveCategory category) { return((Modifier)(atk.Move.Move.Category == category ? 0x1199 : 0x1000)); }
private static Modifier Orb(AtkContext atk, int pm, BattleType type) { return((Modifier)(atk.Attacker.Pokemon.Form.Species.Number == pm && (atk.Type == BattleType.Dragon || atk.Type == type) ? 0x1333 : 0x1000)); }
private static Modifier TypeItem(AtkContext atk, BattleType type) { return((Modifier)(atk.Type == type ? 0x1333 : 0x1000)); }
private static Modifier AttackerItem(AtkContext atk) { if (atk.HasCondition(Cs.Gem)) { return(0x1800); } switch (atk.Attacker.Item) { case Is.GRISEOUS_ORB: return(Orb(atk, 487, BattleType.Ghost)); case Is.ADAMANT_ORB: return(Orb(atk, 483, BattleType.Steel)); case Is.LUSTROUS_ORB: return(Orb(atk, 484, BattleType.Water)); case Is.SILVERPOWDER: case Is.INSECT_PLATE: return(TypeItem(atk, BattleType.Bug)); case Is.METAL_COAT: case Is.IRON_PLATE: return(TypeItem(atk, BattleType.Steel)); case Is.SOFT_SAND: case Is.EARTH_PLATE: return(TypeItem(atk, BattleType.Ground)); case Is.HARD_STONE: case Is.STONE_PLATE: case Is.ROCK_INCENSE: return(TypeItem(atk, BattleType.Rock)); case Is.MIRACLE_SEED: case Is.MEADOW_PLATE: case Is.ROSE_INCENSE: return(TypeItem(atk, BattleType.Grass)); case Is.BLACKGLASSES: case Is.DREAD_PLATE: return(TypeItem(atk, BattleType.Dark)); case Is.BLACK_BELT: case Is.FIST_PLATE: return(TypeItem(atk, BattleType.Fighting)); case Is.MAGNET: case Is.ZAP_PLATE: return(TypeItem(atk, BattleType.Electric)); case Is.MYSTIC_WATER: case Is.SPLASH_PLATE: case Is.WAVE_INCENSE: case Is.SEA_INCENSE: return(TypeItem(atk, BattleType.Water)); case Is.SHARP_BEAK: case Is.SKY_PLATE: return(TypeItem(atk, BattleType.Flying)); case Is.POISON_BARB: case Is.TOXIC_PLATE: return(TypeItem(atk, BattleType.Poison)); case Is.NEVERMELTICE: case Is.ICICLE_PLATE: return(TypeItem(atk, BattleType.Ice)); case Is.SPELL_TAG: case Is.SPOOKY_PLATE: return(TypeItem(atk, BattleType.Ghost)); case Is.TWISTEDSPOON: case Is.MIND_PLATE: case Is.ODD_INCENSE: return(TypeItem(atk, BattleType.Psychic)); case Is.CHARCOAL: case Is.FLAME_PLATE: return(TypeItem(atk, BattleType.Fire)); case Is.DRAGON_FANG: case Is.DRACO_PLATE: return(TypeItem(atk, BattleType.Dragon)); case Is.PIXIE_PLATE: return(TypeItem(atk, BattleType.Fairy)); case Is.SILK_SCARF: return(TypeItem(atk, BattleType.Normal)); case Is.MUSCLE_BAND: return(Category(atk, MoveCategory.Physical)); case Is.WISE_GLASSES: return(Category(atk, MoveCategory.Special)); default: return(0x1000); } }
private static void Generic(AtkContext atk) { var move = atk.Move; var aer = atk.Attacker; if (move.PrepareOneTurn && PrepareOneTurn(atk)) { return; } if (aer.Controller.GameSettings.Mode.XBound() != 1 && (move.Id == Ms.WATER_PLEDGE || move.Id == Ms.FIRE_PLEDGE || move.Id == Ms.GRASS_PLEDGE)) { if (aer.Field.AddTurnCondition(Cs.Plege, move.Id)) { foreach (var pm in aer.Controller.ActingPokemons) { if (pm.Pokemon.TeamId == aer.Pokemon.TeamId && pm.SelectedMove != null && pm.SelectedMove.MoveE.Id != move.Id && (pm.SelectedMove.MoveE.Id == Ms.WATER_PLEDGE || pm.SelectedMove.MoveE.Id == Ms.FIRE_PLEDGE || pm.SelectedMove.MoveE.Id == Ms.GRASS_PLEDGE) && pm.CanMove) { aer.ShowLogPm(Ls.Pledge, pm.Id); aer.Controller.Board.SetTurnCondition(Cs.NextActingPokemon, pm); return; } } } } if (move.Snatchable) { foreach (var pm in atk.Controller.OnboardPokemons) { if (pm.OnboardPokemon.HasCondition(Cs.Snatch)) { pm.OnboardPokemon.RemoveCondition(Cs.Snatch); pm.ShowLogPm("Snatch", aer.Id); var s = new AtkContext(pm) { Move = move }; InitAtkContext.Execute(s); MoveE.BuildDefContext(s, null); if (MoveNotFail.Execute(s)) { MoveAct.Execute(s); } else { s.FailAll(); } atk.SetAttackerAction(PokemonAction.Done); return; } } } if (move.MagicCoat && atk.Targets == null && !atk.HasCondition(Cs.IgnoreMagicCoat)) { foreach (var p in aer.Controller.GetOnboardPokemons(1 - aer.Pokemon.TeamId)) { if (STs.MagicCoat(atk, p)) { atk.SetCondition(Cs.MagicCoat, new List <PokemonProxy>() { p }); atk.FailAll(null); MoveE.MagicCoat(atk); return; } } } CalculateType.Execute(atk); if (atk.Type == BattleType.Fire && aer.OnboardPokemon.HasCondition(Cs.Powder)) { aer.EffectHurtByOneNth(4, Ls.Powder); atk.FailAll(null); return; } if (atk.Move.Move.Category != MoveCategory.Status) { if (atk.Type == BattleType.Fire && aer.Controller.Board.GetCondition <int>(Cs.SpWeather) == As.PRIMORDIAL_SEA) { atk.FailAll(Ls.HeavyRain); return; } if (atk.Type == BattleType.Water && aer.Controller.Board.GetCondition <int>(Cs.SpWeather) == As.DESOLATE_LAND) { atk.FailAll(Ls.HarshSunlight); return; } } if (aer.AbilityE(As.PROTEAN) && aer.OnboardPokemon.SetTypes(atk.Type)) { aer.RaiseAbility(); aer.ShowLogPm("TypeChange", (int)atk.Type); } MoveE.FilterDefContext(atk); if (atk.Targets != null && atk.Target == null) { atk.FailAll(null); } else { MoveAct.Execute(atk); MoveE.MoveEnding(atk); } if (move.MagicCoat && atk.Targets != null) { MoveE.MagicCoat(atk); } }
public static void Execute(AtkContext atk, Tile selectTile = null) { var move = atk.Move.Id; var aer = atk.Attacker; if (MoveNotFail.Execute(atk)) { switch (move) { case Ms.METRONOME: //118 Metronome(atk); break; case Ms.MIRROR_MOVE: //119 MirrorMove(atk); break; case Ms.SLEEP_TALK: //214 SleepTalk(atk); break; case Ms.NATURE_POWER: //267 NaturePower(atk, selectTile); break; case Ms.ASSIST: //274 Assist(atk); break; case Ms.SNATCH: //289 Snatch(atk); break; case Ms.ME_FIRST: //382 MeFirst(atk); break; case Ms.COPYCAT: //383 Copycat(atk); break; case Ms.Instruct: Instruct(atk); goto default; default: atk.ImplementPressure(); Generic(atk); if (atk.Fail) { switch (move) { case Ms.JUMP_KICK: case Ms.HIGH_JUMP_KICK: if (aer.EffectHurtByOneNth(2, Ls.FailSelfHurt)) { aer.CheckFaint(); } break; case Ms.SELFDESTRUCT: case Ms.EXPLOSION: aer.Faint(); break; case Ms.NATURAL_GIFT: //363 case Ms.FLING: aer.ConsumeItem(); break; } } break; } } else { atk.ImplementPressure(); } if (atk.Move.Id == Ms.RAGE && aer != null) { aer.OnboardPokemon.SetCondition(Cs.Rage); } }
public static bool IgnoreSubstitute(this AtkContext atk) { return(atk.Move.IgnoreSubstitute || atk.Attacker.AbilityE(As.INFILTRATOR)); }
private static void Snatch(AtkContext atk) { atk.Attacker.OnboardPokemon.SetTurnCondition(Cs.Snatch); atk.Attacker.ShowLogPm("EnSnatch"); atk.SetAttackerAction(PokemonAction.Done); }