@@ -13,6 +13,8 @@ namespace gameplay
13
13
utils::hook::detour pm_player_trace_hook;
14
14
utils::hook::detour pm_crashland_hook;
15
15
16
+ game::dvar_t * pm_snap_vector = nullptr ;
17
+
16
18
void pm_player_trace_stub (game::pmove_t * pm, game::trace_t * results, const float * start,
17
19
const float * end, const game::Bounds* bounds, int passEntityNum, int contentMask)
18
20
{
@@ -111,6 +113,51 @@ namespace gameplay
111
113
a.bind (loc_140691518);
112
114
a.jmp (0x140691518 );
113
115
}
116
+
117
+ void sys_snap_vector (float * velocity)
118
+ {
119
+ if (!pm_snap_vector->current .enabled )
120
+ {
121
+ return ;
122
+ }
123
+
124
+ velocity[0 ] = std::floorf (velocity[0 ] + 0 .5f );
125
+ velocity[1 ] = std::floorf (velocity[1 ] + 0 .5f );
126
+ velocity[2 ] = std::floorf (velocity[2 ] + 0 .5f );
127
+ }
128
+
129
+ void add_snap_vector_call (utils::hook::assembler& a)
130
+ {
131
+ a.pushad64 ();
132
+ a.mov (rcx, rsi);
133
+ a.call_aligned (sys_snap_vector);
134
+ a.popad64 ();
135
+ }
136
+
137
+ void pmove_single_stub1 (utils::hook::assembler& a)
138
+ {
139
+ const auto loc_14068FEBD = a.newLabel ();
140
+
141
+ a.comiss (xmm5, xmm4);
142
+ a.jbe (loc_14068FEBD);
143
+ a.mov (rax, 0x3F800000 );
144
+ a.movq (xmm1, rax);
145
+ a.jmp (0x14068FE99 );
146
+
147
+ a.bind (loc_14068FEBD);
148
+ add_snap_vector_call (a);
149
+ a.jmp (0x14068FEBD );
150
+ }
151
+
152
+ void pmove_single_stub2 (utils::hook::assembler& a)
153
+ {
154
+ a.movss (dword_ptr (rsi, 8 ), xmm1);
155
+ a.movss (dword_ptr (rsi, 4 ), xmm0);
156
+ a.movss (dword_ptr (rsi), xmm6);
157
+
158
+ add_snap_vector_call (a);
159
+ a.jmp (0x14068FEBD );
160
+ }
114
161
}
115
162
116
163
class component final : public component_interface
@@ -154,6 +201,11 @@ namespace gameplay
154
201
game::DVAR_FLAG_REPLICATED, " Game gravity in inches per second squared" );
155
202
dvars::register_int (" g_speed" , 190 , 0 , 1000 ,
156
203
game::DVAR_FLAG_REPLICATED, " Player speed" );
204
+
205
+ pm_snap_vector = dvars::register_bool (" pm_snapVector" , false , game::DVAR_FLAG_REPLICATED, " Snap velocity vector (mp movement)" );
206
+
207
+ utils::hook::jump (0x14068FE8C , utils::hook::assemble (pmove_single_stub1), true );
208
+ utils::hook::jump (0x14068FEAF , utils::hook::assemble (pmove_single_stub2), true );
157
209
}
158
210
};
159
211
}
0 commit comments