Modding Resources: Installing Mods | Creating Mods | Basic Code Examples | Creating a Character | Audio and Visual Effects | The Automator | User Interface | Graph Editor

Creating Mods


Clicker Heroes 2 mods are made using ActionScript 3 and this guide will walk you through setting up and using the free program FlashDevelop for creating CH2 mods on Windows. At the moment this guide is only for making code mods, and not for editing or adding new art assets. If you already have some idea of what you're doing, there's a summary at the end that states everything concisely.

WARNING: Before you mod your game you should always backup your saves! Otherwise you will not be able to get your save back if something gets broken or you want to revert certain changes.

On Windows your save files can be found here:

    C:\Users\*Your User Name*\AppData\Roaming\ClickerHeroes2\Local Store\saves

You can also type %appdata% into the Windows Explorer address bar to get directly to the AppData/Roaming folding if you're having trouble locating it.

Part I: Program Set-Up

To get ready to start making mods, first download and install FlashDevelop from http://www.flashdevelop.org/. FlashDevelop requires Java and .NET to run, so you will need to download and install these free resources as well, if you don't already have them.

Once FlashDevelop is installed you will need to install compilers, which can be done from within FlashDevelop. From the top menu bar in FlashDevelop go to Tools > Install Software... This will bring up a window where you will want to select the checkbox for "Flex SDK + AIR SDK" from the Compilers section, and then click the button that should now say "Install 1 items" in the lower right of the window.

Once that's done you're all set up and ready to create mods!

Part II: Creating a Project

To start making a new mod, you will need to create a new project in FlashDevelop. From the top menu bar go to Project > New Project… then select "AS3 Project" from the top area of the window that pops up, and fill out the Name and Location fields below. The Name will be the name of your mod file, and the Location is where the files you are creating will be stored while you are working on them and where you will find your mod file when you are done. After you've named your project and picked a location, click OK.

In order to associate your new project with Clicker Heroes 2 you will need to tell it where to find the code it needs to reference. From the top menu bar go to Project > Properties... and at the top of the window that pops up, select the Compiler Options tab. Scroll down the list shown until you see "SWC Libraries". To the right of this label should be a field with the text "String[] Array". If you click where it says "String[] Array" to the right of "SWC Libraries" a small button with three dots (...) will come up on the right side of the field. Click on this button and in the window that pops up you will need to enter the file location of CH2Library.swc. This will be in the folder where your Clicker Heroes 2 game is installed, which by default should look something like this, if you are using Steam:

    C:\Program Files (x86)\Steam\steamapps\common\Clicker Heroes 2\CH2Library.swc

Make sure you put the full file path like shown above, and then click OK, then OK again to close the Properties window. You are now ready to make your mod!

Part III: Basic Code Set-Up

After you create a new project in FlashDevelop, to the right side of the screen you will see a list of the folders and files that have been created for your project, with the project name you chose at the top. Below there should be a folder called “src” that you can expand by clicking on the little plus sign (+) to the left of the folder name.

Inside that folder should be a file Main.as that you can rename to something more specific. Right click and choose Rename, enter the new name (make sure it still ends with .as), and when a popup appears asking if you want to “update the references” choose Yes.

You can open this Main.as file by double clicking on it - this is the file you will edit to create your mod. To start out with, FlashDevelop will have provided you with some code that looks something like this:

	
	package
	{
	    import flash.display.Sprite;
	    import flash.events.Event;
	    
	    /**
	     * ...
	     * @author Your Name
	     */
	    public class YourMain extends Sprite 
	    {
	    
	        public function YourMain() 
	        {
	            if (stage) init();
	            else addEventListener(Event.ADDED_TO_STAGE, init);
	        }
	        
	        private function init(e:Event = null):void 
	        {
	            removeEventListener(Event.ADDED_TO_STAGE, init);
	            // entry point
	        }
	        
	    }
	    
	}
	

But the only important parts needed for a CH2 mod are these:

    
	package
	{
	    import flash.display.Sprite;

	    public class YourMain extends Sprite 
	    {        
	    
	    }
	    
	}
	

There are also a few extra things that you will need to add to this that should be added to all Clicker Heroes 2 mods.

The following line will need to be added to the top under import flash.display.Sprite:

    
	import heroclickerlib.CH2;
	

You will also need to create a MOD_INFO object in your Main class with the following fields:

	
	public var MOD_INFO:Object =    
	{    
	    "name": "Your Mod's Name",
	    "description": "A description of your mod.",
	    "version": 1,
	    "author": "Your Name"
	};
	

And, finally, you will need to add at least one of the five functions that the game looks for when loading mods:

	
	public function onStartup(game:IdleHeroMain):void { }

	public function onStaticDataLoaded(staticData:Object):void { }

	public function onUserDataLoaded():void { }

	public function onCharacterCreated(characterInstance:Character):void { }
	// Note: onCharacter Created requires import models.Character
	
	public function onUICreated():void { }

	

You can leave out any of the functions that your mod doesnt use, but you will need at least one of them depending on what you plan to do. The basic outline of your mod should look something like this:

	
	package
	{
		import flash.display.Sprite;
		import heroclickerlib.CH2;
		import models.Character;

		public class YourMain extends Sprite 
		{        
		        public var MOD_INFO:Object =    
				{    
				    "name": "Example Mod",
				    "description": "An example mod description.",
				    "version": 1,
				    "author": "Author Name"
				};

				public function onStartup(game:IdleHeroMain):void 
				{ 
					// Your Code Here
				}

				public function onStaticDataLoaded(staticData:Object):void
				{ 
					// Your Code Here
				}

				public function onUserDataLoaded():void
				{ 
					// Your Code Here
				}

				public function onCharacterCreated(characterInstance:Character):void
				{ 
					// Your Code Here
				}
				
				public function onUICreated():void
				{ 
					// Your Code Here
				}
	    	}

	}		
	

As a shortcut you can copy and paste the above template into your project, but make sure that you change YourMain, the name of the class, to match whatever name you gave your own Main.as file. You will need to make sure you’ve renamed Main.as before you copy and paste the template or FlashDevelop may give you an error that a target file must be specified. You’ll also want to change the "name" and "description" fields to be the name and description of your own mod, and “author” to be your own name or handle. Make sure to keep the quotes (""). You can also find the same code template in EmptyModTemplateMain.as in the Clicker Heroes 2\mods\examples folder.

At this point you should be able to build your project by going to Project > Build Project from the menu bar, or by pressing F8, or by clicking the gear symbol menu button at the top. After this, code completion should be enabled, and you will be able to reference Clicker Heroes 2 code to create your mod.

When you are finished writing your code and build your project for the final time, you will find your completed mod in the Location that you set when you first created your project. At that location there will be a folder with your mod name, and inside will be a bin folder that will contain a .swf file that is your mod. The folder structure will be something like this:

    Your Mod Name\bin\YourModName.swf

You will need to copy the .swf file to the mods\active folder, which is located where your Clicker Heroes 2 game is installed. By default it should be somewhere like this with Steam:

    C:\Program Files (x86)\Steam\steamapps\common\Clicker Heroes 2\mods\active\

You can also find the Clicker Heroes 2 folder through Steam by right-clicking on Clicker Heroes 2 in your games list and choosing Properties > Local Files > Browse Local Files… and then going to the mods\active folder from there.

You will know you've found the right place because you will see some mods that come with the game, like HelpfulAdventurer.swf -- this is Cid, and yep, she's a mod!

At the moment you will also have to manually edit a file to tell the game to load your mods, and what order to load it in compared to your other installed mods. The file is called mod.txt and on Windows it will be located in this location:

    C:\Users\*Your User Name*\AppData\Roaming\ClickerHeroes2\Local Store\

You can also type %appdata% into the Windows Explorer address bar to get directly to the AppData\Roaming folding if you are having trouble locating it.

You will need to add the line YourMod.swf to mods.txt, using the name of the .swf file you just put in the mods\active folder. It should look something like this alongside the mods that come with the game, with the italics being the part you add:

  • HelpfulAdventurer.swf
  • Wizard.swf
  • YourMod.swf

WARNING: Before you run your game you should always backup your saves before testing out new mods! Otherwise you will not be able to get your save back if something gets broken or you want to revert certain changes. On Windows your save files can be found here:

    C:\Users\*Your User Name*\AppData\Roaming\ClickerHeroes2\Local Store\saves

You can also type %appdata% into the Windows Explorer address bar to get directly to the AppData\Roaming folding if you're having trouble locating it.

After that you should be able to load the game and see the effects of your mod!

Summary: Creating a CH2 Mod in FlashDevelop with Flex SDK + Air SDK

  1. Backup your saves!

  2. Create a new AS3 project and insert the full file path of CH2Library.swc into the SWC Libraries array in Project > Properties > Compiler Options

    Note: You will need to do this for every new project/mod

  3. Rename Main.as to whatever you want the name of your Main class to be (including the .as) and update references.
  4. In your mod, import flash.display.Sprite and heroclickerlib.CH2 (and models.Character if you will be using onCharacterCreated), create a main class that extends Sprite, create a MOD_INFO object as detailed above, and add any of the onStartup, onStaticDataLoaded, onUserDataLoaded, onCharacterCreated, or onUICreated functions you plan to use, as detailed above. A basic outline of your mod should look something like this, with YourMain being what you renamed your Main.as file (without the .as), or you can also find the same code template in EmptyModTemplateMain.as in the Clicker Heroes 2\mods\examples folder:

  5. 	
    	package
    	{
    		import flash.display.Sprite;
    		import heroclickerlib.CH2;
    		import models.Character;
    
    		public class YourMain extends Sprite 
    		    {        
    		        public var MOD_INFO:Object =    
    			{    
    				"name": "Example Mod",
    				"description": "An example mod description.",
    				"version": 1,
    				"author": "Author Name"
    			};
    
    			public function onStartup(game:IdleHeroMain):void { }
    
    			public function onStaticDataLoaded(staticData:Object):void { }
    
    			public function onUserDataLoaded():void { }
    
    			public function onCharacterCreated(characterInstance:Character):void { }
    			
    			public function onUICreated():void { }
    	    }
    	}
    		
    	
    
  6. Write your code and build your project.

  7. Put the compiled .swf of your mod in the mods\active folder.

  8. Edit mods.txt in \AppData\Roaming\ClickerHeroes2\Local Store\ to add your mod's filename to the priority list.

  9. Backup your saves!

  10. Run the game and test your mod.