Mantis: 0000538

o Fixed onos digestion progress bar

git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@481 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
puzl 2006-05-14 13:14:57 +00:00
parent d0a185c664
commit db15b07ef4
6 changed files with 58 additions and 30 deletions

View File

@ -2403,7 +2403,9 @@ int AvHHud::ServerVar(const char* pszName, int iSize, void* pbuf)
BIND_MESSAGE(Progress);
int AvHHud::Progress(const char* pszName, int iSize, void* pbuf)
{
NetMsg_ProgressBar( pbuf, iSize, this->mProgressBarEntityIndex, this->mProgressBarParam );
NetMsg_ProgressBar( pbuf, iSize, this->mProgressBarEntityIndex, this->mProgressBarParam, this->mProgressBarCompleted );
char msg[1024];
CenterPrint(msg);
return 1;
}
@ -2485,6 +2487,7 @@ void AvHHud::ResetGame(bool inMapChanged)
this->mCurrentCursorFrame = 0;
this->mProgressBarEntityIndex = -1;
this->mProgressBarParam = -1;
this->mProgressBarCompleted = -1;
this->mEnemyBlips.Clear();
this->mFriendlyBlips.Clear();
@ -3675,6 +3678,7 @@ void AvHHud::Init(void)
this->mProgressBarEntityIndex = -1;
this->mProgressBarParam = -1;
this->mProgressBarCompleted = -1;
this->mSelectedNodeResourceCost = -1;
this->mCurrentUseableEnergyLevel = 0;
this->mVisualEnergyLevel = 0.0f;
@ -5747,31 +5751,36 @@ void AvHHud::UpdateProgressBar()
if(theProgressEntity)
{
ASSERT(this->mProgressBarParam >= 1);
ASSERT(this->mProgressBarParam <= 4);
ASSERT(this->mProgressBarParam <= 5);
float theProgress = 0.0f;
switch(this->mProgressBarParam)
{
case 1:
theProgress = theProgressEntity->curstate.fuser1;
break;
case 2:
theProgress = theProgressEntity->curstate.fuser2;
break;
case 3:
theProgress = theProgressEntity->curstate.fuser3;
break;
case 4: // NOTE: check delta.lst for fuser4, it isn't propagated currently
theProgress = theProgressEntity->curstate.fuser4;
break;
if ( this->mProgressBarParam == 5 ) {
thePercentage=(float)(this->mProgressBarCompleted)/100.0f;
}
else {
switch(this->mProgressBarParam)
{
case 1:
theProgress = theProgressEntity->curstate.fuser1;
break;
case 2:
theProgress = theProgressEntity->curstate.fuser2;
break;
case 3:
theProgress = theProgressEntity->curstate.fuser3;
break;
case 4: // NOTE: check delta.lst for fuser4, it isn't propagated currently
theProgress = theProgressEntity->curstate.fuser4;
break;
}
if((this->GetHUDUser3() == AVH_USER3_ALIEN_EMBRYO) || this->GetIsDigesting())
{
theProgress = pmove->fuser3;
if((this->GetHUDUser3() == AVH_USER3_ALIEN_EMBRYO) || this->GetIsDigesting() )
{
theProgress = pmove->fuser3;
}
thePercentage = theProgress/kNormalizationNetworkFactor;
}
thePercentage = theProgress/kNormalizationNetworkFactor;
int theType = (this->GetIsAlien())? PROGRESS_BAR_ALIEN: PROGRESS_BAR_MARINE;
if(thePercentage < 1.0f)
{

View File

@ -762,6 +762,7 @@ private:
int mProgressBarEntityIndex;
int mProgressBarParam;
int mProgressBarCompleted;
float mProgressBarStatus;
float mProgressBarLastDrawn;
int mProgressBarDrawframe;

View File

@ -75,7 +75,7 @@ void Net_InitializeMessages(void)
g_msgListPS = REG_USER_MSG( "ListPS", -1 );
g_msgPlayHUDNotification = REG_USER_MSG( "PlayHUDNot", 6 );
g_msgHUDSetUpgrades = REG_USER_MSG( "SetUpgrades", 1);
g_msgProgressBar = REG_USER_MSG( "Progress", 3 );
g_msgProgressBar = REG_USER_MSG( "Progress", -1 );
g_msgServerVar = REG_USER_MSG( "ServerVar", -1 );
g_msgSetGammaRamp = REG_USER_MSG( "SetGmma", 1 );
g_msgSetOrder = REG_USER_MSG( "SetOrder", -1 );
@ -1496,19 +1496,24 @@ union float_converter
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#ifndef AVH_SERVER
void NetMsg_ProgressBar( void* const buffer, const int size, int& entity_number, int& progress )
void NetMsg_ProgressBar( void* const buffer, const int size, int& entity_number, int& progress, int& seconds)
{
BEGIN_READ( buffer, size );
entity_number = READ_SHORT();
progress = READ_BYTE();
if ( progress == 5 )
seconds=READ_BYTE();
END_READ();
}
#else
void NetMsg_ProgressBar( entvars_t* const pev, const int entity_number, const int progress )
void NetMsg_ProgressBar( entvars_t* const pev, const int entity_number, const int progress, int seconds )
{
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, g_msgProgressBar, NULL, pev );
WRITE_SHORT( entity_number );
WRITE_BYTE( progress );
if ( progress == 5 )
WRITE_BYTE( seconds );
MESSAGE_END();
}
#endif

View File

@ -93,7 +93,7 @@
void NetMsg_HUDSetUpgrades( int upgradeMask );
void NetMsg_HUDSetUpgrades( entvars_t* const pev, int upgradeMask );
void NetMsg_PlayHUDNotification( entvars_t* const pev, const int flags, const int sound, const float location_x, const float location_y );
void NetMsg_ProgressBar( entvars_t* const pev, const int entity_number, const int progress );
void NetMsg_ProgressBar( entvars_t* const pev, const int entity_number, const int progress, int percent=0 );
void NetMsg_ServerVar( entvars_t* const pev, const string& name, const string& value );
void NetMsg_SetGammaRamp( entvars_t* const pev, const float gamma );
void NetMsg_SetOrder( entvars_t* const pev, const AvHOrder& order );
@ -182,7 +182,7 @@
void NetMsg_ListPS( void* const buffer, const int size, string& system_name );
void NetMsg_HUDSetUpgrades( void* const buffer, const int size, int& upgradeMask );
void NetMsg_PlayHUDNotification( void* const buffer, const int size, int& flags, int& sound, float& location_x, float& location_y );
void NetMsg_ProgressBar( void* const buffer, const int size, int& entity_number, int& progress );
void NetMsg_ProgressBar( void* const buffer, const int size, int& entity_number, int& progress, int &percent);
//45
void NetMsg_ServerVar( void* const buffer, const int size, string& name, string& value );
void NetMsg_SetGammaRamp( void* const buffer, const int size, float& gamma );

View File

@ -3513,6 +3513,7 @@ void AvHPlayer::Init()
// Don't set this, must propagate
//this->mClientProgressBarEntityIndex = -1;
this->mProgressBarParam = -1;
this->mProgressBarCompleted = -1;
this->mTimeProgressBarTriggered = -1;
this->mTimeOfLastFogTrigger = -1;
this->mFogExpireTime = -1;
@ -5444,13 +5445,16 @@ void AvHPlayer::InternalDigestionThink()
// Set status bar estimating how long before player will be digested (for both digestee and digester)
theDigestee->TriggerProgressBar(theDigesteeIndex, 3);
this->TriggerProgressBar(theDigesteeIndex, 3);
// Set fuser3 appropriately
int theMaxHealth = AvHPlayerUpgrade::GetMaxHealth(theDigestee->pev->iuser4, theDigestee->GetUser3(), this->GetExperienceLevel());
float theDigestingScalar = (((float)theMaxHealth - theDigestee->pev->health)/(float)theMaxHealth);
/*this->pev->fuser3 =*/ theDigestee->pev->fuser3 = theDigestingScalar*kNormalizationNetworkFactor;
int thePercent=theDigestingScalar*100.0f ;
thePercent=min(100, max(0, thePercent));
this->TriggerProgressBar(theDigesteeIndex, 5, thePercent);
// Set sound effects as player gets more and more digested
int theDesiredRoomType = 26; // strange sounds right before you die
if(theDigestingScalar < .33f)
@ -5479,6 +5483,7 @@ void AvHPlayer::InternalDigestionThink()
// If digestee is dead and no longer relevant
if(!theDigestee->IsAlive() || !theDigestee->GetIsRelevant() || (theDigestee->GetTeam() == this->GetTeam()))
{
this->mProgressBarParam = -1;
this->StopDigestion(thePlayerWasDigested);
}
}
@ -6958,6 +6963,7 @@ void AvHPlayer::InternalProgressBarThink()
this->mTimeProgressBarTriggered = -1;
this->mProgressBarEntityIndex = -1;
this->mProgressBarParam = -1;
this->mProgressBarCompleted = -1;
}
}
}
@ -8702,13 +8708,15 @@ void AvHPlayer::TriggerFog(int inFogEntity, float inFogExpireTime)
}
}
void AvHPlayer::TriggerProgressBar(int inEntityID, int inParam)
void AvHPlayer::TriggerProgressBar(int inEntityID, int inParam, int inPercent)
{
ASSERT(inEntityID >= 0);
this->mProgressBarEntityIndex = inEntityID;
this->mProgressBarParam = inParam;
this->mProgressBarCompleted = inPercent;
this->mTimeProgressBarTriggered = gpGlobals->time;
}
float AvHPlayer::GetTimeOfLastTeleport() const
@ -9638,9 +9646,13 @@ void AvHPlayer::UpdateProgressBar()
// Assumes that progress is normalized and stored in one of the fuser variables of the entity index sent down
if(this->mClientProgressBarEntityIndex != this->mProgressBarEntityIndex)
{
NetMsg_ProgressBar( this->pev, this->mProgressBarEntityIndex, this->mProgressBarParam );
NetMsg_ProgressBar( this->pev, this->mProgressBarEntityIndex, this->mProgressBarParam, this->mProgressBarCompleted );
this->mClientProgressBarEntityIndex = this->mProgressBarEntityIndex;
}
// onos digestion uses a parameter to the network message
else if ( this->mProgressBarParam == 5 ) {
NetMsg_ProgressBar( this->pev, this->mProgressBarEntityIndex, this->mProgressBarParam, this->mProgressBarCompleted );
}
}
void AvHPlayer::UpdateVUser4()

View File

@ -332,7 +332,7 @@ public:
void SetCurrentCommand(const struct usercmd_s* inCommand);
void SetDebugCSP(weapon_data_t* inWeaponData);
void SetPendingCommand(char* inCommand);
void TriggerProgressBar(int inEntityID, int inParam);
void TriggerProgressBar(int inEntityID, int inParam, int inPercent=0);
float GetTimeOfLastTeleport() const;
void SetTimeOfLastTeleport(float inTime);
bool SwitchWeapon(const char* inString);
@ -764,6 +764,7 @@ private:
int mClientProgressBarEntityIndex;
int mProgressBarEntityIndex;
int mProgressBarParam;
int mProgressBarCompleted;
float mTimeProgressBarTriggered;
float mTimeOfLastFogTrigger;