diff options
Diffstat (limited to '')
| -rw-r--r-- | src/hl2h.cpp | 93 |
1 files changed, 3 insertions, 90 deletions
diff --git a/src/hl2h.cpp b/src/hl2h.cpp index defdd27..c51d35e 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp | |||
| @@ -169,75 +169,6 @@ static void apply_autostrafe(CUserCmd *cmd, const float *vel) { | |||
| 169 | cmd->sidemove = (dx * rx + dy * ry) * 450.0f; | 169 | cmd->sidemove = (dx * rx + dy * ry) * 450.0f; |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | // True while the player stands on (or just left) a physics prop. m_hGroundEntity | ||
| 173 | // is latched briefly because it clears during each hop. | ||
| 174 | static bool stucklaunch_prop_ok(void *ent, int tick) { | ||
| 175 | if (g_net.groundentity < 0) { | ||
| 176 | static bool logged = false; | ||
| 177 | if (!logged) { | ||
| 178 | logged = true; | ||
| 179 | logf("stucklaunch: m_hGroundEntity unavailable; prop detection off"); | ||
| 180 | } | ||
| 181 | return true; // no netvar: the bind is the only safeguard | ||
| 182 | } | ||
| 183 | static int last_prop_tick = -100000; | ||
| 184 | uint32_t h = *(uint32_t *)((uintptr_t)ent + g_net.groundentity); | ||
| 185 | int gi = (h == 0xFFFFFFFFu) ? 0 : (int)(h & 0xFFFF); | ||
| 186 | bool on = gi > 0 && gi <= 4096 && entity_is_physics_prop(gi); | ||
| 187 | if (on) { | ||
| 188 | static int prop_logs = 0; | ||
| 189 | if (prop_logs < 4) { | ||
| 190 | prop_logs++; | ||
| 191 | logf("stucklaunch: prop idx=%d engaged", gi); | ||
| 192 | } | ||
| 193 | last_prop_tick = tick; | ||
| 194 | } else { | ||
| 195 | static int miss_logs = 0; | ||
| 196 | if (miss_logs < 4) { | ||
| 197 | miss_logs++; | ||
| 198 | logf("stucklaunch: ground h=%#x idx=%d is not a physics prop", h, gi); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | return tick - last_prop_tick < 32; // ~0.5 s at 66 tick | ||
| 202 | } | ||
| 203 | |||
| 204 | // Stucklaunch assist. The player supplies the physics prop and a little | ||
| 205 | // initial speed; this holds jump, alternates +use (and optionally the gravity | ||
| 206 | // gun's +attack) to keep regrabbing the prop, and air-strafes the hops. | ||
| 207 | static void stucklaunch_apply(CUserCmd *cmd, void *local_ent, bool onground, | ||
| 208 | const float *vel) { | ||
| 209 | static bool engaged_logged = false; | ||
| 210 | if (!engaged_logged) { | ||
| 211 | engaged_logged = true; | ||
| 212 | logf("stucklaunch: applying jump/spam (onground=%d)", (int)onground); | ||
| 213 | } | ||
| 214 | cmd->buttons |= IN_JUMP; | ||
| 215 | int period = stucklaunch_spam_ticks(); | ||
| 216 | if (period < 1) | ||
| 217 | period = 1; | ||
| 218 | int phase = (cmd->tick_count / period) & 1; | ||
| 219 | bool gravity = stucklaunch_gravspam_enabled() && | ||
| 220 | active_weapon_is_gravity_gun(local_ent); | ||
| 221 | if (gravity) { | ||
| 222 | // Pick up with +attack, drop with +use on the next half-cycle. Pressing | ||
| 223 | // both together would punt instead of regrabbing. | ||
| 224 | if (phase == 0) { | ||
| 225 | cmd->buttons |= IN_ATTACK; | ||
| 226 | cmd->buttons &= ~IN_USE; | ||
| 227 | } else { | ||
| 228 | cmd->buttons |= IN_USE; | ||
| 229 | cmd->buttons &= ~IN_ATTACK; | ||
| 230 | } | ||
| 231 | } else if (stucklaunch_use_spam_enabled()) { | ||
| 232 | if (phase == 0) | ||
| 233 | cmd->buttons |= IN_USE; | ||
| 234 | else | ||
| 235 | cmd->buttons &= ~IN_USE; | ||
| 236 | } | ||
| 237 | if (stucklaunch_autostrafe_enabled() && !onground) | ||
| 238 | apply_autostrafe(cmd, vel); | ||
| 239 | } | ||
| 240 | |||
| 241 | // --------------------------------------------------------------------------- | 172 | // --------------------------------------------------------------------------- |
| 242 | // jumpbug | 173 | // jumpbug |
| 243 | // --------------------------------------------------------------------------- | 174 | // --------------------------------------------------------------------------- |
| @@ -645,23 +576,8 @@ static void do_move(int seq, float frametime) { | |||
| 645 | return; | 576 | return; |
| 646 | } | 577 | } |
| 647 | 578 | ||
| 648 | bool stuck_on = feature_active(FEAT_STUCKLAUNCH); | 579 | bool bhop_on = feature_active(FEAT_BHOP); |
| 649 | if (g_stucklaunch.active) { | 580 | bool abh_on = feature_active(FEAT_ABH); |
| 650 | static bool state_logged = false; | ||
| 651 | if (!state_logged) { | ||
| 652 | state_logged = true; | ||
| 653 | logf("stucklaunch: active=1 run=%d bind=%d groundoff=%d", | ||
| 654 | (int)stuck_on, g_stucklaunch.bind, g_net.groundentity); | ||
| 655 | } | ||
| 656 | } | ||
| 657 | bool stuck_engaged = stuck_on && stucklaunch_prop_ok(ent, cmd->tick_count); | ||
| 658 | if (stuck_engaged) { | ||
| 659 | stucklaunch_apply(cmd, ent, onground, vel); | ||
| 660 | note_modified(cmd, flags, vel); | ||
| 661 | } | ||
| 662 | |||
| 663 | bool bhop_on = !stuck_engaged && feature_active(FEAT_BHOP); | ||
| 664 | bool abh_on = !stuck_engaged && feature_active(FEAT_ABH); | ||
| 665 | 581 | ||
| 666 | static bool lastground = false; | 582 | static bool lastground = false; |
| 667 | 583 | ||
| @@ -712,8 +628,7 @@ static void do_move(int seq, float frametime) { | |||
| 712 | } | 628 | } |
| 713 | } | 629 | } |
| 714 | 630 | ||
| 715 | if (!stuck_engaged && | 631 | if (jumpbug_apply(cmd, localIdx, ent, flags, vel, frametime)) |
| 716 | jumpbug_apply(cmd, localIdx, ent, flags, vel, frametime)) | ||
| 717 | note_modified(cmd, flags, vel); | 632 | note_modified(cmd, flags, vel); |
| 718 | 633 | ||
| 719 | bool melee = feature_active(FEAT_MELEE) && melee_weapon_active(ent); | 634 | bool melee = feature_active(FEAT_MELEE) && melee_weapon_active(ent); |
| @@ -951,8 +866,6 @@ static void *setup_thread(void *) { | |||
| 951 | toastf(TOAST_ERROR, "Netvars incomplete; features may be disabled"); | 866 | toastf(TOAST_ERROR, "Netvars incomplete; features may be disabled"); |
| 952 | else if (g_net.absvelocity < 0) | 867 | else if (g_net.absvelocity < 0) |
| 953 | toastf(TOAST_WARN, "Jumpbug assist disabled: velocity netvar missing"); | 868 | toastf(TOAST_WARN, "Jumpbug assist disabled: velocity netvar missing"); |
| 954 | if (g_net.groundentity < 0) | ||
| 955 | toastf(TOAST_WARN, "Stucklaunch prop detection unavailable; bind it"); | ||
| 956 | if (!g_iface.engineserver) | 869 | if (!g_iface.engineserver) |
| 957 | toastf(TOAST_WARN, "Server interfaces missing; jumpbug/spread limited"); | 870 | toastf(TOAST_WARN, "Server interfaces missing; jumpbug/spread limited"); |
| 958 | if (!g_iface.debugoverlay) | 871 | if (!g_iface.debugoverlay) |
