Well, I actually solved it by modifying it a little bit and adding the
jetpack as a regular suit device, like sprint does. Now it's draining
equally fast for everyone.

 

Kind regards,

Radimir

 

From: hlcoders-boun...@list.valvesoftware.com
[mailto:hlcoders-boun...@list.valvesoftware.com] On Behalf Of Radimir Bobev
Sent: Saturday, July 6, 2013 7:32 PM
To: 'Discussion of Half-Life Programming'
Subject: [hlcoders] Suit energy drains faster for host than for clients

 

Hi guys

 

In my mod, I have a jetpack which uses the suit energy as "fuel"; the
problem is that it drains at its normal, intended rate, for the host player,
and for all other players it drains much more slowly. And when I say more
slowly, I mean at least 5x as slow. 

 

The jetpack works as follows:

 

In CGameMovement::FullWalkMove( ), I check if the jetpack is enabled, if it
is, I call CGameMovement::ApplyJetpack( )

 

There, we have

 

void CGameMovement::ApplyJetpack( void )

{

#ifndef CLIENT_DLL

       CHL2MP_Player *tempHL2p = ToHL2MPPlayer(player);

       if (!tempHL2p) return;

       //boostType = tempHL2p->GetBoostType();

#endif

#ifdef CLIENT_DLL

       C_HL2MP_Player *tempHL2p = ToHL2MPPlayer(player);

       if (!tempHL2p) return;

#endif

       

       if (frameCount != gpGlobals->framecount)

       {

             frameCount = gpGlobals->framecount;

             if (!DrainSuit( JETPACK_DRAIN_RATE * gpGlobals->frametime ))

             {

                    tempHL2p->JetpackEnabled = false;

                    return;

             }

       }

 

..

 

 

DrainSuit is a custom function (it's been a while since I implemented it but
I think it was so the client can get updated on the current suit %
immediately)

 

bool CGameMovement::DrainSuit( float tempVal )

{

#ifndef CLIENT_DLL

       CHL2_Player *pPlayer2 = static_cast<CHL2_Player *>( player );

       if (pPlayer2->SuitPower_Drain( tempVal )) return true;

       else return false;

#else

       if (ToHL2MPPlayer(player)->m_HL2Local.m_flSuitPower <= tempVal)
return false;

       else return true;

#endif

       return false;

}

 

Any ideas what could be causing this behavior? I suppose it's a networking
issue, but I'm not sure what exactly it could be.

 

Kind regards,

Radimir

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

Reply via email to