世界上有很多游戏引擎,但是在历史和功能上都没有一个类似于Source的引擎。
在本(试验)教程中,我们将逐步介绍SDK源代码的最简单步骤,并对“半条命2”代码进行首次更改。
介绍
几个词
该源SDK本身是一套实用程序和帮助您开发自己的水平和修改的游戏程序,以及为半条命2和情节的源代码。
/ ( , :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 );
- ,
- 由于我们是在参数中
-dev
编写的,因此默认情况下会启用作弊命令,因此请将谚语写到控制台上impulse 101
并尝试射击手枪!
结论
我们学到了什么?
[我希望]从本教程中我们得出:
- 一般而言,什么是Source SDK?
- 如何使用VPC生成项目
- 如何在开发者控制台上打印内容
下一步是什么?
在第二部分中,我们将分解Source SDK实体系统。