Double kill messages


(*Shadow* Commando) #1

This was one of the first things I wanted to add to my mod. But never looked at it.
I took a look this week and this is the code for double kill messages. Am not sure if
it works completely, cause I haven’t tested it yet.

In g_combat.c above the player_die function:

//Double kill messages
static void G_DoubleKill(gentity_t *ent) {
	char	*message;

	//If not a client, stop here
	if(!ent || !ent->client) {
		return;
	}

	//If not enabled, stop here
	if(!g_doublekill.integer) {
		return;
	}

	message = "";

	/*
	* If the lastkill wasn't made 1 second earlier set
	* client->doublekill to 0 and set the lastkilTime to
	* the level.time and stop here. If the lastkill WAS
	* 1 second earlier then add 1 to client->doublekill and
	* also set the lastkillTime to level.time
	*/
	if((level.time - ent->client->lastKillTime) > 1000) {
		ent->client->doublekill = 0;
		ent->client->lastKillTime = level.time;
		return;
	} else {
		ent->client->doublekill++;
		ent->client->lastKillTime = level.time;
	}

	//If we come here then print the message
	switch(ent->client->doublekill) {
	case 1:
		message = "Double kill!";
		break;
	case 2:
		message = "Triple kill!";
		break;
	case 3:
		message = "Quad kill!";
		break;
	case 4:
		message = "Multi kill!";
		break;
	case 5:
		message = "Ultra kill!";
		break;
	case 6:
		message = "Jackpot!";
		break;
	}

	if( ent->client->doublekill >= 1 && 
		ent->client->doublekill <= 6 ) {
			CP(va(" cpm\"^1%s\"", message ));
	}

}

In the player_die function, replace the:

attacker->client->lastKillTime = level.time;

With:

G_DoubleKill( attacker );

And finally in g_local.h:
Above:

qboolean	hasaward;
int		doublekill;

If you use this code, please let me know if it works.
And already - A Happy Newyear!


(*Shadow* Commando) #2

I have tested it now and it works gr8.
I hope I helped some out