halflife icon indicating copy to clipboard operation
halflife copied to clipboard

[HL/CS] Adding new client message : ViewModel

Open Arkshine opened this issue 12 years ago • 17 comments

Small feature but still one of the most wanted functionality people would like to see : having the possibility to change render properties of the view model, through a new message named ViewModel.

Proposed code :

hud.h

class CHud
{
    public:

    [...]
    void _cdecl MsgFunc_ViewModel( const char *pszName, int iSize, void *pbuf );
    [...]
};

hud.cpp

void __MsgFunc_ViewModel(const char *pszName, int iSize, void *pbuf)
{
    gHUD.MsgFunc_ViewModel( pszName, iSize, pbuf );
    return 1;
}

void CHud::Init( void )
{
    [...]
    HOOK_MESSAGE( ViewModel );
    [...]
}

hud_msg.cpp

void CHud::MsgFunc_ViewModel( const char *pszName, int iSize, void *pbuf )
{
    BEGIN_READ(pbuf, iSize);
    cl_entity_t *view = gEngfuncs.GetViewModel();
    if ( view )
    {
        view->curstate.rendermode       = READ_BYTE();
        view->curstate.renderfx         = READ_BYTE();
        view->curstate.rendercolor.r    = READ_BYTE();
        view->curstate.rendercolor.g    = READ_BYTE();
        view->curstate.rendercolor.b    = READ_BYTE();
        view->curstate.renderamt        = READ_BYTE();
        view->curstate.skin             = READ_BYTE();
        view->curstate.body             = READ_BYTE();
    }
}

There is no need to register it on the server, that's something the coders will do themselves. I think it's a reasonable feature, easy to review/implement, and will be in favor of a better gameplay immersion (it reminds me quake!).

As side-note, it has been tested on HL by someone and me and we can confirm it's working fine. Proof:

Thanks for considering this cool feature.

Arkshine avatar Feb 16 '13 14:02 Arkshine

+1 For this. Will be cool if is possible to set also the body of view model

bogdyutzu avatar Feb 16 '13 15:02 bogdyutzu

Nevermind my last sentence about not working for me. It works now, the reason was I was not up-to-date and was still using old game location.

@bogdyutzu : I guess it could be useful, I've edited the first post.

Arkshine avatar Feb 16 '13 16:02 Arkshine

100% agree with this feature request, it would be amazing to see this added and it would open up a whole new world of fun possibilities for coders and players.

Egon-Spengler avatar Feb 16 '13 17:02 Egon-Spengler

Awesome request.

Also, would be good to set a param to reset it's values, and another client message "WeaponModel" which will be the same for p_* models, don't you think?

dystopm avatar Feb 17 '13 00:02 dystopm

Sexy

StarsailorAMX avatar Feb 20 '13 01:02 StarsailorAMX

bump

DeMNiX avatar Apr 23 '19 06:04 DeMNiX

Really cool.

New possibilities to scripters

RauliTop avatar Apr 23 '19 14:04 RauliTop

@mikela-valve Is it possible to add for the next release?

oaus avatar Apr 24 '19 21:04 oaus

Please, if this functionality is implemented, if possible, make support for integer values, instead of byte arguments.

Droads2 avatar Apr 25 '19 14:04 Droads2

It's not a good idea. Now we set viemmodel at client-side thru precache list idexes. @mikela-valve

afwn90cj93201nixr2e1re avatar Apr 28 '19 12:04 afwn90cj93201nixr2e1re

So, any news on this? Have been waiting for this feature

SmiteIsTrashBro avatar May 25 '20 15:05 SmiteIsTrashBro

On TFC only, it's possible to render viewmodels, all you gotta do is set render mode for the player entity.

DarthMan avatar Dec 09 '20 21:12 DarthMan

        view->curstate.skin             = READ_BYTE();
        view->curstate.body             = READ_BYTE();

should be long instead of byte allowing more combinations of submodels

        view->curstate.skin             = READ_LONG();
        view->curstate.body             = READ_LONG();

ab2331 avatar Mar 22 '23 17:03 ab2331

Now it would be the time to implement this in the 25th anniversary update for mod-makers considering how easy to implement and review is this.

rtxa avatar Nov 21 '23 15:11 rtxa

My hope hasn't died yet!

LKING1543 avatar Apr 28 '24 16:04 LKING1543

@shawns-valve

WaLkZa avatar Sep 01 '24 06:09 WaLkZa

this could also use the event system too. Would save on messages (don't know what the downsides of the event system are though, other than having to precache it)

Pacman1105 avatar Oct 08 '25 20:10 Pacman1105