Convert Figma logo to code with AI

ValveSoftware logohalflife

Half-Life 1 engine based games

3,653
617
3,653
2,073

Top Related Projects

4,791

Quake GPL Source Release

1,790

Vulkan Quake port based on QuakeSpasm

Xash3D FWGS engine.

Quick Overview

The ValveSoftware/halflife repository contains the source code for the original Half-Life game engine, released by Valve Corporation. This repository allows developers and modders to explore, modify, and build upon the classic game engine that powered one of the most influential first-person shooters in gaming history.

Pros

  • Provides access to the source code of a legendary game engine
  • Enables modders and developers to create custom content and mods
  • Offers valuable insights into game engine architecture and design
  • Supports cross-platform development (Windows, Linux, macOS)

Cons

  • Outdated codebase compared to modern game engines
  • Limited documentation and support
  • Requires significant technical knowledge to work with effectively
  • May have licensing restrictions for commercial use

Code Examples

// Example 1: Player movement calculation
void CBasePlayer::PlayerMove()
{
    if (FBitSet(pev->flags, FL_ONTRAIN))
    {
        PlayerRide();
        return;
    }

    if (pev->waterlevel > 1)
    {
        if (pev->movetype != MOVETYPE_NOCLIP)
        {
            pev->movetype = MOVETYPE_WALK;
            WaterMove();
            return;
        }
    }

    if (pev->movetype != MOVETYPE_NOCLIP && pev->movetype != MOVETYPE_NONE)
    {
        WalkMove();
    }
}

This code snippet demonstrates how player movement is calculated in the Half-Life engine, handling different scenarios such as riding on trains, moving in water, and regular walking.

// Example 2: Weapon firing logic
void CBasePlayerWeapon::PrimaryAttack()
{
    if (m_iClip <= 0)
    {
        if (m_fFireOnEmpty)
        {
            PlayEmptySound();
            m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
        }
        return;
    }

    m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
    m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;

    m_iClip--;

    m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;

    // player "shoot" animation
    m_pPlayer->SetAnimation(PLAYER_ATTACK1);

    Vector vecSrc	 = m_pPlayer->GetGunPosition();
    Vector vecAiming = m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES);

    Vector vecDir;
    vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_1DEGREES, 8192, BULLET_PLAYER_MP5, 2);

    PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usMP5, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0);

    m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1;

    if (m_iClip == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
        m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);

    m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15);
}

This example shows the logic for firing a weapon in the Half-Life engine, including ammo management, player animations, and bullet trajectory calculations.

Getting Started

To get started with the Half-Life engine source code:

  1. Clone the repository: `git clone https://github.com/ValveSoftware/halflife.

Competitor Comparisons

4,791

Quake GPL Source Release

Pros of Quake

  • More extensive documentation and community contributions
  • Broader platform support, including DOS and various Unix systems
  • Pioneering 3D engine technology with hardware acceleration support

Cons of Quake

  • Older codebase with less modern programming practices
  • More complex build process due to supporting multiple platforms
  • Less modular architecture compared to Half-Life's engine

Code Comparison

Quake (client movement):

void CL_BaseMove (usercmd_t *cmd)
{
    if (cls.signon != SIGNONS)
        return;

    CL_AdjustAngles ();
    
    VectorCopy (cl.viewangles, cmd->angles);
    if (in_strafe.state & 1)
    {
        cmd->sidemove += cl_sidespeed.value * CL_KeyState (&in_right);
        cmd->sidemove -= cl_sidespeed.value * CL_KeyState (&in_left);
    }
}

Half-Life (player movement):

void CBasePlayer::PlayerRun( void )
{
    if ( ( m_nButtons & IN_DUCK ) || FBitSet( pev->flags, FL_DUCKING ) )
    {
        SetAnimation( PLAYER_WALK );
    }
    else
    {
        SetAnimation( PLAYER_RUN );
    }
}

Both repositories showcase groundbreaking FPS game engines, with Quake focusing on 3D rendering innovations and Half-Life emphasizing modular design and extensibility. Quake's codebase is more platform-diverse but less modern, while Half-Life's is more focused on Windows and uses more object-oriented approaches.

1,790

Vulkan Quake port based on QuakeSpasm

Pros of vkQuake

  • Utilizes modern Vulkan API for improved graphics performance
  • Actively maintained with recent updates
  • Supports cross-platform development (Windows, Linux, macOS)

Cons of vkQuake

  • Smaller community and less extensive modding support
  • Limited to Quake engine, while Half-Life supports multiple mods
  • May require more modern hardware to run optimally

Code Comparison

vkQuake (Vulkan rendering):

VkCommandBuffer cmd = vkQuake.currentCommandBuffer;
vkCmdBeginRenderPass(cmd, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, graphics_pipeline);
vkCmdDraw(cmd, 3, 1, 0, 0);
vkCmdEndRenderPass(cmd);

Half-Life (OpenGL rendering):

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_TRIANGLES);
glVertex3f(-1.0f, -1.0f, 0.0f);
glVertex3f( 1.0f, -1.0f, 0.0f);
glVertex3f( 0.0f,  1.0f, 0.0f);
glEnd();

The code snippets demonstrate the difference in rendering APIs, with vkQuake using Vulkan for more efficient GPU utilization, while Half-Life uses traditional OpenGL calls.

Xash3D FWGS engine.

Pros of xash3d-fwgs

  • Cross-platform support, including mobile devices
  • Active development and community contributions
  • Enhanced features and mod support beyond the original engine

Cons of xash3d-fwgs

  • Potential compatibility issues with some mods or custom content
  • Less official support from Valve

Code Comparison

halflife:

void CBasePlayer::PreThink(void)
{
    if (g_fGameOver)
        return;

    ItemPreFrame();
    WaterMove();

xash3d-fwgs:

void CBasePlayer::PreThink(void)
{
    if (g_fGameOver)
        return;

    ItemPreFrame();
    WaterMove();

The core functionality in both repositories appears similar, with xash3d-fwgs likely building upon the original halflife codebase. However, xash3d-fwgs may include additional optimizations and features not present in the official Valve repository.

xash3d-fwgs offers broader platform support and ongoing development, making it attractive for modders and enthusiasts. However, halflife provides the official, unmodified source code, which may be preferable for purists or those seeking guaranteed compatibility with original Half-Life content.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Half Life 1 SDK LICENSE

Half Life 1 SDK Copyright © Valve Corp.

THIS DOCUMENT DESCRIBES A CONTRACT BETWEEN YOU AND VALVE CORPORATION (“Valve”). PLEASE READ IT BEFORE DOWNLOADING OR USING THE HALF LIFE 1 SDK (“SDK”). BY DOWNLOADING AND/OR USING THE SOURCE ENGINE SDK YOU ACCEPT THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE PLEASE DON’T DOWNLOAD OR USE THE SDK.

You may, free of charge, download and use the SDK to develop a modified Valve game running on the Half-Life engine. You may distribute your modified Valve game in source and object code form, but only for free. Terms of use for Valve games are found in the Steam Subscriber Agreement located here: https://store.steampowered.com/subscriber_agreement/

You may copy, modify, and distribute the SDK and any modifications you make to the SDK in source and object code form, but only for free. Any distribution of this SDK must include this license.txt and third_party_licenses.txt.

Any distribution of the SDK or a substantial portion of the SDK must include the above copyright notice and the following:

DISCLAIMER OF WARRANTIES. THE SOURCE SDK AND ANY OTHER MATERIAL DOWNLOADED BY LICENSEE IS PROVIDED “AS IS”. VALVE AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES WITH RESPECT TO THE SDK, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, TITLE AND FITNESS FOR A PARTICULAR PURPOSE.

LIMITATION OF LIABILITY. IN NO EVENT SHALL VALVE OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE ENGINE AND/OR THE SDK, EVEN IF VALVE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

If you would like to use the SDK for a commercial purpose, please contact Valve at sourceengine@valvesoftware.com.

Half-Life 1

This is the README for the Half-Life 1 engine and its associated games.

Please use this repository to report bugs and feature requests for Half-Life 1 related products.

Reporting Issues

If you encounter an issue while using Half-Life 1 games, first search the issue list to see if it has already been reported. Include closed issues in your search.

If it has not been reported, create a new issue with at least the following information:

  • a short, descriptive title;
  • a detailed description of the issue, including any output from the command line;
  • steps for reproducing the issue;
  • your system information.*; and
  • the version output from the in-game console.

Please place logs either in a code block (press M in your browser for a GFM cheat sheet) or a gist.

* The preferred and easiest way to get this information is from Steam's Hardware Information viewer from the menu (Help -> System Information). Once your information appears: right-click within the dialog, choose Select All, right-click again, and then choose Copy. Paste this information into your report, preferably in a code block.

Conduct

There are basic rules of conduct that should be followed at all times by everyone participating in the discussions. While this is generally a relaxed environment, please remember the following:

  • Do not insult, harass, or demean anyone.
  • Do not intentionally multi-post an issue.
  • Do not use ALL CAPS when creating an issue report.
  • Do not repeatedly update an open issue remarking that the issue persists.

Remember: Just because the issue you reported was reported here does not mean that it is an issue with Half-Life. As well, should your issue not be resolved immediately, it does not mean that a resolution is not being researched or tested. Patience is always appreciated.

Building the SDK code

Visual Studio 2019 is required to build mod DLLs on Windows. In the Visual Studio installer, install "Desktop development with C++" under "Workloads" and "C++ MFC for latest v142 build tools (x86 & x64)" under "Individual components". VS2019 projects can be found in the projects\vs2019 folder.

Tools have not yet been updated for VS2019, but can be built using the VS2010 projects in the projects\vs2010 folder. See the readme.txt file there.

Linux binaries can be built using Makefiles found in the linux folder. They expect to be built / run in the Steam Runtime "scout" environment. The built binaries are copied to a directory called game at the same level as the root directory for the git repository. You can set CREATE_OUTPUT_DIRS=1 while building to create the output directory structure automatically.