Auto-attach list in CE

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
krul
Expert Cheater
Expert Cheater
Posts: 101
Joined: Tue Jan 30, 2018 7:11 pm
Reputation: 7

Auto-attach list in CE

Post by krul »

Would it be possible to implement in CE a toolbar list in which you could put [I]name[/I].exe once, so next time you open the table and start the game,

it automatically attaches the table to that [I]name[/I].exe .

You won't need to re-attach exe every time.
Last edited by krul on Sun Jun 03, 2018 10:06 pm, edited 2 times in total.

User avatar
FreeER
Expert Cheater
Expert Cheater
Posts: 116
Joined: Fri Mar 10, 2017 7:11 pm
Reputation: 28

Auto-attach list in CE

Post by FreeER »

Use CE's settings?

[IMG]https://i.imgur.com/PB0RQNs.png[/IMG]



For a table you can use some lua code... though default settings will cause you to get a prompt when you open the table if you put it in the Table's Lua Script which I find annoying (but I also don't want to just run everyone's lua code), you could also put it in an AA script by using {$lua} to switch it to lua ({$asm} would switch back, but all lua sections are run before AA code is done, returned strings are used as AA code in the place of the lua section which can occasionally be useful) in which case you have to enable that script to attach to the game or just do it manually.



[code]getAutoAttachList().add('game.exe') -- open first time (same as trainer generated code)



-- check every second if game has closed and try to reopen

local t = createTimer()

t.Interval = 1000

t.OnTimer = function()

if process and readByte(process,1) == nil then

-- disable all scripts (could do something more advanced to reenable them but.)

for i=0, AddressList.Count -1 do

local mr = AddressList[i]

if mr.type == vtAutoAssembler and mr.Active then

mr.disableWithoutExecute()

end

end

-- try to reopen process

openProcess(process)

end

end[/code]



or something like that, I never do it so it could be slightly wrong, you can definitely find working examples using google to search the CE forums.
Last edited by FreeER on Sun Jun 03, 2018 10:20 pm, edited 5 times in total.

krul
Expert Cheater
Expert Cheater
Posts: 101
Joined: Tue Jan 30, 2018 7:11 pm
Reputation: 7

Auto-attach list in CE

Post by krul »

Only table I have seen to do so is this [URL]https://fearlessrevolution.com/attachments/darksoulsxxx-ct.43/[/URL]



It excutes the script on the beginning but is written for Dark souls



[SPOILER="long code"]

[ICODE=lua]controlMainForm = getMainForm()

AddressList = getAddressList()

-- Remove the first hyphen from the next line to comment out the Cheat Engine slim line code

---[[

--Compact mode

control_setVisible(wincontrol_getControl(controlMainForm,0), false)

control_setVisible(wincontrol_getControl(controlMainForm,2), false)

control_setVisible(wincontrol_getControl(controlMainForm,3), false)

--end

--Disable header sorting and items dragging

AddressListTreeview = component_getComponent(AddressList,0)

AddressListHeader = component_getComponent(AddressList,1)

setMethodProperty(AddressListHeader ,"OnSectionClick",nil)

setMethodProperty(AddressListTreeview,"OnDragOver" ,nil)

setMethodProperty(AddressListTreeview,"OnDragDrop" ,nil)

setMethodProperty(AddressListTreeview,"OnEndDrag" ,nil)

--end



--show main window

ShowMainWindowTimer = createTimer(nil,false)

timer_setInterval(ShowMainWindowTimer, 1)

timer_onTimer(ShowMainWindowTimer, function (sender)

object_destroy(sender)

control_setVisible(controlMainForm,true) -- set visible

form_setMenu(controlMainForm,nil) -- hide menu

end)

timer_setEnabled(ShowMainWindowTimer, true)

--end

--]]



if getCEVersion == nil or getCEVersion() < 6.3 then

messageDialog('It is recommended to use at least Cheat Engine 6.3! (Your Version: '..getCEVersion()..')', mtError, mbOK)

end



errorOnLookupFailure(false)

DefaultProccessName = "DARKSOULS.exe"

strings_add(getAutoAttachList(), DefaultProccessName)



-------------------------------------------------------------------------------



function unfreezeAllMemoryRecords()

local count = addresslist_getCount(AddressList)

for i=0,count-1 do

local record = addresslist_getMemoryRecord(AddressList, i)

memoryrecord_unfreeze(record)

end

end



function getProcessNameFromProcessID(iProcessID)

if iProcessID < 1 then return 0 end

local plist = createStringlist()

getProcesslist(plist)

for i=1, strings_getCount(plist)-1 do

local process = strings_getString(plist, i)

local offset = string.find(process,'-')

local pid = tonumber('0x'..string.sub(process,1,offset-1))

local pname = string.sub(process,offset+1)

if pid == iProcessID then return pname end

end

return 0

end



function getOpenedProcessName()

local process = getOpenedProcessID()

if process ~= 0 and getProcessIDFromProcessName(DefaultProccessName) == getOpenedProcessID() then

if checkOpenedProcess(DefaultProccessName) == true then return DefaultProccessName end

return 0

end

return getProcessNameFromProcessID(getOpenedProcessID())

end



function checkOpenedProcess(process)

if process == nil or process == 0 or process == false then

process = getOpenedProcessID()

if process ~= 0 and getProcessIDFromProcessName(DefaultProccessName) == process then

process = DefaultProccessName

end

end

if type(process) == "number" then process = getProcessNameFromProcessID(process) end

if process ~= nil and process ~= 0 then

if readInteger(process) then return true end

end

return false

end



function checkProccessAttached()

if DefaultProccessName == nil then return end

if checkOpenedProcess() == false then openProcess(DefaultProccessName) end

end



function CheckVariable(sVar)

if sVar == nil or sVar == false or sVar <= 0 then return false end

return true

end



function CheckEnabled(sVar)

if checkOpenedProcess() == false or CheckVariable(readInteger("pHero")) == false then return false end

if sVar ~= nil then

local bEnabled = readInteger(getAddress(sVar))

if bEnabled == nil or (bEnabled ~= 1 and bEnabled ~= true) then return false end

end

return true

end



function trim(s)

return s:find'^%s*$' and '' or s:match'^%s*(.*%S)'

end



if aHotKey ~= nil and #aHotKey ~= 0 then

for i=1,#aHotKey do object_destroy(aHotKey[i]) end

end

aHotKey = {}

function addHotKey(func, button)

table.insert(aHotKey, createHotkey(func, button))

end



-------------------------------------------------------------------------------



control_setCaption(controlMainForm,"Dark Souls Cheat Compilation by TechnoJacker - Cheat Engine " .. getCEVersion())



function onOpenProcess(processid)

unfreezeAllMemoryRecords()

beep()

end



--]]--



if AttachTimer ~= nil then

timer_setEnabled(AttachTimer, false); object_destroy(AttachTimer); AttachTimer = nil;

end

AttachTimer = createTimer(nil)

timer_onTimer(AttachTimer, checkProccessAttached)

timer_setInterval(AttachTimer,10000)

timer_setEnabled(AttachTimer, true)



-------------------------------------------------------------------------------



itemTypes = {'Melee','Range','Casting','Shield'}

eleTypes={'Magic','Fire','Lightning','Demon','Raw','Enchanted','Divine','Occult','Crystal','Chaos'}



function PopulateItemData(DataOnly, Refresh)

local tDesc = {'name', 'id', 'cat', 'sort', 'dura', 'ingame', 'multi', 'quant', 'type', 'element', 'level', 'max'}

local ItemBox = combobox_getItems(component_findComponentByName(ItemReplacer,"ItemBox"))

if not DataOnly then strings_clear(ItemBox) end

if ItemData == nil or #ItemData <= 0 or Refresh then

ItemData = {}

local ReplacerData = combobox_getItems(component_findComponentByName(ItemReplacer,"ItemData"))

local ItemCount = strings_getCount(ReplacerData)

for i=0,ItemCount-1 do

local line = trim(strings_getString(ReplacerData,i)); local x = 1; ItemData[i] = {};

for token in string.gmatch(line, "[^:]+") do

if x > 4 then token = tonumber(token) end

ItemData[i][tDesc[x]] = token

x = x + 1

end

if not DataOnly then strings_add(ItemBox,ItemData[i].name..(ItemData[i].ingame == '0' and '*' or '')) end

end

elseif not DataOnly then

for i=0,#ItemData do strings_add(ItemBox,ItemData[i].name..(ItemData[i].ingame == '0' and '*' or '')) end

end

end



function CheckReplacerData()

local ItemBox = combobox_getItems(component_findComponentByName(ItemReplacer,"ItemBox"))

local ItemCount = strings_getCount(ItemBox)-1

if ItemData == nil or #ItemData <= 0 or ItemCount <= 0 then PopulateItemData() end

end



function ReplaceItemClick(sender)

if CheckEnabled('bReplacerModLoaded') == false then return end



local aID = addresslist_getMemoryRecordByDescription(AddressList,"Category and ID")

local aSort = addresslist_getMemoryRecordByDescription(AddressList,"Index and Sort Value")

local aDura = addresslist_getMemoryRecordByDescription(AddressList,"Durability")

local index = combobox_getItemIndex(component_findComponentByName(ItemReplacer,"ItemBox"))

local SortValue = memoryrecord_getValue(aSort)

if SortValue == nil or SortValue == 'FFFFFFFF' or SortValue == '??' or ItemData == nil or #ItemData <= 0 or index < 0 then

return

end



local IndexValue = ItemData[index].id..ItemData[index].cat..'0000000'

local SortValue = ItemData[index].sort ..SortValue.sub(SortValue,7)

local DuraValue = ItemData[index].dura



memoryrecord_setValue(aID, IndexValue)

memoryrecord_setValue(aSort, SortValue)

memoryrecord_setValue(aDura, DuraValue)

beep()

end



function ReplacerUpdater()

if CheckEnabled('bReplacerModLoaded') == false then return end



local CurItemBox = component_findComponentByName(ItemReplacer,"CurrentItemBox")

local sID = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AddressList,"ID"))

local sCat = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AddressList,"Category"))

if sID == nil or sID == 'FFFFFFFF' or sID == '??' or ItemData == nil or #ItemData <= 0 then

control_setCaption(CurItemBox, 'None')

return

end



local sCat = string.sub(sCat, 1, 1)

local CurID = sID..'-'..sCat

if ItemCache == nil then ItemCache = {} end

if ItemCache[CurID] == nil then

for i=0,#ItemData do

local ItemID = ItemData[i].id..'-'..ItemData[i].cat

if ItemID == CurID then

ItemCache[CurID] = ItemData[i].name..(ItemData[i].ingame == '0' and '*' or '')

break

end

end

if ItemCache[CurID] == nil then ItemCache[CurID] = "Unknown" end

end

if ItemCache['last'] ~= CurID then

control_setCaption(CurItemBox, ItemCache[CurID])

ItemCache['last'] = CurID

end

end



function InitRepTimer(Disabled)

if Disabled then Disabled = false else Disabled = true end

if RepTimer ~= nil then

timer_setEnabled(RepTimer, false); object_destroy(RepTimer); RepTimer = nil;

end

RepTimer = createTimer(nil, Disabled)

timer_onTimer(RepTimer, ReplacerUpdater)

timer_setInterval(RepTimer,200)

end

InitRepTimer()



function ReplacerOpen()

InitRepTimer()

control_setCaption(component_findComponentByName(ItemReplacer,"CurrentItemBox"), 'None')

form_show(ItemReplacer)

end



function ReplacerClose()

InitRepTimer(true)

strings_clear(combobox_getItems(component_findComponentByName(ItemReplacer,"ItemBox")))

control_setCaption(component_findComponentByName(ItemReplacer,"CurrentItemBox"), 'None')

form_hide(ItemReplacer)

end



function EnableReplacer()

local ItemReplacerAddr = addresslist_getMemoryRecordByDescription(AddressList,'Item Replacer')

memoryrecord_freeze(ItemReplacerAddr)

end



function DisableReplacer()

local ItemReplacerAddr = addresslist_getMemoryRecordByDescription(AddressList,'Item Replacer')

memoryrecord_unfreeze(ItemReplacerAddr)

end



-------------------------------------------------------------------------------



function InitRandomTimer(Disabled)

if Disabled then Disabled = false else Disabled = true end

math.randomseed(os.time())

LastRandInterval = nil

if RandomTimer ~= nil then

timer_setEnabled(RandomTimer, false); object_destroy(RandomTimer); RandomTimer = nil;

end

RandomTimer = createTimer(nil, Disabled)

timer_onTimer(RandomTimer, RandomModUpdater)

timer_setInterval(RandomTimer, 500)

end

InitRandomTimer()



function GetRandomWeapon()

if ItemData == nil or #ItemData <= 0 then PopulateItemData(true) end

if not MeleeData then

MeleeData = {}

for i=0,#ItemData do

if ItemData[i].type == 1 then table.insert(MeleeData, i) end

end

return

end

return tonumber(ItemData[MeleeData[math.random(1,#MeleeData)]].id, 16)

end



function RandomModUpdater()

if CheckEnabled('bRandomModLoaded') == false then return DisableRandomMod() end



local RandomInterval = readInteger(getAddress('iRandomModInterval'))

if not RandomInterval or RandomInterval < 1 then RandomInterval = 7 end

RandomInterval = RandomInterval * 1000

if RandomInterval ~= LastRandInterval then

LastRandInterval = RandomInterval

timer_setInterval(RandomTimer, RandomInterval)

end



local RWeapon1ID = addresslist_getMemoryRecordByDescription(AddressList,"R Weapon 1 ID")

local RWeapon2ID = addresslist_getMemoryRecordByDescription(AddressList,"R Weapon 2 ID")

local RWeapon1IDValue = memoryrecord_getValue(RWeapon1ID)

if RWeapon1IDValue == nil or RWeapon1IDValue == 'FFFFFFFF' or RWeapon1IDValue == '??' then return end



if not RandOrigWeapon1 then RandOrigWeapon1 = memoryrecord_getValue(RWeapon1ID) end

if not RandOrigWeapon2 then RandOrigWeapon2 = memoryrecord_getValue(RWeapon2ID) end

memoryrecord_setValue(RWeapon1ID, GetRandomWeapon())

memoryrecord_setValue(RWeapon2ID, GetRandomWeapon())

end



function EnableRandomMod()

InitRandomTimer()

beep()

end



function DisableRandomMod()

if RandOrigWeapon1 then

local RWeapon1ID = addresslist_getMemoryRecordByDescription(AddressList,"R Weapon 1 ID")

memoryrecord_setValue(RWeapon1ID, RandOrigWeapon1)

RandOrigWeapon1 = nil

end

if RandOrigWeapon2 then

local RWeapon2ID = addresslist_getMemoryRecordByDescription(AddressList,"R Weapon 2 ID")

memoryrecord_setValue(RWeapon2ID, RandOrigWeapon2)

RandOrigWeapon2 = nil

end

InitRandomTimer(true)

end



function FreezeRandomMod()

local RandomModAddr = addresslist_getMemoryRecordByDescription(AddressList,'Random Weapon Mod')

memoryrecord_freeze(RandomModAddr)

end



function UnfreezeRandomMod()

local RandomModAddr = addresslist_getMemoryRecordByDescription(AddressList,'Random Weapon Mod')

memoryrecord_unfreeze(RandomModAddr)

end



-------------------------------------------------------------------------------



SaveLoc = {}; SavePos = 0

CordAddressData = {

['x'] = '[["DARKSOULS.exe"+00EDF9E8]+18]+10',

['y'] = '[["DARKSOULS.exe"+00EDF9E8]+18]+18',

['z'] = '[["DARKSOULS.exe"+00EDF9E8]+18]+14'

}



function TeleportSave()

if CheckEnabled('bTeleModLoaded') == false then return end



SavePos = readInteger("iTeleModSavePos")

SaveLoc[SavePos] = { x = readFloat(getAddress(CordAddressData['x'])),

y = readFloat(getAddress(CordAddressData['y'])),

z = readFloat(getAddress(CordAddressData['z'])) }

beep()

end



function TeleportLoad()

if CheckEnabled('bTeleModLoaded') == false then return end



SavePos = readInteger("iTeleModSavePos")

if SaveLoc[SavePos] == nil then return end



writeFloat(getAddress(CordAddressData['x']), SaveLoc[SavePos]['x'])

writeFloat(getAddress(CordAddressData['y']), SaveLoc[SavePos]['y'])

writeFloat(getAddress(CordAddressData['z']), SaveLoc[SavePos]['z'])



beep()

end



addHotKey("TeleportSave", VK_NUMPAD0)

addHotKey("TeleportLoad", VK_DECIMAL)[/ICODE]

[/SPOILER]
Last edited by krul on Thu Jan 01, 1970 12:00 am, edited 1 time in total.

User avatar
FreeER
Expert Cheater
Expert Cheater
Posts: 116
Joined: Fri Mar 10, 2017 7:11 pm
Reputation: 28

Auto-attach list in CE

Post by FreeER »

The vast majority of that code is entirely unrelated to the specific topic....

[CODE=lua]DefaultProccessName = "DARKSOULS.exe"

strings_add(getAutoAttachList(), DefaultProccessName)



function unfreezeAllMemoryRecords()

local AddressList = getAddressList()

local count = addresslist_getCount(AddressList)

for i=0,count-1 do

local record = addresslist_getMemoryRecord(AddressList, i)

memoryrecord_unfreeze(record)

end

end



function getProcessNameFromProcessID(iProcessID)

if iProcessID < 1 then return 0 end

local plist = createStringlist()

getProcesslist(plist)

for i=1, strings_getCount(plist)-1 do

local process = strings_getString(plist, i)

local offset = string.find(process,'-')

local pid = tonumber('0x'..string.sub(process,1,offset-1))

local pname = string.sub(process,offset+1)

if pid == iProcessID then return pname end

end

return 0

end



function checkOpenedProcess(process)

if process == nil or process == 0 or process == false then

process = getOpenedProcessID()

if process ~= 0 and getProcessIDFromProcessName(DefaultProccessName) == process then

process = DefaultProccessName

end

end

if type(process) == "number" then process = getProcessNameFromProcessID(process) end

if process ~= nil and process ~= 0 then

if readInteger(process) then return true end

end

return false

end



function checkProccessAttached()

if DefaultProccessName == nil then return end

if checkOpenedProcess() == false then openProcess(DefaultProccessName) end

end



function onOpenProcess(processid)

unfreezeAllMemoryRecords()

beep()

end



if AttachTimer ~= nil then

timer_setEnabled(AttachTimer, false); object_destroy(AttachTimer); AttachTimer = nil;

end

AttachTimer = createTimer(nil)

timer_onTimer(AttachTimer, checkProccessAttached)

timer_setInterval(AttachTimer,10000)

timer_setEnabled(AttachTimer, true)

[/CODE]



That's using a (much) older syntax (obviously still works but) and has extra code to support things that aren't used, in CE 6.7 it can be simplified to just

[CODE=lua]

DefaultProccessName = "DARKSOULS.exe"

getAutoAttachList().add(DefaultProccessName)



function unfreezeAllMemoryRecords()

for i=0, AddressList.Count-1 do

AddressList[i].Active=false

-- ^ unfreeze values, run disable code for scripts (disableWithoutExecute wouldn't have existed in the older syntax)

end

end



function checkOpenedProcess(process) return readInteger(DefaultProccessName) end



function checkProccessAttached()

if not checkOpenedProcess() then openProcess(DefaultProccessName) end

end



function onOpenProcess(processid)

unfreezeAllMemoryRecords()

--beep() -- why? :)

end



if AttachTimer ~= nil then -- incase we reran this code multiple times (eg when writing it)

AttachTimer.Enabled=false; AttachTimer.destroy(); AttachTimer = nil;

end

AttachTimer = createTimer(nil)

AttachTimer.OnTimer=checkProccessAttached

AttachTimer.Interval=10000 [/code]
Last edited by FreeER on Mon Jun 04, 2018 8:27 pm, edited 5 times in total.

krul
Expert Cheater
Expert Cheater
Posts: 101
Joined: Tue Jan 30, 2018 7:11 pm
Reputation: 7

Auto-attach list in CE

Post by krul »

Thank you.



How to activate a specific script in CE table with lua file ?



Script in CE table has some name desciption.

User avatar
FreeER
Expert Cheater
Expert Cheater
Posts: 116
Joined: Fri Mar 10, 2017 7:11 pm
Reputation: 28

Auto-attach list in CE

Post by FreeER »

to activate a script with lua code in 6.7 you can use [ICODE]AddressList.getMemoryRecordByDescription("Desc/Name of MR").Active = true[/ICODE] (or ByID or just [ICODE]AddressList[i][/ICODE] for by index/position, 0-based). Pre 6.7, if you want to support that, [ICODE]AddressList[/ICODE] wasn't defined so you have to use [ICODE]getAddressList()[/ICODE]
Last edited by FreeER on Thu Jan 01, 1970 12:00 am, edited 2 times in total.

User avatar
SunBeam
Administration
Administration
Posts: 4763
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4402

Auto-attach list in CE

Post by SunBeam »

Just let him read on his own. There's a big fucking TXT file in CE's folder called [SIZE=7]CELUA.TXT[/SIZE]. Use it! That + google, like the rest of us.
Last edited by SunBeam on Tue Jun 05, 2018 1:22 am, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: No registered users