actionsplintself.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. class ActionSplintSelfCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.APPLY_SPLINT);
  6. }
  7. };
  8. class ActionSplintSelf: ActionContinuousBase
  9. {
  10. void ActionSplintSelf()
  11. {
  12. m_CallbackClass = ActionSplintSelfCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
  14. m_FullBody = true;
  15. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
  16. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  17. m_Text = "#apply_splint";
  18. }
  19. override void CreateConditionComponents()
  20. {
  21. m_ConditionItem = new CCINonRuined;
  22. m_ConditionTarget = new CCTSelf;
  23. }
  24. override bool HasTarget()
  25. {
  26. return false;
  27. }
  28. override void OnFinishProgressServer( ActionData action_data )
  29. {
  30. action_data.m_MainItem.TransferModifiers(action_data.m_Player);
  31. action_data.m_Player.ApplySplint();
  32. //Double check to not enter splinted state if legs are not broken
  33. if (action_data.m_Player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  34. {
  35. action_data.m_Player.SetBrokenLegs(eBrokenLegs.BROKEN_LEGS_SPLINT);
  36. ItemBase new_item = ItemBase.Cast(action_data.m_Player.GetInventory().CreateInInventory("Splint_Applied"));
  37. if ( new_item )
  38. {
  39. MiscGameplayFunctions.TransferItemProperties(action_data.m_MainItem,new_item,true,false,true);
  40. action_data.m_MainItem.Delete();
  41. }
  42. }
  43. }
  44. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  45. {
  46. if (player.GetBrokenLegs() != eBrokenLegs.BROKEN_LEGS || IsWearingSplint(player))
  47. {
  48. return false;
  49. }
  50. return super.ActionCondition(player, target, item);
  51. }
  52. bool IsWearingSplint( PlayerBase player )
  53. {
  54. if ( player.GetItemOnSlot("Splint_Right") )
  55. {
  56. return true;
  57. }
  58. return false;
  59. }
  60. };