Tutorial: Separate Player and Monster Hivehand damages Last edited 4 years ago2020-04-11 14:59:55 UTC

You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date. Click here to see the current revision of this page.

Why?

Well, this could be used to give the Hivehand a bit more "punch" on both ends easily.

You could simply change a number in your skill.cfg and that would be it. No need to edit the code and build again and again.

This can be done because Valve hardcoded in the value of the player's hivehand damage, as they tried balancing it late in the development.

The Code

gamerules.cpp

Around line 276, you should find this something similar to this.
// PLAYER HORNET
// Up to this point, player hornet damage and monster hornet damage were both using
// monDmgHornet to determine how much damage to do. In tuning the hivehand, we now need
// to separate player damage and monster hivehand damage. Since it's so late in the project, we've
// added plrDmgHornet to the SKILLDATA struct, but not to the engine CVar list, so it's inaccesible
// via SKILLS.CFG. Any player hivehand tuning must take place in the code. (sjb)
gSkillData.plrDmgHornet = 7;
This means the player's hornet deals 7 points of damage.

NOTE: We will use sk_plr_hornet to represent player hornet damage in the code from now on.

Change the 7 to GetSkillCvar( "sk_plr_hornet" ). It should now look like this.
gSkillData.plrDmgHornet = GetSkillCvar("sk_plr_hornet");

game.cpp

Around line 855, you'll find this:
// Tripmine
CVAR_REGISTER ( &sk_plr_tripmine1 );// {"sk_plr_tripmine1","0"};
CVAR_REGISTER ( &sk_plr_tripmine2 );// {"sk_plr_tripmine2","0"};
CVAR_REGISTER ( &sk_plr_tripmine3 );// {"sk_plr_tripmine3","0"};

// WORLD WEAPONS
CVAR_REGISTER ( &sk_12mm_bullet1 );// {"sk_12mm_bullet1","0"};
CVAR_REGISTER ( &sk_12mm_bullet2 );// {"sk_12mm_bullet2","0"};
CVAR_REGISTER ( &sk_12mm_bullet3 );// {"sk_12mm_bullet3","0"};
Let's just slip in a little sk_plr_hornet reference there, shall we?
// Tripmine
CVAR_REGISTER ( &sk_plr_tripmine1 );// {"sk_plr_tripmine1","0"};
CVAR_REGISTER ( &sk_plr_tripmine2 );// {"sk_plr_tripmine2","0"};
CVAR_REGISTER ( &sk_plr_tripmine3 );// {"sk_plr_tripmine3","0"};

// HORNET PLAYER
CVAR_REGISTER( &sk_plr_hornet1 );// {"sk_plr_hornet1","0"};
CVAR_REGISTER( &sk_plr_hornet2 );// {"sk_plr_hornet2","0"};
CVAR_REGISTER( &sk_plr_hornet3 );// {"sk_plr_hornet3","0"};

// WORLD WEAPONS
CVAR_REGISTER ( &sk_12mm_bullet1 );// {"sk_12mm_bullet1","0"};
CVAR_REGISTER ( &sk_12mm_bullet2 );// {"sk_12mm_bullet2","0"};
CVAR_REGISTER ( &sk_12mm_bullet3 );// {"sk_12mm_bullet3","0"};
What we've done is just let the server part of the game know that there is a cvar (console variable) which can be used, and there are 3 of them.
See if you can spot them.

Lastly, in the same file around line 370
// Tripmine
cvar_t sk_plr_tripmine1 = {"sk_plr_tripmine1","0"};
cvar_t sk_plr_tripmine2 = {"sk_plr_tripmine2","0"};
cvar_t sk_plr_tripmine3 = {"sk_plr_tripmine3","0"};
Following standard insertion procedure, add these lines below the given code:
// Player Hornet
cvar_t sk_plr_hornet1 = { "sk_plr_hornet1","0" };
cvar_t sk_plr_hornet2 = { "sk_plr_hornet2","0" };
cvar_t sk_plr_hornet3 = { "sk_plr_hornet3","0" };
Now compile.

Make sure the compiled binaries are in your mod's folder.

Finally, before you play

Add these lines to your mod's skill.cfg
// Player Hornet
sk_plr_hornet1 "7"
sk_plr_hornet2 "7"
sk_plr_hornet3 "7"
Now, 7 was the hardcoded value, but this one can be anything you want. Just, if you're making a mod others will play, make it balanced. Or not.

Have some fun.

Comments

You must log in to post a comment. You can login or register a new account.