Read text file for function Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Guest

Read text file for function  Topic is solved

28 Apr 2015, 05:48

I already posted about this here
http://www.autohotkey.com/board/topic/1 ... -function/
but some users don't like the site so i made one here also :P

Hi
 
So i play a game called PokeMMO, witch i have a made a script to read the coordinates of my player/trainer
 
Here is a bad quality video of how it works:

Here is a picture:
http://s11.postimg.org/rg2vmljwz/pokemoncenter.png

So what the script does is, Reads the games memory so i get the coordinates of my player and then shows it in the GUI edit and every time i press WSA or D it records/saves the coordinates and also puts a direction to it:
 
W: UP | S: Down | A: Left | D: Right
 
and then it saves the coordinates and Directions to a file called "Path.ppm"
in the file:

Code: Select all

1769498|Left
1769493|Up
1179669|Left
524332|Down
917548|Left
917541|Up
and then i have a function that looks like this,

Code: Select all

Walk_To_Pos("%CordPath%",currentPos,"%DirPath%") ; example Walk_To_Pos("1769498","Left")

Walk_To_Pos(target,currentPos, dir)
{
  IF  (target = currentPos)
  {
  GuiControl,, Statusy, Walking to %target%
  send, {%dir% Down}
     }
}
that basically sends a key to the game if the player/trainer stands on that coordinate, here is an example:
http://s11.postimg.org/a3xxnf11v/screenshot_177.png
Walk_To_Pos("262150",currentPos,"Right")
^
Means IF the player is standing 262150 then send the Right arrow key.
 
 So the problem is that i don't know how to read the text inside of Path.ppm and split it so that the coordinates and the Directions gets in to the function and loops depending on how many lines there are in the Path.ppm
 
i tried splinting it myself but i don't really know how to do it, example:

Code: Select all

IF  (Playmode = 1)
{
FileRead, Read_Path,Path.ppm
StringSplit, CordPath, Read_Path, `n
StringSplit, DirPath, Read_Path,  |

Walk_To_Pos("%CordPath%",currentPos,"%DirPath%") ; Walk_To_Pos("1769498","Left")
}
Script:

Code: Select all

#Include memory.ahk

;center cord = 262151, 1 STEP DOWN FROM CENTER =  327687

Clipboard = 
toggle = 0
#MaxThreadsPerHotkey 2
#SingleInstance, force
SetWorkingDir, %A_ScriptDir%

Gui, +AlwaysOnTop

Gui, Add, ListBox, x236 y7 w350 h460 VWalk, Press The Direcion you want

Gui, Add, Button, x16 y247 w110 h40 gtest, Test Path

Gui, Add, Text, x16 y17 w40 h20 , Cords:
Gui, Add, Edit, x66 y17 w70 h20 vXXYY, --

Gui, Add, Text, x226 y7 w10 h20 , 1
Gui, Add, Text, x226 y27 w10 h20 , 2
Gui, Add, Text, x226 y47 w10 h20 , 3
Gui, Add, Text, x226 y67 w10 h20 , 4
Gui, Add, Text, x226 y87 w10 h20 , 5
Gui, Add, Text, x226 y107 w10 h20 , 6
Gui, Add, Text, x226 y127 w10 h20 , 7
Gui, Add, Text, x226 y147 w10 h20 , 8
Gui, Add, Text, x226 y167 w10 h20 , 9
Gui, Add, Text, x216 y187 w20 h20 , 10
Gui, Add, Text, x216 y207 w20 h20 , 11
Gui, Add, Text, x216 y227 w20 h20 , 12
Gui, Add, Text, x216 y247 w20 h20 , 13
Gui, Add, Text, x216 y267 w20 h20 , 14
; Generated using SmartGUI Creator for SciTE
Gui, Show, w608 h491, PokeMMO Path Maker
return

GuiClose:
ExitApp

~W::
GuiControlGet, XXYY_OUT,, XXYY
step = IF: %XXYY_OUT% Walk: Up
GuiControl,, Walk, %Step%
FileAppend,%XXYY_OUT%|Up`n,Path.ppm
return

~A::
GuiControlGet, XXYY_OUT,, XXYY
step = IF: %XXYY_OUT% Walk: Left
GuiControl,, Walk, %Step%
FileAppend,%XXYY_OUT%|Left`n,Path.ppm
return

~S::
GuiControlGet, XXYY_OUT,, XXYY
step = IF: %XXYY_OUT% Walk: Down
GuiControl,, Walk, %Step%
FileAppend,%XXYY_OUT%|Down`n,Path.ppm
return

~D::
GuiControlGet, XXYY_OUT,, XXYY
step = IF: %XXYY_OUT% Walk: Right
GuiControl,, Walk, %Step%
FileAppend,%XXYY_OUT%|Right`n,Path.ppm
return

test:
Playmode = 1
return

Q::
Toggle := !Toggle
While Toggle
{

ProcessName := "javaw.exe" ; Pokemmo
cords := 0xAB3F44A8 ; Cords
	
hwnd := MemoryOpenFromName(ProcessName)
	
cords := MemoryReadPointer(hwnd,cords, "int")
Status := MemoryReadPointer(hwnd,Status, "int")
	
MemoryClose(hwnd)
GuiControl,, XXYY, %cords%

IF  (Playmode = 1)
{
FileRead, Read_Path,Path.ppm
StringSplit, CordPath, Read_Path, `n
StringSplit, DirPath, Read_Path,  |

Walk_To_Pos("%CordPath%",currentPos,"%DirPath%") ; Walk_To_Pos("1769498","Left")
}

}
return

Walk_To_Pos(target,currentPos, dir)
{ 
		IF  (target = currentPos)
		{	
		GuiControl,, Statusy, Walking to %target%
		send, {%dir% Down}
	    }
}


Go_Loop(target,target2, currentPos, dir1,dir2)
{ 
		IF  (target = currentPos)
		{	
		GuiControl,, Statusy, Walking to %target2%
		send, {%dir2% Up}
		send, {%dir1% Down}
	    }
		
		IF  (target2 = currentPos)
		{	
		GuiControl,, Statusy, Walking to %target%
		send, {%dir1% Up}
		send, {%dir2% Down}
    }
}
Here is some more info on how a older script just so you can get the idea on how it works:
http://www.autohotkey.com/board/topic/1 ... ot-working
 
Thanks and if you need any more info, feel free to send me a PM
theon
Posts: 124
Joined: 23 Jun 2019, 15:39

Re: Read text file for function

02 Apr 2020, 21:37

I'm like the same problem my script reading the player's exact position, but I don't know how to make him walk with her, it helps me; D




pos, x, y, z
Attachments
ponto.png
ponto.png (7.13 KiB) Viewed 1409 times
theon
Posts: 124
Joined: 23 Jun 2019, 15:39

Re: Read text file for function

02 Apr 2020, 21:43

I need a function where the she calculates the position is x10 y 10

and the player ta x5 y5

so every time he north 1+ south -1, left +1, right -1

now how to create the function for him to calculate this = Z
the script has to calculate the steps of the player to reach x10 y10

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 112 guests