actiondigworms.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. class ActionDigWormsCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. float time_spent;
  6. time_spent = UATimeSpent.DIG_WORMS;
  7. if (m_ActionData.m_MainItem.KindOf("Knife"))
  8. time_spent = time_spent * 1.2;
  9. if (m_ActionData.m_Player.GetInColdArea())
  10. time_spent *= GameConstants.COLD_AREA_DIG_WORMS_MODIF;
  11. m_ActionData.m_ActionComponent = new CAContinuousRepeat(time_spent);
  12. }
  13. };
  14. class ActionDigWorms: ActionContinuousBase
  15. {
  16. void ActionDigWorms()
  17. {
  18. m_CallbackClass = ActionDigWormsCB;
  19. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGGIN_WORMS;
  20. m_FullBody = true;
  21. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  22. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_MEDIUM;
  23. m_Text = "#dig_up_worms";
  24. }
  25. override void CreateConditionComponents()
  26. {
  27. m_ConditionItem = new CCINonRuined;
  28. m_ConditionTarget = new CCTSurface(UAMaxDistances.DEFAULT);
  29. }
  30. override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
  31. {
  32. if (!super.Can(player, target, item, condition_mask))
  33. return false;
  34. return player.CheckFreeSpace(vector.Forward, 0.8, false);
  35. }
  36. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  37. {
  38. if (player.IsPlacingLocal())
  39. return false;
  40. return IsTargetFertile(target) && IsPlayerOnGround(player);
  41. }
  42. override bool ActionConditionContinue(ActionData action_data)
  43. {
  44. return IsPlayerOnGround(action_data.m_Player);
  45. }
  46. override bool HasTarget()
  47. {
  48. return true;
  49. }
  50. override void OnFinishProgressServer(ActionData action_data)
  51. {
  52. int count = action_data.m_MainItem.GetOnDigWormsAmount();
  53. for (int i = 0; i < count; i++)
  54. {
  55. /*
  56. vector posHead;
  57. MiscGameplayFunctions.GetHeadBonePos(action_data.m_Player,posHead);
  58. vector posRandom = MiscGameplayFunctions.GetRandomizedPositionVerified(posHead,action_data.m_Target.GetCursorHitPos(),UAItemsSpreadRadius.NARROW,action_data.m_Player);
  59. GetGame().CreateObjectEx("Worm", posRandom, ECE_PLACE_ON_SURFACE);
  60. */
  61. GetGame().CreateObjectEx("Worm", action_data.m_Target.GetCursorHitPos(), ECE_PLACE_ON_SURFACE);
  62. }
  63. MiscGameplayFunctions.DealEvinronmentAdjustedDmg(action_data.m_MainItem, action_data.m_Player, 4);
  64. }
  65. bool IsTargetFertile(ActionTarget target)
  66. {
  67. if (target)
  68. {
  69. string surface_type;
  70. vector position;
  71. position = target.GetCursorHitPos();
  72. GetGame().SurfaceGetType(position[0], position[2], surface_type);
  73. if (GetGame().IsSurfaceFertile(surface_type))
  74. {
  75. return true;
  76. }
  77. }
  78. return false;
  79. }
  80. bool IsPlayerOnGround(PlayerBase player)
  81. {
  82. vector position = player.GetPosition();
  83. float heightDiff = GetGame().SurfaceY(position[0], position[2]);
  84. heightDiff = position[1] - heightDiff;
  85. return heightDiff <= 0.4; // Player is considered on ground
  86. }
  87. //! DEPRECATED - See ItemBase.OverrideActionAnimation() to override commands for items
  88. void SetDiggignAnimation(ItemBase item);
  89. };