actiondigoutstash.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. class ActionDigOutStashCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DIG_STASH);
  6. }
  7. }
  8. class ActionDigOutStash: ActionContinuousBase
  9. {
  10. void ActionDigOutStash()
  11. {
  12. m_CallbackClass = ActionDigOutStashCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGUPCACHE;
  14. m_FullBody = true;
  15. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
  16. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  17. m_Text = "#dig_stash";
  18. }
  19. override void CreateConditionComponents()
  20. {
  21. m_ConditionTarget = new CCTObject(UAMaxDistances.DEFAULT);
  22. m_ConditionItem = new CCINonRuined();
  23. }
  24. override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
  25. {
  26. if (!super.Can(player, target, item, condition_mask))
  27. return false;
  28. return player.CheckFreeSpace(vector.Forward, 1.0, false);
  29. }
  30. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  31. {
  32. ItemBase target_IB;
  33. if (Class.CastTo(target_IB, target.GetObject()))
  34. {
  35. if (target_IB.CanBeDigged())
  36. {
  37. return target_IB.IsInherited(UndergroundStash);
  38. }
  39. }
  40. return false;
  41. }
  42. override void OnExecuteClient(ActionData action_data)
  43. {
  44. super.OnExecuteClient(action_data);
  45. SpawnParticleShovelRaise(action_data);
  46. }
  47. override void OnExecuteServer(ActionData action_data)
  48. {
  49. super.OnExecuteServer(action_data);
  50. if (!GetGame().IsMultiplayer())
  51. {
  52. SpawnParticleShovelRaise(action_data);
  53. }
  54. }
  55. void SpawnParticleShovelRaise(ActionData action_data)
  56. {
  57. ParticleManager.GetInstance().PlayOnObject(ParticleList.DIGGING_STASH, action_data.m_Player);
  58. }
  59. override void OnFinishProgressServer( ActionData action_data )
  60. {
  61. EntityAI targetEntity = EntityAI.Cast(action_data.m_Target.GetObject());
  62. if (!targetEntity)
  63. {
  64. ErrorEx("Cannot get entity=" + targetEntity);
  65. return;
  66. }
  67. InventoryLocation target_IL = new InventoryLocation();
  68. if (!targetEntity.GetInventory().GetCurrentInventoryLocation(target_IL))
  69. {
  70. ErrorEx("Cannot get inventory location of entity=" + targetEntity);
  71. return;
  72. }
  73. // Dig out of stash
  74. UndergroundStash stash;
  75. if (Class.CastTo(stash, targetEntity))
  76. {
  77. ItemBase stashedItem = stash.GetStashedItem();
  78. if (stashedItem)
  79. {
  80. DigOutStashLambda lambda(stash, "", action_data.m_Player);
  81. action_data.m_Player.ServerReplaceItemWithNew(lambda);
  82. }
  83. else
  84. g_Game.ObjectDelete(stash);
  85. }
  86. //Apply tool damage
  87. MiscGameplayFunctions.DealEvinronmentAdjustedDmg(action_data.m_MainItem, action_data.m_Player, 10);
  88. }
  89. override string GetAdminLogMessage(ActionData action_data)
  90. {
  91. return string.Format("Player %1 Dug out %2 at position %3", action_data.m_Player, action_data.m_Target.GetObject(), action_data.m_Target.GetObject().GetPosition());
  92. }
  93. }
  94. class DigOutStashLambda : DropEquipAndDestroyRootLambda
  95. {
  96. void DigOutStashLambda(EntityAI old_item, string new_item_type, PlayerBase player) {}
  97. override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
  98. {
  99. super.CopyOldPropertiesToNew(old_item, new_item);
  100. }
  101. }