Skip to content

Commit

Permalink
initial class-based stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
themuffinator committed Sep 14, 2024
1 parent 9fb8b97 commit a33e647
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/bots/bot_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/g_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/g_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/g_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/monsters/m_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
59 changes: 23 additions & 36 deletions src/p_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/p_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/p_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a33e647

Please sign in to comment.