DayZ 1.24
Loading...
Searching...
No Matches
ActionUnpackBox.c
Go to the documentation of this file.
8
10{
12 {
14 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENITEM;
15 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_OPENITEM;
17 m_Text = "#unbox";
18 }
19
25
26 override bool HasProneException()
27 {
28 return true;
29 }
30
31 override bool HasTarget()
32 {
33 return false;
34 }
35
37 {
38 if (action_data.m_MainItem && action_data.m_MainItem.GetHierarchyRootPlayer() == action_data.m_Player)
39 {
40 string path = "CfgVehicles " + action_data.m_MainItem.GetType();
41 string child_name = "";
42 int count;
44
45 if (GetGame().ConfigIsExisting(path) && GetGame().ConfigIsExisting(path + " Resources"))
46 {
47 path = path + " Resources";
48 count = GetGame().ConfigGetChildrenCount(path);
49 for (int i = 0; i < count; i++)
50 {
51 GetGame().ConfigGetChildName(path, i, child_name);
52
53 if (GetGame().ConfigGetInt(path + " " + child_name + " value"))
54 resources.Insert(child_name);
55 }
56
57 //TODO modify to allow for multiple ammo types spawning (if needed??)
58 string itemType = resources.Get(0);
59 int itemCount = GetGame().ConfigGetInt(path + " " + itemType + " value");
60
61 UnboxLambda lambda = new UnboxLambda(action_data.m_MainItem, itemType, action_data.m_Player, itemCount);
62 action_data.m_Player.ServerReplaceItemInHandsWithNew(lambda);
63
64 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
65 }
66 }
67 }
68};
69
71{
74
76 {
77 super.CopyOldPropertiesToNew(old_item, new_item);
78
79 if (GetGame().ConfigIsExisting("CfgMagazines " + m_NewItemType))
80 {
83 pile.ServerSetAmmoCount(m_ItemCount);
84 }
85 else
86 {
89 unboxed.SetQuantity(m_ItemCount);
90 }
91 }
92
94 {
95 super.OnSuccess(new_item);
96
97 //spawns wrapping Paper
98 ItemBase paper = ItemBase.Cast(GetGame().CreateObjectEx("Paper", new_item.GetHierarchyRoot().GetPosition(), ECE_PLACE_ON_SURFACE));
99 }
100};
101
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
const int ECE_PLACE_ON_SURFACE
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
override void CreateActionComponent()
override void CreateConditionComponents()
override void OnFinishProgressServer(ActionData action_data)
override bool HasTarget()
override bool HasProneException()
Super root of all classes in Enforce script.
Definition EnScript.c:11
base class for transformation operations (creating one item from another)
const float UNPACK
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void OnSuccess(EntityAI new_item)
void UnboxLambda(EntityAI old_item, string new_item_type, PlayerBase player, int count)
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.