Half-Life Re-imagined competition results on their way...
Check out Skewing textures in Hammer, our newest tutorial!
Say hello to neophus775, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Poll

Feeling Blue

What's your favourite shade of blue?

Azure

9

Cobalt

19

Turquoise

5

Cyan

8

Royal

3

Teal

3

Onliners

2 mins

Dr. Orange

12 mins

neophus775

29 mins

Kachito

33 mins

Solokiller

36 mins

fuzun

53 mins

Admer456

1 hours

Crollo

Affiliates

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

Creating a Vampire gamestyle

By [ICR]

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.