reaction/code/game/g_arenas.c

352 lines
9.5 KiB
C
Raw Normal View History

//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
2001-12-31 16:28:42 +00:00
// $Log$
2003-03-22 20:29:26 +00:00
// Revision 1.10 2003/03/22 20:29:26 jbravo
// wrapping linkent and unlinkent calls
//
// Revision 1.9 2002/09/24 05:06:16 blaze
// fixed spectating so ref\'s can now use all the chasecam modes.
//
// Revision 1.8 2002/06/16 20:06:14 jbravo
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
//
// Revision 1.7 2002/06/16 17:38:00 jbravo
// Removed the MISSIONPACK ifdefs and missionpack only code.
//
// Revision 1.6 2002/01/11 19:48:30 jbravo
// Formatted the source in non DOS format.
//
2001-12-31 16:28:42 +00:00
// Revision 1.5 2001/12/31 16:28:42 jbravo
// I made a Booboo with the Log tag.
//
//
//-----------------------------------------------------------------------------
2001-05-06 20:50:27 +00:00
// Copyright (C) 1999-2000 Id Software, Inc.
//
//
// g_arenas.c
//
#include "g_local.h"
gentity_t *podium1;
gentity_t *podium2;
gentity_t *podium3;
2001-05-06 20:50:27 +00:00
/*
==================
UpdateTournamentInfo
==================
*/
void UpdateTournamentInfo(void)
{
int i;
gentity_t *player;
2012-10-13 18:11:42 +00:00
// int playerClientNum;
2012-03-17 14:56:06 +00:00
//int n, accuracy, perfect, msglen;
int n, msglen;
char buf[32];
char msg[MAX_STRING_CHARS];
2001-05-06 20:50:27 +00:00
// find the real player
player = NULL;
for (i = 0; i < level.maxclients; i++) {
//Blaze: Print out some debug info
if (&g_entities[i] == NULL) G_Printf("Ln 0052\n");
2001-05-06 20:50:27 +00:00
player = &g_entities[i];
if (!player->inuse) {
2001-05-06 20:50:27 +00:00
continue;
}
if (!(player->r.svFlags & SVF_BOT)) {
2001-05-06 20:50:27 +00:00
break;
}
}
// this should never happen!
if (!player || i == level.maxclients) {
2001-05-06 20:50:27 +00:00
return;
}
2012-10-13 18:11:42 +00:00
// playerClientNum = i;
2001-05-06 20:50:27 +00:00
CalculateRanks();
2012-03-17 14:56:06 +00:00
/* if (level.clients[playerClientNum].sess.sessionTeam == TEAM_SPECTATOR) {
Com_sprintf(msg, sizeof(msg), "postgame %i %i 0 0 0 0 0 0", level.numNonSpectatorClients,
playerClientNum);
} else {
if (player->client->accuracy_shots) {
2001-05-06 20:50:27 +00:00
accuracy = player->client->accuracy_hits * 100 / player->client->accuracy_shots;
} else {
2001-05-06 20:50:27 +00:00
accuracy = 0;
}
perfect = (level.clients[playerClientNum].ps.persistant[PERS_RANK] == 0
&& player->client->ps.persistant[PERS_KILLED] == 0) ? 1 : 0;
2001-06-11 06:12:32 +00:00
//Blaze: Removed because it uses the persistant stats stuff
2012-03-17 14:56:06 +00:00
Com_sprintf( msg, sizeof(msg), "postgame %i %i %i %i %i %i %i %i", level.numNonSpectatorClients, playerClientNum, accuracy,
2001-05-06 20:50:27 +00:00
player->client->ps.persistant[PERS_IMPRESSIVE_COUNT], player->client->ps.persistant[PERS_EXCELLENT_COUNT],
player->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT], player->client->ps.persistant[PERS_SCORE],
2012-03-17 14:56:06 +00:00
perfect );
} */
2001-05-06 20:50:27 +00:00
msglen = strlen(msg);
for (i = 0; i < level.numNonSpectatorClients; i++) {
2001-05-06 20:50:27 +00:00
n = level.sortedClients[i];
Com_sprintf(buf, sizeof(buf), " %i %i %i", n, level.clients[n].ps.persistant[PERS_RANK],
level.clients[n].ps.persistant[PERS_SCORE]);
msglen += strlen(buf);
if (msglen >= sizeof(msg)) {
2001-05-06 20:50:27 +00:00
break;
}
strcat(msg, buf);
2001-05-06 20:50:27 +00:00
}
trap_SendConsoleCommand(EXEC_APPEND, msg);
2001-05-06 20:50:27 +00:00
}
static gentity_t *SpawnModelOnVictoryPad(gentity_t * pad, vec3_t offset, gentity_t * ent, int place)
{
gentity_t *body;
vec3_t vec;
vec3_t f, r, u;
2001-05-06 20:50:27 +00:00
body = G_Spawn();
if (!body) {
G_Printf(S_COLOR_RED "ERROR: out of gentities\n");
2001-05-06 20:50:27 +00:00
return NULL;
}
body->classname = ent->client->pers.netname;
body->client = ent->client;
body->s = ent->s;
body->s.eType = ET_PLAYER; // could be ET_INVISIBLE
body->s.eFlags = 0; // clear EF_TALK, etc
body->s.powerups = 0; // clear powerups
body->s.loopSound = 0; // clear lava burning
2001-05-06 20:50:27 +00:00
body->s.number = body - g_entities;
body->timestamp = level.time;
body->physicsObject = qtrue;
body->physicsBounce = 0; // don't bounce
2001-05-06 20:50:27 +00:00
body->s.event = 0;
body->s.pos.trType = TR_STATIONARY;
body->s.groundEntityNum = ENTITYNUM_WORLD;
body->s.legsAnim = LEGS_IDLE;
body->s.torsoAnim = TORSO_STAND;
if (body->s.weapon == WP_NONE) {
2001-05-06 20:50:27 +00:00
body->s.weapon = WP_PISTOL;
}
if (body->s.weapon == WP_KNIFE) {
2001-05-06 20:50:27 +00:00
body->s.torsoAnim = TORSO_STAND2;
}
body->s.event = 0;
body->r.svFlags = ent->r.svFlags;
VectorCopy(ent->r.mins, body->r.mins);
VectorCopy(ent->r.maxs, body->r.maxs);
VectorCopy(ent->r.absmin, body->r.absmin);
VectorCopy(ent->r.absmax, body->r.absmax);
2001-05-06 20:50:27 +00:00
body->clipmask = CONTENTS_SOLID | CONTENTS_PLAYERCLIP;
body->r.contents = CONTENTS_BODY;
body->r.ownerNum = ent->r.ownerNum;
body->takedamage = qfalse;
VectorSubtract(level.intermission_origin, pad->r.currentOrigin, vec);
vectoangles(vec, body->s.apos.trBase);
2001-05-06 20:50:27 +00:00
body->s.apos.trBase[PITCH] = 0;
body->s.apos.trBase[ROLL] = 0;
AngleVectors(body->s.apos.trBase, f, r, u);
VectorMA(pad->r.currentOrigin, offset[0], f, vec);
VectorMA(vec, offset[1], r, vec);
VectorMA(vec, offset[2], u, vec);
2001-05-06 20:50:27 +00:00
G_SetOrigin(body, vec);
2001-05-06 20:50:27 +00:00
trap_LinkEntity(body);
2001-05-06 20:50:27 +00:00
body->count = place;
return body;
}
static void CelebrateStop(gentity_t * player)
{
int anim;
2001-05-06 20:50:27 +00:00
//Blaze: gah, dont need to change stance for using gauntlet
// if( player->s.weapon == WP_GAUNTLET) {
// anim = TORSO_STAND2;
// }
// else {
anim = TORSO_STAND;
// }
player->s.torsoAnim = ((player->s.torsoAnim & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | anim;
2001-05-06 20:50:27 +00:00
}
#define TIMER_GESTURE (34*66+50)
static void CelebrateStart(gentity_t * player)
{
player->s.torsoAnim = ((player->s.torsoAnim & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | TORSO_GESTURE;
2001-05-06 20:50:27 +00:00
player->nextthink = level.time + TIMER_GESTURE;
player->think = CelebrateStop;
/*
player->client->ps.events[player->client->ps.eventSequence & (MAX_PS_EVENTS-1)] = EV_TAUNT;
player->client->ps.eventParms[player->client->ps.eventSequence & (MAX_PS_EVENTS-1)] = 0;
player->client->ps.eventSequence++;
*/
2001-05-06 20:50:27 +00:00
G_AddEvent(player, EV_TAUNT, 0);
}
static vec3_t offsetFirst = { 0, 0, 74 };
static vec3_t offsetSecond = { -10, 60, 54 };
static vec3_t offsetThird = { -19, -60, 45 };
2001-05-06 20:50:27 +00:00
static void PodiumPlacementThink(gentity_t * podium)
{
vec3_t vec;
vec3_t origin;
vec3_t f, r, u;
2001-05-06 20:50:27 +00:00
podium->nextthink = level.time + 100;
AngleVectors(level.intermission_angle, vec, NULL, NULL);
VectorMA(level.intermission_origin, trap_Cvar_VariableIntegerValue("g_podiumDist"), vec, origin);
origin[2] -= trap_Cvar_VariableIntegerValue("g_podiumDrop");
G_SetOrigin(podium, origin);
2001-05-06 20:50:27 +00:00
if (podium1) {
VectorSubtract(level.intermission_origin, podium->r.currentOrigin, vec);
vectoangles(vec, podium1->s.apos.trBase);
2001-05-06 20:50:27 +00:00
podium1->s.apos.trBase[PITCH] = 0;
podium1->s.apos.trBase[ROLL] = 0;
AngleVectors(podium1->s.apos.trBase, f, r, u);
VectorMA(podium->r.currentOrigin, offsetFirst[0], f, vec);
VectorMA(vec, offsetFirst[1], r, vec);
VectorMA(vec, offsetFirst[2], u, vec);
2001-05-06 20:50:27 +00:00
G_SetOrigin(podium1, vec);
2001-05-06 20:50:27 +00:00
}
if (podium2) {
VectorSubtract(level.intermission_origin, podium->r.currentOrigin, vec);
vectoangles(vec, podium2->s.apos.trBase);
2001-05-06 20:50:27 +00:00
podium2->s.apos.trBase[PITCH] = 0;
podium2->s.apos.trBase[ROLL] = 0;
AngleVectors(podium2->s.apos.trBase, f, r, u);
VectorMA(podium->r.currentOrigin, offsetSecond[0], f, vec);
VectorMA(vec, offsetSecond[1], r, vec);
VectorMA(vec, offsetSecond[2], u, vec);
2001-05-06 20:50:27 +00:00
G_SetOrigin(podium2, vec);
2001-05-06 20:50:27 +00:00
}
if (podium3) {
VectorSubtract(level.intermission_origin, podium->r.currentOrigin, vec);
vectoangles(vec, podium3->s.apos.trBase);
2001-05-06 20:50:27 +00:00
podium3->s.apos.trBase[PITCH] = 0;
podium3->s.apos.trBase[ROLL] = 0;
AngleVectors(podium3->s.apos.trBase, f, r, u);
VectorMA(podium->r.currentOrigin, offsetThird[0], f, vec);
VectorMA(vec, offsetThird[1], r, vec);
VectorMA(vec, offsetThird[2], u, vec);
2001-05-06 20:50:27 +00:00
G_SetOrigin(podium3, vec);
2001-05-06 20:50:27 +00:00
}
}
static gentity_t *SpawnPodium(void)
{
gentity_t *podium;
vec3_t vec;
vec3_t origin;
2001-05-06 20:50:27 +00:00
podium = G_Spawn();
if (!podium) {
2001-05-06 20:50:27 +00:00
return NULL;
}
podium->classname = "podium";
podium->s.eType = ET_GENERAL;
podium->s.number = podium - g_entities;
podium->clipmask = CONTENTS_SOLID;
podium->r.contents = CONTENTS_SOLID;
podium->s.modelindex = G_ModelIndex(SP_PODIUM_MODEL);
2001-05-06 20:50:27 +00:00
AngleVectors(level.intermission_angle, vec, NULL, NULL);
VectorMA(level.intermission_origin, trap_Cvar_VariableIntegerValue("g_podiumDist"), vec, origin);
origin[2] -= trap_Cvar_VariableIntegerValue("g_podiumDrop");
G_SetOrigin(podium, origin);
2001-05-06 20:50:27 +00:00
VectorSubtract(level.intermission_origin, podium->r.currentOrigin, vec);
podium->s.apos.trBase[YAW] = vectoyaw(vec);
trap_LinkEntity(podium);
2001-05-06 20:50:27 +00:00
podium->think = PodiumPlacementThink;
podium->nextthink = level.time + 100;
return podium;
}
/*
==================
SpawnModelsOnVictoryPads
==================
*/
void SpawnModelsOnVictoryPads(void)
{
gentity_t *player;
gentity_t *podium;
2001-05-06 20:50:27 +00:00
podium1 = NULL;
podium2 = NULL;
podium3 = NULL;
podium = SpawnPodium();
player = SpawnModelOnVictoryPad(podium, offsetFirst, &g_entities[level.sortedClients[0]],
level.clients[level.sortedClients[0]].ps.
persistant[PERS_RANK] & ~RANK_TIED_FLAG);
if (player) {
2001-05-06 20:50:27 +00:00
player->nextthink = level.time + 2000;
player->think = CelebrateStart;
podium1 = player;
}
player = SpawnModelOnVictoryPad(podium, offsetSecond, &g_entities[level.sortedClients[1]],
level.clients[level.sortedClients[1]].ps.
persistant[PERS_RANK] & ~RANK_TIED_FLAG);
if (player) {
2001-05-06 20:50:27 +00:00
podium2 = player;
}
if (level.numNonSpectatorClients > 2) {
player = SpawnModelOnVictoryPad(podium, offsetThird, &g_entities[level.sortedClients[2]],
level.clients[level.sortedClients[2]].ps.
persistant[PERS_RANK] & ~RANK_TIED_FLAG);
if (player) {
2001-05-06 20:50:27 +00:00
podium3 = player;
}
}
}
/*
===============
Svcmd_AbortPodium_f
===============
*/
void Svcmd_AbortPodium_f(void)
{
if (g_gametype.integer != GT_SINGLE_PLAYER) {
2001-05-06 20:50:27 +00:00
return;
}
if (podium1) {
2001-05-06 20:50:27 +00:00
podium1->nextthink = level.time;
podium1->think = CelebrateStop;
}
}