void CShotgun::SecondaryAttack( void ) { // don't fire underwater if (m_pPlayer->pev->waterlevel == 3 && m_pPlayer->pev->watertype > CONTENT_FLYFIELD) { PlayEmptySound( ); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } if (m_iClip <= 1) { Reload( ); PlayEmptySound( ); return; } m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; m_iClip -= 2; int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); Vector vecSrc = m_pPlayer->GetGunPosition( ); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); #ifndef CLIENT_DLL MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_DLIGHT ); WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_BYTE( 16 ); // radius WRITE_BYTE( 255 ); // R WRITE_BYTE( 255 ); // G WRITE_BYTE( 160 ); // B WRITE_BYTE( 0 ); // life * 10 WRITE_BYTE( 0 ); // decay MESSAGE_END(); #endif Vector vecDir; #ifdef CLIENT_DLL if ( bIsMultiplayer() ) #else if ( g_pGameRules->IsMultiplayer() ) #endif { // tuned for deathmatch vecDir = m_pPlayer->FireBulletsPlayer( 8, vecSrc, vecAiming, VECTOR_CONE_DM_DOUBLESHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); } else { // untouched default single player vecDir = m_pPlayer->FireBulletsPlayer( 12, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); } PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usDoubleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); if (m_iClip != 0) m_flPumpTime = gpGlobals->time + 0.95; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5; if (m_iClip != 0) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0; else m_flTimeWeaponIdle = 1.5; m_fInSpecialReload = 0; }
FileIoBackend::FileIoBackend(const QString& filename, const QString& soc_name) { m_filename = filename; m_soc = soc_name; Reload(); }
void c_main(char *blockBase, u32 blockSize) { int numRead = 0; char commandline[128]; blobStatus status; int i; int retval = 0; /* We really want to be able to communicate, so initialise the * serial port at 9k6 (which works good for terminals) */ SerialInit(baud9k6); TimerInit(); /* initialise status */ status.kernelSize = 0; status.kernelType = fromFlash; status.ramdiskSize = 0; status.ramdiskType = fromFlash; status.blockSize = blockSize; status.downloadSpeed = baud115k2; /* Load kernel and ramdisk from flash to RAM */ Reload("kernel", &status); Reload("ramdisk", &status); /* Print the required GPL string */ SerialOutputString("\r" PACKAGE " version " VERSION "\r" "Copyright (C) 1999 2000 " "Jan-Derk Bakker and Erik Mouw\r" "Copyright (C) 2000 " "Johan Pouwelse.\r"); SerialOutputString(PACKAGE " comes with ABSOLUTELY NO WARRANTY; " "read the GNU GPL for details.\r"); SerialOutputString("This is free software, and you are welcome " "to redistribute it\r"); SerialOutputString("under certain conditions; " "read the GNU GPL for details.\r\r"); /* and some information */ #ifdef BLOB_DEBUG SerialOutputString("Running from "); if(RunningFromInternal()) SerialOutputString("internal flash\r"); else SerialOutputString("external flash\r"); SerialOutputString("blockBase = 0x"); SerialOutputHex((int) blockBase); SerialOutputString(", blockSize = 0x"); SerialOutputHex(blockSize); SerialOutputByte('\r'); #endif /* wait 10 seconds before starting autoboot */ SerialOutputString("Autoboot in progress, press any key to stop "); for(i = 0; i < 10; i++) { SerialOutputByte('.'); retval = SerialInputBlock(commandline, 1, 1); if(retval > 0) break; } /* no key was pressed, so proceed booting the kernel */ if(retval == 0) { commandline[0] = '\0'; BootKernel(commandline); } SerialOutputString("\rAutoboot aborted\r"); SerialOutputString("Type \"help\" to get a list of commands\r"); /* the command loop. endless, of course */ for(;;) { DisplayPrompt(NULL); /* wait an hour to get a command */ numRead = GetCommand(commandline, 128, 3600); if(numRead > 0) { if(MyStrNCmp(commandline, "boot", 4) == 0) { BootKernel(commandline + 4); } else if(MyStrNCmp(commandline, "clock", 5) == 0) { SetClock(commandline + 5); } else if(MyStrNCmp(commandline, "download ", 9) == 0) { Download(commandline + 9, &status); } else if(MyStrNCmp(commandline, "flash ", 6) == 0) { Flash(commandline + 6, &status); } else if(MyStrNCmp(commandline, "help", 4) == 0) { PrintHelp(); } else if(MyStrNCmp(commandline, "reload ", 7) == 0) { Reload(commandline + 7, &status); } else if(MyStrNCmp(commandline, "reset", 5) == 0) { ResetTerminal(); } else if(MyStrNCmp(commandline, "speed ", 6) == 0) { SetDownloadSpeed(commandline + 6, &status); } else if(MyStrNCmp(commandline, "status", 6) == 0) { PrintStatus(&status); } else { SerialOutputString("*** Unknown command: "); SerialOutputString(commandline); SerialOutputByte('\r'); } } } } /* c_main */
void SPTexture::Load() { Reload(); }
/* ===================== CBasePlayerWeapon::ItemPostFrame Handles weapon firing, reloading, etc. ===================== */ void CBasePlayerWeapon::ItemPostFrame( void ) { if ((m_fInReload) && (m_pPlayer->m_flNextAttack <= 0.0)) { #if 0 // FIXME, need ammo on client to make this work right // complete the reload. int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); // Add them to the clip m_iClip += j; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; #else m_iClip += 10; #endif m_fInReload = FALSE; } if ((m_pPlayer->pev->button & IN_ATTACK2) && (m_flNextSecondaryAttack <= 0.0)) { if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) { m_fFireOnEmpty = TRUE; } SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } else if ((m_pPlayer->pev->button & IN_ATTACK) && (m_flNextPrimaryAttack <= 0.0)) { if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) { m_fFireOnEmpty = TRUE; } PrimaryAttack(); } else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. Reload(); } else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) ) { // no fire buttons down m_fFireOnEmpty = FALSE; // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < 0.0 ) { Reload(); return; } WeaponIdle( ); return; } // catch all if ( ShouldWeaponIdle() ) { WeaponIdle(); } }
bool CWayPointManager::Load( const std::string& filename ) { m_Filename = filename; return Reload(); }
CAudioSystemEditor_wwise::CAudioSystemEditor_wwise() { Reload(); }
ShaderLib::ShaderLib(CoreLib::Basic::String fileName) { Reload(fileName); }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- bool EffectImplemented::Reload( void* data, int32_t size, const EFK_CHAR* materialPath ) { if(m_pManager == NULL ) return false; return Reload( m_pManager, 1, data, size, materialPath ); }
void CHgun::SecondaryAttack(void) { Reload(); if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) return; CBaseEntity *pHornet; Vector vecSrc; UTIL_MakeVectors(m_pPlayer->pev->v_angle); vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12; m_iFirePhase++; switch (m_iFirePhase) { case 1: vecSrc = vecSrc + gpGlobals->v_up * 8; break; case 2: vecSrc = vecSrc + gpGlobals->v_up * 8; vecSrc = vecSrc + gpGlobals->v_right * 8; break; case 3: vecSrc = vecSrc + gpGlobals->v_right * 8; break; case 4: vecSrc = vecSrc + gpGlobals->v_up * -8; vecSrc = vecSrc + gpGlobals->v_right * 8; break; case 5: vecSrc = vecSrc + gpGlobals->v_up * -8; break; case 6: vecSrc = vecSrc + gpGlobals->v_up * -8; vecSrc = vecSrc + gpGlobals->v_right * -8; break; case 7: vecSrc = vecSrc + gpGlobals->v_right * -8; break; case 8: vecSrc = vecSrc + gpGlobals->v_up * 8; vecSrc = vecSrc + gpGlobals->v_right * -8; m_iFirePhase = 0; break; } pHornet = CBaseEntity::Create("hornet", vecSrc, m_pPlayer->pev->v_angle, m_pPlayer->edict()); pHornet->pev->velocity = gpGlobals->v_forward * 1200; pHornet->pev->angles = UTIL_VecToAngles(pHornet->pev->velocity); pHornet->SetThink(&CHornet::StartDart); m_flRechargeTime = gpGlobals->time + 0.5; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; SendWeaponAnim(HGUN_SHOOT); // player "shoot" animation m_pPlayer->SetAnimation(PLAYER_ATTACK1); m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_GlobalTimeBase() + 0.1; m_flTimeWeaponIdle = UTIL_GlobalTimeBase() + RANDOM_LONG(10, 15); m_pPlayer->pev->punchangle.x = RANDOM_FLOAT(0, 2); }
bool Weapon::FrameNext(float dt) { SPADES_MARK_FUNCTION(); bool ownerIsLocalPlayer = owner->IsLocalPlayer(); bool fired = false; bool dryFire = false; if (shooting && (!reloading || IsReloadSlow())) { // abort slow reload reloading = false; if (!shootingPreviously) { nextShotTime = std::max(nextShotTime, time); } // Automatic operation of weapon. if (time >= nextShotTime && (ammo > 0 || !ownerIsLocalPlayer)) { fired = true; // Consume an ammo. // Ammo count tracking is disabled for remote players because the server doesn't // send enough information for us to do that. if (ownerIsLocalPlayer) { ammo--; } if (world->GetListener()) { world->GetListener()->PlayerFiredWeapon(owner); } nextShotTime += GetDelay(); } else if (time >= nextShotTime) { dryFire = true; } shootingPreviously = true; } else { shootingPreviously = false; } if (reloading) { if (time >= reloadEndTime) { // reload done reloading = false; if (IsReloadSlow()) { // for local player, server sends // new ammo/stock value if (ammo < GetClipSize() && stock > 0 && !ownerIsLocalPlayer) { ammo++; stock--; } slowReloadLeftCount--; if (slowReloadLeftCount > 0) Reload(false); else if (world->GetListener()) world->GetListener()->PlayerReloadedWeapon(owner); } else { // for local player, server sends // new ammo/stock value if (!ownerIsLocalPlayer) { int newStock; newStock = std::max(0, stock - GetClipSize() + ammo); ammo += stock - newStock; stock = newStock; } if (world->GetListener()) world->GetListener()->PlayerReloadedWeapon(owner); } } } time += dt; if (dryFire && !lastDryFire) { if (world->GetListener()) world->GetListener()->PlayerDryFiredWeapon(owner); } lastDryFire = dryFire; return fired; }
/* ===================== CBasePlayerWeapon::ItemPostFrame Handles weapon firing, reloading, etc. ===================== */ void CBasePlayerWeapon::ItemPostFrame( void ) { WeaponTick(); if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { #ifdef SERVER_DLL // FIXME, need ammo on client to make this work right // complete the reload. int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] ); // Add them to the clip m_iClip += j; m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] -= j; #else m_iClip += 10; #endif m_fInReload = false; } #ifdef SERVER_DLL if( !m_pPlayer->GetButtons().Any( IN_ATTACK ) ) { m_flLastFireTime = 0.0f; } #endif if( m_pPlayer->GetButtons().Any( IN_ATTACK2 ) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, IsPredicted() ) ) { if( pszAmmo2() && !m_pPlayer->m_rgAmmo[ SecondaryAmmoIndex() ] ) { m_bFireOnEmpty = true; } SecondaryAttack(); m_pPlayer->GetButtons().ClearFlags( IN_ATTACK2 ); } else if( m_pPlayer->GetButtons().Any( IN_ATTACK ) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, IsPredicted() ) ) { if( ( m_iClip == 0 && pszAmmo1() ) || ( iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] ) ) { m_bFireOnEmpty = true; } PrimaryAttack(); } else if( m_pPlayer->GetButtons().Any( IN_RELOAD ) && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. Reload(); } else if( !m_pPlayer->GetButtons().Any( IN_ATTACK | IN_ATTACK2 ) ) { // no fire buttons down m_bFireOnEmpty = false; //Only the server checks for weapon switching. - Solokiller #ifdef SERVER_DLL if( !IsUseable() && m_flNextPrimaryAttack < ( IsPredicted() ? 0.0 : gpGlobals->time ) ) { // weapon isn't useable, switch. if( !( iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY ) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) { m_flNextPrimaryAttack = ( IsPredicted() ? 0.0 : gpGlobals->time ) + 0.3; return; } } else #endif { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && CanReload( m_flNextPrimaryAttack, gpGlobals->time, IsPredicted() ) ) { Reload(); return; } } WeaponIdle(); return; } // catch all if( ShouldWeaponIdle() ) { WeaponIdle(); } }
void CSharedFilesWnd::OnBnClickedReloadSharedFiles() { CWaitCursor curWait; Reload(); }
//------------------------------------------------------------------------------------------------ void Person::Update(float dt) { if (mGuns[mGunIndex] == NULL) { printf("isPlayerOnline: %i\n",mIsPlayerOnline); printf("invalid gunindex: %i\n",mGunIndex); return; } mStateTime += dt; if (mState == DEAD) { if (mStateTime >= 2000.0f) { mFadeTime -= dt; if (mFadeTime < 0.0f) { mFadeTime = 0.0f; } } return; } mWalkAngle = mAngle; if (mIsActive) { if (mMoveState == NOTMOVING) { if (!mIsPlayerOnline) { mSpeed -= .0005f*dt; if (mSpeed < 0) { mSpeed = 0; } } mStepTime = 240.0f; } else if (mMoveState == MOVING) { if (!mIsPlayerOnline) { mSpeed += .0005f*dt; if (mSpeed > mMaxSpeed) { mSpeed = mMaxSpeed; } } if (mRecoilAngle < mGuns[mGunIndex]->mGun->mSpread*0.5f) { //HERE mRecoilAngle += mGuns[mGunIndex]->mGun->mSpread/50.0f*dt; if (mRecoilAngle > mGuns[mGunIndex]->mGun->mSpread*0.5f) { mRecoilAngle = mGuns[mGunIndex]->mGun->mSpread*0.5f; } } } } if (!mIsPlayerOnline) { mOldX = mX; mOldY = mY; mX += mSpeed * cosf(mAngle) * dt; mY += mSpeed * sinf(mAngle) * dt; } //JSprite::Update(dt); if (mGuns[mGunIndex]->mGun->mId == 7 || mGuns[mGunIndex]->mGun->mId == 8) { //HERE mRecoilAngle = mGuns[mGunIndex]->mGun->mSpread; } mLastFireAngle = mRotation; if (mState == NORMAL) { if (mGuns[mGunIndex]->mGun->mId != 7 && mGuns[mGunIndex]->mGun->mId != 8) { mRecoilAngle -= mGuns[mGunIndex]->mGun->mSpread/100.0f*dt; if (mRecoilAngle < 0) { mRecoilAngle = 0.0f; } } } else if (mState == ATTACKING) { if (mMoveState == NOTMOVING) { mRecoilAngle += mGuns[mGunIndex]->mGun->mSpread/500.0f*dt; } else if (mMoveState == MOVING) { mRecoilAngle += mGuns[mGunIndex]->mGun->mSpread/50.0f*dt; } if (mGuns[mGunIndex]->mGun->mId == 16 || mGuns[mGunIndex]->mGun->mId == 21 || mGuns[mGunIndex]->mGun->mId == 22 || mGuns[mGunIndex]->mGun->mId == 23) { mRecoilAngle = mGuns[mGunIndex]->mGun->mSpread; } if (mRecoilAngle > mGuns[mGunIndex]->mGun->mSpread) { mRecoilAngle = mGuns[mGunIndex]->mGun->mSpread; } if (mRecoilAngle*500.0f >= 0.1f && mStateTime < 100.0f) { mLastFireAngle += (rand()%(int)ceilf(mRecoilAngle*500.0f))/1000.0f-(mRecoilAngle/4.0f); } if (mStateTime >= mGuns[mGunIndex]->mGun->mDelay) { if (mGunIndex == GRENADE) { mStateTime = mGuns[mGunIndex]->mGun->mDelay; } else { SetState(NORMAL); } } } else if (mState == RELOADING) { if (mStateTime >= mGuns[mGunIndex]->mGun->mReloadDelay) { mGuns[mGunIndex]->mRemainingAmmo -= (mGuns[mGunIndex]->mGun->mClip-mGuns[mGunIndex]->mClipAmmo); mGuns[mGunIndex]->mClipAmmo = mGuns[mGunIndex]->mGun->mClip; if (mGuns[mGunIndex]->mRemainingAmmo < 0) { mGuns[mGunIndex]->mClipAmmo = mGuns[mGunIndex]->mGun->mClip + mGuns[mGunIndex]->mRemainingAmmo ; mGuns[mGunIndex]->mRemainingAmmo = 0; } SetState(NORMAL); } if (mGuns[mGunIndex]->mGun->mId != 7 && mGuns[mGunIndex]->mGun->mId != 8) { mRecoilAngle -= mGuns[mGunIndex]->mGun->mSpread/100.0f*dt; if (mRecoilAngle < 0.0f) { mRecoilAngle = 0.0f; } } } else if (mState == DRYFIRING) { if (mGunIndex == PRIMARY) { if (mStateTime >= 250.0f) { SetState(NORMAL); mNumDryFire++; } } else if (mGunIndex == SECONDARY) { SetState(NORMAL); mNumDryFire++; } else if (mGunIndex == KNIFE) { if (mStateTime >= mGuns[mGunIndex]->mGun->mDelay) { SetState(NORMAL); } } } else if (mState == SWITCHING) { if (mGunIndex == PRIMARY || mGunIndex == SECONDARY) { float delay = mGuns[mGunIndex]->mGun->mDelay*0.75f; if (delay < 150.0f) delay = 150.0f; if (mStateTime >= delay) { SetState(NORMAL); } } else { if (mStateTime >= 150.0f) { SetState(NORMAL); } } } if (!mIsPlayerOnline) { if (mNumDryFire > 3) { Reload(); } } if (mIsFlashed) { mFlashTime -= dt/mFlashIntensity; if (mFlashTime < 0.0f) { mFlashTime = 0.0f; mIsFlashed = false; } } mMuzzleFlashTime -= dt; if (mMuzzleFlashTime < 0.0f) { mMuzzleFlashTime = 0.0f; } mRadarTime -= dt; if (mRadarTime < 0.0f) { mRadarTime = 0.0f; } mCurrentAnimation->Update(dt,mKeyFrame); mInvincibleTime -= dt; if (mInvincibleTime < 0.0f) { mInvincibleTime = 0.0f; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCrossbow::FireBolt( void ) { if ( m_iClip1 <= 0 ) { if ( !m_bFireOnEmpty ) { Reload(); } else { WeaponSound( EMPTY ); m_flNextPrimaryAttack = 0.15; } return; } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; pOwner->RumbleEffect( RUMBLE_357, 0, RUMBLE_FLAG_RESTART ); Vector vecAiming = pOwner->GetAutoaimVector( 0 ); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles( vecAiming, angAiming ); #if defined(HL2_EPISODIC) // !!!HACK - the other piece of the Alyx crossbow bolt hack for Outland_10 (see ::BoltTouch() for more detail) if( FStrEq(STRING(gpGlobals->mapname), "ep2_outland_10") ) { trace_t tr; UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 24.0f, MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr ); if( tr.m_pEnt != NULL && tr.m_pEnt->Classify() == CLASS_PLAYER_ALLY_VITAL ) { // If Alyx is right in front of the player, make sure the bolt starts outside of the player's BBOX, or the bolt // will instantly collide with the player after the owner of the bolt is switched to Alyx in ::BoltTouch(). We // avoid this altogether by making it impossible for the bolt to collide with the player. vecSrc += vecAiming * 24.0f; } } #endif CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate( vecSrc, angAiming, pOwner ); if ( pOwner->GetWaterLevel() == 3 ) { pBolt->SetAbsVelocity( vecAiming * BOLT_WATER_VELOCITY ); } else { pBolt->SetAbsVelocity( vecAiming * BOLT_AIR_VELOCITY ); } m_iClip1--; pOwner->ViewPunch( QAngle( -2, 0, 0 ) ); WeaponSound( SINGLE ); WeaponSound( SPECIAL2 ); CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 200, 0.2 ); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); if ( !m_iClip1 && pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { // HEV suit - indicate out of ammo condition pOwner->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState( CHARGER_STATE_DISCHARGE ); }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- bool EffectImplemented::Reload( const EFK_CHAR* path, const EFK_CHAR* materialPath ) { if(m_pManager == NULL ) return false; return Reload( m_pManager, 1, path, materialPath ); }
bool CParticleSettingsManager::Load( const std::string& filename ) { m_Filename = filename; return Reload(); }
//----------------------------------------------------------------------------- // Purpose: Overloaded to handle the zoom functionality. //----------------------------------------------------------------------------- void CWeaponSniperRifle::ItemPostFrame( void ) { CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if (pPlayer == NULL) { return; } if ((m_bInReload) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) { FinishReload(); m_bInReload = false; } if (pPlayer->m_nButtons & IN_ATTACK2) { if (m_fNextZoom <= gpGlobals->curtime) { Zoom(); pPlayer->m_nButtons &= ~IN_ATTACK2; } } else if ((pPlayer->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) { if ( (m_iClip1 == 0 && UsesClipsForAmmo1()) || ( !UsesClipsForAmmo1() && !pPlayer->GetAmmoCount(m_iPrimaryAmmoType) ) ) { m_bFireOnEmpty = true; } // Fire underwater? if (pPlayer->GetWaterLevel() == 3 && m_bFiresUnderwater == false) { WeaponSound(EMPTY); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; return; } else { // If the firing button was just pressed, reset the firing time if ( pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK ) { m_flNextPrimaryAttack = gpGlobals->curtime; } PrimaryAttack(); } } // ----------------------- // Reload pressed / Clip Empty // ----------------------- if ( pPlayer->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. Reload(); } // ----------------------- // No buttons down // ----------------------- if (!((pPlayer->m_nButtons & IN_ATTACK) || (pPlayer->m_nButtons & IN_ATTACK2) || (pPlayer->m_nButtons & IN_RELOAD))) { // no fire buttons down m_bFireOnEmpty = false; if ( !HasAnyAmmo() && m_flNextPrimaryAttack < gpGlobals->curtime ) { // weapon isn't useable, switch. if ( !(GetWeaponFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && pPlayer->SwitchToNextBestWeapon( this ) ) { m_flNextPrimaryAttack = gpGlobals->curtime + 0.3; return; } } else { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if ( m_iClip1 == 0 && !(GetWeaponFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < gpGlobals->curtime ) { Reload(); return; } } WeaponIdle( ); return; } }
/* <2cab36> ../cstrike/dlls/wpn_shared/wpn_xm1014.cpp:106 */ void CXM1014::__MAKE_VHOOK(PrimaryAttack)(void) { Vector vecAiming, vecSrc, vecDir; int flag; // don't fire underwater if (m_pPlayer->pev->waterlevel == 3) { PlayEmptySound(); m_flNextPrimaryAttack = GetNextAttackDelay(0.15); return; } if (m_iClip <= 0) { Reload(); if (!m_iClip) { PlayEmptySound(); } if (TheBots != NULL) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } m_flNextPrimaryAttack = GetNextAttackDelay(1); return; } m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; // player "shoot" animation m_pPlayer->SetAnimation(PLAYER_ATTACK1); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); vecSrc = m_pPlayer->GetGunPosition(); vecAiming = gpGlobals->v_forward; m_pPlayer->FireBullets(6, vecSrc, vecAiming, XM1014_CONE_VECTOR, 3048, BULLET_PLAYER_BUCKSHOT, 0); #ifdef CLIENT_WEAPONS flag = FEV_NOTHOST; #else flag = 0; #endif // CLIENT_WEAPONS PLAYBACK_EVENT_FULL(flag, m_pPlayer->edict(), m_usFireXM1014, 0, (float *)&g_vecZero, (float *)&g_vecZero, m_vVecAiming.x, m_vVecAiming.y, 7, (int)(m_vVecAiming.x * 100), m_iClip == 0, FALSE); if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } if (m_iClip != 0) m_flPumpTime = UTIL_WeaponTimeBase() + 0.125; m_flNextPrimaryAttack = GetNextAttackDelay(0.25); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25; if (m_iClip != 0) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.25; else m_flTimeWeaponIdle = 0.75; m_fInSpecialReload = 0; if (m_pPlayer->pev->flags & FL_ONGROUND) m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 3, 5); else m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 7, 10); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCrossbow::FireBolt( void ) { if ( m_iClip1 <= 0 ) { if ( !m_bFireOnEmpty ) { Reload(); } else { WeaponSound( EMPTY ); m_flNextPrimaryAttack = 0.15; } return; } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; #ifndef CLIENT_DLL Vector vecAiming = pOwner->GetAutoaimVector( 0 ); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles( vecAiming, angAiming ); CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate( vecSrc, angAiming, GetHL2MPWpnData().m_iPlayerDamage, pOwner ); if ( pOwner->GetWaterLevel() == 3 ) { pBolt->SetAbsVelocity( vecAiming * BOLT_WATER_VELOCITY ); } else { pBolt->SetAbsVelocity( vecAiming * BOLT_AIR_VELOCITY ); } #endif m_iClip1--; pOwner->ViewPunch( QAngle( -2, 0, 0 ) ); WeaponSound( SINGLE ); WeaponSound( SPECIAL2 ); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); if ( !m_iClip1 && pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { // HEV suit - indicate out of ammo condition pOwner->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState( CHARGER_STATE_DISCHARGE ); }
void CHgun::SecondaryAttack( void ) { Reload(); if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { return; } //Wouldn't be a bad idea to completely predict these, since they fly so fast... #ifndef CLIENT_DLL CBaseEntity *pHornet; Vector vecSrc; UTIL_MakeVectors( m_pPlayer->pev->v_angle ); vecSrc = m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12; m_iFirePhase++; switch ( m_iFirePhase ) { case 1: vecSrc = vecSrc + gpGlobals->v_up * 8; break; case 2: vecSrc = vecSrc + gpGlobals->v_up * 8; vecSrc = vecSrc + gpGlobals->v_right * 8; break; case 3: vecSrc = vecSrc + gpGlobals->v_right * 8; break; case 4: vecSrc = vecSrc + gpGlobals->v_up * -8; vecSrc = vecSrc + gpGlobals->v_right * 8; break; case 5: vecSrc = vecSrc + gpGlobals->v_up * -8; break; case 6: vecSrc = vecSrc + gpGlobals->v_up * -8; vecSrc = vecSrc + gpGlobals->v_right * -8; break; case 7: vecSrc = vecSrc + gpGlobals->v_right * -8; break; case 8: vecSrc = vecSrc + gpGlobals->v_up * 8; vecSrc = vecSrc + gpGlobals->v_right * -8; m_iFirePhase = 0; break; } pHornet = CBaseEntity::Create( "hornet", vecSrc, m_pPlayer->pev->v_angle, m_pPlayer->edict() ); pHornet->pev->velocity = gpGlobals->v_forward * 1200; pHornet->pev->angles = UTIL_VecToAngles( pHornet->pev->velocity ); pHornet->SetThink( CHornet::StartDart ); m_flRechargeTime = gpGlobals->time + 0.5; #endif int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, FIREMODE_FAST, 0, 0, 0 ); m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); }
BOOL KScriptManager::Reload(const char* pszFileName) { BOOL bResult = false; BOOL bRetCode = false; IFile* piFile = NULL; char* pszBuffer = NULL; DWORD dwScriptID = 0; DWORD dwFileSize = 0; DWORD dwReadSize = 0; KLuaScriptData* pScriptData = NULL; char szPathName[MAX_PATH]; char szFileName[MAX_PATH]; assert(pszFileName); piFile = g_OpenFile(pszFileName); KG_PROCESS_ERROR(piFile); dwFileSize = piFile->Size(); pszBuffer = new char[dwFileSize]; KG_PROCESS_ERROR(pszBuffer); dwReadSize = piFile->Read(pszBuffer, dwFileSize); KG_PROCESS_ERROR(dwReadSize == dwFileSize); g_GetFullPath(szPathName, pszFileName); bRetCode = g_GetFilePathFromFullPath(szFileName, szPathName); KG_PROCESS_ERROR(bRetCode); dwScriptID = g_FileNameHash(szFileName); bRetCode = IsScriptExist(dwScriptID); KG_PROCESS_ERROR(bRetCode); bRetCode = m_piScript->LoadFromBuffer(dwScriptID, szPathName, pszBuffer, dwFileSize); KG_PROCESS_ERROR(bRetCode); pScriptData = m_piScript->GetScriptData(dwScriptID); if (pScriptData) { std::vector<DWORD>::iterator it = pScriptData->vecIncludeScriptID.begin(); std::vector<DWORD>::iterator itEnd = pScriptData->vecIncludeScriptID.end(); for (NULL; it != itEnd; ++it) { KLuaScriptData* pNewScriptData = NULL; pNewScriptData = m_piScript->GetScriptData(*it); if (pNewScriptData) Reload(pNewScriptData->szName); } } bResult = true; Exit0: if (!bResult) { KGLogPrintf(KGLOG_ERR, "[Lua] Failed to reload file \"%s\" !\n", pszFileName); } KG_DELETE_ARRAY(pszBuffer); KG_COM_RELEASE(piFile); return bResult; }
CDLP::CDLP() { dlpavailable=false; dlpInstance=NULL; Reload(); }
void CWeaponHgun::ItemPostFrame( void ) { Reload(); BaseClass::ItemPostFrame(); }
bool CAIWeaponAbstract::DefaultFire(CAI* pAI, const LTVector& vTargetPos, bool bAnimatesReload) { if( !( m_pWeapon && m_pAIWeaponRecord ) ) { return false; } HOBJECT hTarget = pAI->GetAIBlackBoard()->GetBBTargetObject(); // Get our fire position LTVector vFirePos = GetFirePosition(pAI); // Get our firing vector LTVector vDir = vTargetPos - vFirePos; vDir.Normalize(); // Now fire the weapon WeaponFireInfo weaponFireInfo; static uint8 s_nCount = GetRandom( 0, 255 ); s_nCount++; weaponFireInfo.hFiredFrom = pAI->GetHOBJECT(); weaponFireInfo.vPath = vDir; weaponFireInfo.vFirePos = vFirePos; weaponFireInfo.vFlashPos = vFirePos; weaponFireInfo.hTestObj = hTarget; weaponFireInfo.hFiringWeapon = m_pWeapon->GetModelObject(); weaponFireInfo.nSeed = (uint8)GetRandom( 2, 255 ); weaponFireInfo.nPerturbCount = s_nCount; weaponFireInfo.nFireTimestamp = g_pLTServer->GetRealTimeMS( ); weaponFireInfo.bLeftHandWeapon = ( LTStrIEquals( m_szFireSocketName.c_str( ), "LEFTHAND" ) ); if( pAI->GetAIBlackBoard()->GetBBPerfectAccuracy() ) { weaponFireInfo.fPerturb = 0.0f; } else { weaponFireInfo.fPerturb = 1.f; } WeaponState eWeaponState = m_pWeapon->UpdateWeapon( weaponFireInfo, true ); if( eWeaponState == W_FIRED ) { UpdateWeaponAnimation( pAI ); } if( m_pWeapon->GetAmmoInClip() == 0 ) { // Automatically reload if: // 1) The AI has more ammo for this weapon and // 2) Either the AI is flagged to autoreload, or the weapon is flagged to not animation reloads. if( AIWeaponUtils::HasAmmo(pAI, m_pAIWeaponRecord->eAIWeaponType, !AIWEAP_CHECK_HOLSTER) && ( ( pAI->GetAIBlackBoard()->GetBBAutoReload() && m_pAIWeaponRecord->bAllowAutoReload ) || !bAnimatesReload) ) { Reload(pAI); } else { pAI->GetAIWorldState()->SetWSProp( kWSK_WeaponLoaded, pAI->GetHOBJECT(), kWST_bool, false ); } } else { pAI->GetAIWorldState()->SetWSProp( kWSK_WeaponLoaded, pAI->GetHOBJECT(), kWST_bool, true ); } // If the primary weapon is now out of ammo, set the WeaponArmed // worldstate to false. if( pAI->GetAIBlackBoard()->GetBBPrimaryWeaponType() == m_pAIWeaponRecord->eAIWeaponType && !AIWeaponUtils::HasAmmo(pAI, m_pAIWeaponRecord->eAIWeaponType, !AIWEAP_CHECK_HOLSTER)) { pAI->GetAIBlackBoard()->SetBBSelectAction(true); } return true; }
void CBasePlayerWeapon::ItemPostFrame( void ) { if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); // Add them to the clip m_iClip += j; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; m_pPlayer->TabulateAmmo(); m_fInReload = FALSE; } if ((m_pPlayer->pev->button & IN_ATTACK2) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) ) { if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) { m_fFireOnEmpty = TRUE; } m_pPlayer->TabulateAmmo(); SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) ) { if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) { m_fFireOnEmpty = TRUE; } m_pPlayer->TabulateAmmo(); PrimaryAttack(); } else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. Reload(); } else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) ) { // no fire buttons down m_fFireOnEmpty = FALSE; if ( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) { // weapon isn't useable, switch. if ( !(iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) { m_flNextPrimaryAttack = ( UseDecrement() ? 0.0 : gpGlobals->time ) + 0.3; return; } } else { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < gpGlobals->time ) { Reload(); return; } } WeaponIdle( ); return; } // catch all if ( ShouldWeaponIdle() ) { WeaponIdle(); } }
bool Config::SetSource(const char *file) { mFilename = file; return Reload(); }
void CASW_Weapon_Minigun::PrimaryAttack() { // can't attack until the minigun barrel has spun up if ( GetSpinRate() < asw_minigun_spin_rate_threshold.GetFloat() ) return; // If my clip is empty (and I use clips) start reload if ( UsesClipsForAmmo1() && !m_iClip1 ) { Reload(); return; } CASW_Player *pPlayer = GetCommander(); CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return; m_bIsFiring = true; // MUST call sound before removing a round from the clip of a CMachineGun WeaponSound(SINGLE); if (m_iClip1 <= AmmoClickPoint()) { LowAmmoSound(); } // tell the marine to tell its weapon to draw the muzzle flash pMarine->DoMuzzleFlash(); // sets the animation on the weapon model itself SendWeaponAnim( GetPrimaryAttackActivity() ); // sets the animation on the marine holding this weapon //pMarine->SetAnimation( PLAYER_ATTACK1 ); #ifdef GAME_DLL // check for turning on lag compensation if (pPlayer && pMarine->IsInhabited()) { CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() ); } #endif FireBulletsInfo_t info; info.m_vecSrc = pMarine->Weapon_ShootPosition( ); if ( pPlayer && pMarine->IsInhabited() ) { info.m_vecDirShooting = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187 } else { #ifdef CLIENT_DLL Msg("Error, clientside firing of a weapon that's being controlled by an AI marine\n"); #else info.m_vecDirShooting = pMarine->GetActualShootTrajectory( info.m_vecSrc ); #endif } // To make the firing framerate independent, we may have to fire more than one bullet here on low-framerate systems, // especially if the weapon we're firing has a really fast rate of fire. info.m_iShots = 0; float fireRate = GetFireRate() * ( 1.0f / MAX( GetSpinRate(), asw_minigun_spin_rate_threshold.GetFloat() ) ); while ( m_flNextPrimaryAttack <= gpGlobals->curtime ) { m_flNextPrimaryAttack = m_flNextPrimaryAttack + fireRate; info.m_iShots++; if ( !fireRate ) break; } // Make sure we don't fire more than the amount in the clip if ( UsesClipsForAmmo1() ) { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_flPartialBullets += static_cast<float>( info.m_iShots ) * 0.5f; if ( m_flPartialBullets >= 1.0f ) { // Subtract ammo if we've counted up a whole bullet int nBullets = m_flPartialBullets; m_iClip1 -= nBullets; m_flPartialBullets -= nBullets; } #ifdef GAME_DLL CASW_Marine *pMarine = GetMarine(); if (pMarine && m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) { pMarine->OnWeaponOutOfAmmo(true); } #endif } else { info.m_iShots = MIN( info.m_iShots, pMarine->GetAmmoCount( m_iPrimaryAmmoType ) ); pMarine->RemoveAmmo( info.m_iShots, m_iPrimaryAmmoType ); } info.m_flDistance = asw_weapon_max_shooting_distance.GetFloat(); info.m_iAmmoType = m_iPrimaryAmmoType; info.m_iTracerFreq = 1; // asw tracer test everytime info.m_flDamageForceScale = asw_weapon_force_scale.GetFloat(); info.m_vecSpread = pMarine->GetActiveWeapon()->GetBulletSpread(); info.m_flDamage = GetWeaponDamage(); #ifndef CLIENT_DLL if (asw_debug_marine_damage.GetBool()) Msg("Weapon dmg = %f\n", info.m_flDamage); info.m_flDamage *= pMarine->OnFired_GetDamageScale(); if (asw_DebugAutoAim.GetBool()) { NDebugOverlay::Line(info.m_vecSrc, info.m_vecSrc + info.m_vecDirShooting * info.m_flDistance, 64, 0, 64, true, 1.0); } #endif // fire extra shots per ammo from the minigun, so we get a nice solid spray of bullets //info.m_iShots = 2; pMarine->FireBullets( info ); // increment shooting stats #ifndef CLIENT_DLL if (pMarine && pMarine->GetMarineResource()) { pMarine->GetMarineResource()->UsedWeapon(this, info.m_iShots); pMarine->OnWeaponFired( this, info.m_iShots ); } #endif }
//----------------------------------------------------------------------------- // Purpose: Override so shotgun can do mulitple reloads in a row //----------------------------------------------------------------------------- void CWeaponRemington::ItemPostFrame( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if (!pOwner) { return; } if (m_bInReload) { // If I'm primary firing and have one round stop reloading and fire if ((pOwner->m_nButtons & IN_ATTACK ) && (m_iClip1 >=1)) { m_bInReload = false; //m_bNeedPump = false; //DHL m_bDelayedFire1 = true; } // If I'm secondary firing and have one round stop reloading and fire else if ((pOwner->m_nButtons & IN_ATTACK2 ) && (m_iClip1 >=2)) { m_bInReload = false; //m_bNeedPump = false; m_bDelayedFire2 = true; } else if (m_flNextPrimaryAttack <= gpGlobals->curtime) { // If out of ammo end reload if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <=0) { FinishReload(); return; } // If clip not full reload again if (m_iClip1 < GetMaxClip1()) { Reload(); return; } // Clip full, stop reloading else { FinishReload(); return; } } } else { // Make shotgun shell invisible SetBodygroup(1,1); } /* //DHL, trouble maker? Perhaps. if ((m_bNeedPump) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) { Pump(); return; } */ // Shotgun uses same timing and ammo for secondary attack if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2)&&(m_flNextPrimaryAttack <= gpGlobals->curtime)) { m_bDelayedFire2 = false; if ( (m_iClip1 <= 1 && UsesClipsForAmmo1())) { // If only one shell is left, do a single shot instead if ( m_iClip1 == 1 ) { PrimaryAttack(); } else if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType)) { DryFire(); } else { StartReload(); } } // Fire underwater? else if (GetOwner()->GetWaterLevel() == 3 && m_bFiresUnderwater == false) { WeaponSound(EMPTY); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; return; } else { // If the firing button was just pressed, reset the firing time if ( pOwner->m_afButtonPressed & IN_ATTACK ) { m_flNextPrimaryAttack = gpGlobals->curtime; } SecondaryAttack(); } } else if ( (m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime) { m_bDelayedFire1 = false; if ( (m_iClip1 <= 0 && UsesClipsForAmmo1()) || ( !UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType) ) ) { if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType)) { DryFire(); } else { StartReload(); } } // Fire underwater? else if (pOwner->GetWaterLevel() == 3 && m_bFiresUnderwater == false) { WeaponSound(EMPTY); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; return; } else { // If the firing button was just pressed, reset the firing time CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK ) { m_flNextPrimaryAttack = gpGlobals->curtime; } PrimaryAttack(); } } if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. StartReload(); } else { // no fire buttons down m_bFireOnEmpty = false; if ( !HasAnyAmmo() && m_flNextPrimaryAttack < gpGlobals->curtime ) { // weapon isn't useable, switch. if ( !(GetWeaponFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && pOwner->SwitchToNextBestWeapon( this ) ) { m_flNextPrimaryAttack = gpGlobals->curtime + 0.3; return; } } else { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if ( m_iClip1 <= 0 && !(GetWeaponFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < gpGlobals->curtime ) { if (StartReload()) { // if we've successfully started to reload, we're done return; } } } WeaponIdle( ); return; } }
void CM3::PrimaryAttack(void) { if (m_pPlayer->pev->waterlevel == 3) { PlayEmptySound(); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } if (m_iClip <= 0) { Reload(); if (m_iClip == 0) PlayEmptySound(); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0; return; } m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); m_pPlayer->FireBullets(9, m_pPlayer->GetGunPosition(), gpGlobals->v_forward, Vector(0.0675, 0.0675, 0), 3000, BULLET_PLAYER_BUCKSHOT, 0); int flags; #ifdef CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif PLAYBACK_EVENT_FULL(flags, ENT(m_pPlayer->pev), m_usFireM3, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, 0, FALSE, FALSE); if (m_iClip) m_flPumpTime = UTIL_WeaponTimeBase() + 0.5; if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); if (m_iClip) m_flPumpTime = UTIL_WeaponTimeBase() + 0.5; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.875; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.875; if (m_iClip) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5; else m_flTimeWeaponIdle = 0.875; m_fInSpecialReload = 0; if (m_pPlayer->pev->flags & FL_ONGROUND) m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 4, 6); else m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomLong(m_pPlayer->random_seed + 1, 8, 11); m_pPlayer->m_flEjectBrass = gpGlobals->time + 0.45; }