codemp/game/g_saga.c File Reference

#include "g_local.h"
#include "bg_saga.h"

Go to the source code of this file.

Defines

#define SIEGEITEM_STARTOFFRADAR   8
#define SIEGE_ITEM_RESPAWN_TIME   20000

Functions

void LogExit (const char *string)
void SetTeamQuick (gentity_t *ent, int team, qboolean doBegin)
void G_SiegeRegisterWeaponsAndHoldables (int team)
void SiegeSetCompleteData (int team)
void InitSiegeMode (void)
void G_SiegeSetObjectiveComplete (int team, int objective, qboolean failIt)
qboolean G_SiegeGetCompletionStatus (int team, int objective)
void UseSiegeTarget (gentity_t *other, gentity_t *en, char *target)
void SiegeBroadcast_OBJECTIVECOMPLETE (int team, int client, int objective)
void SiegeBroadcast_ROUNDOVER (int winningteam, int winningclient)
void BroadcastObjectiveCompletion (int team, int objective, int final, int client)
void AddSiegeWinningTeamPoints (int team, int winner)
void SiegeClearSwitchData (void)
void SiegeDoTeamAssign (void)
void SiegeTeamSwitch (int winTeam, int winTime)
void SiegeRoundComplete (int winningteam, int winningclient)
void G_ValidateSiegeClassForTeam (gentity_t *ent, int team)
void SiegeRespawn (gentity_t *ent)
void SiegeBeginRound (int entNum)
void SiegeCheckTimers (void)
void SiegeObjectiveCompleted (int team, int objective, int final, int client)
void siegeTriggerUse (gentity_t *ent, gentity_t *other, gentity_t *activator)
void SP_info_siege_objective (gentity_t *ent)
void SiegeIconUse (gentity_t *ent, gentity_t *other, gentity_t *activator)
void SP_info_siege_radaricon (gentity_t *ent)
void decompTriggerUse (gentity_t *ent, gentity_t *other, gentity_t *activator)
void SP_info_siege_decomplete (gentity_t *ent)
void siegeEndUse (gentity_t *ent, gentity_t *other, gentity_t *activator)
void SP_target_siege_end (gentity_t *ent)
void SiegeItemRemoveOwner (gentity_t *ent, gentity_t *carrier)
void SiegeItemThink (gentity_t *ent)
void SiegeItemTouch (gentity_t *self, gentity_t *other, trace_t *trace)
void SiegeItemPain (gentity_t *self, gentity_t *attacker, int damage)
void SiegeItemDie (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath)
void SiegeItemUse (gentity_t *ent, gentity_t *other, gentity_t *activator)
void SP_misc_siege_item (gentity_t *ent)
void G_SiegeClientExData (gentity_t *msgTarg)

Variables

siegePers_t g_siegePersistant = {qfalse, 0, 0}
int imperial_goals_required = 0
int imperial_goals_completed = 0
int rebel_goals_required = 0
int rebel_goals_completed = 0
int imperial_time_limit = 0
int rebel_time_limit = 0
int gImperialCountdown = 0
int gRebelCountdown = 0
int rebel_attackers = 0
int imperial_attackers = 0
qboolean gSiegeRoundBegun = qfalse
qboolean gSiegeRoundEnded = qfalse
qboolean gSiegeRoundWinningTeam = 0
int gSiegeBeginTime = Q3_INFINITE
int g_preroundState = 0


Define Documentation

#define SIEGE_ITEM_RESPAWN_TIME   20000
 

Definition at line 1336 of file g_saga.c.

Referenced by SiegeItemThink().

#define SIEGEITEM_STARTOFFRADAR   8
 

Definition at line 15 of file g_saga.c.

Referenced by SiegeItemUse(), SP_info_siege_objective(), and SP_misc_siege_item().


Function Documentation

void AddSiegeWinningTeamPoints int  team,
int  winner
 

Definition at line 566 of file g_saga.c.

References AddScore(), gentity_s::client, g_entities, gentity_t, MAX_CLIENTS, playerState_s::origin, gclient_s::ps, gclient_s::sess, clientSession_t::sessionTeam, SIEGE_POINTS_FINALOBJECTIVECOMPLETED, and SIEGE_POINTS_TEAMWONROUND.

Referenced by SiegeRoundComplete().

00567 {
00568         int i = 0;
00569         gentity_t *ent;
00570 
00571         while (i < MAX_CLIENTS)
00572         {
00573                 ent = &g_entities[i];
00574 
00575                 if (ent && ent->client && ent->client->sess.sessionTeam == team)
00576                 {
00577                         if (i == winner)
00578                         {
00579                                 AddScore(ent, ent->client->ps.origin, SIEGE_POINTS_TEAMWONROUND+SIEGE_POINTS_FINALOBJECTIVECOMPLETED);
00580                         }
00581                         else
00582                         {
00583                                 AddScore(ent, ent->client->ps.origin, SIEGE_POINTS_TEAMWONROUND);
00584                         }
00585                 }
00586 
00587                 i++;
00588         }
00589 }

void BroadcastObjectiveCompletion int  team,
int  objective,
int  final,
int  client
 

Definition at line 555 of file g_saga.c.

References AddScore(), client, ENTITYNUM_NONE, g_entities, playerState_s::origin, gclient_s::ps, gclient_s::sess, clientSession_t::sessionTeam, SIEGE_POINTS_OBJECTIVECOMPLETED, and SiegeBroadcast_OBJECTIVECOMPLETE().

Referenced by SiegeObjectiveCompleted().

00556 {
00557         if (client != ENTITYNUM_NONE && g_entities[client].client && g_entities[client].client->sess.sessionTeam == team)
00558         { //guy who completed this objective gets points, providing he's on the opposing team
00559                 AddScore(&g_entities[client], g_entities[client].client->ps.origin, SIEGE_POINTS_OBJECTIVECOMPLETED);
00560         }
00561 
00562         SiegeBroadcast_OBJECTIVECOMPLETE(team, client, objective);
00563         //G_Printf("Broadcast goal completion team %i objective %i final %i\n", team, objective, final);
00564 }

void decompTriggerUse gentity_t ent,
gentity_t other,
gentity_t activator
 

Definition at line 1236 of file g_saga.c.

References atoi(), BG_SiegeGetPairedValue(), BG_SiegeGetValueGroup(), Com_sprintf(), G_SiegeGetCompletionStatus(), G_SiegeSetObjectiveComplete(), gentity_t, gSiegeRoundEnded, imperial_goals_completed, MAX_SIEGE_INFO_SIZE, gentity_s::objective, qtrue, rebel_goals_completed, gentity_s::side, siege_info, and SIEGETEAM_TEAM1.

Referenced by SP_info_siege_decomplete().

01237 {
01238         int final = 0;
01239         char teamstr[1024];
01240         char objectivestr[64];
01241         char desiredobjective[MAX_SIEGE_INFO_SIZE];
01242 
01243         if (gSiegeRoundEnded)
01244         {
01245                 return;
01246         }
01247 
01248         if (!G_SiegeGetCompletionStatus(ent->side, ent->objective))
01249         { //if it's not complete then there's nothing to do here
01250                 return;
01251         }
01252 
01253         //Update the configstring status
01254         G_SiegeSetObjectiveComplete(ent->side, ent->objective, qtrue);
01255 
01256         //Find out if this objective counts toward the final objective count
01257         if (ent->side == SIEGETEAM_TEAM1)
01258         {
01259                 Com_sprintf(teamstr, sizeof(teamstr), team1);
01260         }
01261         else
01262         {
01263                 Com_sprintf(teamstr, sizeof(teamstr), team2);
01264         }
01265 
01266         if (BG_SiegeGetValueGroup(siege_info, teamstr, gParseObjectives))
01267         {
01268                 Com_sprintf(objectivestr, sizeof(objectivestr), "Objective%i", ent->objective);
01269 
01270                 if (BG_SiegeGetValueGroup(gParseObjectives, objectivestr, desiredobjective))
01271                 {
01272                         if (BG_SiegeGetPairedValue(desiredobjective, "final", teamstr))
01273                         {
01274                                 final = atoi(teamstr);
01275                         }
01276                 }
01277         }
01278 
01279         //Subtract the goal num if applicable
01280         if (final != -1)
01281         {
01282                 if (ent->side == SIEGETEAM_TEAM1)
01283                 {
01284                         imperial_goals_completed--;
01285                 }
01286                 else
01287                 {
01288                         rebel_goals_completed--;
01289                 }
01290         }
01291 }

void G_SiegeClientExData gentity_t msgTarg  ) 
 

Definition at line 1845 of file g_saga.c.

References playerState_s::ammo, gentity_s::client, Com_sprintf(), ET_PLAYER, entityState_s::eType, g_entities, gentity_t, gentity_s::inuse, level, MAX_EXDATA_ENTS_TO_SEND, MAX_STRING_CHARS, level_locals_t::num_entities, entityState_s::number, playerState_s::origin, gclient_s::ps, Q_strcat(), gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, STAT_HEALTH, STAT_MAX_HEALTH, playerState_s::stats, strcpy(), trap_InPVS(), trap_SendServerCommand(), playerState_s::weapon, and weaponData.

Referenced by G_RunFrame().

01846 {
01847         gentity_t *ent;
01848         int count = 0;
01849         int i = 0;
01850         char str[MAX_STRING_CHARS];
01851         char scratch[MAX_STRING_CHARS];
01852 
01853         while (i < level.num_entities && count < MAX_EXDATA_ENTS_TO_SEND)
01854         {
01855                 ent = &g_entities[i];
01856 
01857                 if (ent->inuse && ent->client && msgTarg->s.number != ent->s.number &&
01858                         ent->s.eType == ET_PLAYER && msgTarg->client->sess.sessionTeam == ent->client->sess.sessionTeam &&
01859                         trap_InPVS(msgTarg->client->ps.origin, ent->client->ps.origin))
01860                 { //another client in the same pvs, send his jive
01861             if (count)
01862                         { //append a seperating space if we are not the first in the list
01863                                 Q_strcat(str, sizeof(str), " ");
01864                         }
01865                         else
01866                         { //otherwise create the prepended chunk
01867                                 strcpy(str, "sxd ");
01868                         }
01869 
01870                         //append the stats
01871                         Com_sprintf(scratch, sizeof(scratch), "%i|%i|%i|%i", ent->s.number, ent->client->ps.stats[STAT_HEALTH],
01872                                 ent->client->ps.stats[STAT_MAX_HEALTH], ent->client->ps.ammo[weaponData[ent->client->ps.weapon].ammoIndex]);
01873                         Q_strcat(str, sizeof(str), scratch);
01874                         count++;
01875                 }
01876                 i++;
01877         }
01878 
01879         if (!count)
01880         { //nothing to send
01881                 return;
01882         }
01883 
01884         //send the string to him
01885         trap_SendServerCommand(msgTarg-g_entities, str);
01886 }

qboolean G_SiegeGetCompletionStatus int  team,
int  objective
 

Definition at line 430 of file g_saga.c.

References NULL, qboolean, qfalse, qtrue, SIEGETEAM_TEAM1, SIEGETEAM_TEAM2, and strstr().

Referenced by decompTriggerUse().

00431 {
00432         char *p = NULL;
00433         int onObjective = 0;
00434 
00435         if (team == SIEGETEAM_TEAM1)
00436         {
00437                 p = strstr(gObjectiveCfgStr, "t1");
00438         }
00439         else if (team == SIEGETEAM_TEAM2)
00440         {
00441                 p = strstr(gObjectiveCfgStr, "t2");
00442         }
00443 
00444         if (!p)
00445         {
00446                 assert(0);
00447                 return qfalse;
00448         }
00449 
00450         //Parse from the beginning of this team's objectives until we get to the desired objective
00451         //number.
00452         while (p && *p && *p != '|')
00453         {
00454                 if (*p == '-')
00455                 {
00456                         onObjective++;
00457                 }
00458 
00459                 if (onObjective == objective)
00460                 { //this is the one we want
00461                         //Move to the next char, the status of this objective
00462                         p++;
00463 
00464                         //return qtrue if it's '1', qfalse if it's anything else
00465                         if (*p == '1')
00466                         {
00467                                 return qtrue;
00468                         }
00469                         else
00470                         {
00471                                 return qfalse;
00472                         }
00473                         break;
00474                 }
00475 
00476                 p++;
00477         }
00478 
00479         return qfalse;
00480 }

void G_SiegeRegisterWeaponsAndHoldables int  team  ) 
 

Definition at line 51 of file g_saga.c.

References BG_FindItemForHoldable(), BG_FindItemForWeapon(), BG_SiegeFindThemeForTeam(), siegeTeam_t::classes, HI_NUM_HOLDABLE, siegeClass_t::invenItems, siegeTeam_t::numClasses, RegisterItem(), siegeClass_t::weapons, and WP_NUM_WEAPONS.

Referenced by InitSiegeMode().

00052 {
00053         siegeTeam_t *stm = BG_SiegeFindThemeForTeam(team);
00054 
00055         if (stm)
00056         {
00057                 int i = 0;
00058                 siegeClass_t *scl;
00059                 while (i < stm->numClasses)
00060                 {
00061                         scl = stm->classes[i];
00062 
00063                         if (scl)
00064                         {
00065                                 int j = 0;
00066                                 while (j < WP_NUM_WEAPONS)
00067                                 {
00068                                         if (scl->weapons & (1 << j))
00069                                         { //we use this weapon so register it.
00070                                                 RegisterItem(BG_FindItemForWeapon(j));
00071                                         }
00072                                         j++;
00073                                 }
00074                                 j = 0;
00075                                 while (j < HI_NUM_HOLDABLE)
00076                                 {
00077                                         if (scl->invenItems & (1 << j))
00078                                         { //we use this item so register it.
00079                                                 RegisterItem(BG_FindItemForHoldable(j));
00080                                         }
00081                                         j++;
00082                                 }
00083                         }
00084                         i++;
00085                 }
00086         }
00087 }

void G_SiegeSetObjectiveComplete int  team,
int  objective,
qboolean  failIt
 

Definition at line 375 of file g_saga.c.

References CS_SIEGE_OBJECTIVES, NULL, SIEGETEAM_TEAM1, SIEGETEAM_TEAM2, strstr(), and trap_SetConfigstring().

Referenced by decompTriggerUse(), and SiegeObjectiveCompleted().

00376 {
00377         char *p = NULL;
00378         int onObjective = 0;
00379 
00380         if (team == SIEGETEAM_TEAM1)
00381         {
00382                 p = strstr(gObjectiveCfgStr, "t1");
00383         }
00384         else if (team == SIEGETEAM_TEAM2)
00385         {
00386                 p = strstr(gObjectiveCfgStr, "t2");
00387         }
00388 
00389         if (!p)
00390         {
00391                 assert(0);
00392                 return;
00393         }
00394 
00395         //Parse from the beginning of this team's objectives until we get to the desired objective
00396         //number.
00397         while (p && *p && *p != '|')
00398         {
00399                 if (*p == '-')
00400                 {
00401                         onObjective++;
00402                 }
00403 
00404                 if (onObjective == objective)
00405                 { //this is the one we want
00406                         //Move to the next char, the status of this objective
00407                         p++;
00408 
00409                         //Now change it from '0' to '1' if we are completeing the objective
00410                         //or vice versa if the objective has been taken away
00411                         if (failIt)
00412                         {
00413                                 *p = '0';
00414                         }
00415                         else
00416                         {
00417                                 *p = '1';
00418                         }
00419                         break;
00420                 }
00421 
00422                 p++;
00423         }
00424 
00425         //Now re-update the configstring.
00426         trap_SetConfigstring(CS_SIEGE_OBJECTIVES, gObjectiveCfgStr);
00427 }

void G_ValidateSiegeClassForTeam gentity_t ent,
int  team
 

Definition at line 744 of file g_saga.c.

References BG_SiegeFindClassIndexByName(), BG_SiegeFindThemeForTeam(), bgSiegeClasses, siegeTeam_t::classes, gentity_s::client, gentity_t, siegeClass_t::name, siegeTeam_t::numClasses, siegeClass_t::playerClass, Q_stricmp(), gclient_s::sess, clientSession_t::siegeClass, gclient_s::siegeClass, and strcpy().

Referenced by ClientUserinfoChanged(), and SetTeamQuick().

00745 {
00746         siegeClass_t *scl;
00747         siegeTeam_t *stm;
00748         int newClassIndex = -1;
00749         if (ent->client->siegeClass == -1)
00750         { //uh.. sure.
00751                 return;
00752         }
00753 
00754         scl = &bgSiegeClasses[ent->client->siegeClass];
00755 
00756         stm = BG_SiegeFindThemeForTeam(team);
00757         if (stm)
00758         {
00759                 int i = 0;
00760 
00761                 while (i < stm->numClasses)
00762                 { //go through the team and see its valid classes, can we find one that matches our current player class?
00763                         if (stm->classes[i])
00764                         {
00765                                 if (!Q_stricmp(scl->name, stm->classes[i]->name))
00766                                 { //the class we're using is already ok for this team.
00767                                         return;
00768                                 }
00769                                 if (stm->classes[i]->playerClass == scl->playerClass ||
00770                                         newClassIndex == -1)
00771                                 {
00772                                         newClassIndex = i;
00773                                 }
00774                         }
00775                         i++;
00776                 }
00777 
00778                 if (newClassIndex != -1)
00779                 { //ok, let's find it in the global class array
00780                         ent->client->siegeClass = BG_SiegeFindClassIndexByName(stm->classes[newClassIndex]->name);
00781                         strcpy(ent->client->sess.siegeClass, stm->classes[newClassIndex]->name);
00782                 }
00783         }
00784 }

void InitSiegeMode void   ) 
 

Definition at line 96 of file g_saga.c.

References atoi(), siegePers_s::beatingTime, BG_PrecacheSabersForSiegeTeam(), BG_SiegeGetPairedValue(), BG_SiegeGetValueGroup(), BG_SiegeLoadClasses(), BG_SiegeLoadTeams(), BG_SiegeSetTeamTheme(), bgNumSiegeClasses, bgNumSiegeTeams, Com_Printf(), Com_sprintf(), CS_SIEGE_OBJECTIVES, CS_SIEGE_TIMEOVERRIDE, CVAR_ROM, CVAR_SERVERINFO, fileHandle_t, FS_READ, G_Error(), g_gametype, g_preroundState, g_siegePersistant, G_SiegeRegisterWeaponsAndHoldables(), g_siegeTeam1, g_siegeTeam2, g_siegeTeamSwitch, gImperialCountdown, gRebelCountdown, GT_SIEGE, imperial_attackers, imperial_goals_completed, imperial_goals_required, imperial_time_limit, vmCvar_t::integer, siegePers_s::lastTime, level, MAX_SIEGE_INFO_SIZE, NULL, Q_strcat(), Q_stricmp(), rebel_attackers, rebel_goals_completed, rebel_goals_required, rebel_time_limit, siege_info, siege_valid, SiegeSetCompleteData(), SIEGETEAM_TEAM1, SIEGETEAM_TEAM2, strcpy(), vmCvar_t::string, level_locals_t::time, trap_Cvar_Register(), trap_Cvar_Set(), trap_FS_FCloseFile(), trap_FS_FOpenFile(), trap_FS_Read(), trap_SetConfigstring(), trap_SiegePersGet(), and va().

Referenced by G_InitGame().

00097 {
00098         vmCvar_t                mapname;
00099         char                    levelname[512];
00100         char                    teamIcon[128];
00101         char                    goalreq[64];
00102         char                    teams[2048];
00103         char                    objective[MAX_SIEGE_INFO_SIZE];
00104         char                    objecStr[8192];
00105         int                             len = 0;
00106         int                             i = 0;
00107 //      int                             j = 0;
00108         int                             objectiveNumTeam1 = 0;
00109         int                             objectiveNumTeam2 = 0;
00110         fileHandle_t    f;
00111 
00112         if (g_gametype.integer != GT_SIEGE)
00113         {
00114                 goto failure;
00115         }
00116 
00117         //reset
00118         SiegeSetCompleteData(0);
00119 
00120         //get pers data in case it existed from last level
00121         if (g_siegeTeamSwitch.integer)
00122         {
00123                 trap_SiegePersGet(&g_siegePersistant);
00124                 if (g_siegePersistant.beatingTime)
00125                 {
00126                         trap_SetConfigstring(CS_SIEGE_TIMEOVERRIDE, va("%i", g_siegePersistant.lastTime));
00127                 }
00128                 else
00129                 {
00130                         trap_SetConfigstring(CS_SIEGE_TIMEOVERRIDE, "0");
00131                 }
00132         }
00133         else
00134         { //hmm, ok, nothing.
00135                 trap_SetConfigstring(CS_SIEGE_TIMEOVERRIDE, "0");
00136         }
00137 
00138         imperial_goals_completed = 0;
00139         rebel_goals_completed = 0;
00140 
00141         trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );
00142 
00143         Com_sprintf(levelname, sizeof(levelname), "maps/%s.siege\0", mapname.string);
00144 
00145         if (!levelname || !levelname[0])
00146         {
00147                 goto failure;
00148         }
00149 
00150         len = trap_FS_FOpenFile(levelname, &f, FS_READ);
00151 
00152         if (!f || len >= MAX_SIEGE_INFO_SIZE)
00153         {
00154                 goto failure;
00155         }
00156 
00157         trap_FS_Read(siege_info, len, f);
00158 
00159         trap_FS_FCloseFile(f);
00160 
00161         siege_valid = 1;
00162 
00163         //See if players should be specs or ingame preround
00164         if (BG_SiegeGetPairedValue(siege_info, "preround_state", teams))
00165         {
00166                 if (teams[0])
00167                 {
00168                         g_preroundState = atoi(teams);
00169                 }
00170         }
00171 
00172         if (BG_SiegeGetValueGroup(siege_info, "Teams", teams))
00173         {
00174                 if (g_siegeTeam1.string[0] && Q_stricmp(g_siegeTeam1.string, "none"))
00175                 { //check for override
00176                         strcpy(team1, g_siegeTeam1.string);
00177                 }
00178                 else
00179                 { //otherwise use level default
00180                         BG_SiegeGetPairedValue(teams, "team1", team1);
00181                 }
00182 
00183                 if (g_siegeTeam2.string[0] && Q_stricmp(g_siegeTeam2.string, "none"))
00184                 { //check for override
00185                         strcpy(team2, g_siegeTeam2.string);
00186                 }
00187                 else
00188                 { //otherwise use level default
00189                         BG_SiegeGetPairedValue(teams, "team2", team2);
00190                 }
00191         }
00192         else
00193         {
00194                 G_Error("Siege teams not defined");
00195         }
00196 
00197         if (BG_SiegeGetValueGroup(siege_info, team2, gParseObjectives))
00198         {
00199                 if (BG_SiegeGetPairedValue(gParseObjectives, "TeamIcon", teamIcon))
00200                 {
00201                         trap_Cvar_Set( "team2_icon", teamIcon);
00202                 }
00203 
00204                 if (BG_SiegeGetPairedValue(gParseObjectives, "RequiredObjectives", goalreq))
00205                 {
00206                         rebel_goals_required = atoi(goalreq);
00207                 }
00208                 if (BG_SiegeGetPairedValue(gParseObjectives, "Timed", goalreq))
00209                 {
00210                         rebel_time_limit = atoi(goalreq)*1000;
00211                         if (g_siegeTeamSwitch.integer &&
00212                                 g_siegePersistant.beatingTime)
00213                         {
00214                                 gRebelCountdown = level.time + g_siegePersistant.lastTime;
00215                         }
00216                         else
00217                         {
00218                                 gRebelCountdown = level.time + rebel_time_limit;
00219                         }
00220                 }
00221                 if (BG_SiegeGetPairedValue(gParseObjectives, "attackers", goalreq))
00222                 {
00223                         rebel_attackers = atoi(goalreq);
00224                 }
00225         }
00226 
00227         if (BG_SiegeGetValueGroup(siege_info, team1, gParseObjectives))
00228         {
00229 
00230                 if (BG_SiegeGetPairedValue(gParseObjectives, "TeamIcon", teamIcon))
00231                 {
00232                         trap_Cvar_Set( "team1_icon", teamIcon);
00233                 }
00234 
00235                 if (BG_SiegeGetPairedValue(gParseObjectives, "RequiredObjectives", goalreq))
00236                 {
00237                         imperial_goals_required = atoi(goalreq);
00238                 }
00239                 if (BG_SiegeGetPairedValue(gParseObjectives, "Timed", goalreq))
00240                 {
00241                         if (rebel_time_limit)
00242                         {
00243                                 Com_Printf("Tried to set imperial time limit, but there's already a rebel time limit!\nOnly one team can have a time limit.\n");
00244                         }
00245                         else
00246                         {
00247                                 imperial_time_limit = atoi(goalreq)*1000;
00248                                 if (g_siegeTeamSwitch.integer &&
00249                                         g_siegePersistant.beatingTime)
00250                                 {
00251                                         gImperialCountdown = level.time + g_siegePersistant.lastTime;
00252                                 }
00253                                 else
00254                                 {
00255                                         gImperialCountdown = level.time + imperial_time_limit;
00256                                 }
00257                         }
00258                 }
00259                 if (BG_SiegeGetPairedValue(gParseObjectives, "attackers", goalreq))
00260                 {
00261                         imperial_attackers = atoi(goalreq);
00262                 }
00263         }
00264 
00265         //Load the player class types
00266         BG_SiegeLoadClasses(NULL);
00267 
00268         if (!bgNumSiegeClasses)
00269         { //We didn't find any?!
00270                 G_Error("Couldn't find any player classes for Siege");
00271         }
00272 
00273         /*
00274         //We could probably just see what teams are used on this level,
00275         //then see what classes are used by those teams, and then precache
00276         //all weapons for said classes. However, I'm just going to do them
00277         //all for now.
00278         while (i < bgNumSiegeClasses)
00279         {
00280                 cl = &bgSiegeClasses[i];
00281                 j = 0;
00282 
00283                 while (j < WP_NUM_WEAPONS)
00284                 {
00285                         if (cl->weapons & (1 << j))
00286                         { //we use this weapon so register it.
00287                                 RegisterItem(BG_FindItemForWeapon(j));
00288                         }
00289 
00290                         j++;
00291                 }
00292 
00293                 i++;
00294         }
00295         */
00296         //Ok, I'm adding inventory item precaching now, so I'm finally going to optimize this
00297         //to only do weapons/items for the current teams used on the level.
00298 
00299         //Now load the teams since we have class data.
00300         BG_SiegeLoadTeams();
00301 
00302         if (!bgNumSiegeTeams)
00303         { //React same as with classes.
00304                 G_Error("Couldn't find any player teams for Siege");
00305         }
00306 
00307         //Get and set the team themes for each team. This will control which classes can be
00308         //used on each team.
00309         if (BG_SiegeGetValueGroup(siege_info, team1, gParseObjectives))
00310         {
00311                 if (BG_SiegeGetPairedValue(gParseObjectives, "UseTeam", goalreq))
00312                 {
00313                         BG_SiegeSetTeamTheme(SIEGETEAM_TEAM1, goalreq);
00314                 }
00315 
00316                 //Now count up the objectives for this team.
00317                 i = 1;
00318                 strcpy(objecStr, va("Objective%i", i));
00319                 while (BG_SiegeGetValueGroup(gParseObjectives, objecStr, objective))
00320                 {
00321                         objectiveNumTeam1++;
00322                         i++;
00323                         strcpy(objecStr, va("Objective%i", i));
00324                 }
00325         }
00326         if (BG_SiegeGetValueGroup(siege_info, team2, gParseObjectives))
00327         {
00328                 if (BG_SiegeGetPairedValue(gParseObjectives, "UseTeam", goalreq))
00329                 {
00330                         BG_SiegeSetTeamTheme(SIEGETEAM_TEAM2, goalreq);
00331                 }
00332 
00333                 //Now count up the objectives for this team.
00334                 i = 1;
00335                 strcpy(objecStr, va("Objective%i", i));
00336                 while (BG_SiegeGetValueGroup(gParseObjectives, objecStr, objective))
00337                 {
00338                         objectiveNumTeam2++;
00339                         i++;
00340                         strcpy(objecStr, va("Objective%i", i));
00341                 }
00342         }
00343 
00344         //Set the configstring to show status of all current objectives
00345         strcpy(gObjectiveCfgStr, "t1");
00346         while (objectiveNumTeam1 > 0)
00347         { //mark them all as not completed since we just initialized
00348                 Q_strcat(gObjectiveCfgStr, 1024, "-0");
00349                 objectiveNumTeam1--;
00350         }
00351         //Finished doing team 1's objectives, now do team 2's
00352         Q_strcat(gObjectiveCfgStr, 1024, "|t2");
00353         while (objectiveNumTeam2 > 0)
00354         {
00355                 Q_strcat(gObjectiveCfgStr, 1024, "-0");
00356                 objectiveNumTeam2--;
00357         }
00358 
00359         //And finally set the actual config string
00360         trap_SetConfigstring(CS_SIEGE_OBJECTIVES, gObjectiveCfgStr);
00361 
00362         //precache saber data for classes that use sabers on both teams
00363         BG_PrecacheSabersForSiegeTeam(SIEGETEAM_TEAM1);
00364         BG_PrecacheSabersForSiegeTeam(SIEGETEAM_TEAM2);
00365 
00366         G_SiegeRegisterWeaponsAndHoldables(SIEGETEAM_TEAM1);
00367         G_SiegeRegisterWeaponsAndHoldables(SIEGETEAM_TEAM2);
00368 
00369         return;
00370 
00371 failure:
00372         siege_valid = 0;
00373 }

void LogExit const char *  string  ) 
 

Definition at line 2233 of file g_main.c.

References level_locals_t::clients, CON_CONNECTING, clientPersistant_t::connected, CS_INTERMISSION, g_gametype, G_LogPrintf(), gclient_t, GT_TEAM, vmCvar_t::integer, level_locals_t::intermissionQueued, level, clientPersistant_t::netname, level_locals_t::numConnectedClients, gclient_s::pers, PERS_SCORE, playerState_s::persistant, playerState_s::ping, gclient_s::ps, gclient_s::sess, clientSession_t::sessionTeam, level_locals_t::sortedClients, TEAM_BLUE, TEAM_RED, TEAM_SPECTATOR, level_locals_t::teamScores, level_locals_t::time, and trap_SetConfigstring().

Referenced by CheckExitRules(), siegeEndUse(), SiegeRoundComplete(), and Use_Target_Escapetrig().

02233                                    {
02234         int                             i, numSorted;
02235         gclient_t               *cl;
02236 //      qboolean                won = qtrue;
02237         G_LogPrintf( "Exit: %s\n", string );
02238 
02239         level.intermissionQueued = level.time;
02240 
02241         // this will keep the clients from playing any voice sounds
02242         // that will get cut off when the queued intermission starts
02243         trap_SetConfigstring( CS_INTERMISSION, "1" );
02244 
02245         // don't send more than 32 scores (FIXME?)
02246         numSorted = level.numConnectedClients;
02247         if ( numSorted > 32 ) {
02248                 numSorted = 32;
02249         }
02250 
02251         if ( g_gametype.integer >= GT_TEAM ) {
02252                 G_LogPrintf( "red:%i  blue:%i\n",
02253                         level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE] );
02254         }
02255 
02256         for (i=0 ; i < numSorted ; i++) {
02257                 int             ping;
02258 
02259                 cl = &level.clients[level.sortedClients[i]];
02260 
02261                 if ( cl->sess.sessionTeam == TEAM_SPECTATOR ) {
02262                         continue;
02263                 }
02264                 if ( cl->pers.connected == CON_CONNECTING ) {
02265                         continue;
02266                 }
02267 
02268                 ping = cl->ps.ping < 999 ? cl->ps.ping : 999;
02269 
02270                 G_LogPrintf( "score: %i  ping: %i  client: %i %s\n", cl->ps.persistant[PERS_SCORE], ping, level.sortedClients[i],       cl->pers.netname );
02271 //              if (g_singlePlayer.integer && (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL)) {
02272 //                      if (g_entities[cl - level.clients].r.svFlags & SVF_BOT && cl->ps.persistant[PERS_RANK] == 0) {
02273 //                              won = qfalse;
02274 //                      }
02275 //              }
02276         }
02277 
02278         //yeah.. how about not.
02279         /*
02280         if (g_singlePlayer.integer) {
02281                 if (g_gametype.integer >= GT_CTF) {
02282                         won = level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE];
02283                 }
02284                 trap_SendConsoleCommand( EXEC_APPEND, (won) ? "spWin\n" : "spLose\n" );
02285         }
02286         */
02287 }

void SetTeamQuick gentity_t ent,
int  team,
qboolean  doBegin
 

Referenced by ClientBegin(), SetTeam(), SiegeDoTeamAssign(), and SiegeRespawn().

void SiegeBeginRound int  entNum  ) 
 

Definition at line 853 of file g_saga.c.

References BG_SiegeGetPairedValue(), gentity_s::client, CS_SIEGE_STATE, g_entities, g_preroundState, G_UseTargets2(), gentity_t, gentity_s::inuse, level, MAX_CLIENTS, playerState_s::pm_flags, PMF_FOLLOW, gclient_s::ps, qboolean, qfalse, qtrue, gclient_s::sess, clientSession_t::sessionTeam, siege_info, clientSession_t::siegeDesiredTeam, SiegeRespawn(), TEAM_BLUE, TEAM_RED, TEAM_SPECTATOR, level_locals_t::time, trap_SetConfigstring(), and va().

Referenced by SiegeCheckTimers().

00854 { //entNum is just used as something to fire targets from.
00855         char targname[1024];
00856 
00857         if (!g_preroundState)
00858         { //if players are not ingame on round start then respawn them now
00859                 int i = 0;
00860                 gentity_t *ent;
00861                 qboolean spawnEnt = qfalse;
00862 
00863                 //respawn everyone now
00864                 while (i < MAX_CLIENTS)
00865                 {
00866                         ent = &g_entities[i];
00867 
00868                         if (ent->inuse && ent->client)
00869                         {
00870                                 if (ent->client->sess.sessionTeam != TEAM_SPECTATOR &&
00871                                         !(ent->client->ps.pm_flags & PMF_FOLLOW))
00872                                 { //not a spec, just respawn them
00873                                         spawnEnt = qtrue;
00874                                 }
00875                                 else if (ent->client->sess.sessionTeam == TEAM_SPECTATOR &&
00876                                         (ent->client->sess.siegeDesiredTeam == TEAM_RED ||
00877                                          ent->client->sess.siegeDesiredTeam == TEAM_BLUE))
00878                                 { //spectator but has a desired team
00879                                         spawnEnt = qtrue;
00880                                 }
00881                         }
00882 
00883                         if (spawnEnt)
00884                         {
00885                                 SiegeRespawn(ent);
00886 
00887                                 spawnEnt = qfalse;
00888                         }
00889                         i++;
00890                 }
00891         }
00892 
00893         //Now check if there's something to fire off at the round start, if so do it.
00894         if (BG_SiegeGetPairedValue(siege_info, "roundbegin_target", targname))
00895         {
00896                 if (targname[0])
00897                 {
00898                         G_UseTargets2(&g_entities[entNum], &g_entities[entNum], targname);
00899                 }
00900         }
00901 
00902         trap_SetConfigstring(CS_SIEGE_STATE, va("0|%i", level.time)); //we're ready to g0g0g0
00903 }

void SiegeBroadcast_OBJECTIVECOMPLETE int  team,
int  client,
int  objective
 

Definition at line 528 of file g_saga.c.

References client, EV_SIEGE_OBJECTIVECOMPLETE, entityState_s::eventParm, G_TempEntity(), gentity_t, gentity_s::r, gentity_s::s, SVF_BROADCAST, entityShared_t::svFlags, entityState_s::trickedentindex, vec3_t, VectorClear, and entityState_s::weapon.

Referenced by BroadcastObjectiveCompletion().

00529 {
00530         gentity_t *te;
00531         vec3_t nomatter;
00532 
00533         VectorClear(nomatter);
00534 
00535         te = G_TempEntity( nomatter, EV_SIEGE_OBJECTIVECOMPLETE );
00536         te->r.svFlags |= SVF_BROADCAST;
00537         te->s.eventParm = team;
00538         te->s.weapon = client;
00539         te->s.trickedentindex = objective;
00540 }

void SiegeBroadcast_ROUNDOVER int  winningteam,
int  winningclient
 

Definition at line 542 of file g_saga.c.

References EV_SIEGE_ROUNDOVER, entityState_s::eventParm, G_TempEntity(), gentity_t, gentity_s::r, gentity_s::s, SVF_BROADCAST, entityShared_t::svFlags, vec3_t, VectorClear, and entityState_s::weapon.

Referenced by SiegeRoundComplete().

00543 {
00544         gentity_t *te;
00545         vec3_t nomatter;
00546 
00547         VectorClear(nomatter);
00548 
00549         te = G_TempEntity( nomatter, EV_SIEGE_ROUNDOVER );
00550         te->r.svFlags |= SVF_BROADCAST;
00551         te->s.eventParm = winningteam;
00552         te->s.weapon = winningclient;
00553 }

void SiegeCheckTimers void   ) 
 

Definition at line 905 of file g_saga.c.

References siegePers_s::beatingTime, gentity_s::client, CON_CONNECTED, clientPersistant_t::connected, CS_SIEGE_STATE, ENTITYNUM_NONE, g_entities, g_gametype, g_siegePersistant, g_siegeTeamSwitch, gentity_t, gImperialCountdown, gRebelCountdown, gSiegeBeginTime, gSiegeRoundBegun, gSiegeRoundEnded, GT_SIEGE, imperial_time_limit, vmCvar_t::integer, level_locals_t::intermissiontime, gentity_s::inuse, siegePers_s::lastTime, level, MAX_CLIENTS, gclient_s::pers, qtrue, rebel_time_limit, gclient_s::sess, SIEGE_ROUND_BEGIN_TIME, SiegeBeginRound(), clientSession_t::siegeDesiredTeam, SiegeRoundComplete(), SIEGETEAM_TEAM1, SIEGETEAM_TEAM2, level_locals_t::time, trap_SetConfigstring(), and va().

Referenced by G_RunFrame().

00906 {
00907         int i=0;
00908         gentity_t *ent;
00909         int numTeam1 = 0;
00910         int numTeam2 = 0;
00911 
00912         if (g_gametype.integer != GT_SIEGE)
00913         {
00914                 return;
00915         }
00916 
00917         if (level.intermissiontime)
00918         {
00919                 return;
00920         }
00921 
00922         if (gSiegeRoundEnded)
00923         {
00924                 return;
00925         }
00926 
00927         if (!gSiegeRoundBegun)
00928         { //check if anyone is active on this team - if not, keep the timer set up.
00929                 i = 0;
00930 
00931                 while (i < MAX_CLIENTS)
00932                 {
00933                         ent = &g_entities[i];
00934 
00935                         if (ent && ent->inuse && ent->client &&
00936                                 ent->client->pers.connected == CON_CONNECTED &&
00937                                 ent->client->sess.siegeDesiredTeam == SIEGETEAM_TEAM1)
00938                         {
00939                                 numTeam1++;
00940                         }
00941                         i++;
00942                 }
00943 
00944                 i = 0;
00945 
00946                 while (i < MAX_CLIENTS)
00947                 {
00948                         ent = &g_entities[i];
00949 
00950                         if (ent && ent->inuse && ent->client &&
00951                                 ent->client->pers.connected == CON_CONNECTED &&
00952                                 ent->client->sess.siegeDesiredTeam == SIEGETEAM_TEAM2)
00953                         {
00954                                 numTeam2++;
00955                         }
00956                         i++;
00957                 }
00958 
00959                 if (g_siegeTeamSwitch.integer &&
00960                         g_siegePersistant.beatingTime)
00961                 {
00962                         gImperialCountdown = level.time + g_siegePersistant.lastTime;
00963                         gRebelCountdown = level.time + g_siegePersistant.lastTime;
00964                 }
00965                 else
00966                 {
00967                         gImperialCountdown = level.time + imperial_time_limit;
00968                         gRebelCountdown = level.time + rebel_time_limit;
00969                 }
00970         }
00971 
00972         if (imperial_time_limit)
00973         { //team1
00974                 if (gImperialCountdown < level.time)
00975                 {
00976                         SiegeRoundComplete(SIEGETEAM_TEAM2, ENTITYNUM_NONE);
00977                         imperial_time_limit = 0;
00978                         return;
00979                 }
00980         }
00981 
00982         if (rebel_time_limit)
00983         { //team2
00984                 if (gRebelCountdown < level.time)
00985                 {
00986                         SiegeRoundComplete(SIEGETEAM_TEAM1, ENTITYNUM_NONE);
00987                         rebel_time_limit = 0;
00988                         return;
00989                 }
00990         }
00991 
00992         if (!gSiegeRoundBegun)
00993         {
00994                 if (!numTeam1 || !numTeam2)
00995                 { //don't have people on both teams yet.
00996                         gSiegeBeginTime = level.time + SIEGE_ROUND_BEGIN_TIME;
00997                         trap_SetConfigstring(CS_SIEGE_STATE, "1"); //"waiting for players on both teams"
00998                 }
00999                 else if (gSiegeBeginTime < level.time)
01000                 { //mark the round as having begun
01001                         gSiegeRoundBegun = qtrue;
01002                         SiegeBeginRound(i); //perform any round start tasks
01003                 }
01004                 else if (gSiegeBeginTime > (level.time + SIEGE_ROUND_BEGIN_TIME))
01005                 {
01006                         gSiegeBeginTime = level.time + SIEGE_ROUND_BEGIN_TIME;
01007                 }
01008                 else
01009                 {
01010                         trap_SetConfigstring(CS_SIEGE_STATE, va("2|%i", gSiegeBeginTime - SIEGE_ROUND_BEGIN_TIME)); //getting ready to begin
01011                 }
01012         }
01013 }

void SiegeClearSwitchData void   ) 
 

Definition at line 591 of file g_saga.c.

References g_siegePersistant, memset(), and trap_SiegePersSet().

Referenced by Cmd_CallVote_f(), SiegeRoundComplete(), and SiegeTeamSwitch().

00592 {
00593         memset(&g_siegePersistant, 0, sizeof(g_siegePersistant));
00594         trap_SiegePersSet(&g_siegePersistant);
00595 }

void SiegeDoTeamAssign void   ) 
 

Definition at line 597 of file g_saga.c.

References gentity_s::client, CON_CONNECTED, clientPersistant_t::connected, g_entities, gentity_t, gentity_s::inuse, MAX_CLIENTS, gclient_s::pers, qfalse, gclient_s::sess, clientSession_t::sessionTeam, SetTeamQuick(), clientSession_t::siegeDesiredTeam, SIEGETEAM_TEAM1, and SIEGETEAM_TEAM2.

Referenced by ExitLevel().

00598 {
00599         int i = 0;
00600         gentity_t *ent;
00601 
00602         //yeah, this is great...
00603         while (i < MAX_CLIENTS)
00604         {
00605                 ent = &g_entities[i];
00606 
00607                 if (ent->inuse && ent->client &&
00608                         ent->client->pers.connected == CON_CONNECTED)
00609                 { //a connected client, switch his frickin teams around
00610                         if (ent->client->sess.siegeDesiredTeam == SIEGETEAM_TEAM1)
00611                         {
00612                                 ent->client->sess.siegeDesiredTeam = SIEGETEAM_TEAM2;
00613                         }
00614                         else if (ent->client->sess.siegeDesiredTeam == SIEGETEAM_TEAM2)
00615                         {
00616                                 ent->client->sess.siegeDesiredTeam = SIEGETEAM_TEAM1;
00617                         }
00618 
00619                         if (ent->client->sess.sessionTeam == SIEGETEAM_TEAM1)
00620                         {
00621                                 SetTeamQuick(ent, SIEGETEAM_TEAM2, qfalse);
00622                         }
00623                         else if (ent->client->sess.sessionTeam == SIEGETEAM_TEAM2)
00624                         {
00625                                 SetTeamQuick(ent, SIEGETEAM_TEAM1, qfalse);
00626                         }
00627                 }
00628                 i++;
00629         }
00630 }

void siegeEndUse gentity_t ent,
gentity_t other,
gentity_t activator
 

Definition at line 1317 of file g_saga.c.

References gentity_t, and LogExit().

Referenced by SP_target_siege_end().

01318 {
01319         LogExit("Round ended");
01320 }

void SiegeIconUse gentity_t ent,
gentity_t other,
gentity_t activator
 

Definition at line 1182 of file g_saga.c.

References EF_RADAROBJECT, entityState_s::eFlags, gentity_t, gentity_s::r, gentity_s::s, SVF_BROADCAST, and entityShared_t::svFlags.

Referenced by SP_info_siege_radaricon().

01183 { //toggle it on and off
01184         if (ent->s.eFlags & EF_RADAROBJECT)
01185         {
01186                 ent->s.eFlags &= ~EF_RADAROBJECT;
01187                 ent->r.svFlags &= ~SVF_BROADCAST;
01188         }
01189         else
01190         {
01191                 ent->s.eFlags |= EF_RADAROBJECT;
01192                 ent->r.svFlags |= SVF_BROADCAST;
01193         }
01194 }

void SiegeItemDie gentity_t self,
gentity_t inflictor,
gentity_t attacker,
int  damage,
int  meansOfDeath
 

Definition at line 1553 of file g_saga.c.

References entityShared_t::currentOrigin, G_FreeEntity(), G_PlayEffectID(), G_UseTargets2(), gentity_s::genericValue3, gentity_t, level, gentity_s::neverFree, gentity_s::nextthink, qfalse, gentity_s::r, gentity_s::takedamage, gentity_s::target4, gentity_s::think, level_locals_t::time, vec3_t, and VectorSet.

Referenced by SP_misc_siege_item().

01554 {
01555         self->takedamage = qfalse; //don't die more than once
01556 
01557         if (self->genericValue3)
01558         { //An indexed effect to play on death
01559                 vec3_t upAng;
01560 
01561                 VectorSet(upAng, 0, 0, 1);
01562                 G_PlayEffectID(self->genericValue3, self->r.currentOrigin, upAng);
01563         }
01564 
01565         self->neverFree = qfalse;
01566         self->think = G_FreeEntity;
01567         self->nextthink = level.time;
01568 
01569         //Fire off the death target if we've got one.
01570         if (self->target4 && self->target4[0])
01571         {
01572                 G_UseTargets2(self, self, self->target4);
01573         }
01574 }

void SiegeItemPain gentity_t self,
gentity_t attacker,
int  damage
 

Definition at line 1547 of file g_saga.c.

References gentity_t, level, gentity_s::s, level_locals_t::time, and entityState_s::time2.

Referenced by SP_misc_siege_item().

01548 {
01549         // Time 2 is used to pulse the radar icon to show its under attack
01550         self->s.time2 = level.time;
01551 }

void SiegeItemRemoveOwner gentity_t ent,
gentity_t carrier
 

Definition at line 1338 of file g_saga.c.

References gentity_s::client, ENTITYNUM_NONE, gentity_s::genericValue2, gentity_s::genericValue8, gentity_t, gclient_s::holdingObjectiveItem, gentity_s::r, SVF_BROADCAST, and entityShared_t::svFlags.

Referenced by multi_trigger(), and SiegeItemThink().

01339 {
01340         ent->genericValue2 = 0; //Remove picked-up flag
01341 
01342         ent->genericValue8 = ENTITYNUM_NONE; //Mark entity carrying us as none
01343 
01344         if (carrier)
01345         {
01346                 carrier->client->holdingObjectiveItem = 0; //The carrier is no longer carrying us
01347                 carrier->r.svFlags &= ~SVF_BROADCAST;
01348         }
01349 }

void SiegeItemThink gentity_t ent  ) 
 

Definition at line 1382 of file g_saga.c.

References entityState_s::boltToPlayer, gentity_s::client, CONTENTS_NODROP, entityShared_t::currentOrigin, ENTITYNUM_NONE, gentity_s::epVelocity, FRAMETIME, g_entities, G_RunExPhys(), G_SetOrigin(), G_UseTargets2(), gentity_s::genericValue1, gentity_s::genericValue12, gentity_s::genericValue13, gentity_s::genericValue14, gentity_s::genericValue8, gentity_s::genericValue9, gentity_t, gentity_s::health, gentity_s::inuse, level, gentity_s::mass, MAX_CLIENTS, gentity_s::maxHealth, gentity_s::nextthink, NULL, entityState_s::number, playerState_s::origin, playerState_s::pm_flags, PMF_FOLLOW, gentity_s::pos1, gclient_s::ps, Q_irand(), qfalse, gentity_s::r, gentity_s::radius, gentity_s::random, gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, SIEGE_ITEM_RESPAWN_TIME, SiegeItemRemoveOwner(), SIEGETEAM_TEAM1, SIEGETEAM_TEAM2, gentity_s::target6, level_locals_t::time, entityState_s::time2, trap_LinkEntity(), trap_PointContents(), and VectorCopy.

Referenced by SiegeItemUse(), and SP_misc_siege_item().

01383 {
01384         gentity_t *carrier = NULL;
01385 
01386         if (ent->genericValue12)
01387         { //recharge health
01388                 if (ent->health > 0 && ent->health < ent->maxHealth && ent->genericValue14 < level.time)
01389                 {
01390             ent->genericValue14 = level.time + ent->genericValue13;
01391                         ent->health += ent->genericValue12;
01392                         if (ent->health > ent->maxHealth)
01393                         {
01394                                 ent->health = ent->maxHealth;
01395                         }
01396                 }
01397         }
01398 
01399         if (ent->genericValue8 != ENTITYNUM_NONE)
01400         { //Just keep sticking it on top of the owner. We need it in the same PVS as him so it will render bolted onto him properly.
01401                 carrier = &g_entities[ent->genericValue8];
01402 
01403                 if (carrier->inuse && carrier->client)
01404                 {
01405                         VectorCopy(carrier->client->ps.origin, ent->r.currentOrigin);
01406                         trap_LinkEntity(ent);
01407                 }
01408         }
01409         else if (ent->genericValue1)
01410         { //this means we want to run physics on the object
01411                 G_RunExPhys(ent, ent->radius, ent->mass, ent->random, qfalse, NULL, 0);
01412         }
01413 
01414         //Bolt us to whoever is carrying us if a client
01415         if (ent->genericValue8 < MAX_CLIENTS)
01416         {
01417                 ent->s.boltToPlayer = ent->genericValue8+1;
01418         }
01419         else
01420         {
01421                 ent->s.boltToPlayer = 0;
01422         }
01423 
01424 
01425         if (carrier)
01426         {
01427                 gentity_t *carrier = &g_entities[ent->genericValue8];
01428 
01429                 //This checking can be a bit iffy on the death stuff, but in theory we should always
01430                 //get a think in before the default minimum respawn time is exceeded.
01431                 if (!carrier->inuse || !carrier->client ||
01432                         (carrier->client->sess.sessionTeam != SIEGETEAM_TEAM1 && carrier->client->sess.sessionTeam != SIEGETEAM_TEAM2) ||
01433                         (carrier->client->ps.pm_flags & PMF_FOLLOW))
01434                 { //respawn on the original spot
01435                         SiegeItemRespawnOnOriginalSpot(ent, NULL);
01436                 }
01437                 else if (carrier->health < 1)
01438                 { //The carrier died so pop out where he is (unless in nodrop).
01439                         if (ent->target6 && ent->target6[0])
01440                         {
01441                                 G_UseTargets2(ent, ent, ent->target6);
01442                         }
01443 
01444                         if ( trap_PointContents(carrier->client->ps.origin, carrier->s.number) & CONTENTS_NODROP )
01445                         { //In nodrop land, go back to the original spot.
01446                                 SiegeItemRespawnOnOriginalSpot(ent, carrier);
01447                         }
01448                         else
01449                         {
01450                                 G_SetOrigin(ent, carrier->client->ps.origin);
01451                                 ent->epVelocity[0] = Q_irand(-80, 80);
01452                                 ent->epVelocity[1] = Q_irand(-80, 80);
01453                                 ent->epVelocity[2] = Q_irand(40, 80);
01454 
01455                                 //We're in a nonstandard place, so if we go this long without being touched,
01456                                 //assume we may not be reachable and respawn on the original spot.
01457                                 ent->genericValue9 = level.time + SIEGE_ITEM_RESPAWN_TIME;
01458 
01459                                 SiegeItemRemoveOwner(ent, carrier);
01460                         }
01461                 }
01462         }
01463 
01464         if (ent->genericValue9 && ent->genericValue9 < level.time)
01465         { //time to respawn on the original spot then
01466                 SiegeItemRespawnEffect(ent, ent->pos1);
01467                 G_SetOrigin(ent, ent->pos1);
01468                 ent->genericValue9 = 0;
01469                 
01470                 // stop flashing on radar
01471                 ent->s.time2 = 0;
01472         }
01473 
01474         ent->nextthink = level.time + FRAMETIME/2;
01475 }

void SiegeItemTouch gentity_t self,
gentity_t other,
trace_t trace
 

Definition at line 1477 of file g_saga.c.

References CHAN_AUTO, gentity_s::client, entityShared_t::currentOrigin, ET_NPC, entityState_s::eType, G_SetOrigin(), G_Sound(), G_UseTargets2(), gentity_s::genericValue2, gentity_s::genericValue4, gentity_s::genericValue5, gentity_s::genericValue6, gentity_s::genericValue8, gentity_s::genericValue9, gentity_t, gSiegeRoundBegun, gentity_s::health, gclient_s::holdingObjectiveItem, gentity_s::inuse, gentity_s::noise_index, entityState_s::number, PM_SPECTATOR, playerState_s::pm_type, gclient_s::ps, gentity_s::r, gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, trace_t::startsolid, SVF_BROADCAST, entityShared_t::svFlags, gentity_s::target2, entityState_s::time2, vec3_t, and VectorCopy.

Referenced by SiegeItemUse(), and SP_misc_siege_item().

01478 {
01479         if (!other || !other->inuse ||
01480                 !other->client || other->s.eType == ET_NPC)
01481         {
01482                 if (trace && trace->startsolid)
01483                 { //let me out! (ideally this should not happen, but such is life)
01484                         vec3_t escapePos;
01485                         VectorCopy(self->r.currentOrigin, escapePos);
01486                         escapePos[2] += 1.0f;
01487 
01488                         //I hope you weren't stuck in the ceiling.
01489                         G_SetOrigin(self, escapePos);
01490                 }
01491                 return;
01492         }
01493 
01494         if (other->health < 1)
01495         { //dead people can't pick us up.
01496                 return;
01497         }
01498 
01499         if (other->client->holdingObjectiveItem)
01500         { //this guy's already carrying a siege item
01501                 return;
01502         }
01503 
01504         if ( other->client->ps.pm_type == PM_SPECTATOR )
01505         {//spectators don't pick stuff up
01506                 return;
01507         }
01508 
01509         if (self->genericValue2)
01510         { //Am I already picked up?
01511                 return;
01512         }
01513 
01514         if (self->genericValue6 == other->client->sess.sessionTeam)
01515         { //Set to not be touchable by players on this team.
01516                 return;
01517         }
01518 
01519         if (!gSiegeRoundBegun)
01520         { //can't pick it up if round hasn't started yet
01521                 return;
01522         }
01523 
01524         if (self->noise_index)
01525         { //play the pickup noise.
01526                 G_Sound(other, CHAN_AUTO, self->noise_index);
01527         }
01528 
01529         self->genericValue2 = 1; //Mark it as picked up.
01530 
01531         other->client->holdingObjectiveItem = self->s.number;
01532         other->r.svFlags |= SVF_BROADCAST; //broadcast player while he carries this
01533         self->genericValue8 = other->s.number; //Keep the index so we know who is "carrying" us
01534 
01535         self->genericValue9 = 0; //So it doesn't think it has to respawn.
01536 
01537         if (self->target2 && self->target2[0] && (!self->genericValue4 || !self->genericValue5))
01538         { //fire the target for pickup, if it's set to fire every time, or set to only fire the first time and the first time has not yet occured.
01539                 G_UseTargets2(self, self, self->target2);
01540                 self->genericValue5 = 1; //mark it as having been picked up
01541         }       
01542         
01543         // time2 set to -1 will blink the item on the radar indefinately
01544         self->s.time2 = 0xFFFFFFFF;
01545 }

void SiegeItemUse gentity_t ent,
gentity_t other,
gentity_t activator
 

Definition at line 1576 of file g_saga.c.

References gentity_s::clipmask, entityShared_t::contents, CONTENTS_SOLID, CONTENTS_TERRAIN, CONTENTS_TRIGGER, entityShared_t::currentOrigin, EF_NODRAW, EF_RADAROBJECT, entityState_s::eFlags, FOFS, FRAMETIME, G_Find(), G_SetOrigin(), gentity_s::genericValue11, gentity_t, gentity_s::inuse, level, MASK_PLAYERSOLID, gentity_s::nextthink, NULL, gentity_s::paintarget, gentity_s::r, gentity_s::s, SIEGEITEM_STARTOFFRADAR, SiegeItemThink(), SiegeItemTouch(), gentity_s::spawnflags, gentity_s::takedamage, gentity_s::think, level_locals_t::time, gentity_s::touch, and trap_LinkEntity().

Referenced by SP_misc_siege_item().

01577 { //once used, become active
01578         if (ent->spawnflags & SIEGEITEM_STARTOFFRADAR)
01579         { //start showing on radar
01580                 ent->s.eFlags |= EF_RADAROBJECT;
01581 
01582                 if (!(ent->s.eFlags & EF_NODRAW))
01583                 { //we've nothing else to do here
01584                         return;
01585                 }
01586         }
01587         else
01588         { //make sure it's showing up
01589                 ent->s.eFlags |= EF_RADAROBJECT;
01590         }
01591 
01592         if (ent->genericValue11 || !ent->takedamage)
01593         { //We want to be able to walk into it to pick it up then.
01594                 ent->r.contents = CONTENTS_TRIGGER;
01595                 ent->clipmask = CONTENTS_SOLID|CONTENTS_TERRAIN;
01596                 if (ent->genericValue11)
01597                 {
01598                         ent->touch = SiegeItemTouch;
01599                 }
01600         }
01601         else
01602         { //Make it solid.
01603                 ent->r.contents = MASK_PLAYERSOLID;
01604                 ent->clipmask = MASK_PLAYERSOLID;
01605         }
01606 
01607         ent->think = SiegeItemThink;
01608         ent->nextthink = level.time + FRAMETIME/2;
01609 
01610         //take off nodraw
01611         ent->s.eFlags &= ~EF_NODRAW;
01612 
01613         if (ent->paintarget && ent->paintarget[0])
01614         { //want to be on this guy's origin now then
01615                 gentity_t *targ = G_Find (NULL, FOFS(targetname), ent->paintarget);
01616                 
01617                 if (targ && targ->inuse)
01618                 {
01619                         G_SetOrigin(ent, targ->r.currentOrigin);
01620                         trap_LinkEntity(ent);
01621                 }
01622         }
01623 }

void SiegeObjectiveCompleted int  team,
int  objective,
int  final,
int  client
 

Definition at line 1015 of file g_saga.c.

References BroadcastObjectiveCompletion(), client, G_SiegeSetObjectiveComplete(), gSiegeRoundEnded, imperial_goals_completed, imperial_goals_required, qfalse, rebel_goals_completed, rebel_goals_required, SiegeRoundComplete(), and SIEGETEAM_TEAM1.

Referenced by siegeTriggerUse().

01016 {
01017         int goals_completed, goals_required;
01018 
01019         if (gSiegeRoundEnded)
01020         {
01021                 return;
01022         }
01023 
01024         //Update the configstring status
01025         G_SiegeSetObjectiveComplete(team, objective, qfalse);
01026 
01027         if (final != -1)
01028         {
01029                 if (team == SIEGETEAM_TEAM1)
01030                 {
01031                         imperial_goals_completed++;
01032                 }
01033                 else
01034                 {
01035                         rebel_goals_completed++;
01036                 }
01037         }
01038 
01039         if (team == SIEGETEAM_TEAM1)
01040         {
01041                 goals_completed = imperial_goals_completed;
01042                 goals_required = imperial_goals_required;
01043         }
01044         else
01045         {
01046                 goals_completed = rebel_goals_completed;
01047                 goals_required = rebel_goals_required;
01048         }
01049 
01050         if (final == 1 || goals_completed >= goals_required)
01051         {
01052                 SiegeRoundComplete(team, client);
01053         }
01054         else
01055         {
01056                 BroadcastObjectiveCompletion(team, objective, final, client);
01057         }
01058 }

void SiegeRespawn gentity_t ent  ) 
 

Definition at line 836 of file g_saga.c.

References gentity_s::client, entityState_s::clientNum, ClientSpawn(), EV_PLAYER_TELEPORT_IN, G_TempEntity(), gentity_t, playerState_s::origin, gclient_s::ps, qtrue, gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, SetTeamQuick(), and clientSession_t::siegeDesiredTeam.

Referenced by respawn(), and SiegeBeginRound().

00837 {
00838         gentity_t *tent;
00839 
00840         if (ent->client->sess.sessionTeam != ent->client->sess.siegeDesiredTeam)
00841         {
00842                 SetTeamQuick(ent, ent->client->sess.siegeDesiredTeam, qtrue);
00843         }
00844         else
00845         {
00846                 ClientSpawn(ent);
00847                 // add a teleportation effect
00848                 tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
00849                 tent->s.clientNum = ent->s.clientNum;
00850         }
00851 }

void SiegeRoundComplete int  winningteam,
int  winningclient
 

Definition at line 654 of file g_saga.c.

References AddSiegeWinningTeamPoints(), BG_SiegeGetPairedValue(), BG_SiegeGetValueGroup(), gentity_s::client, Com_sprintf(), CS_SIEGE_STATE, ENTITYNUM_NONE, g_entities, g_siegeTeamSwitch, G_UseTargets2(), gentity_t, gImperialCountdown, gRebelCountdown, gSiegeRoundBegun, gSiegeRoundEnded, gSiegeRoundWinningTeam, imperial_time_limit, vmCvar_t::integer, gentity_s::inuse, level, LogExit(), MAX_CLIENTS, entityState_s::number, qfalse, qtrue, rebel_time_limit, gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, siege_info, SiegeBroadcast_ROUNDOVER(), SiegeClearSwitchData(), SIEGETEAM_TEAM1, SiegeTeamSwitch(), level_locals_t::time, trap_SetConfigstring(), va(), vec3_t, and VectorClear.

Referenced by SiegeCheckTimers(), and SiegeObjectiveCompleted().

00655 {
00656         vec3_t nomatter;
00657         char teamstr[1024];
00658         int originalWinningClient = winningclient;
00659 
00660         //G_Printf("Team %i won\n", winningteam);
00661 
00662         if (winningclient != ENTITYNUM_NONE && g_entities[winningclient].client &&
00663                 g_entities[winningclient].client->sess.sessionTeam != winningteam)
00664         { //this person just won the round for the other team..
00665                 winningclient = ENTITYNUM_NONE;
00666         }
00667 
00668         VectorClear(nomatter);
00669 
00670         SiegeBroadcast_ROUNDOVER(winningteam, winningclient);
00671 
00672         AddSiegeWinningTeamPoints(winningteam, winningclient);
00673 
00674         //Instead of exiting like this, fire off a target, and let it handle things.
00675         //Can be a script or whatever the designer wants.
00676         if (winningteam == SIEGETEAM_TEAM1)
00677         {
00678                 Com_sprintf(teamstr, sizeof(teamstr), team1);
00679         }
00680         else
00681         {
00682                 Com_sprintf(teamstr, sizeof(teamstr), team2);
00683         }
00684 
00685         trap_SetConfigstring(CS_SIEGE_STATE, va("3|%i", level.time)); //ended
00686         gSiegeRoundBegun = qfalse;
00687         gSiegeRoundEnded = qtrue;
00688         gSiegeRoundWinningTeam = winningteam;
00689 
00690         if (BG_SiegeGetValueGroup(siege_info, teamstr, gParseObjectives))
00691         {
00692                 if (!BG_SiegeGetPairedValue(gParseObjectives, "roundover_target", teamstr))
00693                 { //didn't find the name of the thing to target upon win, just logexit now then.
00694                         LogExit( "Objectives completed" );
00695                         return;
00696                 }
00697                 
00698                 if (originalWinningClient == ENTITYNUM_NONE)
00699                 { //oh well, just find something active and use it then.
00700             int i = 0;
00701                         gentity_t *ent;
00702 
00703                         while (i < MAX_CLIENTS)
00704                         {
00705                                 ent = &g_entities[i];
00706 
00707                                 if (ent->inuse)
00708                                 { //sure, you'll do.
00709                     originalWinningClient = ent->s.number;
00710                                         break;
00711                                 }
00712 
00713                                 i++;
00714                         }
00715                 }
00716                 G_UseTargets2(&g_entities[originalWinningClient], &g_entities[originalWinningClient], teamstr);
00717         }
00718 
00719         if (g_siegeTeamSwitch.integer &&
00720                 (imperial_time_limit || rebel_time_limit))
00721         { //handle stupid team switching crap
00722                 int time = 0;
00723                 if (imperial_time_limit)
00724                 {
00725                         time = imperial_time_limit-(gImperialCountdown-level.time);
00726                 }
00727                 else if (rebel_time_limit)
00728                 {
00729                         time = rebel_time_limit-(gRebelCountdown-level.time);
00730                 }
00731 
00732                 if (time < 1)
00733                 {
00734                         time = 1;
00735                 }
00736                 SiegeTeamSwitch(winningteam, time);
00737         }
00738         else
00739         { //assure it's clear for next round
00740                 SiegeClearSwitchData();
00741         }
00742 }

void SiegeSetCompleteData int  team  ) 
 

Definition at line 91 of file g_saga.c.

References CS_SIEGE_WINTEAM, trap_SetConfigstring(), and va().

Referenced by InitSiegeMode(), and SiegeTeamSwitch().

00092 {
00093         trap_SetConfigstring(CS_SIEGE_WINTEAM, va("%i", team));
00094 }

void SiegeTeamSwitch int  winTeam,
int  winTime
 

Definition at line 632 of file g_saga.c.

References siegePers_s::beatingTime, g_siegePersistant, siegePers_s::lastTeam, siegePers_s::lastTime, qtrue, SiegeClearSwitchData(), SiegeSetCompleteData(), trap_SiegePersGet(), and trap_SiegePersSet().

Referenced by SiegeRoundComplete().

00633 {
00634         trap_SiegePersGet(&g_siegePersistant);
00635         if (g_siegePersistant.beatingTime)
00636         { //was already in "switched" mode, change back
00637                 //announce the winning team.
00638                 //either the first team won again, or the second
00639                 //team beat the time set by the initial team. In any
00640                 //case the winTeam here is the overall winning team.
00641                 SiegeSetCompleteData(winTeam);
00642                 SiegeClearSwitchData();
00643         }
00644         else
00645         { //go into "beat their time" mode
00646                 g_siegePersistant.beatingTime = qtrue;
00647         g_siegePersistant.lastTeam = winTeam;
00648                 g_siegePersistant.lastTime = winTime;
00649 
00650                 trap_SiegePersSet(&g_siegePersistant);
00651         }
00652 }

void siegeTriggerUse gentity_t ent,
gentity_t other,
gentity_t activator
 

Definition at line 1060 of file g_saga.c.

References atoi(), BG_SiegeGetPairedValue(), BG_SiegeGetValueGroup(), gentity_s::client, Com_sprintf(), EF_RADAROBJECT, entityState_s::eFlags, ENTITYNUM_NONE, gentity_t, MAX_SIEGE_INFO_SIZE, entityState_s::number, gentity_s::objective, gentity_s::s, gentity_s::side, siege_info, siege_valid, SiegeObjectiveCompleted(), SIEGETEAM_TEAM1, gentity_s::target, and UseSiegeTarget().

Referenced by SP_info_siege_objective().

01061 {
01062         char                    teamstr[64];
01063         char                    objectivestr[64];
01064         char                    desiredobjective[MAX_SIEGE_INFO_SIZE];
01065         int                             clUser = ENTITYNUM_NONE;
01066         int                             final = 0;
01067         int                             i = 0;
01068 
01069         if (!siege_valid)
01070         {
01071                 return;
01072         }
01073 
01074         if (!(ent->s.eFlags & EF_RADAROBJECT))
01075         { //toggle radar on and exit if it is not showing up already
01076                 ent->s.eFlags |= EF_RADAROBJECT;
01077                 return;
01078         }
01079 
01080         if (activator && activator->client)
01081         { //activator will hopefully be the person who triggered this event
01082                 clUser = activator->s.number;
01083         }
01084 
01085         if (ent->side == SIEGETEAM_TEAM1)
01086         {
01087                 Com_sprintf(teamstr, sizeof(teamstr), team1);
01088         }
01089         else
01090         {
01091                 Com_sprintf(teamstr, sizeof(teamstr), team2);
01092         }
01093 
01094         if (BG_SiegeGetValueGroup(siege_info, teamstr, gParseObjectives))
01095         {
01096                 Com_sprintf(objectivestr, sizeof(objectivestr), "Objective%i", ent->objective);
01097 
01098                 if (BG_SiegeGetValueGroup(gParseObjectives, objectivestr, desiredobjective))
01099                 {
01100                         if (BG_SiegeGetPairedValue(desiredobjective, "final", teamstr))
01101                         {
01102                                 final = atoi(teamstr);
01103                         }
01104 
01105                         if (BG_SiegeGetPairedValue(desiredobjective, "target", teamstr))
01106                         {
01107                                 while (teamstr[i])
01108                                 {
01109                                         if (teamstr[i] == '\r' ||
01110                                                 teamstr[i] == '\n')
01111                                         {
01112                                                 teamstr[i] = '\0';
01113                                         }
01114 
01115                                         i++;
01116                                 }
01117                                 UseSiegeTarget(other, activator, teamstr);
01118                         }
01119 
01120                         if (ent->target && ent->target[0])
01121                         { //use this too
01122                                 UseSiegeTarget(other, activator, ent->target);
01123                         }
01124 
01125                         SiegeObjectiveCompleted(ent->side, ent->objective, final, clUser);
01126                 }
01127         }
01128 }

void SP_info_siege_decomplete gentity_t ent  ) 
 

Definition at line 1297 of file g_saga.c.

References decompTriggerUse(), G_FreeEntity(), g_gametype, G_Printf(), G_SpawnInt(), gentity_t, GT_SIEGE, vmCvar_t::integer, gentity_s::objective, gentity_s::side, siege_valid, and gentity_s::use.

01298 {
01299         if (!siege_valid || g_gametype.integer != GT_SIEGE)
01300         {
01301                 G_FreeEntity(ent);
01302                 return;
01303         }
01304 
01305         ent->use = decompTriggerUse;
01306         G_SpawnInt( "objective", "0", &ent->objective);
01307         G_SpawnInt( "side", "0", &ent->side);
01308 
01309         if (!ent->objective || !ent->side)
01310         { //j00 fux0red something up
01311                 G_FreeEntity(ent);
01312                 G_Printf("ERROR: info_siege_objective_decomplete without an objective or side value\n");
01313                 return;
01314         }
01315 }

void SP_info_siege_objective gentity_t ent  ) 
 

Definition at line 1137 of file g_saga.c.

References entityState_s::brokenLimbs, EF_RADAROBJECT, entityState_s::eFlags, entityState_s::frame, G_FreeEntity(), g_gametype, G_IconIndex(), G_Printf(), G_SpawnInt(), G_SpawnString(), entityState_s::genericenemyindex, gentity_t, GT_SIEGE, vmCvar_t::integer, gentity_s::objective, gentity_s::r, gentity_s::s, gentity_s::side, siege_valid, SIEGEITEM_STARTOFFRADAR, siegeTriggerUse(), gentity_s::spawnflags, SVF_BROADCAST, entityShared_t::svFlags, trap_LinkEntity(), and gentity_s::use.

01138 {
01139         char* s;
01140 
01141         if (!siege_valid || g_gametype.integer != GT_SIEGE)
01142         {
01143                 G_FreeEntity(ent);
01144                 return;
01145         }
01146 
01147         ent->use = siegeTriggerUse;
01148         G_SpawnInt( "objective", "0", &ent->objective);
01149         G_SpawnInt( "side", "0", &ent->side);
01150 
01151         if (!ent->objective || !ent->side)
01152         { //j00 fux0red something up
01153                 G_FreeEntity(ent);
01154                 G_Printf("ERROR: info_siege_objective without an objective or side value\n");
01155                 return;
01156         }
01157 
01158         //Set it up to be drawn on radar
01159         if (!(ent->spawnflags & SIEGEITEM_STARTOFFRADAR))
01160         {
01161                 ent->s.eFlags |= EF_RADAROBJECT;
01162         }
01163 
01164         //All clients want to know where it is at all times for radar
01165         ent->r.svFlags |= SVF_BROADCAST;
01166 
01167         G_SpawnString( "icon", "", &s );
01168         
01169         if (s && s[0])
01170         { 
01171                 // We have an icon, so index it now.  We are reusing the genericenemyindex
01172                 // variable rather than adding a new one to the entity state.
01173                 ent->s.genericenemyindex = G_IconIndex(s);
01174         }
01175 
01176         ent->s.brokenLimbs = ent->side;
01177         ent->s.frame = ent->objective;
01178         trap_LinkEntity(ent);
01179 }

void SP_info_siege_radaricon gentity_t ent  ) 
 

Definition at line 1203 of file g_saga.c.

References Com_Error(), EF_RADAROBJECT, entityState_s::eFlags, ERR_DROP, G_FreeEntity(), g_gametype, G_IconIndex(), G_SpawnInt(), G_SpawnString(), entityState_s::genericenemyindex, gentity_t, GT_SIEGE, vmCvar_t::integer, gentity_s::r, gentity_s::s, siege_valid, SiegeIconUse(), SVF_BROADCAST, entityShared_t::svFlags, trap_LinkEntity(), and gentity_s::use.

01204 {
01205         char* s;
01206         int i;
01207 
01208         if (!siege_valid || g_gametype.integer != GT_SIEGE)
01209         {
01210                 G_FreeEntity(ent);
01211                 return;
01212         }
01213 
01214         G_SpawnInt("startoff", "0", &i);
01215 
01216         if (!i)
01217         { //start on then
01218                 ent->s.eFlags |= EF_RADAROBJECT;
01219                 ent->r.svFlags |= SVF_BROADCAST;
01220         }
01221 
01222         G_SpawnString( "icon", "", &s );
01223         if (!s || !s[0])
01224         { //that's the whole point of the entity
01225         Com_Error(ERR_DROP, "misc_siege_radaricon without an icon");
01226                 return;
01227         }
01228 
01229         ent->use = SiegeIconUse;
01230 
01231         ent->s.genericenemyindex = G_IconIndex(s);
01232 
01233         trap_LinkEntity(ent);
01234 }

void SP_misc_siege_item gentity_t ent  ) 
 

Definition at line 1676 of file g_saga.c.

References entityState_s::angles, entityState_s::apos, gentity_s::clipmask, entityShared_t::contents, CONTENTS_SOLID, CONTENTS_TERRAIN, CONTENTS_TRIGGER, entityShared_t::currentAngles, gentity_s::die, EF_CLIENTSMOOTH, EF_NODRAW, EF_RADAROBJECT, entityState_s::eFlags, ENTITYNUM_NONE, ET_GENERAL, entityState_s::eType, FRAMETIME, G_EffectIndex(), G_Error(), G_FreeEntity(), g_gametype, G_IconIndex(), G_ModelIndex(), G_ScaleNetHealth(), G_SetOrigin(), G_SoundIndex(), G_SpawnFloat(), G_SpawnInt(), G_SpawnString(), G_SpawnVector(), entityState_s::genericenemyindex, gentity_s::genericValue1, gentity_s::genericValue10, gentity_s::genericValue11, gentity_s::genericValue12, gentity_s::genericValue13, gentity_s::genericValue15, gentity_s::genericValue3, gentity_s::genericValue4, gentity_s::genericValue6, gentity_s::genericValue7, gentity_s::genericValue8, gentity_t, GT_SIEGE, gentity_s::health, vmCvar_t::integer, level, MASK_PLAYERSOLID, gentity_s::mass, gentity_s::maxHealth, entityShared_t::maxs, entityShared_t::mins, gentity_s::model, entityState_s::modelGhoul2, entityState_s::modelindex, gentity_s::neverFree, gentity_s::nextthink, gentity_s::noise_index, entityState_s::origin, gentity_s::pain, gentity_s::pos1, Q_stricmp(), qfalse, qtrue, gentity_s::r, gentity_s::radius, gentity_s::random, gentity_s::s, siege_valid, SIEGEITEM_STARTOFFRADAR, SiegeItemDie(), SiegeItemPain(), SiegeItemThink(), SiegeItemTouch(), SiegeItemUse(), gentity_s::spawnflags, strlen(), SVF_BROADCAST, entityShared_t::svFlags, gentity_s::takedamage, gentity_s::targetname, gentity_s::think, level_locals_t::time, gentity_s::touch, trap_LinkEntity(), trajectory_t::trBase, gentity_s::use, and VectorCopy.

01677 {
01678         int             canpickup;
01679         int             noradar;
01680         char    *s;
01681 
01682         if (!siege_valid || g_gametype.integer != GT_SIEGE)
01683         {
01684                 G_FreeEntity(ent);
01685                 return;
01686         }
01687 
01688         if (!ent->model || !ent->model[0])
01689         {
01690                 G_Error("You must specify a model for misc_siege_item types.");
01691         }
01692 
01693         G_SpawnInt("canpickup", "1", &canpickup);
01694         G_SpawnInt("usephysics", "1", &ent->genericValue1);
01695 
01696         if (ent->genericValue1)
01697         { //if we're using physics we want lerporigin smoothing
01698                 ent->s.eFlags |= EF_CLIENTSMOOTH;
01699         }
01700 
01701         G_SpawnInt("noradar", "0", &noradar);
01702         //Want it to always show up as a goal object on radar
01703         if (!noradar && !(ent->spawnflags & SIEGEITEM_STARTOFFRADAR))
01704         {
01705                 ent->s.eFlags |= EF_RADAROBJECT;
01706         }
01707 
01708         //All clients want to know where it is at all times for radar
01709         ent->r.svFlags |= SVF_BROADCAST;
01710 
01711         G_SpawnInt("pickuponlyonce", "1", &ent->genericValue4);
01712 
01713         G_SpawnInt("teamnotouch", "0", &ent->genericValue6);
01714         G_SpawnInt("teamnocomplete", "0", &ent->genericValue7);
01715         
01716         //Get default physics values.
01717         G_SpawnFloat("mass", "0.09", &ent->mass);
01718         G_SpawnFloat("gravity", "3.0", &ent->radius);
01719         G_SpawnFloat("bounce", "1.3", &ent->random);
01720 
01721         G_SpawnString( "pickupsound", "", &s );
01722 
01723         if (s && s[0])
01724         { //We have a pickup sound, so index it now.
01725                 ent->noise_index = G_SoundIndex(s);
01726         }
01727 
01728         G_SpawnString( "deathfx", "", &s );
01729 
01730         if (s && s[0])
01731         { //We have a death effect, so index it now.
01732                 ent->genericValue3 = G_EffectIndex(s);
01733         }
01734 
01735         G_SpawnString( "respawnfx", "", &s );
01736 
01737         if (s && s[0])
01738         { //We have a respawn effect, so index it now.
01739                 ent->genericValue10 = G_EffectIndex(s);
01740         }
01741 
01742         G_SpawnString( "icon", "", &s );
01743         
01744         if (s && s[0])
01745         { 
01746                 // We have an icon, so index it now.  We are reusing the genericenemyindex
01747                 // variable rather than adding a new one to the entity state.
01748                 ent->s.genericenemyindex = G_IconIndex(s);
01749         }
01750         
01751         ent->s.modelindex = G_ModelIndex(ent->model);
01752 
01753         //Is the model a ghoul2 model?
01754         if (!Q_stricmp(&ent->model[strlen(ent->model) - 4], ".glm"))
01755         { //apparently so.
01756         ent->s.modelGhoul2 = 1;
01757         }
01758 
01759         ent->s.eType = ET_GENERAL;
01760 
01761         //Set the mins/maxs with default values.
01762         G_SpawnVector("mins", "-16 -16 -24", ent->r.mins);
01763         G_SpawnVector("maxs", "16 16 32", ent->r.maxs);
01764 
01765         VectorCopy(ent->s.origin, ent->pos1); //store off the initial origin for respawning
01766         G_SetOrigin(ent, ent->s.origin);
01767 
01768         VectorCopy(ent->s.angles, ent->r.currentAngles);
01769         VectorCopy(ent->s.angles, ent->s.apos.trBase);
01770 
01771         G_SpawnInt("forcelimit", "0", &ent->genericValue15);
01772 
01773         if (ent->health > 0)
01774         { //If it has health, it can be killed.
01775                 int t;
01776 
01777                 ent->pain = SiegeItemPain;
01778                 ent->die = SiegeItemDie;
01779                 ent->takedamage = qtrue;
01780 
01781                 G_SpawnInt( "showhealth", "0", &t );
01782                 if (t)
01783                 { //a non-0 maxhealth value will mean we want to show the health on the hud
01784                         ent->maxHealth = ent->health;
01785                         G_ScaleNetHealth(ent);
01786 
01787                         G_SpawnInt( "health_chargeamt", "0", &ent->genericValue12);
01788                         G_SpawnInt( "health_chargerate", "0", &ent->genericValue13);
01789                 }
01790         }
01791         else
01792         { //Otherwise no.
01793                 ent->takedamage = qfalse;
01794         }
01795 
01796         if (ent->spawnflags & SIEGEITEM_STARTOFFRADAR)
01797         {
01798                 ent->use = SiegeItemUse;
01799         }
01800         else if (ent->targetname && ent->targetname[0])
01801         {
01802                 ent->s.eFlags |= EF_NODRAW; //kind of hacky, but whatever
01803                 ent->genericValue11 = canpickup;
01804         ent->use = SiegeItemUse;
01805                 ent->s.eFlags &= ~EF_RADAROBJECT;
01806         }
01807 
01808         if ( (!ent->targetname || !ent->targetname[0]) ||
01809                  (ent->spawnflags & SIEGEITEM_STARTOFFRADAR) )
01810         {
01811                 if (canpickup || !ent->takedamage)
01812                 { //We want to be able to walk into it to pick it up then.
01813                         ent->r.contents = CONTENTS_TRIGGER;
01814                         ent->clipmask = CONTENTS_SOLID|CONTENTS_TERRAIN;
01815                         if (canpickup)
01816                         {
01817                                 ent->touch = SiegeItemTouch;
01818                         }
01819                 }
01820                 else
01821                 { //Make it solid.
01822                         ent->r.contents = MASK_PLAYERSOLID;
01823                         ent->clipmask = MASK_PLAYERSOLID;
01824                 }
01825 
01826                 ent->think = SiegeItemThink;
01827                 ent->nextthink = level.time + FRAMETIME/2;
01828         }
01829 
01830         ent->genericValue8 = ENTITYNUM_NONE; //initialize the carrier to none
01831 
01832         ent->neverFree = qtrue; //never free us unless we specifically request it.
01833 
01834         trap_LinkEntity(ent);
01835 }

void SP_target_siege_end gentity_t ent  ) 
 

Definition at line 1325 of file g_saga.c.

References G_FreeEntity(), g_gametype, gentity_t, GT_SIEGE, vmCvar_t::integer, siege_valid, siegeEndUse(), and gentity_s::use.

01326 {
01327         if (!siege_valid || g_gametype.integer != GT_SIEGE)
01328         {
01329                 G_FreeEntity(ent);
01330                 return;
01331         }
01332 
01333         ent->use = siegeEndUse;
01334 }

void UseSiegeTarget gentity_t other,
gentity_t en,
char *  target
 

Definition at line 482 of file g_saga.c.

References gentity_s::client, FOFS, G_Find(), G_Printf(), gentity_t, GlobalUse(), gentity_s::inuse, NULL, and gentity_s::use.

Referenced by siegeTriggerUse().

00483 { //actually use the player which triggered the object which triggered the siege objective to trigger the target
00484         gentity_t               *t;
00485         gentity_t               *ent;
00486 
00487         if ( !en || !en->client )
00488         { //looks like we don't have access to a player, so just use the activating entity
00489                 ent = other;
00490         }
00491         else
00492         {
00493                 ent = en;
00494         }
00495 
00496         if (!en)
00497         {
00498                 return;
00499         }
00500 
00501         if ( !target )
00502         {
00503                 return;
00504         }
00505 
00506         t = NULL;
00507         while ( (t = G_Find (t, FOFS(targetname), target)) != NULL )
00508         {
00509                 if ( t == ent )
00510                 {
00511                         G_Printf ("WARNING: Entity used itself.\n");
00512                 }
00513                 else
00514                 {
00515                         if ( t->use )
00516                         {
00517                                 GlobalUse(t, ent, ent);
00518                         }
00519                 }
00520                 if ( !ent->inuse )
00521                 {
00522                         G_Printf("entity was removed while using targets\n");
00523                         return;
00524                 }
00525         }
00526 }


Variable Documentation

int g_preroundState = 0
 

Definition at line 41 of file g_saga.c.

Referenced by InitSiegeMode(), and SiegeBeginRound().

siegePers_t g_siegePersistant = {qfalse, 0, 0}
 

Definition at line 20 of file g_saga.c.

Referenced by ExitLevel(), InitSiegeMode(), SiegeCheckTimers(), SiegeClearSwitchData(), and SiegeTeamSwitch().

int gImperialCountdown = 0
 

Definition at line 30 of file g_saga.c.

Referenced by InitSiegeMode(), SiegeCheckTimers(), and SiegeRoundComplete().

int gRebelCountdown = 0
 

Definition at line 31 of file g_saga.c.

Referenced by InitSiegeMode(), SiegeCheckTimers(), and SiegeRoundComplete().

int gSiegeBeginTime = Q3_INFINITE
 

Definition at line 39 of file g_saga.c.

Referenced by SiegeCheckTimers().

qboolean gSiegeRoundBegun = qfalse
 

Definition at line 36 of file g_saga.c.

qboolean gSiegeRoundEnded = qfalse
 

Definition at line 37 of file g_saga.c.

qboolean gSiegeRoundWinningTeam = 0
 

Definition at line 38 of file g_saga.c.

Referenced by FindIntermissionPoint(), and SiegeRoundComplete().

int imperial_attackers = 0
 

Definition at line 34 of file g_saga.c.

Referenced by InitSiegeMode(), and SiegeTakesPriority().

int imperial_goals_completed = 0
 

Definition at line 23 of file g_saga.c.

Referenced by decompTriggerUse(), InitSiegeMode(), and SiegeObjectiveCompleted().

int imperial_goals_required = 0
 

Definition at line 22 of file g_saga.c.

Referenced by InitSiegeMode(), and SiegeObjectiveCompleted().

int imperial_time_limit = 0
 

Definition at line 27 of file g_saga.c.

Referenced by InitSiegeMode(), SiegeCheckTimers(), and SiegeRoundComplete().

int rebel_attackers = 0
 

Definition at line 33 of file g_saga.c.

Referenced by InitSiegeMode(), and SiegeTakesPriority().

int rebel_goals_completed = 0
 

Definition at line 25 of file g_saga.c.

Referenced by decompTriggerUse(), InitSiegeMode(), and SiegeObjectiveCompleted().

int rebel_goals_required = 0
 

Definition at line 24 of file g_saga.c.

Referenced by InitSiegeMode(), and SiegeObjectiveCompleted().

int rebel_time_limit = 0
 

Definition at line 28 of file g_saga.c.

Referenced by InitSiegeMode(), SiegeCheckTimers(), and SiegeRoundComplete().