Source Modding - Part 1 - The Basics

There are many game engines in the world, but there is not a single engine that is similar to Source in its history and features.



In this (pilot) lesson, we'll walk through the simplest steps with the SDK source codes, as well as make our first change to the Half-Life 2 code.





Introduction



A few terms



The Source SDK itself is a set of utilities and programs that help you develop your own levels and modifications for the game, as well as the source code for Half-Life 2 and episodes.



/ ( , :p) โ€” SDK.



Source?!



  1. . , , .
  2. . Source .
  3. SDK , SDK ( , ( อกยฐ อœส– อกยฐ) ) ! , Source SDK ( ...) .
  4. . . C++ !
  5. .


?



  1. C++ ( ).
  2. Microsoft Visual Studio Multibyte MFC Library Microsoft Build Tools 2013 (v120/v120_xp). , VS2013.
  3. Git for Windows .
  4. Steam Source SDK Base 2013 [Single|Multi]player ( "" - upstream, )
  5. HLSL, :)






SDK GitHub. :



git clone https://github.com/ValveSoftware/source-sdk-2013.git




Half-Life 2/Episode 1/2, sp/ Source SDK Base 2013 Singleplayer.



Half-Life 2: Deathmatch, mp/ Source SDK Base 2013 Multiplayer.



: SP, , hl2 MP hl2mp hl2!!!





(client.dll) C_, (server.dll) โ€” C:



// client.dll
class C_BaseWeapon { ... };
// server.dll
class CBaseWeapon { ... };


m_, ( , ):



class C_SomeClientClass {
private:
    float m_flTime = 0.0;
};
extern float g_flSomeFloat;
static float s_flSomeStaticFloat;
void SomeFunction(float flValue);




SDK, , .



  • client.dll

    .

    , .

    : src/game/client/
  • server.dll

    .

    , ..

    : src/game/server/
  • tier1.lib

    , , UTL ("" STL), interface convention ..

    : src/tier1/
  • raytrace.lib

    , , . , , .

    vrad , , Valve Hammer Editor.

    : src/raytrace/
  • mathlib.lib

    , , "" Source.

    : src/mathlib/
  • vgui_controls.lib

    , (, ) VGUI2.

    .

    : src/vgui2/vgui_controls/


VPC



Source SDK (sln, Makefile, etc.) โ€ฆ โ€ฆ

Valve Project Creator src/devtools/bin.



.VPC . โ€” -.



:



src/game/client/client_episodic.vpc
src/tier1/tier1.vpc
src/utils/vrad/vrad_dll.vpc


: VPC !





, src/.

โ€” src/creategameprojects.bat.

src/ games.sln.





HL2



SDK HL2 Episodic. , .



, , HL2 :



  1. src/creategameprojects.bat .
  2. /hl2
  3. .




creategameprojects.bat bash โ€” createallprojects.bat bash.



VPC , , vrad (Radiosity!) height2normal.



, .







, , . , ( IDE?):



  1. Release.

    : Debug !!!
  2. (F6)
  3. , 2.
  4. , (creategameprojects) 1.


game/mod_hl2/bin/ game/mod_episodic/bin/ !



โ€” 1 โ€” Steam



  1. mod_xxx //Steam/steamapps/sourcemods/
  2. Steam ( , ...)
  3. "My First Episodic Mod" "My First HL2 Mod"
  4. :

    -dev -console
  5. , sdk_vehicles (SP) dm_lockdown (MP)


โ€” 2 โ€” Visual Studio



โ€” !



  1. ( !!!) Debugging
  2. Command :

    //steam/steamapps/common/Source SDK Base 2013 XXXX/hl2.exe
  3. Working Directory :

    //steam/steamapps/common/Source SDK Base 2013 XXXX/
  4. Command Arguments :

    -game "///xx/game/mod_xxx/" -debug -dev -console
  5. , (F5)!
  6. , sdk_vehicles (SP) dm_lockdown (MP)


โ€” !







Msg()



Msg(), DevMsg(), Warning(), DevWarning() ConColorMsg() - printf(), Source SDK. - debug output.



// somewhere in tier0/dbg.h
void Msg( const tchar* pMsg, ... );

// somewhere in code
Msg( "This is a message! %d\n", 42 );


!



:



  1. src/game/server/hl2/weapon_pistol.cpp (Server (Episodic/HL2)/HL2 DLL/weapon_pistol.cpp)
  2. void CWeaponPistol::PrimaryAttack( void ) (- 255)
  3. BaseClass::PrimaryAttack(); - , :

    BaseClass::PrimaryAttack(); // -   251
    Msg( "weapon_pistol: m_iClip1 = %d\n", m_iClip1 );
  4. ,
  5. Since we wrote in arguments -dev, cheat commands are enabled by default, so write the proverbial to the console impulse 101and try to shoot a pistol!




Conclusion



What have we learned?



[I hope that] from this tutorial we figured out:



  • What is Source SDK in general and what it is eaten with
  • How to generate projects using VPC
  • How to print something to the developer console


What's next?



In the second part, we will break down the Source SDK entity system.



useful links






All Articles