1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Guest, PO has ceased our separate tiering and adopted Smogon tiers for SM. More information and updates here.

    Dismiss Notice

[Battle Scripting] Battle scripting (next update)

Discussion in 'Server and Client Scripting' started by coyotte508, Jul 14, 2012.

  1. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    Upcoming after v2.0.05.

    Battle scripts share all the attributes of client scripts, but they have more. Also they don't share the client events, instead they have battle events.

    Battle events:
    [secret]
    Code (c++):
    1. void onKo(int spot);
    2.     void onSendOut(int spot, int previndex, ShallowBattlePoke* pokemon, bool silent);
    3.     void onSendBack(int spot, bool silent);
    4.     void onUseAttack(int spot, int attack, bool silent);
    5.     void onBeginTurn(int turn);
    6.     void onHpChange(int spot, int newHp);
    7.     void onHitCount(int spot, int count);
    8.     void onEffectiveness(int spot, int effectiveness);
    9.     void onCriticalHit(int spot);
    10.     void onMiss(int spot);
    11.     void onAvoid(int spot);
    12.     void onStatBoost(int spot, int stat, int boost, bool silent);
    13.     void onMajorStatusChange(int spot, int status, bool multipleTurns, bool silent);
    14.     void onPokeballStatusChanged(int player, int poke, int status);
    15.     void onStatusAlreadyThere(int spot, int status);
    16.     void onStatusNotification(int spot, int status);
    17.     void onStatusDamage(int spot, int status);
    18.     void onStatusOver(int spot, int status);
    19.     void onAttackFailing(int spot, bool fail);
    20.     void onPlayerMessage(int spot, const QString& message);
    21.     void onSpectatorJoin(int id, const QString& name);
    22.     void onSpectatorLeave(int id);
    23.     void onSpectatorChat(int id, const QString& message);
    24.     void onMoveMessage(int spot, int move, int part, int type, int foe, int other, const QString &data);
    25.     void onNoTarget(int spot);
    26.     void onItemMessage(int spot, int item, int part, int foe, int berry, int other);
    27.     void onFlinch(int spot);
    28.     void onRecoil(int spot);
    29.     void onDrained(int spot);
    30.     void onStartWeather(int spot, int weather, bool ability);
    31.     void onContinueWeather(int weather);
    32.     void onEndWeather(int weather);
    33.     void onHurtWeather(int spot, int weather);
    34.     void onDamageDone(int spot, int damage);
    35.     void onAbilityMessage(int spot, int ab, int part, int type, int foe, int other);
    36.     void onSubstituteStatus(int spot, bool substitute);
    37.     void onBlankMessage();
    38.     void onClauseActivated(int clause);
    39.     void onRatedNotification(bool rated);
    40.     void onTierNotification(const QString &tier);
    41.     void onDynamicInfo(int spot, const BattleDynamicInfo &info);
    42.     void onPokemonVanish(int spot);
    43.     void onPokemonReappear(int spot);
    44.     void onSpriteChange(int spot, int newSprite);
    45.     void onDefiniteFormeChange(int spot, int poke, int newPoke);
    46.     void onCosmeticFormeChange(int spot, int subforme);
    47.     void onClockStart(int player, int time);
    48.     void onClockStop(int player, int time);
    49.     void onShiftSpots(int player, int spot1, int spot2, bool silent);
    50.     void onBattleEnd(int res, int winner);
    51.     void onPPChange(int spot, int move, int PP);
    52.     void onOfferChoice(int player, const BattleChoices &choice);
    53.     void onTempPPChange(int spot, int move, int PP);
    54.     void onMoveChange(int spot, int slot, int move, bool definite);
    55.     void onRearrangeTeam(int player, const ShallowShownTeam& team);
    56.     void onChoiceSelection(int player);
    57.     void onChoiceCancellation(int player);
    58.     void onVariation(int player, int bonus, int malus);
    59.     void onDynamicStats(int spot, const BattleStats& stats);
    60.     void onPrintHtml(const QString &html);
    61.     void onReconnect(int player);
    62.     void onDisconnect(int player);
    63.     void onAttackChosen(int spot, int attackSlot, int target);
    64.     void onSwitchChosen(int spot, int pokeSlot);
    65.     void onTeamOrderChosen(int player, const RearrangeChoice &rearrange);
    66.     void onChoiceCancelled(int player);
    67.     void onShiftToCenterChosen(int player);
    68.     void onDrawRequest(int player);
    [/secret]

    New global object: "battle"

    Battle

    Properties
    battle.me <- yourself (0 or 1)
    battle.opponent <- opponent (0 or 1)
    battle.id <- the battle id
    battle.data.field <- the battle Field

    Functions
    battle.data.team(player) <- the Team of player (0 or 1)
    Code (C++):
    1.  
    2.     void forfeit();
    3.     /* Those functions are mainly to control the GUI */
    4.     void switchClicked(int zone);
    5.     void attackClicked(int zone);
    6.     void sendMessage();
    7.     void offerTie();
    8.     void attackButton();
    9.     void clickClose();
    10.     void emitCancel();
    11.     void switchToPokeZone();
    12.     void sendRearrangedTeam();
    13.  
    14.     /* returns the player (0 or 1) of the pokemon in the field slot (0 to 5 in triples) */
    15.     int player(int spot) const;
    16.     /* returns 1 - player */
    17.     int opponent(int player) const;
    18.  
    Signals
    signals:
    Code (C++):
    1.     void closedBW(int);
    2.     void battleMessage(int, QString);
    3.     void battleCommand(int battleId, const BattleChoice &);
    4.     void forfeit(int battleid);
    5.     void offerTie(int battleid);
    6.  
    So if you want to send a message, just do battle.battleMessage(battle.id, "abc");
    BattleChoice allows you to make a move, it's detailed further below (really further).


    Enums of battle.data(for ex battle.data.DoomDesire == sys.moveNum("Doom Desire"))

    [secret]
    Code (c++):
    1.     enum Moves {
    2.         NoMove,
    3.         Pound,
    4.         KarateChop,
    5.         DoubleSlap,
    6.         CometPunch,
    7.         MegaPunch,
    8.         PayDay,
    9.         FirePunch,
    10.         IcePunch,
    11.         ThunderPunch,
    12.         Scratch,
    13.         ViceGrip,
    14.         Guillotine,
    15.         RazorWind,
    16.         SwordsDance,
    17.         Cut,
    18.         Gust,
    19.         WingAttack,
    20.         Whirlwind,
    21.         Fly,
    22.         Bind,
    23.         Slam,
    24.         VineWhip,
    25.         Stomp,
    26.         DoubleKick,
    27.         MegaKick,
    28.         JumpKick,
    29.         RollingKick,
    30.         Sand_Attack,
    31.         Headbutt,
    32.         HornAttack,
    33.         FuryAttack,
    34.         HornDrill,
    35.         Tackle,
    36.         BodySlam,
    37.         Wrap,
    38.         TakeDown,
    39.         Thrash,
    40.         Double_Edge,
    41.         TailWhip,
    42.         PoisonSting,
    43.         Twineedle,
    44.         PinMissile,
    45.         Leer,
    46.         Bite,
    47.         Growl,
    48.         Roar,
    49.         Sing,
    50.         Supersonic,
    51.         SonicBoom,
    52.         Disable,
    53.         Acid,
    54.         Ember,
    55.         Flamethrower,
    56.         Mist,
    57.         WaterGun,
    58.         HydroPump,
    59.         Surf,
    60.         IceBeam,
    61.         Blizzard,
    62.         Psybeam,
    63.         BubbleBeam,
    64.         AuroraBeam,
    65.         HyperBeam,
    66.         Peck,
    67.         DrillPeck,
    68.         Submission,
    69.         LowKick,
    70.         Counter,
    71.         SeismicToss,
    72.         Strength,
    73.         Absorb,
    74.         MegaDrain,
    75.         LeechSeed,
    76.         Growth,
    77.         RazorLeaf,
    78.         SolarBeam,
    79.         PoisonPowder,
    80.         StunSpore,
    81.         SleepPowder,
    82.         PetalDance,
    83.         StringShot,
    84.         DragonRage,
    85.         FireSpin,
    86.         ThunderShock,
    87.         Thunderbolt,
    88.         ThunderWave,
    89.         Thunder,
    90.         RockThrow,
    91.         Earthquake,
    92.         Fissure,
    93.         Dig,
    94.         Toxic,
    95.         Confusion,
    96.         Psychic,
    97.         Hypnosis,
    98.         Meditate,
    99.         Agility,
    100.         QuickAttack,
    101.         Rage,
    102.         Teleport,
    103.         NightShade,
    104.         Mimic,
    105.         Screech,
    106.         DoubleTeam,
    107.         Recover,
    108.         Harden,
    109.         Minimize,
    110.         SmokeScreen,
    111.         ConfuseRay,
    112.         Withdraw,
    113.         DefenseCurl,
    114.         Barrier,
    115.         LightScreen,
    116.         Haze,
    117.         Reflect,
    118.         FocusEnergy,
    119.         Bide,
    120.         Metronome,
    121.         MirrorMove,
    122.         Selfdestruct,
    123.         EggBomb,
    124.         Lick,
    125.         Smog,
    126.         Sludge,
    127.         BoneClub,
    128.         FireBlast,
    129.         Waterfall,
    130.         Clamp,
    131.         Swift,
    132.         SkullBash,
    133.         SpikeCannon,
    134.         Constrict,
    135.         Amnesia,
    136.         Kinesis,
    137.         Softboiled,
    138.         HiJumpKick,
    139.         Glare,
    140.         DreamEater,
    141.         PoisonGas,
    142.         Barrage,
    143.         LeechLife,
    144.         LovelyKiss,
    145.         SkyAttack,
    146.         Transform,
    147.         Bubble,
    148.         DizzyPunch,
    149.         Spore,
    150.         Flash,
    151.         Psywave,
    152.         Splash,
    153.         AcidArmor,
    154.         Crabhammer,
    155.         Explosion,
    156.         FurySwipes,
    157.         Bonemerang,
    158.         Rest,
    159.         RockSlide,
    160.         HyperFang,
    161.         Sharpen,
    162.         Conversion,
    163.         TriAttack,
    164.         SuperFang,
    165.         Slash,
    166.         Substitute,
    167.         Struggle,
    168.         Sketch,
    169.         TripleKick,
    170.         Thief,
    171.         SpiderWeb,
    172.         MindReader,
    173.         Nightmare,
    174.         FlameWheel,
    175.         Snore,
    176.         Curse,
    177.         Flail,
    178.         Conversion2,
    179.         Aeroblast,
    180.         CottonSpore,
    181.         Reversal,
    182.         Spite,
    183.         PowderSnow,
    184.         Protect,
    185.         MachPunch,
    186.         ScaryFace,
    187.         FaintAttack,
    188.         SweetKiss,
    189.         BellyDrum,
    190.         SludgeBomb,
    191.         Mud_Slap,
    192.         Octazooka,
    193.         Spikes,
    194.         ZapCannon,
    195.         Foresight,
    196.         DestinyBond,
    197.         PerishSong,
    198.         IcyWind,
    199.         Detect,
    200.         BoneRush,
    201.         Lock_On,
    202.         Outrage,
    203.         Sandstorm,
    204.         GigaDrain,
    205.         Endure,
    206.         Charm,
    207.         Rollout,
    208.         FalseSwipe,
    209.         Swagger,
    210.         MilkDrink,
    211.         Spark,
    212.         FuryCutter,
    213.         SteelWing,
    214.         MeanLook,
    215.         Attract,
    216.         SleepTalk,
    217.         HealBell,
    218.         Return,
    219.         Present,
    220.         Frustration,
    221.         Safeguard,
    222.         PainSplit,
    223.         SacredFire,
    224.         Magnitude,
    225.         DynamicPunch,
    226.         Megahorn,
    227.         DragonBreath,
    228.         BatonPass,
    229.         Encore,
    230.         Pursuit,
    231.         RapidSpin,
    232.         SweetScent,
    233.         IronTail,
    234.         MetalClaw,
    235.         VitalThrow,
    236.         MorningSun,
    237.         Synthesis,
    238.         Moonlight,
    239.         HiddenPower,
    240.         CrossChop,
    241.         Twister,
    242.         RainDance,
    243.         SunnyDay,
    244.         Crunch,
    245.         MirrorCoat,
    246.         PsychUp,
    247.         ExtremeSpeed,
    248.         AncientPower,
    249.         ShadowBall,
    250.         FutureSight,
    251.         RockSmash,
    252.         Whirlpool,
    253.         BeatUp,
    254.         FakeOut,
    255.         Uproar,
    256.         Stockpile,
    257.         SpitUp,
    258.         Swallow,
    259.         HeatWave,
    260.         Hail,
    261.         Torment,
    262.         Flatter,
    263.         Will_O_Wisp,
    264.         Memento,
    265.         Facade,
    266.         FocusPunch,
    267.         SmellingSalt,
    268.         FollowMe,
    269.         NaturePower,
    270.         Charge,
    271.         Taunt,
    272.         HelpingHand,
    273.         Trick,
    274.         RolePlay,
    275.         Wish,
    276.         Assist,
    277.         Ingrain,
    278.         Superpower,
    279.         MagicCoat,
    280.         Recycle,
    281.         Revenge,
    282.         BrickBreak,
    283.         Yawn,
    284.         KnockOff,
    285.         Endeavor,
    286.         Eruption,
    287.         SkillSwap,
    288.         Imprison,
    289.         Refresh,
    290.         Grudge,
    291.         Snatch,
    292.         SecretPower,
    293.         Dive,
    294.         ArmThrust,
    295.         Camouflage,
    296.         TailGlow,
    297.         LusterPurge,
    298.         MistBall,
    299.         FeatherDance,
    300.         TeeterDance,
    301.         BlazeKick,
    302.         MudSport,
    303.         IceBall,
    304.         NeedleArm,
    305.         SlackOff,
    306.         HyperVoice,
    307.         PoisonFang,
    308.         CrushClaw,
    309.         BlastBurn,
    310.         HydroCannon,
    311.         MeteorMash,
    312.         Astonish,
    313.         WeatherBall,
    314.         Aromatherapy,
    315.         FakeTears,
    316.         AirCutter,
    317.         Overheat,
    318.         OdorSleuth,
    319.         RockTomb,
    320.         SilverWind,
    321.         MetalSound,
    322.         GrassWhistle,
    323.         Tickle,
    324.         CosmicPower,
    325.         WaterSpout,
    326.         SignalBeam,
    327.         ShadowPunch,
    328.         Extrasensory,
    329.         SkyUppercut,
    330.         SandTomb,
    331.         SheerCold,
    332.         MuddyWater,
    333.         BulletSeed,
    334.         AerialAce,
    335.         IcicleSpear,
    336.         IronDefense,
    337.         Block,
    338.         Howl,
    339.         DragonClaw,
    340.         FrenzyPlant,
    341.         BulkUp,
    342.         Bounce,
    343.         MudShot,
    344.         PoisonTail,
    345.         Covet,
    346.         VoltTackle,
    347.         MagicalLeaf,
    348.         WaterSport,
    349.         CalmMind,
    350.         LeafBlade,
    351.         DragonDance,
    352.         RockBlast,
    353.         ShockWave,
    354.         WaterPulse,
    355.         DoomDesire,
    356.         PsychoBoost,
    357.         Roost,
    358.         Gravity,
    359.         MiracleEye,
    360.         Wake_UpSlap,
    361.         HammerArm,
    362.         GyroBall,
    363.         HealingWish,
    364.         Brine,
    365.         NaturalGift,
    366.         Feint,
    367.         Pluck,
    368.         Tailwind,
    369.         Acupressure,
    370.         MetalBurst,
    371.         U_turn,
    372.         CloseCombat,
    373.         Payback,
    374.         Assurance,
    375.         Embargo,
    376.         Fling,
    377.         PsychoShift,
    378.         TrumpCard,
    379.         HealBlock,
    380.         WringOut,
    381.         PowerTrick,
    382.         GastroAcid,
    383.         LuckyChant,
    384.         MeFirst,
    385.         Copycat,
    386.         PowerSwap,
    387.         GuardSwap,
    388.         Punishment,
    389.         LastResort,
    390.         WorrySeed,
    391.         SuckerPunch,
    392.         ToxicSpikes,
    393.         HeartSwap,
    394.         AquaRing,
    395.         MagnetRise,
    396.         FlareBlitz,
    397.         ForcePalm,
    398.         AuraSphere,
    399.         RockPolish,
    400.         PoisonJab,
    401.         DarkPulse,
    402.         NightSlash,
    403.         AquaTail,
    404.         SeedBomb,
    405.         AirSlash,
    406.         X_Scissor,
    407.         BugBuzz,
    408.         DragonPulse,
    409.         DragonRush,
    410.         PowerGem,
    411.         DrainPunch,
    412.         VacuumWave,
    413.         FocusBlast,
    414.         EnergyBall,
    415.         BraveBird,
    416.         EarthPower,
    417.         Switcheroo,
    418.         GigaImpact,
    419.         NastyPlot,
    420.         BulletPunch,
    421.         Avalanche,
    422.         IceShard,
    423.         ShadowClaw,
    424.         ThunderFang,
    425.         IceFang,
    426.         FireFang,
    427.         ShadowSneak,
    428.         MudBomb,
    429.         PsychoCut,
    430.         ZenHeadbutt,
    431.         MirrorShot,
    432.         FlashCannon,
    433.         RockClimb,
    434.         Defog,
    435.         TrickRoom,
    436.         DracoMeteor,
    437.         Discharge,
    438.         LavaPlume,
    439.         LeafStorm,
    440.         PowerWhip,
    441.         RockWrecker,
    442.         CrossPoison,
    443.         GunkShot,
    444.         IronHead,
    445.         MagnetBomb,
    446.         StoneEdge,
    447.         Captivate,
    448.         StealthRock,
    449.         GrassKnot,
    450.         Chatter,
    451.         Judgment,
    452.         BugBite,
    453.         ChargeBeam,
    454.         WoodHammer,
    455.         AquaJet,
    456.         AttackOrder,
    457.         DefendOrder,
    458.         HealOrder,
    459.         HeadSmash,
    460.         DoubleHit,
    461.         RoarofTime,
    462.         SpacialRend,
    463.         LunarDance,
    464.         CrushGrip,
    465.         MagmaStorm,
    466.         DarkVoid,
    467.         SeedFlare,
    468.         OminousWind,
    469.         ShadowForce,
    470.         HoneClaws,
    471.         WideGuard,
    472.         GuardSplit,
    473.         PowerSplit,
    474.         WonderRoom,
    475.         Psyshock,
    476.         Venoshock,
    477.         Autotomize,
    478.         RagePowder,
    479.         Telekinesis,
    480.         MagicRoom,
    481.         SmackDown,
    482.         StormThrow,
    483.         FlameBurst,
    484.         SludgeWave,
    485.         QuiverDance,
    486.         HeavySlam,
    487.         Synchronoise,
    488.         ElectroBall,
    489.         Soak,
    490.         FlameCharge,
    491.         Coil,
    492.         LowSweep,
    493.         AcidSpray,
    494.         FoulPlay,
    495.         SimpleBeam,
    496.         Entrainment,
    497.         AfterYou,
    498.         Round,
    499.         EchoedVoice,
    500.         ChipAway,
    501.         ClearSmog,
    502.         StoredPower,
    503.         QuickGuard,
    504.         AllySwitch,
    505.         Scald,
    506.         ShellSmash,
    507.         HealPulse,
    508.         Hex,
    509.         SkyDrop,
    510.         ShiftGear,
    511.         CircleThrow,
    512.         Incinerate,
    513.         Quash,
    514.         Acrobatics,
    515.         ReflectType,
    516.         Retaliate,
    517.         FinalGambit,
    518.         Bestow,
    519.         Inferno,
    520.         WaterPledge,
    521.         FirePledge,
    522.         GrassPledge,
    523.         VoltSwitch,
    524.         StruggleBug,
    525.         Bulldoze,
    526.         FrostBreath,
    527.         DragonTail,
    528.         WorkUp,
    529.         Electroweb,
    530.         WildCharge,
    531.         DrillRun,
    532.         DualChop,
    533.         HeartStamp,
    534.         HornLeech,
    535.         SacredSword,
    536.         RazorShell,
    537.         HeatCrash,
    538.         LeafTornado,
    539.         Steamroller,
    540.         CottonGuard,
    541.         NightDaze,
    542.         Psystrike,
    543.         TailSlap,
    544.         Hurricane,
    545.         HeadCharge,
    546.         GearGrind,
    547.         SearingShot,
    548.         TechnoBlast,
    549.         RelicSong,
    550.         SecretSword,
    551.         Glaciate,
    552.         BoltStrike,
    553.         BlueFlare,
    554.         FieryDance,
    555.         FreezeShock,
    556.         IceBurn,
    557.         Snarl,
    558.         IcicleCrash,
    559.         V_create,
    560.         FusionFlare,
    561.         FusionBolt
    562.     };
    563.  
    564.     enum Items {
    565.         NoItem,
    566.         BigRoot,
    567.         BlueScarf,
    568.         BrightPowder,
    569.         ChoiceBand,
    570.         ChoiceScarf,
    571.         ChoiceSpecs,
    572.         DestinyKnot,
    573.         ExpertBelt,
    574.         FocusBand,
    575.         FocusSash,
    576.         FullIncense,
    577.         GreenScarf,
    578.         LaggingTail,
    579.         LaxIncense,
    580.         Leftovers,
    581.         LuckIncense,
    582.         MentalHerb,
    583.         MetalPowder,
    584.         MuscleBand,
    585.         OddIncense,
    586.         PinkScarf,
    587.         PowerHerb,
    588.         PureIncense,
    589.         QuickPowder,
    590.         ReaperCloth,
    591.         RedScarf,
    592.         RockIncense,
    593.         RoseIncense,
    594.         SeaIncense,
    595.         ShedShell,
    596.         SilkScarf,
    597.         SilverPowder,
    598.         SmoothRock,
    599.         SoftSand,
    600.         SootheBell,
    601.         WaveIncense,
    602.         WhiteHerb,
    603.         WideLens,
    604.         WiseGlasses,
    605.         YellowScarf,
    606.         ZoomLens,
    607.         AmuletCoin,
    608.         Antidote,
    609.         Awakening,
    610.         BerryJuice,
    611.         BigPearl,
    612.         BigMushroom,
    613.         BlackBelt,
    614.         BlackFlute,
    615.         BlackSludge,
    616.         BlackGlasses,
    617.         BlueFlute,
    618.         BlueShard,
    619.         BurnHeal,
    620.         Calcium,
    621.         Carbos,
    622.         Charcoal,
    623.         CleanseTag,
    624.         DampMulch,
    625.         DeepSeaScale,
    626.         DireHit,
    627.         DragonScale,
    628.         Elixir,
    629.         EnergyRoot,
    630.         EnergyPowder,
    631.         EscapeRope,
    632.         Ether,
    633.         Everstone,
    634.         ExpShare,
    635.         FireStone,
    636.         FlameOrb,
    637.         FluffyTail,
    638.         FreshWater,
    639.         FullHeal,
    640.         FullRestore,
    641.         GooeyMulch,
    642.         GreenShard,
    643.         GrowthMulch,
    644.         GuardSpec,
    645.         HealPowder,
    646.         HeartScale,
    647.         Honey,
    648.         HPUp,
    649.         HyperPotion,
    650.         IceHeal,
    651.         Iron,
    652.         KingsRock,
    653.         LavaCookie,
    654.         LeafStone,
    655.         Lemonade,
    656.         LifeOrb,
    657.         LightBall,
    658.         LightClay,
    659.         LuckyEgg,
    660.         Magnet,
    661.         MaxElixir,
    662.         MaxEther,
    663.         MaxPotion,
    664.         MaxRepel,
    665.         MaxRevive,
    666.         MetalCoat,
    667.         MetronomeItem,
    668.         MiracleSeed,
    669.         MooMooMilk,
    670.         MoonStone,
    671.         MysticWater,
    672.         NeverMeltIce,
    673.         Nugget,
    674.         OldGateau,
    675.         ParlyzHeal,
    676.         Pearl,
    677.         PokeDoll,
    678.         Potion,
    679.         PPMax,
    680.         PPUp,
    681.         Protein,
    682.         RareCandy,
    683.         RazorFang,
    684.         RedFlute,
    685.         RedShard,
    686.         Repel,
    687.         RevivalHerb,
    688.         Revive,
    689.         SacredAsh,
    690.         ScopeLens,
    691.         ShellBell,
    692.         ShoalSalt,
    693.         ShoalShell,
    694.         SmokeBall,
    695.         SodaPop,
    696.         SoulDew,
    697.         SpellTag,
    698.         StableMulch,
    699.         StarPiece,
    700.         Stardust,
    701.         SunStone,
    702.         SuperPotion,
    703.         SuperRepel,
    704.         Thunderstone,
    705.         TinyMushroom,
    706.         ToxicOrb,
    707.         TwistedSpoon,
    708.         UpGrade,
    709.         WaterStone,
    710.         WhiteFlute,
    711.         XAccuracy,
    712.         XAttack,
    713.         XDefend,
    714.         XSpecial,
    715.         XSpDef,
    716.         XSpeed,
    717.         YellowFlute,
    718.         YellowShard,
    719.         Zinc,
    720.         IcyRock,
    721.         LuckyPunch,
    722.         DubiousDisc,
    723.         SharpBeak,
    724.         AdamantOrb,
    725.         DampRock,
    726.         HeatRock,
    727.         LustrousOrb,
    728.         MachoBrace,
    729.         Stick,
    730.         DragonFang,
    731.         PoisonBarb,
    732.         PowerAnklet,
    733.         PowerBand,
    734.         PowerBelt,
    735.         PowerBracer,
    736.         PowerLens,
    737.         PowerWeight,
    738.         DawnStone,
    739.         DuskStone,
    740.         Electirizer,
    741.         Magmarizer,
    742.         OddKeystone,
    743.         OvalStone,
    744.         Protector,
    745.         QuickClaw,
    746.         RazorClaw,
    747.         ShinyStone,
    748.         StickyBarb,
    749.         DeepSeaTooth,
    750.         DracoPlate,
    751.         DreadPlate,
    752.         EarthPlate,
    753.         FistPlate,
    754.         FlamePlate,
    755.         GripClaw,
    756.         IciclePlate,
    757.         InsectPlate,
    758.         IronPlate,
    759.         MeadowPlate,
    760.         MindPlate,
    761.         SkyPlate,
    762.         SplashPlate,
    763.         SpookyPlate,
    764.         StonePlate,
    765.         ThickClub,
    766.         ToxicPlate,
    767.         ZapPlate,
    768.         ArmorFossil,
    769.         ClawFossil,
    770.         DomeFossil,
    771.         HardStone,
    772.         HelixFossil,
    773.         OldAmber,
    774.         RareBone,
    775.         RootFossil,
    776.         SkullFossil,
    777.         IronBall,
    778.         GriseousOrb,
    779.         AirMail,
    780.         BloomMail,
    781.         BrickMail,
    782.         BubbleMail,
    783.         FlameMail,
    784.         GrassMail,
    785.         HarborMail,
    786.         HeartMail,
    787.         MosaicMail,
    788.         SnowMail,
    789.         SpaceMail,
    790.         SteelMail,
    791.         TunnelMail,
    792.         DouseDrive,
    793.         ShockDrive,
    794.         BurnDrive,
    795.         ChillDrive,
    796.         HeartSweets,
    797.         CleanScale,
    798.         EvolutionStone,
    799.         PumiceStone,
    800.         RuggedHelmet,
    801.         Balloon,
    802.         RedCard,
    803.         BullsEye,
    804.         PressureBand,
    805.         Bulb,
    806.         RechargeableBattery,
    807.         EscapeButton,
    808.         FireJewel,
    809.         WaterJewel,
    810.         ElectricJewel,
    811.         GrassJewel,
    812.         IceJewel,
    813.         FightJewel,
    814.         PoisonJewel,
    815.         EarthJewel,
    816.         FlightJewel,
    817.         PsychicJewel,
    818.         Bugjewel,
    819.         RockJewel,
    820.         GhostJewel,
    821.         DragonJewel,
    822.         DarkJewel,
    823.         SteelJewel,
    824.         NormalJewel,
    825.         StrengthWing,
    826.         PowerWing,
    827.         ResistanceWing,
    828.         WisdomWing,
    829.         MindWing,
    830.         InstantWing,
    831.         BeautifulWing,
    832.         DreamBall,
    833.         FragrantMushroom,
    834.         HugeGoldOrb,
    835.         RoundPearl,
    836.         CometPiece,
    837.         AncientBronzeCoin,
    838.         AncientSilverCoin,
    839.         AncientGoldCoin,
    840.         AncientVase,
    841.         AncientBracelet,
    842.         AncientStatue,
    843.         AncientCrown,
    844.         HiunIceCream,
    845.         DireHit2,
    846.         XSpeed2,
    847.         XSpecial2,
    848.         XSpDef2,
    849.         XDefend2,
    850.         XAttack2,
    851.         XAccuracy2,
    852.         XSpeed3,
    853.         XSpecial3,
    854.         XSpDef3,
    855.         XDefend3,
    856.         XAttack3,
    857.         XAccuracy3,
    858.         XSpeed6,
    859.         XSpecial6,
    860.         XSpDef6,
    861.         XDefend6,
    862.         XAttack6,
    863.         XAccuracy6,
    864.         SkillCall,
    865.         ItemDrop,
    866.         ItemCall,
    867.         FlatCall,
    868.         DireHit3,
    869.         BerserkGene
    870.     };
    871.  
    [/secret]

    Field

    You can access the battle field with battle.field.

    Pokemon on the field are numbered from 0 to 1 if in singles: 0 is the pokemon of player 0, 1 is the pokemon of player 1.

    In doubles, 0 & 2 are the 2 pokemon of player 0, and 1 & 3 are the two pokemon of player 4

    Functions
    field.poke(int fieldSlot) <- the FieldPokemon corresponding to the slot on the field
    field.zone(int player) <- the Zone corresponding to the player (zone contains info about spikes, ...)

    Properties
    field.weather <- the current weather (emits weatherChanged when changed, so use field.weatherChanged.connect(function(){what to do when weather changes}) when you want to know if the weather chagned)

    Enums
    Code (c++):
    1.  
    2.         NormalWeather = 0,
    3.         Hail = 1,
    4.         Rain = 2,
    5.         SandStorm = 3,
    6.         Sunny = 4
    Zone

    Contains info about tspikes, spikes, rocks. Later may contain info about screens (or you can deduce it yourself from the battle log)

    Properties
    zone.spikes <- Spikes level (spikesChanged emitted when changed, use spikesChanged.connect(function(){}) to detect it)
    zone.toxicSpikes <- Toxic Spikes level (tspikesChanged emitted when changed)
    zone.stealthRocks <- Stealth Rocks (zone.rocksChanged emitted when changed)


    FieldPokemon

    Those can be accessed using the Field. They contain Pokemon information (relative to the team pokemon), as well as field information (substitute, visible, ...)

    Functions
    fpoke.statBoost(int stat);
    fpoke.stat(int stat);

    Properties
    fpoke.onTheField (onTheFieldChanged)
    fpoke.substitute (substituteChanged)
    fpoke.showing (showingChanged) <- Is the poke showing (could it be under ground?)
    fpoke.alternateSprite (alternateSpriteChanged) <- Is the poke transformed, or like cherrim in the sun, and what sprite does it have now?
    fpoke.pokemon (pokemonChanged) <- Current team Pokemon on the field. Contains plenty of information (moves, hp, pps, gender, level, nickname, etc.) . May differ from corresponding team pokemon (if used transform, moves / ability differ etc)

    Team

    Team can be accessed via battle.data.team(player) (with player being battle.me or battle.opponent)

    Properties
    team.name <- Name of the trainer
    team.time (timeChanged) <- time left

    Functions
    team.pokemon(i) <- Pokemon of the team at slot (i). The pokemon on the field is always at slot 0 (ofc in case of doubles it can be 0/1, triples 0/1/2, ...)

    Pokemon

    Contains info about pokemon. At the time of writing this, moves can't be yet accessed, but it requires minimum changes in the code.

    A pokemon can be accessed via battle.data.team(player).poke(slot), or battle.data.field.poke(fieldSlot).pokemon

    Properties
    poke.nick (pokemonReset) <- nick of the pokemon
    poke.status (statusChanged) <- status of the pokemon
    poke.num (numChanged) <- num of the pokemon
    poke.shiny (pokemonReset) <- is the poke shiny
    poke.gender (pokemonReset) <- gender of the pokemon
    poke.level (pokemonReset) <- level of the pokemon
    poke.numRef (numChanged) <- num of the pokemon, as an int
    poke.life (lifeChanged) <- life of the pokemon (in HP if its yours, otherwise percent)
    poke.lifePercent (lifeChanged) <- life of the pokemon in percent
    poke.item (itemChanged) <- the item of the pokemon - crashes if you call it on the foe
    poke.happiness, poke.nature (pokemonReset)

    Functions
    poke.isKoed() <- is the pokemon ko?
    poke.move(i) <- The Move at slot i

    Enums

    Code (c++):
    1.     enum Status {
    2.         Koed = Pokemon::Koed,
    3.         Paralysed = Pokemon::Paralysed,
    4.         Asleep = Pokemon::Asleep,
    5.         Burnt = Pokemon::Burnt,
    6.         Frozen = Pokemon::Frozen,
    7.         Fine = Pokemon::Fine,
    8.         Poisoned = Pokemon::Poisoned
    9.     };
    10.  
    11.     Q_ENUMS(Status)
    Move

    Properties

    move.num <- num of the move
    move.PP
    move.totalPP

    BattleChoice

    This is the parameter of battle.battleCommand(battle.id, BattleChoice). Call that on onChoiceSelection or onChoiceCancellataion to choose a move to do.

    it contains two mandatory parameters: the type of the choice, and the field slot you do it for.

    Examples:

    {"slot":battle.me, "type":"tie"} //requests tie
    {"slot":battle.me, "type":"cancel"} //requests move cancel
    {"slot":battle.me, "type":"shiftcenter"} //in triples move pokemon to center
    {"slot":battle.me, "type":"attack", "attackSlot": 2, "target":battle.opp} //requests attack using attackSlot and targetting target
    {"slot":battle.me, "type":"switch", "pokeSlot": 5} //requests switch to last pokemon (5 is the last one)
    {"slot":battle.me, "type":"rearrange", "neworder":[2,1,0,3,4,5]} //rearranges team for wifi clause with the 3rd pokemon in first slot

    Though you can use battle.attackClicked(int spot) or battle.switchClicked(int spot) if you want the changes to reflect in the GUI. But if you do an invalid switch / attack, the gui will probably stop it before even sending it and so the server won't tell you you did an invalid move (as detected in onCancellation), so you'd have to work around that.
     
    Last edited: Jul 14, 2012
  2. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    So, when scripting, you have two ways of detecting changes:

    1) Use battle events, like usual.
    2) Use the property change notifications. For example, if you want to detect when a pokemon changes status, you can do battle.field.poke(0).pokemon.statusChanged.connect(function() { print("The status of the pokemon 0 has changed.");});

    For now, the changes happen before the battle events. I could change that, and even change the battle events : instead of being onXxx, it could be beforeXxx, property changes & signals, afterXxx. It's a trivial changed (like ~15 lines of codes in the source?) , and I will do it if users ask for it.

    The script capabilities come primarly from the new battle window. Also, any improvement to the new battle window storage (it can already detect weather moves, but it could keep track of the moves & PPs of your opponents) would directly be reflected in the script capabilities. And the reverse too. So you are encouraged to code improvements =)

    That's all for now, will edit in later when theres more stuff availabe. Here is a stupid script that works very well for now (change Indigo Plateau with the channel you're in).

    [secret]
    Code (javascript):
    1. /* Files in the Scripts folder in appdata containing songs lyrics */
    2. var files = ["kids.txt", "lapd.txt", "job.txt", "defy.txt", "fly.txt", "gone.txt", "all.txt", "repeat.txt", "come.txt", "esteem.txt"];
    3. var song = sys.getFileContent(sys.scriptsFolder+files[sys.rand(0, files.length)]);
    4. song = song.split('\n');
    5. var songIndex = 0;
    6. var play = false;
    7. var useAI=true;
    8.  
    9. var channel = client.channelId("Indigo Plateau");
    10.  
    11. var nick = function(spot) { return battle.data.field.poke(spot).pokemon.nick; };
    12. var verb = false;
    13. var send = function(msg) {
    14.    if (!verb) /*print (msg)*/;
    15.    else client.network().sendChanMessage(channel, msg);
    16. };
    17.  
    18. var poke = function(spot) { return battle.data.team(spot).poke(0);};
    19. var fpoke = function(spot) { return battle.data.field.poke(spot);};
    20. var tpoke = function(ind) { return battle.data.team(battle.me).poke(ind);};
    21.  
    22. var switchSong = function() {
    23.              song = sys.getFileContent(sys.scriptsFolder+files[sys.rand(0, files.length)]);
    24.                 song = song.split('\n');
    25.                 songIndex = 0;
    26.              play = true;
    27. };
    28.  
    29. ({
    30. onBeginTurn : function(turn) {
    31.     send("Turn " + turn + " of the battle!");
    32.     if (!play) return;
    33.     battle.battleMessage(battle.id, "♫  " + song[songIndex] + " ♪ ♫");
    34.     songIndex ++;
    35.     if (songIndex >= song.length) {
    36.         battle.battleMessage(battle.id, "------ YEAH ------");
    37.         switchSong();
    38.     }
    39. },
    40. onKo : function(spot) {
    41.     send("Oh no! " + nick(spot) + " fainted!");
    42. },
    43. onDamageDone: function(spot, damage) {
    44.     if (spot == battle.me) {
    45.         send(":(( My " + nick(spot) + " lost " + damage + " HP!");
    46.     } else {
    47.         send(nick(spot) + " lost " + damage + "% ;D !");
    48.     }
    49. },
    50. onChoiceSelection: function(player) {
    51.     if (player!=battle.me || !useAI) {
    52.         return;
    53.     }
    54.     var switches = [];
    55.     for (var i = 1; i < 6; i++) {
    56.         if (!tpoke(i).isKoed()) {
    57.            switches.push(i);
    58.         }
    59.     }
    60.  
    61.    var r = sys.rand(0, 8);
    62.  
    63.     if (r == 0 || (fpoke(battle.me).onTheField && !poke(battle.me).isKoed() && (r != 1 || switches.length == 0))) {
    64.         choice = {"slot": battle.me, "type":"attack", "attackSlot":sys.rand(0,4)};
    65.     } else {
    66.         var cswitch = switches[sys.rand(0,switches.length)];
    67.    
    68.         choice = {"slot": battle.me, "type":"switch", "pokeSlot": cswitch};
    69.     }
    70.     battle.battleCommand(battle.id, choice);
    71. },
    72. onChoiceCancellation: function(player) {
    73.     this.onChoiceSelection(player);
    74. },
    75. onDrawRequest: function (player) {
    76.     this.onChoiceCancelled(player);
    77. },
    78. onChoiceCancelled: function(player) {
    79. //    print ("old useAI: " + useAI);
    80.     useAI = !useAI;
    81.     print ("new useAI: " + useAI);
    82. }
    83. ,
    84. onPlayerMessage: function(player, message) {
    85.     if (player == battle.me) {
    86.         if (message == "annoy") {
    87.             verb = true;
    88.         } else if (message == "debug") {
    89.             verb = false;
    90.         } else if (message == "switch") {
    91.                 switchSong();
    92.         } else if (message == "off") {
    93.              play = false;
    94.         } else if (message.substr(0, 5) == "eval ") {
    95.              sys.eval(message.substr(5));
    96.         }
    97.     }
    98. }
    99. })
    [/secret]
     
    Last edited: Dec 3, 2012
  3. Arceus

    Arceus Member

    Joined:
    May 20, 2010
    Messages:
    238
    Likes Received:
    0
    If I wanted to say change the weather, would I use the onBeginTurn event or is the some other event I'd use? I'd like to make my Chaos Tier more chaotic by changing the weather randomly if possible.
     
  4. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    This is for the client, not the server. Sorry ^^
     
  5. eric the espeon

    eric the espeon is an espeon.

    Joined:
    Apr 21, 2010
    Messages:
    853
    Likes Received:
    1
    Oh yes. I cannot wait for there to be a few battle bots, maybe even an AI league :).
     
  6. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    How would you get your opponents player id (using client.id)
     
  7. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    client.id(battle.data.team(battle.opp).name)

    just wrap it in a function :x
     
  8. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    Is it possible to choose Struggle by battle scripts when it is possible?
     
  9. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    I don't know, did you try?
     
  10. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    Of course. Struggle is not chosen if scripts choose a moveslot (0~3). I made a script to choose a random move and it just tried to attack endlessly; I stopped it after several thousand tries and Struggle was not chosen, lol.
     
  11. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
  12. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    How can you detect Baton Pass / U-turn / Volt Switch switch-outs?
     
  13. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    Can you be more specific?

    You should detect the switch request in any case. To differentiate it from another switch request, you can check if the life of your pokemon is > 0.
     
  14. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    I've automated metro battles between (with no tactics/strategy) two clients (using same script) apart from these switch-outs.

    I don't know how to detect the switch request. I used choice selection for after KOs.
     
  15. Wanderer M

    Wanderer M Dancer

    Joined:
    Sep 14, 2011
    Messages:
    36
    Likes Received:
    0
    PO Trainer Name:
    Wanderer M
    You could try
    Code (text):
    1. void onUseAttack(int spot, int attack, bool silent);
    to check for Volt Switch / U-turn / Baton Pass.
     
  16. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    Code (javascript):
    1. onChoiceSelection: function(player) {
    2.     if (player!=battle.me || !useAI) {
    3.         return;
    4.     }
    5.     var switches = [];
    6.     for (var i = 1; i < 6; i++) {
    7.         if (!tpoke(i).isKoed()) {
    8.            switches.push(i);
    9.         }
    10.     }
    11.  
    12.    var r = sys.rand(0, 8);
    13.  
    14.     if (r == 0 || (fpoke(battle.me).onTheField && !poke(battle.me).isKoed() && (r != 1 || switches.length == 0))) {
    15.         choice = {"slot": battle.me, "type":"attack", "attackSlot":sys.rand(0,4)};
    16.     } else {
    17.         var cswitch = switches[sys.rand(0,switches.length)];
    18.    
    19.         choice = {"slot": battle.me, "type":"switch", "pokeSlot": cswitch};
    20.     }
    21.     battle.battleCommand(battle.id, choice);
    22. },
    That's what I use. The onChoiceSelection event.
     
  17. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    When U-Turn/Volt Switch/Baton Pass is used, that script usually chooses attacking rather than switching, so the choice is cancelled. onChoiceCancellation event may solve it.

    If you rearrange the team by scripts, changes are not shown in the client. Actually, the team window stays opened until you close it and the client shows your first Pokemon is the one which was the first. Is there a way to prevent this?
     
  18. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    Ah. I see. I managed to solve my problem by guessing and testing here anyway.
     
  19. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    Make it an issue in the PO github repo I guess
     
  20. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    Is there a way to get the size of a player's team at the beginning of a battle without having to check whether spot 1,2,3,4 or 5 have a pokemon in them?
     
  21. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
  22. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    Is it possible to get your opponent's nickname somehow?
     
  23. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    battle.data.team(battle.opponent).name
     
  24. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    lol, I found out it and forgot to delete my post.
     
  25. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    191
    PO Trainer Name:
    SongSing
    Is there a way to get an opp's full team in wifi? It seems to only allow you to see pokes that have already been sent out (in case it's no preview, I'm assuming). But for wifi, is there still no way to do this? :0
     
  26. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    it's one of the few things not done:

    Code (cpp):
    1. /***
    2.   Todo:
    3.   Convert the following to script value so that functions can be complete:
    4.     makeEvent("onDynamicInfo", spot, const BattleDynamicInfo &info);
    5.     makeEvent("onOfferChoice", player, const BattleChoices &choice);
    6.     makeEvent("onRearrangeTeam", player, const ShallowShownTeam& team);
    7.     makeEvent("onDynamicStats", spot, const BattleStats& stats);
    8.     makeEvent("onTeamOrderChosen", player, const RearrangeChoice &rearrange);
    9. ***/
     
  27. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    191
    PO Trainer Name:
    SongSing
    Oh, okay :x
     
  28. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Is it possible to change the format of the text that is printed and edit the output as well? I mean, just for me to see. Unless my opponent has the same script.

    For example:

    I have only used quite a bit of JavaScript and little Microsoft Visual Basic. So I'm kind of learning. :smile:

    I often miss seeing the Perish Count warning, due to it being a bit transparent on my screen.
     
  29. Yttrium

    Yttrium Well-Known Member Developer Developer

    Joined:
    Sep 29, 2010
    Messages:
    619
    Likes Received:
    283
    PO Trainer Name:
    Yttrium
    Is there a way to detect forfeits? I seem to crash if I forfeit while the script is battling :x
     
  30. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Is there any way to see if the zone is under gravity, foresight, or helping hand?
     
  31. Zzyzx Road

    Zzyzx Road Member

    Joined:
    Feb 16, 2012
    Messages:
    572
    Likes Received:
    2
    PO Trainer Name:
    Zzyzx Road
    It may sound stupid but I didn't find an OnBattleStart or similar event. How can I place a trigger right after teams are set? Would I have to make use of the first OnSendOut event instead?

    Edit: Also, can I see/reorder the team in WiFi battles via scripts?
     
    Last edited: Jan 31, 2014
  32. Silone

    Silone Kanade <3

    Joined:
    Jul 31, 2013
    Messages:
    265
    Likes Received:
    3
    PO Trainer Name:
    Silone
    If you still need to know, it's the onSendOut because it triggers after the preview teams or whatever it's called.

    Read the op it says:
    for reordering
     
  33. Zzyzx Road

    Zzyzx Road Member

    Joined:
    Feb 16, 2012
    Messages:
    572
    Likes Received:
    2
    PO Trainer Name:
    Zzyzx Road
    Awesome! I don't know how I missed it in the OP though...

    Thanks.
     
  34. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    In which event do you have to send the rearrange command, in case of Wifi clause?
     
  35. Hawkings

    Hawkings New Member

    Joined:
    Mar 15, 2014
    Messages:
    3
    Likes Received:
    1
    I have spotted some errors on the article while writing a script. For example, is confusing when you say that battle.opponent is 0 or 1 and is your opponent, actually your opponent is battle.opp, battle.opponent is a funtion that returns the opponent of a given player (for example battle.opponent(battle.opp) is equal to battle.me).

    Also the two things in bold are mistakes too, the first is the same mistake as before and the second is wrong because the name of the function is team.poke(i), not team.pokemon(i).

    I think there are a few more errors, but I can't remember which ones :(

    Thank you for this reference/mini guide, it was really useful for me, and I want to keep it without mistakes :biggrin:
     
    Nightfall Alicorn likes this.
  36. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Just thought I note that some status are giving incorrect integers:
    5 = Poison
    6 = Confused

    I've tested these and are correct:
    1 = Paralysed
    2 = Asleep
     
  37. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    are you saying that poison is displaying 5 or another number?
     
    Nightfall Alicorn likes this.
  38. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    The status pereimeter for onStatus events are incorrect. They return the wrong integer. Also, Koed isn't detected from my tests.

    Coyoette508's list:
    Code (JavaScript):
    1.  
    2. enum Status {
    3.         Koed = Pokemon::Koed,
    4.         Paralysed = Pokemon::Paralysed,
    5.         Asleep = Pokemon::Asleep,
    6.         Burnt = Pokemon::Burnt,
    7.         Frozen = Pokemon::Frozen,
    8.         Fine = Pokemon::Fine,
    9.         Poisoned = Pokemon::Poisoned
    10.     };
    11.  
    The list I've tested and added to GitHub here recently:
     
    Last edited: Sep 13, 2015
  39. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    Coyo posted the wrong list
    Code (C++):
    1.  
    2. enum Status {
    3.         Fine = 0,
    4.         Paralysed = 1,
    5.         Asleep = 2,
    6.         Frozen = 3,
    7.         Burnt = 4,
    8.         Poisoned = 5,
    9.         Confused = 6,
    10.         Attracted = 7,
    11.         Wrapped = 8,
    12.         Nightmared = 9,
    13.         Tormented = 12,
    14.         Disabled = 13,
    15.         Drowsy = 14,
    16.         HealBlocked = 15,
    17.         Sleuthed = 17,
    18.         Seeded = 18,
    19.         Embargoed = 19,
    20.         Requiemed = 20,
    21.         Rooted = 21,
    22.         Koed = 31
    23.     };
    24.  
     
    Nightfall Alicorn likes this.
  40. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Kinda got a scripting issue. I can't get onBattleEnd event to run code if the user of the script closes the battle window or forfeits for my score counter to count loses. I've looked through events for both battle and client, can't find anything. :x