From e83f9ea54690ccb400a546d6c9d8c6c0383b305d Mon Sep 17 00:00:00 2001 From: tankefugl Date: Fri, 26 May 2006 17:17:24 +0000 Subject: [PATCH] o Movement abilities now play at a much lower sound volume in the readyroom o Charge do no longer push players in the readyroom o Fixed bug where movement abilities sometimes could be available after the needed hives have been destroyed o Fixed issue with movement ability sounds playing more than they should git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@502 67975925-1194-0748-b3d5-c16f83f1a3a1 --- releases/3.2.0/source/cl_dll/ammo.cpp | 12 ++ releases/3.2.0/source/dlls/weapons.cpp | 4 + releases/3.2.0/source/mod/AvHBlink.cpp | 12 +- releases/3.2.0/source/mod/AvHEvents.cpp | 2 +- releases/3.2.0/source/mod/AvHPlayer.cpp | 104 ++++++++++++------ releases/3.2.0/source/mod/AvHPlayer.h | 2 + releases/3.2.0/source/pm_shared/pm_shared.cpp | 21 ++-- 7 files changed, 106 insertions(+), 51 deletions(-) diff --git a/releases/3.2.0/source/cl_dll/ammo.cpp b/releases/3.2.0/source/cl_dll/ammo.cpp index 28affc78..abf300a3 100644 --- a/releases/3.2.0/source/cl_dll/ammo.cpp +++ b/releases/3.2.0/source/cl_dll/ammo.cpp @@ -42,6 +42,8 @@ WeaponsResource gWR; int g_weaponselect = 0; +extern bool gCanMove; + void IN_AttackDownForced(void); void IN_AttackUpForced(void); void IN_Attack2Down(void); @@ -830,6 +832,13 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) if( !bIsCurrent ) { return 1; } +// char temp[255]; +// sprintf(temp, "iState %d iId %d iClip %d\n", iState, iId, iClip); +// gEngfuncs.pfnConsolePrint(temp); + + if (iId == 22 || iId == 11 || iId == 21) + gCanMove = pWeapon->iEnabled; + m_pWeapon = pWeapon; if ( !(gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) ) @@ -882,6 +891,9 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf ) // puzl: 497 - default value for enable state Weapon.iEnabled = 0; +// if (Weapon.iId == 22 || Weapon.iId == 11 || Weapon.iId == 21) +// gCanMove = true; //Weapon.iEnabled; + gWR.AddWeapon( &Weapon ); return 1; } diff --git a/releases/3.2.0/source/dlls/weapons.cpp b/releases/3.2.0/source/dlls/weapons.cpp index ba2227cb..d640b797 100644 --- a/releases/3.2.0/source/dlls/weapons.cpp +++ b/releases/3.2.0/source/dlls/weapons.cpp @@ -126,6 +126,7 @@ MULTIDAMAGE gMultiDamage; #define TRACER_FREQ 4 // Tracers fire every fourth bullet +extern bool gCanMove[]; //========================================================= // MaxAmmoCarry - pass in a name and this function will tell @@ -1171,6 +1172,9 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) bSend = TRUE; } + if (m_iId == 22 || m_iId == 11 || m_iId == 21) + gCanMove[pPlayer->entindex() - 1] = m_iEnabled; + if ( bSend ) { NetMsg_CurWeapon( pPlayer->pev, state, m_iId, m_iClip ); diff --git a/releases/3.2.0/source/mod/AvHBlink.cpp b/releases/3.2.0/source/mod/AvHBlink.cpp index 4b1f5762..b337407b 100644 --- a/releases/3.2.0/source/mod/AvHBlink.cpp +++ b/releases/3.2.0/source/mod/AvHBlink.cpp @@ -125,12 +125,12 @@ void AvHBlinkGun::FireProjectiles(void) thePlayer->TriggerUncloak(); } #endif - if(this->mTimeOfNextBlinkEvent <= 0) - { - const float kEventDelay = 2.0f; - this->PlaybackEvent(this->mBlinkSuccessEvent, this->GetShootAnimation()); - this->mTimeOfNextBlinkEvent = UTIL_WeaponTimeBase() + kEventDelay; - } +// if(this->mTimeOfNextBlinkEvent <= 0) +// { +// const float kEventDelay = 2.0f; +// this->PlaybackEvent(this->mBlinkSuccessEvent, this->GetShootAnimation()); +// this->mTimeOfNextBlinkEvent = UTIL_WeaponTimeBase() + kEventDelay; +// } } bool AvHBlinkGun::GetMustPressTriggerForEachShot() const diff --git a/releases/3.2.0/source/mod/AvHEvents.cpp b/releases/3.2.0/source/mod/AvHEvents.cpp index d98171e7..5b7a3f63 100644 --- a/releases/3.2.0/source/mod/AvHEvents.cpp +++ b/releases/3.2.0/source/mod/AvHEvents.cpp @@ -3016,7 +3016,7 @@ void EV_Leap(struct event_args_s* inArgs) { char* theSoundToPlay = kLeapSound; - gEngfuncs.pEventAPI->EV_PlaySound(inArgs->entindex, inArgs->origin, CHAN_WEAPON, theSoundToPlay, inArgs->fparam1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf )); + // gEngfuncs.pEventAPI->EV_PlaySound(inArgs->entindex, inArgs->origin, CHAN_WEAPON, theSoundToPlay, inArgs->fparam1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf )); if (EV_IsLocal(inArgs->entindex)) { diff --git a/releases/3.2.0/source/mod/AvHPlayer.cpp b/releases/3.2.0/source/mod/AvHPlayer.cpp index d2af9fe5..365a65cd 100644 --- a/releases/3.2.0/source/mod/AvHPlayer.cpp +++ b/releases/3.2.0/source/mod/AvHPlayer.cpp @@ -3593,6 +3593,8 @@ void AvHPlayer::Init() this->mNumSensory=0; this->mNumMovement=0; this->mNumDefense=0; + + this->mTimeOfLastMovementSound = -1.0f; } void AvHPlayer::InitializeFromTeam(float inHealthPercentage, float inArmorPercentage) @@ -6802,51 +6804,91 @@ void AvHPlayer::InternalPreThink() // Charge pushback void AvHPlayer::InternalMovementThink() { - // Ensure that we do leap damage - if(GetHasUpgrade(this->pev->iuser4, MASK_ALIEN_MOVEMENT) && (GetUser3() == AVH_USER3_ALIEN_PLAYER1)) - this->StartLeap(); + const char *theSoundToPlay; + bool thePlaySound = false; + float theSoundDelay = 0.0f; - // Check whether we're in a charge + // SKULK + if(GetHasUpgrade(this->pev->iuser4, MASK_ALIEN_MOVEMENT) && (GetUser3() == AVH_USER3_ALIEN_PLAYER1)) + { + thePlaySound = true; + theSoundDelay = kLeapROF; + theSoundToPlay = kLeapSound; + + // Ensure that we do leap damage + this->StartLeap(); + } + + // FADE + if(GetHasUpgrade(this->pev->iuser4, MASK_ALIEN_MOVEMENT) && (GetUser3() == AVH_USER3_ALIEN_PLAYER4)) + { + thePlaySound = true; + theSoundDelay = 2.0f; + theSoundToPlay = kBlinkSound; + } + + // ONOS if(GetHasUpgrade(this->pev->iuser4, MASK_ALIEN_MOVEMENT) && (GetUser3() == AVH_USER3_ALIEN_PLAYER5)) { + thePlaySound = true; + theSoundDelay = 2.0f; + theSoundToPlay = "weapons/charge2.wav"; + + // Push back players CBaseEntity* theEntity = NULL; float radius = (float)BALANCE_VAR(kChargePushbackRadius); float maxpushbackspeedfactor = (float)BALANCE_VAR(kChargeMaxPushbackSpeedFactor); float pushbackfactor = (float)BALANCE_VAR(kChargeMaxPushbackForce); - // Find all entities around the onos - while((theEntity = UTIL_FindEntityInSphere(theEntity, this->pev->origin, radius)) != NULL) - { - if (theEntity->IsPlayer() && theEntity->IsAlive()) + // Ensure that we don't push back players in the readyroom + if (this->GetPlayMode() == PLAYMODE_PLAYING) + { + // Find all entities around the onos + while((theEntity = UTIL_FindEntityInSphere(theEntity, this->pev->origin, radius)) != NULL) { - float distance = VectorDistance(this->pev->origin, theEntity->pev->origin); - if (distance > 0.0f) + if (theEntity->IsPlayer() && theEntity->IsAlive()) { - float factor = pushbackfactor / (radius / distance); - vec3_t direction, heading; - VectorSubtract(theEntity->pev->origin, this->pev->origin, direction); - VectorNormalize(direction); - - VectorCopy(this->pev->velocity, heading); - VectorNormalize(heading); - - float dot = DotProduct(heading, direction); - if (dot > 0.0f) + float distance = VectorDistance(this->pev->origin, theEntity->pev->origin); + if (distance > 0.0f) { - VectorScale(direction, factor * dot, direction); - VectorAdd(theEntity->pev->velocity, direction, theEntity->pev->velocity); - theEntity->pev->velocity[2] = max(181, theEntity->pev->velocity[2]); - if (Length(theEntity->pev->velocity) > theEntity->pev->maxspeed * maxpushbackspeedfactor) - { - VectorNormalize(theEntity->pev->velocity); - VectorScale(theEntity->pev->velocity, theEntity->pev->maxspeed * maxpushbackspeedfactor, theEntity->pev->velocity); - } - } + float factor = pushbackfactor / (radius / distance); + vec3_t direction, heading; + VectorSubtract(theEntity->pev->origin, this->pev->origin, direction); + VectorNormalize(direction); - // ALERT(at_console, UTIL_VarArgs("direction %f %f %f heading %f %f %f endvel %f %f %f\n", direction[0], direction[1], direction[2], heading[0], heading[1], heading[2], theEntity->pev->velocity[0], theEntity->pev->velocity[1], theEntity->pev->velocity[2])); + VectorCopy(this->pev->velocity, heading); + VectorNormalize(heading); + + float dot = DotProduct(heading, direction); + if (dot > 0.0f) + { + VectorScale(direction, factor * dot, direction); + VectorAdd(theEntity->pev->velocity, direction, theEntity->pev->velocity); + theEntity->pev->velocity[2] = max(181, theEntity->pev->velocity[2]); + if (Length(theEntity->pev->velocity) > theEntity->pev->maxspeed * maxpushbackspeedfactor) + { + VectorNormalize(theEntity->pev->velocity); + VectorScale(theEntity->pev->velocity, theEntity->pev->maxspeed * maxpushbackspeedfactor, theEntity->pev->velocity); + } + } + + // ALERT(at_console, UTIL_VarArgs("direction %f %f %f heading %f %f %f endvel %f %f %f\n", direction[0], direction[1], direction[2], heading[0], heading[1], heading[2], theEntity->pev->velocity[0], theEntity->pev->velocity[1], theEntity->pev->velocity[2])); + } } } - } + } + } + + if (thePlaySound && (mTimeOfLastMovementSound + theSoundDelay < gpGlobals->time)) + { + float theVolumeScalar = this->GetAlienAdjustedEventVolume(); + if (this->GetPlayMode() != PLAYMODE_PLAYING) + theVolumeScalar *= 0.2f; + float thePitch = 94.0f + (float)RANDOM_LONG(0, 16); + + EMIT_SOUND_DYN(ENT(this->pev), CHAN_WEAPON, theSoundToPlay, theVolumeScalar, ATTN_NORM, 0, 100); + + this->mTimeOfLastMovementSound = gpGlobals->time; } } diff --git a/releases/3.2.0/source/mod/AvHPlayer.h b/releases/3.2.0/source/mod/AvHPlayer.h index 8f2a072b..42492345 100644 --- a/releases/3.2.0/source/mod/AvHPlayer.h +++ b/releases/3.2.0/source/mod/AvHPlayer.h @@ -653,6 +653,8 @@ private: float mTimeOfLastEnemySighting; bool mEnemySighted; + float mTimeOfLastMovementSound; + bool mTriggerUncloak; bool mHasLeftReadyRoom; diff --git a/releases/3.2.0/source/pm_shared/pm_shared.cpp b/releases/3.2.0/source/pm_shared/pm_shared.cpp index 0e7c158b..58f3595f 100644 --- a/releases/3.2.0/source/pm_shared/pm_shared.cpp +++ b/releases/3.2.0/source/pm_shared/pm_shared.cpp @@ -217,6 +217,12 @@ vec3_t gSurfaceNormal = { 0, 0, 0 }; bool canWallJump = false; // :tankefugl +#ifdef AVH_SERVER +bool gCanMove[MAX_CLIENTS]; +#else +bool gCanMove; +#endif + #ifdef AVH_CLIENT extern vec3_t gPlayerAngles; extern vec3_t gTargetPlayerAngles; @@ -4368,10 +4374,6 @@ bool PM_BlinkMove (void) SetUpgradeMask(&pmove->iuser4, MASK_ALIEN_MOVEMENT, true); - int theSilenceUpgradeLevel = AvHGetAlienUpgradeLevel(pmove->iuser4, MASK_UPGRADE_6); - float theVolumeScalar = 1.0f - theSilenceUpgradeLevel/3.0f; - PM_NSPlaySound(CHAN_WEAPON, kBlinkSound, theVolumeScalar, ATTN_NORM, 0, 94 + pmove->RandomLong(0, 0xf)); - vec3_t forward, right, up; AngleVectors(pmove->angles, forward, right, up); @@ -4481,10 +4483,6 @@ bool PM_LeapMove() SetUpgradeMask(&pmove->iuser4, MASK_ALIEN_MOVEMENT, true); - int theSilenceUpgradeLevel = AvHGetAlienUpgradeLevel(pmove->iuser4, MASK_UPGRADE_6); - float theVolumeScalar = 1.0f - theSilenceUpgradeLevel/3.0f; - PM_NSPlaySound(CHAN_WEAPON, kLeapSound, theVolumeScalar, ATTN_NORM, 0, 94 + pmove->RandomLong(0, 0xf)); - vec3_t forward, right, up; AngleVectors(pmove->angles, forward, right, up); @@ -4641,9 +4639,6 @@ bool PM_ChargeMove() AvHMUDeductAlienEnergy(pmove->fuser3, theEnergyCost); if (pmove->fuser4 == 0.0f) { - int theSilenceUpgradeLevel = AvHGetAlienUpgradeLevel(pmove->iuser4, MASK_UPGRADE_6); - float theVolumeScalar = 1.0f - theSilenceUpgradeLevel/3.0f; - PM_NSPlaySound( CHAN_WEAPON, "weapons/charge2.wav", theVolumeScalar, ATTN_NORM, 0, PITCH_NORM ); pmove->fuser4 = 0.3f; } pmove->fuser4 += (float)pmove->frametime; @@ -4707,9 +4702,9 @@ void PM_AlienAbilities() bool canmove = true; #ifdef AVH_SERVER - //canmove = gCanMove[pmove->player_index]; + canmove = gCanMove[pmove->player_index]; #else - //canmove = gCanMove; + canmove = gCanMove; #endif bool success = false; if ((pmove->cmd.buttons & IN_ATTACK2) && (AvHGetIsAlien(pmove->iuser3)))