DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionPackGift.c
См. документацию.
2{
3 override void CreateActionComponent()
4 {
5 m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.UNPACK);
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;
17 m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
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 g_Game.GetInventoryItemSize( item_to_pack, x, y );
68
69 if( x > 5 || y > 5 )
70 return false;
71
72 return true;
73 }
74
75 override void OnFinishProgressClient( ActionData action_data )
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
84 override void OnFinishProgressServer( ActionData action_data )
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 g_Game.GetInventoryItemSize( item_to_pack, x, y );
95 int rnd = Math.RandomIntInclusive(1, 4);
96
98
99 if( x <= 2 && y <= 2 )
100 {
101 typeName = "GiftBox_Small_" + rnd;
102 }
103 else if( x <= 3 && y <= 3 )
104 {
105 typeName = "GiftBox_Medium_" + rnd;
106 }
107 else if( x <= 5 && y <= 5 )
108 {
109 typeName = "GiftBox_Large_" + rnd;
110 }
111 else return;
112
113
114 if (!g_Game.IsDedicatedServer())
115 {
116 player.RemoveQuickBarEntityShortcut(item_to_pack);
117 ClearInventoryReservationEx(action_data);
118 }
119 else
120 {
121 ClearActionJuncture(action_data);
122 }
123
124 lambda = new ReplaceWithNewReciveCargoLambda( item, typeName, player,item_to_pack);
125 player.ServerReplaceItemWithNew(lambda);
126
127 }
128
129
130 }
131};
132
134{
136 void ReplaceWithNewReciveCargoLambda(EntityAI old_item, string new_item_type, PlayerBase player, EntityAI item_to_cargo)
137 {
138 m_ItemToCargo = item_to_cargo;
139 }
140
141 override void OnSuccess(EntityAI new_item)
142 {
143 super.OnSuccess(new_item);
144
146 m_ItemToCargo.GetInventory().GetCurrentInventoryLocation(src);
148
149 dst.SetCargo(new_item, m_ItemToCargo, 0,0,0,false);
150
151 if ( dst.IsValid() )
152 {
153 if(g_Game.IsDedicatedServer())
154 m_Player.ServerTakeToDst(src,dst);
155 else
156 m_Player.LocalTakeToDst(src,dst);
157
158 }
159 }
160};
string m_Text
Определения ActionBase.c:57
ref CCIBase m_ConditionItem
Определения ActionBase.c:63
float m_SpecialtyWeight
Определения ActionBase.c:77
ref CCTBase m_ConditionTarget
Определения ActionBase.c:64
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1120
void ClearActionJuncture(ActionData action_data)
Определения ActionBase.c:1207
int m_StanceMask
Определения ActionBase.c:61
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
DayZGame g_Game
Определения DayZGame.c:4074
DayZPlayer m_Player
Определения Hand_Events.c:42
Icon x
Icon y
ActionData m_ActionData
Определения AnimatedActionBase.c:3
void ActionContinuousBase()
Определения ActionContinuousBase.c:124
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
ItemBase m_MainItem
Определения ActionBase.c:35
Определения ActionBase.c:22
override void OnFinishProgressClient(ActionData action_data)
Определения ActionPackGift.c:75
void ActionPackGift()
Определения ActionPackGift.c:11
override void CreateConditionComponents()
Определения ActionPackGift.c:21
override void OnFinishProgressServer(ActionData action_data)
Определения ActionPackGift.c:84
override bool HasTarget()
Определения ActionPackGift.c:27
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionPackGift.c:32
override void CreateActionComponent()
Определения ActionPackGift.c:3
Определения ActionPackGift.c:2
int m_CommandUID
Определения AnimatedActionBase.c:147
Определения Fence.c:2
Определения CCINonRuined.c:2
Определения CCTNonRuined.c:2
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)
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDetachAttachment(EntityAI parent)
Определения GardenLime.c:42
override bool CanRemoveFromCargo(EntityAI parent)
Определения BaseBuildingBase.c:920
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override bool IsTakeable()
Определения BaseBuildingBase.c:909
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
void ReplaceWithNewReciveCargoLambda(EntityAI old_item, string new_item_type, PlayerBase player, EntityAI item_to_cargo)
Определения ActionPackGift.c:136
override void OnSuccess(EntityAI new_item)
Определения ActionPackGift.c:141
EntityAI m_ItemToCargo
Определения ActionPackGift.c:135
const float UNPACK
Определения ActionConstants.c:86
Определения ActionConstants.c:28
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54