VERC: Creating a Vampire gamestyle Last edited 2 years ago2022-09-29 07:54:24 UTC

]
The purpose of this tutorial is to show you how to create a whole new game type in 12 lines (the reason why this tutorial is fairly long is because it takes you through the logical route of creating the code). The game type? Vampire. The basic rules of Vampire are that when you kill someone, you receive their frags, thus creating a King of the Hill style of gameplay, but still encourages deathmatch/team deathmatch rather than chasing after one person.

You can use either SDK, with the singleplayer dlls or the multiplayer dlls, and all the changes we will be making are server side. I will be showing you how to add it to a deathmatch game, but it can easily be adapted for teamplay. You can also add and remove as much code as you like to tailor for your specific gameplay.

Open up the multiplayer_gamerules.cpp ; this is the only file we will be editing. Find line 631 (Ctrl+G) where it should say:
// if a player dies in a deathmatch game and the killer is a client, award the killer some points
pKiller->frags += IPointsForKill( peKiller, pVictim );
Now change the line pKiller->frags += IPointsForKill( peKiller, pVictim ); to the following code:
pKiller->frags += pVictim->pev->frags;
pVictim->pev->frags = 0;
This will add the number of frags pVictim has to pKiller's frag count. It then sets pVictim's frag count to 0. Now if you kill someone, you will receive their frags. However, the game can never actually start, as no-one has any frags to steal. There are two ways to sort this out, either start by giving everyone some frags, meaning that the game can still get stuck, or give pKiller the normal amount of frags if they kill someone with no frags:
if (pVictim->pev->frags == 0)
{
     pKiller->frags += IPointsForKill( peKiller, pVictim );
     pVictim->pev->frags = 0;
}
else
{
     pKiller->frags += pVictim->pev->frags;
     pVictim->pev->frags = 0;
}
However, if pVictim has killed himself, and has a negative amount of frags, then pKiller 's frags would go down. To stop this we do our final change in code:
if (pVictim->pev->frags > 0)
{
     pKiller->frags += pVictim->pev->frags;
     pVictim->pev->frags = 0;
}
else
{
     pKiller->frags += IPointsForKill( peKiller, pVictim );
     pVictim->pev->frags = 0;
}
If pVictim's frags are above 0, then it will add their frags, if not then it adds the normal amount of frags.

I hope this helps you understand a little about frags (although there isn't much to learn in this code) and that creating new gametypes isn't always that hard.
This article was originally published on Valve Editing Resource Collective (VERC).
The archived page is available here.
TWHL only publishes archived articles from defunct websites, or with permission. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

1 Comment

Commented 2 years ago2022-08-12 19:34:08 UTC Comment #104721
There where a vampire mod once before :)

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