Skip to content

Commit

Permalink
Merge pull request #1256 from FortressOne/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
drzel authored Nov 20, 2023
2 parents e08b1c4 + 40b3802 commit 6eb5608
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 62 deletions.
1 change: 0 additions & 1 deletion csqc/csextradefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,6 @@ float team_no;
float crosshair_team_no;
float all_time;
float painfinished;
vector thisorigin;
float jump_counter;
float last_id_time;

Expand Down
12 changes: 8 additions & 4 deletions csqc/pmove.qc
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,13 @@ static PM_Nudge* PM_AddNudgeExplosion(float nat, float seq, float itime, entity
return n;
}

static PM_Nudge* PM_AddNudgeBounce(float itime, entity ent, float dmg) {
static void PM_AddNudgeBounce(float itime, entity ent, float dmg) {
if (vlen(PM_Org() - ent.origin) > dmg * 3) // Fine tune this..
return;

PM_Nudge* n = find_nudge_slot();
if (!n)
return 0;
return;

n->type = NT_BOUNCE;
n->nat = NA_ITIME;
Expand All @@ -453,8 +453,6 @@ static PM_Nudge* PM_AddNudgeBounce(float itime, entity ent, float dmg) {

ent.nudge = n;
ent.removefunc = PM_RemoveSelfNudges;

return n;
}

static void PM_NudgeBounce(PM_Nudge* nudge, entity ent) {
Expand Down Expand Up @@ -624,6 +622,9 @@ static void PM_RunMovement(PMS_Data* pmsd, float endframe) {
if (!CVARF(fopm_nonudge)) {
float slack = (pm.seq == pm.server_seq + 1) ? NUDGE_EPS : 0;
PM_ApplyNudges(ent, pm.seq, pm.interp_t, pm.interp_t + input_timelength, slack);

if ((ent.pmove_flags & PMF_JUMP_HELD) && (pstate_pred.tfstate & TFSTATE_CONC))
Conc_Jump(&pstate_pred.conc_state, ent);
}

pm.seq++;
Expand Down Expand Up @@ -759,6 +760,9 @@ void PM_SyncTo(float seq) {
if (!PM_Enabled())
return;

if (!game_state.is_alive)
return;

entity ent = pm.ent;
PM_RunMovement(SimPMSD(), seq);

Expand Down
2 changes: 1 addition & 1 deletion csqc/weapon_predict.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ void WP_Attack() {
// but this includes the ping adjustment that would occur at pred.
// Tested both ways and this seems to be more stable.
sendevent("Attack", "ifvv",
(float)wi->weapon, pstate_server.client_time,
wi->weapon, pstate_server.client_time,
PM_Org(), input_angles);
}
}
Expand Down
36 changes: 17 additions & 19 deletions share/classes.qc
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,43 @@ static float NextToWall(entity ent) {
const float CONC_P = 0.25;
const float CONC_HZ = 1/CONC_P;

void Conc_Stumble(entity ent, float imp, float flip) {
void Conc_Stumble(entity ent, float stumble, float flip) {
if ((ent.flags & (FL_INWATER | FL_ONGROUND) == 0) ||
(*self_tf_state() & TFSTATE_FEIGNED))
return;

if (NextToWall(ent) && ent.velocity == '0 0 0')
return;

ent.velocity = [flip * ent.velocity_y + imp, flip * ent.velocity_x + imp,
ent.velocity_z];
// [*]: This preserves what looks to be a long-standing bug where y-vel ends
// up propagating due to missed temporary to hold vel_x.
ent.velocity_x = flip * ent.velocity_y + stumble;
ent.velocity_y = flip * ent.velocity_x + stumble;
}

void Conc_Jump(ConcState* cs, entity ent) {
float stumble = shared_crandom(PRNG_CONC) * cs->mag / 10;
float flip = (shared_prng(PRNG_CONC) < 0.5) ? -1 : 1;

// See [*] above.
ent.velocity_x = flip * ent.velocity_y + stumble;
ent.velocity_y = flip * ent.velocity_x + stumble;
}

#ifdef SSQC
void SpawnBubble(vector origin);
static inline void ConcAction(entity ent, float itime, float mag, float flip) {
Conc_Stumble(ent, mag, flip);
}
#else
void PM_AddNudgeConc(float itime, float mag, float flip);

static inline void ConcAction(entity ent, float itime, float mag, float flip) {
PM_AddNudgeConc(itime, mag, flip);
}
#endif

void Conc_Update(ConcState *cs, entity ent, float ctime) {
#ifdef SSQC
if (ent.invincible_finished > time) // TODO: Is this worth sharing?
cs->mag = 0;
#endif
float Conc_Update(ConcState *cs, entity ent, float ctime) {
if (!cs->mag || ctime < cs->next)
return;
return FALSE;

while (ctime >= cs->next) {
cs->mag = max(cs->mag - 1, 0);
Expand All @@ -153,14 +158,7 @@ void Conc_Update(ConcState *cs, entity ent, float ctime) {
cs->next += CONC_P;
}

#ifdef SSQC
if (cs->mag) {
if (cs->mag % CONC_HZ == 0)
SpawnBubble(ent.origin);
} else {
sprint(self.owner, PRINT_HIGH, "Your head feels better now\n");
}
#endif
return TRUE;
}

float Class_ScaleMoment(float playerclass, float damage) {
Expand Down
1 change: 1 addition & 0 deletions share/weapons.qc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ FO_GrenInfo fo_grenades[] = {
{ GREN_MIRVLET, "mirv", "grenade2.mdl", 1, ICON_GREN_NONE, '250 300 400'},
{ GREN_RED, "gl", "grenade2.mdl", 1, ICON_GREN_NONE, '300 300 300'},
{ GREN_PIPE, "pipe", "grenade2.mdl", 2, ICON_GREN_NONE, '300 300 300'},
{ GREN_NONE, "none", "", 0, ICON_GREN_NONE, '0 0 0'},
};

string FO_GrenName(float gtype) {
Expand Down
48 changes: 30 additions & 18 deletions ssqc/client.qc
Original file line number Diff line number Diff line change
Expand Up @@ -2536,17 +2536,8 @@ void () PlayerJump = {
StopAssCan();
}

if (GetConcMode() == CONC_CLASSIC && (self.tfstate & TFSTATE_CONC)) {
entity te = FindConcTimer(self);
stumble = crandom() * (te.health / 100);
if (crandom() < 0) {
self.velocity_x = self.velocity_y + stumble;
self.velocity_y = self.velocity_x + stumble;
} else {
self.velocity_x = (-1 * self.velocity_y) + stumble;
self.velocity_y = (-1 * self.velocity_x) + stumble;
}
}
if (GetConcMode() == CONC_CLASSIC && (self.tfstate & TFSTATE_CONC))
Conc_Jump(&self.conc_state, self);
};

.float dmgtime;
Expand Down Expand Up @@ -2649,9 +2640,31 @@ void () CheckWaterJump = {
}
};

void SpawnBubble(vector origin);

static void ConcUpdate() {
if (self.tfstate & TFSTATE_CONC == 0)
return;

if (self.invincible_finished > time) {
self.conc_state.mag = 0;
} else {
if (!Conc_Update(&self.conc_state, self, time))
return;
}

if (self.conc_state.mag) {
if (self.conc_state.mag % CONC_HZ == 0)
SpawnBubble(self.origin);
} else {
RemoveConc(self, FALSE);
sprint(self.owner, PRINT_HIGH, "Your head feels better now\n");
}
}

void () PlayerPreThink = {
FO_UpdateClientTime();
Conc_Update(&self.conc_state, self, time);
ConcUpdate();

if (self.impulse) {
if (self.impulse == TF_VOTENEXT) {
Expand Down Expand Up @@ -2767,7 +2780,7 @@ void () CheckPowerups = {
self.modelindex = modelindex_eyes;
} else {
if (self.invisible_finished) {
if (self.tfstate & 64) {
if (self.tfstate & TFSTATE_INVISIBLE) {
if (self.invisible_finished < (time + 10)) {
self.invisible_finished = time + 666;
}
Expand Down Expand Up @@ -2802,7 +2815,7 @@ void () CheckPowerups = {
}
}
if (self.invincible_finished) {
if (self.tfstate & 32) {
if (self.tfstate & TFSTATE_INVINCIBLE) {
if (self.invincible_finished < (time + 10)) {
self.invincible_finished = time + 666;
}
Expand Down Expand Up @@ -2846,7 +2859,7 @@ void () CheckPowerups = {
}
}
if (self.super_damage_finished) {
if (self.tfstate & 128) {
if (self.tfstate & TFSTATE_QUAD) {
if (self.super_damage_finished == (time + 10)) {
self.super_damage_finished = time + 666;
}
Expand All @@ -2869,8 +2882,7 @@ void () CheckPowerups = {
self.super_time = 0;
}
if (self.super_damage_finished > time) {
self.effects = self.effects | 8;
self.effects = self.effects | 64;
self.effects |= EF_DIMLIGHT | EF_BLUE;
} else {
lighton = 0;
te = find(world, classname, "item_tfgoal");
Expand All @@ -2889,7 +2901,7 @@ void () CheckPowerups = {
}
if (self.radsuit_finished) {
self.air_finished = time + 12;
if (self.tfstate & 256) {
if (self.tfstate & TFSTATE_RADSUIT) {
if (self.radsuit_finished == (time + 10)) {
self.radsuit_finished = time + 666;
}
Expand Down
1 change: 1 addition & 0 deletions ssqc/scout.qc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void RemoveConc(entity player, float remove_timer = TRUE) {
return;

player.tfstate &= ~TFSTATE_CONC;
player.conc_state.mag = 0;
player.conc_finished = 0;

if (GetConcMode() == CONC_IDLESCALE)
Expand Down
8 changes: 4 additions & 4 deletions ssqc/status.qc
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,7 @@ void UpdateClientReloadSound(entity pl, float weapon) {
}

void UpdateClientGrenadePrimed(entity pl, float grentype, float explodes_at) = {
return; // Not needed until we re-enable TFX.

#if 0 // Not needed until we re-enable TFX.
msg_entity = pl;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, MSG_GRENPRIMED);
Expand All @@ -785,16 +784,17 @@ void UpdateClientGrenadePrimed(entity pl, float grentype, float explodes_at) = {
WriteFloat(MSG_MULTICAST, explodes_at);

multicast('0 0 0', MULTICAST_ALL); // Actual primer has reliable transport.
#endif
}

void UpdateClientGrenadeThrown(entity pl) = {
return; // Not needed until we re-enable TFX.

#if 0 // Not needed until we re-enable TFX.
msg_entity = pl;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, MSG_GRENTHROWN);
WriteEntity(MSG_MULTICAST, pl);
multicast('0 0 0', MULTICAST_ALL);
#endif
}

void UpdateClientIDString(entity pl) {
Expand Down
4 changes: 4 additions & 0 deletions ssqc/tfort.qc
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,10 @@ void TeamFortress_PrimeGrenade(float inp, float is_player) {
return;

FO_GrenInfo* gdesc = FO_PlayerGren(self, inp - 1);

if (gdesc->id == GREN_NONE)
return;

float *numg = (inp == 1) ? &self.no_grenades_1 : &self.no_grenades_2;
string gs = FO_GrenName(gdesc->id);

Expand Down
15 changes: 6 additions & 9 deletions ssqc/tfortmap.qc
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,10 @@ void (entity Goal, entity Player, entity AP, float addb) Apply_Results = {
}

if (disable_resup_gren & 1 == 0)
Player.no_grenades_1 = min(Player.no_grenades_1 + 1,
Player.no_grenades_1 = min(Player.no_grenades_1 + Goal.no_grenades_1,
Player.max_grenades_1);
if (disable_resup_gren & 2 == 0)
Player.no_grenades_2 = min(Player.no_grenades_2 + 1,
Player.no_grenades_2 = min(Player.no_grenades_2 + Goal.no_grenades_2,
Player.max_grenades_2);

if (Player.ammo_detpack > Player.maxammo_detpack) {
Expand Down Expand Up @@ -1179,28 +1179,25 @@ void (entity Goal, entity Player) RemoveResults = {
te = find(te, classname, "item_tfgoal");
}
if ((Goal.invincible_finished > 0) && !puinvin) {
Player.tfstate =
Player.tfstate - (Player.tfstate & TFSTATE_INVINCIBLE);
Player.tfstate &= ~TFSTATE_INVINCIBLE;
Player.items = Player.items | IT_INVULNERABILITY;
Player.invincible_time = 1;
Player.invincible_finished = time + Goal.invincible_finished;
}
if ((Goal.invisible_finished > 0) && !puinvis) {
Player.tfstate =
Player.tfstate - (Player.tfstate & TFSTATE_INVISIBLE);
Player.tfstate &= ~TFSTATE_INVISIBLE;
Player.items = Player.items | IT_INVISIBILITY;
Player.invisible_time = 1;
Player.invisible_finished = time + Goal.invisible_finished;
}
if ((Goal.super_damage_finished > 0) && !puquad) {
Player.tfstate = Player.tfstate - (Player.tfstate & TFSTATE_QUAD);
Player.tfstate &= ~TFSTATE_QUAD;
Player.items = Player.items | IT_QUAD;
Player.super_time = 1;
Player.super_damage_finished = time + Goal.super_damage_finished;
}
if ((Goal.radsuit_finished > 0) && !purad) {
Player.tfstate =
Player.tfstate - (Player.tfstate & TFSTATE_RADSUIT);
Player.tfstate &= ~TFSTATE_RADSUIT;
Player.items = Player.items | IT_SUIT;
Player.rad_time = 1;
Player.radsuit_finished = time + Goal.radsuit_finished;
Expand Down
12 changes: 6 additions & 6 deletions ssqc/weapons.qc
Original file line number Diff line number Diff line change
Expand Up @@ -2676,22 +2676,22 @@ void () SuperDamageSound = {

void () ToggleInvincibility = {
if(self.tfstate & TFSTATE_INVINCIBLE) {
self.items = self.items - (self.items & IT_INVULNERABILITY);
self.items &= ~IT_INVULNERABILITY;
self.invincible_time = 0;
self.invincible_finished = 0;
self.tfstate = self.tfstate - (self.tfstate & TFSTATE_INVINCIBLE);
self.effects = self.effects - (self.effects & (EF_RED + EF_DIMLIGHT + EF_BRIGHTLIGHT));
self.tfstate &= ~TFSTATE_INVINCIBLE;
self.effects &= ~(EF_RED | EF_DIMLIGHT | EF_BRIGHTLIGHT);
} else {
self.items = self.items | IT_INVULNERABILITY;
self.items |= IT_INVULNERABILITY;
self.invincible_time = 1;
self.tfstate = self.tfstate | TFSTATE_INVINCIBLE;
self.tfstate |= TFSTATE_INVINCIBLE;
self.invincible_finished = time + 666;
}
};

// TODO: trust the client less, validate more.
// TODO: Could support hitscan (e.g. sg/ssg)
void (float weap, float ctime, vector pos, vector angles) CSEv_Attack_ifvv = {
void (int weap, float ctime, vector pos, vector angles) CSEv_Attack_ifvv = {
if (!RewindFlagEnabled(REWIND_SENDEVENT))
return;

Expand Down

0 comments on commit 6eb5608

Please sign in to comment.