Random Bot Spoiler var useAI=true; var channel = 0; var nick = function(spot) { return battle.data.field.poke(spot).pokemon.nick; }; var verb = false; var send = function(msg) { if (!verb) /*print (msg)*/; else client.network().sendChanMessage(channel, msg); }; var poke = function(spot) { return battle.data.team(spot).poke(0);}; var fpoke = function(spot) { return battle.data.field.poke(spot);}; var tpoke = function(ind) { return battle.data.team(battle.me).poke(ind);}; ({ onBeginTurn : function(turn) { send("Turn " + turn + " of the battle!"); }, onKo : function(spot) { send("Oh no! " + nick(spot) + " fainted!"); }, onDamageDone: function(spot, damage) { if (spot == battle.me) { send(":(( My " + nick(spot) + " lost " + damage + " HP!"); } else { send(nick(spot) + " lost " + damage + "% ;D !"); } }, onChoiceSelection: function(player) { if (player!=battle.me || !useAI) { return; } var switches = []; for (var i = 1; i < 6; i++) { if (!tpoke(i).isKoed()) { switches.push(i); } } var r = sys.rand(0, 8); if (r == 0 || (fpoke(battle.me).onTheField && !poke(battle.me).isKoed() && (r != 1 || switches.length == 0))) { choice = {"slot": battle.me, "type":"attack", "attackSlot":sys.rand(0,4)}; } else { var cswitch = switches[sys.rand(0,switches.length)]; choice = {"slot": battle.me, "type":"switch", "pokeSlot": cswitch}; } battle.battleCommand(battle.id, choice); }, onChoiceCancellation: function(player) { this.onChoiceSelection(player); }, onDrawRequest: function (player) { this.onChoiceCancelled(player); }, onChoiceCancelled: function(player) { // print ("old useAI: " + useAI); useAI = !useAI; print ("new useAI: " + useAI); } , onPlayerMessage: function(player, message) { if (player == battle.me) { if (message == "annoy") { verb = true; } else if (message == "debug") { verb = false; } else if (message.substr(0, 5) == "eval ") { sys.eval(message.substr(5)); } } } }) How do I make it work? Help
If it's the script I think it is, did you paste it in the battle script window? I think 1 or 2 scripts had problems on the github page for battle what I've found. Make sure you copied all the code in the window as well. If I recall reading about it, the auto battle bot only has limited intelligence and selects random moves. I'm not very good at battle scripting I'm afraid. I can only do a bit. Sorry I'm not much more help. I'm more familiar with client scripts.
I'm not here to help you I'm sorry. The idea of a battling bot is simple to think but hard to make true. It seems that this bot you reported is working fine, but I wonder if I can battle it without using 2 different IP. I tried by opening 2 windows but the result is bot Vs bot and I can just watch the battle...any solutions?
try replacing "if (player!=battle.me || !useAI)" with "if (client.ownName() !== "botname" || !useAI)"
Maybe try adding this at top with your name in the quotes under "var useAI=true;" part. Code (JavaScript): if (client.ownName() === "You Name Here") { var useAI = false; }
Thank you both for help, I tried every solution you gave me but with no results. The problem is that when I open 2 windows I can only do 2 things: 1) me vs me 2) bot vs bot The final result would be me vs bot, but I can't figure how to make the code to properly work.
You could, for now. Open 1 window, login, load the battle script, then open a second tab (CTRL+T), log in, then remove code in the second tab then battle yourself. It's a bug with PO where only newest tabs update the script functionality.
I'm not sure what you did though because it works fine for me. Did you place this if (client.ownName() === "yournamehere") { var useAI = false; } after this? var useAI = true; If you didn't it won't work.
Ohhh yes! It works fine now!! I was wrong by putting the code BEFORE var useAI = true; Thank you so much, now it works =)