Enter Half-Life Re-imagined, our current competition!
Check out Skewing textures in Hammer, our newest tutorial!
Say hello to EsBe, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Poll

Feeling Blue

What's your favourite shade of blue?

Azure

6

Cobalt

9

Turquoise

1

Cyan

4

Royal

3

Teal

1

Onliners

4 mins

Solokiller

5 mins

TJB

13 mins

Admer456

15 mins

Victor-933

18 mins

SpannerSpammer

21 mins

Jessie

60 mins

Kurosaki Ichigo

Affiliates

A gaming and technology blog by TWHL admins Penguinboy and Ant. A music blog by TWHL users Ant and Hugh.

Adding New skill.cfg Entries

By Caleb 'Ghoul' Delnay

The skill.cfg file is a configuration file which is executed whenever a map is loaded. It executes all the commands to set up monster health, damage, and speed settings for each difficulty level. The only thing the file actually does is just set a bunch of cvars to have a value, because thats all the skill settings are, cvars.

Ok, now, lets add a set of 3 entries for some monster's health. This should be very simple. :)

First, open up skill.h. This file holds all the entries for the skilldata_t struct, used for gSkillData. You'll notice a bunch of float variables declared here. These are the variables which are assigned a value equal to that of a corresponding cvar, and used in setting up a monster's health (or whatever other property).

So, lets enter in our own variable for "some monster." Somewhere in the file, say, after the scientistHealth variable is declared, add:

float somemonsterHealth;

There, now we have our variable, next we need to actually give the variable the value of the cvar that corresponds to it. Open up gamerules.cpp and find the RefreshSkillData function. In there you'll see all the variables from skill.h being given values. So, somewhere in the jumble of code, add in:

// Some Monster
gSkillData.somemonsterHealth = GetSkillCvar( "sk_somemonster_health");

This is giving our somemonsterHealth variable the value of the cvar sk_somemonster_health. The GetSkillCvar function returns a different value depending on the difficulty level of the game. So, now we need to make the cvar our entry is trying to use.

Open up game.cpp. You should see a bunch of cvar_ts declared. Scroll down a while until you find the scientist entry. Below that, let's add in our three cvars.

// Scientist
cvar_t     sk_somemonster_health1 = {"sk_somemonster_health1","0"};
cvar_t     sk_somemonster_health2 = {"sk_somemonster_health2","0"};
cvar_t     sk_somemonster_health3 = {"sk_somemonster_health3","0"};

Now, time to explain the way this works. Each cvar used for a skill.h entry actually has 3 different cvars, one for each skill. A 1 at the end of the cvar name means it's for easy difficulty, 2 for medium, 3 for hard. The GetSkillCvar function compares the end number to the current difficulty, and returns the value of the proper cvar so that the corresponding skill.h entry is given the right value. You'll notice all there are set to 0. This is the actual purpose of the skill.cfg, it sets up all the values for the cvars.

We still aren't done, however. Scroll down more until you reach some CVAR_REGISTER functions. We have to add our own in here somewhere now so the engine recognizes them as cvars. So...

// Some Monster
CVAR_REGISTER ( &sk_somemonster_health1 );
CVAR_REGISTER ( &sk_somemonster_health2 );
CVAR_REGISTER ( &sk_somemonster_health3 );

There, now our cvars are registered with the engine. Only one more thing left for programming. If you ever want to use the skill.h entry we just created, you need to:

Make sure you have skill.h included in whichever .cpp file you'll be using gSkillData in.

#include "skill.h"

Then, somewhere in the code.

pev->health = gSkillData.somemonsterHealth;

There, now the value of pev->health will be set to our new entry. Usually a snippet of code like that will be in a monster's Spawn function.

Finally, open up your skill.cfg (if you don't have one in your mod directory, copy it from the valve directory). Somewhere in the file throw in:

sk_somemonster_health1 "50"
sk_somemonster_health2 "50"
sk_somemonster_health3 "60"

Of course you can use your own values, rather than 50 and 60. I hope you've learned something new today. :) Now, then, get out there and add those skill entries!