View previous topic :: View next topic |
Author |
Message |
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Sat Aug 08, 2015 12:14 pm Post subject: Help with this script? |
|
|
I have this AOB:
41 73 73 65 74 5C 43 48 41 52 5F which translates to Assets\CHAR_
I want the user to be able to input a custom name he wants, such as "Subzero_A" and then ask the user what to replace it with "such as Mod\Mod1".
Then the script will search for (AOBScan) 41 73 73 65 74 5C 43 48 41 52 5F and then get the name the user did input as AOB (Subzero_A will become 53 75 62 7A 65 72 6F 5F 41) then add .xxx (2E 78 78 7, and the replace everything starting from the beginning (41 73) with what the user wrote the 2nd time (Mod\Mod1). Is this even possible?
I was thinking about something like this:
aob_replace = {User input 2 in hex}
aob_original = {User input 1 in hex}
aob = AOBScan("41 73 73 65 74 5C 43 48 41 52 5F * * * * * * 2E 78 78 78")
for i=0, aob.Count-1 do
writeBytes(aob[i], unpack(aob_replace))
end
But the thing is that the scanned AOB can vary in size and it can be as long as 3 bytes up to 24 bytes.
So in other words, I'm trying to get a script that searches for an Array of Bytes which the user inputted, and allow him to replace it with another Array without him knowing the address, because I couldn't find the Base Address anywhere.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Aug 08, 2015 7:35 pm Post subject: |
|
|
Looks like my script.
May be able to do something like:
Code: | aob_replace = "Subzero_A"
...
writeBytes(aob[i], string.byte(aob_replace.."\0",0,-1)) |
|
|
Back to top |
|
|
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Sat Aug 08, 2015 10:31 pm Post subject: |
|
|
Zanzer wrote: | Looks like my script.
May be able to do something like:
Code: | aob_replace = "Subzero_A"
...
writeBytes(aob[i], string.byte(aob_replace.."\0",0,-1)) |
|
Okay so if I understand this correctly, I maybe can do something like this:
Code: |
aob_default="Asset/CHAR_"
for i=0 aob_default.Count-1 do
writeBytes(aob[i], string.byte(aob_default)
end
for i=aob_default.Count-1 aob_default.Count-1+aob_replace.Count-1 do
writeBytes(aob[I], string.byte(aob_replace.. "\0", 0,-1))
aob_current = i
end
for i=aob_current+1 aob_current+5 do
WriteBytes(aob[i], {2E 47 47 47})
end |
Will this work as intended? I'm not really that good in Lua.
I understand that \0 is a null terminator or such, but what are the 0 and -1? Also what part of the code asks for user input? And is the string case insensitive?
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Aug 08, 2015 10:48 pm Post subject: |
|
|
Not quite. It will replace whatever the bytes 41 73 etc. were.
The function string.byte returns the bytes of the string. 0 tells it to start at index 0, -1 tells it end at the string length.
The code will replace the string with whatever the user entered.
If the game is case sensitive then your user will need to enter the string correctly.
Code: | local value = inputQuery("Name", "Enter a name:", "")
if value ~= nil and value:len() > 0 then
aob = AOBScan("41 73 73 65 74 5C 43 48 41 52 5F * * * * * * 2E 78 78 78")
for i=0, aob.Count-1 do
writeBytes(aob[i], string.byte(value.."\0",0,-1))
end
end |
|
|
Back to top |
|
|
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Sat Aug 08, 2015 10:57 pm Post subject: |
|
|
Thanks, I will try that and get back to you here.
But there's still one thing, the "* * * *" part is basically, any byte, right? What if this amount is able to expand/conteact?
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Aug 08, 2015 11:07 pm Post subject: |
|
|
The null terminator should prevent the game from trying to read any more of the string.
No matter how many additional non-zero bytes still exist past it.
|
|
Back to top |
|
|
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Sat Aug 08, 2015 11:45 pm Post subject: |
|
|
So eventually I've settled for this code:
Code: |
local Folder = inputQuery("FName", "Enter the path to the modded file:", "")
if Folder ~= nil and Folder:len() > 0 then
aob = AOBScan("41 73 73 65 74 5C" )
for i = 0, aob.Count-1 do
writeBytes(aob[i], string.byte(Folder.."\0",0,-1))
lasti = i
end
end
|
But there's this thing that it is actually replacing the entire memory block and not just the aob.Count-1
So if it was "Asset\blablablablabla" and I type "MODS", it will replace that with MODS, and not "MODSt\blablablabla". What am I doing wrong?
This is what I'm trying to do in Pseudo Code:
Code: |
Get the name of the player to change, for example Subzero_A
search for Asset\CHAR_Subzero_A.xxx
replace Asset\CHAR_Subzero_A.xxx with a user=input path such as MODS\SubzeroMod.xxx
example 2:
Get the name of the player to change, for example JohnnyCage_H
search for Asset\CHAR_JohnnyCage_H.xxx
replace Asset\CHAR_JohnnyCage_H.xxx with a user=input path such as MODS\JohnnyMOD_H.xxx
|
But I don't think that's possible, right? Since the name is subject to change.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 09, 2015 7:37 am Post subject: |
|
|
If your AOB is for "Asset\CHAR_" it will find all of those occurrences.
If your user types in "MODS\JohnnyMOD_H.xxx" (the full thing), it should replace the way you want.
However, if you only want to change the word "Asset" to "MODS" then that's a different script.
|
|
Back to top |
|
|
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Sun Aug 09, 2015 8:04 am Post subject: |
|
|
Zanzer wrote: | If your AOB is for "Asset\CHAR_" it will find all of those occurrences.
If your user types in "MODS\JohnnyMOD_H.xxx" (the full thing), it should replace the way you want.
However, if you only want to change the word "Asset" to "MODS" then that's a different script. |
No no I would like to change it entirely. But the thing is that the script is changing values after .xxx rendering the game unplayable.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 09, 2015 8:12 am Post subject: |
|
|
That's what I meant by you needing to type in the FULL string.
If there is ANYTHING you want to keep after text you prompted, then you need a different script.
For example:
Asset\CHAR_Subzero\Movement
If you only wanted to change "Subzero" but keep "\Movement" then you need a different script.
If your user actually types in "Subzero\Movement" then you're fine.
|
|
Back to top |
|
|
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Sun Aug 09, 2015 10:46 am Post subject: |
|
|
I think I need the other script. I just want to replace everything up until .XXX but keep the text after.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 09, 2015 12:53 pm Post subject: |
|
|
Then you'll need to provide me with the actual strings you're expecting.
I need something to tell it to stop replacing characters from this point on.
|
|
Back to top |
|
|
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Sun Aug 09, 2015 8:28 pm Post subject: |
|
|
If I tell you what I want to do actually will you be able to do it? I don't think it'd be something nice to do since this way I'm making you do all the work while I'm doing nothing.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 09, 2015 9:32 pm Post subject: |
|
|
Well, you'll want to use readString() at each aob[i].
Then, use string.gsub() to replace only the portion you want.
Or use string.find() to get to the '.' or '/' delimiter after the portion you want replaced.
Then use string.sub() to extract what you want to save and concatenate it with the user input.
Finally, use writeString() to insert the full, modified string back into the game.
http://lua-users.org/wiki/StringLibraryTutorial
|
|
Back to top |
|
|
thethiny Cheater Reputation: 0
Joined: 01 Apr 2012 Posts: 38 Location: earth
|
Posted: Mon Aug 10, 2015 12:40 am Post subject: |
|
|
Can you give me a usage example? I'm not able to perform the string.gsub on my results of the AOBscan. I've checked the wiki link and I understood the way the commands work (except for readString for I haven't found anything that teaches that).
I tried this to avoid loops, but I don't think it's getting the right address.
Code: |
local Folder = inputQuery("Folder Name", "Enter the folder's name:", "")
local Char = inputQuery("Character Name", "Enter the Character's file name:", "")
local Modded = inputQuery("Character Name", "Enter the Character_Costume",""
if Folder ~= nil then
if Char ~= nil and Char:len() > 0 then
aob = AOBScan("41 73 73 65 74 5C 43 48 41 52 5F * * * * * * * * * * * * * * * * " )
aobstr = readString(aob, 27, 1)
string.gsub(aobstr, "Asset", Folder)
string.gsub(aobstr, Modded, Char)
end
end |
or what about this?
Code: | Input = "Asset\\CHAR_" + Modded + ".xxx"
string.gsub(Input, "Asset", Folder)
string.gsub(Input, Modded, Char)
|
|
|
Back to top |
|
|
|