|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Desitute How do I cheat? Reputation: 0
Joined: 05 Mar 2018 Posts: 4
|
Posted: Mon Mar 05, 2018 7:00 pm Post subject: Freeze Float Value? |
|
|
Hello,
Basically, I have a teleport table.
Now I want to be able to save current float values to their exact values (X Pos, Y Pos, Z Pos), and then assign them to hotkeys to teleport to key places around the map.
The problem is that this float value is always changing. Is there anyway to lock them at the desired value and stop it from changing?
Cheers.
Description: |
|
Filesize: |
14.88 KB |
Viewed: |
5948 Time(s) |
|
|
|
Back to top |
|
|
Desitute How do I cheat? Reputation: 0
Joined: 05 Mar 2018 Posts: 4
|
Posted: Tue Mar 06, 2018 1:43 pm Post subject: |
|
|
EDIT:
Would I be best off using something like this?
Code: | [ENABLE]
aobscanmodule(TeleportA,WHGame.DLL,D9 0F 28 CD F3 0F 59 4C 24 24) // should be unique
alloc(newmem,$1000,"WHGame.DLL"+1A3B7A)
alloc(store_coord,256)
label(code)
label(return)
label(xpos)
label(ypos)
label(zpos)
label(en_save)
label(en_load)
label(save)
label(load)
registersymbol(en_save)
registersymbol(en_load)
store_coord:
xpos:
dd 0
ypos:
dd 0
zpos:
dd 0
en_save:
dd 0
en_load:
dd 0
newmem:
cmp [en_save],1
je save
cmp [en_load],1
je load
jmp code
save:
mov [en_save],0
push rbx
mov rbx,[rsp+00]
mov [xpos],rbx
mov rbx,[rsp+02]
mov [ypos],rbx
mov rbx,[rsp+04]
mov [zpos],rbx
pop rbx
jmp code
load:
mov [en_load],0
push rbx
mov rbx,[xpos]
mov [rsp+00],rbx
mov rbx,[ypos]
mov [rsp+02],rbx
mov rbx,[zpos]
mov [rsp+04],rbx
pop rbx
jmp code
code:
mulss xmm1,[rsp+24]
jmp return
TeleportA+04:
jmp newmem
nop
return:
registersymbol(TeleportA)
[DISABLE]
TeleportA+04:
db F3 0F 59 4C 24 24
unregistersymbol(TeleportA)
unregistersymbol(en_save)
unregistersymbol(en_load)
dealloc(newmem)
dealloc(store_coord)
|
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Tue Mar 06, 2018 3:30 pm Post subject: |
|
|
The code you posted looks like a working teleportor to me. What floats keep changing, is it the addresses that change?
And as for teleporters, it's best to write where and when the coordinates are written to, but for 99% of games I make tables for this works great.
You just need to run this Lua code; then use "I2CETeleporter.createMemoryRecords()" to generate the memory records, and have "ptrI2CETeleporterCoord" (and optionally "ptrI2CETeleporterWayPoint") set some where.
Code: | --[====================================================================================================================[
I2 Cheat Engine Teleporter
Version: 1.0.2
1.0.1:
* Initial setup.
1.0.2:
* Fixed saves memory record creation error.
* Fixed memory record append on existing memory records.
* Added "delete" and "rename" functions.
Author: Matt - TheyCallMeTim13 - MattI2.com
Features:
- Delete first requests a save to be deleted and is deleted on second call, unless force equates to true.
ptrI2CETeleporterCoord
ptrI2CETeleporterWayPoint
I2CETeleporter.createMemoryRecords()
]====================================================================================================================]--
local NAME = 'I2 Cheat Engine Teleporter'
local CLASS_NAME = 'I2CETeleporter'
local VERSION = '1.0.2'
local AUTHOR = 'Matt Irwin; [email protected]'
local LICENSE = [=[MIT License
Copyright (c) 2018 Matt Irwin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]=]
local format = string.format
local strE = string.empty or STRING_EMPTY or ''
local t = translate
local DEBUG = DEBUG or false
local LOGGER_LEVEL = 2 ---- WARN
local LineEnd = '\r\n'
local AutoLoad = true
local AutoAllocate = AutoLoad
local AutoLoadAndSave = true
local SavesFileName = 'I2CETeleporterSaves.txt'
local SavesFileAsTableFile = false
local OverRideSaveMemoryRecords = false
local writeToCoordsTimerTicksMax = 100
local MainMemoryRecordDescription = '_[ I2CETeleporter ]_'
local SavesMemoryRecordDescription = '_[ ' .. t('Saves') .. ' ]_'
local CoordPointerSymbol = 'ptrI2CETeleporterCoord'
local WayPointPointerSymbol = 'ptrI2CETeleporterWayPoint'
local SaveNameStringSymbol = 'strI2CETeleporterSaveName'
local NewSaveNameStringSymbol = 'strI2CETeleporterSaveNameNew'
local DataDelimiter = '<sep>'
local SaveNameStringMax = 60
local AutoSaveSavesFile = true
local Colors = {
Black = 0x000000,
White = 0xFFFFFF,
Silver = 0xC0C0C0,
Grey = 0x808080,
Red = 0x0000FF, -- 0xFF0000
Maroon = 0x000080, -- 0x800000
Yellow = 0x00FFFF, -- 0xFFFF00
Olive = 0x008080, -- 0x808000
Lime = 0x00FF00,
Green = 0x008000,
Aqua = 0xFFFF00, -- 0x00FFFF
Teal = 0x808000, -- 0x008080
Blue = 0xFF0000, -- 0x0000FF
Navy = 0x800000, -- 0x000080
Fuchsia = 0xFF00FF,
Purple = 0x800080,
}
--
--------
--------
-------- Logger
--------
local Logger = { ClassName = 'I2Logger', Name = 'I2CETeleporter' }
Logger.LEVELS = { OFF = 0, ERROR = 1, WARN = 2, INFO = 3, DEBUG = 4 }
Logger.Level = LOGGER_LEVEL or Logger.LEVELS.WARN
if DEBUG then Logger.Level = Logger.LEVELS.DEBUG end
Logger.print = print
function Logger.logEvent(level, msg, ex)
if Logger.Level >= level then
if Logger.Name ~= nil then
msg = Logger.Name .. ': ' .. msg
end
if Logger.ClassName ~= nil then
msg = Logger.ClassName .. '.' .. msg
end
Logger.print(msg)
if ex then Logger.print('Exception: ' .. tostring(ex)) end
end
end
for k,v in pairs(Logger.LEVELS) do
if v > 0 then
Logger[k:lower()] = function(msg, ex) return Logger.logEvent(v, msg, ex) end
Logger[k:lower() .. 'f'] = function(msg, ... ) return Logger.logEvent(v, format(msg, ... )) end
end
end
Logger.debugf('Loaded', Logger.ClassName)
--------
-------- Logger
--------
--------
local function split(s, delimiter)
result = {}
for match in (s .. delimiter):gmatch('(.-)' .. delimiter) do
table.insert(result, match)
end
return result
end
local function interp(s, tbl)
if s == nil then return end
return (s:gsub('($%b{})', function(w) return tbl[w:sub(3, -2)] or w end))
end
local function padR(str, len, char)
if str == nil or len == nil then return str end
if char == nil then char = ' ' end
return str .. string.rep(char, len - #str)
end
local function titleCase(s, s_char)
if type(s) ~= 'string' then return nil end
local patt = '%S+' -- match every thing but spaces.
local char = ' '
if s_char == '_' then
patt = '[^_]+' -- match every thing but underscores.
char = '_'
elseif s_char == '.' then
patt = '[^\\.]+' -- match every thing but periods.
char = '.'
elseif s_char == 'p' then
patt = '%P+' -- match every thing but punctuation.
char = '.'
end
local r = strE
for w in s:gfind(patt) do
local f = w:sub(1, 1)
if #r > 0 then r = r..char end
r = r..f:upper()..w:sub(2):lower()
end
if #r < 1 then r = s end
return r
end
local function getPointerSize()
aasStr = [====[
globalAlloc(memPointerTest, 0x8)
memPointerTest:
db FF FF FF FF FF FF FF FF
]====]
local assembled = autoAssemble(aasStr)
if assembled then
local p1 = readQword('memPointerTest')
local p2 = readPointer('memPointerTest')
if p1 == p2 then
return 0x8
else
return 0x4
end
end
return nil
end
local function getPointerSizeStrs()
local pointerSize = getPointerSize()
local pointerSizeStr = format('0x%X', pointerSize or 0x8)
local pointerFtmStr = '%016X'
local pointerWordSize = 'dq'
local pointerDefaultStr = 'dq 0'
if pointerSize == 0x4 then
pointerFtmStr = '%08X'
pointerWordSize = 'dd'
pointerDefaultStr = 'dd 0'
end
return pointerSize, pointerSizeStr, pointerFtmStr, pointerWordSize, pointerDefaultStr
end
--[====[
Keys:
SaveName
CoordPointerSymbol
CoordPointerAddress
WayPointPointerSymbol
WayPointPointerAddress
SaveNameStringSymbol
SaveNameStringAddress
NewSaveNameStringSymbol
NewSaveNameStringAddress
Xoffset
Yoffset
Zoffset
WayXoffset
WayYoffset
WayZoffset
X
Y
Z
WayX
WayY
WayZ
]====]--
local DEFAULT_SCRIPT_COLOR = Colors.Green
local DEFAULT_SAVE_MR_DESCRIPTION = t('Teleport to') .. ': ${SaveName} ()->'
local DEFAULT_SAVE_MR_SCRIPT = [==============================[
{$lua}
---- ${SaveName}
---- ${CoordPointerSymbol}: ${CoordPointerAddress}
---- ${X}, ${Y}, ${Z}
[Enable]
if syntaxcheck then return end
I2CETeleporter.teleport('${SaveName}')
[Disable]
]==============================]
local SaveLocationScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.save()
[Disable]
]==============================]
local TeleportToSaveScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.teleport()
[Disable]
]==============================]
local TeleportToWayPointScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.teleportToWayPoint()
[Disable]
]==============================]
local WriteSavesToFileScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.writeSavesToFile()
[Disable]
]==============================]
local ReadFromFileScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.readSavesFromFile()
[Disable]
]==============================]
local PrintSavesScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.printSaves()
[Disable]
]==============================]
local CreateMemoryRecordsScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.createMemoryRecords()
[Disable]
]==============================]
local DeleteSaveScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.delete()
[Disable]
]==============================]
local RenameSaveScript = [==============================[
{$lua}
[Enable]
if syntaxcheck then return end
I2CETeleporter.rename()
[Disable]
]==============================]
I2CETeleporter = {
MainMemoryRecordDescription = MainMemoryRecordDescription,
SavesMemoryRecordDescription = SavesMemoryRecordDescription,
CoordPointerSymbol = CoordPointerSymbol,
-- CoordPointerAddress = 0,
WayPointPointerSymbol = WayPointPointerSymbol,
-- WayPointPointerAddress = 0,
SaveNameStringSymbol = SaveNameStringSymbol,
-- SaveNameStringAddress = 0,
NewSaveNameStringSymbol = NewSaveNameStringSymbol,
-- NewSaveNameStringAddress = 0,
AutoLoad = AutoLoad,
AutoAllocate = AutoAllocate,
AutoLoadAndSave = AutoLoadAndSave,
SavesFileName = SavesFileName,
SavesFileAsTableFile = SavesFileAsTableFile,
OverRideSaveMemoryRecords = OverRideSaveMemoryRecords,
AutoSaveSavesFile = AutoSaveSavesFile,
writeToCoordsTimerTicksMax = writeToCoordsTimerTicksMax,
----
Xoffset = 0,
Yoffset = 4,
Zoffset = 8,
----
XaddOnWrite = 0,
YaddOnWrite = 0,
ZaddOnWrite = 0,
----
XaddOnRead = 0,
YaddOnRead = 0,
ZaddOnRead = 0,
----
WayXoffset = 0,
WayYoffset = 4,
WayZoffset = 8,
----
WayXaddOnRead = 0,
WayYaddOnRead = 0,
WayZaddOnRead = 0,
----
SaveMemoryRecord = {
Description = DEFAULT_SAVE_MR_DESCRIPTION,
Type = vtAutoAssembler,
Script = DEFAULT_SAVE_MR_SCRIPT,
Color = DEFAULT_SCRIPT_COLOR,
},
----
MainMemoryRecords = {
Description = MainMemoryRecordDescription,
IsGroupHeader = true,
options = "[moHideChildren]",
MemoryRecords = {
{
Description = '** ' .. t('Set String to a unique name, click save and save is writen to table file.') .. ' **',
IsGroupHeader = true,
Color = Colors.Maroon,
},
{
Description = '** ' .. t('Use "Create Memory Records" in the "Helpers" section to generate scripts.') .. ' **',
IsGroupHeader = true,
Color = Colors.Maroon,
},
{
Description = '** ' .. t('"Create Memory Records" generates scripts from saves.') .. ' **',
IsGroupHeader = true,
Color = Colors.Maroon,
},
{
Description = t('Save Name'),
Type = vtString,
Address = '${SaveNameStringSymbol}',
Color = Colors.Blue,
String = {
Size = SaveNameStringMax,
},
},
{
Description = t('Save Location') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = SaveLocationScript,
},
{
Description = t('Teleport To Save') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = TeleportToSaveScript,
},
{
Description = t('Teleport To Way Point') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = TeleportToWayPointScript,
},
{
Description = SavesMemoryRecordDescription,
IsGroupHeader = true,
options = "[moHideChildren]",
AppendSaves = true,
},
{
Description = '_[ Helpers ]_',
IsGroupHeader = true,
options = "[moHideChildren]",
Color = Colors.Grey,
MemoryRecords = {
{
Description = t('Create Memory Records') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = CreateMemoryRecordsScript,
},
{
Description = t('Write Saves To File') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = WriteSavesToFileScript,
},
{
Description = t('Print Saves') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = PrintSavesScript,
},
{
Description = '_[ Rename Save ]_',
IsGroupHeader = true,
options = "[moHideChildren]",
MemoryRecords = {
{
Description = t('Save Name (to rename)'),
Type = vtString,
Address = '${SaveNameStringSymbol}',
Color = Colors.Blue,
String = {
Size = SaveNameStringMax,
},
},
{
Description = t('New Save Name'),
Type = vtString,
Address = '${NewSaveNameStringSymbol}',
Color = Colors.Blue,
String = {
Size = SaveNameStringMax,
},
},
{
Description = t('Rename Save') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = RenameSaveScript,
},
},
},
{
Description = t('Read From File') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = ReadFromFileScript,
},
{
Description = t('Delete Save ** Must Enable 2 Times **') .. ' ()->',
Type = vtAutoAssembler,
Color = DEFAULT_SCRIPT_COLOR,
Script = DeleteSaveScript,
},
},
},
},
},
----
DataDelimiter = DataDelimiter,
LineEnd = LineEnd,
----
-- Finalized = false,
-- Saves = {
-- ['Save Name'] = {
-- X = 0,
-- Y = 0,
-- Z = 0,
-- },
-- },
Logger = Logger,
}
function I2CETeleporter.initialize()
Logger.debug('initialize: initializing')
if I2CETeleporter.AutoAllocate then
local function I2CETeleporterInitMemoryTimer_tick(timer)
if process ~= nil then
Logger.debugf('initialize: killing timer: %s', timer)
timer.destroy()
if I2CETeleporter.AutoLoad then
Logger.info('initialize: auto loading')
I2CETeleporter.initMemory()
if I2CETeleporter.AutoLoadAndSave then
Logger.debugf('initialize: hooking main form "OnClose": "%s"', MainForm.OnClose)
I2CETeleporter.readSavesFromFile()
I2CETeleporter.MainFormOnClose = MainForm.OnClose
MainForm.OnClose = I2CETeleporter.OnClose
end
end
end
end
local intervals = 1000
local timer = createTimer(MainForm)
timer.Interval = intervals
timer.OnTimer = I2CETeleporterInitMemoryTimer_tick
Logger.info('initialize: timer started')
end
Logger.infof('Init: initialized')
end
function I2CETeleporter.finalize()
Logger.debug('finalize: finalizing')
if I2CETeleporter.AutoLoadAndSave then --- Can't save table file on close with out forcing table save.
I2CETeleporter.writeSavesToFile()
end
if I2CETeleporter.AutoAllocate then
I2CETeleporter.finaMemory()
end
end
function I2CETeleporter.OnClose(sender)
if not I2CETeleporter.Finalized then
Logger.infof('OnClose: calling main form "OnClose"')
MainForm.OnClose = I2CETeleporter.MainFormOnClose
I2CETeleporter.Finalized = true
closeCE()
end
end
function I2CETeleporter.initMemory()
Logger.debug('initMemory: initializing memory')
local pointerSize, pointerSizeStr, pointerFtmStr, pointerWordSize, pointerDefaultStr = getPointerSizeStrs()
if getAddressSafe(I2CETeleporter.CoordPointerSymbol) then
deAlloc(I2CETeleporter.CoordPointerSymbol)
unregisterSymbol(I2CETeleporter.CoordPointerSymbol)
end
I2CETeleporter.CoordPointerAddress = allocateSharedMemory(I2CETeleporter.CoordPointerSymbol, getPointerSize() or 0x8)
if I2CETeleporter.CoordPointerAddress then
Logger.debugf('initMemory: memory allocated: %s, ' .. pointerFtmStr, I2CETeleporter.CoordPointerSymbol,
I2CETeleporter.CoordPointerAddress)
registerSymbol(I2CETeleporter.CoordPointerSymbol, I2CETeleporter.CoordPointerAddress, true)
else
Logger.debugf('initMemory: memory allocation failed: %s', I2CETeleporter.CoordPointerSymbol)
end
if getAddressSafe(I2CETeleporter.WayPointPointerSymbol) then
deAlloc(I2CETeleporter.WayPointPointerSymbol)
unregisterSymbol(I2CETeleporter.WayPointPointerSymbol)
end
I2CETeleporter.WayPointPointerAddress = allocateSharedMemory(I2CETeleporter.WayPointPointerSymbol, getPointerSize() or 0x8)
if I2CETeleporter.WayPointPointerAddress then
Logger.debugf('initMemory: memory allocated: %s, ' .. pointerFtmStr, I2CETeleporter.WayPointPointerSymbol,
I2CETeleporter.WayPointPointerAddress)
registerSymbol(I2CETeleporter.WayPointPointerSymbol, I2CETeleporter.WayPointPointerAddress, true)
else
Logger.debugf('initMemory: memory allocation failed: %s', I2CETeleporter.WayPointPointerSymbol)
end
if getAddressSafe(I2CETeleporter.SaveNameStringSymbol) then
deAlloc(I2CETeleporter.SaveNameStringSymbol)
unregisterSymbol(I2CETeleporter.SaveNameStringSymbol)
end
local size = SaveNameStringMax * 2
if size < 0x100 then
size = 0x100
end
I2CETeleporter.SaveNameStringAddress = allocateSharedMemory(I2CETeleporter.SaveNameStringSymbol, size or 0x100)
if I2CETeleporter.SaveNameStringAddress then
Logger.debugf('initMemory: memory allocated: %s, ' .. pointerFtmStr, I2CETeleporter.SaveNameStringSymbol,
I2CETeleporter.SaveNameStringAddress)
registerSymbol(I2CETeleporter.SaveNameStringSymbol, I2CETeleporter.SaveNameStringAddress, true)
local bytes = { string.byte(t('Starting location'), 1, -1) }
bytes[#bytes + 1] = 0x00
writeBytes(I2CETeleporter.SaveNameStringSymbol, bytes)
else
Logger.debugf('initMemory: memory allocation failed: %s', I2CETeleporter.SaveNameStringSymbol)
end
if getAddressSafe(I2CETeleporter.NewSaveNameStringSymbol) then
deAlloc(I2CETeleporter.NewSaveNameStringSymbol)
unregisterSymbol(I2CETeleporter.NewSaveNameStringSymbol)
end
local size = SaveNameStringMax * 2
if size < 0x100 then
size = 0x100
end
I2CETeleporter.NewSaveNameStringAddress = allocateSharedMemory(I2CETeleporter.NewSaveNameStringSymbol, size or 0x100)
if I2CETeleporter.NewSaveNameStringAddress then
Logger.debugf('initMemory: memory allocated: %s, ' .. pointerFtmStr, I2CETeleporter.NewSaveNameStringSymbol,
I2CETeleporter.NewSaveNameStringAddress)
registerSymbol(I2CETeleporter.NewSaveNameStringSymbol, I2CETeleporter.NewSaveNameStringAddress, true)
writeBytes(I2CETeleporter.NewSaveNameStringSymbol, { 0 })
else
Logger.debugf('initMemory: memory allocation failed: %s', I2CETeleporter.NewSaveNameStringSymbol)
end
Logger.infof('InitMemory: memory initialized')
end
function I2CETeleporter.finaMemory()
Logger.debug('finaMemory: finalizing')
deAlloc(I2CETeleporter.CoordPointerSymbol)
Logger.debugf('finaMemory: memory deallocated: %s', I2CETeleporter.CoordPointerSymbol)
deAlloc(I2CETeleporter.WayPointPointerSymbol)
Logger.debugf('finaMemory: memory deallocated: %s', I2CETeleporter.WayPointPointerSymbol)
deAlloc(I2CETeleporter.SaveNameStringSymbol)
Logger.debugf('finaMemory: memory deallocated: %s', I2CETeleporter.SaveNameStringSymbol)
deAlloc(I2CETeleporter.NewSaveNameStringSymbol)
Logger.debugf('finaMemory: memory deallocated: %s', I2CETeleporter.NewSaveNameStringSymbol)
unregisterSymbol(I2CETeleporter.CoordPointerSymbol)
unregisterSymbol(I2CETeleporter.WayPointPointerSymbol)
unregisterSymbol(I2CETeleporter.SaveNameStringSymbol)
unregisterSymbol(I2CETeleporter.NewSaveNameStringSymbol)
end
function I2CETeleporter.writeSavesToFile(fileName)
local del = I2CETeleporter.DataDelimiter
local le = I2CETeleporter.LineEnd
if type(fileName) ~= 'string' then
fileName = I2CETeleporter.SavesFileName or 'I2CETeleporterSaves.txt'
end
if I2CETeleporter.Saves == nil then
local msg = 'writeSavesToFile: no saves to write'
Logger.error(msg)
return
end
local fileStr = strE
for k, v in pairs(I2CETeleporter.Saves) do
fileStr = fileStr .. k:gsub('\r', strE):gsub('\n', strE) .. del .. v.X .. del .. v.Y .. del .. v.Z .. le
end
if I2CETeleporter.SavesFileAsTableFile then
local tableFile = findTableFile(fileName)
if tableFile == nil then
tableFile = createTableFile(fileName)
end
if tableFile == nil then
local msg = format('writeSavesToFile: Error opening table file, "%s"', fileName)
Logger.error(msg)
return
end
local stream = tableFile.getData()
local bytes = { string.byte(fileStr, 1, -1) }
stream.write(bytes)
Logger.infof('writeSavesToFile: table file saved, "%s"', fileName)
else
local f, err = io.open(I2CETeleporter.SavesFileName, 'w')
if err then
Logger.errorf('writeSavesToFile: the local file could not be opened, "%s"', fileName)
elseif f and not err then
f:write(fileStr)
f:close()
end
end
return fileName
end
function I2CETeleporter.readSavesFromFile(fileName)
local del = I2CETeleporter.DataDelimiter
if type(fileName) ~= 'string' then
fileName = I2CETeleporter.SavesFileName or 'I2CETeleporterSaves.txt'
end
local fileStr = nil
local f, err = io.open(I2CETeleporter.SavesFileName, 'r')
if err then
--Logger.debugf('readSavesFromFile: the local file could not be opened, "%s"', fileName)
local tableFile = findTableFile(fileName)
if tableFile == nil then
--Logger.warnf('readSavesFromFile: the local file could not be opened, "%s"', fileName)
Logger.warnf('readSavesFromFile: table file not found, "%s"', fileName)
return
end
local stream = tableFile.getData()
local bytes = stream.read(stream.Size)
for i = 1, #bytes do
if fileStr == nil then
fileStr = strE
end
fileStr = fileStr .. string.char(bytes[i])
end
elseif f and not err then
fileStr = f:read('*all')
f:close()
end
if fileStr == nil then
return
end
if I2CETeleporter.Saves == nil then
I2CETeleporter.Saves = {}
end
fileStr = fileStr:gsub('\r\n', '\n'):gsub('\r', '\n')
local lines = split(fileStr, '\n')
local lastSave = nil
for i, line in ipairs(lines) do
if line ~= nil then
local save = split(line, del)
if save ~= nil and save[1] ~= nil and save[2] ~= nil and save[3] ~= nil and save[4] ~= nil then
I2CETeleporter.Saves[save[1]] = {
Name = save[1],
X = tonumber(save[2]),
Y = tonumber(save[3]),
Z = tonumber(save[4]),
}
lastSave = save[1]
Logger.debugf('readSavesFromFile: loading save: %s, %s, %s, %s', save[1], save[2], save[3], save[4])
end
end
end
if lastSave ~= nil then
local bytes = { string.byte(lastSave, 1, -1) }
bytes[#bytes + 1] = 0x00
writeBytes(I2CETeleporter.SaveNameStringSymbol, bytes)
end
Logger.infof('readSavesFromFile: table file loaded, "%s"', fileName)
return I2CETeleporter.Saves
end
function I2CETeleporter.printSaves()
if I2CETeleporter.Saves == nil then
local msg = 'printSaves: no saves to write'
Logger.error(msg)
return
end
for k, v in pairs(I2CETeleporter.Saves) do
print(format('%s : %f9, %f9, %f9', padR(k, 25), v.X, v.Y, v.Z))
end
Logger.debug('printSaves: saves printed')
end
function I2CETeleporter.writeToCoords(x, y, z)
local pointerSize, pointerSizeStr, pointerFtmStr, pointerWordSize, pointerDefaultStr = getPointerSizeStrs()
if type(x) ~= 'number' or type(y) ~= 'number' or type(z) ~= 'number' then
local msg = format('writeToCoords: write canceled, coordinate must be a number: %s, %s, %s',
type(x), type(y), type(z))
Logger.error(msg)
error(msg)
return
end
if (math.type(x) == 'integer' and x == 0)
or (math.type(y) == 'integer' and y == 0)
or (math.type(z) == 'integer' and z == 0) then
local msg = format('writeToCoords: write canceled, coordinate zero: %f9, %f9, %f9', x, y, z)
Logger.error(msg)
error(msg)
return
end
local base = getAddress('[' .. I2CETeleporter.CoordPointerSymbol .. ']')
if base == nil or base == 0 then
local msg = format('writeToCoords: write canceled, no address at base: %s', I2CETeleporter.CoordPointerSymbol)
Logger.error(msg)
error(msg)
return
end
local function writeToCoordsTimer_tick(timer)
if I2CETeleporter.writeToCoordsTimerTicksMax == nil or I2CETeleporter.writeToCoordsTimerTicks == nil then
I2CETeleporter.writeToCoordsTimerTicksMax = 0
I2CETeleporter.writeToCoordsTimerTicks = 0
elseif I2CETeleporter.writeToCoordsTimerTicks > I2CETeleporter.writeToCoordsTimerTicksMax then
timer.destroy()
I2CETeleporter.writeToCoordsTimerTicks = 0
else
I2CETeleporter.writeToCoordsTimerTicks = I2CETeleporter.writeToCoordsTimerTicks + 1
end
Logger.debugf('writeToCoords: writing: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.Xoffset, x)
Logger.debugf('writeToCoords: writing: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.Yoffset, y)
Logger.debugf('writeToCoords: writing: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.Zoffset, z)
writeFloat(base + I2CETeleporter.Xoffset, x + I2CETeleporter.XaddOnWrite)
writeFloat(base + I2CETeleporter.Yoffset, y + I2CETeleporter.YaddOnWrite)
writeFloat(base + I2CETeleporter.Zoffset, z + I2CETeleporter.ZaddOnWrite)
end
local intervals = 100
local timer = createTimer(MainForm, true)
timer.Interval = intervals
timer.OnTimer = writeToCoordsTimer_tick
return x, y, z
end
function I2CETeleporter.readFromCoords()
local pointerSize, pointerSizeStr, pointerFtmStr, pointerWordSize, pointerDefaultStr = getPointerSizeStrs()
local base = getAddress('[' .. I2CETeleporter.CoordPointerSymbol .. ']')
if base == nil or base == 0 then
local msg = format('readFromCoords: read canceled, no address at base: %s', I2CETeleporter.CoordPointerSymbol)
Logger.error(msg)
error(msg)
return
end
x = readFloat(base + I2CETeleporter.Xoffset) + I2CETeleporter.XaddOnRead
y = readFloat(base + I2CETeleporter.Yoffset) + I2CETeleporter.YaddOnRead
z = readFloat(base + I2CETeleporter.Zoffset) + I2CETeleporter.ZaddOnRead
Logger.debugf('readFromCoords: read: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.Xoffset, x)
Logger.debugf('readFromCoords: read: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.Yoffset, y)
Logger.debugf('readFromCoords: read: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.Zoffset, z)
return x, y, z
end
function I2CETeleporter.readFromWayPoint()
local pointerSize, pointerSizeStr, pointerFtmStr, pointerWordSize, pointerDefaultStr = getPointerSizeStrs()
local base = getAddress('[' .. I2CETeleporter.WayPointPointerSymbol .. ']')
if base == nil or base == 0 then
local msg = format('readFromWayPoint: read canceled, no address at base: %s', I2CETeleporter.WayPointPointerSymbol)
Logger.error(msg)
error(msg)
return
end
x = readFloat(base + I2CETeleporter.WayXoffset) + I2CETeleporter.WayXaddOnRead
y = readFloat(base + I2CETeleporter.WayYoffset) + I2CETeleporter.WayYaddOnRead
z = readFloat(base + I2CETeleporter.WayZoffset) + I2CETeleporter.WayZaddOnRead
Logger.debugf('readFromWayPoint: read: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.WayXoffset, x)
Logger.debugf('readFromWayPoint: read: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.WayYoffset, y)
Logger.debugf('readFromWayPoint: read: ' .. pointerFtmStr .. ' : %f9', base + I2CETeleporter.WayZoffset, z)
return x, y, z
end
function I2CETeleporter.teleport(name)
if name == nil then
name = readString(I2CETeleporter.SaveNameStringSymbol, SaveNameStringMax)
end
if type(name) ~= 'string' then
local msg = format('teleport: teleport canceled, "name" must be a string: %s', type(name))
Logger.error(msg)
error(msg)
return
end
local save = I2CETeleporter.Saves[name]
if save == nil then
local msg = format('teleport: teleport canceled, save not found: %s', name)
Logger.error(msg)
error(msg)
return
end
Logger.debugf('teleport: teleporting to save: %s', name)
return I2CETeleporter.writeToCoords(save.X, save.Y, save.Z)
end
function I2CETeleporter.save(name)
if name == nil then
name = readString('strI2CETeleporterSaveName', SaveNameStringMax)
end
if type(name) ~= 'string' then
local msg = format('save: save canceled, "name" must be a string: %s', type(name))
Logger.error(msg)
error(msg)
return
end
local x, y, z = I2CETeleporter.readFromCoords()
if type(x) ~= 'number' or type(y) ~= 'number' or type(z) ~= 'number' then
local msg = format('save: save canceled, coordinate must be a number: %s, %s, %s', type(x), type(y), type(z))
Logger.error(msg)
error(msg)
return
end
if (math.type(x) == 'integer' and x == 0)
or (math.type(y) == 'integer' and y == 0)
or (math.type(z) == 'integer' and z == 0) then
local msg = format('save: save canceled, coordinate zero: %f9, %f9, %f9', x, y, z)
Logger.error(msg)
error(msg)
return
end
if I2CETeleporter.Saves == nil then
I2CETeleporter.Saves = {}
end
Logger.debugf('save: saving: %s, %f9, %f9, %f9', name, x, y, z)
I2CETeleporter.Saves[name] = { Name = name, X = x, Y = y, Z = z }
if I2CETeleporter.AutoSaveSavesFile then
I2CETeleporter.writeSavesToFile()
end
return I2CETeleporter.Saves[name]
end
function I2CETeleporter.delete(name, force)
if name == nil then
name = readString('strI2CETeleporterSaveName', SaveNameStringMax)
end
if type(name) ~= 'string' then
local msg = format('delete: delete canceled, "name" must be a string: %s', type(name))
Logger.error(msg)
error(msg)
return
end
if I2CETeleporter.Saves == nil then
local msg = 'delete: no saves to delete'
Logger.error(msg)
return
end
if force or I2CETeleporter.DeleteRequest == I2CETeleporter.Saves[name] then
I2CETeleporter.Saves[name] = nil
Logger.infof('delete: save deleted: %s', name)
else
I2CETeleporter.DeleteRequest = I2CETeleporter.Saves[name]
Logger.debugf('delete: delete request set for: %s', name)
end
if I2CETeleporter.AutoSaveSavesFile then
I2CETeleporter.writeSavesToFile()
end
end
function I2CETeleporter.rename(name, newName)
if name == nil then
name = readString('strI2CETeleporterSaveName', SaveNameStringMax)
end
if type(name) ~= 'string' then
local msg = format('rename: rename canceled, "name" must be a string: %s', type(name))
Logger.error(msg)
error(msg)
return
end
if newName == nil then
newName = readString('strI2CETeleporterSaveNameNew', SaveNameStringMax)
end
if type(newName) ~= 'string' then
local msg = format('rename: rename canceled, "newName" must be a string: %s', type(newName))
Logger.error(msg)
error(msg)
return
end
if I2CETeleporter.Saves == nil then
local msg = 'rename: no saves to rename'
Logger.error(msg)
return
end
I2CETeleporter.Saves[newName] = I2CETeleporter.Saves[name]
I2CETeleporter.Saves[name] = nil
local bytes = { string.byte(newName, 1, -1) }
bytes[#bytes + 1] = 0x00
writeBytes(I2CETeleporter.SaveNameStringSymbol, bytes)
writeBytes(I2CETeleporter.NewSaveNameStringSymbol, { 0 })
if I2CETeleporter.AutoSaveSavesFile then
I2CETeleporter.writeSavesToFile()
end
return I2CETeleporter.Saves[newName]
end
function I2CETeleporter.teleportToWayPoint()
local x, y, z = I2CETeleporter.readFromWayPoint()
Logger.debugf('teleportToWayPoint: teleporting to way point: %f9, %f9, %f9', x, y, z)
return I2CETeleporter.writeToCoords(x, y, z)
end
function I2CETeleporter.createMR(mrTbl, interpTbl, appendMr)
if mrTbl == nil then return end
local memoryRecord = nil
local memoryRecordCreated = false
if mrTbl.Description ~= nil then
memoryRecord = AddressList.getMemoryRecordByDescription(interp(mrTbl.Description, interpTbl))
end
if memoryRecord == nil then
memoryRecord = AddressList.createMemoryRecord()
memoryRecordCreated = true
Logger.debug('createMR: creating new memory record.')
else
Logger.debug('createMR: memory record found.')
end
local isScript = false
local scriptStr = nil
for k, v in pairs(mrTbl) do
if k == 'MemoryRecords' and type(v) == 'table' then
Logger.debug('createMR: generating child memory records.')
for i = 1, #v do
if not I2CETeleporter.OverRideSaveMemoryRecords and v[i].Description ~= nil
and v[i].Description ~= I2CETeleporter.SavesMemoryRecordDescription
and AddressList.getMemoryRecordByDescription(interp(v[i].Description, interpTbl)) ~= nil then
Logger.debugf('createMR: child memory record found: %s', interp(v[i].Description, interpTbl))
--break
else
I2CETeleporter.createMR(v[i], interpTbl, memoryRecord)
end
end
else
if type(v) == 'table' and memoryRecord[k] ~= nil then
if k == 'Hotkey' then
for v_k, v_v in pairs(v) do
if v_v ~= nil then
memoryRecord[k][v_k] = v_v
end
end
elseif (k == 'Offset' or k == 'OffsetText') then
for v_k, v_v in ipairs(v) do
memoryRecord.setOffsetCount(#v)
if v_v ~= nil then
memoryRecord.setOffset(v_k - 1, tonumber(interp(v_v, interpTbl), 16))
Logger.debugf('createMR: memoryRecord Offset set: %d, %X',
v_k - 1, tonumber(interp(v_v, interpTbl), 16))
end
end
else
for v_k, v_v in pairs(v) do
if v_v ~= nil then
memoryRecord[k][v_k] = v_v
end
end
end
else
if k == 'AppendSaves' then
Logger.debug('createMR: found "AppendSaves"')
if I2CETeleporter.Saves ~= nil then
local tbl = {}
for k, v in pairs(interpTbl) do
tbl[k] = v
end
for k, v in pairs(I2CETeleporter.Saves) do
Logger.debugf('createMR: creating child memory record: %s', k)
tbl.SaveName = k
tbl.X = format('%f9', v.X)
tbl.Y = format('%f9', v.Y)
tbl.Z = format('%f9', v.Z)
I2CETeleporter.createMR(I2CETeleporter.SaveMemoryRecord, tbl, memoryRecord)
end
end
else
if k == 'Type' and v == vtAutoAssembler then
isScript = true
elseif k == 'Script' and type(v) == 'string' then
scriptStr = interp(v, interpTbl)
end
if k == 'Type' and type(v) == 'string'
and (v:lower() == 'pointer' or v:lower() == 'ptr' or v:lower() == 'p') then
if interpTbl.PointerSize == '0x4' then
memoryRecord[k] = vtDword
else
memoryRecord[k] = vtQword
end
else
if type(v) == 'string' then
v = interp(v, interpTbl)
end
memoryRecord[k] = v
end
end
end
end
end
if appendMr ~= nil and memoryRecordCreated then
memoryRecord.appendToEntry(appendMr)
end
if isScript and scriptStr == nil then
memoryRecord.Script = interpTbl.Script
elseif scriptStr ~= nil then
memoryRecord.Script = scriptStr
end
local lDStr = memoryRecord.Description:sub(1, 40)
Logger.debugf('createMR: done: memory record: ID: % 3d, Type: % 2d, "%s".',
memoryRecord.ID, memoryRecord.Type, lDStr)
return memoryRecord
end
function I2CETeleporter.createMemoryRecords()
local selMR = AddressList.getSelectedRecord()
local pointerSize, pointerSizeStr, pointerFtmStr, pointerWordSize, pointerDefaultStr = getPointerSizeStrs()
Logger.info('createMemoryRecords: generating memory records.')
local mrTbl = I2CETeleporter.MainMemoryRecords
local createdMemoryRecordsTbl = { }
local saveName = readString(I2CETeleporter.SaveNameStringSymbol, SaveNameStringMax)
local interpTbl = {
SaveName = saveName,
CoordPointerSymbol = I2CETeleporter.CoordPointerSymbol,
CoordPointerAddress = format(pointerFtmStr, I2CETeleporter.CoordPointerAddress),
WayPointPointerSymbol = I2CETeleporter.WayPointPointerSymbol,
WayPointPointerAddress = format(pointerFtmStr, I2CETeleporter.WayPointPointerAddress),
SaveNameStringSymbol = I2CETeleporter.SaveNameStringSymbol,
SaveNameStringAddress = format(pointerFtmStr, I2CETeleporter.SaveNameStringAddress),
NewSaveNameStringSymbol = I2CETeleporter.NewSaveNameStringSymbol,
NewSaveNameStringAddress = format(pointerFtmStr, I2CETeleporter.NewSaveNameStringAddress),
Xoffset = format('%X', I2CETeleporter.Xoffset),
Yoffset = format('%X', I2CETeleporter.Yoffset),
Zoffset = format('%X', I2CETeleporter.Zoffset),
WayXoffset = format('%X', I2CETeleporter.WayXoffset),
WayYoffset = format('%X', I2CETeleporter.WayYoffset),
WayZoffset = format('%X', I2CETeleporter.WayZoffset),
X = strE,
Y = strE,
Z = strE,
}
if I2CETeleporter.Saves ~= nil and I2CETeleporter.Saves[saveName] ~= nil then
interpTbl.X = format('%f9', I2CETeleporter.Saves[saveName].X)
interpTbl.Y = format('%f9', I2CETeleporter.Saves[saveName].Y)
interpTbl.Z = format('%f9', I2CETeleporter.Saves[saveName].Z)
end
if mrTbl.Description ~= nil then
createdMemoryRecordsTbl[1] = I2CETeleporter.createMR(mrTbl, interpTbl)
else
for i = 1, #mrTbl do
createdMemoryRecordsTbl[i] = I2CETeleporter.createMR(mrTbl[i], interpTbl)
end
end
if selMR ~= nil then
AddressList.setSelectedRecord(selMR)
end
return createdMemoryRecordsTbl
end
function I2CETeleporter.autoLoad()
local function I2CETeleporterAutoLoadTimer_tick(timer)
Logger.debugf('autoLoad: killing timer: %s', timer)
timer.destroy()
if I2CETeleporter.AutoLoad then
Logger.info('autoLoad: auto loading')
I2CETeleporter.initialize()
end
end
---- Use timer to allow other files to load templates and keep menu items in same spot.
local intervals = 100
local timer = createTimer(MainForm)
timer.Interval = intervals
timer.OnTimer = I2CETeleporterAutoLoadTimer_tick
Logger.info('autoLoad: timer started')
end
I2CETeleporter.autoLoad()
return I2CETeleporter
|
_________________
|
|
Back to top |
|
|
Desitute How do I cheat? Reputation: 0
Joined: 05 Mar 2018 Posts: 4
|
Posted: Tue Mar 06, 2018 3:38 pm Post subject: |
|
|
TheyCallMeTim13 wrote: | The code you posted looks like a working teleportor to me. What floats keep changing, is it the addresses that change?
And as for teleporters, it's best to write where and when the coordinates are written to, but for 99% of games I make tables for this works great. |
Well the save function gives me a value when I hit the hotkey, but when I hit load (to teleport back to the save) it just sets the value to 1 and doesn't do anything.
I don't see why it wouldn't work myself.
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Tue Mar 06, 2018 8:28 pm Post subject: |
|
|
Are you sure you're reading and writing to the right address? You're using the stack pointer, did you adjust for the PUSH to the stack? I tend to stay away form the stack point if I can. But I think you may need to add 8 to the offsets, if you haven't already. Just step though your code and check the stack to see.
_________________
|
|
Back to top |
|
|
Desitute How do I cheat? Reputation: 0
Joined: 05 Mar 2018 Posts: 4
|
Posted: Wed Mar 07, 2018 5:32 pm Post subject: |
|
|
TheyCallMeTim13 wrote: | Are you sure you're reading and writing to the right address? You're using the stack pointer, did you adjust for the PUSH to the stack? I tend to stay away form the stack point if I can. But I think you may need to add 8 to the offsets, if you haven't already. Just step though your code and check the stack to see. |
Well im relatively new to deep diving into cheat engine but that might be a good point.
I've been following tutorials and stuff, and I don't expect to be spoon fed, but I think I know where I have messed up. Ill list my steps if thats okay.
So I have my pointers already.
1) Right Click "XPos" and hit "Find what accesses this address" and then hit "Find out what accesses the address pointed by this pointer"
2) I get 10 results/opcodes. I get lost here because I don't know which of those opcodes I am supposed to disassemble or I dont know if I need to disassemble anything. In this case Ive disassembled the first result.
3) I dissect the data structure of first highlighted result.
4) I then type at the top the address for my "XPos" and define a new structure. Now usually, all three of my XYZ are found in a row with the offsets of 00 04 and 08. Which is where my offsets in the script come from.
5) In this case, the first value I find is my "ZPos" which isnt near my X and Y Pos.
6) So I go back and disassemble the next OP code, dissect the first highlighted result. Again, same thing, "ZPos" is by itself and the others are nowhere to be seen.
I think I am missing something or way over complicating this.
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Wed Mar 07, 2018 10:07 pm Post subject: |
|
|
So if you freeze the "XPos" does this stop you from moving? How did you find the X, I always look for Y and the rest have always been up or down a few. I have only seen this if its not the real value, like one that does make the player jumpy/buggy but freezing it won't lock you to that position.
_________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|