First blood message


(*Shadow* Commando) #1

Hi,

Does anyone know how to show a first blood message to the players like on fortymod
or et_admin mod. A popupmessage at the side of your screen.
There is something with first blood in the code, but that’s for Capture the Flag.
Could anyone help me with this…

Greetz


(SCDS_reyalP) #2

when a player is killed, check if they are the first one… How hard is that :???:


(Downright) #3

Didn’t there used to be a time when people were polite?

IE: Oh that is in this section of the code->

Instead of answers like “how hard is that,” “don’t be an idiot,” and “RTFM.” I truly miss those days.

Anyways, after a bit of looking one night, being some of the ET code isn’t the easiest to follow, because of the sheer size of it, I find where and what you need to do for First Blood. I will look for it when I get home from work and post it up here within the next few days.

In the meantime keep plugging along.


(*Shadow* Commando) #4

Thanks downright, that would be awesome.
Because I really had now idea where to look. And what to do.


(SCDS_reyalP) #5

Umm, if you can’t find where people die, you are not going to be able to make a mod. If you try to make a mod by just getting people to post random snippets of code, you will very soon find yourself in a buggy mess that you can’t code your way out of.

When I want to find something in the code, I first think about whether it would be in the client (cgame) or server (game). Something like this, you obviously want to do on the server, since it already tracks kills and stats and such, and you want to send the message to all players.

Then, if I don’t already have an idea where to look, I either look for files with a name that seems related to what I want (g_combat.c looks like a place where people might die. g_stats.c also might be somewhere in the process) or search all the .c files for some likely word.

Once I have found an area related to what I’m interested in, I read the code to find the best place for the feature.

This process obviously takes more time and effort than just having someone tell you what to do. However, it has the huge advantage of significantly deepening your understanding of the code every time you add a feature. Pretty soon, you will know where to look right away.

As for making a ‘first blood’ message, the simple way to do it would be to have a global variable set to some value when game gets initialized (look in g_main.c) and check every time a player dies. If the variable is at its initial value, print the ‘first blood’ message, and set the variable to some other value. There are a few more details of course, such as making sure the first death was from another player, and dealing with warmup. Again, if you can’t come up with that kind of stuff yourself, maybe you shouldn’t be trying to make a mod.

I’m not trying to be rude. I’m just pointing out that if you aren’t willing to invest the effort in actually learning, no amount of hand holding will allow you to make a working mod.

There are also some websites that can help you get a general understanding of the code. http://www.planetquake.com/code3arena/ is a good place to start (it is for q3, but the code is organised in the same way, and the major functions all do pretty much the same thing)
A few more links can be found in this thread:
http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=8198&


(Jaquboss) #6

That´s a BIG truth , you must first know something about C , but I don´t know if you can learm it on ET sources (I think you can , because ET is my first C experience , and I am doing it now much better , I can remmember begginings , lol)


(*Shadow* Commando) #7

For anyone intrested in the code for it, here it is:

In g_local.h add:

int			firstblood;

Above:

int			firstbloodTeam;

Then in g_stats.c in g_LogKill:
After:

if(!ent->client) {
		return;
	}

Add:

if( g_firstblood.integer && !(g_gamestate.integer == GS_WARMUP) && !(g_gamestate.integer == GS_WARMUP_COUNTDOWN)){
		level.firstblood++;
		
		if( level.firstblood == 1 ) {
			AP(va(" cpm\"%s ^1drew first blood!
\"", ent->client->pers.netname));
		}
	}