Advertisement
dcomicboy

all of it

Jul 7th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. void WeaponItem::InitialUpdate()
  2. {
  3. AMMO const *pAmmo = g_pWeaponMgr->GetAmmo(m_nAmmoId);
  4. if (!pAmmo) return;
  5.  
  6. // Set our default ammo if necessary...
  7.  
  8. if (m_nAmmo < 0)
  9. {
  10. m_nAmmo = pAmmo->nSpawnedAmount;
  11. }
  12. }
  13.  
  14. // ----------------------------------------------------------------------- //
  15. //
  16. // ROUTINE: WeaponItem::ObjectTouch
  17. //
  18. // PURPOSE: Add weapon powerup to object
  19. //
  20. // ----------------------------------------------------------------------- //
  21.  
  22. void WeaponItem::ObjectTouch(HOBJECT hObject, bool bForcePickup/*=false*/)
  23. {
  24. if (!hObject) return;
  25.  
  26. // If we hit non-player objects, just ignore them...
  27.  
  28. if (IsPlayer(hObject))
  29. {
  30. CCharacter* pCharObj = (CCharacter*)g_pLTServer->HandleToObject(hObject);
  31.  
  32. if (pCharObj && !pCharObj->IsDead())
  33. {
  34. CAutoMessage cMsg;
  35. cMsg.Writeuint32(MID_ADDWEAPON);
  36. cMsg.Writeuint8(m_nWeaponId);
  37. cMsg.Writeuint8(m_nAmmoId);
  38. cMsg.Writeint32(m_nAmmo);
  39. cMsg.Writebool(bForcePickup);
  40. g_pLTServer->SendToObject(cMsg.Read(), m_hObject, hObject, MESSAGE_GUARANTEED);
  41. }
  42. }
  43. }
  44.  
  45. // ----------------------------------------------------------------------- //
  46. //
  47. // ROUTINE: WeaponItem::PickedUp
  48. //
  49. // PURPOSE: Called when an object tells this item that the object
  50. // picked it up...
  51. //
  52. // ----------------------------------------------------------------------- //
  53.  
  54. void WeaponItem::PickedUp( ILTMessage_Read *pMsg )
  55. {
  56. PickupItem::PickedUp( pMsg );
  57.  
  58. if( m_bRespawn )
  59. {
  60. WEAPON const *pWeapon = g_pWeaponMgr->GetWeapon( m_nWeaponId );
  61. if( !pWeapon )
  62. return;
  63.  
  64. // Change the skins and renderstyles to the waiting to respawn files...
  65.  
  66. ObjectCreateStruct ocs;
  67.  
  68. pWeapon->blrRespawnWaitSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 );
  69. pWeapon->blrRespawnWaitRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 );
  70.  
  71. if( pWeapon->blrRespawnWaitRenderStyles.GetNumItems() < 1 )
  72. LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS ));
  73.  
  74. g_pCommonLT->SetObjectFilenames( m_hObject, &ocs );
  75.  
  76. // Stop playing PowerupFX and play RespawnWaitFX...
  77.  
  78. SetClientFX( pWeapon->szRespawnWaitFX );
  79.  
  80. // Set our visibility and translucency...
  81.  
  82. g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags, pWeapon->bRespawnWaitVisible ? FLAG_VISIBLE : 0, FLAG_VISIBLE );
  83. g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags2, pWeapon->bRespawnWaitTranslucent ? FLAG2_FORCETRANSLUCENT : 0, FLAG2_FORCETRANSLUCENT );
  84. }
  85. }
  86.  
  87. // ----------------------------------------------------------------------- //
  88. //
  89. // ROUTINE: WeaponItem::Respawn
  90. //
  91. // PURPOSE: Handle "respawning" the model (make it visible, switch skins, etc.)...
  92. //
  93. // ----------------------------------------------------------------------- //
  94.  
  95. void WeaponItem::Respawn( )
  96. {
  97. PickupItem::Respawn();
  98.  
  99. WEAPON const *pWeapon = g_pWeaponMgr->GetWeapon( m_nWeaponId );
  100. if( !pWeapon )
  101. return;
  102.  
  103. // Change the skins and renderstyles back to the normal powerup files...
  104.  
  105. ObjectCreateStruct ocs;
  106.  
  107. pWeapon->blrHHSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 );
  108. pWeapon->blrHHRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 );
  109.  
  110. if( pWeapon->blrHHRenderStyles.GetNumItems() < 1 )
  111. LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS ));
  112.  
  113. // See if we are using a different model...
  114.  
  115. CheckForOverrideModel( &ocs );
  116.  
  117. g_pCommonLT->SetObjectFilenames( m_hObject, &ocs );
  118.  
  119. // Stop playing RespawnWaitFX and play PowerupFX...
  120.  
  121. SetClientFX( pWeapon->szPowerupFX );
  122. }
  123.  
  124. // ----------------------------------------------------------------------- //
  125. //
  126. // ROUTINE: WeaponItem::Save
  127. //
  128. // PURPOSE: Save the object
  129. //
  130. // ----------------------------------------------------------------------- //
  131.  
  132. void WeaponItem::Save(ILTMessage_Write *pMsg, uint32 dwSaveFlags)
  133. {
  134. if (!pMsg) return;
  135.  
  136. SAVE_BYTE(m_nWeaponId);
  137. SAVE_BYTE(m_nAmmoId);
  138. SAVE_INT(m_nAmmo);
  139. }
  140.  
  141.  
  142. // ----------------------------------------------------------------------- //
  143. //
  144. // ROUTINE: WeaponItem::Load
  145. //
  146. // PURPOSE: Load the object
  147. //
  148. // ----------------------------------------------------------------------- //
  149.  
  150. void WeaponItem::Load(ILTMessage_Read *pMsg, uint32 dwLoadFlags)
  151. {
  152. if (!pMsg) return;
  153.  
  154. LOAD_BYTE(m_nWeaponId);
  155. LOAD_BYTE(m_nAmmoId);
  156. LOAD_INT(m_nAmmo);
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement