Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionunpackbox.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.UNPACK);
6  }
7 };
8 
10 {
11  void ActionUnpackBox()
12  {
13  m_CallbackClass = ActionUnpackBoxCB;
14  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENITEM;
15  m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_OPENITEM;
17  m_Text = "#unbox";
18  }
19 
20  override void CreateConditionComponents()
21  {
24  }
25 
26  override bool HasProneException()
27  {
28  return true;
29  }
30 
31  override bool HasTarget()
32  {
33  return false;
34  }
35 
36  override void OnFinishProgressServer( ActionData action_data )
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;
43  array<string> resources = new array<string>;
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  {
55  resources.Insert( child_name );
56  }
57  }
58 
59  //TODO modify to allow for multiple ammo types spawning (if needed??)
60  string itemType = resources.Get(0);
61  int itemCount = GetGame().ConfigGetInt( path + " " + itemType + " value" );
62 
63  UnboxLambda lambda = new UnboxLambda(action_data.m_MainItem, itemType, action_data.m_Player, itemCount);
64  action_data.m_Player.ServerReplaceItemInHandsWithNew(lambda);
65 
66  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
67  }
68  }
69  }
70 };
71 
73 {
74  int m_ItemCount;
75  void UnboxLambda (EntityAI old_item, string new_item_type, PlayerBase player, int count) { m_ItemCount = count; }
76 
77  override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
78  {
79  super.CopyOldPropertiesToNew(old_item, new_item);
80 
81  if ( GetGame().ConfigIsExisting( "CfgMagazines " + m_NewItemType ) )
82  {
83  Magazine pile;
84  Class.CastTo(pile, new_item);
85  pile.ServerSetAmmoCount(m_ItemCount);
86  }
87  else
88  {
89  ItemBase unboxed;
90  Class.CastTo(unboxed, new_item);
91  unboxed.SetQuantity(m_ItemCount);
92  }
93  }
94 
95  override void OnSuccess(EntityAI new_item)
96  {
97  super.OnSuccess(new_item);
98 
99  //spawns wrapping Paper
100  ItemBase paper = ItemBase.Cast( GetGame().CreateObjectEx("Paper", new_item.GetHierarchyRoot().GetPosition(), ECE_PLACE_ON_SURFACE) );
101  }
102 };
103 
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
CAContinuousTime
Definition: cacontinuoustime.c:1
ActionUnpackBoxCB
Definition: actionunpackbox.c:1
UASoftSkillsWeight
Definition: actionconstants.c:118
ActionUnpackBox
Definition: actionunpackbox.c:9
CCTNone
Definition: cctnone.c:1
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
m_ItemCount
class SeedPackBase extends Inventory_Base m_ItemCount
UnboxLambda
Definition: actionunpackbox.c:72
PlayerBase
Definition: playerbaseclient.c:1
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
array< string >
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition: replaceitemwithnewlambdabase.c:4
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
EntityAI
Definition: building.c:5
path
string path
Definition: optionselectormultistate.c:135