Ok, so you have decided that you want to write your own mod. You have found that special thing that you would really love to have in the game, but when you ask about in on the forums, nobody listens. Or maybe they listen, but the mods don’t turn out the way you want them to.
What to do?
You start to browse the internet to buy Flash, and you realize that the price for Flash Professional is somewhere around 500 bucks (unless you’re a student, or teacher and can get the faculty discount), and it just doesnt feel right to spend that amount of your hard earned dollars on having an extra sound playing when your friends come online (or whatever mod you’ve planned to write).
But this isn’t the end of the road. It’s totally possible to write your mod with free (yes, legally free) stuff of the internet. It can be a little tricky for the newbie, but hey, if it’s too easy – no fun, right :).
This is what you do…
(This guide isn’t really a guide on how to code actionscript, it’s focus is to get your environment up and running).
Downloading and installing your tools
The links to all the tools mentioned here is also placed in the linkbox to the right. Before you do anything, make sure that you have the latest Flash ActiveX Debugger installed.
- Download UDK and install it (pay attention where this is installed to make it easier to configure FlashDevelop later).
- Download FlashDevelop, and install it.
- Flex SDK will be installed along with FlashDevelop (all you need to create mods for TSW), but if you want extra SDK’s you can download them manually later.
- Download and install (just doubleclick the downloaded file) the AS2 templates.
Now to setting up your environment for first use
- I would recommend that you make a copy of your source directory (usually located: D:\Program Files (x86)\Funcom\The Secret World\Data\Gui\Customized\Flash\Sources). Especially since you need to change some files to be able to compile your project. Make it a good practice to not change files that you have not written yourself. Always change copies.
- Lets fire up FlashDevelop and start.
- Create a new Project based the AS2 Template, and just name it Test.
![Step1](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step1.png?w=300&h=206)
First we need to configure FlashDevelop on where to find the source files needed
- Go to Project > Properties.
![Step2](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step2.png?w=293&h=300)
- Click the tab Classpaths and then the button Edit Global Classpaths…
![Step3](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step3.png?w=300&h=200)
- Add the path to the UDK CLIK (your path may differ, but since you read the instructions earlier you know where your install path is). The first line is the path to the copy of the sources folder you made at step 5.
Now we are going to configure deployment of our mod
- Navigate to the project explorer (the tree view to the right).
- Create a new folder in your project and name it package.
- Create a second folder in your project and name it lib. We will use it later.
- Create a new folder under package and name it Test.
- Now right click project name and select Properties.
- On the Output tab, in the General group enter package\Test\Test.swf in the Output file field..
![Step4](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step4.png?w=293&h=300)
- Now click the Build tab.
- In the Post-build Command Line field enter the following:
xcopy "$(ProjectDir)\package\*.*" "D:\Program Files (x86)\Funcom\The Secret World\Data\Gui\Customized\Flash\" /e /y
Make sure that you write the path to your TSW installation. I have mine on the D-drive, you may use C.
This will copy our mod files when we compile. The /e /y flags make sure that our new directory is created for us, and that we can just re-compile our project when we make changes, and not worry about being prompted if we want to overwrite our old version.
![Step5](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step5.png?w=293&h=300)
- Create two new xml files in the package\Test folder. Name them CharPrefs.xml and Modules.xml.
Enter the following content in CharPrefs.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Root>
<Value name="Test" value="true" />
<Archive name="Test_data" />
</Root>
and the following content in Modules.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Root>
<Module name = "Test"
movie = "Test\Test.swf"
flags = "GMF_CFG_STORE_USER_CONFIG | GMF_DONT_UNLOAD"
depth_layer = "Top"
sub_depth = "0"
variable = "Test"
criteria = "Test && (guimode & (GUIMODEFLAGS_INPLAY | GUIMODEFLAGS_ENABLEALLGUI))"
config_name = "Test_data"/>
</Root>
We’re getting close. Just a few more steps. Hang in there!
Two more things is needed to be able to compile our little test mod.
First, since we don’t have the real flash, the flash pre-compiled classes like Button, and so on is not included (everything in mx.*), and Funcom uses the mx.utils.Delegate class, so we have to write that class ourselves. Easy enough. 🙂
While we’re at it, we’re going to make improve the Delegate class so we also can send arguments to our scoped function (you can use this function even if you code in Flash Pro, since it is better than the built in function).
- Open up Windows Explorer and navigate to your source folder (where you copied the source directory from your TSW installation folder). You know you found the right level of the folder structure when you see PrecompiledClasses.as and PrecompiledClasses.fla.
- Create a new folder called mx, and under it utils. In the utils folder create a new textfile, and name it Delegate.as and enter the following content in the textfile and save it:
class mx.utils.Delegate {
public static function create(t:Object, f:Function) : Function
{
var _f:Function = function():Void
{
var _na:Array = arguments.slice(2);
f.apply(t, arguments.concat(_na));
};
return _f;
}
}
- Navigate back to the source folder (the one with the PrecompiledClasses files). And nagivate down to com\Utils. Open the file Signal.as.
- On lines 68, and 76. Change the line:
return;
to:
return null;
You see, one thing with using FlashDevelop is that it is harder on the compile rules than Flash. So bad code, that compile in Flash Pro will not compile. In this case Funcom has written code that return void when the function declaration promise a com.Utils.Slot. Big no-no ofc (but the code does compile in Flash Pro). So one of the benefits with using FlashDevelop compared to Flash Pro is that you learn how to write better code automatically, because some bad code will simply not compile.
Now. We have everything set. All that is left is to write some code for our mod and make it visible in TSW.
- Go back to FlashDevelop.
- In the project folder lib that we created before. Right-click it and choose Add > Library Asset. Select a font from your font library (i downloaded and choose Aller for my example).
- Write the following in Main.as:
import com.GameInterface.Game.Character;
class Main
{
public static function main(swfRoot:MovieClip):Void
{
var t:TextField = swfRoot.createTextField("i_txt", 1, 0, 0, 300, 20);
t.embedFonts = true;
var tf:TextFormat = new TextFormat("lib.Aller.ttf", 14, 0xFF0000, true, false, false);
t.setNewTextFormat(tf);
var c:Character = Character.GetClientCharacter();
t.text = "Hello " + c.GetName();
t._y = 20;
}
public function Main()
{
}
}
- Go to the toolbar and change your compile mode to Debug, and press the Test button (you want to change this back to Release when your mod has been tested and ready to be shared with the world).
![Step6](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step6.png?w=510)
Big success! You should now be presented with a Flash window that looks like this:
![Step7](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step7.png?w=300&h=115)
It says undefined instead of your name, but it’s all good. The Character object will not be available until we are in the game.
Before we start TSW, just check that the mod was deployed correctly.
- Navigate to the flash folder in TSW (Program Files (x86)\Funcom\The Secret World\Data\Gui\Customized\Flash).
- There should be a new folder there named Test. And in that folder you should now have Test.swf, CharPrefs.xml, and Modules.xml.
Isn’t this exciting?!
Time to fire up TSW.
Log in, and if you look at the upper, left corner you should now see your new mod!
![Step8](https://tswmods.wordpress.com/wp-content/uploads/2013/03/step8.png?w=300&h=128)
And now the character name is displayed correctly! Btw, GhostWorld is my char on TestLive if you want to say hello.
One last thing, just to make it clear how easy you can update your mod when you have everthing configured:
- Tab to FlashDevelop. And change this line:
t.text = "Hello " + c.GetName();
to:
t.text = "Hello " + c.GetName() + " you are awesome!";
- Press the Test button again.
- Tab back to TSW.
- Reload your ui by pressing Ctrl+Shift+F1.
And there you have it!
How to develop mods for TSW. For free, and legit!
Happy coding!