DayZ 1.24
Loading...
Searching...
No Matches
ActionPackGift.c
Go to the documentation of this file.
8
10{
12 {
14 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENITEM;
15 //m_FullBody = true;
16 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
18 m_Text = "#STR_Wrap";
19 }
20
26
27 override bool HasTarget()
28 {
29 return true;
30 }
31
32 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
33 {
34 ItemBase item_to_pack = ItemBase.Cast(target.GetObject());
35 if (!item_to_pack)
36 return false;
37
38 if (!item_to_pack.IsTakeable()) return false;
39 if (item_to_pack.IsBeingPlaced()) return false;
40 if (BaseBuildingBase.Cast(item_to_pack)) return false;
41 if (!item_to_pack.CanPutInCargo(null)) return false;
42
43 EntityAI tgt_parent = EntityAI.Cast(target.GetParent());
44
45 if (tgt_parent)
46 {
47 if (item_to_pack.GetInventory().IsAttachment())
48 {
49 if (!item_to_pack.CanDetachAttachment(tgt_parent) || !tgt_parent.CanReleaseAttachment(item_to_pack))
50 return false;
51 }
52 else
53 {
54 if (!item_to_pack.CanRemoveFromCargo(tgt_parent) || !tgt_parent.CanReleaseCargo(item_to_pack))
55 return false;
56 }
57 }
58
59 if (item_to_pack.GetInventory().GetCargo() && item_to_pack.GetInventory().GetCargo().GetItemCount() > 0)
60 return false;
61
62 if (!item_to_pack.IsWeapon() && item_to_pack.GetInventory().AttachmentCount() > 0)
63 return false;
64
65
66 int x, y;
67 GetGame().GetInventoryItemSize(item_to_pack, x, y);
68
69 if (x > 5 || y > 5)
70 return false;
71
72 return true;
73 }
74
76 {
77 PlayerBase player = action_data.m_Player;
78 ItemBase item_to_pack = ItemBase.Cast(action_data.m_Target.GetObject());
79
80 player.RemoveQuickBarEntityShortcut(item_to_pack);
81
82 }
83
85 {
86 ItemBase item_to_pack = ItemBase.Cast(action_data.m_Target.GetObject());
87 ItemBase item = action_data.m_MainItem;
88 PlayerBase player = action_data.m_Player;
89 string typeName;
90
91 if (item_to_pack)
92 {
93 int x, y;
94 GetGame().GetInventoryItemSize(item_to_pack, x, y);
95 int rnd = Math.RandomIntInclusive(1, 4);
96
98
99 if (x <= 2 && y <= 2)
100 typeName = "GiftBox_Small_" + rnd;
101 else if (x <= 3 && y <= 3)
102 typeName = "GiftBox_Medium_" + rnd;
103 else if (x <= 5 && y <= 5)
104 typeName = "GiftBox_Large_" + rnd;
105 else return;
106
107
108 if (!GetGame().IsDedicatedServer())
109 player.RemoveQuickBarEntityShortcut(item_to_pack);
110
112 player.ServerReplaceItemWithNew(lambda);
113
114 }
115
116
117 }
118};
119
121{
127
129 {
130 super.OnSuccess(new_item);
131
133 m_ItemToCargo.GetInventory().GetCurrentInventoryLocation(src);
135
136 dst.SetCargo(new_item, m_ItemToCargo, 0, 0, 0, false);
137
138 if (dst.IsValid())
139 {
140 if (GetGame().IsDedicatedServer())
141 m_Player.ServerTakeToDst(src, dst);
142 else
143 m_Player.LocalTakeToDst(src, dst);
144
145 }
146 }
147};
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
DayZPlayer m_Player
Definition Hand_Events.c:42
Icon x
Icon y
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
override void CreateActionComponent()
override void OnFinishProgressClient(ActionData action_data)
override void CreateConditionComponents()
override void OnFinishProgressServer(ActionData action_data)
override bool HasTarget()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
InventoryLocation.
Definition EnMath.c:7
void ReplaceWithNewReciveCargoLambda(EntityAI old_item, string new_item_type, PlayerBase player, EntityAI item_to_cargo)
override void OnSuccess(EntityAI new_item)
const float UNPACK
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54