From a33e6475e67b5dd7af78350328b6e3c6937b898c Mon Sep 17 00:00:00 2001 From: themuffinator Date: Sun, 15 Sep 2024 00:41:55 +0100 Subject: [PATCH] initial class-based stuff --- src/bots/bot_utils.cpp | 2 +- src/g_ai.cpp | 8 +++--- src/g_local.h | 2 ++ src/g_main.cpp | 5 +++- src/g_utils.cpp | 6 +++++ src/monsters/m_move.cpp | 2 +- src/p_client.cpp | 59 ++++++++++++++++------------------------- src/p_hud.cpp | 2 +- src/p_view.cpp | 4 +-- 9 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/bots/bot_utils.cpp b/src/bots/bot_utils.cpp index 80b1e3d..f4d5988 100644 --- a/src/bots/bot_utils.cpp +++ b/src/bots/bot_utils.cpp @@ -44,7 +44,7 @@ static void Player_UpdateState(gentity_t *player) { player->sv.ent_flags |= SVFL_HAS_PROTECTION; } - if (player->client->pu_time_invisibility > level.time) { + if (ClientIsPredator(player->client) || player->client->pu_time_invisibility > level.time) { player->sv.ent_flags |= SVFL_HAS_INVISIBILITY; } diff --git a/src/g_ai.cpp b/src/g_ai.cpp index bab350a..4040b4b 100644 --- a/src/g_ai.cpp +++ b/src/g_ai.cpp @@ -349,7 +349,7 @@ bool visible(gentity_t *self, gentity_t *other, bool through_glass) { if (!other->solid) return false; - if (other->client->pu_time_invisibility > level.time) { + if (ClientIsPredator(other->client) || other->client->pu_time_invisibility > level.time) { // can't see us at all after this time if (other->client->invisibility_fade_time <= level.time) return false; @@ -717,7 +717,7 @@ bool FindTarget(gentity_t *self) { } } - if (self->enemy->client && self->enemy->client->pu_time_invisibility > level.time && self->enemy->client->invisibility_fade_time <= level.time) { + if (self->enemy->client && (ClientIsPredator(self->enemy->client) || self->enemy->client->pu_time_invisibility > level.time) && self->enemy->client->invisibility_fade_time <= level.time) { self->enemy = nullptr; return false; } @@ -805,7 +805,7 @@ bool M_CheckAttack_Base(gentity_t *self, float stand_ground_chance, float melee_ if (self->enemy->health > 0) { if (self->enemy->client) { - if (self->enemy->client->pu_time_invisibility > level.time) { + if (ClientIsPredator(self->enemy->client) || self->enemy->client->pu_time_invisibility > level.time) { // can't see us at all after this time if (self->enemy->client->invisibility_fade_time <= level.time) return false; @@ -1094,7 +1094,7 @@ bool ai_checkattack(gentity_t *self, float dist) { } // [Paril-KEX] if our enemy was invisible, lose sight now - if (self->enemy->client && self->enemy->client->pu_time_invisibility > level.time && self->enemy->client->invisibility_fade_time <= level.time && + if (self->enemy->client && (ClientIsPredator(self->enemy->client) || self->enemy->client->pu_time_invisibility > level.time) && self->enemy->client->invisibility_fade_time <= level.time && (self->monsterinfo.aiflags & AI_PURSUE_NEXT)) { hesDeadJim = true; } diff --git a/src/g_local.h b/src/g_local.h index 9ed1ee7..3604c0e 100644 --- a/src/g_local.h +++ b/src/g_local.h @@ -2227,6 +2227,7 @@ extern cvar_t *g_no_nukes; extern cvar_t *g_no_powerups; extern cvar_t *g_no_spheres; extern cvar_t *g_owner_auto_join; +extern cvar_t *g_predator_ir; extern cvar_t *g_quadhog; extern cvar_t *g_quick_weapon_switch; extern cvar_t *g_rollangle; @@ -2420,6 +2421,7 @@ gentity_t *ClientEntFromString(const char *in); ruleset_t RS_IndexFromString(const char *in); void TeleporterVelocity(gentity_t *ent, gvec3_t angles); void MS_Adjust(gclient_t *cl, mstats_t index, int count); +bool ClientIsPredator(gclient_t *cl); // // g_spawn.cpp diff --git a/src/g_main.cpp b/src/g_main.cpp index cd54f1d..055f86d 100644 --- a/src/g_main.cpp +++ b/src/g_main.cpp @@ -177,6 +177,7 @@ cvar_t *g_no_nukes; cvar_t *g_no_powerups; cvar_t *g_no_spheres; cvar_t *g_owner_auto_join; +cvar_t *g_predator_ir; cvar_t *g_quadhog; cvar_t *g_quick_weapon_switch; cvar_t *g_rollangle; @@ -357,10 +358,12 @@ static void InitGame() { g_dm_strong_mines = gi.cvar("g_dm_strong_mines", "0", CVAR_NOFLAGS); g_dm_random_items = gi.cvar("g_dm_random_items", "0", CVAR_NOFLAGS); + g_owner_auto_join = gi.cvar("g_owner_auto_join", "1", CVAR_NOFLAGS); + g_predator_ir = gi.cvar("g_predator_ir", "1", CVAR_NOFLAGS); + // game modifications g_instagib = gi.cvar("g_instagib", "0", CVAR_SERVERINFO | CVAR_LATCH); g_instagib_splash = gi.cvar("g_instagib_splash", "0", CVAR_NOFLAGS); - g_owner_auto_join = gi.cvar("g_owner_auto_join", "1", CVAR_NOFLAGS); g_quadhog = gi.cvar("g_quadhog", "0", CVAR_SERVERINFO | CVAR_LATCH); g_nadefest = gi.cvar("g_nadefest", "0", CVAR_SERVERINFO | CVAR_LATCH); g_frenzy = gi.cvar("g_frenzy", "0", CVAR_SERVERINFO | CVAR_LATCH); diff --git a/src/g_utils.cpp b/src/g_utils.cpp index 2cc3c22..ac6e539 100644 --- a/src/g_utils.cpp +++ b/src/g_utils.cpp @@ -1009,3 +1009,9 @@ void MS_Adjust(gclient_t *cl, mstats_t index, int count) { cl->resp.mstats[index] += count; } + +bool ClientIsPredator(gclient_t *cl) { + if (cl->sess.team == TEAM_PREDATOR) + return true; + return false; +} \ No newline at end of file diff --git a/src/monsters/m_move.cpp b/src/monsters/m_move.cpp index 9af6db5..c7063ae 100644 --- a/src/monsters/m_move.cpp +++ b/src/monsters/m_move.cpp @@ -1134,7 +1134,7 @@ static bool M_MoveToPath(gentity_t *self, float dist) { return false; else if (!self->enemy) return false; - else if (self->enemy->client && self->enemy->client->pu_time_invisibility > level.time && self->enemy->client->invisibility_fade_time <= level.time) + else if (self->enemy->client && (ClientIsPredator(self->enemy->client) || self->enemy->client->pu_time_invisibility > level.time) && self->enemy->client->invisibility_fade_time <= level.time) return false; else if (self->monsterinfo.attack_state >= AS_MISSILE) return true; diff --git a/src/p_client.cpp b/src/p_client.cpp index 225caa7..7395604 100644 --- a/src/p_client.cpp +++ b/src/p_client.cpp @@ -1208,47 +1208,34 @@ void InitClientPersistant(gentity_t *ent, gclient_t *client) { } else if (g_nadefest->integer) { client->pers.inventory[IT_AMMO_GRENADES] = AMMO_INFINITE; } else { - if (RS(RS_Q3A)) { - client->pers.max_ammo.fill(200); - client->pers.max_ammo[AMMO_BULLETS] = 200; - client->pers.max_ammo[AMMO_SHELLS] = 200; - client->pers.max_ammo[AMMO_CELLS] = 200; + if (client->sess.team == TEAM_SOLDIERS) { + client->pers.max_ammo.fill(50); - client->pers.max_ammo[AMMO_TRAP] = 200; - client->pers.max_ammo[AMMO_FLECHETTES] = 200; - client->pers.max_ammo[AMMO_DISRUPTOR] = 200; - client->pers.max_ammo[AMMO_TESLA] = 200; + client->pers.inventory[IT_WEAPON_BLASTER] = 1; - client->pers.inventory[IT_WEAPON_CHAINFIST] = 1; - client->pers.inventory[IT_WEAPON_MACHINEGUN] = 1; - client->pers.inventory[IT_AMMO_BULLETS] = 100; - } else if (RS(RS_Q1)) { - client->pers.max_ammo.fill(200); - client->pers.max_ammo[AMMO_BULLETS] = 200; - client->pers.max_ammo[AMMO_SHELLS] = 200; - client->pers.max_ammo[AMMO_CELLS] = 200; - - client->pers.max_ammo[AMMO_TRAP] = 200; - client->pers.max_ammo[AMMO_FLECHETTES] = 200; - client->pers.max_ammo[AMMO_DISRUPTOR] = 200; - client->pers.max_ammo[AMMO_TESLA] = 200; + if (brandom()) { + client->pers.inventory[IT_WEAPON_MACHINEGUN] = 1; + client->pers.inventory[IT_AMMO_BULLETS] = 150; + client->pers.max_ammo[AMMO_BULLETS] = 200; + } else { + client->pers.inventory[IT_WEAPON_SHOTGUN] = 1; + client->pers.inventory[IT_AMMO_SHELLS] = 50; + client->pers.max_ammo[AMMO_SHELLS] = 50; + } - client->pers.inventory[IT_WEAPON_CHAINFIST] = 1; - client->pers.inventory[IT_WEAPON_SHOTGUN] = 1; - client->pers.inventory[IT_AMMO_SHELLS] = 10; + client->pers.inventory[IT_AMMO_GRENADES] = 50; } else { - // fill with 50s, since it's our most common value client->pers.max_ammo.fill(50); - client->pers.max_ammo[AMMO_BULLETS] = 200; - client->pers.max_ammo[AMMO_SHELLS] = 100; - client->pers.max_ammo[AMMO_CELLS] = 200; - - client->pers.max_ammo[AMMO_TRAP] = 5; - client->pers.max_ammo[AMMO_FLECHETTES] = 200; - client->pers.max_ammo[AMMO_DISRUPTOR] = 12; - client->pers.max_ammo[AMMO_TESLA] = 5; - - client->pers.inventory[IT_WEAPON_BLASTER] = 1; + client->pers.max_ammo[AMMO_ROCKETS] = 50; + client->pers.max_ammo[AMMO_SLUGS] = 50; + + client->pers.inventory[IT_WEAPON_RLAUNCHER] = 1; + client->pers.inventory[IT_WEAPON_RAILGUN] = 1; + client->pers.inventory[IT_AMMO_ROCKETS] = 50; + client->pers.inventory[IT_AMMO_SLUGS] = 50; + + client->pers.inventory[IT_WEAPON_GRAPPLE] = 1; + client->pers.inventory[IT_WEAPON_CHAINFIST] = 1; } if (deathmatch->integer) { diff --git a/src/p_hud.cpp b/src/p_hud.cpp index 977941f..2d934e2 100644 --- a/src/p_hud.cpp +++ b/src/p_hud.cpp @@ -988,7 +988,7 @@ static void SetCrosshairIDView(gentity_t *ent) { return; // don't show if traced client is currently invisibile - if (tr.ent->client->pu_time_invisibility > level.time) + if (ClientIsPredator(tr.ent->client) || tr.ent->client->pu_time_invisibility > level.time) return; ent->client->ps.stats[STAT_CROSSHAIR_ID_VIEW] = (tr.ent - g_entities); diff --git a/src/p_view.cpp b/src/p_view.cpp index 6feb635..db28e39 100644 --- a/src/p_view.cpp +++ b/src/p_view.cpp @@ -573,7 +573,7 @@ static void G_CalcBlend(gentity_t *ent) { float brightness = (ent->client->nuke_time - level.time).seconds() / 2.0f; G_AddBlend(1, 1, 1, brightness, ent->client->ps.screen_blend); } - if (ent->client->ir_time > level.time) { + if ((ClientIsPredator(ent->client) && g_predator_ir->integer) || ent->client->ir_time > level.time) { remaining = ent->client->ir_time - level.time; if (G_PowerUpExpiringRelative(remaining)) { ent->client->ps.rdflags |= RDF_IRGOGGLES; @@ -818,7 +818,7 @@ static void G_SetClientEffects(gentity_t *ent) { ent->s.effects |= EF_HALF_DAMAGE; if (ent->client->tracker_pain_time > level.time) ent->s.effects |= EF_TRACKERTRAIL; - if (ent->client->pu_time_invisibility > level.time) { + if (ClientIsPredator(ent->client) || ent->client->pu_time_invisibility > level.time) { if (ent->client->invisibility_fade_time <= level.time) ent->s.alpha = 0.05f; else {