DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionTakeItem.c
См. документацию.
1/*class ActionTakeItemReciveData : ActionReciveData
2{
3 ref InventoryLocation m_InventoryLocation;
4}*/
5
7{
8 string m_ItemName = "";
9
11 {
12 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_INVENTORY;
13 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_INVENTORY;
14 m_Text = "#take";
15 }
16
22
23 override bool HasProneException()
24 {
25 return true;
26 }
27
28 override bool ActionConditionContinue( ActionData action_data )
29 {
30 return true;
31 }
32
33 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
34 {
35 ItemBase tgtItem = ItemBase.Cast(target.GetObject());
36 if (tgtItem && !tgtItem.IsTakeable())
37 return false;
38 if (tgtItem && tgtItem.IsBeingPlaced())
39 return false;
40
41 EntityAI tgtParent = EntityAI.Cast(target.GetParent());
42 EntityAI tgtEntity = EntityAI.Cast(target.GetObject());
43
44 if (tgtEntity && (!tgtParent || tgtParent.CanUseConstruction()))
45 {
46 if (tgtEntity && tgtEntity.IsItemBase() && player.GetInventory().CanAddEntityIntoInventory(tgtEntity) && tgtEntity.GetHierarchyRootPlayer() != player)
47 {
48 if (tgtParent && (!tgtItem.CanDetachAttachment(tgtParent) || !tgtParent.CanReleaseAttachment(tgtItem)))
49 return false;
50
52 DigitalCodeLock codeLock = DigitalCodeLock.Cast(tgtItem);
53 if (codeLock && !codeLock.CanDetachCodeLock(player, target.GetComponentIndex()))
54 return false;
55
56 return true;
57 }
58 }
59 return false;
60 }
61
62 override bool CanBeUsedOnBack()
63 {
64 return true;
65 }
66
67 override bool InventoryReservation(ActionData action_data)
68 {
69 bool success = true;
70
72
73 ItemBase targetItem;
74 if ( ItemBase.CastTo(targetItem, action_data.m_Target.GetObject()) )
75 {
76 action_data.m_Player.GetInventory().FindFreeLocationFor( targetItem , FindInventoryLocationType.ANY, il );
77 if ( action_data.m_Player.GetInventory().HasInventoryReservation( targetItem, il) )
78 {
79 success = false;
80 }
81 else
82 {
83 action_data.m_Player.GetInventory().AddInventoryReservationEx( targetItem, il, GameInventory.c_InventoryReservationTimeoutMS);
84 }
85 }
86
87 if ( success )
88 {
89 if( il )
90 action_data.m_ReservedInventoryLocations.Insert(il);
91 }
92
93 return success;
94 }
95
96 override void OnExecute(ActionData action_data)
97 {
98 if (g_Game.IsDedicatedServer())
99 {
100 ClearActionJuncture(action_data);
101 return;
102 }
103
104 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
105 ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
106 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
107 InventoryLocation targetInventoryLocation = new InventoryLocation;
108 ntarget.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
109
110 ClearInventoryReservationEx(action_data);
111
112 //SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
113
114 float stackable = ntarget.GetTargetQuantityMax(il.GetSlot());
115
116 if( stackable == 0 || stackable >= ntarget.GetQuantity() )
117 {
118 action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
119 }
120 else
121 {
122 ClearInventoryReservationEx(action_data);
123 ntarget.SplitIntoStackMaxToInventoryLocationClient( il );
124 }
125
126 //action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
127 }
128};
string m_Text
Определения ActionBase.c:57
ref CCIBase m_ConditionItem
Определения ActionBase.c:63
ref CCTBase m_ConditionTarget
Определения ActionBase.c:64
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1120
void ClearActionJuncture(ActionData action_data)
Определения ActionBase.c:1207
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
DayZGame g_Game
Определения DayZGame.c:4074
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
ref array< ref InventoryLocation > m_ReservedInventoryLocations
Определения ActionBase.c:42
Определения ActionBase.c:22
void ActionInteractBase()
Определения ActionInteractBase.c:43
override bool HasProneException()
Определения ActionTakeItem.c:23
void ActionTakeItem()
Определения ActionTakeItem.c:10
override void CreateConditionComponents()
Определения ActionTakeItem.c:17
override bool CanBeUsedOnBack()
Определения ActionTakeItem.c:62
string m_ItemName
Определения ActionTakeItem.c:8
override bool ActionConditionContinue(ActionData action_data)
Определения ActionTakeItem.c:28
override bool InventoryReservation(ActionData action_data)
Определения ActionTakeItem.c:67
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionTakeItem.c:33
override void OnExecute(ActionData action_data)
Определения ActionTakeItem.c:96
int m_CommandUID
Определения AnimatedActionBase.c:147
int m_CommandUIDProne
Определения AnimatedActionBase.c:148
Определения CCINone.c:2
Определения CCTObject.c:2
bool CanDetachCodeLock(notnull PlayerBase player, int componentIndex)
Condition check called from ActionTakeItem and ActionTakeItemToHands.
Определения CodeLock.c:216
Определения CodeLock.c:2
const int c_InventoryReservationTimeoutMS
reservations
script counterpart to engine's class Inventory
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDetachAttachment(EntityAI parent)
Определения GardenLime.c:42
override bool IsTakeable()
Определения BaseBuildingBase.c:909
Определения PlayerBaseClient.c:2
const float DEFAULT
Определения ActionConstants.c:114
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602