|
|
|
The scientists at Black Mesa have been hard at work adding a freeze ray to the secondary fire on the Egon gun. The freeze ray will "freeze" a player in their tracks and prevent them from moving (it will even freeze them in mid-air). The freeze ray will only fire in short bursts (2/10ths of a second) and takes 5 seconds to recharge after firing. The player who is frozen will not be able to move for 3 seconds and they will see a blue screen fading back to normal during this time. The other players in the game will see a blue glowing shell around the player to indicate that the player is frozen.
If you wanted to be really fair to the frozen player, you could make further modifications so that the only weapon that would do damage to the frozen player would be the crowbar. That way the frozen player would have half a chance to get away after being frozen. As it is right now, it's WAY TOO EASY to freeze the player then hold the primary fire on the Egon gun until the frozen player is dead.
The original code in the files will be shown in CYAN.
The new code in the files will be shown in RED.
Open up egon.cpp in your favorite editor...
search for "gamerules.h" and add the following line after it...
#include "gamerules.h" #include "..\engine\shake.h"
In class CEgon : public CBasePlayerWeapon...
after
void PrimaryAttack( void );add
void SecondaryAttack( void );and after
BOOL m_deployed;add
float m_attackEndTime;
in CEgon::Spawn...
after
m_iDefaultAmmo = EGON_DEFAULT_GIVE;add
m_attackEndTime = 0;
in CEgon::Attack...
change
if (m_pPlayer->pev->waterlevel == 3) { if ( m_pBeam )to
if (m_pPlayer->pev->waterlevel == 3) { if (( m_pBeam ) || ( m_pNoise ))
after
void CEgon::PrimaryAttack( void ) { m_fireMode = FIRE_WIDE; Attack(); }add
void CEgon::SecondaryAttack( void ) { m_fireMode = FIRE_NARROW; if (m_attackEndTime == 0) m_attackEndTime = gpGlobals->time + 0.2; else if (m_attackEndTime <= gpGlobals->time) { if ( m_fireState != FIRE_OFF ) EndAttack(); m_flNextSecondaryAttack = gpGlobals->time + 5.0; return; } Attack(); }
in CEgon::Fire...
after
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);add
CBasePlayer *pPlayer = (CBasePlayer *)pEntity;and change
case FIRE_NARROW: if ( pev->dmgtime < gpGlobals->time ) { // Narrow mode only does damage to the entity it hits ClearMultiDamage(); if (pEntity->pev->takedamage) { pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM ); } ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); if ( g_pGameRules->IsMultiplayer() ) { // multiplayer uses 1 ammo every 1/10th second if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.1; } } else { // single player, use 3 ammo/second if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.166; } } pev->dmgtime = gpGlobals->time + GetPulseInterval(); } timedist = ( pev->dmgtime - gpGlobals->time ) / GetPulseInterval(); break;to
case FIRE_NARROW: UTIL_ScreenFade( pPlayer, Vector(0,0,255), 2.0, 1.0, 128, FFADE_IN ); pPlayer->pev->rendermode = kRenderNormal; pPlayer->pev->renderfx = kRenderFxGlowShell; pPlayer->pev->rendercolor.x = 0; // red pPlayer->pev->rendercolor.y = 0; // green pPlayer->pev->rendercolor.z = 255; // blue pPlayer->pev->renderamt = 10; // glow shell distance from entity // freeze the player and set the "unfreeze" time... pPlayer->EnableControl(FALSE); pPlayer->m_vFreezeAngle = pPlayer->pev->v_angle; pPlayer->m_flFreezeTime = gpGlobals->time + 3.0; if ( g_pGameRules->IsMultiplayer() ) { // multiplayer uses 1 ammo every 1/10th second if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.1; } } else { // single player, use 3 ammo/second if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.166; } } break;
in CEgon::UpdateEffect...
change
if ( !m_pBeam )to
if (( !m_pBeam ) && ( !m_pNoise ))
and change
m_pBeam->SetStartPos( endPoint ); m_pBeam->SetBrightness( 255 - (timeBlend*180) ); m_pBeam->SetWidth( 40 - (timeBlend*20) );to
if ( m_fireMode == FIRE_WIDE ) { m_pBeam->SetStartPos( endPoint ); m_pBeam->SetBrightness( 255 - (timeBlend*180) ); m_pBeam->SetWidth( 40 - (timeBlend*20) ); }
then change
if ( m_fireMode == FIRE_WIDE ) m_pBeam->SetColor( 30 + (25*timeBlend), 30 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); else m_pBeam->SetColor( 60 + (25*timeBlend), 120 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) );to
if ( m_fireMode == FIRE_WIDE ) m_pBeam->SetColor( 30 + (25*timeBlend), 30 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) );
in CEgon::CreateEffect...
change
m_pBeam = CBeam::BeamCreate( EGON_BEAM_SPRITE, 40 ); m_pBeam->PointEntInit( pev->origin, m_pPlayer->entindex() ); m_pBeam->SetFlags( BEAM_FSINE ); m_pBeam->SetEndAttachment( 1 ); m_pBeam->pev->spawnflags |= SF_BEAM_TEMPORARY; // Flag these to be destroyed on save/restore or level transition m_pNoise = CBeam::BeamCreate( EGON_BEAM_SPRITE, 55 ); m_pNoise->PointEntInit( pev->origin, m_pPlayer->entindex() ); m_pNoise->SetScrollRate( 25 ); m_pNoise->SetBrightness( 100 ); m_pNoise->SetEndAttachment( 1 ); m_pNoise->pev->spawnflags |= SF_BEAM_TEMPORARY;to
if ( m_fireMode == FIRE_WIDE ) { m_pBeam = CBeam::BeamCreate( EGON_BEAM_SPRITE, 40 ); m_pBeam->PointEntInit( pev->origin, m_pPlayer->entindex() ); m_pBeam->SetFlags( BEAM_FSINE ); m_pBeam->SetEndAttachment( 1 ); m_pBeam->pev->spawnflags |= SF_BEAM_TEMPORARY; // Flag these to be destroyed on save/restore or level transition m_pNoise = CBeam::BeamCreate( EGON_BEAM_SPRITE, 55 ); m_pNoise->PointEntInit( pev->origin, m_pPlayer->entindex() ); m_pNoise->SetScrollRate( 25 ); m_pNoise->SetBrightness( 100 ); m_pNoise->SetEndAttachment( 1 ); m_pNoise->pev->spawnflags |= SF_BEAM_TEMPORARY; } else { m_pNoise = CBeam::BeamCreate( EGON_BEAM_SPRITE, 55 ); m_pNoise->PointEntInit( pev->origin, m_pPlayer->entindex() ); m_pNoise->SetScrollRate( 50 ); m_pNoise->SetBrightness( 255 ); m_pNoise->SetEndAttachment( 1 ); m_pNoise->pev->spawnflags |= SF_BEAM_TEMPORARY; }
and change
if ( m_fireMode == FIRE_WIDE ) { m_pBeam->SetScrollRate( 50 ); m_pBeam->SetNoise( 20 ); m_pNoise->SetColor( 50, 50, 255 ); m_pNoise->SetNoise( 8 ); } else { m_pBeam->SetScrollRate( 110 ); m_pBeam->SetNoise( 5 ); m_pNoise->SetColor( 80, 120, 255 ); m_pNoise->SetNoise( 2 ); }to
if ( m_fireMode == FIRE_WIDE ) { m_pBeam->SetScrollRate( 50 ); m_pBeam->SetNoise( 20 ); m_pNoise->SetColor( 50, 50, 255 ); m_pNoise->SetNoise( 8 ); } else { m_pNoise->SetColor( 10, 10, 255 ); // bright blue m_pNoise->SetNoise( 2 ); }
in CEgon::EndAttack...
change
m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.5; DestroyEffect();to
m_flNextPrimaryAttack = gpGlobals->time + 0.5; if (m_attackEndTime > 0) { m_attackEndTime = 0; m_flNextSecondaryAttack = gpGlobals->time + 5.0; } DestroyEffect();
Now save the modified egon.cpp file and open the player.h file...
after
float m_flWallJumpTime; // how long until next walljumpadd
float m_flFreezeTime; // when to unfreeze the player Vector m_vFreezeAngle; // angles when frozen
Now save the modified player.h file and open the player.cpp file...
in CBasePlayer::PreThink...
after
m_afButtonPressed = buttonsChanged & pev->button; // The changed ones still down are "pressed" m_afButtonReleased = buttonsChanged & (~pev->button); // The ones not down are "released"add
if (m_flFreezeTime > 0) { if (m_flFreezeTime <= gpGlobals->time) { EnableControl(TRUE); pev->rendermode = kRenderNormal; pev->renderfx = kRenderFxNone; pev->renderamt = 0; m_flFreezeTime = 0; } else { pev->v_angle = m_vFreezeAngle; pev->fixangle = TRUE; } }
in CBasePlayer::Spawn...
after
m_lastx = m_lasty = 0;add
m_flFreezeTime = 0;
Now save the modified player.cpp file, rebuild the mp.dll file and you
should be able to use the secondary fire on the Egon gun to freeze
players!
Any questions or suggestions should be sent to me:
botman@mailandnews.com