My First Mod: Difference between revisions
Goldenoren (talk | contribs) No edit summary |
m (Reverting Goldenoren's changes) |
||
Line 4: | Line 4: | ||
This tutorial will teach you how to create, setup and build your first simple HL2 MOD. In this MOD we will change the speed at which Half-Life 2's rocket travels through the world. | This tutorial will teach you how to create, setup and build your first simple HL2 MOD. In this MOD we will change the speed at which Half-Life 2's rocket travels through the world. | ||
== Create the | == Create the MOD project == | ||
For the purpose of this tutorial we will call our first MOD, "MyMod". When you make your own MOD this can be any name you wish (i.e. "QuickMod", " | For the purpose of this tutorial we will call our first MOD, "MyMod". When you make your own MOD this can be any name you wish (i.e. "QuickMod", "TreasureTroll", etc.) | ||
Please note that in order to get the latest source-code you must [[Refresh SDK Content|refresh the SDK content]]. | Please note that in order to get the latest source-code you must [[Refresh SDK Content|refresh the SDK content]]. |
Revision as of 01:14, 7 December 2006
Introduction
This tutorial will teach you how to create, setup and build your first simple HL2 MOD. In this MOD we will change the speed at which Half-Life 2's rocket travels through the world.
Create the MOD project
For the purpose of this tutorial we will call our first MOD, "MyMod". When you make your own MOD this can be any name you wish (i.e. "QuickMod", "TreasureTroll", etc.)
Please note that in order to get the latest source-code you must refresh the SDK content.
To create a MOD project:
- Open the Source SDK application from Steam's Tools menu.
- Open Create A Mod from the Utilities group.
- Select either Modify Half-Life 2 Single Player or Modify Half-Life 2 Multiplayer.
- Specify where you would like the MOD's project to be placed (i.e.
C:\MyMod
). - Enter the name of your MOD. In this example, we'll use "MyMod".
The Steam application will then copy all the relevant files to the destination directory that you specified. You now have a copy of Half-Life 2's source code at that location which you can modify.
Open the MOD solution
- Launch the Microsoft Visual C++ .NET 2003 v7.1 application. If you only have Microsoft Visual C++ .NET 2002 read Compiling under VS2002 on how to convert the project files. In case you're using Microsoft Visual C++ .NET 2005 read Compiling under VS2005.
- Select File->Open Solution from the menu and open the Game_SDK solution located in your MOD's
src
directory.
Alter the rocket's speed
If you are editing Half-life Single-player, open file hl2_dll/weapon_rpg.cpp
. Otherwise open hl2mp_dll/weapon_rpg.cpp
.
At the top of the file, find the line:
#define RPG_SPEED 1500
Change this line to read:
#define RPG_SPEED 400
By altering this number, we've told the rocket to travel at 400 units per second (or about 33 feet per second). Previously the rocket traveled at 1500 units per second (125 feet per second). The difference in speed will be very apparent when we compile and run the MOD.
Set the active configuration
We'll need to set our active configuration to "Release HL2".
To do this:
- Select Build->Configuration Manager.
- Change the Active Solution Configuration drop-down list to "Release HL2"
- Select Close.
Compile the project
Now we are ready to build the solution. Choose Build->Build Solution to begin. When the requested compilation has completed there will be a server.dll
and client.dll
file in the MyMod/bin
directory (i.e. C:\MyMod\MyMod\Bin)
. This is the custom server and client DLL for our MOD and is one of the pieces that would be distributed to end-users.
Run the MOD
In the directory that you created your MOD, there will be a batch file called run_mod.bat
. Use this batch file to launch your MOD. Now before you launch it's important to ensure you have something to launch. By default new mods will use the 215 appid, this loads the Source SDK Base. This is not a bad thing, infact it's the best version of the engine available. The only problem it does have is that it has no game specific content. Global resources like textures and models available to all games will be present; however, levels will not be. You will either need to change the appid to use different game engines and load content from that game or instead copy content out of that game into your mod. GCFScape can allow you to copy out the content into your mod, this content cannot be legal redistributed with your mod. The other approach is simply finding your .../steamapps/sourcemods/MyMod/gameinfo.txt
and changing the value to 220 for single player and 320 for multiplayer, its advisable to change it back to 215 later.
Now theres content to load start the game up. When the engine has loaded, you'll be taken to the title screen. If you are warned about missing content, such as maplist.txt
, ignore it. Hit the tilde key (~) to bring up the Developer Console. This console will provide you with numerous tools to help you create content for the Source engine.
No maps are provided with your single player mod so Copy a map which can be extracted from the original HL2 maps with GCFSCAPE (http://developer.valvesoftware.com/wiki/GCFScape) to your mod's /maps/ directory inside of SteamApps/SourceMods. Load a map by typing "map " (including the space) into the console and select from the list (i.e. "map d1_canals_01
") then type "impulse 101
" to give yourself a load of weapons.

sv_cheats 1
" in the console (~) for the "impulse 101
" command to workSelect and fire the RPG to view the changes you've made.
You've built your first MOD
You’ve now setup and built your first MOD. See Category:Modding for articles to help you add more features to your MOD. See Category:Programming for a listing of programmer-specific documentation.
Known issues
Use of the 215 appid has been known to cause a glitch with the gravity gun. The sprites surrounding it do not have correct transparency and as such are surrounded by black. Simply extracting the correct files from the source materials.gcf
will resolve the issue. Extracting the entire materials/sprites
folder is the quickest and least complicated approach.
Template:Otherlang:en Template:Otherlang:en:ru, Template:Otherlang:en:de, Template:Otherlang:en:pl