Note: This thread is for discussing how to fix knock back only, not other issues with ZR. Don't go off topic here.
Problem
The knock back feature is supposed to push players in a certain direction with a certain force (using TeleportEntity in SourceMod to append to the player velocity). In CS:S players will slide on the ground in varying distances depending on the push force, it behaves just like we want to. In CS:GO players don't slide much on the ground, no matter how high the push force is. If the same push force is applied when they're in mid-air, players fly away as we want to.
By applying a push force I mean increasing a players momentum. I've tried really high push forces, but players really hold on to the ground. If this was for real, a player could stop a moving train by just standing there.
I've been investigating the knock back issue and so far I haven't found an acceptable solution. My findings so far:
Velocity capped when on ground
No matter how large velocity I apply, the value seems to never go above the running speed (233 with knife). It looks like it's capped. The question is: When?
The trigger_push entity also have the same issue when players stand on the ground. So if someone find a fix for trigger_push we also might be able to fix knock back.
Upwards force above 250 (velocity[2]) works
Applying a velocity that will push you up 251 units/sec will make you go off the ground so that the knock back velocity is applied. Though people will also fly a bit upwards because of this. It doesn't look natural, especially when shooting from above (which is the last thing people would expect happening).
This is a workaround that at least makes it possible to push people back. But it has bad side effects because it pushes you up in the air. People/zombies in air are very vulnerable to knock back compared to those on the ground (because there's no friction when in air, which also applies to CS:S). It's a lot easier to shoot them away. Zombies can avoid this by not jumping too much, but with this workaround they are always vulnerable. There's no difference in knock back for zombies on the ground or zombies in the air. This is a bad side effect that may make the game unbalanced.
Velocity seems to decrease in a fixed time span
This might just be an illusion if the velocity is capped, but when applying high velocity I expected it to take longer time to decrease so people will slide on the ground, just like in CS:S. But in CS: GO players always stop quickly, like there's high friction. Lowering sv_friction didn't make it any better because it affected general movement, such as when you stop walking you're supposed to stop quickly.
Stuff that didn't work- sv_gravity 0
- sv_friction 1 (or other low values)
- sv_enablebunnyhopping 0
- sv_staminalandcost 0
- sv_staminajumpcost 0
- sv_maxspeed 1000
- overriding CBasePlayer::m_flMaxspeed in PostThink (in combination with sv_maxspeed)
I suspected that the velocity applied to the player is capped by max speed. It still didn't work.
- mp_solid_teammates 1
- modifying CBasePlayer::m_vecBaseVelocity
No difference from applying velocity with TeleportEntity native in SourceMod.
- modifying CBasePlayer::m_vecVelocity
The player moved in the correct direction, but movement stopped quickly, even in air. Maybe I didn't do this correctly or the engine didn't like me changing the value directly.
- sv_stopspeed 0 - Player deacceleration is slower, but the player still move about the same distance no matter how high the knock back push is.
Stuff to test
Everyone are welcome to test this and report back here.
- Read the velocity (m_vecVelocity) in every possible event or hook, such as (pre/post) think. We need to figure out if or when velocity is capped. Only compare readings in the same game frame - maybe also a list of readings (n + 10 frames).
- Experiment with the FL_ONGROUND flag before/after applying knock back. Though changes will probably be overwritten in the next frame. And players not on the ground will have those bad side effects mentioned above.
- Experiment with CBasePlayer::m_flFriction multiplier.
Solutions or ideas are welcome (without side effects if possible), just remember to don't go off topic.
__________________