moved function declarations of game syscalls to own header

This commit is contained in:
Walter Julius Hennecke 2014-10-09 20:15:26 +02:00
parent 788960f5d0
commit 38c6a7a8c8
39 changed files with 33569 additions and 33977 deletions

View File

@ -35,6 +35,8 @@
#include "inv.h" //indexes into the inventory
#include "syn.h" //synonyms
#include "match.h" //string matching types and vars
//
#include "g_syscalls.h"
/*

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,8 @@
#include "syn.h" //synonyms
#include "match.h" //string matching types and vars
#include "g_syscalls.h"
//goal flag, see be_ai_goal.h for the other GFL_*
#define GFL_AIR 128

View File

@ -37,6 +37,8 @@
#include "syn.h" //synonyms
#include "match.h" //string matching types and vars
#include "g_syscalls.h"
#define IDEAL_ATTACKDIST 140
#define WEAPONINDEX_PHASER 2

View File

@ -37,6 +37,8 @@
#include "inv.h"
#include "syn.h"
#include "g_syscalls.h"
#define AI_MAX_PATH 144

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,413 +1,414 @@
// Copyright (C) 1999-2000 Id Software, Inc.
//
//
// g_arenas.c
//
#include "g_local.h"
#include "g_client.h"
#include "g_utils.h"
#ifndef min
#define min(a, b) (a) < (b) ? a : b
#endif
gentity_t* podium1;
gentity_t* podium2;
gentity_t* podium3;
void UpdateTournamentInfo(void) {
char msg[AWARDS_MSG_LENGTH];
char msg2[AWARDS_MSG_LENGTH];
char* mvpName = "";
int32_t i = 0;
int32_t j = 0;
int32_t k = 0;
int32_t n = 0;
int32_t playerClientNum = 0;
int32_t playerRank = level.numNonSpectatorClients - 1;
int32_t highestTiedRank = 0;
int32_t mvpNum = -1;
int32_t mvpPoints = 0;
int32_t winningCaptures = 0;
int32_t winningPoints = 0;
int32_t winningTeam=0;
int32_t loseCaptures = 0;
int32_t losePoints = 0;
int32_t secondPlaceTied=0;
gentity_t* MVP = NULL;
gentity_t* player = NULL;
gclient_t* cl = NULL;
gclient_t* cl2= NULL;
memset(msg, 0, AWARDS_MSG_LENGTH);
memset(msg2, 0, AWARDS_MSG_LENGTH);
// Was there a tie for second place on the podium?
cl = &level.clients[level.sortedClients[1]];
cl2= &level.clients[level.sortedClients[2]];
if(cl->ps.persistant[PERS_SCORE] == cl2->ps.persistant[PERS_SCORE]) {
secondPlaceTied = 1;
}
winningTeam = level.clients[0].ps.persistant[PERS_RANK]+1;
if((winningTeam != TEAM_BLUE) && (winningTeam != TEAM_RED)) {
//tie or not a team game
winningTeam = 0;
}
if(mvpNum < 0) {
//ah, crap no MVP, pick the first player on the winning team
for(i = 0; i < level.maxclients; i++) {
if((&g_entities[i]) == NULL) { continue; }
if((&g_entities[i])->client == NULL) { continue; }
if(g_entities[i].client->ps.persistant[PERS_TEAM] == winningTeam ) {
mvpNum = i;
break;
}
}
}
if(mvpNum >= 0) {
//still no MVP, so skip it
MVP = &g_entities[mvpNum];
mvpName = MVP->client->pers.netname;
mvpPoints = MVP->client->ps.persistant[PERS_SCORE];
winningTeam = MVP->client->ps.persistant[PERS_TEAM];
}
if(winningTeam != 0) {
//one of the teams won
winningCaptures = level.teamScores[winningTeam];
if(winningTeam == TEAM_RED) {
loseCaptures = level.teamScores[TEAM_BLUE];
} else {
loseCaptures = level.teamScores[TEAM_RED];
}
for(i = 0; i < level.maxclients; i++) {
if((&g_entities[i]) == NULL) { continue; }
if((&g_entities[i])->client == NULL) { continue; }
if(g_entities[i].client->ps.persistant[PERS_TEAM] == winningTeam) {
winningPoints += g_entities[i].client->ps.persistant[PERS_SCORE];
} else {
losePoints += g_entities[i].client->ps.persistant[PERS_SCORE];
}
}
}
for(i = 0; i < level.maxclients; i++) {
player = &g_entities[i];
if ((player == NULL) || (player->inuse == qfalse) || ((player->r.svFlags & SVF_BOT) != 0)) {
continue;
}
playerClientNum = i;
G_Client_CalculateRanks( qfalse );
// put info for the top three players into the msg
Com_sprintf(msg, AWARDS_MSG_LENGTH, "awards %d", level.numNonSpectatorClients);
for(j = 0; j < level.numNonSpectatorClients; j++) {
if(j > 2) {
break;
}
n = level.sortedClients[j];
strcpy(msg2, msg);
Com_sprintf(msg, AWARDS_MSG_LENGTH, "%s %d", msg2, n);
}
// put this guy's awards into the msg
if(level.clients[playerClientNum].sess.sessionTeam == TEAM_SPECTATOR) {
strcpy(msg2, msg);
Com_sprintf( msg, sizeof(msg), "%s 0", msg2);
}
// now supply...
//
// 1) winning team's MVP's name
// 2) winning team's MVP's score
// 3) winning team's total captures
// 4) winning team's total points
// 5) this player's rank
// 6) the highest rank for which this player tied
// 7) losing team's total captures
// 8) losing team's total points
// 9) if second place was tied
// 10) intermission point
// 11) intermission angles
//
for(k = 0; k < level.numNonSpectatorClients; k++) {
if(level.sortedClients[k] == playerClientNum) {
playerRank = k;
break;
}
}
highestTiedRank = 0;
for(k = playerRank-1; k >= 0; k--) {
cl = &level.clients[level.sortedClients[k]];
if (cl->ps.persistant[PERS_SCORE] > level.clients[level.sortedClients[playerRank]].ps.persistant[PERS_SCORE]) {
break;
}
highestTiedRank = k+1;
}
strcpy(msg2, msg);
Com_sprintf(msg, AWARDS_MSG_LENGTH, "%s \"%s\" %d %d %d %d %d %d %d %d %f %f %f %f %f %f",
msg2, mvpName, mvpPoints, winningCaptures, winningPoints, playerRank, highestTiedRank,
loseCaptures, losePoints, secondPlaceTied, level.intermission_origin[0], level.intermission_origin[1],
level.intermission_origin[2], level.intermission_angle[0], level.intermission_angle[1],
level.intermission_angle[2]);
trap_SendServerCommand(player-g_entities, msg);
}
if(g_gametype.integer == GT_SINGLE_PLAYER) {
Com_sprintf( msg, sizeof(msg), "postgame %i", playerRank);
trap_SendConsoleCommand( EXEC_APPEND, msg);
}
}
static gentity_t* SpawnModelOnVictoryPad(gentity_t* pad, vec3_t offset, gentity_t* ent, int32_t place) {
gentity_t* body;
vec3_t vec;
vec3_t f;
vec3_t r;
vec3_t u;
entityState_t* eState;
entityShared_t* eShared;
body = G_Spawn();
if(body == NULL) {
G_Printf( S_COLOR_RED "ERROR: out of gentities\n" );
return NULL;
}
eState = &body->s;
eShared = &body->r;
body->classname = ent->client->pers.netname;
body->client = ent->client;
eState = &ent->s;
eState->eType = ET_PLAYER; // could be ET_INVISIBLE
eState->eFlags = 0; // clear EF_TALK, etc
eState->powerups = 0; // clear powerups
eState->loopSound = 0; // clear lava burning
eState->number = body - g_entities;
body->timestamp = level.time;
body->physicsObject = qtrue;
body->physicsBounce = 0; // don't bounce
eState->event = 0;
eState->pos.trType = TR_STATIONARY;
eState->groundEntityNum = ENTITYNUM_WORLD;
eState->legsAnim = BOTH_STAND1; //TORSO_STAND
eState->torsoAnim = BOTH_STAND1;
// fix up some weapon holding / shooting issues
if (eState->weapon==WP_5 || eState->weapon==WP_13 || eState->weapon == WP_0 ) {
eState->weapon = WP_6;
}
eState->event = 0;
eShared->svFlags = ent->r.svFlags;
VectorCopy (ent->r.mins, eShared->mins);
VectorCopy (ent->r.maxs, eShared->maxs);
VectorCopy (ent->r.absmin, eShared->absmin);
VectorCopy (ent->r.absmax, eShared->absmax);
body->clipmask = CONTENTS_SOLID | CONTENTS_PLAYERCLIP;
eShared->contents = CONTENTS_BODY;
eShared->ownerNum = ent->r.ownerNum;
body->takedamage = qfalse;
VectorSubtract( level.intermission_origin, pad->r.currentOrigin, vec );
vectoangles( vec, eState->apos.trBase );
eState->apos.trBase[PITCH] = 0;
eState->apos.trBase[ROLL] = 0;
AngleVectors( eState->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 );
G_SetOrigin( body, vec );
trap_LinkEntity (body);
body->count = place;
return body;
}
static void CelebrateStop(gentity_t* player) {
int32_t anim;
anim = BOTH_STAND1; //TORSO_STAND
player->s.torsoAnim = ( ( player->s.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;
}
#define TIMER_GESTURE (34*66+50)
extern void BG_AddPredictableEventToPlayerstate(int32_t newEvent, int32_t eventParm, playerState_t* ps);
static void CelebrateStart(gentity_t* player)
{
/*player->s.torsoAnim = ( ( player->s.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | TORSO_GESTURE;
player->nextthink = level.time + TIMER_GESTURE;
player->think = CelebrateStop;*/
// We don't want the taunt sound effect because it interfears with the computer voice giving awards
// FIXME: just get timing right?
//FIXME: why does this get lost now?
BG_AddPredictableEventToPlayerstate( EV_TAUNT, 0, &player->client->ps );
}
static vec3_t offsetFirst = {0, 0, 64};
static vec3_t offsetSecond = {-10, 60, 44};
static vec3_t offsetThird = {-19, -60, 35};
static void PodiumPlacementThink(gentity_t* podium) {
vec3_t vec;
vec3_t origin;
vec3_t f;
vec3_t r;
vec3_t u;
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 );
if(podium1 != NULL) {
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
vectoangles( vec, podium1->s.apos.trBase );
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 );
G_SetOrigin( podium1, vec );
}
if(podium2 != NULL) {
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
vectoangles( vec, podium2->s.apos.trBase );
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 );
G_SetOrigin( podium2, vec );
}
if(podium3 != NULL) {
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
vectoangles( vec, podium3->s.apos.trBase );
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 );
G_SetOrigin( podium3, vec );
}
}
static gentity_t* SpawnPodium( void ) {
gentity_t* podium;
vec3_t vec;
vec3_t origin;
podium = G_Spawn();
if(podium == NULL) {
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;
if(g_gametype.integer > GT_SINGLE_PLAYER) {
podium->s.modelindex = G_ModelIndex( TEAM_PODIUM_MODEL );
} else {
podium->s.modelindex = G_ModelIndex( SP_PODIUM_MODEL );
}
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 );
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
podium->s.apos.trBase[YAW] = vectoyaw( vec );
trap_LinkEntity (podium);
podium->think = PodiumPlacementThink;
podium->nextthink = level.time + 100;
return podium;
}
void SpawnModelsOnVictoryPads( void ) {
gentity_t* player;
gentity_t* podium;
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 != NULL) {
player->nextthink = level.time + 2000;
player->think = CelebrateStart;
podium1 = player;
}
// For non team game types, we want to spawn 3 characters on the victory pad
// For team games (GT_TEAM, GT_CTF) we want to have only a single player on the pad
if(( g_gametype.integer == GT_FFA ) || (g_gametype.integer == GT_TOURNAMENT) || (g_gametype.integer == GT_SINGLE_PLAYER)) {
if( level.numNonSpectatorClients > 1 ) {
player = SpawnModelOnVictoryPad( podium, offsetSecond, &g_entities[level.sortedClients[1]],
level.clients[ level.sortedClients[1] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );
if(player != NULL) {
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 != NULL) {
podium3 = player;
}
}
}
}
void Svcmd_AbortPodium_f( void ) {
if( g_gametype.integer != GT_SINGLE_PLAYER ) {
return;
}
if( podium1 != NULL ) {
podium1->nextthink = level.time;
podium1->think = CelebrateStop;
}
}
// Copyright (C) 1999-2000 Id Software, Inc.
//
//
// g_arenas.c
//
#include "g_local.h"
#include "g_client.h"
#include "g_utils.h"
#include "g_syscalls.h"
#ifndef min
#define min(a, b) (a) < (b) ? a : b
#endif
gentity_t* podium1;
gentity_t* podium2;
gentity_t* podium3;
void UpdateTournamentInfo(void) {
char msg[AWARDS_MSG_LENGTH];
char msg2[AWARDS_MSG_LENGTH];
char* mvpName = "";
int32_t i = 0;
int32_t j = 0;
int32_t k = 0;
int32_t n = 0;
int32_t playerClientNum = 0;
int32_t playerRank = level.numNonSpectatorClients - 1;
int32_t highestTiedRank = 0;
int32_t mvpNum = -1;
int32_t mvpPoints = 0;
int32_t winningCaptures = 0;
int32_t winningPoints = 0;
int32_t winningTeam=0;
int32_t loseCaptures = 0;
int32_t losePoints = 0;
int32_t secondPlaceTied=0;
gentity_t* MVP = NULL;
gentity_t* player = NULL;
gclient_t* cl = NULL;
gclient_t* cl2= NULL;
memset(msg, 0, AWARDS_MSG_LENGTH);
memset(msg2, 0, AWARDS_MSG_LENGTH);
// Was there a tie for second place on the podium?
cl = &level.clients[level.sortedClients[1]];
cl2= &level.clients[level.sortedClients[2]];
if(cl->ps.persistant[PERS_SCORE] == cl2->ps.persistant[PERS_SCORE]) {
secondPlaceTied = 1;
}
winningTeam = level.clients[0].ps.persistant[PERS_RANK]+1;
if((winningTeam != TEAM_BLUE) && (winningTeam != TEAM_RED)) {
//tie or not a team game
winningTeam = 0;
}
if(mvpNum < 0) {
//ah, crap no MVP, pick the first player on the winning team
for(i = 0; i < level.maxclients; i++) {
if((&g_entities[i]) == NULL) { continue; }
if((&g_entities[i])->client == NULL) { continue; }
if(g_entities[i].client->ps.persistant[PERS_TEAM] == winningTeam ) {
mvpNum = i;
break;
}
}
}
if(mvpNum >= 0) {
//still no MVP, so skip it
MVP = &g_entities[mvpNum];
mvpName = MVP->client->pers.netname;
mvpPoints = MVP->client->ps.persistant[PERS_SCORE];
winningTeam = MVP->client->ps.persistant[PERS_TEAM];
}
if(winningTeam != 0) {
//one of the teams won
winningCaptures = level.teamScores[winningTeam];
if(winningTeam == TEAM_RED) {
loseCaptures = level.teamScores[TEAM_BLUE];
} else {
loseCaptures = level.teamScores[TEAM_RED];
}
for(i = 0; i < level.maxclients; i++) {
if((&g_entities[i]) == NULL) { continue; }
if((&g_entities[i])->client == NULL) { continue; }
if(g_entities[i].client->ps.persistant[PERS_TEAM] == winningTeam) {
winningPoints += g_entities[i].client->ps.persistant[PERS_SCORE];
} else {
losePoints += g_entities[i].client->ps.persistant[PERS_SCORE];
}
}
}
for(i = 0; i < level.maxclients; i++) {
player = &g_entities[i];
if ((player == NULL) || (player->inuse == qfalse) || ((player->r.svFlags & SVF_BOT) != 0)) {
continue;
}
playerClientNum = i;
G_Client_CalculateRanks( qfalse );
// put info for the top three players into the msg
Com_sprintf(msg, AWARDS_MSG_LENGTH, "awards %d", level.numNonSpectatorClients);
for(j = 0; j < level.numNonSpectatorClients; j++) {
if(j > 2) {
break;
}
n = level.sortedClients[j];
strcpy(msg2, msg);
Com_sprintf(msg, AWARDS_MSG_LENGTH, "%s %d", msg2, n);
}
// put this guy's awards into the msg
if(level.clients[playerClientNum].sess.sessionTeam == TEAM_SPECTATOR) {
strcpy(msg2, msg);
Com_sprintf( msg, sizeof(msg), "%s 0", msg2);
}
// now supply...
//
// 1) winning team's MVP's name
// 2) winning team's MVP's score
// 3) winning team's total captures
// 4) winning team's total points
// 5) this player's rank
// 6) the highest rank for which this player tied
// 7) losing team's total captures
// 8) losing team's total points
// 9) if second place was tied
// 10) intermission point
// 11) intermission angles
//
for(k = 0; k < level.numNonSpectatorClients; k++) {
if(level.sortedClients[k] == playerClientNum) {
playerRank = k;
break;
}
}
highestTiedRank = 0;
for(k = playerRank-1; k >= 0; k--) {
cl = &level.clients[level.sortedClients[k]];
if (cl->ps.persistant[PERS_SCORE] > level.clients[level.sortedClients[playerRank]].ps.persistant[PERS_SCORE]) {
break;
}
highestTiedRank = k+1;
}
strcpy(msg2, msg);
Com_sprintf(msg, AWARDS_MSG_LENGTH, "%s \"%s\" %d %d %d %d %d %d %d %d %f %f %f %f %f %f",
msg2, mvpName, mvpPoints, winningCaptures, winningPoints, playerRank, highestTiedRank,
loseCaptures, losePoints, secondPlaceTied, level.intermission_origin[0], level.intermission_origin[1],
level.intermission_origin[2], level.intermission_angle[0], level.intermission_angle[1],
level.intermission_angle[2]);
trap_SendServerCommand(player-g_entities, msg);
}
if(g_gametype.integer == GT_SINGLE_PLAYER) {
Com_sprintf( msg, sizeof(msg), "postgame %i", playerRank);
trap_SendConsoleCommand( EXEC_APPEND, msg);
}
}
static gentity_t* SpawnModelOnVictoryPad(gentity_t* pad, vec3_t offset, gentity_t* ent, int32_t place) {
gentity_t* body;
vec3_t vec;
vec3_t f;
vec3_t r;
vec3_t u;
entityState_t* eState;
entityShared_t* eShared;
body = G_Spawn();
if(body == NULL) {
G_Printf( S_COLOR_RED "ERROR: out of gentities\n" );
return NULL;
}
eState = &body->s;
eShared = &body->r;
body->classname = ent->client->pers.netname;
body->client = ent->client;
eState = &ent->s;
eState->eType = ET_PLAYER; // could be ET_INVISIBLE
eState->eFlags = 0; // clear EF_TALK, etc
eState->powerups = 0; // clear powerups
eState->loopSound = 0; // clear lava burning
eState->number = body - g_entities;
body->timestamp = level.time;
body->physicsObject = qtrue;
body->physicsBounce = 0; // don't bounce
eState->event = 0;
eState->pos.trType = TR_STATIONARY;
eState->groundEntityNum = ENTITYNUM_WORLD;
eState->legsAnim = BOTH_STAND1; //TORSO_STAND
eState->torsoAnim = BOTH_STAND1;
// fix up some weapon holding / shooting issues
if (eState->weapon==WP_5 || eState->weapon==WP_13 || eState->weapon == WP_0 ) {
eState->weapon = WP_6;
}
eState->event = 0;
eShared->svFlags = ent->r.svFlags;
VectorCopy (ent->r.mins, eShared->mins);
VectorCopy (ent->r.maxs, eShared->maxs);
VectorCopy (ent->r.absmin, eShared->absmin);
VectorCopy (ent->r.absmax, eShared->absmax);
body->clipmask = CONTENTS_SOLID | CONTENTS_PLAYERCLIP;
eShared->contents = CONTENTS_BODY;
eShared->ownerNum = ent->r.ownerNum;
body->takedamage = qfalse;
VectorSubtract( level.intermission_origin, pad->r.currentOrigin, vec );
vectoangles( vec, eState->apos.trBase );
eState->apos.trBase[PITCH] = 0;
eState->apos.trBase[ROLL] = 0;
AngleVectors( eState->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 );
G_SetOrigin( body, vec );
trap_LinkEntity (body);
body->count = place;
return body;
}
static void CelebrateStop(gentity_t* player) {
int32_t anim;
anim = BOTH_STAND1; //TORSO_STAND
player->s.torsoAnim = ( ( player->s.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;
}
#define TIMER_GESTURE (34*66+50)
extern void BG_AddPredictableEventToPlayerstate(int32_t newEvent, int32_t eventParm, playerState_t* ps);
static void CelebrateStart(gentity_t* player)
{
/*player->s.torsoAnim = ( ( player->s.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | TORSO_GESTURE;
player->nextthink = level.time + TIMER_GESTURE;
player->think = CelebrateStop;*/
// We don't want the taunt sound effect because it interfears with the computer voice giving awards
// FIXME: just get timing right?
//FIXME: why does this get lost now?
BG_AddPredictableEventToPlayerstate( EV_TAUNT, 0, &player->client->ps );
}
static vec3_t offsetFirst = {0, 0, 64};
static vec3_t offsetSecond = {-10, 60, 44};
static vec3_t offsetThird = {-19, -60, 35};
static void PodiumPlacementThink(gentity_t* podium) {
vec3_t vec;
vec3_t origin;
vec3_t f;
vec3_t r;
vec3_t u;
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 );
if(podium1 != NULL) {
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
vectoangles( vec, podium1->s.apos.trBase );
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 );
G_SetOrigin( podium1, vec );
}
if(podium2 != NULL) {
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
vectoangles( vec, podium2->s.apos.trBase );
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 );
G_SetOrigin( podium2, vec );
}
if(podium3 != NULL) {
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
vectoangles( vec, podium3->s.apos.trBase );
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 );
G_SetOrigin( podium3, vec );
}
}
static gentity_t* SpawnPodium( void ) {
gentity_t* podium;
vec3_t vec;
vec3_t origin;
podium = G_Spawn();
if(podium == NULL) {
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;
if(g_gametype.integer > GT_SINGLE_PLAYER) {
podium->s.modelindex = G_ModelIndex( TEAM_PODIUM_MODEL );
} else {
podium->s.modelindex = G_ModelIndex( SP_PODIUM_MODEL );
}
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 );
VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
podium->s.apos.trBase[YAW] = vectoyaw( vec );
trap_LinkEntity (podium);
podium->think = PodiumPlacementThink;
podium->nextthink = level.time + 100;
return podium;
}
void SpawnModelsOnVictoryPads( void ) {
gentity_t* player;
gentity_t* podium;
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 != NULL) {
player->nextthink = level.time + 2000;
player->think = CelebrateStart;
podium1 = player;
}
// For non team game types, we want to spawn 3 characters on the victory pad
// For team games (GT_TEAM, GT_CTF) we want to have only a single player on the pad
if(( g_gametype.integer == GT_FFA ) || (g_gametype.integer == GT_TOURNAMENT) || (g_gametype.integer == GT_SINGLE_PLAYER)) {
if( level.numNonSpectatorClients > 1 ) {
player = SpawnModelOnVictoryPad( podium, offsetSecond, &g_entities[level.sortedClients[1]],
level.clients[ level.sortedClients[1] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );
if(player != NULL) {
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 != NULL) {
podium3 = player;
}
}
}
}
void Svcmd_AbortPodium_f( void ) {
if( g_gametype.integer != GT_SINGLE_PLAYER ) {
return;
}
if( podium1 != NULL ) {
podium1->nextthink = level.time;
podium1->think = CelebrateStop;
}
}

View File

@ -5,6 +5,7 @@
#include "g_local.h"
#include "g_main.h"
#include "g_client.h"
#include "g_syscalls.h"
static int32_t g_numBots;

View File

@ -4,6 +4,7 @@
#include "g_items.h"
#include "g_combat.h"
#include "g_utils.h"
#include "g_syscalls.h"
/**
* \brief A func_breakables health has sunk to or under zero

View File

@ -1,81 +1,82 @@
#include "g_cinematic.h"
#include "g_local.h"
#include "g_client.h"
#include "g_spawn.h"
extern void InitMover( gentity_t *ent );
/*QUAKED cinematic_camera (0 0.5 0) (-4 -4 -4) (4 4 4)
-----DESCRIPTION-----
Camera for cinematic. Normally spawn by Lua script.
-----SPAWNFLAGS-----
none
-----KEYS-----
none
-----LUA-----
To be written later.
*/
void SP_cinematic_camera(gentity_t *ent) {
ent->type = ENT_CINEMATIC_CAMMERA;
trap_LinkEntity(ent);
InitMover(ent);
}
void Cinematic_ActivateCameraMode(gentity_t *ent, gentity_t *target) {
gclient_t *client;
if(!ent || !ent->client || (ent->flags & FL_CCAM)) return;
client = ent->client;
ent->flags ^= FL_CCAM;
client->ps.pm_type = PM_CCAM;
client->cam = target;
VectorCopy(client->ps.viewangles, client->origViewAngles);
VectorCopy(ent->r.currentOrigin, client->origOrigin);
G_Client_SetViewAngle(ent, target->s.angles);
G_SetOrigin(ent, target->r.currentOrigin);
VectorCopy(target->r.currentOrigin, ent->client->ps.origin);
trap_LinkEntity(ent);
}
void Cinematic_DeactivateCameraMode(gentity_t *ent) {
gclient_t *client;
if(!ent || !ent->client || !(ent->flags & FL_CCAM)) return;
client = ent->client;
client->cam = NULL;
G_Printf("resetting origin to %s\n", vtos(client->origOrigin));
G_SetOrigin(ent, client->origOrigin);
VectorCopy(client->origOrigin, ent->client->ps.origin);
G_Client_SetViewAngle(ent, client->origViewAngles);
trap_LinkEntity(ent);
}
void Cinematic_ActivateGlobalCameraMode(gentity_t *target) {
int i;
gentity_t *ent;
for(i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if(!ent || !ent->client) continue;
Cinematic_ActivateCameraMode(ent, target);
}
}
void Cinematic_DeactivateGlobalCameraMode(void) {
int i;
gentity_t *ent;
for(i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if(!ent || !ent->client) continue;
Cinematic_DeactivateCameraMode(ent);
}
}
#include "g_cinematic.h"
#include "g_local.h"
#include "g_client.h"
#include "g_spawn.h"
#include "g_syscalls.h"
extern void InitMover( gentity_t *ent );
/*QUAKED cinematic_camera (0 0.5 0) (-4 -4 -4) (4 4 4)
-----DESCRIPTION-----
Camera for cinematic. Normally spawn by Lua script.
-----SPAWNFLAGS-----
none
-----KEYS-----
none
-----LUA-----
To be written later.
*/
void SP_cinematic_camera(gentity_t *ent) {
ent->type = ENT_CINEMATIC_CAMMERA;
trap_LinkEntity(ent);
InitMover(ent);
}
void Cinematic_ActivateCameraMode(gentity_t *ent, gentity_t *target) {
gclient_t *client;
if(!ent || !ent->client || (ent->flags & FL_CCAM)) return;
client = ent->client;
ent->flags ^= FL_CCAM;
client->ps.pm_type = PM_CCAM;
client->cam = target;
VectorCopy(client->ps.viewangles, client->origViewAngles);
VectorCopy(ent->r.currentOrigin, client->origOrigin);
G_Client_SetViewAngle(ent, target->s.angles);
G_SetOrigin(ent, target->r.currentOrigin);
VectorCopy(target->r.currentOrigin, ent->client->ps.origin);
trap_LinkEntity(ent);
}
void Cinematic_DeactivateCameraMode(gentity_t *ent) {
gclient_t *client;
if(!ent || !ent->client || !(ent->flags & FL_CCAM)) return;
client = ent->client;
client->cam = NULL;
G_Printf("resetting origin to %s\n", vtos(client->origOrigin));
G_SetOrigin(ent, client->origOrigin);
VectorCopy(client->origOrigin, ent->client->ps.origin);
G_Client_SetViewAngle(ent, client->origViewAngles);
trap_LinkEntity(ent);
}
void Cinematic_ActivateGlobalCameraMode(gentity_t *target) {
int i;
gentity_t *ent;
for(i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if(!ent || !ent->client) continue;
Cinematic_ActivateCameraMode(ent, target);
}
}
void Cinematic_DeactivateGlobalCameraMode(void) {
int i;
gentity_t *ent;
for(i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if(!ent || !ent->client) continue;
Cinematic_DeactivateCameraMode(ent);
}
}

View File

@ -10,6 +10,7 @@
#include "g_items.h"
#include "g_lua.h"
#include "g_logger.h"
#include "g_syscalls.h"
reconData_t g_reconData[MAX_RECON_NAMES]; //!< recon data for a limited ammount of clients
int32_t g_reconNum;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2190,464 +2190,6 @@ extern vmCvar_t dev_showTriggers;
extern vmCvar_t rpg_spEasterEggs;
//RPG-X - Stephen: Some global varibles for RPG-X
//extern int lastTimedMessage; //The last timed message that was displayed
//TiM - since we'll only use this in g_active, why not reduce its scope to make things easier. :)
/**
* Call G_PRINT in the engine.
* \param fmt format string.
*/
void trap_Printf( const char* fmt );
/**
* Calls Com_error in the engine
* \param fmt error desription
*/
void trap_Error( const char* fmt );
/**
* Get milliseconds since engine start
* \return milliseconds since engine start
*/
int trap_Milliseconds( void );
/**
* Get count of arguments for the current client game command
* \return count of arguments
*/
int trap_Argc( void );
/**
* Get a n of the current client game command
* \param n argument to get
* \param buffer buffer to store the argument in
* \param bufferLength size of the buffer
*/
void trap_Argv( int n, char* buffer, int bufferLength );
/**
* Get all args of the current client game command
* \param buffer buffer to store the arguments in
* \param bufferLength size of the buffer
*/
void trap_Args( char* buffer, int bufferLength );
/**
* Opens a file
* \param qpath path and filename
* \param f filehandle to use
* \param mode mode to use
*/
int trap_FS_FOpenFile( const char* qpath, fileHandle_t* f, fsMode_t mode );
/**
* Read a opened file
* \param buffer buffer to read to
* \param len buffer length or length to read (<sizeof(buffer))
* \param f filehandle for the file to read from
*
* You have to open the file first.
*/
void trap_FS_Read( void* buffer, int len, fileHandle_t f );
/**
* Write to a file
* \param buffer text to write
* \param len length of buffer
* \param f filehandle for the file to write to
*
* You have to open the file first.
*/
void trap_FS_Write( const void* buffer, int len, fileHandle_t f );
/**
* Close a file
* \param f filehandle for file to close
*/
void trap_FS_FCloseFile( fileHandle_t f );
/**
* Get a list of files in a path
* \param path path to get the list for
* \param extension filter to get only files with this extension
* \param listbuf buffer to store the file list in
* \param bufsize size of the buffer
* \return number of files in the list
*/
int trap_FS_GetFileList( const char* path, const char* extension, char* listbuf, int bufsize );
/**
* Sends a console command to execute to the client console
* \param exec_when when to exec (e.g. EXEC_APPEND)
* \param text the command to execute
*/
void trap_SendConsoleCommand( int exec_when, const char *text );
/**
* Register a cvar
* \param cvar representation of the cvar in the vm
* \param var_name name of the cvar
* \param value default value for the cvar
* \param flags additional options for the cvar (e.g. CVAR_ARCHIVE)
*/
void trap_Cvar_Register( /*@null@*/ vmCvar_t* cvar, const char* var_name, const char* value, int flags );
/**
* \brief Update a cvar.
*
* Tells the server/engine that a cvar in the vm has changed.
* \param cvar cvar to update
*/
void trap_Cvar_Update( vmCvar_t* cvar );
/**
* Set the cvar to a value.
* \param var_name name of the cvar to set
* \param value new value for the cvar
*/
void trap_Cvar_Set( const char* var_name, const char* value );
/**
* Get the integer value for an cvar
* \param var_name name of the cvar
*/
int trap_Cvar_VariableIntegerValue( const char* var_name );
/**
* Get the value of the cvar as string
* \param var_name name of the cvar
* \param buffer to store the value
* \param bufsize size of the buffer
*/
void trap_Cvar_VariableStringBuffer( const char* var_name, char* buffer, int bufsize );
/**
* Send some information of the current game/map to the server
* \param pointer to level.entities which is g_entities
* \param numGEntities number of game entities (level.num_entities)
* \param sizeofGEntity_t size of gentity_t
* \param gameClients level.clients[0].ps
* \param sizeOfGameClient size of level.clients[0]
*/
void trap_LocateGameData( gentity_t* gEnts, int numGEntities, int sizeofGEntity_t, playerState_t* gameClients, int sizeofGameClient );
/**
* Drop a client from server.
* \param clientNum client number of client to drop
* \param test reason for client drop
*/
void trap_DropClient( int clientNum, const char* reason );
/**
* \brief Send a server command to the client
* \param clientNum client number of client
* \param server command to execute
*
* A value of -1 for clientNum will send the command to all clients.
*/
void trap_SendServerCommand( int clientNum, const char* text );
/**
* Set a configstring
* \param num CS_...
* \param string set cofig string to this
*/
void trap_SetConfigstring( int num, /*@null@*/ const char* string );
/**
* Get a configstring
* \param num CS_...
* \param buffer buffer to store config string in
* \param bufferSize size of buffer
*/
void trap_GetConfigstring( int num, char* buffer, size_t bufferSize );
/**
* Get the userinfo for a client
* \param num client number
* \param buffer buffer to store config string in
* \param size of buffer
*/
void trap_GetUserinfo( int num, char* buffer, int bufferSize );
/**
* Set the userinfo for a client
* \param num client number
* \param buffer string the contains new userinfo
*/
void trap_SetUserinfo( int num, const char* buffer );
/**
* Get server info.
* \param buffer buffer to store the info in
* \param bufferSize size of buffer
*/
void trap_GetServerinfo( char* buffer, size_t bufferSize );
/**
* \brief Set the brush model for a entity.
* \param ent entity to the the model on
* \param name the model name
*
* The normal case is trap_SetBrushModel(ent, ent->model).
* Brush models always have names of *<int>.
*/
void trap_SetBrushModel( gentity_t* ent, const char* name );
/**
* \brief Do a trace on the server
* \param results trace_t to store the results in
* \param start startpoint
* \param end endpoint
* \param mins used to define the volume size
* \param maxs uses to define the volume size
* \param passEntityNum entity/entities to ignore
* \param contentmask only check for this contents (CONTENT_...)
*
* This actually moves a box with the size defined by mins and maxs through the world
* from start to end and checks whether it colides with anything that matches the contentmask.
* The entities that math the passEntityNum will be ingnored.
*/
void trap_Trace( trace_t* results, const vec3_t start, /*@null@*/ const vec3_t mins, /*@null@*/ const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
/**
* \param point the point
* \param passEntityNum ingore this
*
* Works similar to a trace but only check a single point.
*/
int trap_PointContents( const vec3_t point, int passEntityNum );
qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );
qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );
/**
* Adjust the state of a area portal used for doors etc
* \param ent entity that effects the areaportal (area portal is inide the entities bounds)
* \param open open or close it?
*/
void trap_AdjustAreaPortalState( gentity_t* ent, qboolean open );
/**
* Checks if two areas are connected.
*/
qboolean trap_AreasConnected( int area1, int area2 );
/**
* Link an entity.
* This results in shared values beeing avaible on both game and client side.
*/
void trap_LinkEntity( gentity_t* ent );
/**
* Unlinks an entity.
*/
void trap_UnlinkEntity( gentity_t* ent );
/**
* \brief Get a list of all entities in a box.
* \param entityList list where entitynums will be stored
* \param maxcount limits the number of listed entities
*
* The size of the box is defined by mins and maxs.
*/
int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int32_t* entityList, int maxcount );
/**
* Checks if a entity is in contact with a defined box.
*/
qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t* ent );
/**
* Allocates a free client for a bot.
*/
int trap_BotAllocateClient( void );
/**
* Free the client that was used for a bot.
*/
void trap_BotFreeClient( int clientNum );
/**
* Get the last command a user did.
*/
void trap_GetUsercmd( int clientNum, usercmd_t* cmd );
/**
* Get entity token.
*/
qboolean trap_GetEntityToken( char* buffer, int bufferSize );
/**
* Create a debug polygon.
*
* \param color color of the polygon
* \param numPoints number of points the polygon has
* \param points points of the polygon
* \return Polgon id
*/
int trap_DebugPolygonCreate(int color, int numPoints, vec3_t* points);
/**
* Deletes a debug polygon.
*
* \param id id of polygon to delete
*/
void trap_DebugPolygonDelete(int id);
int trap_BotLibSetup( void );
int trap_BotLibShutdown( void );
int trap_BotLibVarSet(char* var_name, char* value);
int trap_BotLibVarGet(char* var_name, char* value, int size);
int trap_BotLibDefine(char* string);
int trap_BotLibStartFrame(float time);
int trap_BotLibLoadMap(const char* mapname);
int trap_BotLibUpdateEntity(int ent, void* bue);
int trap_BotLibTest(int parm0, char* parm1, vec3_t parm2, vec3_t parm3);
int trap_BotGetSnapshotEntity( int clientNum, int sequence );
int trap_BotGetConsoleMessage(int clientNum, char* message, int size);
void trap_BotUserCommand(int client, usercmd_t* ucmd);
void trap_AAS_EntityInfo(int entnum, void* info);
int trap_AAS_Initialized(void);
void trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
float trap_AAS_Time(void);
int trap_AAS_PointAreaNum(vec3_t point);
int trap_AAS_TraceAreas(vec3_t start, vec3_t end, int* areas, vec3_t* points, int maxareas);
int trap_AAS_PointContents(vec3_t point);
int trap_AAS_NextBSPEntity(int ent);
int trap_AAS_ValueForBSPEpairKey(int ent, char* key, char* value, int size);
int trap_AAS_VectorForBSPEpairKey(int ent, char* key, vec3_t v);
int trap_AAS_FloatForBSPEpairKey(int ent, char* key, float* value);
int trap_AAS_IntForBSPEpairKey(int ent, char* key, int* value);
int trap_AAS_AreaReachability(int areanum);
int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
int trap_AAS_Swimming(vec3_t origin);
int trap_AAS_PredictClientMovement(void* move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize);
void trap_EA_Say(int client, char* str);
void trap_EA_SayTeam(int client, char* str);
void trap_EA_SayClass(int client, char* str);
void trap_EA_UseItem(int client, char* it);
void trap_EA_DropItem(int client, char* it);
void trap_EA_UseInv(int client, char* inv);
void trap_EA_DropInv(int client, char* inv);
void trap_EA_Gesture(int client);
void trap_EA_Command(int client, char* command);
void trap_EA_SelectWeapon(int client, int weapon);
void trap_EA_Talk(int client);
void trap_EA_Attack(int client);
void trap_EA_Alt_Attack(int client);
void trap_EA_Use(int client);
void trap_EA_Respawn(int client);
void trap_EA_Jump(int client);
void trap_EA_DelayedJump(int client);
void trap_EA_Crouch(int client);
void trap_EA_MoveUp(int client);
void trap_EA_MoveDown(int client);
void trap_EA_MoveForward(int client);
void trap_EA_MoveBack(int client);
void trap_EA_MoveLeft(int client);
void trap_EA_MoveRight(int client);
void trap_EA_Move(int client, vec3_t dir, float speed);
void trap_EA_View(int client, vec3_t viewangles);
void trap_EA_EndRegular(int client, float thinktime);
void trap_EA_GetInput(int client, float thinktime, void* input);
void trap_EA_ResetInput(int client);
int trap_BotLoadCharacter(char* charfile, int skill);
void trap_BotFreeCharacter(int character);
float trap_Characteristic_Float(int character, int index);
float trap_Characteristic_BFloat(int character, int index, float min, float max);
int trap_Characteristic_Integer(int character, int index);
int trap_Characteristic_BInteger(int character, int index, int min, int max);
void trap_Characteristic_String(int character, int index, char *buf, int size);
int trap_BotAllocChatState(void);
void trap_BotFreeChatState(int handle);
void trap_BotQueueConsoleMessage(int chatstate, int type, char* message);
void trap_BotRemoveConsoleMessage(int chatstate, int handle);
int trap_BotNextConsoleMessage(int chatstate, void* cm);
int trap_BotNumConsoleMessages(int chatstate);
void trap_BotInitialChat(int chatstate, char* type, int mcontext, char* var0, char* var1, char* var2, char* var3, char* var4, char* var5, char* var6, char* var7 );
int trap_BotNumInitialChats(int chatstate, char* type);
int trap_BotReplyChat(int chatstate, char* message, int mcontext, int vcontext, char* var0, char* var1, char* var2, char* var3, char* var4, char* var5, char* var6, char* var7 );
int trap_BotChatLength(int chatstate);
void trap_BotEnterChat(int chatstate, int client, int sendto);
void trap_BotGetChatMessage(int chatstate, char* buf, int size);
int trap_StringContains(char* str1, char* str2, int casesensitive);
int trap_BotFindMatch(char* str, void* match, unsigned long int context);
void trap_BotMatchVariable(void* match, int variable, char* buf, int size);
void trap_UnifyWhiteSpaces(char* string);
void trap_BotReplaceSynonyms(char* string, unsigned long int context);
int trap_BotLoadChatFile(int chatstate, char* chatfile, char* chatname);
void trap_BotSetChatGender(int chatstate, int gender);
void trap_BotSetChatName(int chatstate, char* name);
void trap_BotResetGoalState(int goalstate);
void trap_BotRemoveFromAvoidGoals(int goalstate, int number);
void trap_BotResetAvoidGoals(int goalstate);
void trap_BotPushGoal(int goalstate, void* goal);
void trap_BotPopGoal(int goalstate);
void trap_BotEmptyGoalStack(int goalstate);
void trap_BotDumpAvoidGoals(int goalstate);
void trap_BotDumpGoalStack(int goalstate);
void trap_BotGoalName(int number, char* name, int size);
int trap_BotGetTopGoal(int goalstate, void* goal);
int trap_BotGetSecondGoal(int goalstate, void* goal);
int trap_BotChooseLTGItem(int goalstate, vec3_t origin, int* inventory, int travelflags, qboolean botRoamsOnly );
int trap_BotChooseNBGItem(int goalstate, vec3_t origin, int* inventory, int travelflags, void* ltg, float maxtime, qboolean botRoamsOnly);
int trap_BotTouchingGoal(vec3_t origin, void* goal);
int trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void* goal);
int trap_BotGetNextCampSpotGoal(int num, void* goal);
int trap_BotGetMapLocationGoal(char* name, void* goal);
int trap_BotGetLevelItemGoal(int index, char* classname, void* goal);
float trap_BotAvoidGoalTime(int goalstate, int number);
void trap_BotInitLevelItems(void);
void trap_BotUpdateEntityItems(void);
int trap_BotLoadItemWeights(int goalstate, char* filename);
void trap_BotFreeItemWeights(int goalstate);
void trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
void trap_BotSaveGoalFuzzyLogic(int goalstate, char* filename);
void trap_BotMutateGoalFuzzyLogic(int goalstate, float range);
int trap_BotAllocGoalState(int state);
void trap_BotFreeGoalState(int handle);
void trap_BotResetMoveState(int movestate);
void trap_BotMoveToGoal(void* result, int movestate, void* goal, int travelflags);
int trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
void trap_BotResetAvoidReach(int movestate);
void trap_BotResetLastAvoidReach(int movestate);
int trap_BotReachabilityArea(vec3_t origin, int testground);
int trap_BotMovementViewTarget(int movestate, void* goal, int travelflags, float lookahead, vec3_t target);
int trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void* goal, int travelflags, vec3_t target);
int trap_BotAllocMoveState(void);
void trap_BotFreeMoveState(int handle);
void trap_BotInitMoveState(int handle, void* initmove);
int trap_BotChooseBestFightWeapon(int weaponstate, int* inventory, qboolean meleeRange);
void trap_BotGetWeaponInfo(int weaponstate, int weapon, void* weaponinfo);
int trap_BotLoadWeaponWeights(int weaponstate, char* filename);
int trap_BotAllocWeaponState(void);
void trap_BotFreeWeaponState(int weaponstate);
void trap_BotResetWeaponState(int weaponstate);
int trap_GeneticParentsAndChildSelection(int numranks, float* ranks, int* parent1, int* parent2, int* child);
//OUMS
/** \typedef holoData_t

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
#include "g_utils.h"
#include "g_mover.h"
#include "g_weapon.h"
#include "g_syscalls.h"
extern void BG_LoadItemNames(void);
extern qboolean BG_ParseRankNames(char* fileName, rankNames_t rankNames[], size_t size);

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@
#include "g_missile.h"
#include "g_logger.h"
#include "g_combat.h"
#include "g_syscalls.h"
#define MISSILE_PRESTEP_TIME 50

View File

@ -8,6 +8,7 @@
#include "g_lua.h"
#include "g_utils.h"
#include "q_math.h"
#include "g_syscalls.h"
extern qboolean G_CallSpawn(gentity_t *ent);

View File

@ -2,6 +2,7 @@
//
#include "g_local.h"
#include "g_main.h"
#include "g_syscalls.h"
/*

View File

@ -5,6 +5,7 @@
#include "g_spawn.h"
#include "g_items.h"
#include "g_lua.h"
#include "g_syscalls.h"
field_t fields[] = {
{ "classname", FOFS(classname), F_LSTRING },

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
// Copyright (C) 1999-2000 Id Software, Inc.
//
#include "g_local.h"
#include "g_syscalls.h"
// this file is only included when building a dll
// g_syscalls.asm is included instead when building a qvm

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
#include "g_spawn.h"
#include "g_trigger.h"
#include "g_logger.h"
#include "g_syscalls.h"
#define UI_DIABLED 1
/*QUAKED ui_transporter (1 0.5 0) (-8 -8 -8) (8 8 8) ? DISABLED

View File

@ -3,6 +3,7 @@
#include "g_spawn.h"
#include "g_client.h"
#include "g_logger.h"
#include "g_syscalls.h"
#define USABLE_START_OFF 1
#define USABLE_AUTOANIM 2

View File

@ -10,6 +10,7 @@
#include "g_lua.h"
#include "g_logger.h"
#include "g_combat.h"
#include "g_syscalls.h"
/**
* \brief Data structure for a singele shader remap.

View File

@ -13,6 +13,7 @@
#include "g_combat.h"
#include "q_math.h"
#include "bg_lex.h"
#include "g_syscalls.h"
weaponConfig_t weaponConfig;

View File

@ -1,119 +1,121 @@
// lua library for cvars
#include "g_lua.h"
#include <string.h>
#ifdef G_LUA
/***
This module allows getting and setting game cvars.
@module cvar
*/
/***
Get cvar value as integer.
@function integer
@param name Cvar name.
@return Cvar value as integer.
*/
static int Cvar_Integer(lua_State *L) {
char *cvar;
char buf[1024];
cvar = (char *)luaL_checkstring(L, 1);
if(!cvar[0]) {
lua_pushinteger(L, 0);
return 1;
}
if(strstr(Q_strlwr(cvar), "password") != NULL
|| strstr(Q_strlwr(cvar), "pass") != NULL
|| strstr(Q_strlwr(cvar), "sql") != NULL) {
lua_pushinteger(L, 0);
return 1;
}
trap_Cvar_VariableStringBuffer(cvar, buf, sizeof(buf));
lua_pushinteger(L, atoi(buf));
return 1;
}
/***
Get cvar value as floating point number.
@function value
@param name Cvar name.
@return Cvar value as floating point number.
*/
static int Cvar_Value(lua_State *L) {
char *cvar;
char buf[1024];
cvar = (char *)luaL_checkstring(L, 1);
if(!cvar[0]) {
lua_pushnumber(L, 0);
return 1;
}
if(strstr(Q_strlwr(cvar), "password") != NULL
|| strstr(Q_strlwr(cvar), "pass") != NULL
|| strstr(Q_strlwr(cvar), "sql") != NULL) {
lua_pushnumber(L, 0);
return 1;
}
trap_Cvar_VariableStringBuffer(cvar, buf, sizeof(buf));
lua_pushnumber(L, atof(buf));
return 1;
}
/***
Get cvar value as string.
@function string
@param name Cvar name.
@return Cvar value as string.
*/
static int Cvar_String(lua_State *L) {
char *cvar;
char buf[1024];
cvar = (char *)luaL_checkstring(L, 1);
if(!cvar[0]) {
lua_pushstring(L, "");
return 1;
}
if(strstr(Q_strlwr(cvar), "password") != NULL
|| strstr(Q_strlwr(cvar), "pass") != NULL
|| strstr(Q_strlwr(cvar), "sql") != NULL) {
lua_pushstring(L, "");
return 1;
}
trap_Cvar_VariableStringBuffer(cvar, buf, sizeof(buf));
lua_pushstring(L, buf);
return 1;
}
/***
Get value for rpg_phaserdmg as number.
@function integer
@param name Cvar name.
@return Value for rpg_phaserdmg as number.
*/
static int Cvar_rpg_phaserdmg(lua_State *L) {
lua_pushnumber(L, (rpg_dmgFlags.integer & 1));
return 1;
}
static const luaL_Reg lib_cvar[] = {
{ "Integer", Cvar_Integer },
{ "Value", Cvar_Value },
{ "String", Cvar_String },
{ "rpg_phaserdmg", Cvar_rpg_phaserdmg }, // cvar does not exist anymore ... modified function to return the correct information for convinience
{ NULL, NULL}
};
int Luaopen_Cvar(lua_State *L) {
luaL_register(L, "cvar", lib_cvar);
return 1;
}
// lua library for cvars
#include "g_lua.h"
#ifdef G_LUA
#include <string.h>
#include "g_syscalls.h"
/***
This module allows getting and setting game cvars.
@module cvar
*/
/***
Get cvar value as integer.
@function integer
@param name Cvar name.
@return Cvar value as integer.
*/
static int Cvar_Integer(lua_State *L) {
char *cvar;
char buf[1024];
cvar = (char *)luaL_checkstring(L, 1);
if(!cvar[0]) {
lua_pushinteger(L, 0);
return 1;
}
if(strstr(Q_strlwr(cvar), "password") != NULL
|| strstr(Q_strlwr(cvar), "pass") != NULL
|| strstr(Q_strlwr(cvar), "sql") != NULL) {
lua_pushinteger(L, 0);
return 1;
}
trap_Cvar_VariableStringBuffer(cvar, buf, sizeof(buf));
lua_pushinteger(L, atoi(buf));
return 1;
}
/***
Get cvar value as floating point number.
@function value
@param name Cvar name.
@return Cvar value as floating point number.
*/
static int Cvar_Value(lua_State *L) {
char *cvar;
char buf[1024];
cvar = (char *)luaL_checkstring(L, 1);
if(!cvar[0]) {
lua_pushnumber(L, 0);
return 1;
}
if(strstr(Q_strlwr(cvar), "password") != NULL
|| strstr(Q_strlwr(cvar), "pass") != NULL
|| strstr(Q_strlwr(cvar), "sql") != NULL) {
lua_pushnumber(L, 0);
return 1;
}
trap_Cvar_VariableStringBuffer(cvar, buf, sizeof(buf));
lua_pushnumber(L, atof(buf));
return 1;
}
/***
Get cvar value as string.
@function string
@param name Cvar name.
@return Cvar value as string.
*/
static int Cvar_String(lua_State *L) {
char *cvar;
char buf[1024];
cvar = (char *)luaL_checkstring(L, 1);
if(!cvar[0]) {
lua_pushstring(L, "");
return 1;
}
if(strstr(Q_strlwr(cvar), "password") != NULL
|| strstr(Q_strlwr(cvar), "pass") != NULL
|| strstr(Q_strlwr(cvar), "sql") != NULL) {
lua_pushstring(L, "");
return 1;
}
trap_Cvar_VariableStringBuffer(cvar, buf, sizeof(buf));
lua_pushstring(L, buf);
return 1;
}
/***
Get value for rpg_phaserdmg as number.
@function integer
@param name Cvar name.
@return Value for rpg_phaserdmg as number.
*/
static int Cvar_rpg_phaserdmg(lua_State *L) {
lua_pushnumber(L, (rpg_dmgFlags.integer & 1));
return 1;
}
static const luaL_Reg lib_cvar[] = {
{ "Integer", Cvar_Integer },
{ "Value", Cvar_Value },
{ "String", Cvar_String },
{ "rpg_phaserdmg", Cvar_rpg_phaserdmg }, // cvar does not exist anymore ... modified function to return the correct information for convinience
{ NULL, NULL}
};
int Luaopen_Cvar(lua_State *L) {
luaL_register(L, "cvar", lib_cvar);
return 1;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,12 @@
// game lib for lua
#include "g_lua.h"
#include "g_combat.h"
#ifdef G_LUA
#include "g_combat.h"
#include "g_syscalls.h"
/***
This module provides access to some of the servers functionality.
@module game

File diff suppressed because it is too large Load Diff

View File

@ -1,299 +1,301 @@
// lua library for trace_t
#include "g_lua.h"
#ifdef G_LUA
/***
A module allowing to do traces. Documentation under work.
@module trace
*/
static int Trace_GC(lua_State * L)
{
return 0;
}
static int Trace_ToString(lua_State * L)
{
ltrace_t *ltrace;
trace_t *trace;
char buf[MAX_STRING_CHARS];
ltrace = Lua_GetTrace(L, 1);
trace = ltrace->tr;
Com_sprintf(buf, sizeof(buf), "trace: entity=%i fraction=%f allsolid=%i contents=%i endpos=\"%s\" startsolid=%i surfaceFlags=%i pointer=%p\n",
trace->entityNum,
trace->fraction,
trace->allsolid,
trace->contents,
vtos(trace->endpos),
trace->startsolid,
trace->surfaceFlags,
trace);
lua_pushstring(L, buf);
return 1;
}
/***
Does a trace.
@function DoTrace
@param start start-point of the trace.
@param mins minimal distance of trace (nil if unused)
@param maxs maximal distance of trace (nil if unused)
@param end end-point of trace
@param passEnt Number of ents to pass
@param contents Set content flags.
*/
static int Trace_DoTrace(lua_State *L) {
trace_t *tr;
vec_t *start, *end, *mins = NULL, *maxs = NULL;
int passEnt, contents;
start = Lua_GetVector(L, 1);
if(!lua_isnil(L, 2))
mins = Lua_GetVector(L, 2);
if(!lua_isnil(L, 3))
maxs = Lua_GetVector(L, 3);
end = Lua_GetVector(L, 4);
passEnt = (int)luaL_checknumber(L, 5);
contents = (int) luaL_checknumber(L, 6);
tr = (trace_t *)malloc(sizeof(trace_t));
if(!tr) {
LUA_DEBUG("Trace_DoTrace - was unable to allocate a trace_t.\n");
lua_pushnil(L);
return 1;
}
trap_Trace(tr, start, mins, maxs, end, passEnt, contents);
Lua_PushTrace(L, tr);
return 1;
}
/***
Frees all memory that was allocated for this trace.
@function FreeTrace
@param trace The trace.
*/
static int Trace_FreeTrace(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
if(tr && tr->tr)
free(tr->tr);
return 1;
}
/***
Check whether the trace has gone only trough solid content (e.g. only inside a wall).
@function GetAllsolid
@return Whether trace was all solid.
*/
static int Trace_GetAllsolid(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushboolean(L, (int)tr->tr->allsolid);
return 1;
}
/***
Check whether the trace has started in solid contents.
@function GetStartsolid
@return Whether trace started solid.
*/
static int Trace_GetStartsolid(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushboolean(L, (int)tr->tr->startsolid);
return 1;
}
/***
Get fraction of trace.
@function GetFraction
@return Fraction.
*/
static int Trace_GetFraction(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->fraction);
return 1;
}
/***
Get end position of the trace.
@function GetEndpos
@return End position of the trace.
*/
static int Trace_GetEndpos(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
Lua_PushVector(L, tr->tr->endpos);
return 1;
}
/***
Get the surface flags for the face the trace hit.
@function GetSurfaceFlags
@return Surface flags.
*/
static int Trace_GetSurfaceFlags(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->surfaceFlags);
return 1;
}
/***
Get content flags for the trace.
@function GetContents
@return Content flags.
*/
static int Trace_GetContents(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->contents);
return 1;
}
/***
Get entity number for entity the trace hit.
@function GetEntityNum
@return Entity number.
*/
static int Trace_GetEntityNum(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->entityNum);
return 1;
}
/***
Get entity the trace hit.
@function GetEntity
@return entity the trace hit.
*/
static int Trace_GetEntity(lua_State *L) {
ltrace_t *tr;
gentity_t *ent;
tr = Lua_GetTrace(L, 1);
ent = &g_entities[tr->tr->entityNum];
Lua_PushEntity(L, ent);
return 1;
}
static const luaL_Reg lib_trace[] = {
{ "DoTrace", Trace_DoTrace },
{ "FreeTrace", Trace_FreeTrace },
{ NULL, NULL }
};
static const luaL_Reg Trace_meta[] = {
{ "__gc", Trace_GC },
{ "__tostring", Trace_ToString },
{ "GetAllsolid", Trace_GetAllsolid },
{ "GetStartsolid", Trace_GetStartsolid },
{ "GetFraction", Trace_GetFraction },
{ "GetEndpos", Trace_GetEndpos },
{ "GetSurfaceFlags", Trace_GetSurfaceFlags },
{ "GetContents", Trace_GetContents },
{ "GetEntityNum", Trace_GetEntityNum },
{ "GetEntity", Trace_GetEntity },
{ NULL, NULL }
};
int Luaopen_Trace(lua_State *L) {
luaL_newmetatable(L, "game.trace");
lua_pushstring(L, "__index");
lua_pushvalue(L, -2);
lua_settable(L, -3);
luaL_register(L, NULL, Trace_meta);
luaL_register(L, "trace", lib_trace);
/* Add constants */
lua_pushstring(L, "CONSTANTS");
lua_newtable(L);
Lua_RegConstInteger(L, CONTENTS_NONE);
Lua_RegConstInteger(L, CONTENTS_SOLID);
Lua_RegConstInteger(L, CONTENTS_LAVA);
Lua_RegConstInteger(L, CONTENTS_SLIME);
Lua_RegConstInteger(L, CONTENTS_WATER);
Lua_RegConstInteger(L, CONTENTS_FOG);
Lua_RegConstInteger(L, CONTENTS_LADDER);
Lua_RegConstInteger(L, CONTENTS_AREAPORTAL);
Lua_RegConstInteger(L, CONTENTS_PLAYERCLIP);
Lua_RegConstInteger(L, CONTENTS_MONSTERCLIP);
Lua_RegConstInteger(L, CONTENTS_SHOTCLIP);
Lua_RegConstInteger(L, CONTENTS_TELEPORTER);
Lua_RegConstInteger(L, CONTENTS_JUMPPAD);
Lua_RegConstInteger(L, CONTENTS_ITEM);
Lua_RegConstInteger(L, CONTENTS_CLUSTERPORTAL);
Lua_RegConstInteger(L, CONTENTS_DONOTENTER);
Lua_RegConstInteger(L, CONTENTS_BOTCLIP);
Lua_RegConstInteger(L, CONTENTS_ORIGIN);
Lua_RegConstInteger(L, CONTENTS_BODY);
Lua_RegConstInteger(L, CONTENTS_CORPSE);
Lua_RegConstInteger(L, CONTENTS_DETAIL);
Lua_RegConstInteger(L, CONTENTS_STRUCTURAL);
Lua_RegConstInteger(L, CONTENTS_TRANSLUCENT);
Lua_RegConstInteger(L, CONTENTS_TRIGGER);
Lua_RegConstInteger(L, CONTENTS_NODROP);
Lua_RegConstInteger(L, MASK_ALL);
Lua_RegConstInteger(L, MASK_SOLID);
Lua_RegConstInteger(L, MASK_PLAYERSOLID);
Lua_RegConstInteger(L, MASK_DEADSOLID);
Lua_RegConstInteger(L, MASK_WATER);
Lua_RegConstInteger(L, MASK_OPAQUE);
Lua_RegConstInteger(L, MASK_SHOT);
Lua_RegConstInteger(L, MASK_ONLYPLAYER);
Lua_RegConstInteger(L, MASK_BRUSHES);
lua_settable(L, -3);
return 1;
}
void Lua_PushTrace(lua_State * L, trace_t * tr)
{
ltrace_t *trace;
trace = (ltrace_t *)lua_newuserdata(L, sizeof(ltrace_t));
luaL_getmetatable(L, "game.trace");
lua_setmetatable(L, -2);
trace->tr = tr;
}
ltrace_t *Lua_GetTrace(lua_State * L, int argNum)
{
void *ud;
ud = luaL_checkudata(L, argNum, "game.trace");
luaL_argcheck(L, ud != NULL, argNum, "\'trace\' expected");
return (ltrace_t *) ud;
}
#endif
// lua library for trace_t
#include "g_lua.h"
#ifdef G_LUA
#include "g_syscalls.h"
/***
A module allowing to do traces. Documentation under work.
@module trace
*/
static int Trace_GC(lua_State * L)
{
return 0;
}
static int Trace_ToString(lua_State * L)
{
ltrace_t *ltrace;
trace_t *trace;
char buf[MAX_STRING_CHARS];
ltrace = Lua_GetTrace(L, 1);
trace = ltrace->tr;
Com_sprintf(buf, sizeof(buf), "trace: entity=%i fraction=%f allsolid=%i contents=%i endpos=\"%s\" startsolid=%i surfaceFlags=%i pointer=%p\n",
trace->entityNum,
trace->fraction,
trace->allsolid,
trace->contents,
vtos(trace->endpos),
trace->startsolid,
trace->surfaceFlags,
trace);
lua_pushstring(L, buf);
return 1;
}
/***
Does a trace.
@function DoTrace
@param start start-point of the trace.
@param mins minimal distance of trace (nil if unused)
@param maxs maximal distance of trace (nil if unused)
@param end end-point of trace
@param passEnt Number of ents to pass
@param contents Set content flags.
*/
static int Trace_DoTrace(lua_State *L) {
trace_t *tr;
vec_t *start, *end, *mins = NULL, *maxs = NULL;
int passEnt, contents;
start = Lua_GetVector(L, 1);
if(!lua_isnil(L, 2))
mins = Lua_GetVector(L, 2);
if(!lua_isnil(L, 3))
maxs = Lua_GetVector(L, 3);
end = Lua_GetVector(L, 4);
passEnt = (int)luaL_checknumber(L, 5);
contents = (int) luaL_checknumber(L, 6);
tr = (trace_t *)malloc(sizeof(trace_t));
if(!tr) {
LUA_DEBUG("Trace_DoTrace - was unable to allocate a trace_t.\n");
lua_pushnil(L);
return 1;
}
trap_Trace(tr, start, mins, maxs, end, passEnt, contents);
Lua_PushTrace(L, tr);
return 1;
}
/***
Frees all memory that was allocated for this trace.
@function FreeTrace
@param trace The trace.
*/
static int Trace_FreeTrace(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
if(tr && tr->tr)
free(tr->tr);
return 1;
}
/***
Check whether the trace has gone only trough solid content (e.g. only inside a wall).
@function GetAllsolid
@return Whether trace was all solid.
*/
static int Trace_GetAllsolid(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushboolean(L, (int)tr->tr->allsolid);
return 1;
}
/***
Check whether the trace has started in solid contents.
@function GetStartsolid
@return Whether trace started solid.
*/
static int Trace_GetStartsolid(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushboolean(L, (int)tr->tr->startsolid);
return 1;
}
/***
Get fraction of trace.
@function GetFraction
@return Fraction.
*/
static int Trace_GetFraction(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->fraction);
return 1;
}
/***
Get end position of the trace.
@function GetEndpos
@return End position of the trace.
*/
static int Trace_GetEndpos(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
Lua_PushVector(L, tr->tr->endpos);
return 1;
}
/***
Get the surface flags for the face the trace hit.
@function GetSurfaceFlags
@return Surface flags.
*/
static int Trace_GetSurfaceFlags(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->surfaceFlags);
return 1;
}
/***
Get content flags for the trace.
@function GetContents
@return Content flags.
*/
static int Trace_GetContents(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->contents);
return 1;
}
/***
Get entity number for entity the trace hit.
@function GetEntityNum
@return Entity number.
*/
static int Trace_GetEntityNum(lua_State *L) {
ltrace_t *tr;
tr = Lua_GetTrace(L, 1);
lua_pushnumber(L, tr->tr->entityNum);
return 1;
}
/***
Get entity the trace hit.
@function GetEntity
@return entity the trace hit.
*/
static int Trace_GetEntity(lua_State *L) {
ltrace_t *tr;
gentity_t *ent;
tr = Lua_GetTrace(L, 1);
ent = &g_entities[tr->tr->entityNum];
Lua_PushEntity(L, ent);
return 1;
}
static const luaL_Reg lib_trace[] = {
{ "DoTrace", Trace_DoTrace },
{ "FreeTrace", Trace_FreeTrace },
{ NULL, NULL }
};
static const luaL_Reg Trace_meta[] = {
{ "__gc", Trace_GC },
{ "__tostring", Trace_ToString },
{ "GetAllsolid", Trace_GetAllsolid },
{ "GetStartsolid", Trace_GetStartsolid },
{ "GetFraction", Trace_GetFraction },
{ "GetEndpos", Trace_GetEndpos },
{ "GetSurfaceFlags", Trace_GetSurfaceFlags },
{ "GetContents", Trace_GetContents },
{ "GetEntityNum", Trace_GetEntityNum },
{ "GetEntity", Trace_GetEntity },
{ NULL, NULL }
};
int Luaopen_Trace(lua_State *L) {
luaL_newmetatable(L, "game.trace");
lua_pushstring(L, "__index");
lua_pushvalue(L, -2);
lua_settable(L, -3);
luaL_register(L, NULL, Trace_meta);
luaL_register(L, "trace", lib_trace);
/* Add constants */
lua_pushstring(L, "CONSTANTS");
lua_newtable(L);
Lua_RegConstInteger(L, CONTENTS_NONE);
Lua_RegConstInteger(L, CONTENTS_SOLID);
Lua_RegConstInteger(L, CONTENTS_LAVA);
Lua_RegConstInteger(L, CONTENTS_SLIME);
Lua_RegConstInteger(L, CONTENTS_WATER);
Lua_RegConstInteger(L, CONTENTS_FOG);
Lua_RegConstInteger(L, CONTENTS_LADDER);
Lua_RegConstInteger(L, CONTENTS_AREAPORTAL);
Lua_RegConstInteger(L, CONTENTS_PLAYERCLIP);
Lua_RegConstInteger(L, CONTENTS_MONSTERCLIP);
Lua_RegConstInteger(L, CONTENTS_SHOTCLIP);
Lua_RegConstInteger(L, CONTENTS_TELEPORTER);
Lua_RegConstInteger(L, CONTENTS_JUMPPAD);
Lua_RegConstInteger(L, CONTENTS_ITEM);
Lua_RegConstInteger(L, CONTENTS_CLUSTERPORTAL);
Lua_RegConstInteger(L, CONTENTS_DONOTENTER);
Lua_RegConstInteger(L, CONTENTS_BOTCLIP);
Lua_RegConstInteger(L, CONTENTS_ORIGIN);
Lua_RegConstInteger(L, CONTENTS_BODY);
Lua_RegConstInteger(L, CONTENTS_CORPSE);
Lua_RegConstInteger(L, CONTENTS_DETAIL);
Lua_RegConstInteger(L, CONTENTS_STRUCTURAL);
Lua_RegConstInteger(L, CONTENTS_TRANSLUCENT);
Lua_RegConstInteger(L, CONTENTS_TRIGGER);
Lua_RegConstInteger(L, CONTENTS_NODROP);
Lua_RegConstInteger(L, MASK_ALL);
Lua_RegConstInteger(L, MASK_SOLID);
Lua_RegConstInteger(L, MASK_PLAYERSOLID);
Lua_RegConstInteger(L, MASK_DEADSOLID);
Lua_RegConstInteger(L, MASK_WATER);
Lua_RegConstInteger(L, MASK_OPAQUE);
Lua_RegConstInteger(L, MASK_SHOT);
Lua_RegConstInteger(L, MASK_ONLYPLAYER);
Lua_RegConstInteger(L, MASK_BRUSHES);
lua_settable(L, -3);
return 1;
}
void Lua_PushTrace(lua_State * L, trace_t * tr)
{
ltrace_t *trace;
trace = (ltrace_t *)lua_newuserdata(L, sizeof(ltrace_t));
luaL_getmetatable(L, "game.trace");
lua_setmetatable(L, -2);
trace->tr = tr;
}
ltrace_t *Lua_GetTrace(lua_State * L, int argNum)
{
void *ud;
ud = luaL_checkudata(L, argNum, "game.trace");
luaL_argcheck(L, ud != NULL, argNum, "\'trace\' expected");
return (ltrace_t *) ud;
}
#endif