actionopenfence.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. class ActionOpenFence: ActionInteractBase
  2. {
  3. ref NoiseParams m_NoisePar;
  4. const string SELECTION_INTERACT = "gate_interact";
  5. void ActionOpenFence()
  6. {
  7. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
  8. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  9. m_Text = "#open";
  10. }
  11. override void CreateConditionComponents()
  12. {
  13. m_ConditionItem = new CCINone;
  14. m_ConditionTarget = new CCTCursor;
  15. }
  16. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  17. {
  18. Object targetObject = target.GetObject();
  19. if ( targetObject && targetObject.CanUseConstruction() )
  20. {
  21. Fence fence = Fence.Cast( targetObject );
  22. if ( fence && fence.CanOpenFence() )
  23. {
  24. array<string> selections = new array<string>;
  25. targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
  26. for ( int i = 0; i < selections.Count(); i++ )
  27. {
  28. if ( selections[i] == SELECTION_INTERACT )
  29. return true;
  30. }
  31. }
  32. }
  33. return false;
  34. }
  35. override void OnStartServer( ActionData action_data )
  36. {
  37. super.OnStartServer(action_data);
  38. Fence fence = Fence.Cast( action_data.m_Target.GetObject() );
  39. fence.OpenFence();
  40. }
  41. override void OnEndServer( ActionData action_data )
  42. {
  43. super.OnEndServer(action_data);
  44. m_NoisePar = new NoiseParams();
  45. m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
  46. NoiseSystem noise = GetGame().GetNoiseSystem();
  47. if ( noise )
  48. {
  49. if ( action_data.m_Player )
  50. noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar, NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather()));
  51. }
  52. }
  53. }