The trainer uses the cheats as buttons - when clicked it will change the item value to 99 and freeze the value, if clicked again it will unfreeze the value.
The finished trainer is a whopping 3163 KB (3.08 MB) in size. VirusScan.Jotti.org reports 0 false-positives for a virus (from 20 virus scanners). So no problems with users getting a false-positive virus warning.
Interesting enough Cheat Engine showed a Easter egg for New Year's, which keeps showing up whenever I start CE. Here is the message, "And what are your good intentions for this year? ;-)".
Spelunky Tutorial - Part 3 of 5
- Game Cheating Tutorial
- GTS Trainer Tutorial
- Cheat Engine Trainer Tutorial
- AutoIt Trainer Tutorial
- FreeBASIC Trainer Tutorial
Programs Needed
To do this tutorial you will need --
- Cheat Engine version 6.1
- My CE table created for Spelunky (as created in the Game Cheating Tutorial)
- PC game Spelunky version 1.1 by Derek Yu. Also available at FilePlanet.com and Games.On.Net
Getting Started
** For anyone that gets stuck in this tutorial I have put the CE table, with the trainer online. Simply download the CE table with trainer, and load it in Cheat Engine. View the trainer with the menu Table and the item Show Cheat Table Lua Script. First load the Spelunky game, CE needs the game loaded to set the trainer process. Start CE (Cheat Engine) and select the process of the game, Spelunky.exe, using the computer and magnifying glass icon - click open.
Next load the Spelunky cheat table, use the folder icon or the menu File and Load. Next select the menu File, and choose Generate trainer from table.
The generated trainer is used to create the default trainer Lua script, and set the basic trainer settings. This is required before we can customize the trainer.
Two new windows will open to allow you to set the trainer settings, and show the generated trainer. Don't worry about how the generated trainer looks, as it will be changed shorty.
As for the settings, the first one to change is to set the checkbox on top to read Don't support Cheat Engine (or yourself). If you leave the option to support Cheat Engine it will turn your trainer into a Adware package.
Trainers are viewed by many as possible viruses anyway, there is no need to add advertisements and such as well into your trainer. This will only serve to ban your trainer(s) from many places online.
Even if it is set to support Cheat Engine, the advertisement window only shows a error for me (a real error, not a fake advert). I would suggest if you truly want to support Cheat Engine visit the site and contact Dark Byte, the program author, about making a donation or helping out by some other means. His contact information is available on the About CE page.
Anyway back to the trainer settings. If you loaded the game and set the process in CE before creating the trainer, the process will already be selected. Just be sure that the Processname is set to Spelunky.exe; otherwise, your trainer will not work no matter what you do.
Title is the trainer window text, I use Spelunky +3 Trainer. I leave the rest of the settings as they are; however, you can change the trainer icon image or the freeze interval (timer). The About text will not be used, so no need to change it.
When you have the settings updated, click the Generate Trainer button. Select the name of the trainer and where to save it. Clicking the Save button will bring up another window to modify the trainer EXE.
The only option to set is the Compression level to Max. Ensure that the Target process is 32-bit is selected. The other options need to be left alone, unchecked. If you want a custom icon for the trainer you can select that here as well (Change EXE Icon).
Click the Generate button, and wait while it is saved, and click the Ok button once it is finished. Now close the extra CE windows, leaving only the main CE window (Close Exe Trainer Generator and Trainer Generator).
CE is done with the Spelunky game, so you can close Spelunky now too.
Trainer GUI - Blank Slate
Now that CE created the basic required Lua script and internal trainer settings we are ready to customize the trainer. Click the menu item Table, and scroll down to CETrainer and click Edit.
CE will open several windows to edit the trainer window. The first step is to select the TCESplitter by clicking it in the trainer window. View the image to the left, as it is selected.
Once you have it selected press your DEL key. Everything in the trainer window has to be deleted, and if the TCESplitter is not removed first it is near impossible to get rid of it.
Continue selecting other items from the trainer window, text and buttons first and deleting them too. Finally delete the panels. You should have a empty trainer window - verify this by looking at the Object Inspector (Top left item) the only thing in the list should be CETrainer: TTrainerForm.
Trainer GUI - Create
With a a now empty trainer window we can start creating the actual trainer GUI (graphical user interface).
Just a note about CE - I have found no other way to make a blank trainer with the required default trainer Lua script created and internal trainer settings. Even creating the Lua script manually, or using the button Design userinterface manually, does not work.
Anyway, with the blank trainer window the first step is to change the window size.
Set trainer window Properties Height to 170 and Width to 116. The other settings are fine, and we are ready to add the cheat buttons.
Using the FormDesigner click the Button Icon (image is a Ok button), and then click in the trainer window. A button will be created, which we need to edit.
Change the button Properties as follows - Caption to Bomb Max (Off), Height to 44, Left to 11, Top to 13, and Width to 92. Leave the button Name alone, as CEButton1.
The last thing to change on the button is what to do when the button is clicked. Click the Events tab, beside the Properties tab. For the OnClick event enter the text CEButton1Click and leave the other settings as they are.
The OnClick event will call the function CEButton1Click in the Lua script we will program shorty. The other two buttons are setup the same way, and I will give you the data you need to enter/change for each.
Create another button with the FormDesigner button Icon. Change the button Properties as follows - Caption to Health Max (Off), Height to 44, Left to 11, Top to 61, and Width to 92. Leave the button Name alone, as CEButton2. Change the OnClick Event to CEButton2Click
One more button to create with the FormDesigner button Icon. Change the button Properties as follows - Caption to Rope Max (Off), Height to 44, Left to 11, Top to 111, and Width to 92. Leave the button Name alone, as CEButton2. Change the OnClick Event to CEButton3Click
We are done creating the trainer GUI so close the FormDesigner window and close the trainer window. You should only have the main CE window left open.
Lua Trainer Script
Now in CE click the Table menu, and click Show Cheat Table Lua Script. This is the actual programming code that is used in the trainer.
As we had CE generate and save the default trainer earlier, we now have the basic trainer script. For more help/information about CE Lua functions you can load the file main.lua from the main Cheat Engine folder. It lists the available functions, how to call them, and what they do.
Your Lua script window should have this default script -
--TRAINERGENERATORSTART-- --This is autogenerated code. Changing code in this block will --get erased and rewritten if you regenerate the trainer code --Uncomment the following line if this is a Cheat Table format trainer and you don't want CE to show (Tip, save as .CETRAINER alternatively) --hideAllCEWindows() addresslist=getAddressList() control_setVisible(CETrainer_SEPERATOR, false) strings_add(getAutoAttachList(), "Spelunky.exe") gBeepOnAction=false form_show(CETrainer) function AboutClick() showMessage(gAboutText) end gAboutText=[[This trainer was made by Cheat Engine www.cheatengine.org]] function CloseClick() closeCE() return caFree --onClick doesn't care, but onClose would like a result end --TRAINERGENERATORSTOP--
I recommend you do not change any of the default script - any changes will likely make your trainer not work. In most cases it will create the EXE and clicking the EXE will act like it is loading; however, the trainer will will not show-up and be stuck in memory.
For example the gAboutText and the function AboutClick() can not be altered/removed without crashing any trainer created with the code. Even though they are not used by the trainer they are required by CE.
Programming the Lua Trainer
In the trainer GUI we edited the three buttons to use functions, and now we need to add those functions.
The first thing to add are some variables for the buttons. They will tell the trainer if the buttons are On or Off. Find the line gBeepOnAction=false
Copy and Paste these three new lines under the gBeepOnAction line -
gButtonOnBomb=false gButtonOnHealth=false gButtonOnRope=false
Next find the line --TRAINERGENERATORSTOP-- at the bottom and add a few blank lines below it. We are ready to add the button code to switch the buttons On/Off and apply the cheats.
All three buttons use nearly the same code, with differences only of which cheat to use and variable names. I will walk you through the first cheat.
This is the code for all the buttons, Copy and Paste the code below the --TRAINERGENERATORSTOP-- line -
function CEButton1Click(sender) if (gButtonOnBomb) then control_setCaption(CETrainer_CEButton1, "Bomb Max (Off)") gButtonOnBomb=false local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Bombs (99)") memoryrecord_unfreeze(memrec) else control_setCaption(CETrainer_CEButton1, "Bomb Max (On)") gButtonOnBomb=true local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Bombs (99)") memoryrecord_setValue(memrec, 99) memoryrecord_freeze(memrec) end end function CEButton2Click(sender) if (gButtonOnHealth) then control_setCaption(CETrainer_CEButton2, "Health Max (Off)") gButtonOnHealth=false local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Health (99)") memoryrecord_unfreeze(memrec) else control_setCaption(CETrainer_CEButton2, "Health Max (On)") gButtonOnHealth=true local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Health (99)") memoryrecord_setValue(memrec, 99) memoryrecord_freeze(memrec) end end function CEButton3Click(sender) if (gButtonOnRope) then control_setCaption(CETrainer_CEButton3, "Rope Max (Off)") gButtonOnRope=false local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Rope (99)") memoryrecord_unfreeze(memrec) else control_setCaption(CETrainer_CEButton3, "Rope Max (On)") gButtonOnRope=true local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Rope (99)") memoryrecord_setValue(memrec, 99) memoryrecord_freeze(memrec) end end
First some notes about using CE for creating trainers. CE Trainers actually include your cheat table and the entire main CE program inside them. This saves you some time programming your trainers, but at the cost of the trainer file size.
With the cheat button code - each button has two main pieces of code, switch the button On and switch the button Off. Both pieces have equal codes that does the reverse of the other.
function CEButton1Click(sender) is the OnEvent function that is called when the user clicks the first cheat button. We set this up in the Events tab in the FormDesigner, using the OnClick event. The button functions are only called when the cheat buttons are actually clicked.
if (gButtonOnBomb) then check if the button is On, by using the variable gButtonOnBomb that we use as a status for it. If it is On then the following code is executed until the else code.
control_setCaption(CETrainer_CEButton1, "Bomb Max (Off)") changes the cheat button text caption to the cheat name and Off.
gButtonOnBomb=false updates the button status variable to Off which is false.
local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Bombs (99)") finds the cheat in our CE table with the description Bombs (99) and saves the cheat record to the variable memrec so it can be accessed.
memoryrecord_unfreeze(memrec) un-checks the freeze option (unfreezes it, and returning it to normal) for the cheat in the variable memrec, which we set in the previous code to the Bomb cheat.
else if the button cheat is Off it will do the next codes and turn the button On.
control_setCaption(CETrainer_CEButton1, "Bomb Max (On)") changes the cheat button text caption to the cheat name and On.
gButtonOnBomb=true updates the button status variable to On which is true.
local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Bombs (99)") finds the cheat in our CE table with the description Bombs (99) and saves the cheat record to the variable memrec so it can be accessed.
memoryrecord_setValue(memrec, 99) change the value of the cheat to the decimal number 99. CE handles putting the value into the correct format which is double for this cheat.
memoryrecord_freeze(memrec) checks the freeze option (freezing it, which updates the value every 250 milliseconds (or whatever you changed it to in the Trainer GUI - Create section)) for the cheat in the variable memrec, which we set in the previous code to the Bomb cheat.
end marks the end of the if .. else .. block of code. end is the end of the button1 function.
That is all the coding for the first cheat button for Bombs. The two remaining functions use the same codes, with small changes that apply to them. If you have any questions about the last function codes look at the explanations I just gave for help.
When you are finished save your trainer using the menu File and Save. You can use either window to save it as it is all the same. Leave the Save As Type set to Cheat Engine Tables (*.CT) for now.
Close the Lua script: Cheat Table window, as the trainer is finished. If needed you can always re-open it from the menu Table and the item Show Cheat Table Lua Script.
Saving the Trainer
Now with the trainer finished you have a couple of options to distribute your CE trainer. Click the menu File and Save, or the save icon - it will bring up the save window.
As you can see in the image on the left if you click the Save as type you will have three save option formats.
The first Cheat Engine Tables (*.CE) will save the trainer into the cheat table, but is not recommended. The trainer does not automatically load, and they can freely edit the trainer. This save type is useful though as a back-up for you, and is how I distributed my trainer for this tutorial.
The second Cheat Engine Table (*.CETRAINER) saves the trainer into it's own file; however, requires anyone who uses it to have CE installed. If you choose this option CE will give you the option of protecting the trainer from editing and most prying eyes.
The CETRAINER created for me, of the Spelunky trainer was only 3.79 KB in size; however, it is not a EXE file and requires CE to be installed as mentioned. As such this method can be a great download option for other CE users, but definitely not for mass distribution - for that you will need the last save option.
Some notes about the CETRAINER though. If you load the file into CE, the main CE window will disappear, leaving only the trainer window. Double-clicking the CETRAINER file will load only the trainer window. With either, the trainer will function normally, and once the user closes it CE closes as well.
The remaining save option is Cheat Engine Trainer Standalone (*.EXE). It is by far the most used save type, unless of course you plan to only distribute your trainers to other CE users.
So change the file name or directory if needed, select the Save as type to Cheat Engine Trainer Standalone (*.EXE), and click the Save button.
You will see the familiar trainer generator window. Just check that it is set to Target process is 32-bit and Compression is set to Max. Click the Generate button.
Once it is done, your finished trainer is complete. Try it out by loading the Spelunky game and your trainer EXE.
You can also test the trainer in the Lua script: Cheat Table window (menu item Table and the item Show Cheat Table Lua Script). Load the game and simply click the button Execute Script in the script window - this will however exit CE when you close the trainer.
Finished Trainer
The completed trainer is saved in the folder you selected inside CE. You may notice the huge file size for a trainer, which is 3163 KB (3.08 MB). The size is due to the CE cheat table, and the main CE program is inside the trainer.
If you have a small amount of limited file space like me, or pay for file hosting or your website bandwidth the file size can be a problem - even costing you money.
You can host your trainers on free file servers to avoid the issues; however, most will delete your files for various reasons - and is not much of a option.
The only thing you can do to reduce the file size is to pack your trainer with a EXE packer. I recommend the freeware/open source packer UPX. Besides a EXE packer the only alternative is to use another program to create your trainers.
In order to use a EXE packer you must save the trainer with the Compression set to None. As CE uses something, and is identified as BINARYRES.
So save your trainer as Cheat Engine Trainer Standalone (*.EXE) and set the Compression to None - see the image to the left.
Even with UPX set at maximum compression, the CE trainer is 2594 KB (2.53 MB) in file size. UPX though did manage to take off an additional 569 KB - which sadly is the typical size of an entire trainer.
If you want to know how to create this trainer using other programs, view the links in the Spelunky Tutorial section near the beginning of this page.
0 comments:
Post a Comment