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?!
- . , , .
- . Source .
- SDK , SDK ( , ( อกยฐ อส อกยฐ) ) ! , Source SDK ( ...) .
- . . C++ !
.
?
- C++ ( ).
- Microsoft Visual Studio Multibyte MFC Library Microsoft Build Tools 2013 (v120/v120_xp). , VS2013.
- Git for Windows .
- Steam Source SDK Base 2013 [Single|Multi]player ( "" - upstream, )
- 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 :
-
src/creategameprojects.bat
. -
/hl2
- .
creategameprojects.bat
bash โ createallprojects.bat
bash.
VPC , , vrad (Radiosity!) height2normal.
, .
, , . , ( IDE?):
- Release.
: Debug !!! - (F6)
- , 2.
- , (creategameprojects) 1.
game/mod_hl2/bin/
game/mod_episodic/bin/
!
โ 1 โ Steam
-
mod_xxx
//Steam/steamapps/sourcemods/
- Steam ( , ...)
- "My First Episodic Mod" "My First HL2 Mod"
- :
-dev -console
- ,
sdk_vehicles
(SP)dm_lockdown
(MP)
โ 2 โ Visual Studio
โ !
- ( !!!) Debugging
- Command :
//steam/steamapps/common/Source SDK Base 2013 XXXX/hl2.exe
- Working Directory :
//steam/steamapps/common/Source SDK Base 2013 XXXX/
- Command Arguments :
-game "///xx/game/mod_xxx/" -debug -dev -console
- , (F5)!
- ,
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 );
!
:
-
src/game/server/hl2/weapon_pistol.cpp
(Server (Episodic/HL2)/HL2 DLL/weapon_pistol.cpp
) -
void CWeaponPistol::PrimaryAttack( void )
(- 255) -
BaseClass::PrimaryAttack();
- , :
BaseClass::PrimaryAttack(); // - 251 Msg( "weapon_pistol: m_iClip1 = %d\n", m_iClip1 );
- ,
- Since we wrote in arguments
-dev
, cheat commands are enabled by default, so write the proverbial to the consoleimpulse 101
and 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
- Valve Developer Community and its SSDK section
- My mod [SP] with numerous fixes