DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionTakeArrow.c
См. документацию.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
6 m_Text = "#take";
7 }
8
14
15 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
16 {
17 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
18 if (!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
19 return false;
20
21 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
22 if (arrowManager)
23 {
24 ItemBase arrow = ItemBase.Cast(arrowManager.GetFirstArrow());
25 if (arrow)
26 {
27 if (player.GetInventory().CanAddEntityIntoInventory(arrow))
28 return true;
29 }
30 }
31
32 return false;
33 }
34
36 {
37 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
38 if (!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
39 return null;
40
41 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
42 if (arrowManager)
43 {
44 return arrowManager.GetFirstArrow();
45 }
46
47 return null;
48 }
49
50 override bool CanBeUsedOnBack()
51 {
52 return false;
53 }
54
55 override bool InventoryReservation(ActionData action_data)
56 {
57 bool success = true;
58
60
61 EntityAI targetEntity;
62 if (EntityAI.CastTo(targetEntity, action_data.m_Target.GetObject()))
63 {
64 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
65 if (arrowManager)
66 {
67 ItemBase targetArrow = ItemBase.Cast(arrowManager.GetFirstArrow());
68 if (targetArrow)
69 {
70 action_data.m_Player.GetInventory().FindFreeLocationFor(targetArrow , FindInventoryLocationType.ANY, il);
71 if (action_data.m_Player.GetInventory().HasInventoryReservation(targetArrow, il))
72 {
73 success = false;
74 }
75 else
76 {
77 action_data.m_Player.GetInventory().AddInventoryReservationEx(targetArrow, il, GameInventory.c_InventoryReservationTimeoutMS);
78 }
79 }
80 }
81 }
82
83 if (success)
84 {
85 if (il)
86 action_data.m_ReservedInventoryLocations.Insert(il);
87 }
88
89 return success;
90 }
91
92
93 override void OnExecute(ActionData action_data)
94 {
95 if (GetGame().IsDedicatedServer())
96 {
97 ClearActionJuncture(action_data);
98 return;
99 }
100
101 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
102
103 ClearInventoryReservationEx(action_data);
104
105 ItemBase arrow = ItemBase.Cast(il.GetItem());
106 InventoryLocation arrowInventoryLocation = new InventoryLocation;
107 arrow.GetInventory().GetCurrentInventoryLocation(arrowInventoryLocation);
108
109 float stackable = arrow.GetTargetQuantityMax(il.GetSlot());
110
111 if ( stackable == 0 || stackable >= arrow.GetQuantity() )
112 {
113 action_data.m_Player.PredictiveTakeToDst(arrowInventoryLocation, il);
114 }
115 else
116 {
117 arrow.SplitIntoStackMaxToInventoryLocationClient( il );
118 }
119 }
120}
ActionBase ActionData
Определения ActionBase.c:30
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:121
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
void ClearActionJuncture(ActionData action_data)
Определения ActionBase.c:1122
string m_Text
Определения ActionBase.c:58
ref CCIBase m_ConditionItem
Определения ActionBase.c:64
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1061
ref CCTBase m_ConditionTarget
Определения ActionBase.c:65
override bool CanBeUsedOnBack()
Определения ActionTakeArrow.c:50
override void OnExecute(ActionData action_data)
Определения ActionTakeArrow.c:93
override bool InventoryReservation(ActionData action_data)
Определения ActionTakeArrow.c:55
void ActionTakeArrow()
Определения ActionTakeArrow.c:3
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionTakeArrow.c:15
override Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
Определения ActionTakeArrow.c:35
override void CreateConditionComponents()
Определения ActionTakeArrow.c:9
void ActionTakeItem()
Определения ActionTakeItem.c:10
int m_CommandUID
Определения AnimatedActionBase.c:143
EntityAI GetFirstArrow()
Определения ArrowManagerBase.c:82
Определения CCINone.c:2
Определения CCTObject.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
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
const float DEFAULT
Определения ActionConstants.c:112
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
proto native CGame GetGame()