actionuncoverheadself.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. class ActionUncoverHeadSelfCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.COVER_HEAD);
  6. }
  7. };
  8. class ActionUncoverHeadBase: ActionContinuousBase
  9. {
  10. void UncoverHead(PlayerBase target, PlayerBase source)
  11. {
  12. EntityAI attachment;
  13. if (Class.CastTo(attachment, target.GetInventory().FindAttachment(InventorySlots.HEADGEAR)) && attachment.GetType() == "BurlapSackCover")
  14. {
  15. ItemBase new_item = null;
  16. if (!source.GetHumanInventory().GetEntityInHands())
  17. {
  18. new_item = ItemBase.Cast(HumanInventory.Cast(source.GetInventory()).CreateInHands("BurlapSack"));
  19. }
  20. else
  21. {
  22. if (!Class.CastTo(new_item,source.GetInventory().CreateInInventory("BurlapSack")))//full inventory
  23. {
  24. vector m4[4];
  25. source.GetTransformWS(m4);
  26. InventoryLocation target_gnd = new InventoryLocation;
  27. target_gnd.SetGround(null, m4);
  28. new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(target_gnd, "BurlapSack",ECE_IN_INVENTORY,RF_DEFAULT));
  29. }
  30. }
  31. if (new_item)
  32. {
  33. MiscGameplayFunctions.TransferItemProperties(attachment,new_item,true,false,true);
  34. attachment.Delete();
  35. }
  36. }
  37. }
  38. }
  39. class ActionUncoverHeadSelf: ActionUncoverHeadBase
  40. {
  41. void ActionUncoverHeadSelf()
  42. {
  43. m_CallbackClass = ActionUncoverHeadSelfCB;
  44. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_COVERHEAD_SELF;
  45. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_PRONE;
  46. m_Text = "#uncover_head";
  47. }
  48. override void CreateConditionComponents()
  49. {
  50. m_ConditionItem = new CCINone;
  51. m_ConditionTarget = new CCTNone;
  52. }
  53. override bool HasTarget()
  54. {
  55. return false;
  56. }
  57. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  58. {
  59. if ( IsWearingBurlap(player) )
  60. return true;
  61. return false;
  62. }
  63. override void OnFinishProgressServer( ActionData action_data )
  64. {
  65. UncoverHead(action_data.m_Player, action_data.m_Player);
  66. }
  67. bool IsWearingBurlap( PlayerBase player )
  68. {
  69. EntityAI attachment;
  70. Class.CastTo(attachment, player.GetInventory().FindAttachment(InventorySlots.HEADGEAR));
  71. if ( attachment && attachment.IsInherited(BurlapSackCover) )
  72. {
  73. return true;
  74. }
  75. return false;
  76. }
  77. };