源代码修改-第1部分-基础知识

世界上有很多游戏引擎,但是在历史和功能上都没有一个类似于Source的引擎。



在本(试验)教程中,我们将逐步介绍SDK源代码的最简单步骤,并对“半条命2”代码进行首次更改。





介绍



几个词



源SDK本身是一套实用程序和帮助您开发自己的水平和修改的游戏程序,以及为半条命2和情节的源代码。



/ ( , :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. 由于我们是在参数中-dev编写的,因此默认情况下会启用作弊命令,因此请将谚语写到控制台上impulse 101并尝试射击手枪!




结论



我们学到了什么?



[我希望]从本教程中我们得出:



  • 一般而言,什么是Source SDK?
  • 如何使用VPC生成项目
  • 如何在开发者控制台上打印内容


下一步是什么?



第二部分中,我们将分解Source SDK实体系统。



有用的链接






All Articles