|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sun Jun 10, 2012 9:41 am Post subject: ingame(d3d) trainer example (homm6) |
|
|
Here is a trainer example for heroes of might and magic 6 (or better said, might and magic heroes 6, can't really compare that series with this one...)
Credit goes to recifense for his table which I used ( http://forum.cheatengine.org/viewtopic.php?t=543621 )
anyhow, here is the script
Code: |
hiddenbyuser=false --variable set by pressing ~
oldvisiblestate=true --to save on hiding/showing
function keypress(vkey, char)
if vkey==VK_F1 then
if isKeyPressed(VK_CONTROL) then
writeInteger("[[pHero]+120]+18", readInteger("[[pHero]+120]+18")+100)
writeFloat("[pHero]+140", readFloat("[pHero]+140")+1000)
writeFloat("[pHero]+154", readFloat("[pHero]+154")+1000)
writeFloat("[pHero]+168", readFloat("[pHero]+168")+1000)
writeFloat("[pHero]+17c", readFloat("[pHero]+17c")+1000)
writeFloat("[pHero]+190", readFloat("[pHero]+190")+1000)
writeFloat("[pHero]+1a4", readFloat("[pHero]+1a4")+1000)
beep()
else
writeInteger("iEnableMR", (readInteger("iEnableMR")+1) % 2)
end
UpdateStatus()
return false
end
if vkey==VK_F2 then
writeInteger("iEnableMM", (readInteger("iEnableMM")+1) % 2)
UpdateStatus()
return false
end
if vkey==VK_F3 then
writeInteger("iEnableMMa", (readInteger("iEnableMMa")+1) % 2)
UpdateStatus()
return false
end
if vkey==VK_F4 then
writeInteger("iEnableMS", (readInteger("iEnableMS")+1) % 2)
UpdateStatus()
return false
end
if vkey==192 then
hiddenbyuser=not hiddenbyuser
UpdateStatus()
return true
end
end
function UpdateStatus(sender)
--check if a hero is selected. If not, hide
--also responsible for reading the cheat stats
local newvisiblestate=false
if hiddenbyuser or (readInteger('[[pHero]+120]+18')==nil) then
--hide
newvisiblestate=false
else
--show
if readInteger("iEnableMR")==1 then
s1='Disable'
else
s1='Enable'
end
if readInteger("iEnableMM")==1 then
s2='Disable'
else
s2='Enable'
end
if readInteger("iEnableMMa")==1 then
s3='Disable'
else
s3='Enable'
end
if readInteger("iEnableMS")==1 then
s4='Disable'
else
s4='Enable'
end
status=string.format([[F1 : %s Minimum Resources
F2 : %s Unlimited Movement
F3 : %s Fast Recover Mana
F4 : %s Troop Minimum Sizes
Ctrl+F1 : Super Hero
]], s1,s2,s3,s4)
d3dhook_textcontainer_setText(tc, status)
newvisiblestate=true
end
if oldvisiblestate~=newvisiblestate then
d3dhook_renderobject_setVisible(tc, newvisiblestate)
d3dhook_renderobject_setVisible(tc2, newvisiblestate)
d3dhook_renderobject_setVisible(statusbarsprite, newvisiblestate)
d3dhook_renderobject_setVisible(bgsprite, newvisiblestate)
oldvisiblestate=newvisiblestate
end
end
function InjectMenu()
-- control_setCaption(UDF1_CELabel1,"Inside InjectMenu")
--pause() --decrease chance of crashes (won't work in protected trainers...)
-- control_setCaption(UDF1_CELabel1,"After pause")
--create a black transparent background for the hero status
statusbackground=createPicture()
bmp=picture_getBitmap(statusbackground);
graphic_setHeight(bmp,1)
graphic_setWidth(bmp,1)
c=rasterimage_getCanvas(bmp)
canvas_setPixel(c,0,0,0x000000) --black
-- control_setCaption(UDF1_CELabel1,"Going to init")
d3dhook_initializeHook()
-- control_setCaption(UDF1_CELabel1,"After Init")
bgtexture=d3dhook_createTexture(statusbackground)
bgsprite=d3dhook_createSprite(bgtexture);
--load the statusbar
statusbartexture=d3dhook_createTexture(getCheatEngineDir().."trainerwindow.png")
d3dhook_renderobject_setX(bgsprite, -1) --center it horizontally
d3dhook_sprite_setWidth(bgsprite, d3dhook_texture_getWidth(statusbartexture))
d3dhook_sprite_setHeight(bgsprite, d3dhook_texture_getHeight(statusbartexture))
d3dhook_renderobject_setY(bgsprite, 48)
d3dhook_renderobject_setAlphablend(bgsprite, 0.7)
statusbarsprite=d3dhook_createSprite(statusbartexture)
d3dhook_renderobject_setX(statusbarsprite, -1) --center it horizontally
d3dhook_renderobject_setY(statusbarsprite, d3dhook_renderobject_getY(bgsprite))
f=integerToUserData(getProperty(UDF1_Font, "Font"))
fm=d3dhook_createFontmap(f)
tc=d3dhook_createTextContainer(fm, -1, d3dhook_renderobject_getY(bgsprite)+2, 'Initializing...')
f2=integerToUserData(getProperty(UDF1_Font2, "Font"))
fm2=d3dhook_createFontmap(f2)
tc2=d3dhook_createTextContainer(fm2, -1, d3dhook_renderobject_getY(bgsprite)+d3dhook_texture_getHeight(statusbartexture)-d3dhook_texture_getHeight(fm2)-2, 'Press ` to Hide/Show')
--f3=integerToUserData(getProperty(UDF1_Font3, "Font"))
--fm3=d3dhook_createFontmap(f3)
--tc3=d3dhook_createTextContainer(fm3, -1, d3dhook_renderobject_getY(bgsprite)+2+5*d3dhook_texture_getHeight(fm), [[Hero stats
--Ctrl+F1 : Super Hero
--]])
--start a timer that updates the textcontainer (alternatively, I could use a mouseclick event)
d3dhook_onKey(keypress)
t=createTimer(nil)
timer_onInterval(t, UpdateStatus)
timer_setInterval(t, 250)
timer_setEnabled(t, true)
--unpause()
end
strings_add(getAutoAttachList(), "Might & Magic Heroes VI.exe");
scriptentry=addresslist_getMemoryRecordByID(getAddressList(), 69)
function ActivateCheck(sender)
--try to activate the script entry
memoryrecord_freeze(scriptentry)
if memoryrecord_isActive(scriptentry) then
control_setCaption(UDF1_CELabel1,"Script activated. Killing timer")
object_destroy(sender)
control_setCaption(UDF1_CELabel1,"Script activated. Injecting script")
InjectMenu()
--still here so no crash/whatever
control_setCaption(UDF1_CELabel1,"Menu injected. Go into the game and move your hero once")
end
end
function onOpenProcess(pid)
control_setCaption(UDF1_CELabel1,"Process found. Activing script")
t=createTimer(nil)
timer_setInterval(t, 1000)
timer_onTimer(t,ActivateCheck)
timer_setEnabled(t,true)
end
form_show(UDF1)
function FormClose(sender)
closeCE()
return caHide --Possible options: caHide, caFree, caMinimize, caNone
end
|
This script makes use of the trainerwindow.png file:
it should be inside your cheat engine folder if you embed it in the trainer, or make use of TrainerOrigin if you put it next to your trainer. (in my example I embedded it)
http://cheatengine.org/temp/homm6.zip for the final result in exe form (sadly enough I couldn't make it a tiny trainer)
Also, there is a bug with the 6.2 release that doesn't deal with homm6's special setup and needed a fix. Also noticed an alignment issue with the d3dhook_textcontainer object. Replace the dll's in your ce install with these: http://cheatengine.org/temp/d3dhookfix.zip
(the reason I couldn't make a tiny version)
And don't forget. When making a trainer, you must add the used .dll's manually using "add file(s)"
Description: |
|
Download |
Filename: |
homm6.CT |
Filesize: |
22.8 KB |
Downloaded: |
2623 Time(s) |
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping
Last edited by Dark Byte on Tue Apr 16, 2013 8:51 am; edited 1 time in total |
|
Back to top |
|
|
Dave_Scream Cheater Reputation: 0
Joined: 06 Dec 2009 Posts: 26
|
Posted: Sun Jun 10, 2012 10:46 am Post subject: |
|
|
d3dhookfix - maybe because of it crosshair tool not worked for me
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sun Jun 10, 2012 10:56 am Post subject: |
|
|
try it. It fixes the loading of textures in d3d9Ex , and the crosshair is a texture
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Wed Jun 13, 2012 4:37 pm Post subject: |
|
|
Also, this is one of the games that become a lot more playable when you make use of the mouse locking feature. That way your mouse won't get out of the screen while scrolling, causing the game to minimize when you click on something
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Wed Jun 13, 2012 5:45 pm Post subject: |
|
|
Actually, with a small modification to the script I can make this into a tiny trainer, with added benefit that it fixes a bug in ce at the same time for those that run it
just add this to the very end: (and replace getCheatEngineDir()..'trainerwindow.png' with TrainerOrigin..'trainerwindow.png')
Code: |
if (TrainerOrigin~=nil) and (getCEVersion()<=6.2) then
control_setCaption(UDF1_CELabel1,"Updating Cheat Engine")
dxhook = io.open(TrainerOrigin..'d3dhook.dll', "rb")
cedxhook = io.open(getCheatEngineDir()..'d3dhook.dll',"wb")
bytes = dxhook:read(100000)
if not bytes then print("FUUUU") end
cedxhook:write(bytes)
dxhook:close()
cedxhook:close()
dx9hook = io.open(TrainerOrigin..'ced3d9hook.dll', "rb")
cedx9hook = io.open(getCheatEngineDir()..'ced3d9hook.dll',"wb")
bytes = dx9hook:read(100000)
if not bytes then print("FUUUU") end
cedx9hook:write(bytes)
dx9hook:close()
cedx9hook:close()
control_setCaption(UDF1_CELabel1,"Launch the game if it hasn't already")
end
|
http://cheatengine.org/download/homm6tiny.zip
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
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
|
|