Es/My First Mod
Introducción
Este tutorial enseña como crear, configurar y compilar tu primer simple MOD de HL2. En este MOD cambiaremos la velocidad de los misiles de Half-Life 2.
Crear un nuevo proyecto de MOD Half-Life 2
Para los propósitos de este tutorial llamaremos a este primer MOD, "MiMod". Cuando creas un nuevo MOD lo puedes llamar como quieras (p.e. "QuickMod", "TreasureTroll", etc.)
Asegurate, para obtener siempre la última versión del código Source Actualizar contenido SDK ('Redresh SDK Content').
Para crear un nuevo MOD sigue los soguientes pasos:
- Busca en el menu Herramientas de tu programa Steam y abre Source SDK (que tienes seguro si compraste HL2 original)
- Selecciona Create a Mod ('Crear Mod') de la lista de Utilidades.
- Elige si quieres modificar el juego en solitario: Modify Half-Life 2 Single Player; o bien el juego multijugador Modify Half-Life 2 Multiplayer.
- Especifica el directorio en el cual quieres situar los archivos del MOD (p.e.
C:\MiMod
). - Elije un nobre para tu MOD. En este ejemplo lo llamamos 'Mimod'.
- Windows Vista posiblemente requiera una configuración de seguridad especial. (Más abajo están los problemas conocidos listados)
La aplicación Steam copiará todos los archivos relevantes al directorio elegido. Todos los archivos son las librerías de programación entre otros, y están debidamente catalogados y organizados. Todo eso puede ser modificado.
Abrir las soluciones del MOD
- Ejecuta Microsoft Visual Studio. El código está diseñado para funcionar con la versión 2003 pero ha sido mejorado para funcionar con versiones más modernas. Recomendamos una copia mejor. Hay guías para, Compilar con VS 2005 y Compilar con VS 2008
- Seleciona File->Open Solution del menu, y abre Game_HL2-2003.sln o Game_HL2-2005.sln localizables en el directorio del mod
src
. Selecciona el que coincida con tu versión de Microsoft Visual Studio. Fijate en que la parte "HL2" del nombre del archivo correspoderá con lo qeu se seleccionó en la creación del Mod. Si seleccionaste un Mod desde un borrador, "Borrador" aparecera en vez de 'hl2'.
Alterar la velocidad del misil
Si estás editando 'Half-life Single-player', abre el archivo hl2_dll/weapon_rpg.cpp
. En caso contrario, abre hl2mp_dll/weapon_rpg.cpp
.
Nota: Si no encuentras el archivo, prueba a buscar en 'server_hl2 > Source Files > HL2 DLL' en el explorador, o en el Visual Studio.
Una vez abierto, al comienzo del archivo busca la sentencia:
#define RPG_SPEED 1500
Cambia este número para que ponga:
#define RPG_SPEED 400
Alterando este número, hemos establecido la velocidad de los misiles a 400 unidades por minuto (unos 33 pies, (10 meters), por segundo). Antes, la velocidad era de 1500 unidades por segundo (125 pies/s o 38 m/s). La diferencia de velocidades será definitiva cuando compilemos el 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.
For Visual Studio 2005 users:
- Select Project -> Properties (last entry in menu)
- Press Configuration Manager (upper right button)
- Change the Active Solution Configuration drop-down list to "Release"
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
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; in fact, 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 that content into your mod, but this content cannot be legally 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, although it's advisable to change it back to 215 later.
In the directory that you created your MOD, there will be a batch file called run_mod.bat
. Don't use the bat file to launch your mod, as it has not been updated for the SDK Base. The best way to launch your mod is to restart Steam and launch it from your Games list (where it should hopefully have appeared) or via the debugging option in vis (read how to debug the source code).
Now that there's 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.
In "Options", "Keyboard", and "Advanced", enable the Developer Console. 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 from the HL2 maps with 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 (e.g. "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.
- See Category:Level_Design for articles on populating your mod with levels.
- See Category:Modeling for articles to help you add models to your MOD.
Template:Otherlang:en Template:Otherlang:en:es, Template:Otherlang:en:de, Template:Otherlang:en:pl, Template:Otherlang:en:ru, Template:Otherlang:en:pt, Template:Otherlang:en:pt-br