I just found a horrible hack in the SDK that has been causing weird
problems for my mod and I thought I should post it here in case anyone runs
into similar problems.  Some of the weapons in my mod depend on multiple
bodies in the model. In the 2.0 SDK, the body got sent automatically
whenever you called SendWeaponAnim(), but in the 2.2 SDK they added a new
default parameter to SendWeaponAnim().  The new last parameter is body and
it defaults to 0, so you can no longer just set pev->body and then send off
an animation, you must add the body to the end of all your SendWeaponAnim
calls for that weapon.

This is not the hack though, it is just an inconvenience that you should
know about.  The hack is this bit of code in hl_weapons.cpp on the client;

// Make sure that weapon animation matches what the game .dll is telling us
//  over the wire ( fixes some animation glitches )
if ( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) )
{
        int body = 2;

        //Pop the model to body 0.
        if ( pWeapon == &g_Tripmine )
                 body = 0;

        //Show laser sight/scope combo
        if ( pWeapon == &g_Python && bIsMultiplayer() )
                 body = 1;

        // Force a fixed anim down to viewmodel
        HUD_SendWeaponAnim( to->client.weaponanim, body, 1 );
}

Apparently they were having animation glitches when the client and server
got out of sync occasionally, so they threw this hack in to fix it.  The
problem is though, that it does not care what body your weapon is using, it
automatically sets it to 2.  I tried commenting this out and there are
animation glitches when the player spawns.

So, the moral of the story is, if you have a weapon that depends on
multiple bodies, add an if (pWeapon == &gYourWeapon) and set the body to
the correct value.  Talk about a maintenance nightmare and bugs waiting to
happen ;-)

Hope this helps someone, I spent enough hours tearing my hair out over it
:D  Anyone think this is worth writing a tutorial over?

Rob Prouse
Tour of Duty Mod
http://www.tourofdutymod.com

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to