actionsawplanks.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. class ActionSawPlanksCB : ActionContinuousBaseCB
  2. {
  3. static const float TIME_SAW_HANDSAW = 1.5;
  4. static const float TIME_SAW_HACKSAW = 3.0;
  5. static const float TIME_AXES = 1.2;
  6. override void CreateActionComponent()
  7. {
  8. m_ActionData.m_ActionComponent = new CAContinuousRepeat(GetDefaultTime());
  9. }
  10. float GetDefaultTime()
  11. {
  12. string item_type = m_ActionData.m_MainItem.GetType();
  13. switch(item_type)
  14. {
  15. case "Hacksaw":
  16. return TIME_SAW_HACKSAW;
  17. break;
  18. case "HandSaw":
  19. return TIME_SAW_HANDSAW;
  20. break;
  21. default: // axes
  22. return TIME_AXES;
  23. break
  24. }
  25. Print("ActionSawPlanksCB | Item detection error, assigning negative time");
  26. return -1;
  27. }
  28. };
  29. class ActionSawPlanks: ActionContinuousBase
  30. {
  31. static const int DECREASE_HEALTH_OF_TOOL_DEFAULT = 10; // this constant is not use anymore see ActionConstants.c UADamageApplied
  32. //static const int DECREASE_HEALTH_OF_TOOL_AXE = 20; // axes
  33. //static const int DECREASE_FUEL_OF_CHAINSAW = 20; // chainsaw fuel in ml
  34. static const int YIELD = 3;
  35. ItemBase m_Planks;
  36. ref InventoryLocation m_PlanksLocation = new InventoryLocation;
  37. void ActionSawPlanks()
  38. {
  39. m_CallbackClass = ActionSawPlanksCB;
  40. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
  41. m_FullBody = true;
  42. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
  43. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_MEDIUM;
  44. m_Text = "#saw_planks";
  45. m_LockTargetOnUse = false;
  46. }
  47. override void CreateConditionComponents()
  48. {
  49. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  50. m_ConditionItem = new CCINonRuined;
  51. }
  52. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  53. {
  54. Object target_O = target.GetObject();
  55. if ( item && target_O.IsInherited(PileOfWoodenPlanks))
  56. {
  57. string item_type = item.GetType();
  58. switch(item_type)
  59. {
  60. case "Chainsaw":
  61. if ( item.HasEnergyManager() && item.GetCompEM().CanWork() )
  62. {
  63. return true;
  64. }
  65. else
  66. {
  67. return false;
  68. }
  69. break;
  70. }
  71. return true;
  72. }
  73. return false;
  74. }
  75. override void OnFinishProgressServer( ActionData action_data )
  76. {
  77. PileOfWoodenPlanks item_POWP = PileOfWoodenPlanks.Cast( action_data.m_Target.GetObject() );
  78. item_POWP.RemovePlanks(YIELD);
  79. vector pos = action_data.m_Player.GetPosition();
  80. InventoryLocation currentLoc = new InventoryLocation;
  81. if (m_Planks)
  82. m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
  83. if (!m_Planks || !currentLoc.CompareLocationOnly(m_PlanksLocation))
  84. {
  85. m_Planks = ItemBase.Cast( GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE) );
  86. m_Planks.SetQuantity(YIELD);
  87. m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
  88. m_PlanksLocation.Copy(currentLoc);
  89. }
  90. else if ((m_Planks.GetQuantity() + YIELD) >= m_Planks.GetQuantityMax())
  91. {
  92. int remnant = m_Planks.GetQuantity() + YIELD - m_Planks.GetQuantityMax();
  93. m_Planks.SetQuantity(m_Planks.GetQuantityMax());
  94. if (remnant > 0)
  95. {
  96. m_Planks = ItemBase.Cast( GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE) );
  97. m_Planks.SetQuantity(remnant);
  98. m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
  99. m_PlanksLocation.Copy(currentLoc);
  100. }
  101. }
  102. else
  103. {
  104. m_Planks.AddQuantity(YIELD);
  105. }
  106. ItemBase item = action_data.m_MainItem;
  107. string item_type = item.GetType();
  108. item.DecreaseHealth("", "", UADamageApplied.SAW_PLANKS);
  109. /*switch(item_type)
  110. {
  111. case "WoodAxe":
  112. item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
  113. break;
  114. case "FirefighterAxe":
  115. item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
  116. break;
  117. case "FirefighterAxe_Black":
  118. item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
  119. break;
  120. case "FirefighterAxe_Green":
  121. item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
  122. break;
  123. case "Hatchet":
  124. item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
  125. break;
  126. case "Chainsaw":
  127. if ( item.HasEnergyManager() )
  128. {
  129. item.GetCompEM().ConsumeEnergy(DECREASE_FUEL_OF_CHAINSAW);
  130. }
  131. break;
  132. default: // Hacksaw and other
  133. item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( UADamageApplied.SAW_PLANKS, GetSpecialtyWeight() ));
  134. break;
  135. }*/
  136. }
  137. };