actionsplinttarget.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. class ActionSplintTargetCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.APPLY_SPLINT);
  6. }
  7. };
  8. class ActionSplintTarget: ActionContinuousBase
  9. {
  10. void ActionSplintTarget()
  11. {
  12. m_CallbackClass = ActionSplintTargetCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_BANDAGETARGET;
  14. m_FullBody = true;
  15. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  16. m_Text = "#fix_persons_fracture";
  17. }
  18. override void CreateConditionComponents()
  19. {
  20. m_ConditionItem = new CCINonRuined;
  21. m_ConditionTarget = new CCTMan(UAMaxDistances.DEFAULT);
  22. }
  23. override void OnFinishProgressServer( ActionData action_data )
  24. {
  25. PlayerBase ntarget = PlayerBase.Cast( action_data.m_Target.GetObject() );
  26. if (CanReceiveAction(action_data.m_Target))
  27. {
  28. action_data.m_MainItem.TransferModifiers(ntarget);
  29. ntarget.ApplySplint();
  30. ItemBase new_item = ItemBase.Cast(ntarget.GetInventory().CreateInInventory("Splint_Applied"));
  31. if ( new_item )
  32. {
  33. MiscGameplayFunctions.TransferItemProperties(action_data.m_MainItem,new_item,true,false,true);
  34. action_data.m_MainItem.Delete();
  35. }
  36. ntarget.SetBrokenLegs(eBrokenLegs.BROKEN_LEGS_SPLINT);
  37. }
  38. }
  39. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  40. {
  41. PlayerBase ntarget = PlayerBase.Cast( target.GetObject() );
  42. if (ntarget.GetBrokenLegs() != eBrokenLegs.BROKEN_LEGS || IsWearingSplint(ntarget))
  43. {
  44. return false;
  45. }
  46. return super.ActionCondition(player, target, item);
  47. }
  48. bool IsWearingSplint( PlayerBase player )
  49. {
  50. if ( player.GetItemOnSlot("Splint_Right") )
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. };