diff --git a/csqc/hud_helpers.qc b/csqc/hud_helpers.qc index 16345ca8..7f7afc23 100644 --- a/csqc/hud_helpers.qc +++ b/csqc/hud_helpers.qc @@ -113,6 +113,26 @@ float(PanelID id, vector pos, vector size, float alpha, float enabled) hud_panel return sui_is_clicked(id); }; +static string lmp_lookup(float c, float use_red) { + string lmp = ""; + switch (c) { + case ' ': return ""; + case '*': return "use_red"; // Caller must handle + case '-': lmp = "num_minus"; break; + case '/': lmp = "num_slash"; break; + case ':': lmp = "num_colon"; break; + default: { + if (c >= '0' && c <= '9') + lmp = sprintf("num_%g", c-'0'); + else + return "sb_quad"; // Unrecognized. + } + } + if (use_red) + lmp = strcat("a", lmp); + return lmp; +} + // this draws backwards, haven't bothered to change as we don't use it void Hud_DrawLargeValue(vector pos, float value, float threshhold, float size) { @@ -143,81 +163,47 @@ void Hud_DrawLargeValue(vector pos, float value, float threshhold, float size) void Hud_DrawStringLMP(vector pos, string value, float size) { - float c; - float len, i; + float len, i, j; string s; if (!size) size = 24; vector vsize = [size, size, 0]; s = value; len = strlen(s); - i = 0; + float use_red = FALSE; - while(i= 0; i--) { @@ -52,6 +52,28 @@ float RemoveFromSlotHistory(float slot) { } +static void BindAlias(TFAlias* tfa) { + if (tfa->impulse == 0 && tfa->cmd == "") // Some aliases are !csqc-only + return; + + if (tfa->impulse) + localcmd(sprintf("alias %s impulse %d\n", tfa->alias, tfa->impulse)); + else + localcmd(strcat("alias ", tfa->alias, " \"", tfa->cmd, "\"\n")); +} + +static void SetupAliases() { + float i; + + for (i = 0; i < client_aliases.length; i++) + BindAlias(&client_aliases[i]); + + for (i = 0; i < csqc_aliases.length; i++) + BindAlias(&csqc_aliases[i]); + + print("Aliases set\n"); +} + DECLARE_PERF_SAMPLER(frame_timing, 60, 0.1); DECLARE_PERF_SAMPLER(hud_timing, 60, 0.1); DECLARE_PERF_SAMPLER(hud_partial_timing, 60, 0.1); @@ -106,27 +128,11 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = { registercommand("+aux_jump"); registercommand("-aux_jump"); - registercommand("+special"); - registercommand("-special"); - registercommand("+special2"); - registercommand("-special2"); - registercommand("+grenade1"); - registercommand("-grenade1"); - registercommand("+grenade2"); - registercommand("-grenade2"); - registercommand("+dropflag"); - registercommand("-dropflag"); registercommand("+rj"); registercommand("-rj"); - // registercommand("+quick1"); - // registercommand("-quick1"); - // registercommand("+quick2"); - // registercommand("-quick2"); - // registercommand("+quick3"); - // registercommand("-quick3"); - // registercommand("+quick4"); - // registercommand("-quick4"); - registercommand("tracktarget"); + + registercommand("slot_a"); + registercommand("+fo_showscores"); registercommand("-fo_showscores"); registercommand("fo_settings_check"); @@ -159,12 +165,17 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = { vote_list_filter = ""; TF_Init(); + + ClientSettings_Check(); + SetupAliases(); + print("CSQC initialization finished\n"); }; noref void() CSQC_WorldLoaded = { - print("CSQC World Loaded\n"); - ClientSettings_Check(); localcmd("menu_restart\n"); + // Resolve race condition where models packed into map package sometimes do + // not resolve correctly. + localcmd("flush\n"); } void FO_CussView(); @@ -214,6 +225,7 @@ void Slot_Keydown(float slot) { void Slot_Keyup(float slot) { RemoveFromSlotHistory(slot); + if (slot_history_top >= 0) { // still holding another +slot bind localcmd(sprintf("impulse %f\n", slot_history[slot_history_top])); } else { @@ -224,6 +236,8 @@ void Slot_Keyup(float slot) { } } +void W_ChangeToSlotAlternate(string opt1, string opt2); + noref float(string cmd) CSQC_ConsoleCommand = { tokenize_console(cmd); float val; @@ -378,9 +392,6 @@ noref float(string cmd) CSQC_ConsoleCommand = { FO_Show_Scores(FALSE); } break; - case "tracktarget": - localcmd("cmd tracktarget\n"); - break; case "+aux_jump": jump_counter++; localcmd("+jump\n"); @@ -397,60 +408,6 @@ noref float(string cmd) CSQC_ConsoleCommand = { } break; - case "+special": - localcmd("+button3\n"); - break; - case "-special": - localcmd("-button3\n"); - break; - case "+special2": - localcmd("+button4\n"); - break; - case "-special2": - localcmd("-button4\n"); - break; - case "+grenade1": - localcmd("+button5\n"); - break; - case "-grenade1": - localcmd("-button5\n"); - break; - case "+grenade2": - localcmd("+button6\n"); - break; - case "-grenade2": - localcmd("-button6\n"); - break; - case "+dropflag": - localcmd("+button7\n"); - break; - case "-dropflag": - localcmd("-button7\n"); - break; - // case "+quick1": - // localcmd("+button8\n"); - // break; - // case "-quick1": - // localcmd("-button8\n"); - // break; - // case "+quick2": - // localcmd("+button9\n"); - // break; - // case "-quick2": - // localcmd("-button9\n"); - // break; - // case "+quick3": - // localcmd("+button10\n"); - // break; - // case "-quick3": - // localcmd("-button10\n"); - // break; - // case "+quick4": - // localcmd("+button11\n"); - // break; - // case "-quick4": - // localcmd("-button11\n"); - // break; case "+rj": if (player_class == PC_SOLDIER || player_class == PC_PYRO) { localcmd("+button4\n"); @@ -473,6 +430,9 @@ noref float(string cmd) CSQC_ConsoleCommand = { case "vote_removemap": RemoveVoteMap(argv(1), TRUE); break; + case "slot_a": // Alternate between passed options + W_ChangeToSlotAlternate(argv(1), argv(2)); + break; } return FALSE; @@ -565,20 +525,20 @@ static vector FO_Conc_Offset() { } float amp = Blend(table[i+1].amp_end, cur->amp_end, rem, cur->duration); - amp *= pstate_pred.conc_amp; float a = (cur->duration - rem) / cur->duration * cur->cycles * 2 * M_PI; a += cur->offset * 2 * M_PI; - return [amp * sin(a), amp * sin(a) * cos(a), 0]; + return [sin(a), sin(a) * cos(a), amp * pstate_pred.conc_amp]; } static void FO_UpdateConcAim() { makevectors(input_angles); vector o = FO_Conc_Offset(); - cuss_state.c_forward = normalize(v_forward * 200 + o.x * v_right + o.y * v_up); + cuss_state.c_forward = normalize(v_forward * 200 + o.x * o.z * v_right + o.y * o.z * v_up); - cuss_state.c_view = vectoangles(v_forward * 200 + o.x/4 * v_right + o.y/4 * v_up); + vector vv = o * min(o.z / 4, 20); + cuss_state.c_view = vectoangles(v_forward * 200 + vv.x * v_right + vv.y * v_up); cuss_state.c_view[0] *= -1; } @@ -809,7 +769,7 @@ void Perf_Status() { } void ClientSettings_Check() { - localcmd("cl_movespeedkey 1"); + localcmd("cl_movespeedkey 1\n"); if (cvar("worker_count") == 0) printf("ERROR: Please set `worker_count 4` to reduce stuttering!\n"); if (cvar("r_temporalscenecache") == 0) diff --git a/csqc/status.qc b/csqc/status.qc index 06c3bf5f..16e09dd0 100644 --- a/csqc/status.qc +++ b/csqc/status.qc @@ -8,9 +8,12 @@ FO_Hud_Panel* getHudPanel(PanelID); void FO_Hud_HidePanel(PanelID id); void FO_Hud_ShowPanel(PanelID id); +DEFCVAR_FLOAT(fo_hud_noclipicon, 0); + void(PanelID ignored, string text) drawClipSize = { + string icon = CVARF(fo_hud_noclipicon) ? "" : ICON_CLIPSIZE; if (is_alive || fo_hud_editor) - Hud_DrawPanelLMP(getHudPanel(HUDP_CLIPSIZE), text, ICON_CLIPSIZE, 1); + Hud_DrawPanelLMP(getHudPanel(HUDP_CLIPSIZE), text, icon, 1); }; void(PanelID ignored, string text) drawIdentify = { @@ -618,42 +621,31 @@ void(PanelID panelid, string text) drawReadyPanel = { } } -float (float val) AbbreviateNumber = { - val = val / 1000; - val = rint(val); - return val; -}; - string (float val) AbbreviateNumberToString = { - string abbr = ""; + val = rint(val); + if (val < 10000) + return ftos(rint(val)); - int count = 0; - while (val >= 1000) - { - val = AbbreviateNumber(val); + float count = 0; + while (val >= 1000) { + val /= 1000; count++; } - switch (count) - { - case 1: - abbr = "k"; - break; - case 2: - abbr = "m"; - break; - case 3: - abbr = "b"; - break; - } - - string s = strcat(ftos(val), abbr); - return s; + // Try to (with max density) use up to 4 characters. + const string abbr = "kmb"; + if (count == 0) + return ftos(val); + else if (val < 100) + return sprintf("%0.1f%c", val, abbr[min(count - 1, 2)]); + else + return sprintf("%d%c", val, abbr[min(count - 1, 2)]); }; void (vector position, vector size, string val, vector textcolour, float alpha , float flags, string colname) drawShowScoresColumnVal = { - val = strpad(strlen(colname) * -1, val); + if (strlen(val) < strlen(colname)) + val = strpad(strlen(colname) * -1, val); sui_text(position, size, val, textcolour, 1, 0); }; diff --git a/csqc/weapon_predict.qc b/csqc/weapon_predict.qc index c7db61e6..1cec49c7 100644 --- a/csqc/weapon_predict.qc +++ b/csqc/weapon_predict.qc @@ -631,7 +631,7 @@ float WP_CheckAmmo(FO_WeapInfo* wi) { return FALSE; int ammo = WP_GetAmmo(wi->ammo_type); - return ammo > wi->ammo_per_shot; + return ammo >= wi->ammo_per_shot; } void WP_ChangeWeapon(Slot slot) { @@ -644,6 +644,23 @@ void WP_ChangeWeapon(Slot slot) { // UpdateViewModel will propagate. } +// Alternate between opt1/opt2, activating opt1 if neither is active. +// Useful for demoman to have red/yellows bound to 1 key. +void W_ChangeToSlotAlternate(string opt1, string opt2) { + float v1 = strlen(opt1) > 0 ? stof(opt1) : 0; + float v2 = strlen(opt2) > 0 ? stof(opt2) : v1; + + if ((v1 < 1 || v1 > TF_NUM_SLOTS) || (v2 < 1 || v2 > TF_NUM_SLOTS)) + return; + + // The OWI/slot mess rears its head again here. We convert to a slot for + // comparison but use the naked input value which will then be converted per + // OWI if active. + Slot slot = FO_SlotByInput(pstate_pred.playerclass, v1); + float imp = IsSameSlot(pstate_pred.current_slot, slot) ? v2 : v1; + localcmd(sprintf("impulse %d\n", imp)); +} + Slot WP_BestWeaponSlot() { for (float i = 1; i <= TF_NUM_SLOTS; i++) { Slot slot = MakeSlot(i); @@ -899,7 +916,15 @@ string WP_GetClip() { pstate_pred.reload_finished); float clip = capacity - fired - still_loading; - return sprintf("%d/%d", clip, wi->clip_size); + float rem = WP_GetAmmo(wi->ammo_type); + + // It's possible for the amount in clip to exceed remaining ammo (this + // occurs because we load before we drop for example). Render a clipped + // clip when this occurs, with a visual indicator. + if (clip > rem) + return sprintf("*%d*/%d", rem, wi->clip_size); + else + return sprintf("%d/%d", clip, wi->clip_size); } float WP_CanReload(Slot slot, string* msg = __NULL__) { @@ -988,6 +1013,14 @@ float WP_ConsumeAmmo(Slot slot) { return TRUE; } +float W_ConsumeAmmoIfPossible(float ammo_type, float amount) { + if (WP_GetAmmo(ammo_type) < amount) + return FALSE; + + pstate_pred.ammo_used[ammo_type] += amount; + return TRUE; +} + var void() melee_anim = player_axeN; void WP_AnimateModel() { @@ -1518,8 +1551,12 @@ void WP_Attack() { // Start the AC state machine when necessary. if (wi->weapon == WEAP_ASSAULT_CANNON && - (pstate_pred.tfstate & TFSTATE_AC_MASK) == 0) - pstate_pred.tfstate |= TFSTATE_AC_SPINUP; + (pstate_pred.tfstate & TFSTATE_AC_MASK) == 0) { + if (W_ConsumeAmmoIfPossible(AMMO_CELLS, PC_HVYWEAP_CELL_FIRE)) + pstate_pred.tfstate |= TFSTATE_AC_SPINUP; + else + pstate_pred.client_thinkindex = 0; // Just kidding, no cells. + } #if 0 // If our latency is higher than forward projection, synchronize animation // with when it will actually start/finish. The projectile internally diff --git a/share/animate.qc b/share/animate.qc index ab40bbe5..6d0db327 100644 --- a/share/animate.qc +++ b/share/animate.qc @@ -154,7 +154,7 @@ static inline float is_attacking() { return input_buttons & BUTTON0; } static inline float is_intermission() { return intermission; } static void SuperDamageSound() {} // TODO static inline vector get_velocity() { return pmove_vel; } -static inline void set_weapon_frame(int f) { self.frame = f; } +static inline void set_weapon_frame(float f) { pstate_pred.weaponframe = f; } static inline void muzzleflash() {} float WP_CurrentClipFired(); static inline float get_clip_fired() { return WP_CurrentClipFired(); } diff --git a/share/defs.h b/share/defs.h index 51d1b1b8..d2d45042 100644 --- a/share/defs.h +++ b/share/defs.h @@ -509,7 +509,7 @@ struct Slot { int id; }; #define TF_SHOWTF 107 // Displays server settings and mod version #define TF_SHOWLEGALCLASSES 108 // Show what classes are allowed by current map #define TF_SHOW_IDS 109 // Show ids of connected players -#define TF_ALIAS_CHECK 110 // Check if client has gotten all the aliases +// unused 110 #define TF_CHANGECLASS 111 // Bring up class selection menu #define TF_CHANGEPC_SCOUT 112 // Change class to Scout #define TF_CHANGEPC_SNIPER 113 // Change class to Sniper @@ -1065,6 +1065,7 @@ enumflags { #define PC_HVYWEAP_GRENADE_MAX_1 4 #define PC_HVYWEAP_GRENADE_MAX_2 1 #define PC_HVYWEAP_TF_ITEMS 0 +#define PC_HVYWEAP_CELL_FIRE 7 // Class Details for PYRO @@ -1536,3 +1537,171 @@ enumflags { #define FO_QUAD_STARTED_REQUEST 2 #define FO_QUAD_FINISHED_REQUEST 3 #define FO_LOGIN_REQUEST 4 + +struct TFAlias { + string alias; + float impulse; + string cmd; + float nocsqc_impulse; + string nocsqc_cmd; +}; + +TFAlias client_aliases[] = { + {"slot1", TF_IMPULSE_SLOT1}, + {"slot2", TF_IMPULSE_SLOT2}, + {"slot3", TF_IMPULSE_SLOT3}, + {"slot4", TF_IMPULSE_SLOT4}, + {"+slot1", 0, "impulse 20;+attack"}, + {"-slot1", 0, "-attack;impulse 24"}, + {"+slot2", 0, "impulse 21;+attack"}, + {"-slot2", 0, "-attack;impulse 24"}, + {"+slot3", 0, "impulse 22;+attack"}, + {"-slot3", 0, "-attack;impulse 24"}, + {"+slot4", 0, "impulse 23;+attack"}, + {"-slot4", 0, "-attack;impulse 24"}, + {"+quick1", 0, "impulse 1;+attack"}, + {"-quick1", 0, "-attack"}, + {"+quick2", 0, "impulse 2;+attack"}, + {"-quick2", 0, "-attack"}, + {"+quick3", 0, "impulse 3;+attack"}, + {"-quick3", 0, "-attack"}, + {"+quick4", 0, "impulse 4;+attack"}, + {"-quick4", 0, "-attack"}, + {"menu", 0, "fo_menu_special", 0, "cmd menu"}, + {"changeteam", 0, "fo_menu_team", TF_CHANGETEAM}, + {"teamblue", 0, "cmd changeteam 1", TF_TEAM_1}, + {"teamred", 0, "cmd changeteam 2", TF_TEAM_2}, + {"teamyellow", 0, "cmd changeteam 3", TF_TEAM_3}, + {"teamgreen", 0, "cmd changeteam 4", TF_TEAM_4}, + {"changeclass", 0, "fo_menu_class", TF_CHANGECLASS}, + {"scout", 0, "cmd changeclass 1", TF_CHANGEPC_SCOUT}, + {"sniper", 0, "cmd changeclass 2", TF_CHANGEPC_SNIPER}, + {"soldier", 0, "cmd changeclass 3", TF_CHANGEPC_SOLDIER}, + {"demoman", 0, "cmd changeclass 4", TF_CHANGEPC_DEMOMAN}, + {"medic", 0, "cmd changeclass 5", TF_CHANGEPC_MEDIC}, + {"hwguy", 0, "cmd changeclass 6", TF_CHANGEPC_HVYWEAP}, + {"pyro", 0, "cmd changeclass 7", TF_CHANGEPC_PYRO}, + {"spy", 0, "cmd changeclass 8", TF_CHANGEPC_SPY}, + {"engineer", 0, "cmd changeclass 9", TF_CHANGEPC_ENGINEER}, + {"randompc", 0, "cmd changeclass 10", TF_CHANGEPC_RANDOM}, + {"showclasses", TF_TEAM_CLASSES}, + {"legalclasses", TF_SHOWLEGALCLASSES}, + {"classhelp", TF_CLASSHELP}, + {"query", TF_STATUS_QUERY}, + {"inv", TF_INVENTORY}, + {"showtf", TF_SHOWTF}, + {"showscores", TF_TEAM_SCORES}, + {"flaginfo", FLAG_INFO}, + {"maphelp", TF_HELP_MAP}, + {"showids", TF_SHOW_IDS}, + {"id", TF_ID}, + {"idteam", TF_ID_TEAM}, + {"idenemy", TF_ID_ENEMY}, + {"nexttip", TF_NEXTTIP}, + {"votenext", TF_VOTENEXT}, + {"votetrick", TF_VOTETRICK}, + {"voterace", TF_VOTERACE}, + {"forcenext", TF_FORCENEXT}, + {"togglevote", TF_TOGGLEVOTE}, + {"dropkey", TF_DROPKEY}, + {"dropammo", 0, "fo_menu_dropammo", TF_DROP_AMMO}, + {"dropflag", TF_DROPFLAG}, + {"dropitems", TF_DROPFLAG}, + {"showloc", TF_DISPLAYLOCATION}, + {"special", TF_SPECIAL_SKILL}, + {"special2", TF_SPECIAL_SKILL_2}, + {"saveme", TF_MEDIC_HELPME}, + {"discard", TF_DISCARD}, + {"discard_drop_ammo", TF_DISCARD_DROP_AMMO}, + {"weapnext", TF_WEAPNEXT}, + {"weapprev", TF_WEAPPREV}, + {"weaplast", TF_WEAPLAST}, + {"reload", TF_RELOAD}, + {"reload1", TF_RELOAD_SLOT1}, + {"reload2", TF_RELOAD_SLOT2}, + {"reload3", TF_RELOAD_SLOT3}, + {"reloadnext", TF_RELOAD_NEXT}, + {"grenswitch", TF_GRENADE_SWITCH}, + {"throwgren", TF_GRENADE_T}, + {"primeone", TF_GRENADE_1}, + {"primetwo", TF_GRENADE_2}, + {"+gren1", TF_GRENADE_1}, + {"-gren1", TF_GRENADE_T}, + {"+gren2", TF_GRENADE_2}, + {"-gren2", TF_GRENADE_T}, + {"gren1", TF_GRENADE_PT_1}, + {"gren2", TF_GRENADE_PT_2}, + {"dash", TF_DASH}, + {"autoscan", TF_SCAN}, + {"scansound", TF_SCAN_SOUND}, + {"scanf", TF_SCAN_FRIENDLY}, + {"scane", TF_SCAN_ENEMY}, + {"zoomtoggle", TF_ZOOMTOGGLE}, + {"zoomin", TF_ZOOMIN}, + {"zoomout", TF_ZOOMOUT}, + {"detpipe", TF_PB_DETONATE}, + {"+det5", TF_DETPACK_5}, + {"-det5", TF_DETPACK_STOP}, + {"+det20", TF_DETPACK_20}, + {"-det20", TF_DETPACK_STOP}, + {"+det50", TF_DETPACK_50}, + {"-det50", TF_DETPACK_STOP}, + {"+det255", TF_DETPACK}, + {"-det255", TF_DETPACK_STOP}, + {"aura", TF_MEDIC_AURA_TOGGLE}, + {"locktoggle", TF_HVYWEAP_LOCK_TOGGLE}, + {"lock", TF_LOCKON}, + {"unlock", TF_LOCKOFF}, + {"+lock", TF_LOCKON}, + {"-lock", TF_LOCKOFF}, + {"airblast", TF_AIRBLAST}, + {"disguise", 0, "fo_menu_disguise", TF_SPY_SPY}, + {"+feign", TF_SPY_DIE_ON}, + {"-feign", TF_SPY_DIE_OFF}, + {"feign", TF_SPY_DIE}, + {"sfeign", TF_SPY_SILENT_DIE}, + {"dreset", TF_DISGUISE_RESET}, + {"dscout", TF_DISGUISE_SCOUT}, + {"dsniper", TF_DISGUISE_SNIPER}, + {"dsoldier", TF_DISGUISE_SOLDIER}, + {"ddemoman", TF_DISGUISE_DEMOMAN}, + {"dmedic", TF_DISGUISE_MEDIC}, + {"dhwguy", TF_DISGUISE_HWGUY}, + {"dpyro", TF_DISGUISE_PYRO}, + {"dengineer", TF_DISGUISE_ENGINEER}, + {"dblue", TF_DISGUISE_BLUE}, + {"dred", TF_DISGUISE_RED}, + {"dyellow", TF_DISGUISE_YELLOW}, + {"dgreen", TF_DISGUISE_GREEN}, + {"denemy", TF_DISGUISE_ENEMY}, + {"dlast", TF_DISGUISE_LAST}, + {"dlastspawn", TF_DISGUISE_LAST_SPAWNED}, + {"build", 0, "fo_menu_build", TF_ENGINEER_BUILD}, + {"detsentry", TF_ENGINEER_DETSENTRY}, + {"detdispenser", TF_ENGINEER_DETDISP}, + {"toggledispenser", TF_ENGINEER_TOGGLEDISPENSER}, + {"togglesentry", TF_ENGINEER_TOGGLESENTRY}, + {"ready", TF_PLAYER_READY}, + {"notready", TF_PLAYER_NOT_READY}, + {"nginfo", TF_NAILGREN_INFO}, + {"break", 0, "cmd break"}, + {"voteyes", 0, "cmd voteyes"}, + {"yes", 0, "cmd voteyes"}, + {"fo_settings_status", 0, "cmd fo_settings_status"}, + {"placepracspawn", TF_PRACSPAWN_PLACE}, + {"removepracspawn", TF_PRACSPAWN_REMOVE}, + {"tracktarget", 0, "cmd tracktarget", 0, "cmd track target"}, +}; + +TFAlias csqc_aliases[] = { + {"+special", 0, "+button3"}, + {"-special", 0, "-button3"}, + {"+special2", 0, "+button4"}, + {"-special2", 0, "-button4"}, + {"+grenade1", 0, "+button5"}, + {"-grenade1", 0, "-button5"}, + {"+grenade2", 0, "+button6"}, + {"-grenade2", 0, "-button6"}, + {"+dropflag", 0, "+button7"}, + {"-dropflag", 0, "-button7"}, +}; diff --git a/share/weapons.qc b/share/weapons.qc index e357900d..a0ed2d8b 100644 --- a/share/weapons.qc +++ b/share/weapons.qc @@ -34,7 +34,8 @@ float SlotIndex(Slot slot) { printf("ERROR: OOB slot id (%d) found. Continuing.\n", (float)slot.id); return TF_NUM_SLOTS - 1; } - return slot.id - 1; } + return slot.id - 1; +} // Convert a weapon-bit to a linear index. static float WEAP_to_index(float weapon) { @@ -335,19 +336,6 @@ static FO_WeapModels weapon_models[] = { // REQUIRES: Order must match above. static string AMMO_to_s[] = {"none", "shells", "nails", "cells", "rockets"}; -static float* AMMO_to_p(entity player, AmmoType ammo_type) { - switch (ammo_type) { - case AMMO_SHELLS: return &player.ammo_shells; - case AMMO_CELLS: return &player.ammo_cells; - case AMMO_NAILS: return &player.ammo_nails; - case AMMO_ROCKETS: return &player.ammo_rockets; - default: - case AMMO_NONE: - return __NULL__; - } - return __NULL__; -} - Slot WEAP_to_slot(float playerclass, float weapon) { for (float i = 0; i < TF_NUM_SLOTS; i++) { if (class_weapons[playerclass].slots[i] == weapon) @@ -466,6 +454,8 @@ struct FO_WeapState { }; +float* W_ammo_to_p(entity player, AmmoType ammo_type); + void FO_FillWeapState(entity player, Slot slot, FO_WeapState* result) { FO_WeapInfo* wi = FO_SlotWeapInfo(player.playerclass, slot); @@ -473,7 +463,7 @@ void FO_FillWeapState(entity player, Slot slot, FO_WeapState* result) { result->slot = slot; result->wi = wi; - result->ammo_remaining = AMMO_to_p(player, wi->ammo_type); + result->ammo_remaining = W_ammo_to_p(player, wi->ammo_type); if (!IsSlotNull(slot)) result->clip_fired = &player.clip_fired[SlotIndex(slot)]; diff --git a/ssqc/clan.qc b/ssqc/clan.qc index de247a11..d3448929 100644 --- a/ssqc/clan.qc +++ b/ssqc/clan.qc @@ -1095,7 +1095,7 @@ float () CheckAllPlayersReady = { void () PlayerReady = { if (fo_login_required && self.fo_login == string_null) { - sprint(self, PRINT_HIGH, "You need to log in to ready up. See fortressone.org\n"); + sprint(self, PRINT_HIGH, "You need to sign in first. Get your login token at www.fortressone.org\n"); return; } diff --git a/ssqc/client.qc b/ssqc/client.qc index ba8f15aa..f2fcb96d 100644 --- a/ssqc/client.qc +++ b/ssqc/client.qc @@ -526,7 +526,7 @@ void () DecodeLevelParms = { feign_msg = CF_GetSetting("fm", "feign_msg", "on"); // rate limit on feign - feign_rate_limit = CF_GetSetting("frl", "feign_rate_limit", "0"); + feign_rate_limit = CF_GetSetting("frl", "feign_rate_limit", "0.5"); // turn off spy [off] spy_off = CF_GetSetting("spy", "spy", "off"); @@ -608,12 +608,6 @@ void () DecodeLevelParms = { // CSQC projectiles fo_projectiles = CF_GetSetting("focp", "fo_csqc_projectiles", "on"); - // project projectile weapons by player ping - project_weapons = CF_GetSetting("pw", "project_weapons", "off"); - - // max projectile projection latency (default 100ms) - project_weapons_max_latency = CF_GetSetting("pwml", "project_weapons_max_latency", ftos(0.1)); - // delay respawning by this many seconds [0] Role_None.respawn_delay_time = CF_GetSetting("rd", "respawn_delay", "0"); if (Role_None.respawn_delay_time) { @@ -992,7 +986,6 @@ void () DecodeLevelParms = { detpipe_limit_world = 7; medicaura = FALSE; medicnocuss = FALSE; - project_weapons = FALSE; distance_based_cuss_duration = FALSE; drop_grenades = FALSE; drop_grenpack = FALSE; @@ -2121,6 +2114,8 @@ void () PutClientInServer = { TeamFortress_ChangeClass(11); } + int prev_playerclass = self.playerclass; + if (deathmatch == 3) { if(self.nextpc != self.playerclass) { if (self.playerclass != 0) { @@ -2302,6 +2297,11 @@ void () PutClientInServer = { self.tf_items_flags = self.tf_items_flags | NIT_SCANNER_ENEMY; } + // Activate medic aura by default when changing to class and off + if (self.playerclass == PC_MEDIC && prev_playerclass != PC_MEDIC && + !self.aura_active) + CF_Medic_AuraToggle(); + UpdateReadyStatus(); }; @@ -2944,6 +2944,8 @@ void FO_HandleTFStateUpdate() { self.last_tfstate = self.tfstate; } +void TeamFortress_MOTD(); + void () PlayerPostThink = { FO_CheckClientThink(); UpdateScoreboardInfo(self); @@ -3007,7 +3009,7 @@ void () PlayerPostThink = { FO_ReloadFrame(); ButtonFrame(); W_WeaponFrame(); - if (self.motd <= 400) { + if (self.motd >= 0) { TeamFortress_MOTD(); } else { if (self.cheat_check == 0) { @@ -3051,7 +3053,6 @@ void () ClientConnect = { bprint(PRINT_HIGH, self.netname, " entered the game\n"); self.motd = 0; - self.got_aliases = 0; if (self.netname == string_null) KickCheater(self); diff --git a/ssqc/commands.qc b/ssqc/commands.qc index 629de952..5e6f58e3 100644 --- a/ssqc/commands.qc +++ b/ssqc/commands.qc @@ -27,6 +27,11 @@ void () RestartMap = { } void () ForceStartMatch = { + if (fo_login_required) { + bprint(PRINT_HIGH, "Can't forcestart while logins enabled.\n"); + return; + } + if (clanbattle == 1 && cb_prematch == 1) { bprint(PRINT_HIGH, self.netname); bprint(PRINT_HIGH, " has forced the match start.\n"); diff --git a/ssqc/events.qc b/ssqc/events.qc index 404470ec..4090fec9 100644 --- a/ssqc/events.qc +++ b/ssqc/events.qc @@ -29,6 +29,8 @@ string () ISOTimemillis = { string (entity pl) getEntityNameOrLogin = { if (loginRequired) return pl.login; + else if (fo_login_required) + return pl.fo_login; else return clearString(pl.netname); } diff --git a/ssqc/hwguy.qc b/ssqc/hwguy.qc index ae6caade..daac67e2 100644 --- a/ssqc/hwguy.qc +++ b/ssqc/hwguy.qc @@ -98,3 +98,23 @@ void FO_LockToggle () { /* this shouldn't be here, I think we just need to allow this impulse while shooting */ /* worth checking detpipes for this too */ } + +float AssCanTryBeginFire() { + if (get_shells() < 1) + return FALSE; + + if (FO_CheckForReload()) + return FALSE; + + if (!W_ConsumeAmmoIfPossible(AMMO_CELLS, PC_HVYWEAP_CELL_FIRE)) { + // Not worth optimizing w/ client side. + if (time >= self.antispam_assault_cannon) { + sprint(self, PRINT_MEDIUM, "Not enough cells to power up the Assault Cannon\n"); + self.antispam_assault_cannon = time + 3; + } + return FALSE; + } + + player_asscan_up1(); + return TRUE; +} diff --git a/ssqc/quadmode.qc b/ssqc/quadmode.qc index f37fad3f..7112320a 100644 --- a/ssqc/quadmode.qc +++ b/ssqc/quadmode.qc @@ -1,6 +1,15 @@ void () info_player_teamspawn; void () PostFOQuadStarted = { + if (!fo_login_required) + return; + + if !(TeamFortress_TeamGetNoPlayersExcludingAllTime(1) == TeamFortress_TeamGetNoPlayersExcludingAllTime(2)) { + bprint(PRINT_HIGH, "Uneven teams, match can't be recorded\n"); + fo_login_required = FALSE; + return; + } + local string data = ""; data = strcat(data, "{\n"); @@ -76,6 +85,9 @@ void () PostFOQuadStarted = { }; void () PostFOQuadFinalRoundStarted = { + if (!fo_login_required) + return; + local string data = ""; data = strcat(data, "{\n"); @@ -133,6 +145,9 @@ void () PostFOQuadFinalRoundStarted = { }; void (float winner) PostFOQuadFinished = { + if (!fo_login_required) + return; + if (!match_id) return; diff --git a/ssqc/qw.qc b/ssqc/qw.qc index fed85c31..c8450756 100644 --- a/ssqc/qw.qc +++ b/ssqc/qw.qc @@ -49,7 +49,6 @@ float remote_client_time(); .float tp_grenades_2; // 2nd type of grenades being carried .float tp_grenade_switch; // Set to 1 if +gren1 and +gren2 switch places .float hook_out; // Dummy field for hook to silence error messages -.float got_aliases; // TRUE if the player has TeamFortress aliases .float cheat_check; // Time when we'll next check for team cheats .float is_removed; // TRUE if the entity has been removed .float is_undercover; // TRUE for a SPY if they're undercover @@ -600,9 +599,6 @@ float old_dispenser; float old_hp_armor; float max_armor_hwguy; -float project_weapons; -float project_weapons_max_latency; - float ng_damage; float sng_damage; float superaxe; diff --git a/ssqc/spect.qc b/ssqc/spect.qc index 2b045ce2..24367707 100644 --- a/ssqc/spect.qc +++ b/ssqc/spect.qc @@ -12,7 +12,6 @@ void () SpectatorDisconnect; void () SpectatorImpulseCommand; void () SpectatorThink; -void () Quick_Aliases; void () Admin_Aliases; void () SpectatorConnect = { @@ -29,8 +28,6 @@ void () SpectatorConnect = { if (infokey(self,"*admin")) self.is_admin = stof(infokey(self, "*admin")); - Quick_Aliases(); - st = infokey(self, "apw"); if (st == string_null) st = infokey(self, "adminpwd"); @@ -160,8 +157,6 @@ void () SpectatorThink = { if (self.impulse) SpectatorImpulseCommand(); - //if (self.motd <= 400) - // TeamFortress_MOTD(); if (time >= self.StatusRefreshTime) { RefreshStatusBar(self); } diff --git a/ssqc/tforthlp.qc b/ssqc/tforthlp.qc index a869d546..ab35927d 100644 --- a/ssqc/tforthlp.qc +++ b/ssqc/tforthlp.qc @@ -8,272 +8,66 @@ void (float inp) MOTD_Input = { Menu_Team_Input(inp); }; -void () Quick_Aliases = -{ - TeamFortress_AliasString("+quick1", "impulse 1;+attack"); - TeamFortress_AliasString("-quick1", "-attack"); - TeamFortress_AliasString("+quick2", "impulse 2;+attack"); - TeamFortress_AliasString("-quick2", "-attack"); - TeamFortress_AliasString("+quick3", "impulse 3;+attack"); - TeamFortress_AliasString("-quick3", "-attack"); - TeamFortress_AliasString("+quick4", "impulse 4;+attack"); - TeamFortress_AliasString("-quick4", "-attack"); -}; - -void () TeamFortress_MOTD = { - if (votemode) { +void TeamFortress_MOTD() { + if (votemode) return; - } - local float csqcactive = infokeyf(self, INFOKEY_P_CSQCACTIVE); - if (self.classname == "observer") { - if(!csqcactive) { - TeamFortress_AliasString("tracktarget", "cmd tracktarget"); - } + + if (loginRequired && !self.login) + Menu_Login(); + else + Menu_Team(0); + + float csqcactive = infokeyf(self, INFOKEY_P_CSQCACTIVE); + if (csqcactive) { + self.motd = -1; return; } + // Below is not really tested, it's an attempt at preserving for posterity. + // Expect potential bugs if we ever reintroduce !CSQC support. + const float ALIAS_OFFSET = 100; - local string st1; - local string st2; - local string ya; - - if (self.motd == 5) { - if(csqcactive) { - if(self.team_no == 0 && !intermission_running ) { - if (loginRequired && !self.login) - Menu_Login(); - else - Menu_Team(0); - } - } else { - sprint(self, PRINT_HIGH, "\nFortressOne ", VER, "\n\n"); + if (self.motd == 0) { + if ((teamplay != 0) && (self.team_no == 0)) + stuffcmd(self, "color 0\n"); - st1 = infokey(world, "motd1"); - if (st1 != string_null) { - st2 = infokey(world, "motd2"); - if (st2 != string_null) { - st1 = strcat(strcat(st1, "\n"), st2); - } - } else { - st1 = "Welcome to FortressOne\n==================================\nwww.github.com/FortressOne"; - } + sprint(self, PRINT_HIGH, "\nFortressOne ", VER, "\n\n"); - sprint(self, PRINT_HIGH, st1); - sprint(self, PRINT_HIGH, "\n\n\n"); - if(self.team_no == 0 && !intermission_running) { - Status_Menu(self, MOTD_Input, st1); + string st1, st2; + st1 = infokey(world, "motd1"); + if (st1 != string_null) { + st2 = infokey(world, "motd2"); + if (st2 != string_null) { + st1 = strcat(strcat(st1, "\n"), st2); } - } - } - - if (self.motd == 20) { - if ((teamplay != 0) && (self.team_no == 0)) { - stuffcmd(self, "color "); - ya = ftos(0); - stuffcmd(self, ya); - stuffcmd(self, "\n"); + } else { + st1 = "Welcome to FortressOne\n==================================\nwww.github.com/FortressOne"; } - // will also skip motd - if (self.got_aliases == TRUE) { - self.motd = 400; - return; - } + sprint(self, PRINT_HIGH, strcat(st1, "\n\n\n")); + if(self.team_no == 0 && !intermission_running) + Status_Menu(self, MOTD_Input, st1); - if (csqcactive) { - TeamFortress_AliasString("menu", "fo_menu_special"); - } else { - TeamFortress_AliasString("menu", "cmd menu"); - } + self.motd = ALIAS_OFFSET; + } - TeamFortress_Alias("slot1", TF_IMPULSE_SLOT1, 0); - TeamFortress_Alias("slot2", TF_IMPULSE_SLOT2, 0); - TeamFortress_Alias("slot3", TF_IMPULSE_SLOT3, 0); - TeamFortress_Alias("slot4", TF_IMPULSE_SLOT4, 0); + float idx = self.motd - ALIAS_OFFSET; + if (idx >= 0 && idx < client_aliases.length) { + TFAlias* alias = &client_aliases[idx]; - TeamFortress_AliasString("+slot1", "impulse 20;+attack"); - TeamFortress_AliasString("-slot1", "-attack;impulse 24"); - TeamFortress_AliasString("+slot2", "impulse 21;+attack"); - TeamFortress_AliasString("-slot2", "-attack;impulse 24"); - TeamFortress_AliasString("+slot3", "impulse 22;+attack"); - TeamFortress_AliasString("-slot3", "-attack;impulse 24"); - TeamFortress_AliasString("+slot4", "impulse 23;+attack"); - TeamFortress_AliasString("-slot4", "-attack;impulse 24"); - } else if (self.motd == 30) { - if(csqcactive) { - TeamFortress_AliasString("changeteam", "fo_menu_team"); - TeamFortress_AliasString("teamblue", "cmd changeteam 1"); - TeamFortress_AliasString("teamred", "cmd changeteam 2"); - TeamFortress_AliasString("teamyellow", "cmd changeteam 3"); - TeamFortress_AliasString("teamgreen", "cmd changeteam 4"); - TeamFortress_AliasString("changeclass", "fo_menu_class"); - TeamFortress_AliasString("scout", "cmd changeclass 1"); - TeamFortress_AliasString("sniper", "cmd changeclass 2"); - TeamFortress_AliasString("soldier", "cmd changeclass 3"); - TeamFortress_AliasString("demoman", "cmd changeclass 4"); - TeamFortress_AliasString("medic", "cmd changeclass 5"); - TeamFortress_AliasString("hwguy", "cmd changeclass 6"); - TeamFortress_AliasString("pyro", "cmd changeclass 7"); - TeamFortress_AliasString("spy", "cmd changeclass 8"); - TeamFortress_AliasString("engineer", "cmd changeclass 9"); - TeamFortress_AliasString("randompc", "cmd changeclass 10"); - } else { - TeamFortress_Alias("changeteam", TF_CHANGETEAM, 0); - TeamFortress_Alias("teamblue", TF_TEAM_1, 0); - TeamFortress_Alias("teamred", TF_TEAM_2, 0); - TeamFortress_Alias("teamyellow", TF_TEAM_3, 0); - TeamFortress_Alias("teamgreen", TF_TEAM_4, 0); - TeamFortress_Alias("changeclass", TF_CHANGECLASS, 0); - TeamFortress_Alias("scout", TF_CHANGEPC_SCOUT, 0); - TeamFortress_Alias("sniper", TF_CHANGEPC_SNIPER, 0); - TeamFortress_Alias("soldier", TF_CHANGEPC_SOLDIER, 0); - TeamFortress_Alias("demoman", TF_CHANGEPC_DEMOMAN, 0); - TeamFortress_Alias("medic", TF_CHANGEPC_MEDIC, 0); - TeamFortress_Alias("hwguy", TF_CHANGEPC_HVYWEAP, 0); - TeamFortress_Alias("pyro", TF_CHANGEPC_PYRO, 0); - TeamFortress_Alias("spy", TF_CHANGEPC_SPY, 0); - TeamFortress_Alias("engineer", TF_CHANGEPC_ENGINEER, 0); - TeamFortress_Alias("randompc", TF_CHANGEPC_RANDOM, 0); - } - TeamFortress_Alias("showclasses", TF_TEAM_CLASSES, 0); - TeamFortress_Alias("legalclasses", TF_SHOWLEGALCLASSES, 0); - TeamFortress_Alias("classhelp", TF_CLASSHELP, 0); - } else if (self.motd == 40) { - TeamFortress_Alias("query", TF_STATUS_QUERY, 0); - TeamFortress_Alias("inv", TF_INVENTORY, 0); - TeamFortress_Alias("showtf", TF_SHOWTF, 0); - TeamFortress_Alias("showscores", TF_TEAM_SCORES, 0); - TeamFortress_Alias("flaginfo", FLAG_INFO, 0); - TeamFortress_Alias("maphelp", TF_HELP_MAP, 0); - TeamFortress_Alias("showids", TF_SHOW_IDS, 0); - TeamFortress_Alias("id", TF_ID, 0); - TeamFortress_Alias("idteam", TF_ID_TEAM, 0); - TeamFortress_Alias("idenemy", TF_ID_ENEMY, 0); - TeamFortress_Alias("is_aliased", TF_ALIAS_CHECK, 0); - } else if (self.motd == 50) { - TeamFortress_Alias("nexttip", TF_NEXTTIP, 0); - TeamFortress_Alias("votenext", TF_VOTENEXT, 0); - TeamFortress_Alias("votetrick", TF_VOTETRICK, 0); - TeamFortress_Alias("voterace", TF_VOTERACE, 0); - TeamFortress_Alias("forcenext", TF_FORCENEXT, 0); - TeamFortress_Alias("togglevote", TF_TOGGLEVOTE, 0); - TeamFortress_Alias("dropkey", TF_DROPKEY, 0); - if(csqcactive) { - TeamFortress_AliasString("dropammo", "fo_menu_dropammo"); - } else { - TeamFortress_Alias("dropammo", TF_DROP_AMMO, 0); - } - TeamFortress_Alias("dropflag", TF_DROPFLAG, 0); - TeamFortress_Alias("dropitems", TF_DROPFLAG, 0); - TeamFortress_Alias("showloc", TF_DISPLAYLOCATION, 0); - TeamFortress_Alias("special", TF_SPECIAL_SKILL, 0); - TeamFortress_Alias("special2", TF_SPECIAL_SKILL_2, 0); - TeamFortress_Alias("saveme", TF_MEDIC_HELPME, 0); - TeamFortress_Alias("discard", TF_DISCARD, 0); - TeamFortress_Alias("discard_drop_ammo", TF_DISCARD_DROP_AMMO, 0); - } else if (self.motd == 60) { - TeamFortress_Alias("weapnext", TF_WEAPNEXT, 0); - TeamFortress_Alias("weapprev", TF_WEAPPREV, 0); - TeamFortress_Alias("weaplast", TF_WEAPLAST, 0); - TeamFortress_Alias("reload", TF_RELOAD, 0); - TeamFortress_Alias("reload1", TF_RELOAD_SLOT1, 0); - TeamFortress_Alias("reload2", TF_RELOAD_SLOT2, 0); - TeamFortress_Alias("reload3", TF_RELOAD_SLOT3, 0); - TeamFortress_Alias("reloadnext", TF_RELOAD_NEXT, 0); - } else if (self.motd == 70) { - TeamFortress_Alias("grenswitch", TF_GRENADE_SWITCH, 0); - TeamFortress_Alias("-gren1", TF_GRENADE_T, 0); - TeamFortress_Alias("-gren2", TF_GRENADE_T, 0); - TeamFortress_Alias("throwgren", TF_GRENADE_T, 0); - TeamFortress_Alias("primeone", TF_GRENADE_1, 0); - TeamFortress_Alias("primetwo", TF_GRENADE_2, 0); - TeamFortress_Alias("+gren1", TF_GRENADE_1, 0); - TeamFortress_Alias("+gren2", TF_GRENADE_2, 0); - TeamFortress_Alias("gren1", TF_GRENADE_PT_1, 0); - TeamFortress_Alias("gren2", TF_GRENADE_PT_2, 0); - } else if (self.motd == 80) { - TeamFortress_Alias("dash", TF_DASH, 0); - TeamFortress_Alias("autoscan", TF_SCAN, 0); - TeamFortress_Alias("scansound", TF_SCAN_SOUND, 0); - TeamFortress_Alias("scanf", TF_SCAN_FRIENDLY, 0); - TeamFortress_Alias("scane", TF_SCAN_ENEMY, 0); - TeamFortress_Alias("zoomtoggle", TF_ZOOMTOGGLE, 0); - TeamFortress_Alias("zoomin", TF_ZOOMIN, 0); - TeamFortress_Alias("zoomout", TF_ZOOMOUT, 0); - } else if (self.motd == 90) { - TeamFortress_Alias("detpipe", TF_PB_DETONATE, 0); - TeamFortress_Alias("+det5", TF_DETPACK_5, 0); - TeamFortress_Alias("-det5", TF_DETPACK_STOP, 0); - TeamFortress_Alias("+det20", TF_DETPACK_20, 0); - TeamFortress_Alias("-det20", TF_DETPACK_STOP, 0); - TeamFortress_Alias("+det50", TF_DETPACK_50, 0); - TeamFortress_Alias("-det50", TF_DETPACK_STOP, 0); - TeamFortress_Alias("+det255", TF_DETPACK, 255); - TeamFortress_Alias("-det255", TF_DETPACK_STOP, 0); - } else if (self.motd == 100) { - TeamFortress_Alias("aura", TF_MEDIC_AURA_TOGGLE, 0); - TeamFortress_Alias("locktoggle", TF_HVYWEAP_LOCK_TOGGLE, 0); - TeamFortress_Alias("lock", TF_LOCKON, 0); - TeamFortress_Alias("unlock", TF_LOCKOFF, 0); - TeamFortress_Alias("+lock", TF_LOCKON, 0); - TeamFortress_Alias("-lock", TF_LOCKOFF, 0); - TeamFortress_Alias("airblast", TF_AIRBLAST, 0); - if(csqcactive) { - TeamFortress_AliasString("disguise", "fo_menu_disguise"); - } else { - TeamFortress_Alias("disguise", TF_SPY_SPY, 0); - } - TeamFortress_Alias("+feign", TF_SPY_DIE_ON, 0); - TeamFortress_Alias("-feign", TF_SPY_DIE_OFF, 0); - TeamFortress_Alias("feign", TF_SPY_DIE, 0); - TeamFortress_Alias("sfeign", TF_SPY_SILENT_DIE, 0); - } else if (self.motd == 110) { - TeamFortress_Alias("dreset", TF_DISGUISE_RESET, 0); - TeamFortress_Alias("dscout", TF_DISGUISE_SCOUT, 0); - TeamFortress_Alias("dsniper", TF_DISGUISE_SNIPER, 0); - TeamFortress_Alias("dsoldier", TF_DISGUISE_SOLDIER, 0); - TeamFortress_Alias("ddemoman", TF_DISGUISE_DEMOMAN, 0); - TeamFortress_Alias("dmedic", TF_DISGUISE_MEDIC, 0); - TeamFortress_Alias("dhwguy", TF_DISGUISE_HWGUY, 0); - TeamFortress_Alias("dpyro", TF_DISGUISE_PYRO, 0); - } else if (self.motd == 120) { - TeamFortress_Alias("dengineer", TF_DISGUISE_ENGINEER, 0); - TeamFortress_Alias("dblue", TF_DISGUISE_BLUE, 0); - TeamFortress_Alias("dred", TF_DISGUISE_RED, 0); - TeamFortress_Alias("dyellow", TF_DISGUISE_YELLOW, 0); - TeamFortress_Alias("dgreen", TF_DISGUISE_GREEN, 0); - TeamFortress_Alias("denemy", TF_DISGUISE_ENEMY, 0); - TeamFortress_Alias("dlast", TF_DISGUISE_LAST, 0); - TeamFortress_Alias("dlastspawn", TF_DISGUISE_LAST_SPAWNED, 0); - if(csqcactive) { - TeamFortress_AliasString("build", "fo_menu_build"); - } else { - TeamFortress_Alias("build", TF_ENGINEER_BUILD, 0); - } - TeamFortress_Alias("detsentry", TF_ENGINEER_DETSENTRY, 0); - TeamFortress_Alias("detdispenser", TF_ENGINEER_DETDISP, 0); - TeamFortress_Alias("toggledispenser", TF_ENGINEER_TOGGLEDISPENSER, 0); - TeamFortress_Alias("togglesentry", TF_ENGINEER_TOGGLESENTRY, 0); - } else if (self.motd == 130) { - stuffcmd(self, "is_aliased\n"); - TeamFortress_Alias ("ready", TF_PLAYER_READY, 0); - TeamFortress_Alias ("notready", TF_PLAYER_NOT_READY, 0); - TeamFortress_Alias ("nginfo", TF_NAILGREN_INFO, 0); //nailgreninfo - TeamFortress_AliasString("break", "cmd break"); - TeamFortress_AliasString("voteyes", "cmd voteyes"); - TeamFortress_AliasString("yes", "cmd voteyes"); - TeamFortress_AliasString("fo_settings_status", "cmd fo_settings_status"); - TeamFortress_Alias("placepracspawn", TF_PRACSPAWN_PLACE, 0); - TeamFortress_Alias("removepracspawn", TF_PRACSPAWN_REMOVE, 0); - } else if (self.motd == 140) { - Quick_Aliases(); - } else if (self.motd == 400 && self.team_no == 0 && !csqcactive) { - if (loginRequired && !self.login) - Menu_Login(); + if (alias->nocsqc_cmd) + TeamFortress_AliasString(alias->alias, alias->nocsqc_cmd); + else if (alias->nocsqc_impulse) + TeamFortress_Alias(alias->alias, alias->nocsqc_impulse, 0); + else if (alias->impulse) + TeamFortress_Alias(alias->alias, alias->impulse, 0); else - Menu_Team(1); + TeamFortress_AliasString(alias->alias, alias->cmd); } - self.motd = self.motd + 1; + if (idx < client_aliases.length) + self.motd += 1; + else + self.motd = -1; }; void () TeamFortress_HelpMap = { diff --git a/ssqc/weapons.qc b/ssqc/weapons.qc index dfca2c2f..b5e199e3 100644 --- a/ssqc/weapons.qc +++ b/ssqc/weapons.qc @@ -88,7 +88,6 @@ void () fadefromwhite; void (entity disp) Engineer_UseDispenser; void (entity gun) Engineer_UseSentryGun; -void () TeamFortress_MOTD; void () TeamFortress_HelpMap; void () TeamFortress_NailGrenInfo; @@ -190,6 +189,29 @@ void (float att_delay) Attack_Finished = { self.attack_finished = self.client_time + att_delay; }; +float* W_ammo_to_p(entity player, AmmoType ammo_type) { + switch (ammo_type) { + case AMMO_SHELLS: return &player.ammo_shells; + case AMMO_CELLS: return &player.ammo_cells; + case AMMO_NAILS: return &player.ammo_nails; + case AMMO_ROCKETS: return &player.ammo_rockets; + default: + case AMMO_NONE: + return __NULL__; + } + return __NULL__; +} + +float W_ConsumeAmmoIfPossible(float ammo_type, float amount) { + float *ammo = W_ammo_to_p(self, ammo_type); + + if (*ammo < amount) + return FALSE; + *ammo -= amount; + return TRUE; +} + + int () W_FireAxe = { local vector source; local vector org; @@ -1621,6 +1643,8 @@ void () player_asscan_up1; void () player_medikit1; void () player_medikitb1; +float AssCanTryBeginFire(); + void () W_Attack = { FO_WeapState ws; FO_FillCurrentWeapState(&ws); @@ -1705,19 +1729,9 @@ void () W_Attack = { player_autorifle1(); W_FireAutoRifle(); } else if (ws.weapon == WEAP_ASSAULT_CANNON) { - if (self.ammo_cells < 7) { - if (time >= self.antispam_assault_cannon) { - sprint(self, PRINT_MEDIUM, "Not enough cells to power up the Assault Cannon\n"); - self.antispam_assault_cannon = time + 3; - } + self.immune_to_check = time + 5; + if (!AssCanTryBeginFire()) W_ChangeToBestWeapon(); - } else { - self.ammo_cells -= - 7; - self.count = 0; - self.immune_to_check = time + 5; - self.tfstate |= TFSTATE_AIMING; - player_asscan_up1(); - } } else if (ws.weapon == WEAP_FLAMETHROWER) { player_flamethrower1(); W_FireFlame(); @@ -2279,10 +2293,6 @@ void () DeadImpulses = { } } Status_Refresh(self); - } else if (self.impulse == TF_ALIAS_CHECK) { - sprint(self, PRINT_HIGH, "Aliases checked\n"); - self.got_aliases = 1; - self.impulse = 0; } if (self.impulse == TF_PLAYER_READY) { if (clanbattle == 1) {