Raised This Month: $ Target: $400
 0% 

Custom server-side viewmodel, with prediction


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MsDysphie
AlliedModders Donor
Join Date: Dec 2017
Old 07-09-2021 , 12:02   Custom server-side viewmodel, with prediction
Reply With Quote #1

I'm trying to create fully server-side custom viewmodels that are predicted by the client.
Doing this for No More Room in Hell but process probably translates over to other games.

All videos were recorded with net_fakelag 200 and changing the original model from a Glock to an M92FS

Approach #1:
Edit the existing predicted_viewmodel.
Pros: Client predicts properly ..sorta
Dealbreaker: Viewmodel flickers when the animations loop around, even if they are the same length. This issue doesn't seem to affect CSGO for some reason. https://gfycat.com/passionateunawareaztecant

PHP Code:
public Action OverrideViewmodel(int clientint args)
{
    
int vm GetEntPropEnt(clientProp_Data"m_hViewModel"0);
    
SetEntProp(vmProp_Send"m_nModelIndex"customModel);
    return 
Plugin_Handled;

Approach #2:
Create a prop_dynamic and bonemerge to the original viewmodel
Pros: Perfect client side prediction!
Dealbreaker: Model is offset forward and cannot be repositioned. It also clips the player hull making it not render properly. I could painstakingly fix the FOV by editing the .mdl file but the clipping issue remains https://gfycat.com/athleticexemplaryglassfrog

PHP Code:
public Action CreateFakeViewmodel(int clientint args)
{
    
int prop CreateEntityByName("prop_dynamic_override");

    
DispatchKeyValue(prop"model""models/weapons/fa_m92fs/v_fa_m92fs.mdl");
    
DispatchKeyValue(prop"disablereceiveshadows""1");
    
DispatchKeyValue(prop"disableshadows""1");
    
DispatchKeyValue(prop"solid""0");
    
DispatchSpawn(prop);

    
SetEntityMoveType(propMOVETYPE_NONE); // Needed to animate

    
int viewmodel GetEntPropEnt(clientProp_Data"m_hViewModel"0);

    
SetVariantString("!activator");
    
AcceptEntityInput(prop"SetParent"viewmodel);
    
SetEntProp(propProp_Send"m_fEffects"EF_BONEMERGE); // Also needed to animate

    
ReplyToCommand(client"Created fake viewmodel %d"prop);
    return 
Plugin_Handled;


Approach #3:
Create a new predicted_viewmodel (CCSPlayer::CreateViewModel)
Pros: Displays at the right position and doesn't clip
Dealbreaker: Can't get it to animate without manually setting the sequence, which wouldn't play nicely with client prediction https://gfycat.com/smartpettyacouchi

PHP Code:
public Action CreateRealViewmodel(int clientint args)
{
    
int index 1;

    
SDKCall(fnCreateViewmodelclientindex);

    
int vm2 GetEntPropEnt(clientProp_Data"m_hViewModel"index);
    
SetEntityModel(vm2"models/weapons/fa_m92fs/v_fa_m92fs.mdl");

    
// ... What to do now? Setting m_hWeapon doesn't help

    
ReplyToCommand(client"Created real viewmodel %d"vm2);

So yeah, curious if anyone knows how to fix any of these or has another working method, I'm out of ideas at this point
Here's the full test script https://hatebin.com/wsyflqvnqc

Last edited by MsDysphie; 07-09-2021 at 12:11.
MsDysphie is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 07-15-2021 , 06:40   Re: Custom server-side viewmodel, with prediction
Reply With Quote #2

There is some work by Silvers & Lux related to client viewmodel faking, you may want to look to:
[CS:GO/L4D1/L4D2] Weapon Charms
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode