Having started making (well, trying to make) a mod for Half-Life with a few buddies, I have decided to put my notes on the source on Everything. (I may be the wrong person to do it (me sucking so much and all) but we need more of this kind of thing)

  • CGrenade
    • Location: weapons.h
    • Surprisingly enough, this is the grenade class. Derived from CBaseMonster.
    • The member functions for the explosion (Explosion(Vector &, Vector &), Explosion(TraceResult *, int), and void EXPORT Smoke()) are modular enough to transfer to other CBaseMonsters with minor modifications.
  • CHornet
    • Location: hornet.h
    • The homing insects from the grunts and the hornetgun. Another CBasemonster.
  • Vector
  • Vector2D
    • Similar to the 3d vector(and in the same file), but with only 2 axis. According to the comments, used for pathfinding, but not used very frequently

More classes coming soon...

While working on the mod, I decided that we would need to create custom commands. Unfamiliar with the actual source I had to explore and learn it for myself. This proved to be tought. A word of advice, leave the cl_dll alone until you are familiar with it, because you won't be able to easily add commands there.

The place to look for adding you commands would be in the mp.dll, in the client.cpp file to be more specific. To add you command go to the function ClientCommand()--the line that says "void ClientCommand( edict_t *pEntity )".
Scroll down to about line #384. After the "else if", but before the last "else" put in this code:

else if (FStrEq(pcmd, "mycommand")) { DO STUFF HERE }

My understanding isnt great but I assume that the FStrEq function compares a player's command (pcmd) with one of the came commands (the second parameter) and returns a TRUE if the two are the same. The bracketed stuff is how the command is gonna reacted when it is called.

This basically adds the code for the command, the next part is optional for if you want the user to be able to change the command's binding in the Half-Life's Controls section in the Configuration Menu.
In your mod directory add a folder called "gfx" (if you don't already have one"), in that folder add another called "shell," it is in this directory where you will place 2 files which will add the control to the game's control menu.

This write-up assumes that you have SDK version 2.0, is not, get it or your mod will not work with the newer version of HL. Now in the "SDK" folder, open the "shell" and find the files "kb_act.lst" and "kb_def.lst" and move them to the shell folder in your mod directory.
Open the "kb_act.lst" file, this basically defines the description that will be used to identify the command in the Controls menu. Go to the end, or beginning, of the file and add this line: "mycommand" "Description"

where mycommand is your command's name as it appears in the source code, and the Description is the very basic description of the command. Next open the "kb_def.lst" file, this sets the default bindings for the game's commands. At the beginning of the file add this line: "key" "command"

where key is the key you want the command to be bound to by defaul, and command is the command's name as it appears in the source code.

This is just a primitive summary of how to add a command, I will hopefully add more write-ups that deal with Half-Life's source code as I figure it out.

Log in or register to write something here or to contact authors.