actionunpackgift.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. class ActionUnpackGiftCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.UNPACK);
  6. }
  7. };
  8. class ActionUnpackGift: ActionContinuousBase
  9. {
  10. void ActionUnpackGift()
  11. {
  12. m_CallbackClass = ActionUnpackGiftCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENITEM;
  14. //m_FullBody = true;
  15. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  16. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  17. m_Text = "#STR_Unwrap";
  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 bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  29. {
  30. return true;
  31. }
  32. override void OnFinishProgressServer( ActionData action_data )
  33. {
  34. ItemBase item = ItemBase.Cast(action_data.m_MainItem);
  35. CargoBase cargo = item.GetInventory().GetCargo();
  36. InventoryLocation il_dst = new InventoryLocation;
  37. InventoryLocation il_src = new InventoryLocation;
  38. float dmg = item.GetHealth01("","");
  39. if( dmg > 0.25 )
  40. {
  41. Object paper = GetGame().CreateObjectEx("GiftWrapPaper",action_data.m_Player.GetPosition(),ECE_PLACE_ON_SURFACE,RF_DEFAULT);
  42. paper.SetHealth01("","", dmg - 0.25 );
  43. }
  44. for(int i = cargo.GetItemCount() - 1; i >= 0 ; i--)
  45. {
  46. EntityAI cargo_item = cargo.GetItem(i);
  47. GameInventory.SetGroundPosByOwner(action_data.m_Player,cargo_item,il_dst);
  48. cargo_item.GetInventory().GetCurrentInventoryLocation(il_src);
  49. if(GetGame().IsDedicatedServer())
  50. action_data.m_Player.ServerTakeToDst( il_src, il_dst );
  51. else
  52. action_data.m_Player.LocalTakeToDst( il_src, il_dst );
  53. }
  54. item.DeleteSafe();
  55. }
  56. };