[Battle Scripting] Lutra's Battle Scripts

Discussion in 'Server and Client Scripting' started by Lutra, Dec 5, 2012.

  1. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    I'm starting my battles scripts off with a metronome playing script. Thanks very much to coyotte508 for his detailed battle scripting guide and Swadnerovicus for their idea to overcome the last hurdle.

    The script is here

    Basically, for a long time, I've wanted to collect the probabilities of a pokemon winning against another in a 1v1 face-off with both pokemon at full health. I started this script with that in mind, but while I was doing the script, I realised there's an opportunity to do both that and maybe make an AI out of it. So that's what I intend to do in the future with this :)

    It's very simple at the moment, and doesn't incorporate any tactics or strategy. All it does is keep attacking until KOed or BP/U-turn/Volt Switched out and then switches in a pokemon randomly out of the remaining unfainted pokemon. I tested it out on the metronome ladder under 'MetronomeWatcher' and it won thanks to my much more competitive team compared to the opponent's and maybe a bit of luck too.

    Feel free to post any suggestions, but for now it's just this metronome script, not any other battle scripts.

    Instructions

    1. Click on Plugins > Plugin Manager and plugin the Script Window if it isn't already (ClientScripting.dll)
    2. Click on Plugins > Script Window.
    3. Click on the Battle scripts tab.
    4. Copy the script and paste it into the window.
    5. Click OK

    Changelogs

    • Began Metronome Script - battles for you if you are in the metronome tier; switches in a Pokemon randomly when required.
    • Support for any team-size.
    • Message displayed to show you are using the script.
    • Script pauses to stop itself flooding.
     
    Last edited: Dec 24, 2012
  2. Dr. Fuji

    Dr. Fuji Active Member

    Joined:
    Mar 8, 2011
    Messages:
    1,471
    Likes Received:
    1
    PO Trainer Name:
    Dr. Fuji
    Well I'm going to do my best to help out this amazing guy and his amazing script!

    Things that could be implemented in future
    - Check for resistances on 2 or more turn attacks. (Solar Beam, Bounce, Fly, Dive, Shadow Force, Ice Ball, Rollout, Dig, Freeze Shock, Ice Burn, Razor Wind)
    - Switch out of perish song/ghost type curse/torment/disable.
    - On death due to struggling switch to pokemon with highest attack in case of imprison. (highest power struggle)
    - Switch out on confusion/cute charm activating.
    - Always switch to a pokemon with a type advantage if possible.
    - Autoclicking Find Battle.
    - Switch in slowest pokemon should trick room be used.
    - Switch in a pokemon immune to sand/hail should it be used.
    - Switching to a faster pokemon if opposing pokemon is <25% hp.
    - Switch out if Neg stats = -2 or more if Hp >50% Including self inflicted (Superpower, draco meteor ect..)
    - Switch in most weakened pokemon should Lunar Dance and other self KO moves be used.
    - Switch in the pokemon that would take the least damage from spikes/stealth rock/toxic spikes should they be on the field (greater chance for rapid spin).

    Lesser Priority: (Individual Pokemon Stuff)
    Switch Cute Charm Clefable/Wigglytuff into opposite sex opponents.
    Switch Intimidate Granbull into pokemon with higher attack then special attack (Snorlax, Dusknoir, other Granbull, Machamp ect.)
    Switch Blissey/Snorlax into pokemon with higher special attack (togekiss, mewtwo ect.)
    Switch No Guard Machamp into evasion boosted pokemon.
    Switch in Swift Swim Poliwrath, Ludicolo/Rain Dish Ludicolo, Dry Skin Jynx if rain dance is used.
    Switch out Dry Skin Jynx should sunny day be used.
    Switch Celebi out of status.
     
    Last edited: Dec 15, 2012
  3. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    PHP:
    1.         metro = tier === "Metronome" ? true : false;
    2.  
    This can be simplified into metro = tier === "Metronome". The (strictly) equals operator returns a boolean.
     
  4. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    Thanks TUO, fixed that. Also, updated with support for all team sizes and a message informing the opponent that this script is being used.
     
  5. Dr. Fuji

    Dr. Fuji Active Member

    Joined:
    Mar 8, 2011
    Messages:
    1,471
    Likes Received:
    1
    PO Trainer Name:
    Dr. Fuji
    haha great ideas I had been manually saying that I was using the script.
     
  6. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    Anyone have any ideas how I could detect the switch-ins following U-turn/Baton Pass/Volt Switch and when struggle is due, which currently results in up to three battle commands being sent consecutively, so it doesn't make someone using this script overactive so easily.
     
  7. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    The scripting plugin needs to be upgraded with providing the choices you have in onOfferChoice (instead of just giving the spot)

    But you can limit the number of commands you send in 1 min to 30 or something.
     
  8. Bomb

    Bomb trying new things..

    Joined:
    Aug 3, 2012
    Messages:
    19
    Likes Received:
    0
    Hi Lutra, i have some doubts about the battle script.

    Asher how i can see the battle in Metronome OU? And why the bot can only asher a movement?
     
  9. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    I don't know what asher means but I think you want:

    Replace
    with
    OR with
    || means OR

    Do you mean you want a command to turn the auto-battling off or just I didn't put in all the checks if not in metronome?

    I've updated with a fix to make sure it checks for metro in the other events and also a way to limit the commands (but it's still buggy, I'm not sure what exactly is causing all the overactivity).
     
    Last edited: Dec 24, 2012
  10. Bomb

    Bomb trying new things..

    Joined:
    Aug 3, 2012
    Messages:
    19
    Likes Received:
    0
    okay, is all I wanted to know, thanks. :D