lespoils Posted July 8, 2007 Share Posted July 8, 2007 My buddy and I were wondering what is the RegExp with .* but it needs to include new lines.Not sure i understand the question. I'm pretty new to AutoIt but maybe i can help Link to comment Share on other sites More sharing options...
Zarox Posted July 8, 2007 Author Share Posted July 8, 2007 Hi, this is my first try at making script with autoit, and it's a FaceBook's pet game automation. i don't use any mouseclick command, so u can do other stuff on your comp while the script is running. In general it works well. it only fights with Ant that are not 2 lvl higher than the pet. There's a little glitch tho, after some time running i get errors from IE.au3. What i'd like is to make it more robust.since this post is mostly about facebook pet game i devided to post it herePlease post comments, ideas or corrections !By the way, I tested it in Internet Explorer 7.0 and it works great. Thanks for the share of your script. It kicks mine in the ass. Link to comment Share on other sites More sharing options...
lespoils Posted July 8, 2007 Share Posted July 8, 2007 Thanks for the reply and the testing I think i've found a way to make it more robust. I use the _IELoadWait ($oIE) function instead of the sleep() one. seems less buggy. I'm now making a script to sell all the unequipped items automatically i'll be posting it when done. the new code follows: expandcollapse popup;Title: Facebook Pets Game bot ;Filename: IE.au3 ;Description: This script plays the Pet game on Facebook. It will do so on and on. ;Author: Patrick Sirois ;Version: 1.0 ;Last Update: july 8th, 2006 ;Requirements: A Facebook account, the Pet game installed, firefox And IE, Autoit v3.2.4.9 ;READ ME ;To make the script work: ; -log on facebook into the pets game page. ; -Go to the main screen where you click Feed,Kill Monster, buy/sell items,... ; -Rightclick in the Pet game frame and choose: this frame -> Open in a new window ; -copy paste the url in a Internet Explorer window, now we have a webpage with only the Petgame inside ; -Run the script, (shift+alt+s) ; -Press Esc to terminate script #include <IE.au3> Global $Paused HotKeySet("{ESC}", "Terminate") HotKeySet("+!s", "Start") ;the script goes on until the ESC key is pressed While 1 Sleep(100) WEnd ;;;;;;;; ;Terminates the script Func Terminate() Exit 0 EndFunc ;This is where all the core functions a called in an eternal loop Func Start() while 1 = 1 Feed() sleep(500) KillMonster() sleep(500) fight() sleep(500) WEnd EndFunc ;Decides wether a monster is to be fought or not ;A monster can only be an Ant and can only be 2 lvl higher func FightOrEvade() $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") dim $iEnemyLvl dim $iPetLvl ; This loop keeps on going until a monster is chosen to be fought. ;A monster can only be an Ant and can only be 1 lvl higher $while = 0 while $while = 0 ;This is where the decision begins if StringRegExp($sText, 'Ant') then $oIE = _IEAttach ("Pet me") sleep(500) $sText = _IEPropertyGet($oIE,"innertext") $oTextTable = StringSplit (_IEPropertyGet($oIE,"innertext")," ") $oPetName = $oTextTable[1] ;this is the only way i found to be able to get a ;specific text string (the levels) from the web page for $i = 2 to $oTextTable[0] if StringRegExp($oTextTable[$i], 'Level') then if StringRegExp($oTextTable[$i-2], 'encountered') = 0 Then if StringRegExp($oTextTable[$i-1], $oPetName)=0 Then $iEnemyLvl = $oTextTable[$i+1] $iPetLvl = $oTextTable[$i+5] EndIf EndIf EndIf next ;checks the level difference. ;If it is okay, the Fight it button is clicked ;If it is not okay, the Evade button is clicked $iLvlDiff = $iPetLvl - $iEnemyLvl if $iLvlDiff > -2 then $while = 1 ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,0) $oElement = _IEFormElementGetCollection($oForms,4) _IEAction($oElement,"click") _IELoadWait ($oIE) Else ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,1) $oElement = _IEFormElementGetCollection($oForms,2) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") EndIf Else ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,1) $oElement = _IEFormElementGetCollection($oForms,2) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") EndIf WEnd EndFunc ;Feeds until energy is full func Feed() $oIE = _IEAttach ("Pet me") _IELoadWait ($oIE) $sText = _IEPropertyGet($oIE,"innertext") while StringRegExp($sText, 'Your pet has full hit points, no need to eat ') = 0 ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,1) $oElement = _IEFormElementGetCollection($oForms,3) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") ;sleep(500) WEnd EndFunc ;Click on the Kill monster button from the main page func KillMonster() $oIE = _IEAttach ("Pet me") $oForms = _IEFormGetCollection ($oIE,3) $oElement = _IEFormElementGetCollection($oForms,0) _IEAction($oElement,"click") _IELoadWait ($oIE) FightOrEvade() EndFunc ;Fights until monster dies than loots ;Losing a battle is not an option... func Fight() $oIE = _IEAttach ("Pet me") _IELoadWait ($oIE) $sText = _IEPropertyGet($oIE,"innertext") while StringRegExp($sText, 'You have killed a') = 0 ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,0) $oElement = _IEFormElementGetCollection($oForms,0) _IEAction($oElement,"click") ;sleep(100);_IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") WEnd _IELoadWait ($oIE) if StringRegExp($sText, 'You have killed a') then ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,0) $oElement = _IEFormElementGetCollection($oForms,4) _IEAction($oElement,"click") _IELoadWait ($oIE) EndIf EndFunc Link to comment Share on other sites More sharing options...
Zarox Posted July 8, 2007 Author Share Posted July 8, 2007 (edited) Thanks for the reply and the testing I think i've found a way to make it more robust. I use the _IELoadWait ($oIE) function instead of the sleep() one. seems less buggy. I'm now making a script to sell all the unequipped items automatically i'll be posting it when done.the new code follows:Test Results: Running Time - 30 MinutesCrashes - 0Browser- IE 7New Results Running Time - 1.5 HoursProblems - The only problem is when the website glitches and sends you to the "Your Pets" page. Edited July 8, 2007 by Zarox Link to comment Share on other sites More sharing options...
lespoils Posted July 8, 2007 Share Posted July 8, 2007 You are right i have the same issue, looking into it Update on autoselling script: i am now able to retreive the number of items and wich item is equipped next step will be to click on the right button. I put this aside tho, wanna make the game script able to run for hours without glitch Link to comment Share on other sites More sharing options...
Zarox Posted July 8, 2007 Author Share Posted July 8, 2007 You are right i have the same issue, looking into itUpdate on autoselling script: i am now able to retreive the number of items and wich item is equipped next step will be to click on the right button. I put this aside tho, wanna make the game script able to run for hours without glitchAlright, its great to hear you are working on that issue. It will be great if it could run forever, theoretically. Link to comment Share on other sites More sharing options...
defrag Posted July 9, 2007 Share Posted July 9, 2007 Tested, and as said before - works except that little bug. Awesome to hear you are working on fixing this issue. Would it be possible for you to code the script so it attacks all types of monsters? Would save a lot of time evading them! Link to comment Share on other sites More sharing options...
lespoils Posted July 9, 2007 Share Posted July 9, 2007 yeah sure ! but i really want to take the glitch out, i've thought of a this work around: In the function start i'll simply put a if condition, if the page has the text " Pet not showing up on your profile page?" then it'll click on the pet image and gets back into the game loop. my problem is i can't get a click on the image. i think this is because it's not in a form in the html code. it looks like it in a script. as soon as i'm done with this, i'll add the code to make it fight any monster 3 lvls lower, is that okay or is there another pattern you think would work best ? Lespoils Link to comment Share on other sites More sharing options...
Zarox Posted July 9, 2007 Author Share Posted July 9, 2007 yeah sure ! but i really want to take the glitch out, i've thought of a this work around:In the function start i'll simply put a if condition, if the page has the text " Pet not showing up on your profile page?" then it'll click on the pet image and gets back into the game loop. my problem is i can't get a click on the image. i think this is because it's not in a form in the html code. it looks like it in a script.as soon as i'm done with this, i'll add the code to make it fight any monster 3 lvls lower, is that okay or is there another pattern you think would work best ? LespoilsI think the best way would to find a way to let us pick how low a level for each species, if possible ofcourse. Link to comment Share on other sites More sharing options...
lespoils Posted July 9, 2007 Share Posted July 9, 2007 okay if u mean a lev difference for each species i agree, but it must not be a static level for each specie because after a few hours of fighting u'll have leveled and this must adapt. I have now made it that any monster 3 levels lower than you will be fought. I understand the idea of beeing able to select a level difference for each type of monster but i don't think the time saved while choosing a fight is worth all the scripting time. it currently goes fast enough to gain a lot of xp in a short time. As soon as the glitch is no longer an issue, i'll make the autosell unequipped loot function Lespoils Link to comment Share on other sites More sharing options...
lespoils Posted July 9, 2007 Share Posted July 9, 2007 here's the script with the fight monster 3 lvls lower modif and some attempt to work around the glitch. if u want to help me test it, it'be nice since it can run for over half an hour without the glitch hapening expandcollapse popup;Title: Facebook Pets Game bot ;Filename: IE.au3 ;Description: This script plays the Pet game on Facebook. It will do so on and on. ;Author: Patrick Sirois ;Version: 1.2 ;Last Update: july 8th, 2006 ;Requirements: A Facebook account, the Pet game installed, firefox And IE 6.0(not tested with v.7), Autoit v3.2.4.9 ;READ ME ;To make the script work: ; -log on facebook into the pets game page. ; -Go to the main screen where you click Feed,Kill Monster, buy/sell items,... ; -Rightclick in the Pet game frame and choose: this frame -> Open in a new window ; -copy paste the url in a Internet Explorer window, now we have a webpage with only the Petgame inside ; -Run the script, (shift+alt+s) ; -Press Esc to terminate script #include <Array.au3> #include <IE.au3> _Singleton("Petface") HotKeySet("{ESC}", "Terminate") HotKeySet("+!s", "Start") ;the script goes on until the ESC key is pressed While 1 Sleep(100) WEnd ;;;;;;;; ;Terminates the script Func Terminate() Exit 0 EndFunc ;This is where all the core functions a called in an eternal loop Func Start() $oIE = _IEAttach ("Pet me") _IELoadWait ($oIE) $sText = _IEPropertyGet($oIE,"innertext") while 1 = 1 if StringRegExp($sText, 'Pet not showing up on your profile page?') = 0 then _IELoadWait ($oIE) Feed() _IELoadWait ($oIE) KillMonster() _IELoadWait ($oIE) FightorEvade() _IELoadWait ($oIE) fight() _IELoadWait ($oIE) Else MsgBox(0,"","avant click") _IELinkClickByIndex ($oIE, 0) MsgBox(0,"","apres click") _IELoadWait ($oIE) KillMonster() _IELoadWait ($oIE) fight() _IELoadWait ($oIE) EndIf $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") WEnd EndFunc ;Decides wether a monster is to be fought or not ;A monster can only be an Ant and can only be 2 lvl higher func FightOrEvade() $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") dim $iEnemyLvl dim $iPetLvl ; This loop keeps on going until a monster is chosen to be fought. ;A monster can only be an Ant and can only be 1 lvl higher $while = 0 while $while = 0 ;This is where the decision begins $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") $oTextTable = StringSplit (_IEPropertyGet($oIE,"innertext")," ") $oPetName = $oTextTable[1] ;this is the only way i found to be able to get a ;specific text string (the levels) from the web page for $i = 2 to $oTextTable[0] if StringRegExp($oTextTable[$i], 'Level') then if StringRegExp($oTextTable[$i-2], 'encountered') = 0 Then if StringRegExp($oTextTable[$i-1], $oPetName)=0 Then $iEnemyLvl = $oTextTable[$i+1] $iPetLvl = $oTextTable[$i+5] EndIf EndIf EndIf next if StringRegExp($sText, 'Ant') then ;checks the level difference. ;If it is okay, the Fight it button is clicked ;If it is not okay, the Evade button is clicked $iLvlDiff = $iPetLvl - $iEnemyLvl if $iLvlDiff > -2 then $while = 1 ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,0) $oElement = _IEFormElementGetCollection($oForms,4) _IELoadWait ($oIE) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") Else ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,1) $oElement = _IEFormElementGetCollection($oForms,2) _IELoadWait ($oIE) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") EndIf Else $iLvlDiff = $iPetLvl - $iEnemyLvl if $iLvlDiff > 2 then $while = 1 ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,0) $oElement = _IEFormElementGetCollection($oForms,4) _IELoadWait ($oIE) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") Else ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,1) $oElement = _IEFormElementGetCollection($oForms,2) _IELoadWait ($oIE) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") EndIf EndIf WEnd EndFunc ;Feeds until energy is full func Feed() $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") while StringRegExp($sText, 'Your pet has full hit points, no need to eat ') = 0 ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,1) $oElement = _IEFormElementGetCollection($oForms,3) _IELoadWait ($oIE) _IEAction($oElement,"click") _IELoadWait ($oIE) $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") WEnd EndFunc ;Click on the Kill monster button from the main page func KillMonster() $oIE = _IEAttach ("Pet me") $oForms = _IEFormGetCollection ($oIE,3) $oElement = _IEFormElementGetCollection($oForms,0) _IELoadWait ($oIE) _IEAction($oElement,"click") _IELoadWait ($oIE) EndFunc ;Fights until monster dies than loots ;Losing a battle is not an option... func Fight() $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") while StringRegExp($sText, 'You have killed a') = 0 ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,0) $oElement = _IEFormElementGetCollection($oForms,0) ;no _IELoadWait() here to have quicker battle _IEAction($oElement,"click") $oIE = _IEAttach ("Pet me") $sText = _IEPropertyGet($oIE,"innertext") WEnd ;wait untill the page loads before click loot _IELoadWait ($oIE) if StringRegExp($sText, 'You have killed a') then ;this is how i choose a specific button from the page $oForms = _IEFormGetCollection ($oIE,0) $oElement = _IEFormElementGetCollection($oForms,4) _IELoadWait ($oIE) _IEAction($oElement,"click") _IELoadWait ($oIE) EndIf EndFunc Link to comment Share on other sites More sharing options...
lespoils Posted July 9, 2007 Share Posted July 9, 2007 I let the script run all night and this morning i had lost a fight to a scorpion 3 lvls lower than me. That is the reason i only fought with ants in the beginning. Now i change the lvl difference to 4 for any other monster. I really don't think the time spent searching for an ant is much of a problem as the script in overall is quite fast. i'm presently at work, when i get back tonight, i 'll see how things went. if it is still running i'll leave it like that. If u want to customize this level difference, look at the function FightOrEvade() in my code. there is a Big If the monster is an Ant condition. in the "then" part of that if there is another IF (if $iLvlDiff > -2 then ) if u want to fight only with ant ur level or lower change the "-2" to "-1". in the Else part of the First If there is a similar if $iLvlDiff > 2. this is the one for every other monster. i put it to 4 now, so if im 24 and i meet a mantis lvl20 it'll fight it but not a level 21. Scorpions are the base of this issue since they are quite strong. Futur update coming tonight Link to comment Share on other sites More sharing options...
Zarox Posted July 9, 2007 Author Share Posted July 9, 2007 Thanks for the heads up, but the glitch still happened to me about 2 minutes ago. Link to comment Share on other sites More sharing options...
lespoils Posted July 9, 2007 Share Posted July 9, 2007 Yeah i know..... i don't know why for now, and it's not easy to troubleshoot since i have to wait for it to happen. tho now when it happens i juste start the script again and it catches on. still have to work on it. it's still doing a good job of power leveling Later Lespoils Link to comment Share on other sites More sharing options...
Zarox Posted July 9, 2007 Author Share Posted July 9, 2007 (edited) Yeah i know.....i don't know why for now, and it's not easy to troubleshoot since i have to wait for it to happen. tho now when it happens i juste start the script again and it catches on.still have to work on it. it's still doing a good job of power leveling LaterLespoilsYa, the testing is alittle annoying, but it always happens after you press attack, once you find the right monster to attack. This might help.Edit: I just got to level 25 and have the Chimera Set. Wootz. Edited July 10, 2007 by Zarox Link to comment Share on other sites More sharing options...
lespoils Posted July 10, 2007 Share Posted July 10, 2007 gratz on the lv 25 Link to comment Share on other sites More sharing options...
Golbez Posted July 10, 2007 Share Posted July 10, 2007 (edited) no more code for you leachers Edited July 14, 2007 by Golbez Link to comment Share on other sites More sharing options...
Golbez Posted July 10, 2007 Share Posted July 10, 2007 (edited) i made gui for this now i just got to get the bot working so i can put the to together nvm im a moron lol i got it now Edited July 10, 2007 by Golbez Link to comment Share on other sites More sharing options...
Zarox Posted July 10, 2007 Author Share Posted July 10, 2007 (edited) i made gui for this now i just got to get the bot working so i can put the to together nvm im a moron lol i got it now I think a GUI is the least of our concerns, I think we would rather have features but you may do as you please I have so many items at the moment, I think that the automatic selling would be the best thing for the future of the program. Also, I don't want to sell 100 Million items.Also, I htink that the game doesn't let yo usee all of your items if you have over a certain amount. I currently have the whole Chimera set but only 2 show up in my inventory.Thanks,Zarox Edited July 10, 2007 by Zarox Link to comment Share on other sites More sharing options...
lespoils Posted July 10, 2007 Share Posted July 10, 2007 (edited) Zarox you are right about the inv not all showing, when you will sell more items the chimera gear will show up. The bot worked pretty much all night yesterday as i manage to get to 40million xp (LV 25 TOO ) and when i went to bed i was at 30 million. I hope i finally corrected the glitch *cross fingers* As for Golbez, thank you for your interrest ! you're more than welcome to help out ! but i don't see right away the mods you've made and why is the #inclue <misc.au3> necessary. Work on the code but try to mark out the changes And for the gui, i agree with both of you it would be an interresting feature but i also feel the auto loot selling function is more interresting for now. If the script is still running when i get back from work, i'll work on the AutoSell function. Cheers Lespoils Edited July 10, 2007 by lespoils Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now