Post by Ambershee on Nov 16, 2003 12:59:56 GMT -5
Hey all, for those who are interested and have a little QuakeC know how, here's a quick excercise to do. First one to do it gets a cookie!
First open up g_local.c and where it says 'int timeResidual' add an int declaration. This can be anything but make it sensible. This will hold your kill counts.
Then in player_die() in g_combat.c clear the target's kill count and increment the attacker's killcount.
Now still in g_combat.c and still in player_die() you need to count up the number of kills the attacker has got and print out the appropriate message. I use a switch statement and something like this:
switch(attacker->client->killcount)
{
case 5: message = "is on a Killing Spree!\n";
trap_SendServerCommand( -1, va("cp \"%s ^7%s\"", killerName, message));
trap_SendServerCommand( -1, va("print \"%s ^7%s\"", killerName, message));
break;
case 10: blah blah,etc
break;
case 15:
etc.
}
I am just doing the first one and I also play a sound to the attacker at this point.The first one is a Killing Spree, then it's whatever you like. But you don't have to follow this pattern, of course!
Now compiling and testing this will cause something unexpected to happen in game.
I'll let you try this out and tell me what's wrong!
It's the suicide problem! When you kill yourself you're the attacker
And also when you fall off the map 5 times or more the world gets the credit! So you need checks to stop this from happening. Also a message needs to be displayed if someone stops a killing spree so this needs to be done as well.
To stop the world or yourself from getting the credit you need to check when incrementing the killcount.
if(attacker!=self)
if(! OnSameTeam (self, attacker))
if(killer!=ENTITYNUM_WORLD)
attacker->client->killcount++;
To display a message when a killing spree has stopped
if(self->client->killcount>5)
{
if(self==attacker)
{
message="was doing well until\nsuicidal tendencies took over!\n";
trap_SendServerCommand( -1, va("cp \"%s ^7%s\"", targetName, message));
message="was doing well until suicidal tendencies took over!\n";
trap_SendServerCommand( -1, va("print \"%s ^7%s\"", targetName, message));
}
else if(killer==ENTITYNUM_WORLD)
{
message="'s killing spree was ended\nby falling into the wrong place";
trap_SendServerCommand( -1, va("cp \"%s^7%s\"", targetName, message));
message="'s killing spree was ended by falling into the wrong place";
trap_SendServerCommand( -1, va("print \"%s^7%s\n\"", targetName, message));
}
}
else
{
message="'s killing spree \nwas ended by";
trap_SendServerCommand( -1, va("cp \"%s^7%s %s\"", targetName, message, killerName));
message="'s killing spree was ended by";
trap_SendServerCommand( -1, va("print \"%s^7%s %s\n\"", targetName, message, killerName));
}
}
Put the code for clearing the target's killcount after these lines otherwise it won't work.
Once you've managed to do all that correctly, you should have a nice modifiable code.
It's not much as a tutorial, but it should be a great learning excercise.
The Ambershee
First open up g_local.c and where it says 'int timeResidual' add an int declaration. This can be anything but make it sensible. This will hold your kill counts.
Then in player_die() in g_combat.c clear the target's kill count and increment the attacker's killcount.
Now still in g_combat.c and still in player_die() you need to count up the number of kills the attacker has got and print out the appropriate message. I use a switch statement and something like this:
switch(attacker->client->killcount)
{
case 5: message = "is on a Killing Spree!\n";
trap_SendServerCommand( -1, va("cp \"%s ^7%s\"", killerName, message));
trap_SendServerCommand( -1, va("print \"%s ^7%s\"", killerName, message));
break;
case 10: blah blah,etc
break;
case 15:
etc.
}
I am just doing the first one and I also play a sound to the attacker at this point.The first one is a Killing Spree, then it's whatever you like. But you don't have to follow this pattern, of course!
Now compiling and testing this will cause something unexpected to happen in game.
I'll let you try this out and tell me what's wrong!
It's the suicide problem! When you kill yourself you're the attacker
And also when you fall off the map 5 times or more the world gets the credit! So you need checks to stop this from happening. Also a message needs to be displayed if someone stops a killing spree so this needs to be done as well.
To stop the world or yourself from getting the credit you need to check when incrementing the killcount.
if(attacker!=self)
if(! OnSameTeam (self, attacker))
if(killer!=ENTITYNUM_WORLD)
attacker->client->killcount++;
To display a message when a killing spree has stopped
if(self->client->killcount>5)
{
if(self==attacker)
{
message="was doing well until\nsuicidal tendencies took over!\n";
trap_SendServerCommand( -1, va("cp \"%s ^7%s\"", targetName, message));
message="was doing well until suicidal tendencies took over!\n";
trap_SendServerCommand( -1, va("print \"%s ^7%s\"", targetName, message));
}
else if(killer==ENTITYNUM_WORLD)
{
message="'s killing spree was ended\nby falling into the wrong place";
trap_SendServerCommand( -1, va("cp \"%s^7%s\"", targetName, message));
message="'s killing spree was ended by falling into the wrong place";
trap_SendServerCommand( -1, va("print \"%s^7%s\n\"", targetName, message));
}
}
else
{
message="'s killing spree \nwas ended by";
trap_SendServerCommand( -1, va("cp \"%s^7%s %s\"", targetName, message, killerName));
message="'s killing spree was ended by";
trap_SendServerCommand( -1, va("print \"%s^7%s %s\n\"", targetName, message, killerName));
}
}
Put the code for clearing the target's killcount after these lines otherwise it won't work.
Once you've managed to do all that correctly, you should have a nice modifiable code.
It's not much as a tutorial, but it should be a great learning excercise.
The Ambershee