actiongagself.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. class ActionGagSelf: ActionContinuousBase
  2. {
  3. void ActionGagSelf()
  4. {
  5. m_CallbackClass = ActionCoverHeadSelfCB;
  6. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_COVERHEAD_SELF;
  7. //m_FullBody = true;
  8. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  9. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  10. m_Text = "#gag_self";
  11. }
  12. override void CreateConditionComponents()
  13. {
  14. m_ConditionItem = new CCINonRuined;
  15. m_ConditionTarget = new CCTSelf;
  16. }
  17. override bool HasTarget()
  18. {
  19. return false;
  20. }
  21. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  22. {
  23. if (item.GetQuantity() > 1)
  24. return false;
  25. if ( !IsWearingMask(player) )
  26. {
  27. ItemBase headgear = ItemBase.Cast(player.FindAttachmentBySlotName( "Headgear" ));
  28. if ( headgear )
  29. {
  30. bool headgear_restricted;
  31. headgear_restricted = headgear.ConfigGetBool( "noMask" );
  32. if (headgear_restricted)
  33. {
  34. return false;
  35. }
  36. }
  37. return true;
  38. }
  39. return false;
  40. }
  41. override void OnFinishProgressServer( ActionData action_data )
  42. {
  43. ItemBase new_item;
  44. if (Class.CastTo(new_item,action_data.m_Player.GetInventory().CreateAttachmentEx("MouthRag",InventorySlots.MASK)))
  45. {
  46. MiscGameplayFunctions.TransferItemProperties(action_data.m_MainItem,new_item,true,false,true);
  47. action_data.m_MainItem.TransferModifiers(action_data.m_Player);
  48. action_data.m_MainItem.Delete();
  49. }
  50. }
  51. bool IsWearingMask( PlayerBase player)
  52. {
  53. if ( player.GetInventory().FindAttachment(InventorySlots.MASK) )
  54. {
  55. return true;
  56. }
  57. return false;
  58. }
  59. };