Skip to content

Commit

Permalink
Merge pull request #1291 from newbytf/master
Browse files Browse the repository at this point in the history
sync staging -> master
  • Loading branch information
drzel authored Jan 24, 2024
2 parents 6eb5608 + c34ea3f commit 1ae6cf5
Show file tree
Hide file tree
Showing 33 changed files with 695 additions and 214 deletions.
11 changes: 3 additions & 8 deletions csqc/csextradefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ typedef struct {
float clanmode;
float quadmode;
float duelmode;
float new_balance;
float quad_rounds;
float quad_round_time;
float fo_login_required;
Expand All @@ -345,14 +346,6 @@ typedef struct {
float class_limit_pyro;
float class_limit_spy;
float class_limit_engineer;
float spurs_on;
float spurs_scout;
float spurs_spy;
float spurs_engineer;
float spurs_duration;
float spurs_boost;
float spurs_consume;
float spurs_flag;
} SERVER_SETTINGS;
SERVER_SETTINGS SERVER_ADMIN;

Expand Down Expand Up @@ -925,3 +918,5 @@ void cvar_parse4(string s, __out veci target) {
target.v[2] = stof(argv(2));
target.i = stof(argv(3));
}

float servertime;
1 change: 1 addition & 0 deletions csqc/events.qc
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ void() CSQC_Parse_Event = {
SERVER_ADMIN.clanmode = readfloat();
SERVER_ADMIN.quadmode = readfloat();
SERVER_ADMIN.duelmode = readfloat();
SERVER_ADMIN.new_balance = readfloat();
SERVER_ADMIN.pubmode = (((SERVER_ADMIN.clanmode & 1) || (SERVER_ADMIN.quadmode & 1) || (SERVER_ADMIN.duelmode & 1))?1:0) +
(((SERVER_ADMIN.clanmode & 2) || (SERVER_ADMIN.quadmode & 2) || (SERVER_ADMIN.duelmode & 2))?2:0);
SERVER_ADMIN.pubmode = 3 - SERVER_ADMIN.pubmode; //Invert
Expand Down
12 changes: 12 additions & 0 deletions csqc/hud.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,15 @@ void Hud_DrawClassInfoPanel(float playerclass)
}
break;
case PC_ENGINEER:
if (NewBalanceActive()) {
basepos = pos;
msg = pstate_pred.server_time >= pstate_pred.special_next ?
"Impeller charged" : "Impeller recharging";
HRC_drawOffsetString(panel->Orientation, msg, size, fontSize,
pos, basepos, FALSE, colour);

pos = [pos_x, pos_y + size_y + 4];
}
if (SBAR.HasSentry)
{
icon = ICON_ENGINEER_SG; //HudIcons[playerclass+6].icon;
Expand Down Expand Up @@ -1049,6 +1058,9 @@ void Hud_DrawIdentifyPanel(string identify) {
// click event
}

if (time > last_id_time + 3)
return;

vector fontSize = FO_Hud_Icon_Font_Size * panel->Scale;

float count = tokenizebyseparator(identify, "\n");
Expand Down
15 changes: 9 additions & 6 deletions csqc/menu.qc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void (float force) FO_Menu_Admin_Timelimit;
void (float force) FO_Menu_Admin_Fraglimit;
void (float force) FO_Menu_Admin_QuadTimelimit;
void (float force) FO_Menu_Admin_FoMatchRated;
void (float force) FO_Menu_Admin_NewBalance;
void (float force) FO_Menu_Spy;
void (float force) FO_Menu_Spy_Skin;
void (float force) FO_Menu_Spy_Team;
Expand Down Expand Up @@ -438,10 +439,9 @@ var fo_menu FO_MENU_ADMIN_MODES = {
{"2","Clan Mode","","Game has a prematch",FO_MENU_STATE_NORMAL,{localcmd("cmd clanmode\n");},MENU_BORDER_WARNING},
{"3","Quad Mode","","Play for a set number of rounds, designed for attack vs defence",FO_MENU_STATE_NORMAL,{localcmd("cmd quadmode\n");},MENU_BORDER_WARNING},
{"4","Duel Mode","","Simplifies 1 on 1 action",FO_MENU_STATE_NORMAL,{localcmd("cmd duelmode\n");},MENU_BORDER_WARNING},
{"5","Quad Rounds...","","Number of rounds in Quad mode. Usually 2",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_Rounds(TRUE);},MENU_BORDER_WARNING},
{"6","Quad Round Time...","","Round time for each quad round",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_QuadTimelimit(TRUE);},MENU_BORDER_WARNING},
{"5","Captains Mode","","Select captains who can then pick their teams",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_Players(TRUE, CLIENT_MENU_CAPTAIN_1, 0);},MENU_BORDER_WARNING},
{"7","Rated/Unrated","","Will player ratings be affected?",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_FoMatchRated(TRUE);},MENU_BORDER_WARNING},
{"8","Captains Mode","","Select captains who can then pick their teams",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_Players(TRUE, CLIENT_MENU_CAPTAIN_1, 0);},MENU_BORDER_WARNING},
{"8","New Balance","","New Balance Test",FO_MENU_STATE_NORMAL,{localcmd("cmd new_balance");},MENU_BORDER_WARNING},
{"9","Force Start","","Skip prematch and start the game\nPlease use sparingly",FO_MENU_STATE_NORMAL,{localcmd("cmd forcestart\n");},MENU_BORDER_WARNING},
{"0","Close Menu","","",FO_MENU_STATE_NORMAL,{Menu_Cancel();},MENU_BUTTON},
{"+","Next - Settings","","",FO_MENU_STATE_NORMAL,{Menu_Cancel(); FO_Menu_Admin_Settings(TRUE);},MENU_BUTTON},
Expand All @@ -452,16 +452,17 @@ var fo_menu FO_MENU_ADMIN_MODES = {
FO_MENU_ADMIN_MODES.options[1].value = modeStatus(SERVER_ADMIN.clanmode);
FO_MENU_ADMIN_MODES.options[2].value = modeStatus(SERVER_ADMIN.quadmode);
FO_MENU_ADMIN_MODES.options[3].value = modeStatus(SERVER_ADMIN.duelmode);
FO_MENU_ADMIN_MODES.options[4].value = ftos(SERVER_ADMIN.quad_rounds);
FO_MENU_ADMIN_MODES.options[5].value = ftos(SERVER_ADMIN.quad_round_time);
FO_MENU_ADMIN_MODES.options[4].value = SERVER_ADMIN.captainmode?"on":"off";
FO_MENU_ADMIN_MODES.options[6].value = ratedStatus(SERVER_ADMIN.fo_matchrated);
FO_MENU_ADMIN_MODES.options[7].value = SERVER_ADMIN.captainmode?"on":"off";
FO_MENU_ADMIN_MODES.options[6].value = modeStatus(SERVER_ADMIN.new_balance);
}
};
var fo_menu FO_MENU_ADMIN_SETTINGS = {
[0,0], [300,300], "Settings [3/3]", FO_MENU_FLAG_USE_MOUSE | FO_MENU_FLAG_CENTER | FO_MENU_FLAG_SHOW_SHORTCUTS | FO_MENU_FLAG_SHOW_VALUES | FO_MENU_FLAG_WARNING | FO_MENU_FLAG_ALLOW_INTERMISSION, {
{"1","Timelimit","","",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_Timelimit(TRUE);},MENU_BORDER_WARNING},
{"2","Fraglimit","","",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_Fraglimit(TRUE);},MENU_BORDER_WARNING},
{"3","Quad Rounds...","","Number of rounds in Quad mode. Usually 2",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_Rounds(TRUE);},MENU_BORDER_WARNING},
{"4","Quad Round Time...","","Round time for each quad round",FO_MENU_STATE_NORMAL,{FO_Menu_Admin_QuadTimelimit(TRUE);},MENU_BORDER_WARNING},
MenuSpacer,
MenuSpacer,
MenuSpacer,
Expand All @@ -476,6 +477,8 @@ var fo_menu FO_MENU_ADMIN_SETTINGS = {
updateAdminMenuInfo();
FO_MENU_ADMIN_SETTINGS.options[0].value = ftos(SERVER_ADMIN.timelimit);
FO_MENU_ADMIN_SETTINGS.options[1].value = ftos(SERVER_ADMIN.fraglimit);
FO_MENU_ADMIN_SETTINGS.options[2].value = ftos(SERVER_ADMIN.quad_rounds);
FO_MENU_ADMIN_SETTINGS.options[3].value = ftos(SERVER_ADMIN.quad_round_time);
}
};
var void execute_admin_players(float choice, float page) {
Expand Down
17 changes: 17 additions & 0 deletions csqc/pmove.qc
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ static void PM_NudgeExplosion(PM_Nudge* nudge, entity ent) {
if (vlen(ent.origin - nudge->org) > dmg + 40)
return;

const float MOVE_WORLDONLY = 3;
traceline(ent.origin, nudge->org, MOVE_WORLDONLY, pm.ent);
if (trace_fraction < 1) // No knock from occluded explosions
return;

float flg = KF_BOTH_PLAYER; // Assumes everything is from a player for now
if (nudge->src.owner == pengine.player_ent)
flg |= KF_SELF;
Expand Down Expand Up @@ -465,6 +470,9 @@ static void PM_NudgeBounce(PM_Nudge* nudge, entity ent) {
float points = dmg - vlen(targ_org - nudge->org) / 2;

ent.velocity = (targ_org - nudge->org) * points/20;

NB_ConcCapAction(ent, pstate_pred.playerclass, &pstate_pred.tfstate,
pm.interp_t, &pstate_pred.conc_cap_time, kLaunch);
}


Expand Down Expand Up @@ -625,6 +633,12 @@ static void PM_RunMovement(PMS_Data* pmsd, float endframe) {

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

if ((ent.pmove_flags & PMF_JUMP_HELD) && (pstate_pred.tfstate & TFSTATE_CONC_CAP)) {
NB_ConcCapAction(ent, pstate_pred.playerclass, &pstate_pred.tfstate,
pm.interp_t, &pstate_pred.conc_cap_time,
kLand);
}
}

pm.seq++;
Expand Down Expand Up @@ -803,6 +817,9 @@ void PM_Update(float sendflags) {
float enabled = (pstate_server.predict_flags & PF_PMOVE) &&
game_state.is_player;

if (isdemo())
enabled = 0;

if (enabled != was_enabled ||
game_state.is_player != prev_game_state.is_player)
PM_SetEnabled(enabled);
Expand Down
6 changes: 3 additions & 3 deletions csqc/status.qc
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ string gameClockString() {
if (!end)
end = timelimit * 60;

if (end) {
minutes = (end - time)/60;
seconds = (end - time)%60;
if (end && end > servertime) {
minutes = (end - servertime)/60;
seconds = (end - servertime)%60;
} else {
minutes = time/60;
seconds = time%60;
Expand Down
52 changes: 38 additions & 14 deletions csqc/weapon_predict.qc
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ void WPP_Status() {
PRINT_CONFIG(max_rewind_fast_projectile_ms);
PRINT_CONFIG(max_rewind_grenade_ms);
PRINT_CONFIG(rewind_fast_projectile_thresh);
PRINT_CONFIG(new_balance);
printf("\n");

PrintFlagField("Rewind Settings [rewind_flags=%d]\n",
Expand All @@ -286,6 +287,9 @@ void WPP_Status() {
PrintFlagField("Clown mode [clown_flags=%d]\n",
fo_config.clown_flags, CLOWN_DESC.length, CLOWN_DESC);

PrintFlagField("NewBalance Flags [newbalance_flags=%d]:\n",
fo_config.new_balance_flags, NBF_DESC.length, NBF_DESC);

PrintFlagField("Concs [fo_concuss=%d]\n",
fo_config.fo_concuss, FO_CONC.length, FO_CONC);
}
Expand Down Expand Up @@ -1027,11 +1031,10 @@ void WP_Impulse() {
}

static float* WP_ClipFired(Slot slot) {
float index = SlotIndex(slot);
if (pstate_pred.playerclass == PC_DEMOMAN && index == 1)
index = 0; // Special case: Pipebomb shares with Grenadel launcher.
if (self_class() == PC_DEMOMAN && SlotIndex(slot) == 1)
slot = MakeSlot(1); // Special case: pipebomb shares with grenade launcher.

return &pstate_pred.clip_fired[index];
return self_clip_fired(slot);
}

float WP_CurrentClipFired() {
Expand Down Expand Up @@ -1115,6 +1118,22 @@ float WP_ReloadSlot(Slot slot) {
return TRUE;
}

void WP_CheckSpecialReady() {
if (!IsEffectFrame())
return;

if (pstate_pred.special_next > pstate_pred.server_time ||
pstate_pred.special_next < pstate_pred.server_time - input_timelength)
return;

switch (pstate_pred.playerclass) {
case PC_ENGINEER:
if (NewBalanceActive())
printf("Impeller ready\n");
break;
}
}

void WP_CheckReloadFinished() {
if (WP_IsReloading() && pstate_pred.reload_finished && pstate_pred.client_time >= pstate_pred.reload_finished) {
pstate_pred.tfstate &= ~TFSTATE_RELOADING;
Expand Down Expand Up @@ -1707,6 +1726,13 @@ void FO_FireAssCanPellet(vector org, vector dir, float proj_speed, int index) {
proj.fpp.ammo_index = WP_GetAmmo(AMMO_SHELLS) * 100 + index;
}

float NB_ImpellerCoolDown(FO_WeapInfo* wi) {
if (!NewBalanceActive() || wi->weapon != WEAP_IMPELLER)
return FALSE;

return pstate_pred.server_time < pstate_pred.special_next;
}

void WP_Attack() {
if (getstatf(STAT_NOFIRE))
return;
Expand All @@ -1719,21 +1745,24 @@ void WP_Attack() {
if (!WP_CheckAmmo(wi))
return;

if (NB_ImpellerCoolDown(wi))
return;

// Whether firing occurs here, or is embedded in the frame animation code
// (because continuous fire).
int in_anim = wi->weapon == WEAP_NAILGUN ||
wi->weapon == WEAP_SUPER_NAILGUN ||
wi->weapon == WEAP_ASSAULT_CANNON;

if (!in_anim && !WP_ConsumeAmmo(CurrentSlot()))
if (!wi->fire_in_anim && !WP_ConsumeAmmo(CurrentSlot()))
return;

// OK. We're ready to pew.

// Must be set prior to animation code, which might internally modify.
pstate_pred.client_thinkindex = 1;

if (IsEffectFrame() && !in_anim && (time > filter_pproj_time)) {
if (IsEffectFrame() && !wi->fire_in_anim && (time > filter_pproj_time)) {
float send_event = FALSE;
switch (wi->weapon) {
case WEAP_ROCKET_LAUNCHER:
Expand All @@ -1744,19 +1773,13 @@ void WP_Attack() {
PP_CreateProjectile(FPP_INCENDIARY, PM_Org() + v_forward * 8 + '0 0 16');
send_event = TRUE;
break;
case WEAP_FLAMETHROWER:
PP_CreateProjectile(FPP_FLAMETHROWER, PM_Org() + v_forward * 16 + '0 0 16');
break;
case WEAP_TRANQ:
PP_CreateProjectile(FPP_TRANQ, PM_Org() + v_forward * 8 + '0 0 16');
break;
case WEAP_RAILGUN:
PP_CreateProjectile(FPP_RAILGUN, PM_Org() + '0 0 16');
break;

case WEAP_ASSAULT_CANNON:
break;

case WEAP_GRENADE_LAUNCHER:
send_event = TRUE;
case WEAP_PIPE_LAUNCHER:
Expand Down Expand Up @@ -1790,7 +1813,7 @@ void WP_Attack() {
}
}

if (!in_anim)
if (!wi->fire_in_anim)
Attack_Finished(wi->attack_time);

// Start the AC state machine when necessary.
Expand Down Expand Up @@ -1974,7 +1997,8 @@ void WP_UpdateViewModel() {
alph = CVARF(fo_reloadalpha);
} else {
alph = CVARF(r_drawviewmodel);
if (!WP_WeaponReady() && CVARF(fo_nofirealpha) != -1)
float ready = WP_WeaponReady() && !NB_ImpellerCoolDown(wi);
if (!ready && CVARF(fo_nofirealpha) != -1)
alph = CVARF(fo_nofirealpha);
}

Expand Down
8 changes: 7 additions & 1 deletion share/animate.qc
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ static inline float FO_CheckForReload() { return WP_ReloadCurrentIfNeeded(); }
void W_FireSpikes(float ox);
// Shared by both client and server side.
void nail_extra_csqc_ssqc() {
if (!is_attacking() || is_intermission()) {
if (!is_attacking() || is_intermission() || !IsSlotNull(self_queue_slot())) {
player_run();
return;
}

FO_WeapInfo* wi = FO_GetWeapInfo(FO_CurrentWeapon());
if (wi->needs_reload && FO_CheckForReload()) {
player_run();
return;
}
Expand Down
47 changes: 47 additions & 0 deletions share/classes.qc
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,50 @@ float Class_ScaleMoment(float playerclass, float damage) {
return damage;
return damage <= 50 ? 0 : damage / 4;
}

enum {
kLaunch,
kLand
};

float NB_UseNewConc() {
return fo_config.new_balance_flags & NBF_CONC_NEW_CAP;
}

float NB_NoCap() {
return fo_config.new_balance_flags & NBF_NO_CAP;
}


void NB_ConcCap(entity ent, float speed) {
vector planar_vel = [ent.velocity_x, ent.velocity_y, 0];

if (vlen(planar_vel) > speed) {
planar_vel = normalize(planar_vel) * speed;
}

ent.velocity_x = planar_vel.x;
ent.velocity_y = planar_vel.y;
}

void NB_ConcCapAction(entity ent, float player_class, float* tfstate,
float gtime, float* cap_time, float action) {
if (!NewBalanceActive() || !NB_UseNewConc())
return;

const float kLockout = 0.5;

if (action == kLaunch) {
if (player_class == PC_MEDIC && !NB_NoCap()) {
*tfstate |= TFSTATE_CONC_CAP;
*cap_time = gtime + kLockout;
}

NB_ConcCap(ent, NB_CONC_CAP_AIR);
} else if (action == kLand && (*tfstate & TFSTATE_CONC_CAP) &&
gtime > *cap_time) {
float cap = *cap_time;
*tfstate &= ~TFSTATE_CONC_CAP;
NB_ConcCap(ent, NB_CONC_CAP_LAND);
}
}
Loading

0 comments on commit 1ae6cf5

Please sign in to comment.