This article was recovered from an archive and needs to be reviewed
- The formatting may be incorrect as it was automatically converted to WikiCode from HTML, it needs to be revised and reformatted
- Some information may be out of date as it was written before Half-Life was available on Steam
- After the article is re-formatted and updated for Steam HL, remove this notice
- Please do not remove the archive notice from the bottom of the article.
- Some archive articles are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
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 MonstergSkillData.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_t s declared. Scroll down a while until you find the scientist entry. Below that, let's add in our three cvars.
// Scientistcvar_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 MonsterCVAR_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!
This article was originally published on the
Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the
TWHL Archiving Project page.