DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionPackGift.c
Go to the documentation of this file.
2{
3 override void CreateActionComponent()
4 {
6 }
7};
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
22 {
25 }
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
42 if ( !item_to_pack.CanPutInCargo(null) ) return false;
43
44
45 EntityAI tgt_parent = EntityAI.Cast( target.GetParent() );
46
47 if ( tgt_parent )
48 {
49 if ( item_to_pack.GetInventory().IsAttachment() )
50 {
51 if ( !item_to_pack.CanDetachAttachment(tgt_parent) || !tgt_parent.CanReleaseAttachment(item_to_pack) )
52 return false;
53 }
54 else
55 {
56 if ( !item_to_pack.CanRemoveFromCargo(tgt_parent) || !tgt_parent.CanReleaseCargo(item_to_pack) )
57 return false;
58 }
59 }
60
61 if ( item_to_pack.GetInventory().GetCargo() && item_to_pack.GetInventory().GetCargo().GetItemCount() > 0)
62 return false;
63
64 if ( !item_to_pack.IsWeapon() && item_to_pack.GetInventory().AttachmentCount() > 0)
65 return false;
66
67
68 int x,y;
69 GetGame().GetInventoryItemSize( item_to_pack, x, y );
70
71 if( x > 5 || y > 5 )
72 return false;
73
74 return true;
75 }
76
77 override void OnFinishProgressClient( ActionData action_data )
78 {
79 PlayerBase player = action_data.m_Player;
80 ItemBase item_to_pack = ItemBase.Cast(action_data.m_Target.GetObject());
81
82 player.RemoveQuickBarEntityShortcut(item_to_pack);
83
84 }
85
86 override void OnFinishProgressServer( ActionData action_data )
87 {
88 ItemBase item_to_pack = ItemBase.Cast(action_data.m_Target.GetObject());
89 ItemBase item = action_data.m_MainItem;
90 PlayerBase player = action_data.m_Player;
91 string typeName;
92
93 if (item_to_pack)
94 {
95 int x,y;
96 GetGame().GetInventoryItemSize( item_to_pack, x, y );
97 int rnd = Math.RandomIntInclusive(1, 4);
98
100
101 if( x <= 2 && y <= 2 )
102 {
103 typeName = "GiftBox_Small_" + rnd;
104 }
105 else if( x <= 3 && y <= 3 )
106 {
107 typeName = "GiftBox_Medium_" + rnd;
108 }
109 else if( x <= 5 && y <= 5 )
110 {
111 typeName = "GiftBox_Large_" + rnd;
112 }
113 else return;
114
115
116 if(!GetGame().IsDedicatedServer())
117 player.RemoveQuickBarEntityShortcut(item_to_pack);
118
119 lambda = new ReplaceWithNewReciveCargoLambda( item, typeName, player,item_to_pack);
120 player.ServerReplaceItemWithNew(lambda);
121
122 }
123
124
125 }
126};
127
129{
131 void ReplaceWithNewReciveCargoLambda(EntityAI old_item, string new_item_type, PlayerBase player, EntityAI item_to_cargo)
132 {
133 m_ItemToCargo = item_to_cargo;
134 }
135
136 override void OnSuccess(EntityAI new_item)
137 {
138 super.OnSuccess(new_item);
139
141 m_ItemToCargo.GetInventory().GetCurrentInventoryLocation(src);
143
144 dst.SetCargo(new_item, m_ItemToCargo, 0,0,0,false);
145
146 if ( dst.IsValid() )
147 {
148 if(GetGame().IsDedicatedServer())
149 m_Player.ServerTakeToDst(src,dst);
150 else
151 m_Player.LocalTakeToDst(src,dst);
152
153 }
154 }
155};
protected float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected string m_Text
Definition ActionBase.c:49
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
DayZPlayer m_Player
Definition Hand_Events.c:42
Icon x
Icon y
protected ActionData m_ActionData
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionTarget m_Target
Definition ActionBase.c:32
override void CreateActionComponent()
override void OnFinishProgressServer(ActionData action_data)
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnFinishProgressClient(ActionData action_data)
override bool HasTarget()
proto void GetInventoryItemSize(InventoryItem item, out int width, out int height)
InventoryLocation.
proto native bool IsValid()
verify current set inventory location
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
override bool CanPutInCargo(EntityAI parent)
Definition GardenBase.c:288
override bool CanRemoveFromCargo(EntityAI parent)
override bool IsTakeable()
override bool CanDetachAttachment(EntityAI parent)
Definition GardenLime.c:42
Definition EnMath.c:7
override void OnSuccess(EntityAI new_item)
void ReplaceWithNewReciveCargoLambda(EntityAI old_item, string new_item_type, PlayerBase player, EntityAI item_to_cargo)
const float UNPACK
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
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:53