Ejemplo n.º 1
0
int V_VoteDone ()
{
	int players = total_players();

	if (players < 1)
		return 0;

	if (numVotes >= 0.75*players)
		return CHANGE_NOW;

	if (numVotes > 0.5*players)
		return CHANGE_LATER;

	return 0;
}
Ejemplo n.º 2
0
void dom_awardpoints (void)
{
	int		i, points, credits;
	edict_t	*cl_ent;

	// flag has not been captured
	if (!DEFENSE_TEAM)
		return;
	FLAG_FRAMES++; // record frames flag has been captured
//	if (!(FLAG_FRAMES % 10))
//		gi.dprintf("frames %d\n", FLAG_FRAMES);

	if (level.framenum % DOMINATION_AWARD_FRAMES)
		return;
	// not enough players
	if (total_players() < DOMINATION_MINIMUM_PLAYERS)
		return;

	for (i=0 ; i<game.maxclients ; i++) {
		cl_ent = g_edicts+1+i;
		//if (G_EntIsAlive(cl_ent) && (cl_ent->teamnum == DEFENSE_TEAM))
		if (cl_ent && cl_ent->inuse && cl_ent->client && (cl_ent->health>0) 
			&& !G_IsSpectator(cl_ent) && (cl_ent->teamnum==DEFENSE_TEAM))
		{
			points = DOMINATION_POINTS;
			credits = DOMINATION_CREDITS;
			// flag carrier gets extra points
			if (cl_ent->client->pers.inventory[flag_index])
			{
				points *= 3;
				credits *= 3;
			}
			/*
			cl_ent->myskills.experience += points;
			cl_ent->client->resp.score += points;
			check_for_levelup(cl_ent);
			*/
			cl_ent->myskills.credits += credits;
			V_AddFinalExp(cl_ent, points);
		}
	}
}
Ejemplo n.º 3
0
int V_AttemptModeChange(qboolean endlevel)
{
#ifdef OLD_VOTE_SYSTEM // Paril
	int pvp, pvm, dom, ctf, ffa, inv, players, total_votes;
	
	players = total_players();

	if (players < 1)
		return 0; // not enough players

	// count the votes for each mode
	pvp = CountTotalModeVotes(MAPMODE_PVP);
	pvm = CountTotalModeVotes(MAPMODE_PVM);
	dom = CountTotalModeVotes(MAPMODE_DOM);
	ctf = CountTotalModeVotes(MAPMODE_CTF);
	ffa = CountTotalModeVotes(MAPMODE_FFA);
	inv = CountTotalModeVotes(MAPMODE_INV);

	total_votes = pvp + pvm + dom + ctf + ffa + inv;

	//gi.dprintf("total_votes=%d\n", total_votes);
	//gi.dprintf("%d,%d,%d,%d,%d\n", pvp,pvm,dom,ctf,ffa);

	if (total_votes < 0.33*players)
		return 0; // need at least 1/3rd of server to change mode

	// change mode immediately if the majority
	// of players are voting
	if (!endlevel && (total_votes < 0.8*players))
		return 0;

	if (pvp && (pvp>pvm) && (pvp>dom) && (pvp>ctf) && (pvp>ffa) && (pvp>inv))
		return MAPMODE_PVP;
	else if (pvm && (pvm>pvp) && (pvm>dom) && (pvm>ctf) && (pvm>ffa) && (pvm>inv))
		return MAPMODE_PVM;
	else if (dom && (dom>pvp) && (dom>pvm) && (dom>ctf) && (dom>ffa) && (dom>inv))
		return MAPMODE_DOM;
	else if (ctf && (ctf>pvp) && (ctf>pvm) && (ctf>dom) && (ctf>ffa) && (ctf>inv))
		return MAPMODE_CTF;
	else if (ffa && (ffa>pvp) && (ffa>pvm) && (ffa>dom) && (ffa>ctf) && (ffa>inv))
		return MAPMODE_FFA;
	else if (inv && (inv>pvp) && (inv>pvm) && (inv>dom) && (inv>ctf) && (inv>ffa))
		return MAPMODE_INV;

	return 0;
#else
	int max_players, players = total_players();

	//4.4 forcibly switch to PvP if we are in Invasion/PvM and there are many players
	max_players = 0.25 * maxclients->value;
	if (max_players < 4)
		max_players = 4;
	if (players >= max_players && (pvm->value || invasion->value) 
		&& (currentVote.mode == MAPMODE_PVM || currentVote.mode == MAPMODE_INV))
	{
		gi.bprintf(PRINT_HIGH, "Forcing switch to FFA because there are too many players!\n");
		return MAPMODE_FFA;
	}

	// did the vote pass?
	if (V_VoteDone())
		return currentVote.mode;

	// vote failed
	return 0;
#endif
}
Ejemplo n.º 4
0
void INV_SpawnMonsters (edict_t *self)
{
	int		players, max_monsters;
	edict_t *e=NULL;

	PVM_TotalMonsters(self, true);

	players = max_monsters = total_players();

	// there are still monsters alive
	if ((self->num_monsters_real > 0) && (self->count == MONSTERSPAWN_STATUS_IDLE))
	{
		// if there's nobody playing, remove all monsters
		if (players < 1)
		{
			PVM_RemoveAllMonsters(self);
			return; // don't spawn any monsters.
		}
		if (level.intermissiontime)
		{
			if (self->num_monsters_real)
				PVM_RemoveAllMonsters(self);
			return;
		}
		if (invasion_data.limitframe > level.time) // we still got time?
		{
			self->nextthink = level.time + FRAMETIME;
			return;
		}else
		{
			gi.bprintf(PRINT_HIGH, "Time's up!\n");
			if (invasion_data.boss && invasion_data.boss->deadflag != DEAD_DEAD) // out of time for the boss.
			{	
				G_PrintGreenText(va("You failed to eliminate the commander soon enough!\n"));
				gi.WriteByte (svc_temp_entity);
				gi.WriteByte (TE_BOSSTPORT);
				gi.WritePosition (invasion_data.boss->s.origin);
				gi.multicast (invasion_data.boss->s.origin, MULTICAST_PVS);
				gi.unlinkentity(invasion_data.boss);
				G_FreeEdict(invasion_data.boss);
				invasion_data.boss = NULL;
			}
			// increase the difficulty level for the next wave
			if (invasion->value == 1)
				invasion_difficulty_level += 1; 
			else
				invasion_difficulty_level += 2; // Hard mode.
			invasion_data.printedmessage = 0;
			gi.sound(&g_edicts[0], CHAN_VOICE, gi.soundindex("misc/tele_up.wav"), 1, ATTN_NONE, 0);
		}
	}else // Timeout has happened or all monsters eliminated
	{
		self->count = MONSTERSPAWN_STATUS_WORKING;
		invasion_data.mspawned = self->num_monsters_real;
	}

	if (players < 1)
	{
		// if there's nobody playing, then wait until some join
		self->nextthink = level.time + FRAMETIME;
		return;
	}

	switch (invasion_difficulty_level)
	{
	case 1: max_monsters = 10; break;
	case 2: max_monsters = 20; break;
	case 3: max_monsters = 25; break;
	case 4: max_monsters = 30; break;
	case 5:
	case 6:
	case 7:
	case 8:
	case 9:
	case 10:
		max_monsters = 35; break; // vrxcl 3.2b decrease for not saturating the server hard.

	default: max_monsters = 40;
	}

	if (!(invasion_difficulty_level % 5))
	{
		if (invasion->value == 1)
			max_monsters = 4*(ActivePlayers()-1);
		else if (invasion->value == 2)
			max_monsters = 6*(ActivePlayers()-1);
	}

	if (!invasion_data.printedmessage)
	{
		invasion_data.limitframe = level.time + TimeFormula();
		if (invasion_difficulty_level == 1)
		{
			if (invasion->value == 1)
				gi.bprintf(PRINT_HIGH, "The invasion begins!\n");
			else
				gi.bprintf(PRINT_HIGH, "The invasion... begins.\n");
		}
		if (invasion_difficulty_level % 5)
			gi.bprintf(PRINT_HIGH, "Welcome to level %d. %d monsters incoming!\n", invasion_difficulty_level, max_monsters);
		else
			gi.bprintf(PRINT_HIGH, "Welcome to level %d.\n", invasion_difficulty_level, max_monsters);
		G_PrintGreenText(va("Timelimit: %dm %ds.\n", (int)TimeFormula() / 60, (int)TimeFormula() % 60));

		gi.sound(&g_edicts[0], CHAN_VOICE, gi.soundindex("misc/talk1.wav"), 1, ATTN_NONE, 0);

		BossCheck(e, self);

		invasion_data.printedmessage = 1;
	}
	
	while ( ((e = INV_GetMonsterSpawn(e)) != NULL) && invasion_data.mspawned < max_monsters)
	{
		int randomval = GetRandom(1, 9);

		if (invasion_difficulty_level % 5 && invasion->value == 1) // nonboss stage? easy mode?
		{
			while ( randomval == 5 ) // disallow medics
			{
				randomval = GetRandom(1, 8);
			}
		}

		if (!INV_SpawnDrone(self, e, randomval))
			continue;
		else
			invasion_data.mspawned++;
	}

	if (invasion_data.mspawned == max_monsters)
	{
		// increase the difficulty level for the next wave
		invasion_difficulty_level += 1;
		invasion_data.printedmessage = 0;
		invasion_data.mspawned = 0;
		self->count = MONSTERSPAWN_STATUS_IDLE;
	}

	self->nextthink = level.time + FRAMETIME;
}
Ejemplo n.º 5
0
void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer) 
{ 

     char entry[MAX_ENTRY_SIZE]; 
     char string[MAX_STRING_SIZE];
	 char name[20], classname[20];//3.78
     int stringlength; 
     int i, j, k; 
     int sorted[MAX_CLIENTS];
     int sortedscores[MAX_CLIENTS]; 
     int score, total, highscore=0; 
     int y;
	 //float accuracy;
	 int time_left=999, frag_left=999;
     gclient_t *cl; 
     edict_t *cl_ent; 

	 // if we are looking at the scoreboard or inventory, deactivate the scanner
	 if (ent->client->showscores || ent->client->showinventory)
	 {
		if (ent->client->pers.scanner_active)
			ent->client->pers.scanner_active = 2;
	 }
	 else
	 {
		 *string = 0;

		 // Scanner active ?
		if (ent->client->pers.scanner_active & 1)
			ShowScanner(ent,string);

		// normal quake code ...	
		gi.WriteByte (svc_layout);
		gi.WriteString (string);
		return;
	 }
	
     // sort the clients by score 
     total = 0; 
     for (i=0 ; i<game.maxclients ; i++)
	{
		cl_ent = g_edicts + 1 + i;

        //3.0 scoreboard code fix
		if (!cl_ent->client || !cl_ent->inuse || cl_ent->client->resp.spectator)
			continue;

		score = game.clients[i].resp.score;
		for (j=0 ; j<total ; j++)
		{
			if (score > sortedscores[j])
				break;
		}
		for (k=total ; k>j ; k--)
		{
			sorted[k] = sorted[k-1];
			sortedscores[k] = sortedscores[k-1];
		}
		sorted[j] = i;
		sortedscores[j] = score;
		total++;
	}
	// print level name and exit rules
	string[0] = 0;
	stringlength = strlen(string);

     // make a header for the data 
	//K03 Begin
	if (timelimit->value)
		time_left = (timelimit->value*60 - level.time);
	else
		time_left = 60*99;
	if (fraglimit->value)
		frag_left = (fraglimit->value - V_HighestFragScore());

	if (time_left < 0)
		time_left = 0;

	Com_sprintf(entry, sizeof(entry), 
		"xv 0 yv 16 string2 \"Time:%2im %2is Frags:%3i Players:%3i\" "
		"xv 0 yv 24 string2 \"Name       Lv Cl Score Frg Spr Png\" ",
		(int)(time_left/60), (int)(time_left-(int)((time_left/60)*60)),
		frag_left, total_players()); 

	 //K03 End
     j = strlen(entry); 

	 //gi.dprintf("header string length=%d\n", j);

     if (stringlength + j < MAX_ENTRY_SIZE) 
     { 
          strcpy (string + stringlength, entry); 
          stringlength += j; 
     } 

     // add the clients in sorted order 
     if (total > 24) 
          total = 24; 
     /* The screen is only so big :( */ 
	 
     for (i=0 ; i<total ; i++)
	 {
          cl = &game.clients[sorted[i]]; 
          cl_ent = g_edicts + 1 + sorted[i];

		  if (!cl_ent)
			  continue; 

          y = 34 + 8 * i; 
		
		// 3.78 truncate client's name and class string
		strcpy(name, V_TruncateString(cl->pers.netname, 11));
		strcpy(classname, V_TruncateString(GetClassString(cl_ent->myskills.class_num), 3));
		padRight(name, 10);

		Com_sprintf(entry, sizeof(entry),
			"xv 0 yv %i string \"%s %2i %s %5i %3i %3i %3i\" ",
			y, name, cl_ent->myskills.level, classname, cl->resp.score, 
			cl->resp.frags, cl_ent->myskills.streak, cl->ping); 

		j = strlen(entry);

		//gi.dprintf("player string length=%d\n", j);

		if (stringlength + j > MAX_ENTRY_SIZE)
			break; 

		strcpy (string + stringlength, entry); 
		stringlength += j; 
     } 

     gi.WriteByte (svc_layout); 
     gi.WriteString (string); 

}