actionrepaircarchassis.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. class ActionRepairCarChassisCB : ActionRepairVehiclePartCB
  2. {};
  3. class ActionRepairCarChassis : ActionRepairVehiclePartBase
  4. {
  5. protected typename m_LastValidType; // deprecated
  6. protected int m_LastValidComponentIndex;
  7. void ActionRepairCarChassis()
  8. {
  9. m_CallbackClass = ActionRepairCarChassisCB;
  10. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  11. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
  12. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
  13. m_FullBody = true;
  14. m_LockTargetOnUse = false;
  15. m_Text = "#repair";
  16. m_LastValidComponentIndex = -1;
  17. }
  18. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  19. {
  20. if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  21. return false;
  22. CarScript car = CarScript.Cast(target.GetObject());
  23. if (!car)
  24. {
  25. return false;
  26. }
  27. if (GetGame().IsMultiplayer() && GetGame().IsServer())
  28. {
  29. return true;
  30. }
  31. if (m_LastValidType != target.Type() || m_LastValidComponentIndex != target.GetComponentIndex() || m_CurrentDamageZone == "")
  32. {
  33. string damageZone = "";
  34. array<string> selections = new array<string>();
  35. car.GetActionComponentNameList(target.GetComponentIndex(), selections);
  36. foreach (string selection : selections)
  37. {
  38. //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
  39. if (car && DamageSystem.GetDamageZoneFromComponentName(car, selection, damageZone))
  40. {
  41. if (damageZone == "Engine")
  42. continue;
  43. int zoneHP = car.GetHealthLevel(damageZone);
  44. if (zoneHP > GameConstants.STATE_WORN && zoneHP < GameConstants.STATE_RUINED)
  45. {
  46. m_CurrentDamageZone = damageZone;
  47. m_LastValidComponentIndex = target.GetComponentIndex();
  48. //Determine if using a "Special" item for repairing
  49. WoodenPlank plank = WoodenPlank.Cast(item);
  50. Fabric tarp = Fabric.Cast(item);
  51. //Prevent planks and tarp from repairing non related areas
  52. if ((tarp || plank) && (damageZone != "BackWood" && damageZone != "BackTarp"))
  53. return false;
  54. return true;
  55. }
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. override void AdjustItemQuantityServer(ActionData action_data)
  62. {
  63. if (action_data.m_MainItem.HasQuantity())
  64. {
  65. if (action_data.m_MainItem.GetQuantity() > 1)
  66. {
  67. int qnt = action_data.m_MainItem.GetQuantity();
  68. Fabric usedTarp = Fabric.Cast(action_data.m_MainItem);
  69. WoodenPlank usedPlank = WoodenPlank.Cast(action_data.m_MainItem);
  70. if (usedTarp || usedPlank)
  71. {
  72. qnt -= 1;
  73. }
  74. else
  75. {
  76. qnt -= action_data.m_MainItem.GetQuantityMax() * 0.25;
  77. }
  78. action_data.m_MainItem.SetQuantity(qnt);
  79. }
  80. else
  81. {
  82. action_data.m_MainItem.Delete();
  83. }
  84. }
  85. }
  86. };
  87. // deprecated
  88. class RepairCarChassisActionReciveData : ActionReciveData
  89. {}
  90. class RepairCarChassisActionData : ActionData
  91. {}