From c40e76e9b40755d8568f2cbe9efee4db6eaeb453 Mon Sep 17 00:00:00 2001 From: Walter Julius Hennecke Date: Wed, 19 Mar 2014 00:44:36 +0100 Subject: [PATCH] - updates to g_combat.c - moved some functions - renamed some functions --- code/game/g_active.c | 25 +- code/game/g_active.h | 18 + code/game/g_breakable.c | 3 +- code/game/g_breakable.h | 5 +- code/game/g_client.c | 720 ++++++++++++++++++- code/game/g_client.h | 357 +++++----- code/game/g_cmds.c | 287 ++++---- code/game/g_combat.c | 1488 ++++++++++----------------------------- code/game/g_combat.h | 87 ++- code/game/g_fx.c | 15 +- code/game/g_items.c | 6 +- code/game/g_local.h | 98 --- code/game/g_missile.c | 15 +- code/game/g_missile.h | 1 + code/game/g_mover.c | 14 +- code/game/g_target.c | 8 +- code/game/g_trigger.c | 4 +- code/game/g_turrets.c | 5 +- code/game/g_usable.c | 2 +- code/game/g_utils.c | 3 +- code/game/g_weapon.c | 27 +- code/game/lua_game.c | 967 ++++++++++++------------- code/game/lua_weapons.c | 245 +++---- 23 files changed, 2179 insertions(+), 2221 deletions(-) diff --git a/code/game/g_active.c b/code/game/g_active.c index df1c508..e6ff5eb 100644 --- a/code/game/g_active.c +++ b/code/game/g_active.c @@ -227,7 +227,7 @@ static void P_WorldEffects( gentity_t *ent ) { // don't play a normal pain sound ent->pain_debounce_time = level.time + 200; - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Combat_Damage (ent, NULL, NULL, NULL, NULL, ent->damage, DAMAGE_NO_ARMOR, MOD_WATER); } } @@ -245,12 +245,12 @@ static void P_WorldEffects( gentity_t *ent ) { && ent->pain_debounce_time < level.time ) { if (ent->watertype & CONTENTS_LAVA) { - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Combat_Damage (ent, NULL, NULL, NULL, NULL, 30*waterlevel, 0, MOD_LAVA); } if (ent->watertype & CONTENTS_SLIME) { - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Combat_Damage (ent, NULL, NULL, NULL, NULL, 10*waterlevel, 0, MOD_SLIME); } } @@ -634,14 +634,10 @@ static qboolean bDetInit = qfalse; //-----------------------------------------------------------------------------DECOY TEMP extern qboolean FinishSpawningDecoy( gentity_t* ent, int32_t itemIndex ); //-----------------------------------------------------------------------------DECOY TEMP -void DetonateDetpack(gentity_t* ent); #define DETPACK_DAMAGE 750 #define DETPACK_RADIUS 500 -/** -* The detpack has been shot -*/ void detpack_shot( gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32_t damage, int32_t meansOfDeath ) { int32_t i = 0; @@ -651,7 +647,7 @@ void detpack_shot( gentity_t* self, gentity_t* inflictor, gentity_t* attacker, i self->takedamage = qfalse; G_TempEntity(self->s.origin, EV_GRENADE_EXPLODE); - G_RadiusDamage( self->s.origin, self->parent?self->parent:self, DETPACK_DAMAGE*0.125, DETPACK_RADIUS*0.25, + G_Combat_RadiusDamage( self->s.origin, self->parent?self->parent:self, DETPACK_DAMAGE*0.125, DETPACK_RADIUS*0.25, self, DAMAGE_ALL_TEAMS, MOD_DETPACK ); // we're blowing up cuz we've been shot, so make sure we remove ourselves //from our parent's inventory (so to speak) @@ -871,8 +867,7 @@ static void DetpackBlammoThink(gentity_t* ent) /** * Detonate a detpack */ -void DetonateDetpack(gentity_t *ent) -{ +void DetonateDetpack(gentity_t *ent) { // find all detpacks. the one whose parent is ent...blow up gentity_t* detpack = NULL; char* classname = BG_FindClassnameForHoldable(HI_DETPACK); @@ -898,7 +893,7 @@ void DetonateDetpack(gentity_t *ent) detpack->takedamage = qfalse; G_AddEvent(detpack, EV_DETPACK, 0); - G_RadiusDamage( detpack->s.origin, detpack->parent, DETPACK_DAMAGE, DETPACK_RADIUS, + G_Combat_RadiusDamage( detpack->s.origin, detpack->parent, DETPACK_DAMAGE, DETPACK_RADIUS, detpack, DAMAGE_HALF_NOTLOS|DAMAGE_ALL_TEAMS, MOD_DETPACK ); // just turn the model invisible and let the entity think for a bit to deliver a shockwave //G_FreeEntity(detpack); @@ -1061,7 +1056,7 @@ void ShieldTouch(gentity_t* self, gentity_t* other, trace_t* trace) if ( other == NULL || other->client == NULL ) return; - if (IsAdmin(other) || (rpg_borgAdapt.integer && rpg_borgMoveThroughFields.integer != 0 && IsBorg(other))/*other->client->sess.sessionClass == PC_ADMIN*/ ) + if (G_Client_IsAdmin(other) || (rpg_borgAdapt.integer && rpg_borgMoveThroughFields.integer != 0 && G_Client_IsBorg(other))/*other->client->sess.sessionClass == PC_ADMIN*/ ) { ShieldGoNotSolid(self); } @@ -1488,7 +1483,7 @@ void Decoy_CheckForSolidity( gentity_t *ent ) { * Use function for decoy, removes it if activator is an player and admin */ void DecoyUse ( gentity_t *self, gentity_t *other, gentity_t *activator ) { - if ( activator == NULL || !IsAdmin( activator ) || activator->client == NULL ) + if ( activator == NULL || !G_Client_IsAdmin( activator ) || activator->client == NULL ) return; G_FreeEntity( self ); @@ -1695,7 +1690,7 @@ static void ClientEvents( gentity_t *ent, int oldEventSequence ) { damage = 0; } ent->pain_debounce_time = level.time + 200; // no normal pain sound - G_Damage (ent, NULL, NULL, NULL, NULL, damage, DAMAGE_ARMOR_PIERCING, MOD_FALLING); + G_Combat_Damage (ent, NULL, NULL, NULL, NULL, damage, DAMAGE_ARMOR_PIERCING, MOD_FALLING); break; @@ -1846,7 +1841,7 @@ void G_ThrowWeapon( gentity_t *ent, char *txt ) item = BG_FindItemForWeapon( ps->weapon ); // admins don't lose weapon when thrown - if ( IsAdmin( ent ) == qfalse ) { + if ( G_Client_IsAdmin( ent ) == qfalse ) { ps->ammo[ ps->weapon ] -= 1; if (ps->ammo[ ps->weapon ] <= 0) { ps->stats[STAT_WEAPONS] &= ~( 1 << ps->weapon ); diff --git a/code/game/g_active.h b/code/game/g_active.h index 8886f44..f7e520c 100644 --- a/code/game/g_active.h +++ b/code/game/g_active.h @@ -2,8 +2,26 @@ #define _G_ACTIVE_H #include "g_local.h" +/** + * @brief The detonation pack has been activated. + * @param self The detonation pack. + * @param inflictor The inflicting entity. + * @param attacker The attacking entity. + * @param damage Amount of damage. + * @param meansOfDeath The means of death. + */ void detpack_shot( gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32_t damage, int32_t meansOfDeath ); +/** + * @brief Places a decoy of the player. + * @param ent The player. + */ qboolean PlaceDecoy(gentity_t *ent); +/** + * @brief Detonate a detonation pack. + * @param ent The detonation pack. + */ +void DetonateDetpack(gentity_t* ent); + #endif /* _G_ACTIVE_H */ \ No newline at end of file diff --git a/code/game/g_breakable.c b/code/game/g_breakable.c index 0a3749c..3367d95 100644 --- a/code/game/g_breakable.c +++ b/code/game/g_breakable.c @@ -2,6 +2,7 @@ #include "g_breakable.h" #include "g_spawn.h" #include "g_items.h" +#include "g_combat.h" /** * \brief A func_breakables health has sunk to or under zero @@ -64,7 +65,7 @@ void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, // Ok, we are allowed to explode, so do it now! if ( (self->splashDamage > 0) && (self->splashRadius > 0) ) { //fixme: what about chain reactions? - G_RadiusDamage( org, attacker, self->splashDamage, self->splashRadius, self, DAMAGE_RADIUS|DAMAGE_ALL_TEAMS, MOD_EXPLOSION ); + G_Combat_RadiusDamage( org, attacker, self->splashDamage, self->splashRadius, self, DAMAGE_RADIUS|DAMAGE_ALL_TEAMS, MOD_EXPLOSION ); //explosion effect te = G_TempEntity( org, EV_MISSILE_MISS ); diff --git a/code/game/g_breakable.h b/code/game/g_breakable.h index 3dff618..ff64db7 100644 --- a/code/game/g_breakable.h +++ b/code/game/g_breakable.h @@ -1,8 +1,9 @@ #ifndef G_BREAKABLE_H_ #define G_BREAKABLE_H_ -void breakable_use(gentity_t *self, gentity_t *other, gentity_t *activator); -void breakable_pain( gentity_t *self, gentity_t *attacker, int32_t damage ); +void InitBBrush(gentity_t* ent); +void breakable_use(gentity_t* self, gentity_t* other, gentity_t* activator); +void breakable_pain(gentity_t* self, gentity_t* attacker, int32_t damage); #endif /* G_BREAKABLE_H_ */ diff --git a/code/game/g_client.c b/code/game/g_client.c index 646a91a..4377983 100644 --- a/code/game/g_client.c +++ b/code/game/g_client.c @@ -9,6 +9,7 @@ #include "g_spawn.h" #include "g_items.h" #include "g_lua.h" +#include "g_logger.h" reconData_t g_reconData[MAX_RECON_NAMES]; //!< recon data for a limited ammount of clients int32_t g_reconNum; @@ -472,7 +473,6 @@ void G_Client_SetViewAngle( gentity_t *ent, vec3_t angle ) { G_Client_Respawn ================ */ -extern char *ClassNameForValue( pclass_t pClass ); void G_Client_Respawn( gentity_t *ent ) { qboolean borg = qfalse; gentity_t* tent = NULL; @@ -1168,7 +1168,7 @@ void G_Client_UserinfoChanged( int32_t clientNum ) { s = va("n\\%s\\t\\%i\\p\\%i\\model\\%s\\hc\\%i\\w\\%i\\l\\%i\\age\\%s\\height\\%s\\weight\\%s\\race\\%s\\of\\%i\\admin\\%i", pers->netname, sess->sessionTeam, sess->sessionClass, model, pers->maxHealth, sess->wins, sess->losses, age, - sHeight, sWeight, race, modelOffset, ((int)IsAdmin(g_entities+clientNum))); + sHeight, sWeight, race, modelOffset, ((int)G_Client_IsAdmin(g_entities+clientNum))); } trap_SetConfigstring( CS_PLAYERS+clientNum, s ); @@ -1344,7 +1344,7 @@ char* G_Client_Connect( int32_t clientNum, qboolean firstTime, qboolean isBot ) if ( changeRank ) { ent->client->UpdateScore = qtrue; - SetScore( ent, tmpScore ); + G_Client_SetScore( ent, tmpScore ); } } @@ -1550,7 +1550,7 @@ void G_Client_Begin( int32_t clientNum, qboolean careAboutWarmup, qboolean isBot client->ps.eFlags = flags; client->UpdateScore = qtrue; - SetScore( ent, score ); + G_Client_SetScore( ent, score ); // locate ent at a spawn point G_Client_Spawn( ent, 0, qfalse );//RPG-X: RedTechie - Modifyed @@ -2229,7 +2229,7 @@ void G_Client_Disconnect( int32_t clientNum ) { // They don't get to take powerups with them! // Especially important for stuff like CTF flags - TossClientItems ( ent, qtrue ); + G_Client_TossClientItems ( ent, qtrue ); } G_LogPrintf( "ClientDisconnect: %i (%s)\n", clientNum, g_entities[clientNum].client->pers.ip ); @@ -2285,7 +2285,7 @@ RPG-X | Phenix | 21/11/2004 * \author Ubergames - Phenix * \date 21/11/2004 */ -qboolean IsAdmin( gentity_t *ent) +qboolean G_Client_IsAdmin( gentity_t *ent) { if ( ent == NULL ) { return qfalse; @@ -2790,7 +2790,7 @@ void G_Client_UpdateSoundZones(void) { if(strlen(supdate) != 0) { Com_sprintf(supdate, sizeof(supdate), "%s\\c%d\\%d", supdate, i, zones[i]); } else { - Com_sprintf(supdate, sizeof(supdate), "cd%\\%d", i, zones[i]); + Com_sprintf(supdate, sizeof(supdate), "c%d\\%d", i, zones[i]); } } @@ -2800,3 +2800,709 @@ void G_Client_UpdateSoundZones(void) { } } } + +void G_Client_SetScore(gentity_t* ent, int32_t score) { + + G_Assert(ent, (void)0); + G_Assert(ent->client, (void)0); + + if (!ent->client->UpdateScore) { + return; + } + + ent->client->ps.persistant[PERS_SCORE] = score; + G_Client_CalculateRanks(qfalse); + + // TiM: send the current scoring to all clients + SendScoreboardMessageToAllClients(); + + //RPG-X: RedTechie - Lets enable score updating without this scores will not be updated + ent->client->UpdateScore = qfalse; +} + +void G_Client_TossClientItems(gentity_t* self, qboolean dis_con) { + double angle = 0; + int32_t i = 0; + int32_t times = 0; + gentity_t* drop = NULL; + playerState_t *ps = NULL; + gitem_t* item = NULL; + + G_Assert(self, (void)0); + G_Assert(self->client, (void)0); + + ps = &self->client->ps; + + if ((self->flags & FL_CLOAK) != 0) { + // remove the invisible powerup if the player is cloaked. + //RPG-X: RedTechie - Also remove ghost + ps->powerups[PW_GHOST] = level.time; + ps->powerups[PW_INVIS] = level.time; + } + + if ((self->flags & FL_FLY) != 0) { + // remove the flying powerup if the player is flying. + ps->powerups[PW_FLIGHT] = level.time; + } + + //RPG-X | Phenix | 8/8/2004 + if ((self->flags & FL_EVOSUIT) != 0) { + // remove the evosuit powerup + ps->powerups[PW_EVOSUIT] = level.time; + } + + // drop all the powerups if not in teamplay + if (g_gametype.integer != GT_TEAM) { + angle = 45; + for (i = 1; i < PW_NUM_POWERUPS; i++) { + if (ps->powerups[i] > level.time) { + item = BG_FindItemForPowerup(i); + if (item == NULL) { + continue; + } + + drop = Drop_Item(self, item, angle); + // decide how many seconds it has left + drop->count = (ps->powerups[i] - level.time) / 1000; + if (drop->count < 1) { + drop->count = 1; + } + angle += 45; + } + } + } + + // RPG-X | Marcin | 30/12/2008 + // ... + if (rpg_allowWeaponDrop.integer == 0 || rpg_dropOnDeath.integer == 0 || dis_con) { + return; + } + + // Drop ALL weapons in inventory + for (i = 0; i < WP_NUM_WEAPONS; ++i) { + // these weapons should not be tossed (hand and null) + if (Max_Weapons[i] == NULL) { + continue; + } + + //RPG-X | GSIO01 | 08/05/2009: let's make sure we only drop weapons the player has + item = NULL; + if (ps->ammo[i]) { + times = ps->ammo[i]; + item = BG_FindItemForWeapon((weapon_t)i); + while (times-- > 0) { // the 'goes towards' operator :p + Drop_Item(self, item, 0); + } + } + } + + // then remove weapons + + for (i = 0; i < WP_NUM_WEAPONS; ++i) { + ps->stats[STAT_WEAPONS] &= ~i; + ps->ammo[i] = 0; + } +} + +void body_die(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32_t damage, int32_t meansOfDeath) { + int32_t contents = 0; + + G_Assert(self, (void)0); + + contents = trap_PointContents(self->r.currentOrigin, -1); + if (rpg_medicsrevive.integer == 1 && !(contents & CONTENTS_NODROP) && (meansOfDeath != MOD_TRIGGER_HURT)) { + if (self->health > GIB_HEALTH_IMPOSSIBLE) { + return; + } + + } else { + if (self->health > GIB_HEALTH) { + return; + } + } + G_Combat_GibEntity(self, 0); +} + +char* G_Client_ClassNameForValue(pclass_t pClass) { + static char buffer[MAX_QPATH]; + char *ptr = NULL; + + trap_Cvar_VariableStringBuffer(va("rpg_%sPass", g_classData[pClass].consoleName), buffer, sizeof(buffer)); + + ptr = buffer; + + return ptr; +} + +// these are just for logging, the client prints its own messages +char* modNames[MOD_MAX] = { + "MOD_UNKNOWN", + + "MOD_WATER", + "MOD_SLIME", + "MOD_LAVA", + "MOD_CRUSH", + "MOD_TELEFRAG", + "MOD_FALLING", + "MOD_SUICIDE", + "MOD_TARGET_LASER", + "MOD_TRIGGER_HURT", + + // Trek weapons + "MOD_PHASER", + "MOD_PHASER_ALT", + "MOD_CRIFLE", + "MOD_CRIFLE_SPLASH", + "MOD_CRIFLE_ALT", + "MOD_CRIFLE_ALT_SPLASH", + "MOD_IMOD", + "MOD_IMOD_ALT", + "MOD_SCAVENGER", + "MOD_SCAVENGER_ALT", + "MOD_SCAVENGER_ALT_SPLASH", + "MOD_STASIS", + "MOD_STASIS_ALT", + "MOD_GRENADE", + "MOD_GRENADE_ALT", + "MOD_GRENADE_SPLASH", + "MOD_GRENADE_ALT_SPLASH", + "MOD_TETRYON", + "MOD_TETRYON_ALT", + "MOD_DREADNOUGHT", + "MOD_DREADNOUGHT_ALT", + "MOD_QUANTUM", + "MOD_QUANTUM_SPLASH", + "MOD_QUANTUM_ALT", + "MOD_QUANTUM_ALT_SPLASH", + + "MOD_DETPACK", + "MOD_SEEKER" + + //expansion pack + "MOD_KNOCKOUT", + "MOD_ASSIMILATE", + "MOD_BORG", + "MOD_BORG_ALT", + + "MOD_RESPAWN", + "MOD_EXPLOSION", +}; //must be kept up to date with bg_public, meansOfDeath_t + +/* +================== +G_Client_Die +Heavly Modifyed By: RedTechie +RPG-X: Marcin: a little bit modified - 30/12/2008 +================== +*/ +void G_Client_Die(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32_t damage, int32_t meansOfDeath) { + //--------------------- + //RPG-X: RedTechie - Check to see if medics revive people and not respawn if true use my fake death insead :) + //--------------------- + int32_t contents = 0; + + G_Assert(self, (void)0); + G_Assert(self->client, (void)0); + + //RPG-X: RedTechie - Make sure there not getting killed by a trigger kill or the medics wont be able to heal them + contents = trap_PointContents(self->r.currentOrigin, -1); + + if (rpg_medicsrevive.integer == 1 && !(contents & CONTENTS_NODROP) && (meansOfDeath != MOD_TRIGGER_HURT)) { + char* classname = NULL; + char* killerName = NULL; + char* obit = NULL; + int32_t anim = 0; + int32_t killer = 0; + int32_t i = 0; + gentity_t* detpack = NULL; + gentity_t* ent = NULL; + playerState_t* ps = &self->client->ps; + + //RPG-X: RedTechie - Blow up a detpack if some one placed it and died + classname = BG_FindClassnameForHoldable(HI_DETPACK); + if (classname != NULL) { + while ((detpack = G_Find(detpack, FOFS(classname), classname)) != NULL) { + if (detpack->parent == self) { + detpack->think = DetonateDetpack; // Detonate next think. + detpack->nextthink = level.time; + } + } + } + + + //RPG-X: Redtechie - Do some score keeping witch we commented out and log + if (attacker != NULL) { + killer = attacker->s.number; + if (attacker->client != NULL) { + killerName = attacker->client->pers.netname; + } else { + killerName = ""; + } + } else { + killer = ENTITYNUM_WORLD; + killerName = ""; + } + + if (killer < 0 || killer >= MAX_CLIENTS) { + killer = ENTITYNUM_WORLD; + killerName = ""; + } + + if (meansOfDeath < 0 || meansOfDeath >= sizeof(modNames) / sizeof(modNames[0])) { + obit = ""; + } else { + obit = modNames[meansOfDeath]; + } + + G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n", killer, self->s.number, meansOfDeath, killerName, self->client->pers.netname, obit); + + G_LogWeaponKill(killer, meansOfDeath); + G_LogWeaponDeath(self->s.number, self->s.weapon); + if (attacker != NULL && attacker->client != NULL && attacker->inuse) { + G_LogWeaponFrag(killer, self->s.number); + } + + if (meansOfDeath != MOD_RESPAWN && meansOfDeath != MOD_CUSTOM_DIE) { + // broadcast the death event to everyone + ent = G_TempEntity(self->r.currentOrigin, EV_OBITUARY); + ent->s.eventParm = meansOfDeath; + ent->s.otherEntityNum = self->s.number; + ent->s.otherEntityNum2 = killer; + ent->r.svFlags = SVF_BROADCAST; // send to everyone + } + + self->enemy = attacker; + + ps->persistant[PERS_KILLED]++; + if (self == attacker) { + self->client->pers.teamState.suicides++; + } else { + //RPG-X | Phenix | 06/04/2005 + // N00b Protection, you kill two people and puff your auto n00b! + + if (attacker != NULL) { + if (attacker->client != NULL) { + if (G_Client_IsAdmin(attacker) == qfalse) { + attacker->n00bCount++; + + attacker->client->fraggerTime = level.time + (rpg_fraggerSpawnDelay.integer * 1000); + + if (rpg_kickAfterXkills.integer < 1) { + trap_SendServerCommand(attacker - g_entities, va("print \"^7Server: You have been caught n00bing, you have been temporary put in the n00b class.\n\"")); + } else { + trap_SendServerCommand(attacker - g_entities, va("print \"^7Server: You have been caught n00bing, %i more times and you will be kicked.\n\"", (rpg_kickAfterXkills.integer - attacker->n00bCount))); + } + + if ((attacker->n00bCount >= rpg_kickAfterXkills.integer) && (rpg_kickAfterXkills.integer != 0)) { + trap_DropClient(attacker->s.number, "Kicked: Do Not N00b!"); + } else { + for (i = 0; g_classData[i].consoleName[0] && i < MAX_CLASSES; i++) { + if (g_classData[i].isn00b) { + char conName[64]; + trap_Cvar_VariableStringBuffer(va("rpg_%sPass", conName), conName, sizeof(conName)); + + Q_strncpyz(attacker->client->origClass, G_Client_ClassNameForValue(attacker->client->sess.sessionClass), sizeof(attacker->client->origClass)); + attacker->client->n00bTime = level.time + 10000; + SetClass(attacker, conName, NULL, qfalse); + break; + } + } + } + } + } + } + } + + //RPG-X: RedTechie no noclip + if (self->client->noclip) { + self->client->noclip = qfalse; + } + + //RPG-X: RedTechie - Toss items + //RPG-X: Marcin - not when respawning - 30/12/2008 + if (meansOfDeath != MOD_RESPAWN) { + G_Client_TossClientItems(self, qfalse); + } + + ps->pm_type = PM_DEAD; + + self->takedamage = qfalse; + + ps->weapon = WP_0; + ps->weaponstate = WEAPON_READY; + self->r.contents = CONTENTS_CORPSE; + + //-TiM + + self->s.loopSound = 0; + + self->r.maxs[2] = -8; + + //RPG-X: RedTechie - Wait....forever + self->client->respawnTime = level.time + 1000000000; + + //Play death sound + //RPG-X: RedTechie - No pain sound when they change class + if (meansOfDeath != MOD_RESPAWN) { + G_AddEvent(self, irandom(EV_DEATH1, EV_DEATH3), killer); + //if we died from falling, add a nice "splat' sound lol + if (meansOfDeath == MOD_FALLING) { + G_AddEvent(self, EV_SPLAT, killer); + } + } + + //RPG-X : Model system - Death animations now based on vector hit + if (meansOfDeath == MOD_FALLING) { + anim = BOTH_FALLDEATH1LAND; + } else if (self->waterlevel == 3) { + anim = BOTH_FLOAT2; + } else { + if (meansOfDeath == MOD_PHASER || meansOfDeath == MOD_PHASER_ALT) { + if ((self->client->lasthurt_location & LOCATION_FRONT) != 0) { + anim = BOTH_DEATHBACKWARD1; + } else if ((self->client->lasthurt_location & LOCATION_BACK) != 0) { + anim = BOTH_DEATHFORWARD2; + } else if ((self->client->lasthurt_location & LOCATION_LEFT) != 0) { + anim = BOTH_DEATH2; + } else if ((self->client->lasthurt_location & LOCATION_RIGHT) != 0) { + anim = BOTH_DEATH2; + } else { + anim = BOTH_DEATH1; + } + } else { + if ((self->client->lasthurt_location & LOCATION_FRONT) != 0) { + anim = BOTH_DEATHBACKWARD2; + } else if ((self->client->lasthurt_location & LOCATION_BACK) != 0) { + anim = BOTH_DEATHFORWARD1; + } else if ((self->client->lasthurt_location & LOCATION_LEFT) != 0) { + anim = BOTH_DEATHFORWARD2; + } else if ((self->client->lasthurt_location & LOCATION_RIGHT) != 0) { + anim = BOTH_DEATHFORWARD2; + } else { + anim = BOTH_DEATH1; + } + } + } + + //TiM + ps->stats[LEGSANIM] = ((ps->stats[LEGSANIM] & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | anim; + ps->stats[TORSOANIM] = ((ps->stats[TORSOANIM] & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | anim; + + trap_LinkEntity(self); + + BG_PlayerStateToEntityState(&self->client->ps, &self->s, qtrue); + + G_Client_UserinfoChanged(self->s.clientNum); + + ClientEndFrame(self); + + G_Client_StoreClientInitialStatus(self); + //--------------------- + //RPG-X: RedTechie - If it dose equal 0 use regular die + //--------------------- + } else { + char* killerName = NULL; + char* obit = NULL; + char* classname = NULL; + int anim = 0; + int killer = 0; + int i = 0; + int BottomlessPitDeath = 0; + static int deathNum; + gentity_t* ent = NULL; + gentity_t* detpack = NULL; + playerState_t* ps = &self->client->ps; + + if (ps->pm_type == PM_DEAD) { + return; + } + + if (level.intermissiontime != 0) { + return; + } + + //RPG-X: RedTechie - Trying to make sure player dies when there health is 1 without medics revive turned on + //RPG-X | Phenix | 05/04/2005 - Read learn that "=" sets where "==" is an if statement!!! + if (self->health == 1) { + self->health = 0; + } + + ps->pm_type = PM_DEAD; + //need to copy health here because pm_type was getting reset to PM_NORMAL if ClientThink_real was called before the STAT_HEALTH was updated + ps->stats[STAT_HEALTH] = self->health; + + // check if we are in a NODROP Zone and died from a TRIGGER HURT + // if so, we assume that this resulted from a fall to a "bottomless pit" and + // treat it differently... + // + // Any problems with other places in the code? + // + BottomlessPitDeath = 0; // initialize + + contents = trap_PointContents(self->r.currentOrigin, -1); + if ((contents & CONTENTS_NODROP) != 0 && (meansOfDeath == MOD_TRIGGER_HURT)) { + BottomlessPitDeath = 1; + } + + // similarly, if El Corpso here has already dropped a detpack, blow it up + classname = BG_FindClassnameForHoldable(HI_DETPACK); + if (classname) { + while ((detpack = G_Find(detpack, FOFS(classname), classname)) != NULL) { + if (detpack->parent == self) { + detpack->think = DetonateDetpack; // Detonate next think. + detpack->nextthink = level.time; + } + } + } + + if (attacker != NULL) { + killer = attacker->s.number; + if (attacker->client != NULL) { + killerName = attacker->client->pers.netname; + } else { + killerName = ""; + } + } else { + killer = ENTITYNUM_WORLD; + killerName = ""; + } + + if (killer < 0 || killer >= MAX_CLIENTS) { + killer = ENTITYNUM_WORLD; + killerName = ""; + } + + if (meansOfDeath < 0 || meansOfDeath >= sizeof(modNames) / sizeof(modNames[0])) { + obit = ""; + } else { + obit = modNames[meansOfDeath]; + } + + G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n", killer, self->s.number, meansOfDeath, killerName, self->client->pers.netname, obit); + + G_LogWeaponKill(killer, meansOfDeath); + G_LogWeaponDeath(self->s.number, self->s.weapon); + if (attacker != NULL && attacker->client != NULL && attacker->inuse) { + G_LogWeaponFrag(killer, self->s.number); + } + + if (meansOfDeath != MOD_RESPAWN) { + // broadcast the death event to everyone + ent = G_TempEntity(self->r.currentOrigin, EV_OBITUARY); + ent->s.eventParm = meansOfDeath; + ent->s.otherEntityNum = self->s.number; + ent->s.otherEntityNum2 = killer; + ent->r.svFlags = SVF_BROADCAST; // send to everyone + } + + self->enemy = attacker; + + ps->persistant[PERS_KILLED]++; + if (self == attacker) { + self->client->pers.teamState.suicides++; + } + + //RPG-X: Redtechie - No awards or score calculations + //////////////////////////////////////////////////////////////////////// + if (attacker != NULL && attacker->client != NULL) { + if (attacker == self) { + if (meansOfDeath != MOD_RESPAWN) {//just changing class + G_Client_AddScore(attacker, -1); + } + } else { + attacker->client->pers.teamState.frags++; + G_Client_AddScore(attacker, 1); + + // Check to see if the player is on a streak. + attacker->client->streakCount++; + + attacker->client->lastKillTime = level.time; + } + } else { + if (meansOfDeath != MOD_RESPAWN) {//not just changing class + G_Client_AddScore(self, -1); + } + } + //////////////////////////////////////////////////////////////////////// + + //RPG-X: Redtechie - agian no need + // Add team bonuses + //Team_FragBonuses(self, inflictor, attacker); + + // if client is in a nodrop area, don't drop anything (but return CTF flags!) + if ((contents & CONTENTS_NODROP) == 0 && meansOfDeath != MOD_SUICIDE && meansOfDeath != MOD_RESPAWN) {//action hero doesn't drop stuff + //don't drop stuff in specialty mode + if (meansOfDeath != MOD_RESPAWN) { + G_Client_TossClientItems(self, qfalse); + } + } + + DeathmatchScoreboardMessage(self); // show scores + // send updated scores to any clients that are following this one, + // or they would get stale scoreboards + for (i = 0; i < level.maxclients; i++) { + gclient_t* client = NULL; + + client = &level.clients[i]; + if (client == NULL) { + continue; + } + + if (client->pers.connected != CON_CONNECTED) { + continue; + } + if (client->sess.sessionTeam != TEAM_SPECTATOR) { + continue; + } + if (client->sess.spectatorClient == self->s.number) { + DeathmatchScoreboardMessage(g_entities + i); + } + } + + self->takedamage = qtrue; // can still be gibbed + + self->s.weapon = WP_0; + self->s.powerups = 0; + self->r.contents = CONTENTS_CORPSE; + + self->s.loopSound = 0; + + self->r.maxs[2] = -8; + + // don't allow respawn until the death anim is done + // g_forcerespawn may force spawning at some later time + self->client->respawnTime = level.time + 1700; + + // We always want to see the body for special animations, so make sure not to gib right away: + if (meansOfDeath == MOD_CRIFLE_ALT || + meansOfDeath == MOD_DETPACK || + meansOfDeath == MOD_QUANTUM_ALT || + meansOfDeath == MOD_DREADNOUGHT_ALT || + meansOfDeath == MOD_PHASER_ALT)//RPG-X: RedTechie - Added phaser alt disnt + { + self->health = 0; + } + + //RPG-X : Model system - Death animations now based on vector hit + if (meansOfDeath == MOD_FALLING) { + anim = BOTH_FALLDEATH1LAND; + } else if (self->waterlevel == 3) { + anim = BOTH_FLOAT2; + } else { + if (meansOfDeath == MOD_PHASER || meansOfDeath == MOD_PHASER_ALT) { + if ((self->client->lasthurt_location & LOCATION_FRONT) != 0) { + anim = BOTH_DEATHBACKWARD1; + } else if ((self->client->lasthurt_location & LOCATION_BACK) != 0) { + anim = BOTH_DEATHFORWARD2; + } else if ((self->client->lasthurt_location & LOCATION_LEFT) != 0) { + anim = BOTH_DEATH2; + } else if ((self->client->lasthurt_location & LOCATION_RIGHT) != 0) { + anim = BOTH_DEATH2; + } else { + anim = BOTH_DEATH1; + } + } else { + if ((self->client->lasthurt_location & LOCATION_FRONT) != 0) { + anim = BOTH_DEATHBACKWARD2; + } else if ((self->client->lasthurt_location & LOCATION_BACK) != 0) { + anim = BOTH_DEATHFORWARD1; + } else if ((self->client->lasthurt_location & LOCATION_LEFT) != 0) { + anim = BOTH_DEATHFORWARD2; + } else if ((self->client->lasthurt_location & LOCATION_RIGHT) != 0) { + anim = BOTH_DEATHFORWARD2; + } else { + anim = BOTH_DEATH1; + } + } + } + + ps->stats[LEGSANIM] = ((ps->stats[LEGSANIM] & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | anim; + ps->stats[TORSOANIM] = ((ps->stats[TORSOANIM] & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | anim; + + if ((BottomlessPitDeath == 1) && (killer == ENTITYNUM_WORLD)) { + //G_AddEvent( self, EV_FALL_FAR, killer ); ?? Need to play falling SF now, or + // use designer trigger?? + //FIXME: need *some* kind of death anim! + } else { + // normal death + + switch (meansOfDeath) { + case MOD_PHASER_ALT: //RPG-X: RedTechie - Added better effect for alt phaser + if (rpg_phaserdisintegrates.integer == 1) {//RPG-X: RedTechie - Check to see if we want this + G_AddEvent(self, EV_DISINTEGRATION, killer); + ps->powerups[PW_DISINTEGRATE] = level.time + 100000; + VectorClear(ps->velocity); + self->takedamage = qfalse; + self->r.contents = 0; + } + break; + case MOD_CRIFLE_ALT: + break; + case MOD_QUANTUM_ALT: + G_AddEvent(self, EV_DISINTEGRATION2, killer); + ps->powerups[PW_EXPLODE] = level.time + 100000; + VectorClear(ps->velocity); + self->takedamage = qfalse; + self->r.contents = 0; + break; + case MOD_SCAVENGER_ALT: + case MOD_SCAVENGER_ALT_SPLASH: + case MOD_GRENADE: + case MOD_GRENADE_ALT: + case MOD_GRENADE_SPLASH: + case MOD_GRENADE_ALT_SPLASH: + case MOD_QUANTUM: + case MOD_QUANTUM_SPLASH: + case MOD_QUANTUM_ALT_SPLASH: + case MOD_DETPACK: + G_AddEvent(self, EV_EXPLODESHELL, killer); + ps->powerups[PW_EXPLODE] = level.time + 100000; + VectorClear(ps->velocity); + self->takedamage = qfalse; + self->r.contents = 0; + break; + case MOD_DREADNOUGHT: + case MOD_DREADNOUGHT_ALT: + G_AddEvent(self, EV_ARCWELD_DISINT, killer); + ps->powerups[PW_ARCWELD_DISINT] = level.time + 100000; + VectorClear(ps->velocity); + self->takedamage = qfalse; + self->r.contents = 0; + break; + case MOD_FALLING: + G_AddEvent(self, EV_SPLAT, killer); + break; + default: + G_AddEvent(self, irandom(EV_DEATH1, EV_DEATH3), killer); + break; + } + + // the body can still be gibbed + self->die = body_die; + + } + // globally cycle through the different death animations + deathNum = (deathNum + 1) % 3; + + trap_LinkEntity(self); + }//RPG-X: RedTechie - End of my if statment for medics revive check +}//RPG-X: RedTechie - End of void + +qboolean G_Client_IsBorg(gentity_t* ent) { + if (ent == NULL) { + return qfalse; + } + + if (ent->client == NULL) { + return qfalse; + } + + if (g_classData[ent->client->sess.sessionClass].isBorg) { + return qtrue; + } else { + return qfalse; + } +} + + + diff --git a/code/game/g_client.h b/code/game/g_client.h index 735ddb8..7634351 100644 --- a/code/game/g_client.h +++ b/code/game/g_client.h @@ -1,158 +1,201 @@ -#ifndef _G_CLIENT_H -#define _G_CLIENT_H - -#include "g_local.h" - -/** - * Select a spawnpoint. - * - * \param avoidPoint Point to avoid. - * \param origin Origin. - * \param angles Angles. - */ -/*@shared@*/ /*@null@*/ gentity_t* G_Client_SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles ); - -/** - * Set the clients view angle. - * - * \param ent Entity for which to set view angle. - * \param angle New view angle. - */ -void G_Client_SetViewAngle( gentity_t* ent, vec3_t angle ); - -/** - * Respawn client. - * - * \param ent Client to respawn. - */ -void G_Client_Respawn(gentity_t *ent); - -/** - * Init the body que. - */ -void G_Client_InitBodyQue(void); - -//TiM - Delayed Transport Beam -void G_InitTransport( int32_t clientNum, vec3_t origin, vec3_t angles ); - -/** - * Pick a random team. - * - * \param ignoreClientNum Client to ignore. - * \return Random team. - */ -team_t G_Client_PickTeam( int32_t ignoreClientNum ); - -/** - * Clients user info changed. - * - * \param clientNum Client num. - */ -void G_Client_UserinfoChanged( int32_t clientNum ); - -/** - * Client connect. - * - * \param clientNum Client num. - * \param firstTime Indicate whether this was the first connect. - * \param isBot Indicate if bot or player. - */ -/*@shared@*/ char* G_Client_Connect( int32_t clientNum, qboolean firstTime, qboolean isBot ); - -/** - * Initialize client. - * - * \param clientNum Client num. - * \param careAboutWarmup Indicate whether to care about warm up. - * \param isBot Bot or client? - * \param first First time? - */ -void G_Client_Begin( int32_t clientNum, qboolean careAboutWarmup, qboolean isBot, qboolean first ); - -/** - * Store the clients initial status. - * - * \param ent The client. - */ -void G_Client_StoreClientInitialStatus( gentity_t* ent ); - -/** - * Spawn client. - * - * \param ent Client to spawn - * \param rpgx_spawn rpgx_spawn - * \param fromDeath Is this a spawn from death? - */ -void G_Client_Spawn( gentity_t* ent, int32_t rpgx_spawn, qboolean fromDeath ); - -/** - * Disconnect client. - * - * \param clientNum Client num. - */ -void G_Client_Disconnect( int32_t clientNum ); - -/** - * Check if player is an admin. - * - * \param ent the player - * \return Whether player is admin. - */ -qboolean IsAdmin( gentity_t* ent ); - -/** - * Get location message for a client. - * - * \param ent The client. - * \param loc Location char. - * \param loclen Length of location char. - * \return Indicates success or fail. - */ -qboolean G_Client_GetLocationMsg(gentity_t* ent, char* loc, int32_t loclen); - -/** - * Check client statuses. - */ -void G_Client_CheckClientStatus(void); - -/** - * Client command. - * - * \param clientNum Client num. - */ -void G_Client_Command( int clientNum ); - -/** - * Begin intermission. - */ -void G_Client_BeginIntermission(void); - -/** - * Let the client die. - * - * \param self Client. - * \param inflictor Entity causing death. - * \param attacker Entity that made inflicotr cause death. - * \param damage ammount of demage - * \param mod means of death - */ -void G_Client_Die (gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int damage, int mod); - -/** - * Add score for the client. - * - * \param ent The client. - * \param score Ammount of score to add. - */ -void G_Client_AddScore( gentity_t* ent, int score ); - -/** - * Calculate clients ranks. - * - * \param fromExit From exit? - */ -void G_Client_CalculateRanks( qboolean fromExit ); - -extern clInitStatus_t clientInitialStatus[MAX_CLIENTS]; - +#ifndef _G_CLIENT_H +#define _G_CLIENT_H + +#include "g_local.h" +#include "g_combat.h" + +/** + * Select a spawnpoint. + * + * \param avoidPoint Point to avoid. + * \param origin Origin. + * \param angles Angles. + */ +/*@shared@*/ /*@null@*/ gentity_t* G_Client_SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles ); + +/** + * Set the clients view angle. + * + * \param ent Entity for which to set view angle. + * \param angle New view angle. + */ +void G_Client_SetViewAngle( gentity_t* ent, vec3_t angle ); + +/** + * Respawn client. + * + * \param ent Client to respawn. + */ +void G_Client_Respawn(gentity_t *ent); + +/** + * Init the body que. + */ +void G_Client_InitBodyQue(void); + +//TiM - Delayed Transport Beam +void G_InitTransport( int32_t clientNum, vec3_t origin, vec3_t angles ); + +/** + * Pick a random team. + * + * \param ignoreClientNum Client to ignore. + * \return Random team. + */ +team_t G_Client_PickTeam( int32_t ignoreClientNum ); + +/** + * Clients user info changed. + * + * \param clientNum Client num. + */ +void G_Client_UserinfoChanged( int32_t clientNum ); + +/** + * Client connect. + * + * \param clientNum Client num. + * \param firstTime Indicate whether this was the first connect. + * \param isBot Indicate if bot or player. + */ +/*@shared@*/ char* G_Client_Connect( int32_t clientNum, qboolean firstTime, qboolean isBot ); + +/** + * Initialize client. + * + * \param clientNum Client num. + * \param careAboutWarmup Indicate whether to care about warm up. + * \param isBot Bot or client? + * \param first First time? + */ +void G_Client_Begin( int32_t clientNum, qboolean careAboutWarmup, qboolean isBot, qboolean first ); + +/** + * Store the clients initial status. + * + * \param ent The client. + */ +void G_Client_StoreClientInitialStatus( gentity_t* ent ); + +/** + * Spawn client. + * + * \param ent Client to spawn + * \param rpgx_spawn rpgx_spawn + * \param fromDeath Is this a spawn from death? + */ +void G_Client_Spawn( gentity_t* ent, int32_t rpgx_spawn, qboolean fromDeath ); + +/** + * Disconnect client. + * + * \param clientNum Client num. + */ +void G_Client_Disconnect( int32_t clientNum ); + +/** + * Check if player is an admin. + * + * \param ent the player + * \return Whether player is admin. + */ +qboolean G_Client_IsAdmin( gentity_t* ent ); + +/** + * Get location message for a client. + * + * \param ent The client. + * \param loc Location char. + * \param loclen Length of location char. + * \return Indicates success or fail. + */ +qboolean G_Client_GetLocationMsg(gentity_t* ent, char* loc, int32_t loclen); + +/** + * Check client statuses. + */ +void G_Client_CheckClientStatus(void); + +/** + * Client command. + * + * \param clientNum Client num. + */ +void G_Client_Command( int clientNum ); + +/** + * Begin intermission. + */ +void G_Client_BeginIntermission(void); + +/** + * Let the client die. + * + * \param self Client. + * \param inflictor Entity causing death. + * \param attacker Entity that made inflicotr cause death. + * \param damage ammount of demage + * \param mod means of death + */ +void G_Client_Die (gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int damage, int mod); + +/** + * Add score for the client. + * + * \param ent The client. + * \param score Ammount of score to add. + */ +void G_Client_AddScore( gentity_t* ent, int score ); + +/** + * Calculate clients ranks. + * + * \param fromExit From exit? + */ +void G_Client_CalculateRanks( qboolean fromExit ); + +/** + * Set the score for a client. + * + * \param ent The client. + * \param score New score for the client. + */ +void G_Client_SetScore(gentity_t *ent, int32_t score); + +/** + * Toss the weapon and powerups for the killed player. + * + * \param self the client. + * \param Caused by disconnect? + */ +void G_Client_TossClientItems(gentity_t* self, qboolean dis_con); + +/** + * Let a body die. + * + * \param self Self. + * \param inflictor entity that is causing the damage + * \param attacker entity that caused the inflictor to damage targ + * \param damage Amount of damage. + * \param meansOfDeath Means of death. + */ +void body_die(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32_t damage, int32_t meansOfDeath); + +/** + * \brief Gets the classname for a given player class. + * \param pClass The class. + */ +char* G_Client_ClassNameForValue(pclass_t pClass); + +/** + * Checks if a player is in a Class that is borg. + * \param ent the player + * + * \author Ubergames - GSIO01 + * \date 08/05/2009 + */ +qboolean G_Client_IsBorg(gentity_t* ent); + +extern clInitStatus_t clientInitialStatus[MAX_CLIENTS]; + #endif /* _G_CLIENT_H */ \ No newline at end of file diff --git a/code/game/g_cmds.c b/code/game/g_cmds.c index 6328eb4..34b0983 100644 --- a/code/game/g_cmds.c +++ b/code/game/g_cmds.c @@ -86,7 +86,7 @@ static qboolean CheatsOk(gentity_t* ent) { G_Assert(ent, qfalse); - if (g_cheats.integer == 0 || IsAdmin(ent) == qfalse) { + if (g_cheats.integer == 0 || G_Client_IsAdmin(ent) == qfalse) { G_PrintfClient(ent, "You can't use cheats in a Roleplay Session!\n"); return qfalse; } @@ -241,12 +241,12 @@ static void Cmd_Give_f(gentity_t *ent) { client = ent->client; #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_GIVE) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_GIVE) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -436,12 +436,12 @@ static void Cmd_God_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_GOD) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_GOD) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -465,7 +465,7 @@ static void Cmd_Notarget_f(gentity_t* ent) { G_Assert(ent, (void)0); - if (IsAdmin(ent) == qfalse) { + if (G_Client_IsAdmin(ent) == qfalse) { return; } @@ -489,12 +489,12 @@ static void Cmd_Noclip_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { trap_SendServerCommand(ent - g_entities, va("print \"ERROR: You are not logged in as an admin.\n\" ")); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_NOCLIP) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_NOCLIP) ) { trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropriate rights.\n\" ") ); return; } @@ -791,17 +791,6 @@ qboolean SetTeam(gentity_t* ent, char* s) { return qtrue; } -char* ClassNameForValue(pclass_t pClass) { - static char buffer[MAX_QPATH]; - char *ptr = NULL; - - trap_Cvar_VariableStringBuffer(va("rpg_%sPass", g_classData[pClass].consoleName), buffer, sizeof(buffer)); - - ptr = buffer; - - return ptr; -} - /* ================= ValueNameForClass @@ -1172,12 +1161,12 @@ static void Cmd_Cloak_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CLOAK) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CLOAK) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n") return; } @@ -1220,12 +1209,12 @@ static void Cmd_EvoSuit_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { trap_SendServerCommand(ent - g_entities, va("print \"ERROR: You are not logged in as an admin.\n\" ")); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_EVOSUIT) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_EVOSUIT) ) { trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropriate rights.\n\" ") ); return; } @@ -1259,12 +1248,12 @@ static void Cmd_Flight_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { trap_SendServerCommand(ent - g_entities, va("print \"ERROR: You are not logged in as an admin.\n\" ")); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FLIGHT) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FLIGHT) ) { trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropriate rights.\n\" ") ); return; } @@ -1416,10 +1405,10 @@ static void G_SayTo(gentity_t* ent, gentity_t* other, int32_t mode, int32_t colo sess = &ent->client->sess; - if (mode == SAY_CLASS && !OnSameClass(ent, other) && (IsAdmin(other) == qfalse)) { + if (mode == SAY_CLASS && !OnSameClass(ent, other) && (G_Client_IsAdmin(other) == qfalse)) { return; } - if (mode == SAY_ADMIN && (IsAdmin(other) == qfalse)) { + if (mode == SAY_ADMIN && (G_Client_IsAdmin(other) == qfalse)) { return; } // no chatting to players in tournements @@ -1437,7 +1426,7 @@ static void G_SayTo(gentity_t* ent, gentity_t* other, int32_t mode, int32_t colo //TiM : If admins want to not see broadcast messages, here's the check. //trap_GetUserinfo( other->client->ps.clientNum, userInfo, sizeof( userInfo ) ); - if ((mode == SAY_CLASS || mode == SAY_ADMIN) && (IsAdmin(other) && (other->client->noAdminChat == qtrue || rpg_respectPrivacy.integer > 0))) { + if ((mode == SAY_CLASS || mode == SAY_ADMIN) && (G_Client_IsAdmin(other) && (other->client->noAdminChat == qtrue || rpg_respectPrivacy.integer > 0))) { return; } @@ -1914,12 +1903,12 @@ static void Cmd_ForceVote_f(gentity_t* ent) { client = ent->client; #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEVOTE) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEVOTE) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -1975,7 +1964,7 @@ static void Cmd_SetViewpos_f(gentity_t* ent) { G_Assert(ent, (void)0); - if (g_cheats.integer == 0 && !IsAdmin(ent)) { + if (g_cheats.integer == 0 && !G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "Cheats are not enabled on this server.\n"); return; } @@ -2014,12 +2003,12 @@ static void Cmd_ForceName_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { G_PrintfClient(ent,"ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2093,12 +2082,12 @@ static void Cmd_ShakeCamera_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2164,12 +2153,12 @@ static void Cmd_ForceClass_f(gentity_t* ent) { } #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2243,12 +2232,12 @@ static void Cmd_ForceKill_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEKILL) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEKILL) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2387,12 +2376,12 @@ static void Cmd_ForceKillRadius_f(gentity_t* ent) { //If client isn't in admin class, exit and disallow command. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEKILL) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEKILL) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2506,12 +2495,12 @@ static void Cmd_TargetKick_f(gentity_t* ent) { //Disallow if not in admin class #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_KICK) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_KICK) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2579,12 +2568,12 @@ static void Cmd_Drag_f(gentity_t* ent) { //If client isn't in admin class, exit and disallow command. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { trap_SendServerCommand(ent - g_entities, va("print \"ERROR: You are not logged in as an admin.\n\" ")); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DRAG) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DRAG) ) { trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropriate rights.\n\" ") ); return; } @@ -2688,12 +2677,12 @@ static void Cmd_UnDrag_f(gentity_t* ent) { //If client isn't in admin class, exit and disallow command. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DRAG) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DRAG) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2781,7 +2770,7 @@ void DragCheck(void) { } //If the starting admin is no longer in admin class: - if (IsAdmin(&g_entities[DragDat[i].AdminId]) == qfalse) { + if (G_Client_IsAdmin(&g_entities[DragDat[i].AdminId]) == qfalse) { //Mark as non-dragging. DragDat[i].AdminId = -1; if (target && target->client) @@ -2841,12 +2830,12 @@ static void Cmd_disarm_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DISARM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DISARM) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -2945,7 +2934,7 @@ static void Cmd_Rank_f(gentity_t* ent) { } if (!MaxRankHit) { - SetScore(ent, newScore); + G_Client_SetScore(ent, newScore); trap_SendServerCommand(ent - g_entities, va("prank %s", g_rankNames[i].consoleName)); break; } else { @@ -2959,7 +2948,7 @@ static void Cmd_Rank_f(gentity_t* ent) { } //Okay... we've hit the highest rank we're allowed to go. If the player tries to change their rank to above this, they'll be pwned lol - if (rpg_maxRank.string[0] != 0 && Q_stricmp(g_rankNames[i].consoleName, rpg_maxRank.string) == 0 && IsAdmin(ent)) { + if (rpg_maxRank.string[0] != 0 && Q_stricmp(g_rankNames[i].consoleName, rpg_maxRank.string) == 0 && G_Client_IsAdmin(ent)) { MaxRankHit = qtrue; } } @@ -2967,7 +2956,7 @@ static void Cmd_Rank_f(gentity_t* ent) { //if we didn't get find a matching name. >.< if (newScore < 0) { G_PrintfClient(ent, "This rank doesn't exist on this server!\n\n"); - SetScore(ent, OldScore); + G_Client_SetScore(ent, OldScore); return; } @@ -2999,12 +2988,12 @@ static void Cmd_ForceRank_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3043,7 +3032,7 @@ static void Cmd_ForceRank_f(gentity_t* ent) { if (Q_stricmp(ArgStr, g_rankNames[i].consoleName) == 0) { newScore = i;//1 << i; - SetScore(other, newScore); + G_Client_SetScore(other, newScore); trap_SendServerCommand(other - g_entities, va("prank %s", g_rankNames[i].consoleName)); break; } @@ -3052,7 +3041,7 @@ static void Cmd_ForceRank_f(gentity_t* ent) { //if we didn't get find a matching name. >.< if (newScore < 0) { G_PrintfClient(ent, "This rank doesn't exist on this server!\n\n"); - SetScore(other, OldScore); + G_Client_SetScore(other, OldScore); return; } @@ -3100,7 +3089,7 @@ static void Cmd_Admins_f(gentity_t* ent) { Q_strncpyz(send, va("%s %s \n", send, target->client->pers.netname), sizeof(send)); } - if ((target->client->LoggedAsAdmin == qtrue) && (IsAdmin(ent) == qtrue)) { + if ((target->client->LoggedAsAdmin == qtrue) && (G_Client_IsAdmin(ent) == qtrue)) { Q_strncpyz(send, va("%s %s (hidden) \n", send, target->client->pers.netname), sizeof(send)); } } @@ -3141,7 +3130,7 @@ static void Cmd_AdminLogin_f(gentity_t* ent) { trap_Cvar_VariableStringBuffer(va("rpg_%sPass", g_classData[j].consoleName), classPass, sizeof(classPass)); if (g_classData[j].isAdmin && Q_stricmp(classPass, arg) == 0) { - if (IsAdmin(ent) == qfalse) { + if (G_Client_IsAdmin(ent) == qfalse) { ent->client->LoggedAsAdmin = qtrue; G_PrintfClient(ent, "You are logged in as an admin.\n"); G_Client_UserinfoChanged(ent - g_entities); @@ -3193,12 +3182,12 @@ static void Cmd_Revive_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent) || rpg_medicsrevive.integer == 0) { + if (!G_Client_IsAdmin(ent) || rpg_medicsrevive.integer == 0) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_REVIVE) || rpg_medicsrevive.integer == 0 ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_REVIVE) || rpg_medicsrevive.integer == 0 ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3351,12 +3340,12 @@ static void Cmd_n00b_f(gentity_t* ent) { //If client isn'tin admin class, exit and disallow command. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_NOOB) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_NOOB) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3382,7 +3371,7 @@ static void Cmd_n00b_f(gentity_t* ent) { char conName[15]; trap_Cvar_VariableStringBuffer(va("rpg_%sPass", g_classData[i].consoleName), conName, 15); - Q_strncpyz(target->client->origClass, ClassNameForValue(target->client->sess.sessionClass), sizeof(target->client->origClass)); + Q_strncpyz(target->client->origClass, G_Client_ClassNameForValue(target->client->sess.sessionClass), sizeof(target->client->origClass)); target->client->n00bTime = level.time + (1000 * timeToBe); SetClass(target, conName, NULL, qfalse); break; @@ -3409,12 +3398,12 @@ static void Cmd_admin_message(gentity_t* ent) { //If client isn't in admin class, exit and disallow command. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MESSAGE) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MESSAGE) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3457,12 +3446,12 @@ static void Cmd_ForceModel_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3520,12 +3509,12 @@ static void Cmd_PlayMusic_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MUSIC) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MUSIC) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3557,12 +3546,12 @@ static void Cmd_StopMusic_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MUSIC) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MUSIC) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3583,12 +3572,12 @@ static void Cmd_PlaySound_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MUSIC) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MUSIC) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3653,12 +3642,12 @@ static void Cmd_UseEnt_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_USEENT) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_USEENT) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3735,12 +3724,12 @@ static void Cmd_EntList_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_USEENT) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_USEENT) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3806,12 +3795,12 @@ static void Cmd_BeamToLoc_f(gentity_t* ent) { //Has to be an admin.. if anyone had it, the brig would become useless. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -3968,12 +3957,12 @@ static void Cmd_ForcePlayer_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPARM) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -4064,12 +4053,12 @@ static void Cmd_BeamToPlayer_f(gentity_t* ent) { //Has to be an admin.. if anyone had it, the brig would become useless. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -4529,12 +4518,12 @@ static void Cmd_fxGun_f(gentity_t* ent) { } #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -4821,12 +4810,12 @@ static void Cmd_flushFX_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -4845,12 +4834,12 @@ static void Cmd_spawnChar_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CHARS) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CHARS) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -4882,12 +4871,12 @@ static void Cmd_fluchChars_f(gentity_t* ent) //GSIO01: fluch Chars ehhh? you kno } #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CHARS) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CHARS) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -4941,7 +4930,7 @@ static void Cmd_flushDropped_f(gentity_t* ent) { } if (locEnt->classname != NULL && Q_strncmp(locEnt->classname, "weapon", 6) == 0) { // everything that begins with weapon_ - if ((ans == qfalse || !IsAdmin(ent)) && locEnt->parent != ent) { + if ((ans == qfalse || !G_Client_IsAdmin(ent)) && locEnt->parent != ent) { continue; } else { G_FreeEntity(locEnt); @@ -4974,12 +4963,12 @@ static void Cmd_Kick2_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_KICK) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_KICK) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5053,12 +5042,12 @@ static void Cmd_ClampInfo_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CLAMP) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CLAMP) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5157,7 +5146,7 @@ static void Cmd_Turbolift_f(gentity_t* ent) { return; } - if ((lift->flags & FL_LOCKED) != 0 && (!IsAdmin(ent))) { + if ((lift->flags & FL_LOCKED) != 0 && (!G_Client_IsAdmin(ent))) { G_PrintfClient(ent, "Turbolift is offline.\n"); return; } @@ -5282,7 +5271,7 @@ static void Cmd_MeActionLocal_f(gentity_t* ent) { //Send message to admins warning about command being used. //TiM - since double spamming is annoying, ensure that the target admin wants this alert - if (!OtherPlayer->client->noAdminChat && IsAdmin(OtherPlayer)) { + if (!OtherPlayer->client->noAdminChat && G_Client_IsAdmin(OtherPlayer)) { G_PrintfClientAll("%s" S_COLOR_CYAN" (locally) " S_COLOR_WHITE "%s\n", ent->client->pers.netname, message); } @@ -5372,12 +5361,12 @@ static void Cmd_lockDoor_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5453,12 +5442,12 @@ static void Cmd_ffColor_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FFSTUFF) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FFSTUFF) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5551,12 +5540,12 @@ static void Cmd_unlockAll_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5613,12 +5602,12 @@ static void Cmd_lockAll_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5648,12 +5637,12 @@ static void Cmd_changeFreq(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FFSTUFF) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FFSTUFF) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5700,12 +5689,12 @@ static void Cmd_alert_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_ALERT) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_ALERT) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5782,12 +5771,12 @@ static void Cmd_zonelist_f(gentity_t* ent) { gentity_t* zone = NULL; #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5857,12 +5846,12 @@ static void Cmd_selfdestruct_f(gentity_t *ent) { trap_Argv(5, arg8, sizeof(arg8)); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -5965,12 +5954,12 @@ static void Cmd_shipdamage_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6119,12 +6108,12 @@ static void Cmd_reloadtorpedos_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6189,12 +6178,12 @@ static void Cmd_torpedolist_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SMS ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6237,12 +6226,12 @@ static void Cmd_admin_centerprint_f(gentity_t* ent) { //If client isn't in admin class, exit and disallow command. #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MESSAGE) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MESSAGE) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6273,12 +6262,12 @@ static void Cmd_getBrushEntCount_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6300,12 +6289,12 @@ static void Cmd_listSPs(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6335,12 +6324,12 @@ static void Cmd_getEntInfo_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6385,12 +6374,12 @@ static void Cmd_getOrigin_f(gentity_t* ent) { G_Assert(ent->client, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6437,12 +6426,12 @@ static void Cmd_getEntByTargetname_f(gentity_t *ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6482,12 +6471,12 @@ static void Cmd_getEntByTarget_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6528,12 +6517,12 @@ static void Cmd_getEntByBmodel_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6558,12 +6547,12 @@ static void Cmd_setOrigin(gentity_t *ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6606,12 +6595,12 @@ static void Cmd_flushTentities_f(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_TESS) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_TESS) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -6679,12 +6668,12 @@ static void Cmd_spawnTentity_f(gentity_t* ent) { clientNum = ent->client->ps.clientNum; #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "ERROR: You are not logged in as an admin.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_TESS) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_TESS) ) { G_PrintfClient(ent, "ERROR: You are not logged in as a user with the appropriate rights.\n"); return; } @@ -7307,12 +7296,12 @@ static void Cmd_UiTransporterLoc_f(gentity_t* ent) { if (locTarget != NULL) { if (locTarget->sound1to2 == 0) { #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { G_PrintfClient(ent, "Destination is a restricted location.\n"); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) { G_PrintfClient(ent, "Destination is a restricted location.\n"); return; } @@ -7460,7 +7449,7 @@ static void Cmd_SqlUserAdd_f(gentity_t* ent) { return; } - if(!IsAdmin(ent)) { + if(!G_Client_IsAdmin(ent)) { return; } @@ -7500,7 +7489,7 @@ static void Cmd_SqlUserMod_f(gentity_t* ent) { return; } - if(!IsAdmin(ent)) { + if(!G_Client_IsAdmin(ent)) { return; } @@ -7554,12 +7543,12 @@ static void Cmd_findEntitiesInRadius(gentity_t* ent) { G_Assert(ent, (void)0); #ifndef SQL - if (!IsAdmin(ent)) { + if (!G_Client_IsAdmin(ent)) { trap_SendServerCommand(ent - g_entities, va("print \"ERROR: You are not logged in as an admin.\n\" ")); return; } #else - if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { + if ( !G_Client_IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DEBUG ) ) { trap_SendServerCommand(ent - g_entities, va("print \"ERROR: You are not logged in as a user with the appropriate rights.\n\" ")); return; } diff --git a/code/game/g_combat.c b/code/game/g_combat.c index 7c8eef1..6131b85 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -10,953 +10,210 @@ #include "g_client.h" #include "g_items.h" #include "g_lua.h" +#include "g_logger.h" +#include "g_missile.h" +#include "g_spawn.h" -/* -============ -SetScore +void G_Combat_GibEntity(gentity_t* self, int32_t killer) { -============ -*/ -void SetScore( gentity_t *ent, int score ) { + G_Assert(self, (void)0); - if ( !ent ) - { - return; - } - if ( !ent->client ) { - return; - } - - if(!ent->client->UpdateScore) - { - return; - } - - ent->client->ps.persistant[PERS_SCORE] = score; - G_Client_CalculateRanks( qfalse ); - - // TiM: send the current scoring to all clients - SendScoreboardMessageToAllClients(); - - //RPG-X: RedTechie - Lets enable score updating without this scores will not be updated - ent->client->UpdateScore = qfalse; -} - -void TossClientItems( gentity_t *self, qboolean dis_con ) { - gitem_t *item; - float angle; - int i; - int times; - gentity_t *drop; - playerState_t *ps = &self->client->ps; - - if (self->flags & FL_CLOAK) { - // remove the invisible powerup if the player is cloaked. - //RPG-X: RedTechie - Also remove ghost - ps->powerups[PW_GHOST] = level.time; - ps->powerups[PW_INVIS] = level.time; - } - if (self->flags & FL_FLY) { - // remove the flying powerup if the player is flying. - ps->powerups[PW_FLIGHT] = level.time; - } - //RPG-X | Phenix | 8/8/2004 - if (self->flags & FL_EVOSUIT) { - // remove the evosuit powerup - ps->powerups[PW_EVOSUIT] = level.time; - } - - // drop all the powerups if not in teamplay - if ( g_gametype.integer != GT_TEAM ) { - angle = 45; - for ( i = 1 ; i < PW_NUM_POWERUPS ; i++ ) { - if ( ps->powerups[ i ] > level.time ) { - item = BG_FindItemForPowerup( i ); - if ( !item ) { - continue; - } - - drop = Drop_Item( self, item, angle ); - // decide how many seconds it has left - drop->count = ( ps->powerups[ i ] - level.time ) / 1000; - if ( drop->count < 1 ) { - drop->count = 1; - } - angle += 45; - } - } - } - - // RPG-X | Marcin | 30/12/2008 - // ... - if (!rpg_allowWeaponDrop.integer || !rpg_dropOnDeath.integer || dis_con) { - return; - } - - // Drop ALL weapons in inventory - for (i = 0; i < WP_NUM_WEAPONS; ++i) { - // these weapons should not be tossed (hand and null) - if ( Max_Weapons[i] == NULL) { - continue; - } - - //RPG-X | GSIO01 | 08/05/2009: let's make sure we only drop weapons the player has - item = NULL; - if(ps->ammo[i]) { - times = ps->ammo[i]; - item = BG_FindItemForWeapon((weapon_t)i); - while ( times --> 0 ) { // the 'goes towards' operator :p - Drop_Item( self, item, 0 ); - } - } - } - - // then remove weapons - - for (i = 0; i < WP_NUM_WEAPONS; ++i) { - ps->stats[STAT_WEAPONS] &= ~i; - ps->ammo[i] = 0; - } - - -} - -/* -================== -GibEntity -================== -*/ -static void GibEntity( gentity_t *self, int killer ) { // Start Disintegration - G_AddEvent( self, EV_EXPLODESHELL, killer ); + G_AddEvent(self, EV_EXPLODESHELL, killer); self->takedamage = qfalse; self->s.eType = ET_INVISIBLE; self->r.contents = 0; } -void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) { - int contents; - contents = trap_PointContents( self->r.currentOrigin, -1 ); - if(rpg_medicsrevive.integer == 1 && !( contents & CONTENTS_NODROP ) && (meansOfDeath != MOD_TRIGGER_HURT)){ - if ( self->health > GIB_HEALTH_IMPOSSIBLE ) { - return; - } - - }else{ - if ( self->health > GIB_HEALTH ) { - return; - } - } - GibEntity( self, 0 ); -} - - -// these are just for logging, the client prints its own messages -char *modNames[MOD_MAX] = { - "MOD_UNKNOWN", - - "MOD_WATER", - "MOD_SLIME", - "MOD_LAVA", - "MOD_CRUSH", - "MOD_TELEFRAG", - "MOD_FALLING", - "MOD_SUICIDE", - "MOD_TARGET_LASER", - "MOD_TRIGGER_HURT", - - // Trek weapons - "MOD_PHASER", - "MOD_PHASER_ALT", - "MOD_CRIFLE", - "MOD_CRIFLE_SPLASH", - "MOD_CRIFLE_ALT", - "MOD_CRIFLE_ALT_SPLASH", - "MOD_IMOD", - "MOD_IMOD_ALT", - "MOD_SCAVENGER", - "MOD_SCAVENGER_ALT", - "MOD_SCAVENGER_ALT_SPLASH", - "MOD_STASIS", - "MOD_STASIS_ALT", - "MOD_GRENADE", - "MOD_GRENADE_ALT", - "MOD_GRENADE_SPLASH", - "MOD_GRENADE_ALT_SPLASH", - "MOD_TETRYON", - "MOD_TETRYON_ALT", - "MOD_DREADNOUGHT", - "MOD_DREADNOUGHT_ALT", - "MOD_QUANTUM", - "MOD_QUANTUM_SPLASH", - "MOD_QUANTUM_ALT", - "MOD_QUANTUM_ALT_SPLASH", - - "MOD_DETPACK", - "MOD_SEEKER" - - //expansion pack - "MOD_KNOCKOUT", - "MOD_ASSIMILATE", - "MOD_BORG", - "MOD_BORG_ALT", - - "MOD_RESPAWN", - "MOD_EXPLOSION", -};//must be kept up to date with bg_public, meansOfDeath_t - -extern void DetonateDetpack(gentity_t *ent); - -/* -================== -G_Client_Die -Heavly Modifyed By: RedTechie -RPG-X: Marcin: a little bit modified - 30/12/2008 -================== -*/ -extern char *ClassNameForValue( pclass_t pClass ); -void G_Client_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) { - //--------------------- - //RPG-X: RedTechie - Check to see if medics revive people and not respawn if true use my fake death insead :) - //--------------------- - int contents; - - //RPG-X: RedTechie - Make sure there not getting killed by a trigger kill or the medics wont be able to heal them - contents = trap_PointContents( self->r.currentOrigin, -1 ); - - if(rpg_medicsrevive.integer == 1 && !( contents & CONTENTS_NODROP ) && (meansOfDeath != MOD_TRIGGER_HURT)){ - int anim; - char *classname = NULL; - gentity_t *detpack = NULL; - int killer; - char *killerName, *obit; - gentity_t *ent; - int i; - playerState_t *ps = &self->client->ps; - - //RPG-X: RedTechie - Blow up a detpack if some one placed it and died - classname = BG_FindClassnameForHoldable(HI_DETPACK); - if (classname) - { - while ((detpack = G_Find (detpack, FOFS(classname), classname)) != NULL) - { - if (detpack->parent == self) - { - detpack->think = DetonateDetpack; // Detonate next think. - detpack->nextthink = level.time; - } - } - } - - - //RPG-X: Redtechie - Do some score keeping witch we commented out and log - if ( attacker ) { - killer = attacker->s.number; - if ( attacker->client ) { - killerName = attacker->client->pers.netname; - } else { - killerName = ""; - } - } else { - killer = ENTITYNUM_WORLD; - killerName = ""; - } - - if ( killer < 0 || killer >= MAX_CLIENTS ) { - killer = ENTITYNUM_WORLD; - killerName = ""; - } - - if ( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) { - obit = ""; - } else { - obit = modNames[ meansOfDeath ]; - } - - G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n", - killer, self->s.number, meansOfDeath, killerName, - self->client->pers.netname, obit ); - - G_LogWeaponKill(killer, meansOfDeath); - G_LogWeaponDeath(self->s.number, self->s.weapon); - if (attacker && attacker->client && attacker->inuse) - { - G_LogWeaponFrag(killer, self->s.number); - } - - if ( meansOfDeath != MOD_RESPAWN && meansOfDeath != MOD_CUSTOM_DIE ) - { - // broadcast the death event to everyone - ent = G_TempEntity( self->r.currentOrigin, EV_OBITUARY ); - ent->s.eventParm = meansOfDeath; - ent->s.otherEntityNum = self->s.number; - ent->s.otherEntityNum2 = killer; - ent->r.svFlags = SVF_BROADCAST; // send to everyone - } - - self->enemy = attacker; - - ps->persistant[PERS_KILLED]++; - if (self == attacker) - { - self->client->pers.teamState.suicides++; - } else { - //RPG-X | Phenix | 06/04/2005 - // N00b Protection, you kill two people and puff your auto n00b! - - if ( attacker ) { - if ( attacker->client ) { - if ( IsAdmin( attacker ) == qfalse ) { - attacker->n00bCount++; - - attacker->client->fraggerTime = level.time + (rpg_fraggerSpawnDelay.integer * 1000); - - if (rpg_kickAfterXkills.integer < 1) - { - trap_SendServerCommand( attacker-g_entities, va("print \"^7Server: You have been caught n00bing, you have been temporary put in the n00b class.\n\"" ) ); - } else { - trap_SendServerCommand( attacker-g_entities, va("print \"^7Server: You have been caught n00bing, %i more times and you will be kicked.\n\"", (rpg_kickAfterXkills.integer - attacker->n00bCount) ) ); - } - - if ((attacker->n00bCount >= rpg_kickAfterXkills.integer) && (rpg_kickAfterXkills.integer != 0)) - { - trap_DropClient( attacker->s.number, "Kicked: Do Not N00b!" ); - } else { - for( i=0; g_classData[i].consoleName[0] && i < MAX_CLASSES; i++ ) - { - if ( g_classData[i].isn00b) { - char conName[64]; - trap_Cvar_VariableStringBuffer( va( "rpg_%sPass", conName ), conName, sizeof(conName) ); - - Q_strncpyz(attacker->client->origClass, ClassNameForValue( attacker->client->sess.sessionClass ), sizeof(attacker->client->origClass)); - attacker->client->n00bTime = level.time + 10000; - SetClass( attacker, conName, NULL, qfalse ); - break; - } - } - } - } - } - } - } - - //RPG-X: RedTechie no noclip - if ( self->client->noclip ) { - self->client->noclip = qfalse; - } - - //RPG-X: RedTechie - Toss items - //RPG-X: Marcin - not when respawning - 30/12/2008 - if ( meansOfDeath != MOD_RESPAWN ) { - TossClientItems( self, qfalse ); - } - - ps->pm_type = PM_DEAD; - - self->takedamage = qfalse; - - ps->weapon = WP_0; - ps->weaponstate = WEAPON_READY; - self->r.contents = CONTENTS_CORPSE; - - //-TiM - - self->s.loopSound = 0; - - self->r.maxs[2] = -8; - - //RPG-X: RedTechie - Wait....forever - self->client->respawnTime = level.time + 1000000000; - - //Clear powerups - //TiM - Bookmark - //memset( ps->powerups, 0, sizeof(ps->powerups) ); - - //Play death sound - //RPG-X: RedTechie - No pain sound when they change class - if(meansOfDeath != MOD_RESPAWN){ - G_AddEvent( self, irandom(EV_DEATH1, EV_DEATH3), killer ); - //if we died from falling, add a nice "splat' sound lol - if ( meansOfDeath == MOD_FALLING ) { - G_AddEvent( self, EV_SPLAT, killer ); - } - } - - //RPG-X : Model system - Death animations now based on vector hit - if (meansOfDeath == MOD_FALLING ) { - anim = BOTH_FALLDEATH1LAND; - } - else if ( self->waterlevel == 3 ) { - anim = BOTH_FLOAT2; - } - else { - if (meansOfDeath == MOD_PHASER || meansOfDeath == MOD_PHASER_ALT ) { - if (self->client->lasthurt_location & LOCATION_FRONT ) { - anim = BOTH_DEATHBACKWARD1; - } - else if ( self->client->lasthurt_location & LOCATION_BACK ) { - anim = BOTH_DEATHFORWARD2; - } - else if ( self->client->lasthurt_location & LOCATION_LEFT ) { - anim = BOTH_DEATH2; - } - else if ( self->client->lasthurt_location & LOCATION_RIGHT ) { - anim = BOTH_DEATH2; - } - else { - anim = BOTH_DEATH1; - } - } - else { - if (self->client->lasthurt_location & LOCATION_FRONT ) { - anim = BOTH_DEATHBACKWARD2; - } - else if ( self->client->lasthurt_location & LOCATION_BACK ) { - anim = BOTH_DEATHFORWARD1; - } - else if ( self->client->lasthurt_location & LOCATION_LEFT ) { - anim = BOTH_DEATHFORWARD2; - } - else if ( self->client->lasthurt_location & LOCATION_RIGHT ) { - anim = BOTH_DEATHFORWARD2; - } - else { - anim = BOTH_DEATH1; - } - } - } - - //TiM - ps->stats[LEGSANIM] = - ( ( ps->stats[LEGSANIM] & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; - ps->stats[TORSOANIM] = - ( ( ps->stats[TORSOANIM] & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; - - trap_LinkEntity (self); - - BG_PlayerStateToEntityState( &self->client->ps, &self->s, qtrue ); - - G_Client_UserinfoChanged( self->s.clientNum ); - - ClientEndFrame( self ); - - G_Client_StoreClientInitialStatus( self ); - //--------------------- - //RPG-X: RedTechie - If it dose equal 0 use regular die - //--------------------- - }else{ - gentity_t *ent; - int anim; - int killer; - int i; - char *killerName, *obit; - gentity_t *detpack = NULL; - char *classname = NULL; - int BottomlessPitDeath; - static int deathNum; - playerState_t *ps = &self->client->ps; - - if ( ps->pm_type == PM_DEAD ) { - return; - } - - if ( level.intermissiontime ) { - return; - } - - //RPG-X: RedTechie - Trying to make sure player dies when there health is 1 without medics revive turned on - //RPG-X | Phenix | 05/04/2005 - Read learn that "=" sets where "==" is an if statement!!! - if (self->health == 1) { - self->health = 0; - } - - ps->pm_type = PM_DEAD; - //need to copy health here because pm_type was getting reset to PM_NORMAL if ClientThink_real was called before the STAT_HEALTH was updated - ps->stats[STAT_HEALTH] = self->health; - - // check if we are in a NODROP Zone and died from a TRIGGER HURT - // if so, we assume that this resulted from a fall to a "bottomless pit" and - // treat it differently... - // - // Any problems with other places in the code? - // - BottomlessPitDeath = 0; // initialize - - contents = trap_PointContents( self->r.currentOrigin, -1 ); - if ( ( contents & CONTENTS_NODROP ) && (meansOfDeath == MOD_TRIGGER_HURT) ) - { - BottomlessPitDeath = 1; - } - - // similarly, if El Corpso here has already dropped a detpack, blow it up - classname = BG_FindClassnameForHoldable(HI_DETPACK); - if (classname) - { - while ((detpack = G_Find (detpack, FOFS(classname), classname)) != NULL) - { - if (detpack->parent == self) - { - detpack->think = DetonateDetpack; // Detonate next think. - detpack->nextthink = level.time; - } - } - } - - if ( attacker ) { - killer = attacker->s.number; - if ( attacker->client ) { - killerName = attacker->client->pers.netname; - } else { - killerName = ""; - } - } else { - killer = ENTITYNUM_WORLD; - killerName = ""; - } - - if ( killer < 0 || killer >= MAX_CLIENTS ) { - killer = ENTITYNUM_WORLD; - killerName = ""; - } - - if ( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) { - obit = ""; - } else { - obit = modNames[ meansOfDeath ]; - } - - G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n", - killer, self->s.number, meansOfDeath, killerName, - self->client->pers.netname, obit ); - - G_LogWeaponKill(killer, meansOfDeath); - G_LogWeaponDeath(self->s.number, self->s.weapon); - if (attacker && attacker->client && attacker->inuse) - { - G_LogWeaponFrag(killer, self->s.number); - } - - if ( meansOfDeath != MOD_RESPAWN ) - { - // broadcast the death event to everyone - ent = G_TempEntity( self->r.currentOrigin, EV_OBITUARY ); - ent->s.eventParm = meansOfDeath; - ent->s.otherEntityNum = self->s.number; - ent->s.otherEntityNum2 = killer; - ent->r.svFlags = SVF_BROADCAST; // send to everyone - } - - self->enemy = attacker; - - ps->persistant[PERS_KILLED]++; - if (self == attacker) - { - self->client->pers.teamState.suicides++; - } - - //RPG-X: Redtechie - No awards or score calculations - //////////////////////////////////////////////////////////////////////// - if (attacker && attacker->client) - { - if ( attacker == self ) - { - if ( meansOfDeath != MOD_RESPAWN ) - {//just changing class - G_Client_AddScore( attacker, -1 ); - } - } - else - { - attacker->client->pers.teamState.frags++; - G_Client_AddScore( attacker, 1 ); - - // Check to see if the player is on a streak. - attacker->client->streakCount++; - - attacker->client->lastKillTime = level.time; - } - } - else - { - if ( meansOfDeath != MOD_RESPAWN ) - {//not just changing class - G_Client_AddScore( self, -1 ); - } - } - //////////////////////////////////////////////////////////////////////// - - //RPG-X: Redtechie - agian no need - // Add team bonuses - //Team_FragBonuses(self, inflictor, attacker); - - // if client is in a nodrop area, don't drop anything (but return CTF flags!) - if ( !( contents & CONTENTS_NODROP ) /*&& self->client->sess.sessionClass != PC_ACTIONHERO*/ && meansOfDeath != MOD_SUICIDE && meansOfDeath != MOD_RESPAWN ) - {//action hero doesn't drop stuff - //don't drop stuff in specialty mode - if ( meansOfDeath != MOD_RESPAWN ) { - TossClientItems( self, qfalse ); - } - } - - DeathmatchScoreboardMessage(self); // show scores - // send updated scores to any clients that are following this one, - // or they would get stale scoreboards - for ( i = 0 ; i < level.maxclients ; i++ ) { - gclient_t *client; - - client = &level.clients[i]; - if ( client->pers.connected != CON_CONNECTED ) { - continue; - } - if ( client->sess.sessionTeam != TEAM_SPECTATOR ) { - continue; - } - if ( client->sess.spectatorClient == self->s.number ) { - DeathmatchScoreboardMessage(g_entities + i); - } - } - - self->takedamage = qtrue; // can still be gibbed - - self->s.weapon = WP_0; - self->s.powerups = 0; - self->r.contents = CONTENTS_CORPSE; - - self->s.loopSound = 0; - - self->r.maxs[2] = -8; - - // don't allow respawn until the death anim is done - // g_forcerespawn may force spawning at some later time - self->client->respawnTime = level.time + 1700; - - // We always want to see the body for special animations, so make sure not to gib right away: - if (meansOfDeath==MOD_CRIFLE_ALT || - meansOfDeath==MOD_DETPACK || - meansOfDeath==MOD_QUANTUM_ALT || - meansOfDeath==MOD_DREADNOUGHT_ALT || - meansOfDeath==MOD_PHASER_ALT)//RPG-X: RedTechie - Added phaser alt disnt - { self->health=0;} - - //RPG-X : Model system - Death animations now based on vector hit - if (meansOfDeath == MOD_FALLING ) { - anim = BOTH_FALLDEATH1LAND; - } - else if ( self->waterlevel == 3 ) { - anim = BOTH_FLOAT2; - } - else { - if (meansOfDeath == MOD_PHASER || meansOfDeath == MOD_PHASER_ALT ) { - if (self->client->lasthurt_location & LOCATION_FRONT ) { - anim = BOTH_DEATHBACKWARD1; - } - else if ( self->client->lasthurt_location & LOCATION_BACK ) { - anim = BOTH_DEATHFORWARD2; - } - else if ( self->client->lasthurt_location & LOCATION_LEFT ) { - anim = BOTH_DEATH2; - } - else if ( self->client->lasthurt_location & LOCATION_RIGHT ) { - anim = BOTH_DEATH2; - } - else { - anim = BOTH_DEATH1; - } - } - else { - if (self->client->lasthurt_location & LOCATION_FRONT ) { - anim = BOTH_DEATHBACKWARD2; - } - else if ( self->client->lasthurt_location & LOCATION_BACK ) { - anim = BOTH_DEATHFORWARD1; - } - else if ( self->client->lasthurt_location & LOCATION_LEFT ) { - anim = BOTH_DEATHFORWARD2; - } - else if ( self->client->lasthurt_location & LOCATION_RIGHT ) { - anim = BOTH_DEATHFORWARD2; - } - else { - anim = BOTH_DEATH1; - } - } - } - - ps->stats[LEGSANIM] = - ( ( ps->stats[LEGSANIM] & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; - ps->stats[TORSOANIM] = - ( ( ps->stats[TORSOANIM] & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; - - if ( (BottomlessPitDeath==1) && (killer == ENTITYNUM_WORLD)) - { - //G_AddEvent( self, EV_FALL_FAR, killer ); ?? Need to play falling SF now, or - // use designer trigger?? - //FIXME: need *some* kind of death anim! - } - else - { - // normal death - - switch(meansOfDeath) - { - case MOD_PHASER_ALT: //RPG-X: RedTechie - Added better effect for alt phaser - if(rpg_phaserdisintegrates.integer == 1){//RPG-X: RedTechie - Check to see if we want this - G_AddEvent( self, EV_DISINTEGRATION, killer ); - ps->powerups[PW_DISINTEGRATE] = level.time + 100000; - VectorClear( ps->velocity ); - self->takedamage = qfalse; - self->r.contents = 0; - } - break; - case MOD_CRIFLE_ALT: - break; - case MOD_QUANTUM_ALT: - G_AddEvent( self, EV_DISINTEGRATION2, killer ); - ps->powerups[PW_EXPLODE] = level.time + 100000; - VectorClear( ps->velocity ); - self->takedamage = qfalse; - self->r.contents = 0; - break; - case MOD_SCAVENGER_ALT: - case MOD_SCAVENGER_ALT_SPLASH: - case MOD_GRENADE: - case MOD_GRENADE_ALT: - case MOD_GRENADE_SPLASH: - case MOD_GRENADE_ALT_SPLASH: - case MOD_QUANTUM: - case MOD_QUANTUM_SPLASH: - case MOD_QUANTUM_ALT_SPLASH: - case MOD_DETPACK: - G_AddEvent( self, EV_EXPLODESHELL, killer ); - ps->powerups[PW_EXPLODE] = level.time + 100000; - VectorClear( ps->velocity ); - self->takedamage = qfalse; - self->r.contents = 0; - break; - case MOD_DREADNOUGHT: - case MOD_DREADNOUGHT_ALT: - G_AddEvent( self, EV_ARCWELD_DISINT, killer); - ps->powerups[PW_ARCWELD_DISINT] = level.time + 100000; - VectorClear( ps->velocity ); - self->takedamage = qfalse; - self->r.contents = 0; - break; - case MOD_FALLING: - G_AddEvent( self, EV_SPLAT, killer ); - break; - default: - G_AddEvent( self, irandom(EV_DEATH1, EV_DEATH3), killer ); - break; - } - - // the body can still be gibbed - self->die = body_die; - - } - // globally cycle through the different death animations - deathNum = ( deathNum + 1 ) % 3; - - trap_LinkEntity (self); - }//RPG-X: RedTechie - End of my if statment for medics revive check -}//RPG-X: RedTechie - End of void - #define BORG_ADAPT_NUM_HITS 10 -static qboolean G_CheckBorgAdaptation( gentity_t *targ, int mod ) -{ - int weapon = 0; - if ( !targ->client ) - { - return qfalse; - } +/** + * \brief Checks if borg have adapted to a specified damage type. + * \param targ The target. + * \param mod The damage type. + */ +static qboolean G_Combat_CheckBorgAdaptation(gentity_t* targ, int32_t mod) { + int32_t weapon = 0; - switch( mod ) - { - //other kinds of damage - case MOD_UNKNOWN: - case MOD_WATER: - case MOD_SLIME: - case MOD_LAVA: - case MOD_CRUSH: - case MOD_TELEFRAG: - case MOD_FALLING: - case MOD_SUICIDE: - case MOD_RESPAWN: - case MOD_TARGET_LASER: - case MOD_TRIGGER_HURT: - case MOD_DETPACK: - case MOD_MAX: - case MOD_KNOCKOUT: - case MOD_EXPLOSION: - return qfalse; - break; - // Trek weapons - case MOD_PHASER: - case MOD_PHASER_ALT: - weapon = WP_5; - break; - case MOD_CRIFLE: - case MOD_CRIFLE_SPLASH: - case MOD_CRIFLE_ALT: - case MOD_CRIFLE_ALT_SPLASH: - weapon = WP_6; - break; - case MOD_SCAVENGER: - case MOD_SCAVENGER_ALT: - case MOD_SCAVENGER_ALT_SPLASH: - case MOD_SEEKER: - weapon = WP_4; - break; - case MOD_STASIS: - case MOD_STASIS_ALT: - weapon = WP_10; - break; - case MOD_GRENADE: - case MOD_GRENADE_ALT: - case MOD_GRENADE_SPLASH: - case MOD_GRENADE_ALT_SPLASH: - weapon = WP_8; - break; - case MOD_TETRION: - case MOD_TETRION_ALT: - weapon = WP_7; - break; - case MOD_DREADNOUGHT: - case MOD_DREADNOUGHT_ALT: - weapon = WP_13; - break; - case MOD_QUANTUM: - case MOD_QUANTUM_SPLASH: - case MOD_QUANTUM_ALT: - case MOD_QUANTUM_ALT_SPLASH: - weapon = WP_9; - break; - case MOD_IMOD: - case MOD_IMOD_ALT: - weapon = WP_3; - break; - case MOD_ASSIMILATE: - case MOD_BORG: - case MOD_BORG_ALT: - return qtrue; - break; + G_Assert(targ, qfalse); + G_Assert(targ->client, qfalse); + + switch (mod) { + //other kinds of damage + case MOD_UNKNOWN: + case MOD_WATER: + case MOD_SLIME: + case MOD_LAVA: + case MOD_CRUSH: + case MOD_TELEFRAG: + case MOD_FALLING: + case MOD_SUICIDE: + case MOD_RESPAWN: + case MOD_TARGET_LASER: + case MOD_TRIGGER_HURT: + case MOD_DETPACK: + case MOD_MAX: + case MOD_KNOCKOUT: + case MOD_EXPLOSION: + return qfalse; + break; + // Trek weapons + case MOD_PHASER: + case MOD_PHASER_ALT: + weapon = WP_5; + break; + case MOD_CRIFLE: + case MOD_CRIFLE_SPLASH: + case MOD_CRIFLE_ALT: + case MOD_CRIFLE_ALT_SPLASH: + weapon = WP_6; + break; + case MOD_SCAVENGER: + case MOD_SCAVENGER_ALT: + case MOD_SCAVENGER_ALT_SPLASH: + case MOD_SEEKER: + weapon = WP_4; + break; + case MOD_STASIS: + case MOD_STASIS_ALT: + weapon = WP_10; + break; + case MOD_GRENADE: + case MOD_GRENADE_ALT: + case MOD_GRENADE_SPLASH: + case MOD_GRENADE_ALT_SPLASH: + weapon = WP_8; + break; + case MOD_TETRION: + case MOD_TETRION_ALT: + weapon = WP_7; + break; + case MOD_DREADNOUGHT: + case MOD_DREADNOUGHT_ALT: + weapon = WP_13; + break; + case MOD_QUANTUM: + case MOD_QUANTUM_SPLASH: + case MOD_QUANTUM_ALT: + case MOD_QUANTUM_ALT_SPLASH: + weapon = WP_9; + break; + case MOD_IMOD: + case MOD_IMOD_ALT: + weapon = WP_3; + break; + case MOD_ASSIMILATE: + case MOD_BORG: + case MOD_BORG_ALT: + return qtrue; + break; } level.borgAdaptHits[weapon]++; - switch(weapon) { - case WP_5: - if(level.borgAdaptHits[WP_5] > rpg_adaptPhaserHits.integer) - return qtrue; - break; - case WP_6: - if(level.borgAdaptHits[WP_6] > rpg_adaptCrifleHits.integer) - return qtrue; - break; - case WP_10: - if(level.borgAdaptHits[WP_10] > rpg_adaptDisruptorHits.integer) - return qtrue; - break; - case WP_8: - if(level.borgAdaptHits[WP_8] > rpg_adaptGrenadeLauncherHits.integer) - return qtrue; - break; - case WP_7: - if(level.borgAdaptHits[WP_7] > rpg_adaptTR116Hits.integer) - return qtrue; - break; - case WP_9: - if(level.borgAdaptHits[WP_9] > rpg_adaptPhotonHits.integer) - return qtrue; - break; - default: - return qfalse; + switch (weapon) { + case WP_5: + if (level.borgAdaptHits[WP_5] > rpg_adaptPhaserHits.integer) + return qtrue; + break; + case WP_6: + if (level.borgAdaptHits[WP_6] > rpg_adaptCrifleHits.integer) + return qtrue; + break; + case WP_10: + if (level.borgAdaptHits[WP_10] > rpg_adaptDisruptorHits.integer) + return qtrue; + break; + case WP_8: + if (level.borgAdaptHits[WP_8] > rpg_adaptGrenadeLauncherHits.integer) + return qtrue; + break; + case WP_7: + if (level.borgAdaptHits[WP_7] > rpg_adaptTR116Hits.integer) + return qtrue; + break; + case WP_9: + if (level.borgAdaptHits[WP_9] > rpg_adaptPhotonHits.integer) + return qtrue; + break; + default: + return qfalse; } return qfalse; } -/* -============ -G_LocationDamage -============ -*/ -static int G_LocationDamage(vec3_t point, gentity_t* targ, gentity_t* attacker, int take) { - vec3_t bulletPath; - vec3_t bulletAngle; - - int clientHeight; - int clientFeetZ; - int clientRotation; - int bulletHeight; - int bulletRotation; // Degrees rotation around client. - // used to check Back of head vs. Face - int impactRotation; +/** + * \brief Determines body the location damage was dealt to. + * \param point Hit point. + * \param targ Target entity. + * \param attacker The attacker. + * \param take Determines whether the target entity can take damage. + */ +static int32_t G_Combat_LocationDamage(vec3_t point, gentity_t* targ, gentity_t* attacker, int32_t take) { + vec3_t bulletPath = { 0, 0, 0 }; + vec3_t bulletAngle = { 0, 0, 0 }; + int32_t clientHeight = 0; + int32_t clientFeetZ = 0; + int32_t clientRotation = 0; + int32_t bulletHeight = 0; + int32_t bulletRotation = 0; + int32_t impactRotation = 0; // First things first. If we're not damaging them, why are we here? - if (!take) + if (take == 0) { return 0; + } // Point[2] is the REAL world Z. We want Z relative to the clients feet // Where the feet are at [real Z] - clientFeetZ = targ->r.currentOrigin[2] + targ->r.mins[2]; + clientFeetZ = targ->r.currentOrigin[2] + targ->r.mins[2]; // How tall the client is [Relative Z] clientHeight = targ->r.maxs[2] - targ->r.mins[2]; // Where the bullet struck [Relative Z] bulletHeight = point[2] - clientFeetZ; // Get a vector aiming from the client to the bullet hit - VectorSubtract(targ->r.currentOrigin, point, bulletPath); + VectorSubtract(targ->r.currentOrigin, point, bulletPath); // Convert it into PITCH, ROLL, YAW vectoangles(bulletPath, bulletAngle); clientRotation = targ->client->ps.viewangles[YAW]; bulletRotation = bulletAngle[YAW]; - impactRotation = abs(clientRotation-bulletRotation); + impactRotation = abs(clientRotation - bulletRotation); impactRotation += 45; // just to make it easier to work with impactRotation = impactRotation % 360; // Keep it in the 0-359 range if (impactRotation < 90) { targ->client->lasthurt_location = LOCATION_BACK; - } - else if (impactRotation < 180) { + } else if (impactRotation < 180) { targ->client->lasthurt_location = LOCATION_RIGHT; - } - else if (impactRotation < 270) { + } else if (impactRotation < 270) { targ->client->lasthurt_location = LOCATION_FRONT; - } - else if (impactRotation < 360) { + } else if (impactRotation < 360) { targ->client->lasthurt_location = LOCATION_LEFT; - } - else { + } else { targ->client->lasthurt_location = LOCATION_NONE; } // The upper body never changes height, just distance from the feet if (bulletHeight > clientHeight - 2) { targ->client->lasthurt_location |= LOCATION_HEAD; - } - else if (bulletHeight > clientHeight - 8) { + } else if (bulletHeight > clientHeight - 8) { targ->client->lasthurt_location |= LOCATION_FACE; - } - else if (bulletHeight > clientHeight - 10) { + } else if (bulletHeight > clientHeight - 10) { targ->client->lasthurt_location |= LOCATION_SHOULDER; - } - else if (bulletHeight > clientHeight - 16) { + } else if (bulletHeight > clientHeight - 16) { targ->client->lasthurt_location |= LOCATION_CHEST; - } - else if (bulletHeight > clientHeight - 26) { + } else if (bulletHeight > clientHeight - 26) { targ->client->lasthurt_location |= LOCATION_STOMACH; - } - else if (bulletHeight > clientHeight - 29) { + } else if (bulletHeight > clientHeight - 29) { targ->client->lasthurt_location |= LOCATION_GROIN; - } - else if (bulletHeight < 4) { + } else if (bulletHeight < 4) { targ->client->lasthurt_location |= LOCATION_FOOT; - } - else { + } else { // The leg is the only thing that changes size when you duck, // so we check for every other parts RELATIVE location, and // whats left over must be the leg. @@ -964,61 +221,61 @@ static int G_LocationDamage(vec3_t point, gentity_t* targ, gentity_t* attacker, } // Check the location ignoring the rotation info - switch ( targ->client->lasthurt_location & - ~(LOCATION_BACK | LOCATION_LEFT | LOCATION_RIGHT | LOCATION_FRONT) ) - { - case LOCATION_HEAD: - take *= 1.8; - break; - case LOCATION_FACE: - if (targ->client->lasthurt_location & LOCATION_FRONT) - take *= 5.0; // Faceshots REALLY suck - else + switch ((targ->client->lasthurt_location & ~(LOCATION_BACK | LOCATION_LEFT | LOCATION_RIGHT | LOCATION_FRONT)) != 0) { + case LOCATION_HEAD: take *= 1.8; - break; - case LOCATION_SHOULDER: - if (targ->client->lasthurt_location & (LOCATION_FRONT | LOCATION_BACK)) - take *= 1.4; // Throat or nape of neck - else - take *= 1.1; // Shoulders - break; - case LOCATION_CHEST: - if (targ->client->lasthurt_location & (LOCATION_FRONT | LOCATION_BACK)) - take *= 1.3; // Belly or back - else - take *= 0.8; // Arms - break; - case LOCATION_STOMACH: - take *= 1.2; - break; - case LOCATION_GROIN: - if (targ->client->lasthurt_location & LOCATION_FRONT) - take *= 1.3; // Groin shot - break; - case LOCATION_LEG: - take *= 0.7; - break; - case LOCATION_FOOT: - take *= 0.5; - break; + break; + case LOCATION_FACE: + if ((targ->client->lasthurt_location & LOCATION_FRONT) != 0) { + take *= 5.0; // Faceshots REALLY suck + } else { + take *= 1.8; + } + break; + case LOCATION_SHOULDER: + if ((targ->client->lasthurt_location & (LOCATION_FRONT | LOCATION_BACK)) != 0) { + take *= 1.4; // Throat or nape of neck + } else { + take *= 1.1; // Shoulders + } + break; + case LOCATION_CHEST: + if ((targ->client->lasthurt_location & (LOCATION_FRONT | LOCATION_BACK)) != 0) { + take *= 1.3; // Belly or back + } else { + take *= 0.8; // Arms + } + break; + case LOCATION_STOMACH: + take *= 1.2; + break; + case LOCATION_GROIN: + if ((targ->client->lasthurt_location & LOCATION_FRONT) != 0) { + take *= 1.3; // Groin shot + } + break; + case LOCATION_LEG: + take *= 0.7; + break; + case LOCATION_FOOT: + take *= 0.5; + break; } return take; } -void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, - vec3_t dir, vec3_t point, int damage, int dflags, int mod ) { - gclient_t *client; - int take=0; - int knockback; - qboolean bFriend = qfalse; +void G_Combat_Damage(gentity_t* targ, gentity_t* inflictor, gentity_t* attacker, vec3_t dir, vec3_t point, int32_t damage, int32_t dflags, int32_t mod) { + int32_t take = 0; + int32_t knockback = 0; + qboolean bFriend = qfalse; + gclient_t* client = NULL; - if(!targ) return; + G_Assert(targ, (void)0); #ifdef G_LUA - if(targ->luaHurt && !targ->client) - { + if (targ->luaHurt && targ->client == NULL) { LuaHook_G_EntityHurt(targ->luaHurt, targ->s.number, inflictor->s.number, attacker->s.number); } #endif @@ -1029,42 +286,39 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, // the intermission has allready been qualified for, so don't // allow any extra scoring - if ( level.intermissionQueued ) { + if (level.intermissionQueued != 0) { return; } - if ( !inflictor ) { + if (inflictor == NULL) { inflictor = &g_entities[ENTITYNUM_WORLD]; } - if ( !attacker ) { + + if (attacker == NULL) { attacker = &g_entities[ENTITYNUM_WORLD]; } // shootable doors / buttons don't actually have any health - if ( ((targ->s.eType == ET_MOVER) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE)) || + if (((targ->s.eType == ET_MOVER) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE)) || ((targ->s.eType == ET_MOVER_STR) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE))) //RPG-X | GSIO01 | 13/05/2009 { - if ( targ->type == ENT_FUNC_FORCEFIELD ) - { - if ( targ->pain ) - { - targ->pain( targ, inflictor, take ); + if (targ->type == ENT_FUNC_FORCEFIELD) { + if (targ->pain != NULL) { + targ->pain(targ, inflictor, take); } - } - else if ( (targ->use != NULL) && ((targ->moverState == MOVER_POS1) || (targ->moverState == ROTATOR_POS1)) && (targ->type != ENT_FUNC_DOOR) && (targ->type != ENT_FUNC_DOOR_ROTATING) ) - { - targ->use( targ, inflictor, attacker ); + } else if ((targ->use != NULL) && ((targ->moverState == MOVER_POS1) || (targ->moverState == ROTATOR_POS1)) && (targ->type != ENT_FUNC_DOOR) && (targ->type != ENT_FUNC_DOOR_ROTATING)) { + targ->use(targ, inflictor, attacker); } return; } //RPG-X | GSIO01 | 08/05/2009: as we put borg adaption back in we need this again - if ( rpg_borgAdapt.integer > -1 && G_CheckBorgAdaptation( targ, mod ) && IsBorg(targ) ) - { + if (rpg_borgAdapt.integer > -1 && G_Combat_CheckBorgAdaptation(targ, mod) && G_Client_IsBorg(targ)) { //flag targ for adaptation effect targ->client->ps.powerups[PW_BORG_ADAPT] = level.time + 250; - if(rpg_adaptUseSound.integer == 1) + if (rpg_adaptUseSound.integer == 1) { G_AddEvent(targ, EV_ADAPT_SOUND, 0); + } return; } @@ -1073,69 +327,62 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, // reduce damage by the attacker's handicap value // unless they are rocket jumping - if ( attacker->client && attacker != targ ) { + if (attacker->client != NULL && attacker != targ) { damage = damage * attacker->client->ps.stats[STAT_MAX_HEALTH] / 100; } client = targ->client; - if ( client ) - { - if ( client == NULL || client->noclip ) { + if (client != NULL) { + if (client == NULL || client->noclip) { return; } } - if ( !dir ) { + if (dir == NULL) { dflags |= DAMAGE_NO_KNOCKBACK; } else { VectorNormalize(dir); } knockback = damage; - if ( knockback > 200 ) { + if (knockback > 200) { knockback = 200; } - if ( targ->flags & FL_NO_KNOCKBACK ) { + if (targ->flags & FL_NO_KNOCKBACK) { knockback = 0; } - if ( dflags & DAMAGE_NO_KNOCKBACK ) { + if (dflags & DAMAGE_NO_KNOCKBACK) { knockback = 0; } - knockback = floor( knockback*g_dmgmult.value ) ; + knockback = floor(knockback * g_dmgmult.value); // figure momentum add, even if the damage won't be taken - if ( knockback && targ->client ) - { + if (knockback && targ->client != NULL) { //if it's non-radius damage knockback from a teammate, don't do it if the damage won't be taken - if ( (dflags&DAMAGE_ALL_TEAMS) || (dflags&DAMAGE_RADIUS) || !attacker->client ) - { - vec3_t kvel; - float mass; + if ((dflags & DAMAGE_ALL_TEAMS) != 0 || (dflags & DAMAGE_RADIUS) != 0 || attacker->client == NULL) { + double mass = 200; + vec3_t kvel = { 0, 0, 0 }; - mass = 200; - - if (targ->client->ps.powerups[PW_FLIGHT]) - { + if (targ->client->ps.powerups[PW_FLIGHT] != 0) { mass *= 0.375; } - if(dir) { - VectorScale (dir, g_knockback.value * (float)knockback / mass, kvel); - VectorAdd (targ->client->ps.velocity, kvel, targ->client->ps.velocity); + if (dir != NULL) { + VectorScale(dir, g_knockback.value * (double)knockback / mass, kvel); + VectorAdd(targ->client->ps.velocity, kvel, targ->client->ps.velocity); } // set the timer so that the other client can't cancel // out the movement immediately - if ( !targ->client->ps.pm_time ) { - int t; + if (targ->client->ps.pm_time == 0) { + int32_t t = knockback * 2; - t = knockback * 2; - if ( t < 50 ) { + if (t < 50) { t = 50; } - if ( t > 200 ) { + if (t > 200) { t = 200; } targ->client->ps.pm_time = t; @@ -1145,31 +392,24 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, } // check for godmode - if ( targ->flags & FL_GODMODE ) { + if ((targ->flags & FL_GODMODE) != 0) { return; } // always give half damage if hurting self // calculated after knockback, so rocket jumping works - if ( rpg_selfdamage.integer != 0 ) - { - if ( targ == attacker) - { + if (rpg_selfdamage.integer != 0) { + if (targ == attacker) { damage *= 0.5; } - if ( damage < 1 ) - { + if (damage < 1) { damage = 1; } - } - else - { - if ( targ == attacker) - { + } else { + if (targ == attacker) { damage *= 0.0; } - if ( damage < 1 ) - { + if (damage < 1) { damage = 0; } } @@ -1181,16 +421,15 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, //asave = CheckArmor (targ, take, dflags); //take -= asave; - if ( g_debugDamage.integer ) { - G_Printf( "%i: client:%i health:%i damage:%i armor:\n", level.time, targ->s.number, - targ->health, take ); + if (g_debugDamage.integer != 0) { + G_Printf("%i: client:%i health:%i damage:%i armor:\n", level.time, targ->s.number, targ->health, take); } // add to the damage inflicted on a player this frame // the total will be turned into screen blends and view angle kicks // at the end of the frame - if ( client ) { - if ( attacker ) { + if (client != NULL) { + if (attacker != NULL) { client->ps.persistant[PERS_ATTACKER] = attacker->s.number; } else { client->ps.persistant[PERS_ATTACKER] = ENTITYNUM_WORLD; @@ -1198,40 +437,35 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, //RPG-X: - RedTechie no armor in RPG client->damage_blood += take; client->damage_knockback += knockback; - if ( dir ) { - VectorCopy ( dir, client->damage_from ); + if (dir != NULL) { + VectorCopy(dir, client->damage_from); client->damage_fromWorld = qfalse; } else { - VectorCopy ( targ->r.currentOrigin, client->damage_from ); + VectorCopy(targ->r.currentOrigin, client->damage_from); client->damage_fromWorld = qtrue; } } - if (targ->client) { + if (targ->client != NULL) { // set the last client who damaged the target targ->client->lasthurt_client = attacker->s.number; targ->client->lasthurt_mod = mod; // Modify the damage for location damage - if (point && targ && targ->health > 1 && attacker && take) - take = G_LocationDamage(point, targ, attacker, take); - else + if (point != NULL && targ != NULL && targ->health > 1 && attacker != NULL && take != 0) { + take = G_Combat_LocationDamage(point, targ, attacker, take); + } else { targ->client->lasthurt_location = LOCATION_NONE; + } } // do the damage - if (take > 0 ) - { + if (take > 0) { // add to the attacker's hit counter - if ( (MOD_TELEFRAG != mod) && attacker->client && targ != attacker && targ->health > 0 ) - {//don't telefrag since damage would wrap when sent as a short and the client would think it's a team dmg. - if (bFriend) - { + if ((MOD_TELEFRAG != mod) && attacker->client != NULL && targ != attacker && targ->health > 0) {//don't telefrag since damage would wrap when sent as a short and the client would think it's a team dmg. + if (bFriend) { attacker->client->ps.persistant[PERS_HITS] -= damage; - } - else if (targ->classname && strcmp(targ->classname, "holdable_shield") // no stupid hit noise when players shoot a shield -- dpk - && strcmp(targ->classname, "holdable_detpack")) // or the detpack either - { + } else if (targ->classname != NULL && strcmp(targ->classname, "holdable_shield") == 0 && strcmp(targ->classname, "holdable_detpack") == 0) { attacker->client->ps.persistant[PERS_HITS] += damage; } } @@ -1239,53 +473,51 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, targ->health = targ->health - take; //RPG-X: RedTechie - If medicrevive is on then health only goes down to 1 so we can simulate fake death - if((rpg_medicsrevive.integer == 1) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE) ){ - if(targ->health <= 0){ + if ((rpg_medicsrevive.integer == 1) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE)) { + if (targ->health <= 0) { targ->health = 1; } - }else { - if(rpg_medicsrevive.integer != 1) { + } else { + if (rpg_medicsrevive.integer != 1) { if (targ->health == 1) { //RPG-X: RedTechie: Ok regular die now kills the player at 1 health not 0 targ->health = 0; } } } - if ( targ->client ) - { + if (targ->client != NULL) { targ->client->ps.stats[STAT_HEALTH] = targ->health; } //RPG-X: RedTechie - Custum medicrevive code - if(rpg_medicsrevive.integer == 1 && targ->s.eType == ET_PLAYER ){ - if(targ->health == 1 ){ //TiM : Added Client to try and fix this stupid crashy bug - client->ps.stats[STAT_WEAPONS] = ( 1 << WP_0 ); //?!!!!! + if (rpg_medicsrevive.integer == 1 && targ->s.eType == ET_PLAYER) { + if (targ->health == 1) { //TiM : Added Client to try and fix this stupid crashy bug + client->ps.stats[STAT_WEAPONS] = (1 << WP_0); //?!!!!! client->ps.stats[STAT_HOLDABLE_ITEM] = HI_NONE; targ->health = 1; - G_Client_Die( targ, inflictor, attacker, take, mod ); + G_Client_Die(targ, inflictor, attacker, take, mod); } - }else{ - if ( targ->health <= 0 ) { - if ( client ) + } else { + if (targ->health <= 0) { + if (client) targ->flags |= FL_NO_KNOCKBACK; if (targ->health < -999) targ->health = -999; #ifdef G_LUA - if(targ->luaDie && !targ->client) - { + if (targ->luaDie && targ->client == NULL) { LuaHook_G_EntityDie(targ->luaDie, targ->s.number, inflictor->s.number, attacker->s.number, take, mod); } #endif targ->enemy = attacker; - targ->die (targ, inflictor, attacker, take, mod); + targ->die(targ, inflictor, attacker, take, mod); return; - } + } - if ( targ->pain ) { - targ->pain (targ, attacker, take); + if (targ->pain != NULL) { + targ->pain(targ, attacker, take); } } G_LogWeaponDamage(attacker->s.number, mod, take); @@ -1293,115 +525,131 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, } -qboolean CanDamage (gentity_t *targ, vec3_t origin) { - vec3_t dest; +qboolean G_Combat_CanDamage(gentity_t* targ, vec3_t origin) { + vec3_t dest = { 0, 0, 0 }; + vec3_t midpoint = { 0, 0, 0 }; trace_t tr; - vec3_t midpoint; // use the midpoint of the bounds instead of the origin, because // bmodels may have their origin is 0,0,0 - VectorAdd (targ->r.absmin, targ->r.absmax, midpoint); - VectorScale (midpoint, 0.5, midpoint); + VectorAdd(targ->r.absmin, targ->r.absmax, midpoint); + VectorScale(midpoint, 0.5, midpoint); - VectorCopy (midpoint, dest); - trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); - if (tr.fraction == 1.0) + VectorCopy(midpoint, dest); + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); + if (tr.fraction == 1.0) { return qtrue; + } // this should probably check in the plane of projection, // rather than in world coordinate, and also include Z - VectorCopy (midpoint, dest); + VectorCopy(midpoint, dest); dest[0] += 15.0; dest[1] += 15.0; - trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); - if (tr.fraction == 1.0) + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); + if (tr.fraction == 1.0) { return qtrue; + } - VectorCopy (midpoint, dest); + VectorCopy(midpoint, dest); dest[0] += 15.0; dest[1] -= 15.0; - trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); - if (tr.fraction == 1.0) + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); + if (tr.fraction == 1.0) { return qtrue; + } - VectorCopy (midpoint, dest); + VectorCopy(midpoint, dest); dest[0] -= 15.0; dest[1] += 15.0; - trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); - if (tr.fraction == 1.0) + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); + if (tr.fraction == 1.0) { return qtrue; + } - VectorCopy (midpoint, dest); + VectorCopy(midpoint, dest); dest[0] -= 15.0; dest[1] -= 15.0; - trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); - if (tr.fraction == 1.0) + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); + if (tr.fraction == 1.0) { return qtrue; - + } return qfalse; } -extern void tripwireThink ( gentity_t *ent ); -qboolean G_RadiusDamage ( vec3_t origin, gentity_t *attacker, float damage, float radius, - gentity_t *ignore, int dflags, int mod) { - float points, dist; - gentity_t *ent; - int entityList[MAX_GENTITIES]; - int numListedEntities; - vec3_t mins, maxs; - vec3_t v; - vec3_t dir; - int i, e; - qboolean hitClient = qfalse; +qboolean G_Combat_RadiusDamage(vec3_t origin, gentity_t* attacker, double damage, double radius, gentity_t* ignore, int32_t dflags, int32_t mod) { + double points = 0; + double dist = 0; + qboolean hitClient = qfalse; + vec3_t mins = { 0, 0, 0 }; + vec3_t maxs = { 0, 0, 0 }; + vec3_t dir = { 0, 0, 0 }; + vec3_t v = { 0, 0, 0 }; + int32_t entityList[MAX_GENTITIES]; + int32_t numListedEntities = 0; + int32_t i = 0; + int32_t e = 0; + gentity_t* ent = NULL; - if ( radius < 1 ) { + if (radius < 1) { radius = 1; } - for ( i = 0 ; i < 3 ; i++ ) { + for (i = 0; i < 3; i++) { mins[i] = origin[i] - radius; maxs[i] = origin[i] + radius; } - numListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); + numListedEntities = trap_EntitiesInBox(mins, maxs, entityList, MAX_GENTITIES); - for ( e = 0 ; e < numListedEntities ; e++ ) { - ent = &g_entities[entityList[ e ]]; + for (e = 0; e < numListedEntities; e++) { + ent = &g_entities[entityList[e]]; - if (ent == ignore) + if (ent == NULL) { continue; - if (!ent->takedamage) + } + + if (ent == ignore) { continue; - if ( ignore != NULL && ignore->parent != NULL && ent->parent == ignore->parent ) - { - if ( ignore->think == tripwireThink && ent->think == tripwireThink ) - {//your own tripwires do not fire off other tripwires of yours. + } + + if (!ent->takedamage) { + continue; + } + + if (ignore != NULL && ignore->parent != NULL && ent->parent == ignore->parent) { + if (ignore->think == tripwireThink && ent->think == tripwireThink) {//your own tripwires do not fire off other tripwires of yours. continue; } } // find the distance from the edge of the bounding box - for ( i = 0 ; i < 3 ; i++ ) { - if ( origin[i] < ent->r.absmin[i] ) { + for (i = 0; i < 3; i++) { + if (origin[i] < ent->r.absmin[i]) { v[i] = ent->r.absmin[i] - origin[i]; - } else if ( origin[i] > ent->r.absmax[i] ) { + } else if (origin[i] > ent->r.absmax[i]) { v[i] = origin[i] - ent->r.absmax[i]; } else { v[i] = 0; } } - dist = VectorLength( v ); - if ( dist >= radius ) { + dist = VectorLength(v); + if (dist >= radius) { continue; } - points = damage * ( 1.0 - dist / radius ); + points = damage * (1.0 - dist / radius); - if( !CanDamage (ent, origin) ) { + if (!G_Combat_CanDamage(ent, origin)) { //no LOS to ent - if ( !(dflags & DAMAGE_HALF_NOTLOS) ) { + if ((dflags & DAMAGE_HALF_NOTLOS) == 0) { //not allowed to do damage without LOS continue; } else { @@ -1410,69 +658,43 @@ qboolean G_RadiusDamage ( vec3_t origin, gentity_t *attacker, float damage, floa } } - if( G_Weapon_LogAccuracyHit( ent, attacker ) ) { + if (G_Weapon_LogAccuracyHit(ent, attacker)) { hitClient = qtrue; } - VectorSubtract (ent->r.currentOrigin, origin, dir); + VectorSubtract(ent->r.currentOrigin, origin, dir); // push the center of mass higher than the origin so players // get knocked into the air more dir[2] += 24; - G_Damage (ent, NULL, attacker, dir, origin, (int)points, dflags|DAMAGE_RADIUS, mod); + G_Combat_Damage(ent, NULL, attacker, dir, origin, (int)points, dflags | DAMAGE_RADIUS, mod); } return hitClient; } -/* -============ -IsBorg -RPG-X | GSIO01 | 08/05/2009 -============ -*/ -/** -* Checks if a player is in a Class that is borg. -* \param ent the player -* -* \author Ubergames - GSIO01 -* \date 08/05/2009 -*/ -qboolean IsBorg(gentity_t *ent) { - if(!ent) - return qfalse; - if(!ent->client) - return qfalse; - if(g_classData[ent->client->sess.sessionClass].isBorg) - return qtrue; - else - return qfalse; -} - -extern void InitBBrush(gentity_t *ent); -extern void SP_misc_model_breakable(gentity_t* self); - -void G_Repair(gentity_t *ent, gentity_t *tr_ent, float rate) { - float distance; - vec3_t help, forward; - int i; - float max = 0; +void G_Combat_Repair(gentity_t* ent, gentity_t* tr_ent, double rate) { + double distance = 0; + double max = 0; + vec3_t help = { 0, 0, 0 }; + vec3_t forward = { 0, 0, 0 }; + int32_t i = 0; // if count isn't 0 the breakable is not damaged and if target is no breakable it does not make sense to go on - if((tr_ent->count != 0) || strstr(tr_ent->classname, "breakable") == NULL) { - return; + if ((tr_ent->count != 0) || strstr(tr_ent->classname, "breakable") == 0) { + return; } - if(!(tr_ent->spawnflags & 256)) { // no REPAIRABLE flag set + if ((tr_ent->spawnflags & 256) == 0) { // no REPAIRABLE flag set return; } // check if player is near the breakable - if(tr_ent->spawnflags & 512) { + if ((tr_ent->spawnflags & 512) != 0) { VectorSubtract(tr_ent->s.angles2, ent->r.currentOrigin, help); max = tr_ent->n00bCount; } else { VectorSubtract(tr_ent->s.origin, ent->r.currentOrigin, help); - for(i = 0; i < 3; i++) { - if(tr_ent->r.maxs[i] > max) { + for (i = 0; i < 3; i++) { + if (tr_ent->r.maxs[i] > max) { max = tr_ent->r.maxs[i]; } } @@ -1480,45 +702,45 @@ void G_Repair(gentity_t *ent, gentity_t *tr_ent, float rate) { distance = VectorLength(help); //G_Printf("goodDst=%f, curDst=%f\n", 80 + max, distance); - if(distance > 80 + max) { + if (distance > 80 + max) { return; } // check if the player is facing it AngleVectors(ent->client->ps.viewangles, forward, NULL, NULL); - if(DotProduct(help, forward) < 0.4) { + if (DotProduct(help, forward) < 0.4) { return; } // check wheter the breakable still needs to be repaired - if(tr_ent->health < tr_ent->damage) { + if (tr_ent->health < tr_ent->damage) { // still not repaired of let's go on tr_ent->health += rate; - if(tr_ent->health >= tr_ent->damage){//we're maxed out after this cycle, reenstate + if (tr_ent->health >= tr_ent->damage) {//we're maxed out after this cycle, reenstate tr_ent->health = tr_ent->damage; - if(tr_ent->target) { + if (tr_ent->target) { G_UseTargets2(tr_ent, tr_ent, tr_ent->target); } - if(tr_ent->type == ENT_FUNC_BREAKABLE) { + if (tr_ent->type == ENT_FUNC_BREAKABLE) { tr_ent->s.solid = CONTENTS_BODY; trap_SetBrushModel(tr_ent, tr_ent->model); tr_ent->r.svFlags &= ~SVF_NOCLIENT; tr_ent->s.eFlags &= ~EF_NODRAW; InitBBrush(tr_ent); - - if(tr_ent->health) { + + if (tr_ent->health) { tr_ent->takedamage = qtrue; } tr_ent->use = breakable_use; - if(tr_ent->paintarget) { + if (tr_ent->paintarget) { tr_ent->pain = breakable_pain; } tr_ent->clipmask = 0; tr_ent->count = 1; - } else if(tr_ent->type == ENT_MISC_MODEL_BREAKABLE) { + } else if (tr_ent->type == ENT_MISC_MODEL_BREAKABLE) { SP_misc_model_breakable(tr_ent); } } diff --git a/code/game/g_combat.h b/code/game/g_combat.h index b0aaad9..b609436 100644 --- a/code/game/g_combat.h +++ b/code/game/g_combat.h @@ -1,8 +1,81 @@ -#ifndef G_COMBAT_H_ -#define G_COMBAT_H_ - -#include "g_local.h" - -qboolean IsBorg( gentity_t* ent ); //GSIO01 | 08/05/2009 - +#ifndef G_COMBAT_H_ +#define G_COMBAT_H_ + +#include "g_local.h" + +// damage flags +#define DAMAGE_RADIUS 0x00000001 //!< damage was indirect +#define DAMAGE_NO_ARMOR 0x00000002 //!< armor (shields) do not protect from this damage +#define DAMAGE_NO_KNOCKBACK 0x00000008 //!< do not affect velocity, just view angles +#define DAMAGE_NO_PROTECTION 0x00000020 //!< armor, shields, invulnerability, and godmode have no effect +#define DAMAGE_NOT_ARMOR_PIERCING 0x00000000 //!< trek: shields fully protect from this damage (for clarity) +#define DAMAGE_ARMOR_PIERCING 0x00000040 //!< trek: shields don't fully protect from this damage +#define DAMAGE_NO_INVULNERABILITY 0x00000080 //!< trek: invulnerability doesn't event protect from this damage +#define DAMAGE_HALF_NOTLOS 0x00000100 //!< trek: radius damage still does 1/2 damage to ents that do not have LOS to explosion org but are in radius +#define DAMAGE_ALL_TEAMS 0x00000200 //!< trek: damage ignores teamdamage settings + +/** +* Damage all entities around an origin in a specified radius. +* +* \return Hit a client? +* \param origin Origin. +* \param attacker Attacker. +* \param damage Amount much damage. +* \param radius Radius. +* \param ignore Entity to ignore. +* \param dflags Damage flags. +* \param mod Means of death. +* \todo Replace ignore entity by list of entites. +*/ +qboolean G_Combat_RadiusDamage(vec3_t origin, gentity_t* attacker, double damage, double radius, gentity_t* ignore, int32_t dflags, int32_t mod); + +/** +* Repairs repairable entities. +* +* \param ent The player. +* \param tr_ent Entity to repair. +* \param rate Rate to repair with. +* \author Ubergames - GSIO01 +* \date 09/05/2009 +*/ +void G_Combat_Repair(gentity_t* ent, gentity_t* tr_ent, double rate); + +/** +* @brief Throws gibs and entity. +* @param self The entity. +* @param killer The killer. +*/ +void G_Combat_GibEntity(gentity_t* self, int32_t killer); + +/** + * brief Damage an entity. + * + * \param targ entity that is being damaged + * \param inflictor entity that is causing the damage + * \param attacker entity that caused the inflictor to damage targ + * \param dir direction of the attack for knockback + * \param point point at which the damage is being inflicted, used for headshots + * \param damage amount of damage being inflicted + * \param knockback force to be applied against targ as a result of the damage + * \param dflags these flags are used to control how G_Damage works + * \param mod means of death + * + * Damage flags: + * DAMAGE_RADIUS damage was indirect (from a nearby explosion) + * DAMAGE_NO_ARMOR armor does not protect from this damage + * DAMAGE_NO_KNOCKBACK do not affect velocity, just view angles + * DAMAGE_NO_PROTECTION kills godmode, armor, everything + */ +void G_Combat_Damage(gentity_t* targ, /*@null@*/ gentity_t* inflictor, /*@null@*/ gentity_t* attacker, /*@null@*/ vec3_t dir, /*@null@*/ vec3_t point, int32_t damage, int32_t dflags, int32_t mod); + +/** + * \brief Returns qtrue if the inflictor can directly damage the target. + * Used for explosions and melee attacks. + * + * \param targ the target + * \param origin the origin + * \return qtrue if the inflictor can directly damage the target. Used for explosions and melee attacks. + */ +qboolean G_Combat_CanDamage(gentity_t* targ, vec3_t origin); + #endif /* G_COMBAT_H_ */ \ No newline at end of file diff --git a/code/game/g_fx.c b/code/game/g_fx.c index e8a3469..c97aee2 100644 --- a/code/game/g_fx.c +++ b/code/game/g_fx.c @@ -3,6 +3,7 @@ #include "g_local.h" #include "g_spawn.h" #include "g_logger.h" +#include "g_combat.h" #define SPARK_STARTOFF 1 /*QUAKED fx_spark (0 0 1) (-8 -8 -8) (8 8 8) STARTOFF @@ -165,7 +166,7 @@ static void steam_think( gentity_t *ent ) gentity_t *victim = &g_entities[trace.entityNum]; if ( (victim != NULL) && victim->takedamage ) { - G_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); + G_Combat_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); } } } @@ -334,7 +335,7 @@ static void bolt_think( gentity_t *ent ) gentity_t *victim = &g_entities[trace.entityNum]; if ( (victim != NULL) && (victim->takedamage == qtrue) ) { - G_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_PHASER_ALT ); + G_Combat_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_PHASER_ALT ); } } } @@ -620,7 +621,7 @@ static void surface_explosion_use( gentity_t *self, /*@unused@*/ gentity_t *othe G_AddEvent( self, EV_FX_SURFACE_EXPLOSION, 0 ); if ( self->splashDamage != 0 ) { - G_RadiusDamage( self->r.currentOrigin, self, (float)self->splashDamage, (float)self->splashRadius, self, DAMAGE_RADIUS|DAMAGE_ALL_TEAMS, MOD_EXPLOSION ); + G_Combat_RadiusDamage( self->r.currentOrigin, self, (float)self->splashDamage, (float)self->splashRadius, self, DAMAGE_RADIUS|DAMAGE_ALL_TEAMS, MOD_EXPLOSION ); } } @@ -894,7 +895,7 @@ static void electrical_explosion_use( gentity_t *self, /*@unused@*/ gentity_t *o if ( self->splashDamage != 0 ) { - G_RadiusDamage( self->s.origin, self, (float)self->splashDamage, (float)self->splashRadius, self, 0, MOD_EXPLOSION ); + G_Combat_RadiusDamage( self->s.origin, self, (float)self->splashDamage, (float)self->splashRadius, self, 0, MOD_EXPLOSION ); } } @@ -1618,7 +1619,7 @@ static void forge_bolt_think( gentity_t *ent ) gentity_t *victim = &g_entities[trace.entityNum]; if ( victim != NULL && victim->takedamage == qtrue ) { - G_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); + G_Combat_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); } } } @@ -1763,7 +1764,7 @@ static void plasma_think( gentity_t *ent ) gentity_t *victim = &g_entities[trace.entityNum]; if ( victim != NULL && victim->takedamage == qtrue ) { - G_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); + G_Combat_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); } } } @@ -1896,7 +1897,7 @@ static void stream_think( gentity_t *ent ) gentity_t *victim = &g_entities[trace.entityNum]; if ( victim != NULL && victim->takedamage == qtrue ) { - G_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); + G_Combat_Damage( victim, ent, ent->activator, temp, trace.endpos, ent->damage, 0, MOD_LAVA ); } } } diff --git a/code/game/g_items.c b/code/game/g_items.c index 83f13ba..f7c0ccc 100644 --- a/code/game/g_items.c +++ b/code/game/g_items.c @@ -185,7 +185,7 @@ static char* Padd_Get( gentity_t* key, gentity_t* who ) //Inform admins for ( j = 0; j < level.maxclients; ++j ) { gentity_t *player = &g_entities[j]; - if ( (player != NULL) && (!player->client->noAdminChat) && IsAdmin( player ) && (rpg_respectPrivacy.integer == 0) && (player != who) && (paddData[i].value[0] != 0) ) { + if ( (player != NULL) && (!player->client->noAdminChat) && G_Client_IsAdmin( player ) && (rpg_respectPrivacy.integer == 0) && (player != who) && (paddData[i].value[0] != 0) ) { trap_SendServerCommand( player-g_entities, va("print \"%s" S_COLOR_CYAN" (picked up by %s" S_COLOR_CYAN ") " S_COLOR_WHITE "%s\n\"", paddData[i].owner, who->client->pers.netname, paddData[i].value ) ); } } @@ -567,7 +567,7 @@ static void Touch_Item (gentity_t* ent, gentity_t* other, trace_t* trace) { // the same pickup rules are used for client side and server side if ( !BG_CanItemBeGrabbed( &ent->s, &other->client->ps, Max_Weapon(other->client->ps.weapon) ) - && IsAdmin( other ) == qfalse ) + && G_Client_IsAdmin( other ) == qfalse ) { return; } @@ -630,7 +630,7 @@ static void Touch_Item (gentity_t* ent, gentity_t* other, trace_t* trace) { // fire item targets G_UseTargets (ent, other); - if ( rpg_weaponsStay.integer == 1 && IsAdmin( ent->parent ) == qtrue && IsAdmin( other ) == qfalse ) { + if ( rpg_weaponsStay.integer == 1 && G_Client_IsAdmin( ent->parent ) == qtrue && G_Client_IsAdmin( other ) == qfalse ) { return; } diff --git a/code/game/g_local.h b/code/game/g_local.h index 29b2d73..133905c 100644 --- a/code/game/g_local.h +++ b/code/game/g_local.h @@ -564,14 +564,6 @@ typedef struct { #define MAX_VOTE_COUNT 3 -/** - * Set the score for a client. - * - * \param ent The client. - * \param score New score for the client. - */ -void SetScore( gentity_t *ent, int score ); - /** * \brief client data that stays across multiple respawns, * @@ -1250,96 +1242,6 @@ int G_GetEntityByBmodel(char* bmodel,list_p entities); */ void AddRemap(const char* oldShader, const char* newShader, float timeOffset); -// -// g_combat.c -// -/** - * Returns qtrue if the inflictor can directly damage the target. Used for - * explosions and melee attacks. - * - * \param targ the target - * \param origin the origin - * \return qtrue if the inflictor can directly damage the target. Used for explosions and melee attacks. - */ -qboolean CanDamage (gentity_t* targ, vec3_t origin); - -/** - * Damage an entity. - * - * \param targ entity that is being damaged - * \param inflictor entity that is causing the damage - * \param attacker entity that caused the inflictor to damage targ - * \param dir direction of the attack for knockback - * \param point point at which the damage is being inflicted, used for headshots - * \param damage amount of damage being inflicted - * \param knockback force to be applied against targ as a result of the damage - * \param dflags these flags are used to control how G_Damage works - * \param mod means of death - * - * Damage flags: - * DAMAGE_RADIUS damage was indirect (from a nearby explosion) - * DAMAGE_NO_ARMOR armor does not protect from this damage - * DAMAGE_NO_KNOCKBACK do not affect velocity, just view angles - * DAMAGE_NO_PROTECTION kills godmode, armor, everything - */ -void G_Damage (gentity_t* targ, /*@null@*/ gentity_t* inflictor, /*@null@*/ gentity_t* attacker, /*@null@*/ vec3_t dir, /*@null@*/ vec3_t point, int damage, int dflags, int mod); - -/** - * Damage all entities around an origin in a specified radius. - * - * \return Hit a client? - * \param origin Origin. - * \param attacker Attacker. - * \param damage Amount much damage. - * \param radius Radius. - * \param ignore Entity to ignore. - * \param dflags Damage flags. - * \param mod Means of death. - * \todo Replace ignore entity by list of entites. - */ -qboolean G_RadiusDamage (vec3_t origin, gentity_t* attacker, float damage, float radius, gentity_t* ignore, int dflags, int mod); - -/** - * Let a body die. - * - * \param self Self. - * \param inflictor entity that is causing the damage - * \param attacker entity that caused the inflictor to damage targ - * \param damage Amount of damage. - * \param meansOfDeath Means of death. - */ -void body_die( gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int damage, int meansOfDeath ); - -/** - * Toss the weapon and powerups for the killed player. - * - * \param self the client. - * \param Caused by disconnect? - */ -void TossClientItems( gentity_t* self, qboolean dis_con ); - -/** - * Repairs repairable entities. - * - * \param ent The player. - * \param tr_ent Entity to repair. - * \param rate Rate to repair with. - * \author Ubergames - GSIO01 - * \date 09/05/2009 - */ -void G_Repair(gentity_t* ent, gentity_t* tr_ent, float rate); - -// damage flags -#define DAMAGE_RADIUS 0x00000001 // damage was indirect -#define DAMAGE_NO_ARMOR 0x00000002 // armor (shields) do not protect from this damage -#define DAMAGE_NO_KNOCKBACK 0x00000008 // do not affect velocity, just view angles -#define DAMAGE_NO_PROTECTION 0x00000020 // armor, shields, invulnerability, and godmode have no effect -#define DAMAGE_NOT_ARMOR_PIERCING 0x00000000 // trek: shields fully protect from this damage (for clarity) -#define DAMAGE_ARMOR_PIERCING 0x00000040 // trek: shields don't fully protect from this damage -#define DAMAGE_NO_INVULNERABILITY 0x00000080 // trek: invulnerability doesn't event protect from this damage -#define DAMAGE_HALF_NOTLOS 0x00000100 // trek: radius damage still does 1/2 damage to ents that do not have LOS to explosion org but are in radius -#define DAMAGE_ALL_TEAMS 0x00000200 // trek: damage ignores teamdamage settings - // // g_missile.c // diff --git a/code/game/g_missile.c b/code/game/g_missile.c index e99bca2..ffb163c 100644 --- a/code/game/g_missile.c +++ b/code/game/g_missile.c @@ -5,6 +5,7 @@ #include "g_spawn.h" #include "g_missile.h" #include "g_logger.h" +#include "g_combat.h" #define MISSILE_PRESTEP_TIME 50 @@ -65,7 +66,7 @@ static void TouchStickyGrenade(gentity_t* ent, gentity_t* other, trace_t* trace) G_Assert(ent, (void)0); G_Assert(other, (void)0); - if (IsAdmin( other ) == qfalse) { + if (G_Client_IsAdmin( other ) == qfalse) { if (other->takedamage) { if (ent->parent != other) { ent->touch = 0; @@ -118,7 +119,7 @@ void tripwireThink ( gentity_t* ent ) { //RPG-X: RedTechie - Admin Class go threw //RPG-X: J2J - Mistake made here, was checking if the _owner_ was in admin at the time, not the player tripping the mine, FIXED. - if (IsAdmin( traceEnt ) == qfalse) { + if (G_Client_IsAdmin( traceEnt ) == qfalse) { grenadeSpewShrapnel( ent ); } } @@ -271,7 +272,7 @@ void G_Missile_Impact( gentity_t* ent, trace_t* trace ) { { //RPG-X: - Our forcefield killer :D if(((other->classname != NULL && !Q_stricmp(other->classname, "holdable_shield")))){ - if(IsAdmin(ent->parent)){ + if(G_Client_IsAdmin(ent->parent)){ G_FreeEntity(ent); G_Active_ShieldRemove(other); @@ -321,7 +322,7 @@ void G_Missile_Impact( gentity_t* ent, trace_t* trace ) { { flags |= DAMAGE_ARMOR_PIERCING; } - G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity, + G_Combat_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity, ent->s.origin, ent->damage, flags, ent->methodOfDeath); } @@ -351,7 +352,7 @@ void G_Missile_Impact( gentity_t* ent, trace_t* trace ) { // splash damage (doesn't apply to person directly hit) if ( ent->splashDamage > 0 ) { - G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius, other, 0, ent->splashMethodOfDeath ); + G_Combat_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius, other, 0, ent->splashMethodOfDeath ); } trap_LinkEntity( ent ); @@ -389,7 +390,7 @@ void G_ExplodeMissile( gentity_t* ent ) { // splash damage if ( ent->splashDamage > 0 ) { - G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, NULL, 0, ent->splashMethodOfDeath ); + G_Combat_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, NULL, 0, ent->splashMethodOfDeath ); } trap_LinkEntity( ent ); @@ -414,7 +415,7 @@ static void G_RunStuckMissile( gentity_t* ent ) if ( (VectorCompare( vec3_origin, other->s.pos.trDelta ) == 0 && other->s.pos.trType != TR_STATIONARY) || (VectorCompare( vec3_origin, other->s.apos.trDelta ) == 0 && other->s.apos.trType != TR_STATIONARY) ) {//thing I stuck to is moving or rotating now, kill me - G_Damage( ent, other, other, NULL, NULL, 99999, 0, MOD_CRUSH ); + G_Combat_Damage( ent, other, other, NULL, NULL, 99999, 0, MOD_CRUSH ); G_LogFuncEnd(); return; diff --git a/code/game/g_missile.h b/code/game/g_missile.h index bc22358..ac4d1ee 100644 --- a/code/game/g_missile.h +++ b/code/game/g_missile.h @@ -4,5 +4,6 @@ #include "g_local.h" void G_Missile_Impact( gentity_t *ent, trace_t *trace); +void tripwireThink(gentity_t* ent); #endif /* G_MISSILE_H_ */ \ No newline at end of file diff --git a/code/game/g_mover.c b/code/game/g_mover.c index 26a91c3..393c120 100644 --- a/code/game/g_mover.c +++ b/code/game/g_mover.c @@ -227,7 +227,7 @@ static qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, genti if ( notMoving && check->s.eFlags&EF_MISSILE_STICK ) {//special case hack for sticky things //destroy it - G_Damage( check, pusher, pusher, NULL, NULL, 99999, 0, MOD_CRUSH ); + G_Combat_Damage( check, pusher, pusher, NULL, NULL, 99999, 0, MOD_CRUSH ); continue; } @@ -263,7 +263,7 @@ static qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, genti // bobbing entities are instant-kill and never get blocked if ( pusher->s.pos.trType == TR_SINE || pusher->s.apos.trType == TR_SINE ) { - G_Damage( check, pusher, pusher, NULL, NULL, 99999, 0, MOD_CRUSH ); + G_Combat_Damage( check, pusher, pusher, NULL, NULL, 99999, 0, MOD_CRUSH ); continue; } @@ -812,7 +812,7 @@ void G_Mover_UseBinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activa //GSIO01 | 09/05/2009: do engage if door is admin only and player isn admin if(((ent->type == ENT_FUNC_DOOR) && ((ent->spawnflags & 128) != 0)) || ((ent->type == ENT_FUNC_DOOR_ROTATING) && ((ent->spawnflags & 64) != 0))) { - if((activator != NULL) && !IsAdmin(activator)) { + if((activator != NULL) && !G_Client_IsAdmin(activator)) { return; } } @@ -1172,7 +1172,7 @@ void Blocked_Door( gentity_t *ent, gentity_t *other ) { } if ( ent->damage ) { - G_Damage( other, ent, ent, NULL, NULL, ent->damage, 0, MOD_CRUSH ); + G_Combat_Damage( other, ent, ent, NULL, NULL, ent->damage, 0, MOD_CRUSH ); } if ( ((ent->spawnflags & 4) != 0) || ((ent->type == ENT_FUNC_DOOR_ROTATING) && ((ent->spawnflags & 2) != 0)) ) { // GSIO01: added support for fucn_door_roating return; // crushers don't reverse @@ -2328,8 +2328,8 @@ static void forcefield_touch( gentity_t *ent, gentity_t *other, trace_t *trace ) ent->r.svFlags &= ~SVF_NOCLIENT; ent->s.eFlags &= ~EF_NODRAW; - if ( ((ent->spawnflags & 4) && IsAdmin(other)) || - ((rpg_borgAdapt.integer && rpg_borgMoveThroughFields.integer && IsBorg(other) && !(ent->spawnflags & 256))) ) + if ( ((ent->spawnflags & 4) && G_Client_IsAdmin(other)) || + ((rpg_borgAdapt.integer && rpg_borgMoveThroughFields.integer && G_Client_IsBorg(other) && !(ent->spawnflags & 256))) ) { FieldGoNotSolid( ent ); } @@ -2356,7 +2356,7 @@ static void forcefield_touch( gentity_t *ent, gentity_t *other, trace_t *trace ) if ( ent->damage ) { - G_Damage (other, ent, ent, NULL, NULL, ent->damage, 0, MOD_FORCEFIELD); + G_Combat_Damage (other, ent, ent, NULL, NULL, ent->damage, 0, MOD_FORCEFIELD); } ent->nextthink = level.time+ent->soundPos2; diff --git a/code/game/g_target.c b/code/game/g_target.c index b1e947b..30baa21 100644 --- a/code/game/g_target.c +++ b/code/game/g_target.c @@ -375,7 +375,7 @@ static void target_laser_think (/*@shared@*/ gentity_t *self) { if ( tr.entityNum != 0 ) { // hurt it if we can - G_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir, + G_Combat_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir, tr.endpos, self->damage, DAMAGE_NO_KNOCKBACK, MOD_TARGET_LASER); } @@ -640,7 +640,7 @@ none */ static void target_kill_use( /*@shared@*/ /*@unused@*/ gentity_t *self, /*@shared@*/ /*@unused@*/ gentity_t *other, /*@shared@*/ gentity_t *activator ) { if(activator != NULL) { - G_Damage ( activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG); + G_Combat_Damage ( activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG); } } @@ -3039,7 +3039,7 @@ void target_selfdestruct_think(gentity_t *ent) { //Loop trough all clients on the server. while((client = G_Find( client, FOFS( classname ), "player" ))!= NULL){ if (client->client->nokilli != 1) - G_Damage (client, ent, ent, 0, 0, 999999, 0, MOD_TRIGGER_HURT); //maybe a new message ala "[Charname] did not abandon ship." + G_Combat_Damage (client, ent, ent, 0, 0, 999999, 0, MOD_TRIGGER_HURT); //maybe a new message ala "[Charname] did not abandon ship." } //we may go this way once more so clear clients back. client = NULL; @@ -3368,7 +3368,7 @@ void target_shiphealth_die(/*@shared@*/ gentity_t *ent){ //Loop trough all clients on the server. while((client = G_Find( client, FOFS( classname ), "player" )) != NULL){ if (client->client && client->client->nokilli != 1) { - G_Damage (client, ent, ent, 0, 0, 999999, 0, MOD_TRIGGER_HURT); //maybe a new message ala "[Charname] did not abandon ship." + G_Combat_Damage (client, ent, ent, 0, 0, 999999, 0, MOD_TRIGGER_HURT); //maybe a new message ala "[Charname] did not abandon ship." } } //we may go this way once more so clear clients back. diff --git a/code/game/g_trigger.c b/code/game/g_trigger.c index b86a074..b5c9650 100644 --- a/code/game/g_trigger.c +++ b/code/game/g_trigger.c @@ -812,7 +812,7 @@ static void hurt_touch( gentity_t* self, gentity_t* other, trace_t* trace ) { } if((self->spawnflags & 64) != 0) { - if(IsAdmin(other)) { + if(G_Client_IsAdmin(other)) { G_LocLogger(LL_DEBUG, "admins are protected\n"); G_LogFuncEnd(); return; @@ -855,7 +855,7 @@ static void hurt_touch( gentity_t* self, gentity_t* other, trace_t* trace ) { dflags = 0; } - G_Damage (other, self, self, NULL, NULL, self->damage, dflags, MOD_TRIGGER_HURT); + G_Combat_Damage (other, self, self, NULL, NULL, self->damage, dflags, MOD_TRIGGER_HURT); G_LogFuncEnd(); } diff --git a/code/game/g_turrets.c b/code/game/g_turrets.c index 9a0478c..5a082c5 100644 --- a/code/game/g_turrets.c +++ b/code/game/g_turrets.c @@ -2,6 +2,7 @@ #include "g_spawn.h" #include "g_items.h" #include "g_logger.h" +#include "g_combat.h" #define ARM_ANGLE_RANGE 60 #define HEAD_ANGLE_RANGE 90 @@ -72,7 +73,7 @@ static void turret_die ( gentity_t* self, gentity_t* inflictor, gentity_t* attac if ( (self->splashDamage > 0) && (self->splashRadius > 0) ) { /* FIXME: specify type of explosion? (barrel, electrical, etc.) */ - G_RadiusDamage( self->r.currentOrigin, attacker, self->splashDamage, self->splashRadius, activator, DAMAGE_RADIUS, MOD_EXPLOSION ); + G_Combat_RadiusDamage( self->r.currentOrigin, attacker, self->splashDamage, self->splashRadius, activator, DAMAGE_RADIUS, MOD_EXPLOSION ); te = G_TempEntity( self->r.currentOrigin, EV_MISSILE_MISS ); VectorSet( dir, 0, 0, 1 ); @@ -1062,7 +1063,7 @@ static void laser_arm_fire (gentity_t* ent) gentity_t *hapless_victim = &g_entities[trace.entityNum]; if ( hapless_victim && hapless_victim->takedamage && ent->damage ) { - G_Damage( hapless_victim, ent, ent->nextTrain->activator, fwd, trace.endpos, ent->damage, DAMAGE_ALL_TEAMS, 1 ); + G_Combat_Damage( hapless_victim, ent, ent->nextTrain->activator, fwd, trace.endpos, ent->damage, DAMAGE_ALL_TEAMS, 1 ); } } } diff --git a/code/game/g_usable.c b/code/game/g_usable.c index 656d51c..2bc9d5d 100644 --- a/code/game/g_usable.c +++ b/code/game/g_usable.c @@ -124,7 +124,7 @@ void func_usable_use (gentity_t* self, gentity_t* other, gentity_t* activator) /* RPG-X | GSIO01 | 09/05/2009: */ if ((self->spawnflags & USABLE_ADMIN_ONLY) != 0) { /* ADMINS_ONLY */ - if (!IsAdmin(activator)) { + if (!G_Client_IsAdmin(activator)) { G_Logger(LL_DEBUG, "activator not a player or not admin\n"); G_LogFuncEnd(); return; diff --git a/code/game/g_utils.c b/code/game/g_utils.c index 5634574..830855c 100644 --- a/code/game/g_utils.c +++ b/code/game/g_utils.c @@ -9,6 +9,7 @@ #include "g_local.h" #include "g_lua.h" #include "g_logger.h" +#include "g_combat.h" /** * \brief Data structure for a singele shader remap. @@ -827,7 +828,7 @@ void G_KillBox (gentity_t* ent) { } /* nail it */ - G_Damage ( hit, ent, ent, NULL, NULL, + G_Combat_Damage ( hit, ent, ent, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG); } diff --git a/code/game/g_weapon.c b/code/game/g_weapon.c index 1a20d3b..9d8a8eb 100644 --- a/code/game/g_weapon.c +++ b/code/game/g_weapon.c @@ -10,6 +10,7 @@ #include "g_missile.h" #include "g_logger.h" #include "g_lua.h" +#include "g_combat.h" #define MAX_BEAM_HITS 4 @@ -176,9 +177,9 @@ static void WP_FireHyperspanner(gentity_t* ent, qboolean alt_fire) { /* call G_Repair */ if(alt_fire) { - G_Repair(ent, nearest, HYPERSPANNER_ALT_RATE * modifier); + G_Combat_Repair(ent, nearest, HYPERSPANNER_ALT_RATE * modifier); } else { - G_Repair(ent, nearest, HYPERSPANNER_RATE * modifier); + G_Combat_Repair(ent, nearest, HYPERSPANNER_RATE * modifier); } validEnts.clear(&validEnts); @@ -289,10 +290,10 @@ static void WP_FirePhaser( gentity_t* ent, qboolean alt_fire ) if (damage > 0) { if ( alt_fire ) { - G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, + G_Combat_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, DAMAGE_NO_KNOCKBACK | DAMAGE_NOT_ARMOR_PIERCING, MOD_PHASER_ALT ); } else { - G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, + G_Combat_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, DAMAGE_NO_KNOCKBACK | DAMAGE_ARMOR_PIERCING, MOD_PHASER ); } } @@ -432,7 +433,7 @@ static void WP_FireCompressionRifle ( gentity_t* ent, qboolean alt_fire ) } if (damage > 0) { - G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, + G_Combat_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, DAMAGE_NO_KNOCKBACK | DAMAGE_ARMOR_PIERCING, MOD_CRIFLE_ALT ); /* GSIO01: was MOD_PHASER */ } } @@ -582,7 +583,7 @@ static void WP_FireDisruptor( gentity_t* ent, qboolean alt_fire ) } if (damage > 0) { - G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, + G_Combat_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, DAMAGE_NO_KNOCKBACK | DAMAGE_ARMOR_PIERCING, MOD_STASIS ); /* GSIO01: was MOD_TETRION_ALT */ } } @@ -634,7 +635,7 @@ static void grenadeExplode( gentity_t* ent ) /* splash damage (doesn't apply to person directly hit) */ if ( ent->splashDamage > 0 ) { - G_RadiusDamage( pos, ent->parent, ent->splashDamage, ent->splashRadius, NULL, 0, ent->splashMethodOfDeath ); + G_Combat_RadiusDamage( pos, ent->parent, ent->splashDamage, ent->splashRadius, NULL, 0, ent->splashMethodOfDeath ); } G_FreeEntity( ent ); @@ -659,7 +660,7 @@ void grenadeSpewShrapnel( gentity_t* ent ) tent->s.eventParm = DirToByte(ent->pos1); // just do radius dmg for altfire - G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, + G_Combat_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent, 0, ent->splashMethodOfDeath ); G_FreeEntity(ent); @@ -819,7 +820,7 @@ static void WP_FireGrenade( gentity_t* ent, qboolean alt_fire ) VectorCopy( start, grenade->pos2 ); } else { /* RPG-X: RedTechie - Check to see if there admin if so grant them effects gun */ - if( IsAdmin(ent) && (rpg_effectsgun.integer == 1)) { + if( G_Client_IsAdmin(ent) && (rpg_effectsgun.integer == 1)) { VectorMA (muzzle, MAXRANGE_CRIFLE, forward, end); trap_Trace (&tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT ); @@ -1039,7 +1040,7 @@ static void WP_FireTR116Bullet( gentity_t* ent, vec3_t start, vec3_t dir ) { G_Assert(traceEnt, (void)0); if ( traceEnt->takedamage && (rpg_dmgFlags.integer & 4) != 0) { - G_Damage( traceEnt, ent, ent, dir, tr.endpos, TETRION_DAMAGE, 0, MOD_TETRION_ALT ); + G_Combat_Damage( traceEnt, ent, ent, dir, tr.endpos, TETRION_DAMAGE, 0, MOD_TETRION_ALT ); } } @@ -1646,7 +1647,7 @@ static void WP_TricorderScan (gentity_t* ent, qboolean alt_fire) } /* Fix - Changed || to && in the below if statement! */ - if ( IsAdmin( ent ) == qfalse ) { + if ( G_Client_IsAdmin( ent ) == qfalse ) { G_Logger(LL_DEBUG, "player not an admin\n"); G_LogFuncEnd(); return; @@ -1756,7 +1757,7 @@ static void WP_SprayVoyagerHypo( gentity_t* ent, qboolean alt_fire ) memset(&tr, 0, sizeof(trace_t)); trap_Trace ( &tr, muzzle, mins, maxs, end, ent->s.number, MASK_OPAQUE|CONTENTS_BODY|CONTENTS_ITEM|CONTENTS_CORPSE ); /*MASK_SHOT*/ - if(rpg_effectsgun.integer == 1 && IsAdmin(ent) && alt_fire == qtrue && ent->s.weapon == WP_12) { + if(rpg_effectsgun.integer == 1 && G_Client_IsAdmin(ent) && alt_fire == qtrue && ent->s.weapon == WP_12) { if(RPGEntityCount != ENTITYNUM_MAX_NORMAL-20){ t_ent = G_TempEntity( muzzle, EV_HYPO_PUFF ); t_ent->s.eventParm = qfalse; /* TiM: Event parm is holding a qboolean value for color of spray */ @@ -1871,7 +1872,7 @@ void FireWeapon( gentity_t* ent, qboolean alt_fire ) WP_FireCompressionRifle( ent, alt_fire ); break; case WP_1: - if ( IsAdmin( ent ) && alt_fire ) + if ( G_Client_IsAdmin( ent ) && alt_fire ) WP_FireGrenade( ent, qfalse ); break; case WP_4: diff --git a/code/game/lua_game.c b/code/game/lua_game.c index 1dc4796..70f5f02 100644 --- a/code/game/lua_game.c +++ b/code/game/lua_game.c @@ -1,483 +1,484 @@ -// game lib for lua - -#include "g_lua.h" - -#ifdef G_LUA - -/*** -This module provides access to some of the servers functionality. -@module game -*/ - -/*** -Prints text to the servers console. -@function Print -@param test Text to print. -*/ -static int Game_Print(lua_State *L) { - int i; - char buf[MAX_STRING_CHARS]; - int n = lua_gettop(L); - - memset(buf, 0, sizeof(buf)); - - lua_getglobal(L, "tostring"); - - LUA_DEBUG("BEGIN - game.Print"); - - for(i = 1; i <= n; i++) - { - const char *s; - - lua_pushvalue(L, -1); - lua_pushvalue(L, i); - lua_call(L, 1, 1); - s = lua_tostring(L, -1); - - if(s == NULL) - { - LUA_DEBUG("ERROR - game.Print - no string"); - return 1; - } - - Q_strcat(buf, sizeof(buf), s); - - lua_pop(L, 1); - } - - G_Printf("%s\n", buf); - - LUA_DEBUG("END - game.Print"); - return 0; -} - -/*** -Prints text to the center of the screen of the client with client number clientNum. If clientNum is -1 the text gets printed for all clients. -@function CenterPrint -@param clientNum Client number. -@param text Text to print. -*/ -static int Game_CenterPrint(lua_State *L) { - int i; - char buf[MAX_STRING_CHARS]; - int n = lua_gettop(L); - int clNum = luaL_checknumber(L, 1); - - memset(buf, 0, sizeof(buf)); - - lua_getglobal(L, "tostring"); - - LUA_DEBUG("BEGIN - game.CenterPrint"); - - for(i = 1; i < n; i++) - { - const char *s; - - lua_pushvalue(L, -1); - lua_pushvalue(L, i); - lua_call(L, 1, 1); - s = lua_tostring(L, 2); - - if(s == NULL) - { - LUA_DEBUG("ERROR - game.CenterPrint - no string"); - lua_pushboolean(L, qfalse); - return 1; - } - - Q_strcat(buf, sizeof(buf), s); - - lua_pop(L, 1); - } - - - trap_SendServerCommand(clNum, va("servercprint \"" S_COLOR_WHITE "%s\n\"", buf)); - - LUA_DEBUG("END - game.CenterPrint"); - lua_pushboolean(L, qtrue); - return 1; -} - -/*** -Prints text to the clients console that has the client number clientNum. If clientNum is -1 the text gets printed to all clients consoles. -@function ClientPrint -@param clientNum Client number. -@param text Text to print. -*/ -static int Game_ClientPrint(lua_State *L) { - int i; - char buf[MAX_STRING_CHARS]; - int n = lua_gettop(L); - int clNum = luaL_checknumber(L, 1); - gentity_t *player; - - memset(buf, 0, sizeof(buf)); - - lua_getglobal(L, "tostring"); - - LUA_DEBUG("BEGIN - game.ClientPrint"); - - for(i = 1; i < n; i++) { - const char *s; - - lua_pushvalue(L, -1); - lua_pushvalue(L, i); - lua_call(L, 1, 1); - s = lua_tostring(L, 2); - - if(s == NULL) - { - LUA_DEBUG("BEGIN - game.ClientPrint - no string"); - lua_pushboolean(L, qfalse); - return 1; - } - - Q_strcat(buf, sizeof(buf), s); - - lua_pop(L, 1); - } - - if(clNum != -1) { - player = &g_entities[clNum]; - if(player && player->client) { - G_PrintfClient(player, "%s", buf); - } - } else { - G_PrintfClientAll("%s", buf); - } - - LUA_DEBUG("END - game.ClientPrint"); - lua_pushboolean(L, qtrue); - return 1; -} - -/*** -Prints text to the lower right corner of the screen of the client with client number clientNum. If clientNum is -1 the text gets printed for all clients. -@functiton MessagePrint -@param clientNum Client number. -@param text Text tp print. -*/ -static int Game_MessagePrint(lua_State *L) { - int i; - char buf[MAX_STRING_CHARS]; - int n = lua_gettop(L); - int clNum = luaL_checknumber(L, 1); - - memset(buf, 0, sizeof(buf)); - - lua_getglobal(L, "tostring"); - - LUA_DEBUG("BEGIN - game.MessagePrint"); - - for(i = 1; i < n; i++) - { - const char *s; - - lua_pushvalue(L, -1); - lua_pushvalue(L, i); - lua_call(L, 1, 1); - s = lua_tostring(L, 2); - - if(s == NULL) - { - LUA_DEBUG("ERROR - game.MessagePrint - no string"); - lua_pushboolean(L, qfalse); - return 1; - } - - Q_strcat(buf, sizeof(buf), s); - - lua_pop(L, 1); - } - - trap_SendServerCommand(clNum, va("servermsg \"" S_COLOR_WHITE "%s\n\"", buf)); - - LUA_DEBUG("END - game.MessagePrint"); - lua_pushboolean(L, qfalse); - return 1; -} - -/*** -Sets a global Lua variable which is called name to value. Creates a new global variable if a variable of name does not exist. Value can be of any type. -@function SetGlobal -@param name Name of global variable. -@param value New value for global variable. -*/ -static int Game_SetGlobal(lua_State *L) { - char *name; - - LUA_DEBUG("BEGIN - game.SetGlobal"); - - name = (char *)luaL_checkstring(L, 1); - - if(name == NULL) { - LUA_DEBUG("ERROR - game.SetGlobal - name NULL"); - lua_pushboolean(L, qfalse); - return 0; - } - - lua_pushvalue(L, 2); - lua_setglobal(L, name); - - LUA_DEBUG("END - game.SetGlobal"); - lua_pushboolean(L, qtrue); - return 0; -} - -/*** -Returns the value of the global variable name. Returns nil if the variable does not exist. -@function GetGlobal -@param name Name of Global variable. -@return value of Global variable. -*/ -static int Game_GetGlobal(lua_State *L) { - char *name; - - LUA_DEBUG("BEGIN - game.SetGlobal"); - - name = (char *)luaL_checkstring(L, 1); - - if(name == NULL) { - LUA_DEBUG("ERROR - game.SetGlobal - name NULL"); - lua_pushnil(L); - return 0; - } - - lua_getglobal(L, name); - LUA_DEBUG("END - game.SetGlobal"); - return 1; -} - -// Alert-Stuff... I don't know. I feel like removing this and stick to the entity spawning and setup. -// game.AlertSetup(entity ent, string greentarget, string yellowtarget, string redtarget, string bluetarget, -// string greensound, string yellowsound, string redsound, string bluesound, integer mode) -static int Game_AlertSetup(lua_State *L) { - - LUA_DEBUG("BEGIN - game.AlertSetup"); - - if(luaAlertState != NULL) { - LUA_DEBUG("ERROR - game.AlertSetup - luaArlterState != NULL"); - lua_pushboolean(L, 0); - return 1; - } - - luaAlertState = (luaAlertState_t *)malloc(sizeof(luaAlertState_t)); - if(luaAlertState == NULL) { - LUA_DEBUG("ERROR - game.AlertSetup - luaAlertState NULL"); - lua_pushboolean(L, 0); - return 1; - } - - luaAlertState->targets[0] = (char *)luaL_checkstring(L, 1); - luaAlertState->targets[1] = (char *)luaL_checkstring(L, 2); - luaAlertState->targets[2] = (char *)luaL_checkstring(L, 3); - luaAlertState->targets[3] = (char *)luaL_checkstring(L, 4); - - luaAlertState->sounds[0] = (char *)luaL_checkstring(L, 5); - luaAlertState->sounds[1] = (char *)luaL_checkstring(L, 6); - luaAlertState->sounds[2] = (char *)luaL_checkstring(L, 7); - luaAlertState->sounds[3] = (char *)luaL_checkstring(L, 8); - - luaAlertState->mode = luaL_checkint(L, 9); - - luaAlertState->cond = 0; - - LUA_DEBUG("END - game.AlertSetup"); - lua_pushboolean(L, 1); - return 1; -} - -static int Game_AlertAddShader(lua_State *L) { - int cond; - char *shader; - - LUA_DEBUG("BEGIN - game.AlertAddShader"); - - if(luaAlertState == NULL) { - LUA_DEBUG("ERROR - game.AlertAddShader - luaAlertShader NULL"); - lua_pushboolean(L, 0); - return 1; - } - - cond = luaL_checkint(L, 1); - if(cond < 0 || cond > 3) { - LUA_DEBUG("ERROR - game.AlertAddShader - cond out of range"); - lua_pushboolean(L, 0); - return 1; - } - - shader = (char *)luaL_checkstring(L, 2); - if(shader == NULL) { - LUA_DEBUG("ERROR - game.AlertAddShader - shader NULL"); - lua_pushboolean(L, 0); - return 1; - } - - if((strlen(shader) + 1) > MAX_QPATH) { - LUA_DEBUG("ERROR - game.AlertAddShader - strlen(shader)+1 > MAX_QPATH"); - lua_pushboolean(L, 0); - return 1; - } - - if(luaAlertState->shaders[cond] == NULL) { - luaAlertState->shaders[cond] = (char *)malloc(sizeof(char) * (strlen(shader) + 1)); - if(luaAlertState->shaders[cond] == NULL) { - LUA_DEBUG("ERROR - game.AlertAddShader - alloc failed"); - lua_pushboolean(L, 0); - return 1; - } - strncpy(luaAlertState->shaders[cond], shader, sizeof(luaAlertState->shaders[cond])); - } else { - void *tmp = realloc(luaAlertState->shaders[cond], sizeof(char) * (strlen(luaAlertState->shaders[cond]) + - strlen(shader) + 1)); - if(tmp == NULL){ - LUA_DEBUG("ERROR - game.AlertAddShader - realloc failed"); - lua_pushboolean(L, 0); - return 1; - } - luaAlertState->shaders[cond] = tmp; - Com_sprintf(luaAlertState->shaders[cond], sizeof(luaAlertState->shaders[cond]), "%s\n%s", luaAlertState->shaders[cond], shader); - } - - lua_pushboolean(L, 1); - LUA_DEBUG("END - game.AlertAddShader"); - return 1; -} - -// game.Alert(entity ent, integer target, boolean silent) -static int Game_Alert(lua_State *L) { - /*lent_t *lent; - int current, target; - qboolean silent;*/ - - return 0; -} - -/*** -Get the current level time in milliseconds. Level time is the time since level start. -@function LevelTime -@return Level time in milliseconds. -*/ -static int Game_Leveltime(lua_State * L) -{ - LUA_DEBUG("BEGIN - game.Leveltime"); - - lua_pushinteger(L, level.time); - - LUA_DEBUG("INFO - game.Leveltime - start/return: leveltime=%d", level.time); - LUA_DEBUG("BEGIN - game.Leveltime"); - return 1; -} - -/*** -Damage and player or entity. -@function Damage -@param target Target entity. -@param inflictor Inflicting entity. Can be nil. -@param attacker Attacking entity. Can be nil. -@param direction Direction of knockback. Can be nil. -@param point Point where the damage is inflicted. Can be nil. -@param damage Ammount of damage. -@param dflags Damage flags. -@param mod Means of death. -@return Success or fail. -*/ -static int Game_Damage(lua_State *L) { - lent_t *lent; - gentity_t *targ = NULL, *inflictor = NULL, *attacker = NULL; - vec_t *dir = NULL, *point = NULL; - int damage = 0, dflags = 0, mod = 0; - - LUA_DEBUG("BEGIN - game.Damage"); - - lent = Lua_GetEntity(L, 1); - if(lent == NULL || lent->e == NULL) { - LUA_DEBUG("ERROR - game.Damage - entity NULL"); - lua_pushboolean(L, qfalse); - return 1; - } - targ = lent->e; - if(!lua_isnil(L, 2)) { - lent = Lua_GetEntity(L, 2); - if(lent && lent->e) { - inflictor = lent->e; - } - } - if(!lua_isnil(L, 3)) { - lent = Lua_GetEntity(L, 3); - if(lent && lent->e) { - attacker = lent->e; - } - } - if(!lua_isnil(L, 4)) { - dir = Lua_GetVector(L, 4); - } - if(!lua_isnil(L, 5)) { - point = Lua_GetVector(L, 5); - } - damage = (int)luaL_checknumber(L, 6); - dflags = (int)luaL_checknumber(L, 7); - mod = (int)luaL_checknumber(L, 8); - - G_Damage(targ, inflictor, attacker, dir, point, damage, dflags, mod); - - lua_pushboolean(L, qtrue); - LUA_DEBUG("END - game.Damage"); - return 1; -} - -/*** -Repair an entity. -@function Repair -@param target Target entity. -@param rate Repair rate. -@return Success or fail. -*/ -static int Game_Repair(lua_State *L) { - lent_t *lent; - float rate; - - LUA_DEBUG("BEGIN - game.Repair"); - - lent = Lua_GetEntity(L, 1); - if(lent == NULL || lent->e == NULL) { - LUA_DEBUG("ERROR - game.Repair - entity NULL"); - lua_pushboolean(L, qfalse); - return 1; - } - - rate = (float)luaL_checknumber(L, 2); - - G_Repair(lent->e, NULL, rate); // FIXME ... trance ent? - - LUA_DEBUG("END - game.Repair"); - lua_pushboolean(L, qtrue); - return 1; -} - -static const luaL_Reg lib_game[] = { - { "Damage", Game_Damage }, - { "Repair", Game_Repair }, - { "Print", Game_Print }, - { "MessagePrint", Game_MessagePrint }, - { "CenterPrint", Game_CenterPrint }, - { "ClientPrint", Game_ClientPrint }, - { "GetTime", Game_Leveltime }, - - { "AlertSetup", Game_AlertSetup }, - { "AlertAddShader", Game_AlertAddShader }, - { "Alert", Game_Alert }, - - { "SetGlobal", Game_SetGlobal }, - { "GetGlobal", Game_GetGlobal }, - { NULL, NULL } -}; - -int Luaopen_Game(lua_State *L) { - luaL_register(L, "game", lib_game); - lua_pushliteral(L, "_GAMEVERSION"); - lua_pushliteral(L, GAMEVERSION); - - return 1; -} -#endif +// game lib for lua + +#include "g_lua.h" +#include "g_combat.h" + +#ifdef G_LUA + +/*** +This module provides access to some of the servers functionality. +@module game +*/ + +/*** +Prints text to the servers console. +@function Print +@param test Text to print. +*/ +static int Game_Print(lua_State *L) { + int i; + char buf[MAX_STRING_CHARS]; + int n = lua_gettop(L); + + memset(buf, 0, sizeof(buf)); + + lua_getglobal(L, "tostring"); + + LUA_DEBUG("BEGIN - game.Print"); + + for(i = 1; i <= n; i++) + { + const char *s; + + lua_pushvalue(L, -1); + lua_pushvalue(L, i); + lua_call(L, 1, 1); + s = lua_tostring(L, -1); + + if(s == NULL) + { + LUA_DEBUG("ERROR - game.Print - no string"); + return 1; + } + + Q_strcat(buf, sizeof(buf), s); + + lua_pop(L, 1); + } + + G_Printf("%s\n", buf); + + LUA_DEBUG("END - game.Print"); + return 0; +} + +/*** +Prints text to the center of the screen of the client with client number clientNum. If clientNum is -1 the text gets printed for all clients. +@function CenterPrint +@param clientNum Client number. +@param text Text to print. +*/ +static int Game_CenterPrint(lua_State *L) { + int i; + char buf[MAX_STRING_CHARS]; + int n = lua_gettop(L); + int clNum = luaL_checknumber(L, 1); + + memset(buf, 0, sizeof(buf)); + + lua_getglobal(L, "tostring"); + + LUA_DEBUG("BEGIN - game.CenterPrint"); + + for(i = 1; i < n; i++) + { + const char *s; + + lua_pushvalue(L, -1); + lua_pushvalue(L, i); + lua_call(L, 1, 1); + s = lua_tostring(L, 2); + + if(s == NULL) + { + LUA_DEBUG("ERROR - game.CenterPrint - no string"); + lua_pushboolean(L, qfalse); + return 1; + } + + Q_strcat(buf, sizeof(buf), s); + + lua_pop(L, 1); + } + + + trap_SendServerCommand(clNum, va("servercprint \"" S_COLOR_WHITE "%s\n\"", buf)); + + LUA_DEBUG("END - game.CenterPrint"); + lua_pushboolean(L, qtrue); + return 1; +} + +/*** +Prints text to the clients console that has the client number clientNum. If clientNum is -1 the text gets printed to all clients consoles. +@function ClientPrint +@param clientNum Client number. +@param text Text to print. +*/ +static int Game_ClientPrint(lua_State *L) { + int i; + char buf[MAX_STRING_CHARS]; + int n = lua_gettop(L); + int clNum = luaL_checknumber(L, 1); + gentity_t *player; + + memset(buf, 0, sizeof(buf)); + + lua_getglobal(L, "tostring"); + + LUA_DEBUG("BEGIN - game.ClientPrint"); + + for(i = 1; i < n; i++) { + const char *s; + + lua_pushvalue(L, -1); + lua_pushvalue(L, i); + lua_call(L, 1, 1); + s = lua_tostring(L, 2); + + if(s == NULL) + { + LUA_DEBUG("BEGIN - game.ClientPrint - no string"); + lua_pushboolean(L, qfalse); + return 1; + } + + Q_strcat(buf, sizeof(buf), s); + + lua_pop(L, 1); + } + + if(clNum != -1) { + player = &g_entities[clNum]; + if(player && player->client) { + G_PrintfClient(player, "%s", buf); + } + } else { + G_PrintfClientAll("%s", buf); + } + + LUA_DEBUG("END - game.ClientPrint"); + lua_pushboolean(L, qtrue); + return 1; +} + +/*** +Prints text to the lower right corner of the screen of the client with client number clientNum. If clientNum is -1 the text gets printed for all clients. +@functiton MessagePrint +@param clientNum Client number. +@param text Text tp print. +*/ +static int Game_MessagePrint(lua_State *L) { + int i; + char buf[MAX_STRING_CHARS]; + int n = lua_gettop(L); + int clNum = luaL_checknumber(L, 1); + + memset(buf, 0, sizeof(buf)); + + lua_getglobal(L, "tostring"); + + LUA_DEBUG("BEGIN - game.MessagePrint"); + + for(i = 1; i < n; i++) + { + const char *s; + + lua_pushvalue(L, -1); + lua_pushvalue(L, i); + lua_call(L, 1, 1); + s = lua_tostring(L, 2); + + if(s == NULL) + { + LUA_DEBUG("ERROR - game.MessagePrint - no string"); + lua_pushboolean(L, qfalse); + return 1; + } + + Q_strcat(buf, sizeof(buf), s); + + lua_pop(L, 1); + } + + trap_SendServerCommand(clNum, va("servermsg \"" S_COLOR_WHITE "%s\n\"", buf)); + + LUA_DEBUG("END - game.MessagePrint"); + lua_pushboolean(L, qfalse); + return 1; +} + +/*** +Sets a global Lua variable which is called name to value. Creates a new global variable if a variable of name does not exist. Value can be of any type. +@function SetGlobal +@param name Name of global variable. +@param value New value for global variable. +*/ +static int Game_SetGlobal(lua_State *L) { + char *name; + + LUA_DEBUG("BEGIN - game.SetGlobal"); + + name = (char *)luaL_checkstring(L, 1); + + if(name == NULL) { + LUA_DEBUG("ERROR - game.SetGlobal - name NULL"); + lua_pushboolean(L, qfalse); + return 0; + } + + lua_pushvalue(L, 2); + lua_setglobal(L, name); + + LUA_DEBUG("END - game.SetGlobal"); + lua_pushboolean(L, qtrue); + return 0; +} + +/*** +Returns the value of the global variable name. Returns nil if the variable does not exist. +@function GetGlobal +@param name Name of Global variable. +@return value of Global variable. +*/ +static int Game_GetGlobal(lua_State *L) { + char *name; + + LUA_DEBUG("BEGIN - game.SetGlobal"); + + name = (char *)luaL_checkstring(L, 1); + + if(name == NULL) { + LUA_DEBUG("ERROR - game.SetGlobal - name NULL"); + lua_pushnil(L); + return 0; + } + + lua_getglobal(L, name); + LUA_DEBUG("END - game.SetGlobal"); + return 1; +} + +// Alert-Stuff... I don't know. I feel like removing this and stick to the entity spawning and setup. +// game.AlertSetup(entity ent, string greentarget, string yellowtarget, string redtarget, string bluetarget, +// string greensound, string yellowsound, string redsound, string bluesound, integer mode) +static int Game_AlertSetup(lua_State *L) { + + LUA_DEBUG("BEGIN - game.AlertSetup"); + + if(luaAlertState != NULL) { + LUA_DEBUG("ERROR - game.AlertSetup - luaArlterState != NULL"); + lua_pushboolean(L, 0); + return 1; + } + + luaAlertState = (luaAlertState_t *)malloc(sizeof(luaAlertState_t)); + if(luaAlertState == NULL) { + LUA_DEBUG("ERROR - game.AlertSetup - luaAlertState NULL"); + lua_pushboolean(L, 0); + return 1; + } + + luaAlertState->targets[0] = (char *)luaL_checkstring(L, 1); + luaAlertState->targets[1] = (char *)luaL_checkstring(L, 2); + luaAlertState->targets[2] = (char *)luaL_checkstring(L, 3); + luaAlertState->targets[3] = (char *)luaL_checkstring(L, 4); + + luaAlertState->sounds[0] = (char *)luaL_checkstring(L, 5); + luaAlertState->sounds[1] = (char *)luaL_checkstring(L, 6); + luaAlertState->sounds[2] = (char *)luaL_checkstring(L, 7); + luaAlertState->sounds[3] = (char *)luaL_checkstring(L, 8); + + luaAlertState->mode = luaL_checkint(L, 9); + + luaAlertState->cond = 0; + + LUA_DEBUG("END - game.AlertSetup"); + lua_pushboolean(L, 1); + return 1; +} + +static int Game_AlertAddShader(lua_State *L) { + int cond; + char *shader; + + LUA_DEBUG("BEGIN - game.AlertAddShader"); + + if(luaAlertState == NULL) { + LUA_DEBUG("ERROR - game.AlertAddShader - luaAlertShader NULL"); + lua_pushboolean(L, 0); + return 1; + } + + cond = luaL_checkint(L, 1); + if(cond < 0 || cond > 3) { + LUA_DEBUG("ERROR - game.AlertAddShader - cond out of range"); + lua_pushboolean(L, 0); + return 1; + } + + shader = (char *)luaL_checkstring(L, 2); + if(shader == NULL) { + LUA_DEBUG("ERROR - game.AlertAddShader - shader NULL"); + lua_pushboolean(L, 0); + return 1; + } + + if((strlen(shader) + 1) > MAX_QPATH) { + LUA_DEBUG("ERROR - game.AlertAddShader - strlen(shader)+1 > MAX_QPATH"); + lua_pushboolean(L, 0); + return 1; + } + + if(luaAlertState->shaders[cond] == NULL) { + luaAlertState->shaders[cond] = (char *)malloc(sizeof(char) * (strlen(shader) + 1)); + if(luaAlertState->shaders[cond] == NULL) { + LUA_DEBUG("ERROR - game.AlertAddShader - alloc failed"); + lua_pushboolean(L, 0); + return 1; + } + strncpy(luaAlertState->shaders[cond], shader, sizeof(luaAlertState->shaders[cond])); + } else { + void *tmp = realloc(luaAlertState->shaders[cond], sizeof(char) * (strlen(luaAlertState->shaders[cond]) + + strlen(shader) + 1)); + if(tmp == NULL){ + LUA_DEBUG("ERROR - game.AlertAddShader - realloc failed"); + lua_pushboolean(L, 0); + return 1; + } + luaAlertState->shaders[cond] = tmp; + Com_sprintf(luaAlertState->shaders[cond], sizeof(luaAlertState->shaders[cond]), "%s\n%s", luaAlertState->shaders[cond], shader); + } + + lua_pushboolean(L, 1); + LUA_DEBUG("END - game.AlertAddShader"); + return 1; +} + +// game.Alert(entity ent, integer target, boolean silent) +static int Game_Alert(lua_State *L) { + /*lent_t *lent; + int current, target; + qboolean silent;*/ + + return 0; +} + +/*** +Get the current level time in milliseconds. Level time is the time since level start. +@function LevelTime +@return Level time in milliseconds. +*/ +static int Game_Leveltime(lua_State * L) +{ + LUA_DEBUG("BEGIN - game.Leveltime"); + + lua_pushinteger(L, level.time); + + LUA_DEBUG("INFO - game.Leveltime - start/return: leveltime=%d", level.time); + LUA_DEBUG("BEGIN - game.Leveltime"); + return 1; +} + +/*** +Damage and player or entity. +@function Damage +@param target Target entity. +@param inflictor Inflicting entity. Can be nil. +@param attacker Attacking entity. Can be nil. +@param direction Direction of knockback. Can be nil. +@param point Point where the damage is inflicted. Can be nil. +@param damage Ammount of damage. +@param dflags Damage flags. +@param mod Means of death. +@return Success or fail. +*/ +static int Game_Damage(lua_State *L) { + lent_t *lent; + gentity_t *targ = NULL, *inflictor = NULL, *attacker = NULL; + vec_t *dir = NULL, *point = NULL; + int damage = 0, dflags = 0, mod = 0; + + LUA_DEBUG("BEGIN - game.Damage"); + + lent = Lua_GetEntity(L, 1); + if(lent == NULL || lent->e == NULL) { + LUA_DEBUG("ERROR - game.Damage - entity NULL"); + lua_pushboolean(L, qfalse); + return 1; + } + targ = lent->e; + if(!lua_isnil(L, 2)) { + lent = Lua_GetEntity(L, 2); + if(lent && lent->e) { + inflictor = lent->e; + } + } + if(!lua_isnil(L, 3)) { + lent = Lua_GetEntity(L, 3); + if(lent && lent->e) { + attacker = lent->e; + } + } + if(!lua_isnil(L, 4)) { + dir = Lua_GetVector(L, 4); + } + if(!lua_isnil(L, 5)) { + point = Lua_GetVector(L, 5); + } + damage = (int)luaL_checknumber(L, 6); + dflags = (int)luaL_checknumber(L, 7); + mod = (int)luaL_checknumber(L, 8); + + G_Combat_Damage(targ, inflictor, attacker, dir, point, damage, dflags, mod); + + lua_pushboolean(L, qtrue); + LUA_DEBUG("END - game.Damage"); + return 1; +} + +/*** +Repair an entity. +@function Repair +@param target Target entity. +@param rate Repair rate. +@return Success or fail. +*/ +static int Game_Repair(lua_State *L) { + lent_t *lent; + float rate; + + LUA_DEBUG("BEGIN - game.Repair"); + + lent = Lua_GetEntity(L, 1); + if(lent == NULL || lent->e == NULL) { + LUA_DEBUG("ERROR - game.Repair - entity NULL"); + lua_pushboolean(L, qfalse); + return 1; + } + + rate = (float)luaL_checknumber(L, 2); + + G_Combat_Repair(lent->e, NULL, rate); // FIXME ... trance ent? + + LUA_DEBUG("END - game.Repair"); + lua_pushboolean(L, qtrue); + return 1; +} + +static const luaL_Reg lib_game[] = { + { "Damage", Game_Damage }, + { "Repair", Game_Repair }, + { "Print", Game_Print }, + { "MessagePrint", Game_MessagePrint }, + { "CenterPrint", Game_CenterPrint }, + { "ClientPrint", Game_ClientPrint }, + { "GetTime", Game_Leveltime }, + + { "AlertSetup", Game_AlertSetup }, + { "AlertAddShader", Game_AlertAddShader }, + { "Alert", Game_Alert }, + + { "SetGlobal", Game_SetGlobal }, + { "GetGlobal", Game_GetGlobal }, + { NULL, NULL } +}; + +int Luaopen_Game(lua_State *L) { + luaL_register(L, "game", lib_game); + lua_pushliteral(L, "_GAMEVERSION"); + lua_pushliteral(L, GAMEVERSION); + + return 1; +} +#endif diff --git a/code/game/lua_weapons.c b/code/game/lua_weapons.c index 99d6efd..2646572 100644 --- a/code/game/lua_weapons.c +++ b/code/game/lua_weapons.c @@ -1,122 +1,123 @@ -// lua library for weapons - -#include "g_lua.h" - -#ifdef G_LUA - -/*** -A module for everything converning weapons. -@module weapons -*/ - -#include "g_weapon.h" - -/*** -Get the forward vector. -@function GetForward -@return Forward vector. -*/ -static int weapon_GetForward(lua_State *L) { - Lua_PushVector(L, forward); - - return 1; -} - -/*** -Get the right vector. -@function GetRight. -@return Right vector. -*/ -static int weapon_GetRight(lua_State *L) { - Lua_PushVector(L, right); - - return 1; -} - -/*** -Get the up vector. -@function GetUp -@return Up vector. -*/ -static int weapon_GetUp(lua_State *L) { - Lua_PushVector(L, up); - - return 1; -} - -/*** -Get the muzzle point. -@function GetMuzzle -@return Muzzle point. -*/ -static int weapon_GetMuzzle(lua_State *L) { - Lua_PushVector(L, muzzle); - - return 1; -} - -/*** -Do damage to an entity. -@function Damage -@param target Target entity. -@param inflictor Inflicting entity. Can be nil. -@param attacker Attacking entity. Can be nil. -@param dir Direction for knockback. Can be nil. -@param point Point. Can be nil. -@param damage Ammount of damage. -@param dflags Damage flags. -@param mod Means of death. -@return Success or failure. -*/ -static int weapon_Damage(lua_State *L) { - lent_t* lent; - gentity_t* target = NULL; - gentity_t* inflictor = NULL; - gentity_t* attacker = NULL; - vec_t *dir, *point; - int damage, dflags, mod; - - lent = Lua_GetEntity(L, 1); - if(lent == NULL || lent->e == NULL) { - lua_pushboolean(L, qfalse); - return 0; - } - target = Lua_GetEntity(L, 1)->e; - - lent = Lua_GetEntity(L, 2); - if(lent != NULL && lent->e != NULL) { - inflictor = lent->e; - } - - lent = Lua_GetEntity(L, 3); - if(lent != NULL && lent->e != NULL) { - attacker = lent->e; - } - - dir = Lua_GetVector(L, 4); - point = Lua_GetVector(L, 5); - damage = (int)luaL_checknumber(L, 6); - dflags = (int)luaL_checknumber(L, 7); - mod = (int)luaL_checknumber(L, 8); - - G_Damage(target, inflictor, attacker, dir, point, damage, dflags, mod); - - lua_pushboolean(L, qtrue); - return 0; -} - -static const luaL_Reg lib_weapons[] = { - { "GetForward", weapon_GetForward }, - { "GetRight", weapon_GetRight }, - { "GetUp", weapon_GetUp }, - { "GetMuzzle", weapon_GetMuzzle }, - { "Damage", weapon_Damage }, - { NULL, NULL } -}; - -int Luaopen_Weapons(lua_State *L) { - luaL_register(L, "weapons", lib_weapons); - - return 1; -} -#endif +// lua library for weapons + +#include "g_lua.h" + +#ifdef G_LUA + +/*** +A module for everything converning weapons. +@module weapons +*/ + +#include "g_weapon.h" +#include "g_combat.h" + +/*** +Get the forward vector. +@function GetForward +@return Forward vector. +*/ +static int weapon_GetForward(lua_State *L) { + Lua_PushVector(L, forward); + + return 1; +} + +/*** +Get the right vector. +@function GetRight. +@return Right vector. +*/ +static int weapon_GetRight(lua_State *L) { + Lua_PushVector(L, right); + + return 1; +} + +/*** +Get the up vector. +@function GetUp +@return Up vector. +*/ +static int weapon_GetUp(lua_State *L) { + Lua_PushVector(L, up); + + return 1; +} + +/*** +Get the muzzle point. +@function GetMuzzle +@return Muzzle point. +*/ +static int weapon_GetMuzzle(lua_State *L) { + Lua_PushVector(L, muzzle); + + return 1; +} + +/*** +Do damage to an entity. +@function Damage +@param target Target entity. +@param inflictor Inflicting entity. Can be nil. +@param attacker Attacking entity. Can be nil. +@param dir Direction for knockback. Can be nil. +@param point Point. Can be nil. +@param damage Ammount of damage. +@param dflags Damage flags. +@param mod Means of death. +@return Success or failure. +*/ +static int weapon_Damage(lua_State *L) { + lent_t* lent; + gentity_t* target = NULL; + gentity_t* inflictor = NULL; + gentity_t* attacker = NULL; + vec_t *dir, *point; + int damage, dflags, mod; + + lent = Lua_GetEntity(L, 1); + if(lent == NULL || lent->e == NULL) { + lua_pushboolean(L, qfalse); + return 0; + } + target = Lua_GetEntity(L, 1)->e; + + lent = Lua_GetEntity(L, 2); + if(lent != NULL && lent->e != NULL) { + inflictor = lent->e; + } + + lent = Lua_GetEntity(L, 3); + if(lent != NULL && lent->e != NULL) { + attacker = lent->e; + } + + dir = Lua_GetVector(L, 4); + point = Lua_GetVector(L, 5); + damage = (int)luaL_checknumber(L, 6); + dflags = (int)luaL_checknumber(L, 7); + mod = (int)luaL_checknumber(L, 8); + + G_Combat_Damage(target, inflictor, attacker, dir, point, damage, dflags, mod); + + lua_pushboolean(L, qtrue); + return 0; +} + +static const luaL_Reg lib_weapons[] = { + { "GetForward", weapon_GetForward }, + { "GetRight", weapon_GetRight }, + { "GetUp", weapon_GetUp }, + { "GetMuzzle", weapon_GetMuzzle }, + { "Damage", weapon_Damage }, + { NULL, NULL } +}; + +int Luaopen_Weapons(lua_State *L) { + luaL_register(L, "weapons", lib_weapons); + + return 1; +} +#endif