Restart D2 script v2.0

Page 3 of 4 Previous  1, 2, 3, 4  Next

View previous topic View next topic Go down

Re: Restart D2 script v2.0

Post by MarcoNecroX on Tue Dec 04, 2012 3:37 am

No D2SE mention, I guess non compatible?

_____________________
http://www.median-xl.com Cookie monster

MarcoNecroX
Malthael

Führer
Posts : 10181
Country : Argentina

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by Quirinus on Wed Dec 05, 2012 10:42 am

SIGMA wrote:No D2SE mention, I guess non compatible?

Yea sadly. I asked in the questions topic if someone knows how to skip the D2SE starting menu (ini line, startup parameter, some option), but no one knew. So you'd have to choose Ultimative manually if it's D2SE. Everything else should work.

Also, known bugs:
Windows labels the game unresponsive if the loading takes too long, so the script restarts D2 then, even if it'd work otherwise. xD

Quirinus
Creature of Flame

Bloody High Five
Posts : 5567
TGGood none
Country : Croatia

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by iwansquall on Wed Dec 05, 2012 2:15 pm

Blah, i suck at new language.
Anyone can help with this?
Im playing back barb again, so i really need this script.

I dunno exact term for AutoIt, glad if someone can help

If (window title = diablo2) //So it only work with d2 game only.
{
onMousedown -> StartTimer / Delay
Once timer is over certain ms, enable script below. (2000ms for example)
mouse click every couple of ms (since barb can attack 4fpa/25 frames, 160ms?)
onMouseUp -> Timer = 0
}end func


some sort of that, been trying for hour, but couldnt find the function i need from the help file.
of course i would need to use /nopickup so i wouldnt accidentally pick up loot.


Edited: Try couple more time, failed.

Actually, if we can setup this properly, we can make auto-gamble.

Framework like this
1. Set 1 key as save npc position
2. Set another key as save 'gamble' button position
3. Lastly a key to restart gamble

So technically it is:
1. Highlight NPC -> use 1st key
2. Highlight Gamble -> use second key
3. So once you checked the gamble screen - press a key to restart the gamble.

Process should be something like this
1. Press escape -> to quit gamble screen.
2. Send mouse position for position saved by 1st key + send mouse click
3. Send mouse position for position saved by 2nd key + send mouse click

Not entire fool proof though, NPC is tend to stupidly walk around if you not talking to them.

iwansquall
Blood Golem

Underpowered Admin
Posts : 2206
Country : Malaysia

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by aahz on Wed Dec 05, 2012 6:29 pm

I use AutoHotkey (similar to AutoIt) for all kind of things so I tried to do it - you can use this code for a start...but it's not pretty and you have to (at least) tune delays...
Code:

#IfWinActive ahk_class Diablo II
Lbutton::
delay=0
Loop
{
  GetKeyState, state, Lbutton, P
  if state=U
  {
    SendInput {Click}
    break
  }

  if delay <= 100
  {
    sleep 1
    delay += 1
  }
  else
  {
    Sendinput {Click}
    Sleep 50
  }
}
return
#IfWinActive

aahz
Cathedral Drow

Server Hoster
Posts : 513
Country : Czech Republic

View user profile http://tsw.vn.cz

Back to top Go down

Re: Restart D2 script v2.0

Post by iQQ on Wed Dec 05, 2012 7:05 pm

@iwansquall wrote:...
Actually, if we can setup this properly, we can make auto-gamble.

Framework like this
1. Set 1 key as save npc position
2. Set another key as save 'gamble' button position
3. Lastly a key to restart gamble

So technically it is:
1. Highlight NPC -> use 1st key
2. Highlight Gamble -> use second key
3. So once you checked the gamble screen - press a key to restart the gamble.

Process should be something like this
1. Press escape -> to quit gamble screen.
2. Send mouse position for position saved by 1st key + send mouse click
3. Send mouse position for position saved by 2nd key + send mouse click

Not entire fool proof though, NPC is tend to stupidly walk around if you not talking to them.

Check out my D2Tools pack, all is written in AutoIt and I think source is easy to read and understand.
Some files are also flexible so modifying them for your purposes shouldn't be hard.
For this script you don't need to persist coordinates to an INI file since the char and NPC might move.

BTW, you don't need the gamble coords, just send Down arrow key twice followed by the Enter key. This is not true for all NPCs.

iQQ
Prowler

Posts : 11
Country : ???

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by iwansquall on Wed Dec 05, 2012 7:29 pm

Look quite complex, i will study them abit.

I managed to do what i want, but still not 'clean' enough.

This one i used addition to code posted in page 2.
Code:

$autoAttack = IniRead($Ini, "Hotkeys", "Killkey", "{`}")
HotKeySet($autoAttack, "autoAttack")
$LoopToggle = 0;

Func autoAttack()
  if ($loopToggle == 0)Then
     $loopToggle = 1
     LoopTimer ()
  Else   
     $loopToggle = 0
  EndIF
EndFunc

func LoopTimer() 
       while $loopToggle = 1      
         If WinActive("[Title:Diablo II;Class:Diablo II]") Then
           MouseClick ("left")
           sleep (40)
         Else
           $loopToggle = 0
         EndIf
       WEnd
endFunc

Basically it just send LMB click every 40ms.
Damn useful, i dun need to press anything my barb Very Happy
Less hand pain as well.


Edited:
Meh, run to some bug. Recursion level exceeded, AutoIt will quit to prevent stack overflow.
I guess it because i run while-loop too much. I will change the code until i find better one.

EDITED:
DOH!, found the reason.
I wouldnt need to call the same function again if Im using while.
As long as toggle is one, it will send mouse click every 40ms.

EDIT3D:
I found the way to call for loop after mouse press for couple of seconds, problem is... i couldnt make it stop.
So my current hotkey work better.
Oh, i edited the code the disable the loop if your d2 window is not active (to prevent CRAZY mouse click on desktop)

EDITED v4:
The reason why it didnt work as intended is because mouseclick is interupting my 'mouse-hold-down' setting.
So here my workaround for it, since shift = standstill + attack, i made CTRL for auto-steer for melee character.
Code:
While 1
  If WinActive("[Title:Diablo II;Class:Diablo II]") Then
     if (_IsPressed("A2" , $hDLL)) Then
       While _IsPressed("A2", $hDLL)   
         MouseClick ("left")
         sleep (40)
       WEnd        
     EndIf   
  EndIf         
  Sleep(100)
WEnd

If you want to change the _isPressed button, refer to here:
http://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm

iwansquall
Blood Golem

Underpowered Admin
Posts : 2206
Country : Malaysia

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by Quirinus on Fri Dec 14, 2012 5:20 am

Oh, if you need auto-gamble here it is:

Code:
;Assigns the HotKey to our custom exit function
HotKeySet("^!x", "MyExit")

$d2 = WinGetHandle ("[CLASS:Diablo II]");
;ControlSend($d2, "", 0, "{ENTER}")


; The coordinates to click in pixels
$x_gamble = 400
$y_gamble = 230
$x_ring = 375
$y_ring = 150
$times = InputBox("D2 Basic Gambler","How many times to gamble? (Max = 76)","48","")

  $i = 0
  While ($i < $times)
 
     ControlClick($d2,"",0,"left",1,$x_gamble, $y_gamble)
     Sleep(100 + Random(1,50,1))
     ControlClick($d2,"",0,"left",1,$x_gamble, $y_gamble)
     Sleep(300 + Random(1,50,1))
     ControlSend($d2, "", 0, "{DOWN}")
     Sleep(100 + Random(1,50,1))
     ControlSend($d2, "", 0, "{DOWN}")
     Sleep(100 + Random(1,50,1))
     ControlSend($d2, "", 0, "{ENTER}")
     Sleep(500 + Random(1,50,1))
     ControlClick($d2,"",0,"left",1,$x_ring, $y_ring)
     Sleep(100 + Random(1,50,1))
     ControlSend($d2, "", 0, "{ENTER}")
     Sleep(500 + Random(1,50,1))
     ControlSend($d2, "", 0, "{ESC}")
     Sleep(200 + Random(1,50,1))
      
     $i = $i + 1
   
  WEnd

  ControlClick($d2,"",0,"left",1,$x_gamble, $y_gamble)
  Sleep(100 + Random(1,50,1))
  ControlClick($d2,"",0,"left",1,$x_gamble, $y_gamble)
  Sleep(300 + Random(1,50,1))
  ControlSend($d2, "", 0, "{DOWN}")
  Sleep(100 + Random(1,50,1))
  ControlSend($d2, "", 0, "{DOWN}")
  Sleep(100 + Random(1,50,1))
  ControlSend($d2, "", 0, "{ENTER}")

  WinActivate($d2)
  WinSetState($d2,"",@SW_RESTORE)
  SoundPlay("C:\Games\SMAC\voices\univ.mp3", 1)




Func MyExit()
  Exit
EndFunc

This one gambles for Rings. I was looking for good rare rings for my barb and a perfect empy band and I was tired of clicking so I made this.

It runs in the background (you can do other stuff while it is gambling) and when it's finished it will maximize D2 and play a sound (change the path to a sound file on your computer). It will also ask, at the start, how many times you want to gamble. (ie. count the free space in your inventory and write it down in there)

The only problem is you need to bring your char in front of the NPC. Press Ctrl+Alt+x to stop it prematurely (or shift, can't remember what ^!x is in autoit, you can google it if you want)

You can change the coordinates to make it gamble amulets. If you're really cheeky you can incorporate image search and make it gamble for other stuff.

I also made an Hold Alt, Hold Shift and Hold Left Mouse Button script for my Sky Siege farmer barb so I just need to move my mouse around instead of holding all 3 buttons and I put pause on the right mouse button so I can pick up items when I need. That script saved my life, my hand was grateful because it hurt before from all the clicking and holding. If you need it let me know.

Quirinus
Creature of Flame

Bloody High Five
Posts : 5567
TGGood none
Country : Croatia

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by iced_tea on Fri Mar 29, 2013 5:02 am

hey Iwansquall and quirinus, your programs seem very useful but i don't know how to get them to work.

iwansquall, i downloaded autoit and installed. copied the code you stated above (EditedV4), pasted in a txt doc, renamed it .au3, ran it but it says

if (_IsPressed("A2" , $hDLL)) Then
if (_IsPressed("A2" , ^ ERROR
Error: Variable used without being declared.

quirinus, your programs seem very useful - shrinecrafter, jewelcrafter, chaos reroller. the .exes start up with no issue, they ask me to press "j" so i press "j" in game and nothing happens for all the programs. help!

iced_tea
Bloodfire Rogue

Posts : 63
Country : ???

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by wojen616 on Fri Mar 29, 2013 6:38 am

^ remember to run as admin

And for Iwans code:
Put this before while loop
Code:
local $hDLL = dllopen("user32.dll")

wojen616
Landmass

Posts : 360
Country : Poland

View user profile

Back to top Go down

Re: Restart D2 script v2.0

Post by iced_tea on Fri Mar 29, 2013 6:53 am

Thanks for the reply wojen. I tried it and this is the code:

local $hDLL = dllopen("user32.dll")

While 1
If WinActive("[Title:Diablo II;Class:Diablo II]") Then
if (_IsPressed("A2" , $hDLL)) Then
While _IsPressed("A2", $hDLL)
MouseClick ("left")
sleep (40)
WEnd
EndIf
EndIf
Sleep(100)
WEnd

I get

if (_IsPressed("A2" , $hDLL)) Then
if (^ ERROR
Error: Unknown function name.

Help! Please help my dying hand/wrists, thanks!

iced_tea
Bloodfire Rogue

Posts : 63
Country : ???

View user profile

Back to top Go down

Page 3 of 4 Previous  1, 2, 3, 4  Next

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum