opencj-dev / server-gsc

OpenCJ serverside GSC files
GNU Affero General Public License v3.0
3 stars 1 forks source link

Allow per-player knockback so that certain fun map scripts can be reinstated #225

Open Yocairo opened 1 year ago

Yocairo commented 1 year ago

For example mp_the_extreme sets g_knockback. Script is nuked now, but could be used if it sets a client dvar instead. Then, we can modify PlayerCmd_finishPlayerDamage in _g_client_script_cmd_mp.asm line 1380:

mov eax, g_knockback // Move g_knockback as cvar_t* into eax
mov eax, [eax] // Grab contents of pointer
cvtsi2ss xmm0, edx // Unsure what edx is at this point, but it will be used to get multiplied with knockback factor
mulss xmm0, [eax+0xc] // Multiply whatever was in xmm0 with value of g_knockback
divss xmm0, dword [_float_250_00000000] // Divide result by 250
movaps xmm1, xmm0 // Move result into xmm1
mulss xmm1, [ebp-0x38] // Don't know what's in ebp at this point
movaps xmm2, xmm0
mulss xmm2, [ebp-0x34]
lea eax, [esi+0x28]
mulss xmm0, [ebp-0x3c]
addss xmm0, [esi+0x28]
movss [esi+0x28], xmm0
iznogod commented 1 year ago

https://github.com/voron00/CoD2rev_Server/blob/1cb9d4e6d2804b51aed9f60c37b583ebba1d39ce/src/game/g_client_script_cmd_mp.cpp#L1061-L1081

Just implement this instead, no need to go through g_knockback cvar, or through finishplayerdamage for that matter.