Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void WeaponItem::InitialUpdate()
- {
- AMMO const *pAmmo = g_pWeaponMgr->GetAmmo(m_nAmmoId);
- if (!pAmmo) return;
- // Set our default ammo if necessary...
- if (m_nAmmo < 0)
- {
- m_nAmmo = pAmmo->nSpawnedAmount;
- }
- }
- // ----------------------------------------------------------------------- //
- //
- // ROUTINE: WeaponItem::ObjectTouch
- //
- // PURPOSE: Add weapon powerup to object
- //
- // ----------------------------------------------------------------------- //
- void WeaponItem::ObjectTouch(HOBJECT hObject, bool bForcePickup/*=false*/)
- {
- if (!hObject) return;
- // If we hit non-player objects, just ignore them...
- if (IsPlayer(hObject))
- {
- CCharacter* pCharObj = (CCharacter*)g_pLTServer->HandleToObject(hObject);
- if (pCharObj && !pCharObj->IsDead())
- {
- CAutoMessage cMsg;
- cMsg.Writeuint32(MID_ADDWEAPON);
- cMsg.Writeuint8(m_nWeaponId);
- cMsg.Writeuint8(m_nAmmoId);
- cMsg.Writeint32(m_nAmmo);
- cMsg.Writebool(bForcePickup);
- g_pLTServer->SendToObject(cMsg.Read(), m_hObject, hObject, MESSAGE_GUARANTEED);
- }
- }
- }
- // ----------------------------------------------------------------------- //
- //
- // ROUTINE: WeaponItem::PickedUp
- //
- // PURPOSE: Called when an object tells this item that the object
- // picked it up...
- //
- // ----------------------------------------------------------------------- //
- void WeaponItem::PickedUp( ILTMessage_Read *pMsg )
- {
- PickupItem::PickedUp( pMsg );
- if( m_bRespawn )
- {
- WEAPON const *pWeapon = g_pWeaponMgr->GetWeapon( m_nWeaponId );
- if( !pWeapon )
- return;
- // Change the skins and renderstyles to the waiting to respawn files...
- ObjectCreateStruct ocs;
- pWeapon->blrRespawnWaitSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 );
- pWeapon->blrRespawnWaitRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 );
- if( pWeapon->blrRespawnWaitRenderStyles.GetNumItems() < 1 )
- LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS ));
- g_pCommonLT->SetObjectFilenames( m_hObject, &ocs );
- // Stop playing PowerupFX and play RespawnWaitFX...
- SetClientFX( pWeapon->szRespawnWaitFX );
- // Set our visibility and translucency...
- g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags, pWeapon->bRespawnWaitVisible ? FLAG_VISIBLE : 0, FLAG_VISIBLE );
- g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags2, pWeapon->bRespawnWaitTranslucent ? FLAG2_FORCETRANSLUCENT : 0, FLAG2_FORCETRANSLUCENT );
- }
- }
- // ----------------------------------------------------------------------- //
- //
- // ROUTINE: WeaponItem::Respawn
- //
- // PURPOSE: Handle "respawning" the model (make it visible, switch skins, etc.)...
- //
- // ----------------------------------------------------------------------- //
- void WeaponItem::Respawn( )
- {
- PickupItem::Respawn();
- WEAPON const *pWeapon = g_pWeaponMgr->GetWeapon( m_nWeaponId );
- if( !pWeapon )
- return;
- // Change the skins and renderstyles back to the normal powerup files...
- ObjectCreateStruct ocs;
- pWeapon->blrHHSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 );
- pWeapon->blrHHRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 );
- if( pWeapon->blrHHRenderStyles.GetNumItems() < 1 )
- LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS ));
- // See if we are using a different model...
- CheckForOverrideModel( &ocs );
- g_pCommonLT->SetObjectFilenames( m_hObject, &ocs );
- // Stop playing RespawnWaitFX and play PowerupFX...
- SetClientFX( pWeapon->szPowerupFX );
- }
- // ----------------------------------------------------------------------- //
- //
- // ROUTINE: WeaponItem::Save
- //
- // PURPOSE: Save the object
- //
- // ----------------------------------------------------------------------- //
- void WeaponItem::Save(ILTMessage_Write *pMsg, uint32 dwSaveFlags)
- {
- if (!pMsg) return;
- SAVE_BYTE(m_nWeaponId);
- SAVE_BYTE(m_nAmmoId);
- SAVE_INT(m_nAmmo);
- }
- // ----------------------------------------------------------------------- //
- //
- // ROUTINE: WeaponItem::Load
- //
- // PURPOSE: Load the object
- //
- // ----------------------------------------------------------------------- //
- void WeaponItem::Load(ILTMessage_Read *pMsg, uint32 dwLoadFlags)
- {
- if (!pMsg) return;
- LOAD_BYTE(m_nWeaponId);
- LOAD_BYTE(m_nAmmoId);
- LOAD_INT(m_nAmmo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement