2 questions


(sniser) #1

in g_team.c:

void Team_DroppedFlagThink(gentity_t *ent) {
	if( ent->item->giTag == PW_REDFLAG ) {
		G_Script_ScriptEvent( &g_entities[ent->s.otherEntityNum], "trigger", "returned" );
		Team_ReturnFlagSound( ent, TEAM_AXIS );
		Team_ResetFlag( ent );
		if( level.gameManager ) {
			G_Script_ScriptEvent( level.gameManager, "trigger", "axis_object_returned" );
		}
		trap_SendServerCommand(-1, "cp \"Axis have returned the objective!\" 2");
	} else if( ent->item->giTag == PW_BLUEFLAG ) {
		G_Script_ScriptEvent( &g_entities[ent->s.otherEntityNum], "trigger", "returned" );
		Team_ReturnFlagSound( ent, TEAM_ALLIES );
		Team_ResetFlag( ent );
		if( level.gameManager ) {
			G_Script_ScriptEvent( level.gameManager, "trigger", "allied_object_returned" );
		}
//		trap_SendServerCommand(-1, "cp \"Allies have returned the objective!\" 2");
	}
	// Reset Flag will delete this entity
}

Without having any clue of the inner workings of anything , it seems to me like the line near the end should NOT be comented out? Would putting that back in be considered a bugfix, not change anything or actually break things?

in g_stats.c:

void G_LogKill( gentity_t* ent, weapon_t weap ) {
	weap = BG_DuplicateWeapon(weap);
	if(!ent->client) {
		return;
	}
	// SNISERTODO
	if(ent->client->sess.playerType == PC_SOLDIER) {
		int i, j;
		qboolean pass = qtrue;
		ent->client->soliderKillTimes[ent->client->soldierKillMarker++] = level.timeCurrent;
		if ( ent->client->soldierKillMarker >= NUM_SOLDIERKILL_TIMES ) {
			ent->client->soldierKillMarker = 0;
		}
		for( i = 0, j = ent->client->soldierKillMarker; i < NUM_SOLDIERKILL_TIMES; i++ ) {
			if( !ent->client->soliderKillTimes[j] || (ent->client->soliderKillTimes[j] < level.timeCurrent - SOLDIERKILL_MAXTIME) ) {
				pass = qfalse;
				break;
			}
			if( ++j == NUM_SOLDIERKILL_TIMES ) {
				j = 0;
			}
		}
	}
	ent->client->pers.playerStats.weaponStats[weap].kills++;
	trap_PbStat ( ent - g_entities , "kill" , 
		va ( "%d %d %d" , ent->client->sess.sessionTeam , ent->client->sess.playerType , weap ) ) ;
}

Elsewhere NUM_SOLDIERKILL_TIMES is defined as 10, and SOLDIERKILL_MAXTIME as 60000.

Now this seems to be a leftover, as the variable pass isn’t actually used. So my question is, what exactly does it check for? Could someone less confused than me explain it in plain text?

(I’d like to change it so any class gets an battle sense XP bonus if they kill more than X enemies in Y seconds, but to do that I’d first have to understand this heh :D)


(Lanz) #2

First question:
The simple anwser is that line just above it: G_Script_ScriptEvent(…
The response is handled in the map script instead of being hardcoded to add some more flexibility.

Second:
It stores the ten last kill times and checks them against the timespan stored in SOLDIERKILL_MAXTIME but
the for-loop doesnt do squat and doesnt use the pass var later either, look for battlesense elsewhere.


(SCDS_reyalP) #3

except the the uncommented version is used for the other team. It seems like one has got to be wrong :moo:


(sniser) #4

I ended up commenting it out for axis too :smiley:

I just looked at it again, and I’d say pass gets set to false if any there are less than NUM_SOLDIERKILL_TIMES, or if any of those kills was not within SOLDIERKILL_MAXTIME. So yeah, it does what I assumed, I think. Unless you use that for anything, comment it out - it’s just a unecessary calculation done each time a soldier makes a kill. Think of all the saved processing power that could instead be used to find aliens or a cure for cancer…


(Chruker) #5

In regards to the second one.

I’ve commented out the entire soldier specific block and the soliderKillTimes, and soliderKillTimes fields in gclient_s


(digibob) #6

Was for a feature that got dropped, and just something we never got around to tidying up.