Jump to content

Quick AutoIt questions


Recommended Posts

I made a script to automate attacks in this game. Thing is, 1) I want it to have a list of random things to say, how do you do that? 2) Another thing is the game "locks" your attacks if you don't move, but there is no {directionDOWN} function for direction keys. Just putting {direction} doesn't work. Any ideas to solve that?

Here's the script.

$count = 0
While 1
    If $count < 50 Then
        Send("{RSHIFT}")
        Sleep(1000)
        $count = $count + 1
    ElseIf $count = 50 Then
        Send("{ENTER}Come on shrooms, I want to kill j00{!}")
        Send("{ENTER}")
        Send("{ENTER}")
        Send("{RIGHT}")
        Sleep(1000)
        $count = $count + 1
    ElseIf $count < 100 Then
        Send("{RSHIFT}")
        Sleep(1000)
        $count = $count + 1
    ElseIf $count = 100 Then
        Send("{ENTER}Bah, they take forever to spawn...")
        Send("{ENTER}")
        Send("{ENTER}")
        Send("!")
        $count = $count + 1
    ElseIf $count < 150 Then
        Send("{RSHIFT}")
        Sleep(1000)
        $count = $count + 1
    ElseIf $count = 150 Then
        Send("{ENTER}Man... I don't want to move to attack them...")
        Send("{ENTER}")
        Send("{ENTER}")
        Send("!")
        $count = $count + 1
    ElseIf $count < 200 Then
        Send("{RSHIFT}")
        Sleep(1000)
        $count = $count + 1
    ElseIf $count = 200 Then
        Send("{ENTER}Gimme j00r life{!}")
        Send("{ENTER}")
        Send("{ENTER}")
        Send("!")
        Sleep(60000)
        $count = 0
    EndIf
WEnd
Edited by JuggaloZeke
Link to comment
Share on other sites

To make it say a Random thing you can do this

$random = Random()
If $random < 0.25 Then
Send("{ENTER}Come on shrooms, I want to kill j00{!}")
Send("{ENTER}")
ElseIf $random > 0.25 AND $random < 0.5 Then
Send("{ENTER}Bah, they take forever to spawn...")
Send("{ENTER}")
ElseIf $random > 0.5 AND $random < 0.75 Then
Send("{ENTER}Man... I don't want to move to attack them...")
Send("{ENTER}")
ElseIf $random > 0.75 Then
Send("{ENTER}Gimme j00r life{!}")
Send("{ENTER}")
EndIf

Its not tested, but i hope it works.

Edited by the_lord_mephy
My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

I guess I should have explained what everything was...

The count is there for a reason. I have my attack mapped to the SHIFT key, so what the script does is attack 50 times, say what I told it to, start attacking again, etc. The random part I wanted something more along the lines of... it might not be the correct term, but an array? Like a list of sorts that AutoIt could randomly choose something from. And it talking isn't that important, what's more important is find a way to "hold down" a directional key.

Link to comment
Share on other sites

Guest BL@(K-R34P3R

Look in helpfile at the bottom in the "Send Key List" it lists all of them... There is also a way to make it hold down keys, (read the bottom part).

Link to comment
Share on other sites

Guest BL@(K-R34P3R

Quote from the helpfile:

To hold a key down (generally only useful for games)

    Send("{a down}") ;Holds the A key down

    Send("{a up}") ;Releases the A key

Link to comment
Share on other sites

And other good idea is making a .txt file of random thing to say like:

sentences.txt (Of course the first four chars are just a 'line number')

01- I want to kill everyone!
02- You... I hate, die.
03- You are boring, die.
04- Move along or die. You have to choice.
05- MURDER! DEATH! KILL!
06- Worry not. You'll leave... for going in hell.
07- Heavens are awaiting you.
08- Ect.

After reading the file with a:

$Sentences = FileRead('e:\full path\sentences.txt',FileGetSize('e:\full path\sentences.txt'))
StringReplace($Sentences,@CRLF,@LF);If it is a standard Dos .txt file that uses @crlf as 
;                                    new line chars. otherwise change as needed.
$Sentences = StringSplit($Sentences,@lf)

So you have an array with all your sentences. Just be careful about empty lines in sentences.txt

And using them when you need with something like:

Send('{Enter}');Activate the 'chat mode'
Send($Sentences[Int(Random(1,$Sentences[0]+1))],1);Write your nonsense
Send('{Enter}');Send it!

So you can just add lines when you have new ideas and remove the ones you do not want with easy. Just reload the script. :)

Edit: forgot a )

2nd Edit: Added the two {enter} after seeing JuggaloZeke post.

Edited by ezzetabi
Link to comment
Share on other sites

  • 4 weeks later...

I'm back again... I have since modified the script and once more again.. but now it just ends when it should loop. The new script:

Sleep(5000)
Send("{ENTER}/makeparty{ENTER}{ENTER}")
$count = 0
While 1
    If $count < 15 Then
        Send("{RCTRL}")
        Send("{RIGHT DOWN}")
        Sleep(1500)
        Send("{RIGHT UP}")
        $count = $count + 1
    ElseIf $count < 30 Then
        Send("{RCTRL}")
        Send("{LEFT DOWN}")
        Sleep(1500)
        Send("{LEFT UP}")
        $count = $count + 1
    ElseIf $count = 45 Then
        $count = 0
    EndIf
WEnd
Link to comment
Share on other sites

Try adding a final else on there... it isnt able to do the if statement... try the following.

Sleep(5000)
Send("{ENTER}/makeparty{ENTER}{ENTER}")
$count = 0
While 1
    If $count < 15 Then
        Send("{RCTRL}")
        Send("{RIGHT DOWN}")
        Sleep(1500)
        Send("{RIGHT UP}")
        $count = $count + 1
    ElseIf $count < 30 Then
        Send("{RCTRL}")
        Send("{LEFT DOWN}")
        Sleep(1500)
        Send("{LEFT UP}")
        $count = $count + 1
    ElseIf $count = 45 Then
        $count = 0
    Else
        MsgBox(0, "Whats wrong?", "This is your count: " & $count)
    EndIf
WEnd

Edit: I just relooked at your code and so far I have been unable to see anything. Add those boxes in several places to check and see if it really does anything.

Edit2: Okay I see what you need. You need While...WEnd statements inside the if statement :)

Something like this...

Sleep(5000)
Send("{ENTER}/makeparty{ENTER}{ENTER}")
$count = 0
While 1
    If $count < 15 Then
        While 1
            Send("{RCTRL}")
            Send("{RIGHT DOWN}")
            Sleep(1500)
            Send("{RIGHT UP}")
            $count = $count + 1
            If $count = 15 Then ExitLoop
        WEnd
    ElseIf $count < 30 Then
        While 1
            Send("{RCTRL}")
            Send("{LEFT DOWN}")
            Sleep(1500)
            Send("{LEFT UP}")
            $count = $count + 1
            If $count = 30 Then ExitLoop
        WEnd
    ElseIf $count = 45 Then
        $count = 0
    Else
        MsgBox(0, "Whats wrong?", "This is your count: " & $count)
    EndIf
WEnd

Hope this helps a bit...

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Let's take a look at the loop.

First count equals to 0, so the first statement executes and keeps executing until count equals to 15.

Then the second statement executes and keeps executing until count equals to 30.

And then the loop keeps popping up the message box.

Here's what I would do.

Sleep(5000)
Send("{ENTER}/makeparty{ENTER}{ENTER}")
While 1
    $count = 0
    Do
        If $count < 15 Then
             Send("{RCTRL}")
             Send("{RIGHT DOWN}")
             Sleep(1500)
             Send("{RIGHT UP}")
             $count = $count + 1
        ElseIf $count < 30 Then
             Send("{RCTRL}")
             Send("{LEFT DOWN}")
             Sleep(1500)
             Send("{LEFT UP}")
             $count = $count + 1
        EndIf
   Until $count = 45
WEnd
Link to comment
Share on other sites

it is not much easier and more readable doing

Sleep(5000)
Send("{ENTER}/makeparty{ENTER}{ENTER}")

While 1
   for $count = 1 to 14 
       Send("{RCTRL}")
       Send("{RIGHT DOWN}")
       Sleep(1500)
       Send("{RIGHT UP}")
       $count = $count + 1
   Next
   For $count = 15 to 29
       Send("{RCTRL}")
       Send("{LEFT DOWN}")
       Sleep(1500)
       Send("{LEFT UP}")
       $count = $count + 1
   Next
   For $count = 30 to 45
    ;Well, none knows from your script.
   Next

WEnd

?

Edited by ezzetabi
Link to comment
Share on other sites

HAHA guys I didnt even catch that. I edited my post like 5 times cause I kept catching stuff hehe I just finally left it.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...