ValveSource

From DigitalBlacksmith

Jump to: navigation, search

Contents

[edit] Valve Source SDK

[edit] Upgrading the MOD to OrangeBox

I decided to update my Valve Source engine to the 'Orange Box' engine.

The OrangeBox engine is a new version of the Valve Source Engine. Therefore, if you want to keep your mod project up to date, you need to switch. Valve still supports the original HL2 engine (something they confusingly refer to as episode 1). So you can still develop using the old engine. However, I'm concerned they might not support it for long, and this will cause hard ache later.

So here are some things I learned about building a mod using the orangebox engine:

[edit] Creating a MOD with OrangeBox Source

You have to tell your steam client to download the OrangeBox (OB) C++ source code. Otherwise, when you create a mod through the Source SDK tools dialog, it will try to use the original engine, and give you a warning like:

The source code distributed with this version of the Source SDK is not compatible with the 'Orange Box' version of the Source engine. Mod source code compatible with the Orange Box will be available in upcoming releases

The reason for this is that steam still thinks you want to develop using to 'old' source sdk. Even after you install the OB, you still need to do this. I made the erroneous assumption that the automatic update part of steam would handle this.

To trigger steam to install and use new OB code you need to add the following launch options to steam:

-beta srcsdk0122

Then restart Steam, and click on tools tab. You will see steam pulling the OB source.

Another point of confusion is how the command line options you add refer to the OB source sdk as a 'beta'.

--Admin 12:32, 26 January 2008 (EST)


[edit] Background Maps

Background maps are the 3D moving backgrounds that appear behind the menus when the game is first launched.

See Background Maps

[edit] Body Groups

http://developer.valvesoftware.com/wiki/Body_Groups

[edit] Brain Dump

I decided to reinstall steam, as I had a view versions and it was pretty messy.

Here's the thread

[edit] Customization

Excellent tutorial by Pitulon on Customizing Your Mod

Custom Menu Screen

[edit] Console Commands and Cheats

Using Console Commands from code

Printing to the Console

Rolling your own commands


Here are some of the codes I use all the time.

For a complete list, please check this.

commandDescription
impulse 200 holster weapon
fov XXX Change FOV
cl_showfps To show frame rate of MOD

[edit] Augmented Reality Helper Commands

Here are some handy commands for Augmented Reality Development:


Helpful commands for Augmented Reality
Command Purpose
drawcross Draws a cross at the given location. Arguments: x y z
drawline Draws line between two 3D Points.

Green If no collision Red Is collided with something Arguments x1 y1 z1 x2 y2 z2

ent_pivot Displays the pivot for the given entity(ies). (y=up=green, z=forward=blue, x=left=red).

Arguments {entity_name} / {class_name} / no argument picks what player is looking at

Command Purpose
Command Purpose

[edit] Command Line & Console Commands

Command Line Parameters

Valve Console CMD List

Nice synopsis here --Admin 20:20, 5 February 2008 (EST)

[edit] Dedicated Server

Dedicated Server Stuff


[edit] Dimensions and Coordinate Sys

[edit] Dimensions

http://developer.valvesoftware.com/wiki/Dimensions

Many folks refer to Valve Source as using 'unit' dimensions BUT Many important objects in the source code are hard coded as inches (i.e. the Player). Sure these can be overridden, but there are limits on the max height of a player. So you are best to work with inches.

[edit] Coordinate System

Valve Source and Hammer uses a right hand coordinate system. If you stick out your right hand, and start with your thumb (X) then stick your pointer finger out like you are making a gun gesture (Y) then tilt your middle figure in 90 degrees (Z) you have a copy of the Valve Source coordinate system. Each fingre points in the positive direction.

The other thing to keep in mind is that given this system, the Z axis is the 'up' axis. This can be confusing if you are looking at OpenGL examples (OpenGL is Y up) or some Maya models, etc.

Hammer axis color codes:

  • Red: X AXIS
  • Green: Y AXIS
  • Blue: Z AXIS

[edit] Fonts

Where are they?

<steaminstall>/SteamApps/MyMod/resource/ClientScheme.res

http://www.gotfrag.com/cs/forums/thread/329415/

[edit] Field of View

The default FOV for the player is 75 degrees in Source. This can be problematic for some folks (causing motion sickness) and also will likely need adjusting if you are doing video see-through Augmented Reality (to match the FOV of your AR display).

To change to player FOV at the console (e.g. to 56 degrees) type:

fov 56

I had a hard time passing this value in as a parameter on the command line of in the config.cg file.

To hard code the default, change the value listed in line 17 in the cl_dll/hl2_clientmode.cpp

ConVar default_fov( "default_fov", "75", FCVAR_CHEAT );

and the value listed in gameshared\hl2\hl2_gamerules.h:

DefaultFOV( void ) { return 75; }

[edit] File System

IFileSystem at Valve Source SDK

Dumping key values

 
  KeyValues *kv1 = new KeyValues( "mylist" );
 
    kv1->SetString("name","Brand New"); 
 
 
    bool bSuccess = kv1->SaveToFile( vgui::filesystem(), "resource/test.res" );
 
    if (!bSuccess)
     {
        Msg("BuildMode - Error saving file", "Error: Could not save changes.  File is most likely read only.");
 
      }
 
 

[edit] Gore Blood and Guts (How to make your MOD kid friendly)

http://www.techenclave.com/forums/half-life-2-tweaks-cheats-mods-10247.html

[edit] Lighting

My Experience with Valve Source Lighting

[edit] Materials

Valve Materials Overview

[edit] Messages Between Client and Server

Doing it with a HUD

Observations:

  • The example above shows how a client registers a callback that matches the name of a global message (defined in gameshared/hl2/hl2_usermessages.cpp)
  • The client then hooks this message using some macros and callbacks. I don't think these need to live inside a VGUI element, as long as you include the right hooking macros ans header files
  • The server the sends the messages like this:

WARNING: If you use this approach, as outlined in the above example, you can't do VGUI animation easily. It's using another viewport which doesn't seem to get updated...Just focus on the messages here.

 
CBaseEntity *pPlayer2 = NULL;
 
    pPlayer2 = UTIL_GetLocalPlayer();
 
    if ( pPlayer2 )
    {
        if ( !pPlayer2->IsNetClient() )
        {
            return;
        }
 
        CSingleUserRecipientFilter user( (CBasePlayer *)pPlayer2 );
        user.MakeReliable();
 
        UserMessageBegin( user, "ARMARMsg" );
            WRITE_BYTE( index );
            WRITE_FLOAT( test_counter++ );
            WRITE_STRING( "BEAT NAVY!");
        MessageEnd();
        DevMsg ("Sent msg %d, %d, %s\n", index, 7, "BEAT NAVY!");
    }
 

[edit] Message Logging

In order to have Msg("my message") go to the console:

  • Add the following lined to the games config.cfg file:
developer "1"

To save all console traffic to a log file:

Starting HL with "-condebug" will also log all console output in the text file "console.log" located in your game directory.

THIS IS VERY VERY HELPFUL


[edit] Models

Tutorial on Exporting From Maya 8.0 to Valve

Scaling thread

HalfLife Modeling Manual

  • This is for HL1, but very helpful and complete

Same as above, only pdf


Compiling multiple SMDs as a single model:

This worked!

$modelname cda\cda.mdl
$cdmaterials models\cda

$surfaceprop "rock"
$staticprop
$scale 1

$body "Body" "cda_ammoSwBaseShape.smd"

$bodygroup studio
{
	studio "cda_ammoSwStubShape.smd"
} 

$sequence idle "cda_idle" fps 1


$collisionmodel "cda_phy.smd" {

	//Mass in kilograms
	$concave
	$mass 2.0
	
}

[edit] Model Transparency

To make a model transparent, you need code like this:

this->SetRenderMode(kRenderTransColor);
this->SetRenderColorA(0);  //0 is invisible 255 fully opaque

You can use other settings besides kRenderTransColor. These are the various settings for SetRenderMode() :

	kRenderNormal,			// src
	kRenderTransColor,		// c*a+dest*(1-a)
	kRenderTransTexture,	// src*a+dest*(1-a)
	kRenderGlow,			// src*a+dest -- No Z buffer checks -- Fixed size in screen space
	kRenderTransAlpha,		// src*srca+dest*(1-srca)
	kRenderTransAdd,		// src*a+dest
	kRenderEnvironmental,	// not drawn, used for environmental effects
	kRenderTransAddFrameBlend, // use a fractional frame value to blend between animation frames
	kRenderTransAlphaAdd,	// src + dest*(1-a)
	kRenderWorldGlow,		// Same as kRenderGlow but not fixed size in screen space
	kRenderNone,			// Don't render.

[edit] MultiPlayer Issues

Click here..ug!

[edit] Networking

RCON 101

Setting up a dedicated Server

Dedicated Server page at Valve SDK

RCON page at Valve SDK

Socket Class C++

Simple Networking

Valve Source Server Query Language with C++ code

[edit] NOCLIP - Clipping

Sometimes in AR applications, you don't want the Physics engine to apply to the player (AR camera), as the player's physics are provided by the real world

[edit] Toggling Clipping

Type the following in the game console:

noclip

[edit] Starting your MOD in NOCLIP mode

Add the following code at the bottom of the Spawn() method in dll/player.cpp:

//BEGIN ADD
// Disengage from hierarchy
SetParent( NULL );
SetMoveType( MOVETYPE_NOCLIP );
AddEFlags( EFL_NOCLIP_ACTIVE );
//END ADD

[edit] Offline Mode

http://www.hlfallout.net/forums/lofiversion/index.php/t11924.html

More


[edit] Sprites

[edit] GIMP to Sprite

Click here for a quick tutorial on making sprites with GIMP.

Click here for a more advanced tutorial on manipulating transparency with Valve Materials (for sprites and models)

[edit] Sprites Facing Direction

Jinx's Tutorial on Sprites

[edit] Sprite Origin

I've discovered that the sprite origin is in the middle of the material. So, if you have a 128x128 sprite, the origin will be at (64,64)

[edit] Sprite Scaling

I also discovered that a 128x128 sprite is pretty large using the default scale factor. I've found a scale factor of 0.01 much more useful.

[edit] Other Sprite Stuff

Sprite Tutorial

Transparent textures

[edit] Steam Stuff

An example of installing a Mod from checked out code (ARMAR Configuration)

Repairing a mod - mod won't show in steam

Source SDK Won't Start

  • It seems there is a new service pack for Valve..ep2...need to look into updating mine (ep1)

[edit] String Operations

[edit] Copy a string

 
        static char szBuf[64];
 
        float y = atof( szValue );
        if (y >= 0)
        {
            Q_snprintf( szBuf,sizeof(szBuf), "%f %f %f", GetLocalAngles()[0], y, GetLocalAngles()[2] );
        }
        else if ((int)y == -1)
        {
            Q_strncpy( szBuf, "-90 0 0", sizeof(szBuf) );
        }
        else
        {
            Q_strncpy( szBuf, "90 0 0", sizeof(szBuf) );
        }
 

[edit] Print to a string

 
        char tempstr[255];
        Q_snprintf(tempstr,sizeof(tempstr),"Dir: %i (%i)",m_nDirCurrent,m_nDirTarget);
 

[edit] Syntax Highlighting

Ultra Edit Syntax Highlighting

[edit] Third Party Tools

http://www.ammahls.com/?p=3

Cannonfodder's Model Decompiler

Had to open:

C:\Steam\steamapps\steamuserid\sourcesdk\launcher

And comment out Line 6 to:

	//ToolsAppId				211		// Tools will load this (ie: so

Also did the one at:

C:\Steam\steamapps\steamuserid\half-life 2\hl2

Will have to undo this later.

[edit] Third Person Chase View

[edit] How to enable

1. Before loading map type thirdperson on the console

2. Load the map

3. Use cam_idealyaw 0 to line up behind the player

[edit] Custom Third Person Chase Class

Excellent overhaul by SubKamran and others

  • Ensure you check out the discussion tab

[edit] Troubleshooting

http://www.steamfriends.com/forums/showthread.php?p=5024

[edit] HLMV Crash

I had a problem with HLMV.exe crashing as it started.

Trying this. (sensitive to monitor resolution?)

YES! Set the monitor from 800x600 back to 1024x768 and badabing!

[edit] Tutorials

[edit] My Tutorials

Motion Blur

PlayerSlavedEntity

  • A simple model entity that is slaved or attached to the player. All you do is add it to a map and specify the model file and attachment transform.

Tutorial/Drill on Valve Transformations

Tutorial on Making Transparent Materials with GIMP

Custom VGUI Panel

[edit] Other Tutorials

Pretty Big List of Tutorials

Tutorials at Interlopers -- mostly mapping stuff but good

[edit] VGUI

Models on VGUI Panel

My VGUI Page

Custom VGUI Tutorial

[edit] Views and View Angles

Thread about setting player orientation and view

My Page on Valve Source transforms

[edit] Windowed Mode

"c:\steam\steam.exe" -applaunch 215 -dev 	-dxlevel 90 -width 800 –height 600 -windowed -game "c:\steam\steamapps\SourceMods\Armar" -allowdebug %1 %2 %3 %4 %5 %6 %7 %8 %9

[edit] Errors and Troubleshooting

Working with Steam and valve Source involves dealing with all kinds of random errors and such that can occur whenever Steam pushes out an update.

[edit] Error:valve source platform error module failed to initialize

I had been using the MOD fine for an entire day. Came back the next day on got this error whenever I tried to load and Valve MOD or Game:

valve source platform error module failed to initialize

The error displayed in a popup dialog after the splash screen and before the front menu.

I found [valve source platform error module failed to initialize this] thread.

I ended up going into Steam->File->Settings->In Game and disabling Steam support in game. Restarted Steam and OK now.

[edit] Links and Resources

[edit] HLCODERS IRC

Join: http://www.gamesurge.net/


irc://irc.gamesurge.net/hlcoders

irc://irc.gamesurge.net/hlcoders

Me: shendoo

[edit] Forums

http://forums.steampowered.com/forums/forumdisplay.php?f=195

[edit] Mailing Lists

Valve's MOD Programming Mailing List

[edit] Steam Pages

My Steam page

Personal tools