Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. class Hesco_1_Kit extends ItemBase
  2. {
  3. ref protected EffectSound m_DeployLoopSound;
  4. protected Object Hesco_1_Kit1;
  5.  
  6. void SandbagLong_Kit()
  7. {
  8. RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
  9. }
  10.  
  11.  
  12. override void EEInit()
  13. {
  14. super.EEInit();
  15. }
  16.  
  17. override void OnItemLocationChanged( EntityAI old_owner, EntityAI new_owner )
  18. {
  19. super.OnItemLocationChanged( old_owner, new_owner );
  20. }
  21.  
  22. override void OnVariablesSynchronized()
  23. {
  24. super.OnVariablesSynchronized();
  25.  
  26. if ( IsDeploySound() )
  27. {
  28. PlayDeploySound();
  29. }
  30.  
  31. if ( CanPlayDeployLoopSound() )
  32. {
  33. PlayDeployLoopSound();
  34. }
  35.  
  36. if ( m_DeployLoopSound && !CanPlayDeployLoopSound() )
  37. {
  38. StopDeployLoopSound();
  39. }
  40. }
  41.  
  42. override void SetActions()
  43. {
  44. super.SetActions();
  45.  
  46. AddAction(ActionTogglePlaceObject);
  47. AddAction(ActionPlaceObject);
  48. }
  49.  
  50. //================================================================
  51. // ADVANCED PLACEMENT
  52. //================================================================
  53.  
  54. override void OnPlacementComplete( Man player )
  55. {
  56. super.OnPlacementComplete( player );
  57.  
  58. PlayerBase pb = PlayerBase.Cast( player );
  59. if ( GetGame().IsServer() )
  60. {
  61. PlayerBase player_base = PlayerBase.Cast( player );
  62. vector position = player_base.GetLocalProjectionPosition();
  63. vector orientation = player_base.GetLocalProjectionOrientation();
  64.  
  65. Hesco_1_Kit1 = GetGame().CreateObject("FortHesco_1", pb.GetLocalProjectionPosition(), false );
  66. Hesco_1_Kit1.SetPosition( position );
  67. Hesco_1_Kit1.SetOrientation( orientation );
  68. }
  69.  
  70. SetIsDeploySound( true );
  71. }
  72.  
  73. override bool IsDeployable()
  74. {
  75. return true;
  76. }
  77.  
  78. override string GetDeploySoundset()
  79. {
  80. return "putDown_FenceKit_SoundSet";
  81. }
  82.  
  83. override string GetLoopDeploySoundset()
  84. {
  85. return "BarbedWire_Deploy_loop_SoundSet";
  86. }
  87.  
  88. void PlayDeployLoopSound()
  89. {
  90. if ( GetGame().IsMultiplayer() && GetGame().IsClient() || !GetGame().IsMultiplayer() )
  91. {
  92. m_DeployLoopSound = SEffectManager.PlaySound( GetLoopDeploySoundset(), GetPosition() );
  93. }
  94. }
  95.  
  96. void StopDeployLoopSound()
  97. {
  98. if ( GetGame().IsMultiplayer() && GetGame().IsClient() || !GetGame().IsMultiplayer() )
  99. {
  100. m_DeployLoopSound.SoundStop();
  101. delete m_DeployLoopSound;
  102. }
  103. }
  104. }
  105.  
  106. class FortHesco_1 : Fence
  107. {
  108. override bool HasBase()
  109. {
  110. return true;
  111. }
  112.  
  113. override bool HasGate()
  114. {
  115. return false;
  116. }
  117.  
  118. override void AfterStoreLoad()
  119. {
  120. //super.AfterStoreLoad();
  121.  
  122. //set gate state
  123. //ConstructionPart gate_part = GetConstruction().GetGateConstructionPart();
  124. //SetGateState( gate_part.IsBuilt() );
  125.  
  126. //update gate state visual
  127. if ( IsOpened() )
  128. {
  129. OpenFence();
  130. }
  131.  
  132. UpdateVisuals();
  133.  
  134. //bsbDebugPrint("[bsb] AfterStoreLoad - build=" + gate_part.IsBuilt() + " opened=" + IsOpened());
  135. }
  136.  
  137. void Fort_Destroy()
  138. {
  139. //delete object
  140. GetGame().ObjectDelete( this );
  141. }
  142.  
  143. bool IsFacingFront( PlayerBase player, string selection )
  144. {
  145. vector metal_pos = GetPosition();
  146. vector player_pos = player.GetPosition();
  147. vector metal_dir = GetDirection();
  148.  
  149. vector metal_player_dir = player_pos - metal_pos;
  150. metal_player_dir.Normalize();
  151. metal_dir.Normalize();
  152.  
  153. if ( metal_dir.Length() != 0 )
  154. {
  155. float dot = vector.Dot( metal_player_dir, metal_dir );
  156.  
  157. if ( dot > 0 )
  158. {
  159. return true;
  160. }
  161. }
  162. return false;
  163. }
  164.  
  165. bool IsFacingBack( PlayerBase player, string selection )
  166. {
  167. return !IsFacingFront( player, selection );
  168. }
  169.  
  170. override bool HasProperDistance( string selection, PlayerBase player )
  171. {
  172. if ( MemoryPointExists( selection ) )
  173. {
  174. vector selection_pos = ModelToWorld( GetMemoryPointPos( selection ) );
  175. float distance = vector.Distance( selection_pos, player.GetPosition() );
  176. if ( distance >= 1.3 )
  177. {
  178. return false;
  179. }
  180. }
  181.  
  182. return true;
  183. }
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement